예제 #1
0
        private void Init()
        {
            try
            {
                CommonUtils.Log("TdxApi.OpenTdx 开始 ");
                TdxApi.OpenTdx();
                CommonUtils.Log("TdxApi.OpenTdx 结束 ");
            }
            catch (Exception ex)
            {
                CommonUtils.Log("TdxApi.OpenTdx 异常 ", ex);
            }

            if (GroupDict == null)
            {
                CommonUtils.Log("4.Init Group Info");
                var client = new ServiceReference.DataWebServiceSoapClient();
                var group  = client.GetGroups(CommonUtils.UserName);

                GroupDict = group.FromJson <Dictionary <string, string> >();
                CommonUtils.Log("5.Group Count " + GroupDict.Keys.Count);
                if (GroupDict.Count > 0)
                {
                    cmbGroup.ItemsSource = GroupDict.Keys;
                }
            }

            animationTimer          = new DispatcherTimer(DispatcherPriority.ContextIdle, Dispatcher);
            animationTimer.Interval = new TimeSpan(0, 0, 1);
            animationTimer.Tick    += p_Tick;
            animationTimer.Start();
        }
예제 #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (CanLoginCount > 0)
            {
                var client = new ServiceReference.DataWebServiceSoapClient();
                client.InnerChannel.OperationTimeout = new TimeSpan(0, 0, 0, 3);

                var userName = Cryptor.MD5Encrypt(this.txtName.Text);
                var psw      = Cryptor.MD5Encrypt(this.psw.Password);
                try
                {
                    var isLoginSuccess = client.Login(userName, psw);
                    if (isLoginSuccess)
                    {
                        CommonUtils.UserName = userName;

                        if (ckbSavePsw.IsChecked == true)
                        {
                            CommonUtils.SetConfig("user", userName);
                            CommonUtils.SetConfig("password", psw);
                        }
                        else
                        {
                            CommonUtils.SetConfig("user", string.Empty);
                            CommonUtils.SetConfig("password", string.Empty);
                        }

                        IsLogon = true;
                        this.Close();
                    }
                    else
                    {
                        CommonUtils.SetConfig("info", Cryptor.MD5Encrypt(DateTime.Today.ToString() + "|" + (CanLoginCount - 1)));
                        MessageBox.Show("用户名或密码不正确!当前可用登录次数为:" + CanLoginCount);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("登录异常,Message " + ex.Message);
                }
            }
            else
            {
                if (CanLogon)
                {
                    MessageBox.Show("可用登录次数已耗尽,请联系管理员!");
                }
            }
        }