Example #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);
        }
Example #2
0
        private void LoginForm_Load(object sender, EventArgs e)
        {
            if (Program.IsSinglePoint)
            {
                this.Text = string.Format("登录 [版本号: {0}]", Program.Version);
            }
            else
            {
                this.Text = string.Format("登录 [版本号: {0}_M]", Program.Version);
            }

            List <string> userName = new List <string>();

            foreach (var user in this.AppConfig.AppSettings.Settings.AllKeys)
            {
                if (!user.Equals(pubServerName))
                {
                    userName.Add(user);
                }
                else
                {
                    pubServerIPCache = Cryptor.MD5Decrypt(this.AppConfig.AppSettings.Settings[pubServerName].Value);
                }
            }
            this.comboBox用户名.DataSource = userName;

            this.MAC = CommonUtils.GetMacAddress();

            if (!string.IsNullOrEmpty(serverIP))
            {
                this.label3.Visible      = false;
                this.textBox服务器.Visible  = false;
                this.textBox服务器.ReadOnly = true;
                this.textBox服务器.Text     = serverIP;
                foreach (var item in ServerIPDict)
                {
                    if (item.Value.Contains(serverIP))
                    {
                        if (Program.IsSinglePoint)
                        {
                            this.Text = string.Format("{0} [版本号: {1}]", item.Key, Program.Version);
                        }
                        else
                        {
                            this.Text = string.Format("{0} [版本号: {1}_M]", item.Key, Program.Version);
                        }
                    }
                }
            }

            if (isSelectServer)
            {
                foreach (var item in ServerIPDict.Values)
                {
                    comboBoxServer.Items.Add(item);
                }
                comboBoxServer.Left  = textBox服务器.Left;
                comboBoxServer.Width = textBox服务器.Width;
                SetServerSelectIndex();
                //textBox服务器.Visible = false;
            }
            else
            {
                comboBoxServer.Visible = false;
            }
        }
Example #3
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);
                    }
                }
            }
        }