~jbrejner/troja/jbrinit

« back to all changes in this revision

Viewing changes to ScriptGUI/BrtypesEqStreams.aspx.cs

  • Committer: jor
  • Date: 2009-05-28 09:02:17 UTC
  • Revision ID: svn-v4:93163c94-53e2-4789-836c-c47e9053d533:dock/Troja:13
Novo test installation 20090527 (VS2005)
no fogbugz

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using System.Data;
 
3
using System.Configuration;
 
4
using System.Collections;
 
5
using System.Web;
 
6
using System.Web.Security;
 
7
using System.Web.UI;
 
8
using System.Web.UI.WebControls;
 
9
using System.Web.UI.WebControls.WebParts;
 
10
using System.Web.UI.HtmlControls;
 
11
using System.Security.Principal;
 
12
 
 
13
namespace ScriptGUI
 
14
{
 
15
    public partial class BrtypesEqStreams1 : System.Web.UI.Page
 
16
    {
 
17
        private static readonly string CMDID = "troja_brtypes_eq_streams";
 
18
        private static TrojaWS proxy;
 
19
        private static string command = @"C:\Program Files\Rational\Common\ratlperl.exe";
 
20
        private static string arguments = @"\\appdkhi008\ClearCase\scripts\brtypes_eq_streams.pl \PDS_PVOB";
 
21
        private static EnvironmentVariable[] environment = null;
 
22
        private static bool merge = false;
 
23
        private static int to_hour = 0;
 
24
        private static int to_min = 5;
 
25
        private static int to_sec = 0;
 
26
 
 
27
        private int id;
 
28
        private string user;
 
29
        private string[] userall;
 
30
 
 
31
        protected void Page_Load(object sender, EventArgs e)
 
32
        {
 
33
            HeaderPlaceHolder.Controls.Add(Page.LoadControl("Header.ascx"));
 
34
            InitUser();
 
35
 
 
36
            if (proxy == null)
 
37
            {
 
38
                proxy = new TrojaWS();
 
39
            }
 
40
 
 
41
            if (Session[CMDID] == null)
 
42
            {
 
43
                try
 
44
                {
 
45
                    id = proxy.CreateCommand(userall, command, arguments, environment, merge, to_hour, to_min, to_sec);
 
46
                    Session[CMDID] = id;
 
47
                }
 
48
                catch (Exception ex)
 
49
                {
 
50
                    StdErrLabel.Text = ex.Message;
 
51
                }
 
52
            }
 
53
            else
 
54
            {
 
55
                id = (int)Session[CMDID];
 
56
            }
 
57
        }
 
58
 
 
59
        protected void TimerTick(object Sender, EventArgs e)
 
60
        {
 
61
            Snapshot snapshot = proxy.TakeSnapshot(user, id);
 
62
 
 
63
            StdOutLabel.Text = snapshot.StandardOutput.Replace("\n", "<br />");
 
64
            StdErrLabel.Text = snapshot.StandardError;
 
65
 
 
66
            if (snapshot.HasExited)
 
67
            {
 
68
                ExitValue.Text = "Exitcode: " + snapshot.ExitCode;
 
69
                Timer.Enabled = false;
 
70
            }
 
71
        }
 
72
 
 
73
        protected void ButtonClick(object Sender, EventArgs e)
 
74
        {
 
75
            Button.Enabled = false;
 
76
 
 
77
            proxy.StartAsync(user, id);
 
78
            Timer.Enabled = true;
 
79
        }
 
80
 
 
81
        private void InitUser()
 
82
        {
 
83
            user = WindowsIdentity.GetCurrent().Name.ToLower();
 
84
 
 
85
            IdentityReferenceCollection groups = WindowsIdentity.GetCurrent().Groups;
 
86
            userall = new string[1 + groups.Count];
 
87
 
 
88
            userall[0] = user;
 
89
 
 
90
            int i = 1;
 
91
            foreach (IdentityReference reference in groups)
 
92
            {
 
93
                userall[i] = ((NTAccount)reference.Translate(typeof(NTAccount))).Value.ToLower();
 
94
                i++;
 
95
            }
 
96
        }
 
97
    }
 
98
}