示例#1
0
文件: Form1.cs 项目: mil-oss/fgsms
        public Form1()
        {
            InitializeComponent();
            this.Resize += new EventHandler(Form1_Resize);
            notifyIcon1.DoubleClick += new EventHandler(notifyIcon1_DoubleClick);
            notifyIcon1.ContextMenuStrip = contextMenuStrip1;
            ConfigLoader cfg = new ConfigLoader();

            ss = cfg.GetSSProxy(cfg.SSurls[0], "FGSMSadmin", "P@$$Word1234567", null);
            t = new Thread(new ThreadStart(getStatusData));
            t.Start();
            this.FormClosing += new FormClosingEventHandler(Form1_FormClosing);
            listBox1.DrawItem += new DrawItemEventHandler(listBox1_DrawItem);
        }
示例#2
0
        public static statusServiceBinding GetSSProxy(string url, string username, string password, ConfigLoader.AuthMode authMode, string pkiinfo)
        {
            ServicePointManager.Expect100Continue = false;
            statusServiceBinding r = new statusServiceBinding();

            r.Url = url;
            switch (authMode)
            {
            case ConfigLoader.AuthMode.usernamePassword:
                r.Credentials = new NetworkCredential(username, (password));
                break;

            case ConfigLoader.AuthMode.PKI:
                r.ClientCertificates.Add(FindCert(pkiinfo));
                break;
            }
            return(r);
        }
示例#3
0
 /// <summary>
 /// This function will return a proxy to the Status service using the provided username and password
 /// OR if FGSMS is configured for PKI auth, the certinfo field will be used to search for a certificate
 /// </summary>
 /// <param name="url"></param>
 /// <param name="Myusername"></param>
 /// <param name="Mypassword"></param>
 /// <param name="certinfo"></param>
 /// <returns></returns>
 public statusServiceBinding GetSSProxy(string url, string Myusername, string Mypassword, string certinfo)
 {
     ServicePointManager.Expect100Continue = false;
     statusServiceBinding r = new statusServiceBinding();
     r.Url = url;
     switch (authMode)
     {
         case AuthMode.usernamePassword:
             r.Credentials = new NetworkCredential(Myusername, Mypassword);
             break;
         case AuthMode.PKI:
             r.ClientCertificates.Add(FindCert(certinfo));
             break;
     }
     return r;
 }
示例#4
0
        public override void RaiseCallbackEvent(string eventArgument)
        {
            statusServiceBinding ss = null;

            ajaxdata = "";
            try
            {
                ss = ProxyLoader.GetSSProxy(this.ssurl, username, password, authMode, pkiinfo);
                if (authMode == ConfigLoader.AuthMode.PKI)
                {
                    ss.useDoubleHopAuthWithPKI = true;
                    ss.actual_username         = HttpContext.Current.User.Identity.Name;
                }
                GetStatusRequestMsg req = new GetStatusRequestMsg();

                req.classification                = new SecurityWrapper();
                req.classification.caveats        = "none";
                req.classification.classification = ClassificationType.U;
                GetStatusResponseMsg[] res = ss.GetAllStatus(req);
                if (res != null && res != null && res.Length > 0)
                {
                    ajaxdata += "<table><th>Status</th><th>URI</th><th>Detail</th><th>Last Check In</th></tr>";
                    for (int i = 0; i < res.Length; i++)
                    {
                        TimeSpan ts = new TimeSpan(DateTime.Now.Ticks - res[i].TimeStamp.Ticks);
                        ajaxdata += "<tr><td>";
                        if (res[i].Operational)
                        {
                            if (ts.TotalHours > 1.0)
                            {
                                ajaxdata += "<img src=\"" + redlight + "\">";
                            }
                            else if (ts.TotalMinutes > 10)
                            {
                                ajaxdata += "<img src=\"" + orangelight + "\">";
                            }
                            else
                            {
                                ajaxdata += "<img src=\"" + greenlight + "\">";
                            }
                        }
                        else
                        {
                            ajaxdata += "<img src=\"" + redlight + "\">";
                        }
                        ajaxdata += "</td><td>";
                        ajaxdata += System.Web.HttpUtility.HtmlEncode(res[i].URI) +
                                    //"</td><td>" + (res.GetStatusResponseResult[i].Operational ? "OK" : "NG") +
                                    "</td><td>" + System.Web.HttpUtility.HtmlEncode(res[i].Message) +
                                    "</td><td>";

                        if (ts.TotalHours > 1.0)
                        {
                            ajaxdata += "<font color=\"red\">" +
                                        DurationToString(ts)// res.GetStatusResponseResult[i].TimeStamp.ToString("o")
                                        + "</font></td></tr>";
                        }
                        else if (ts.TotalMinutes > 10)
                        {
                            ajaxdata += "<font color=\"#FF7D40\">" +
                                        DurationToString(ts)//res.GetStatusResponseResult[i].TimeStamp.ToString("o")
                                        + "</font></td></tr>";
                        }
                        else
                        {
                            ajaxdata += DurationToString(ts) +
                                        //res.GetStatusResponseResult[i].TimeStamp.ToString("o") +
                                        "</td></tr>";
                        }
                    }
                    ajaxdata += "</table>";
                }
            }
            catch (Exception ex)
            {
                HandleError(ex, true);
            }
            finally
            {
            }
        }