private void comboBox用户名_SelectedIndexChanged(object sender, EventArgs e) { if (this.AppConfig.AppSettings.Settings.AllKeys.Contains(this.comboBox用户名.Text)) { string string1 = this.AppConfig.AppSettings.Settings[this.comboBox用户名.Text].Value; int k = string1.IndexOf(","); if (k < 0) { return; } if (!textBox服务器.ReadOnly) { this.textBox服务器.Text = string1.Substring(0, k); } this.textBox密码.Text = Cryptor.MD5Decrypt(string1.Substring(k + 1)); } else { this.textBox服务器.Text = string.Empty; this.textBox密码.Text = string.Empty; } if (isSelectServer) { SetServerSelectIndex(); } }
private void HqServerInit() { if (pubServerIPCache != string.Empty && CommonUtils.TelnetPort(pubServerIPCache, AASClient.TDFData.DataCache.ServerPort)) { AASClient.TDFData.DataCache.ServerIP = pubServerIPCache; } else { string ip = Program.AASServiceClient.GetDataServerIP(); if (string.IsNullOrEmpty(ip)) { TDFData.DataSourceConfig.IsUseTDFData = false; } else { if (ip.Contains(System.Environment.NewLine)) { string[] arr = ip.Split(new[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in arr) { if (CommonUtils.TelnetPort(item, AASClient.TDFData.DataCache.ServerPort)) { AASClient.TDFData.DataCache.ServerIP = item; if (this.AppConfig.AppSettings.Settings.AllKeys.Contains(pubServerName)) { if (item.Equals(Cryptor.MD5Decrypt(this.AppConfig.AppSettings.Settings[pubServerName].Value))) { break; } this.AppConfig.AppSettings.Settings[pubServerName].Value = Cryptor.MD5Encrypt(item); } else { this.AppConfig.AppSettings.Settings.Add(pubServerName, Cryptor.MD5Encrypt(item)); } this.AppConfig.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("appSettings"); break; } Thread.Sleep(100); } } else { if (CommonUtils.TelnetPort(ip, AASClient.TDFData.DataCache.ServerPort)) { AASClient.TDFData.DataCache.ServerIP = ip; } } } } if (AASClient.TDFData.DataCache.ServerIP == string.Empty) { TDFData.DataSourceConfig.IsUseTDFData = false; } }
//预警功能初始化 private static void PreWarningInit() { var strPreWarning = Program.accountDataSet.参数.GetParaValue("预警列表", string.Empty); if (!string.IsNullOrEmpty(strPreWarning)) { var str = Cryptor.MD5Decrypt(strPreWarning); Program.WarningFormulas = str.FromJSON <List <Model.WarningFormulaOne> >(); foreach (var item in Program.WarningFormulas) { Program.Warnings.TryAdd(item.ID, new System.Collections.Concurrent.ConcurrentQueue <Model.WarningEntity>()); } } }
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; } }
private void button登录_Click(object sender, EventArgs e) { try { if (textBox服务器.Text.Length == 0) { MessageBox.Show("请输入登陆服务器IP!"); return; } //string server = string.IsNullOrEmpty(serverIP) ? textBox服务器.Text : serverIP; Program.EndpointAddress = new EndpointAddress(new Uri(string.Format("net.tcp://{0}:{1}/", textBox服务器.Text, Program.Port)), EndpointIdentity.CreateDnsIdentity("localhost")); //if (Program.Port == "808") //{ //} //else //{ // Program.EndpointAddress = new EndpointAddress(new Uri(string.Format("net.tcp://{0}/", textBox服务器.Text)), EndpointIdentity.CreateDnsIdentity("localhost")); //} Program.AASServiceClient = new AASServiceReference.AASServiceClient(Program.callbackInstance, Program.NetTcpBinding, Program.EndpointAddress); //Program.EndpointAddress = new EndpointAddress(new Uri(string.Format("http://{0}/", server)), EndpointIdentity.CreateDnsIdentity("localhost")); //Program.AASServiceClient = new AASServiceReference.AASServiceClient(Program.callbackInstance, Program.WSDualHttpBinding, Program.EndpointAddress); Program.AASServiceClient.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None; Program.AASServiceClient.ClientCredentials.UserName.UserName = this.comboBox用户名.Text; Program.AASServiceClient.ClientCredentials.UserName.Password = this.textBox密码.Text + "\t" + this.MAC; Program.Current平台用户 = Program.AASServiceClient.QuerySingleUser(Program.Version)[0]; Program.LoginInfoCache(textBox服务器.Text, this.comboBox用户名.Text, this.textBox密码.Text); //优先获取缓存的分发服务器地址 //pubServerIPCache = "192.168.1.28"; if (pubServerIPCache != string.Empty && CommonUtils.TelnetPort(pubServerIPCache, AASClient.TDFData.DataCache.ServerPort)) { AASClient.TDFData.DataCache.ServerIP = pubServerIPCache; } else { string ip = Program.AASServiceClient.GetDataServerIP(); if (string.IsNullOrEmpty(ip)) { TDFData.DataSourceConfig.IsUseTDFData = false; } else { if (ip.Contains(System.Environment.NewLine)) { string[] arr = ip.Split(new[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in arr) { if (CommonUtils.TelnetPort(item, AASClient.TDFData.DataCache.ServerPort)) { AASClient.TDFData.DataCache.ServerIP = item; if (this.AppConfig.AppSettings.Settings.AllKeys.Contains(pubServerName)) { if (item.Equals(Cryptor.MD5Decrypt(this.AppConfig.AppSettings.Settings[pubServerName].Value))) { break; } this.AppConfig.AppSettings.Settings[pubServerName].Value = Cryptor.MD5Encrypt(item); } else { this.AppConfig.AppSettings.Settings.Add(pubServerName, Cryptor.MD5Encrypt(item)); } this.AppConfig.Save(ConfigurationSaveMode.Modified); System.Configuration.ConfigurationManager.RefreshSection("appSettings"); break; } Thread.Sleep(100); } } else { if (CommonUtils.TelnetPort(ip, AASClient.TDFData.DataCache.ServerPort)) { AASClient.TDFData.DataCache.ServerIP = ip; } } } } if (AASClient.TDFData.DataCache.ServerIP == string.Empty) { MessageBox.Show("行情服务器IP为空!"); TDFData.DataSourceConfig.IsUseTDFData = false; } //MessageBox.Show(AASClient.TDFData.DataCache.ServerIP); ICommunicationObject ICommunicationObject1 = Program.AASServiceClient as ICommunicationObject; ICommunicationObject1.Faulted += ICommunicationObject1_Faulted; ICommunicationObject1.Closed += ICommunicationObject1_Closed; if (this.checkBox记住密码.Checked) { if (this.AppConfig.AppSettings.Settings.AllKeys.Contains(this.comboBox用户名.Text)) { this.AppConfig.AppSettings.Settings[this.comboBox用户名.Text].Value = this.textBox服务器.Text + "," + Cryptor.MD5Encrypt(this.textBox密码.Text); } else { this.AppConfig.AppSettings.Settings.Add(this.comboBox用户名.Text, this.textBox服务器.Text + "," + Cryptor.MD5Encrypt(this.textBox密码.Text)); } this.AppConfig.Save(ConfigurationSaveMode.Modified); System.Configuration.ConfigurationManager.RefreshSection("appSettings"); } else { if (this.AppConfig.AppSettings.Settings.AllKeys.Contains(this.comboBox用户名.Text)) { this.AppConfig.AppSettings.Settings.Remove(this.comboBox用户名.Text); this.AppConfig.Save(ConfigurationSaveMode.Modified); System.Configuration.ConfigurationManager.RefreshSection("appSettings"); } } Directory.CreateDirectory(Program.Current平台用户.用户名); this.DialogResult = System.Windows.Forms.DialogResult.OK; } catch (MessageSecurityException ex) { if (ex.InnerException == null) { MessageBox.Show(ex.Message, "MessageSecurityException - InnerException"); } else { MessageBox.Show(ex.InnerException.Message, "MessageSecurityException"); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().Name); } }