Ejemplo n.º 1
0
        public static bool AutoReLogin()
        {
            try
            {
                if (Program.AASServiceClient != null)
                {
                    Program.AASServiceClient.Close();
                }
                Program.EndpointAddress = new EndpointAddress(new Uri(string.Format("net.tcp://{0}:{1}/", serverIPCache, Program.Port)), EndpointIdentity.CreateDnsIdentity("localhost"));

                Program.AASServiceClient = new AASServiceReference.AASServiceClient(Program.callbackInstance, Program.NetTcpBinding, Program.EndpointAddress);
                Program.AASServiceClient.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None;
                Program.AASServiceClient.ClientCredentials.UserName.UserName = userNameCache;
                Program.AASServiceClient.ClientCredentials.UserName.Password = passwordCache + "\t" + CommonUtils.GetMacAddress();
                Program.Current平台用户 = Program.AASServiceClient.QuerySingleUser(Program.Version)[0];
                return(true);
            }
            catch (System.ServiceModel.Security.MessageSecurityException)
            {
                //if (ex.InnerException == null)
                //{
                //    Program.logger.LogRunning("自动登录失败:{0}", ex.Message);
                //}
                //else
                //{
                //    Program.logger.LogRunning("自动登录失败:{0}", ex.InnerException.Message);
                //}
            }
            catch (Exception)
            {
                //Program.logger.LogRunning("自动登录失败:{0}", ex.Message);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public static bool AutoReLogin()
        {
            if (isConnectting)
            {
                return(false);
            }
            else
            {
                lock (sync)
                {
                    if (isConnectting)
                    {
                        return(false);
                    }
                    else
                    {
                        isConnectting = true;
                        try
                        {
                            if (Program.AASServiceClient != null)
                            {
                                Program.AASServiceClient.Close();
                            }
                            Program.EndpointAddress = new EndpointAddress(new Uri(string.Format("net.tcp://{0}:{1}/", serverIPCache, Program.Port)), EndpointIdentity.CreateDnsIdentity("localhost"));

                            Program.AASServiceClient = new AASServiceReference.AASServiceClient(Program.callbackInstance, Program.NetTcpBinding, Program.EndpointAddress);
                            Program.AASServiceClient.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None;
                            Program.AASServiceClient.ClientCredentials.UserName.UserName = userNameCache;
                            Program.AASServiceClient.ClientCredentials.UserName.Password = passwordCache + "\t" + CommonUtils.GetMacAddress();
                            Program.Current平台用户 = Program.AASServiceClient.QuerySingleUser(Program.Version)[0];
                            Program.AASServiceClient.FectchAllTable(Program.Current平台用户.用户名);
                            return(true);
                        }
                        catch (Exception) { }
                        return(false);
                    }
                }
            }
        }