Ejemplo n.º 1
0
        public void UpdateUi()
        {
            while (true)
            {
                try
                {
                    ServiceReference1.WebSDataBrCodeSoapClient BrServer = new ServiceReference1.WebSDataBrCodeSoapClient();
                    //BrServer.S = System.Web.Services.Protocols.SoapProtocolVersion.Soap12;
                    BrServer.Endpoint.Address = new System.ServiceModel.EndpointAddress(GetWebServiceURL);
                    ///Вот тут пилим авторизацию...
                    //if (BrServer.ClientCredentials != null)
                    //{
                    //    BrServer.ClientCredentials.UserName.UserName = Login;
                    //    BrServer.ClientCredentials.UserName.Password = pass;
                    //    BrServer.ClientCredentials.Windows.ClientCredential = new NetworkCredential(Login, pass);
                    //}

                    //  BrServer.ClientCredentials.Windows.ClientCredential = new NetworkCredential(Login, pass);
                    BrServer.ClientCredentials.UserName.UserName = Login;
                    BrServer.ClientCredentials.UserName.Password = pass;

                    _result = BrServer.GetLogTSD();


                    //GridViewLog.(new Action(() =>
                    //{
                    //    GridViewLog.DataContext = _result;
                    //}));
                    Dispatcher.Invoke(new Action(() =>
                    {
                        if (_result != null)
                        {
                            try
                            {
                                DataColumn colBack = new DataColumn("Background", typeof(SolidColorBrush));
                                _result.Columns.Add(colBack);
                            }

                            catch (Exception) { }

                            try
                            {
                                //Запилим проход
                                for (int i = 0; i < _result.Rows.Count; i++)
                                {
                                    string mac            = _result.Rows[i]["Mac"].ToString();
                                    string service        = _result.Rows[i]["SERVICE"].ToString();
                                    int indexF            = MacList.IndexOf(mac);
                                    SolidColorBrush Color = GetColor(indexF, mac, service);
                                    //

                                    _result.Rows[i]["Background"] = Color;
                                }
                            }

                            catch (Exception) { }
                        }

                        // SetOracleImage(false);
                        GridViewLog.DataContext = _result;
                        // GridViewLog.
                    }));


                    Dispatcher.Invoke(new Action(() =>
                    {
                        // SetOracleImage(false);
                        TextStatus.Text = DateTime.Now.ToString() + ": Запрос к серверу - Ок";
                        // GridViewLog.
                    }));


                    Thread.Sleep(2000);
                }

                catch (Exception ex)
                {
                    try
                    {
                        Dispatcher.Invoke(new Action(() =>
                        {
                            // SetOracleImage(false);
                            TextStatus.Text = DateTime.Now.ToString() + ": Запрос к серверу - Exc: " + ex.Message + "USER: " + Login;
                            // GridViewLog.
                        }));
                    }
                    catch (Exception) { }

                    Thread.Sleep(5000);
                }
            }
        }