示例#1
0
        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();
            }
        }
示例#2
0
        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;
            }
        }
示例#3
0
        //预警功能初始化
        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>());
                }
            }
        }
示例#4
0
        private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var item = this.bindingSourceSettings.Current as Model.WarningFormulaOne;

            Program.WarningFormulas.Remove(item);

            var strPreWarning = Cryptor.MD5Encrypt(Program.WarningFormulas.ToJSON());

            Program.accountDataSet.参数.SetParaValue("预警列表", strPreWarning);

            this.bindingSourceSettings.DataSource = Program.WarningFormulas.ToList <Model.IWarningFormula>();
            if (Program.fmPreWarnings != null)
            {
                for (int i = 0; i < Program.fmPreWarnings.Count; i++)
                {
                    var fm = Program.fmPreWarnings[i];
                    if (fm != null && fm.Formula.ID == item.ID && !fm.IsDisposed)
                    {
                        Program.fmPreWarnings.Remove(fm);
                        fm.Close();
                    }
                }
            }
        }
示例#5
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;
            }
        }
示例#6
0
        private void Login()
        {
            if (textBox服务器.Text.Length == 0)
            {
                MessageBox.Show("请输入登陆服务器IP!");
                return;
            }
            button登录.Text    = "登录中……";
            button登录.Enabled = false;
            string serverIP = textBox服务器.Text;
            string user     = this.comboBox用户名.Text;
            string psw      = this.textBox密码.Text + "\t" + this.MAC;
            string uri      = string.Format("net.tcp://{0}/", serverIP.Contains(":") ? serverIP : (serverIP + ":" + Program.Port));


            Task.Run(() =>
            {
                try
                {
                    Program.EndpointAddress  = new EndpointAddress(new Uri(uri), EndpointIdentity.CreateDnsIdentity("localhost"));
                    Program.AASServiceClient = new AASServiceClient(Program.callbackInstance, Program.NetTcpBinding, Program.EndpointAddress);
                    Program.AASServiceClient.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
                    Program.AASServiceClient.ClientCredentials.UserName.UserName = user;
                    Program.AASServiceClient.ClientCredentials.UserName.Password = psw;
                    var result = Program.AASServiceClient.QuerySingleUser(Program.Version);

                    Program.Current平台用户 = result[0];

                    Program.LoginInfoCache(serverIP, user, psw);

                    HqServerInit();


                    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(user))
                        {
                            this.AppConfig.AppSettings.Settings[user].Value = serverIP + "," + Cryptor.MD5Encrypt(psw);
                        }
                        else
                        {
                            this.AppConfig.AppSettings.Settings.Add(user, serverIP + "," + Cryptor.MD5Encrypt(psw));
                        }
                        this.AppConfig.Save(ConfigurationSaveMode.Modified);
                        ConfigurationManager.RefreshSection("appSettings");
                    }
                    else
                    {
                        if (this.AppConfig.AppSettings.Settings.AllKeys.Contains(user))
                        {
                            this.AppConfig.AppSettings.Settings.Remove(user);
                            this.AppConfig.Save(ConfigurationSaveMode.Modified);
                            ConfigurationManager.RefreshSection("appSettings");
                        }
                    }

                    Directory.CreateDirectory(Program.Current平台用户.用户名);

                    this.DialogResult = DialogResult.OK;
                }
                catch (MessageSecurityException ex)
                {
                    if (ex.InnerException == null)
                    {
                        this.Invoke(new Action(() => { MessageBox.Show(ex.Message, "MessageSecurityException - InnerException"); }));
                    }
                    else
                    {
                        this.Invoke(new Action(() => { MessageBox.Show(ex.InnerException.Message, "MessageSecurityException"); }));
                    }
                }
                catch (Exception ex)
                {
                    this.Invoke(new Action(() => { MessageBox.Show(ex.Message, ex.GetType().Name); }));
                }

                button登录.BeginInvoke(new Action(() =>
                {
                    button登录.Enabled = true;
                    button登录.Text    = "登录";
                }));
            });
        }
示例#7
0
        private void button登录_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox服务器.Text.Length == 0)
                {
                    MessageBox.Show("请输入登陆服务器IP!");
                    return;
                }

                Program.EndpointAddress = new EndpointAddress(new Uri(string.Format("net.tcp://{0}:{1}/", textBox服务器.Text, 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 = 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);

                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);
            }
        }
示例#8
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            Model.WarningFormulaOne entity = this.Formula ?? new Model.WarningFormulaOne()
            {
                ID = Guid.NewGuid().ToString()
            };

            if (comboBoxCodesType.SelectedIndex != 0)
            {
                entity.IsSubAll = false;
                List <string> codes = GetCodes();
                if (codes.Count < 1)
                {
                    rtbCodes.Focus();
                    MessageBox.Show("预警列表不能为空。");
                    return;
                }

                entity.CodeList = codes;
            }
            else
            {
                entity.IsSubAll = true;
                entity.CodeList = new List <string>();
            }

            var s1 = comboBox1.SelectedItem.ToString();

            entity.FirstSetting = new Model.BidAskItem()
            {
                Index = GetIndex(s1), Direction = GetDerection(s1)
            };

            var s2 = comboBox2.SelectedItem.ToString();

            entity.SecondSetting = new Model.BidAskItem()
            {
                Index = GetIndex(s2), Direction = GetDerection(s2)
            };

            var s3 = comboBox3.SelectedItem.ToString();

            entity.ThirdSetting = new Model.BidAskItem()
            {
                Index = GetIndex(s3), Direction = GetDerection(s3)
            };

            entity.Param = this.numericUpDownParam.Value;

            entity.CompareTypeInfo = (Model.CompareType)comboBoxCompare.SelectedIndex;

            entity.Level = (Model.WarningLevel)comboBoxLevel.SelectedIndex;

            entity.LargeVolume = this.numericUpDownBig.Value;

            entity.ParamCalType = (Model.CalculateType)comboBoxCalType.SelectedIndex;

            entity.Frequency = this.numericUpDownFrequency.Value;

            if (!Program.WarningFormulas.Contains(entity))
            {
                Program.WarningFormulas.Add(entity);
            }

            var strPreWarning = Cryptor.MD5Encrypt(Program.WarningFormulas.ToJSON());

            Program.accountDataSet.参数.SetParaValue("预警列表", strPreWarning);
            if (this.Formula == null)
            {
                var fm = new PrewarningShowForm(entity);
                fm.Show();

                if (Program.fmPreWarnings == null)
                {
                    Program.fmPreWarnings = new List <PrewarningShowForm>();
                }
                Program.fmPreWarnings.Add(fm);
            }
            this.Close();
        }
示例#9
0
        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);
            }
        }