private void AttemptLogin(LoginRequest LoginRequest, int attemptCount)
 {
     LoginWorker.SendLoginRequest(
         LoginRequest.UserName,
         LoginRequest.Password,
         successCallback : delegate(LoginResponse response)
     {
         Dispatcher.Invoke(new Action(delegate
         {
             Security.TokenManager.Token      = response.Token;
             Security.SessionManager.UserName = LoginRequest.UserName;
             labelWaitLogin.Content           = "正在获取用户信息";
             if (LoginRequest.UserName == "admin")
             {
                 getAllNewOrder();
             }
             else
             {
                 LoadUserInfo();
             }
         }));
     },
         failureCallback : delegate(string failureReason)
     {
         Dispatcher.Invoke(new Action(delegate
         {
             ResumeGUI();
             string failureReasonChinese = failureReason;
             if (failureReason == "UserNotRegistrated")
             {
                 failureReasonChinese = string.Format("您输入的手机号{0}尚未注册,请先注册。", LoginRequest.UserName);
             }
             if (failureReason == "PasswordIncorrect")
             {
                 failureReasonChinese = "您输入的密码错误,请重新输入";
             }
             MessageBox.Show("登录失败。" + failureReasonChinese, "", MessageBoxButton.OK, MessageBoxImage.Asterisk);
         }));
     },
         errorCallback : delegate(Exception ex)
     {
         if (attemptCount < 5)
         {
             attemptCount++;
             AttemptLogin(LoginRequest, attemptCount);
         }
         else
         {
             Dispatcher.Invoke(new Action(delegate
             {
                 ResumeGUI();
                 Util.ShowExceptionMessage(ex, "登录出错。");
             }));
         }
     });
 }
        public void LoginAndUpload()
        {
            MESPDownloadUpload.OrderId = MESPDownloadUpload.OrderNo = this._orderID;
            Upload();


            return;

            LungCare.SupportPlatform.Models.LoginRequest LoginRequest = new LungCare.SupportPlatform.Models.LoginRequest();
            LoginRequest.UserName = "******";
            LoginRequest.Password = "******";
            LoginRequest.Sender   = "PC Client";

            ThreadPool.QueueUserWorkItem(delegate
            {
                LoginWorker.SendLoginRequest(
                    LoginRequest.UserName,
                    LoginRequest.Password,
                    successCallback : delegate(LungCare.SupportPlatform.Models.LoginResponse response)
                {
                    //Dispatcher.Invoke(new Action(delegate
                    {
                        LungCare.SupportPlatform.Security.TokenManager.Token      = response.Token;
                        LungCare.SupportPlatform.Security.SessionManager.UserName = LoginRequest.UserName;
                        MESPDownloadUpload.UserId = "15261595318";
                        if (string.IsNullOrEmpty(_orderID))
                        {
                            MessageBox.Show("OrderID为空");
                        }
                        MESPDownloadUpload.OrderId = MESPDownloadUpload.OrderNo = this._orderID;
                        Upload();
                    }
                    //));
                },
                    failureCallback : delegate(string failureReason)
                {
                    //Dispatcher.Invoke(new Action(delegate
                    {
                        //MessageBox.Show("登录失败。" + failureReason, "", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Asterisk);
                    }
                    //));
                },
                    errorCallback : delegate(Exception ex)
                {
                    //Dispatcher.Invoke(new Action(delegate
                    {
                        Util.ShowExceptionMessage(ex, "登录出错。");
                    }
                    //));
                });
            });
        }
Exemple #3
0
        public void Login()
        {
            LungCare.SupportPlatform.Models.LoginRequest LoginRequest = new LungCare.SupportPlatform.Models.LoginRequest();
            LoginRequest.UserName = "******";
            LoginRequest.Password = "******";
            LoginRequest.Sender   = "PC Client";

            ThreadPool.QueueUserWorkItem(delegate
            {
                LoginWorker.SendLoginRequest(
                    LoginRequest.UserName,
                    LoginRequest.Password,
                    successCallback : delegate(LungCare.SupportPlatform.Models.LoginResponse response)
                {
                    //Dispatcher.Invoke(new Action(delegate
                    {
                        LungCare.SupportPlatform.Security.TokenManager.Token      = response.Token;
                        LungCare.SupportPlatform.Security.SessionManager.UserName = LoginRequest.UserName;


                        loadHandledData();
                    }
                    //));
                },
                    failureCallback : delegate(string failureReason)
                {
                    //Dispatcher.Invoke(new Action(delegate
                    {
                        //MessageBox.Show("登录失败。" + failureReason, "", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Asterisk);
                    }
                    //));
                },
                    errorCallback : delegate(Exception ex)
                {
                    //Dispatcher.Invoke(new Action(delegate
                    {
                        Util.ShowExceptionMessage(ex, "登录出错。");
                    }
                    //));
                });
            });
        }
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            LungCare.SupportPlatform.Models.LoginRequest LoginRequest = new LungCare.SupportPlatform.Models.LoginRequest();
            LoginRequest.UserName = tbUserName.Text;
            LoginRequest.Password = tbPassword.Text;
            LoginRequest.Sender   = "PC Client";

            ThreadPool.QueueUserWorkItem(delegate
            {
                LoginWorker.SendLoginRequest(
                    LoginRequest.UserName,
                    LoginRequest.Password,
                    successCallback : delegate(LungCare.SupportPlatform.Models.LoginResponse response)
                {
                    Dispatcher.Invoke(new Action(delegate
                    {
                        LungCare.SupportPlatform.Security.TokenManager.Token      = response.Token;
                        LungCare.SupportPlatform.Security.SessionManager.UserName = LoginRequest.UserName;

                        lbToken.Content = LungCare.SupportPlatform.Security.TokenManager.Token;

                        btn获取用户列表_Click(sender, e);
                        //NotificationsWorker.SendTest();
                    }));
                },
                    failureCallback : delegate(string failureReason)
                {
                    Dispatcher.Invoke(new Action(delegate
                    {
                        MessageBox.Show("登录失败。" + failureReason, "", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                    }));
                },
                    errorCallback : delegate(Exception ex)
                {
                    Dispatcher.Invoke(new Action(delegate
                    {
                        Util.ShowExceptionMessage(ex, "登录出错。");
                    }));
                });
            });
        }
        public void Login()
        {
            LungCare.SupportPlatform.Models.LoginRequest LoginRequest = new LungCare.SupportPlatform.Models.LoginRequest();
            LoginRequest.UserName = "******";
            LoginRequest.Password = "******";
            LoginRequest.Sender   = "PC Client";

            ThreadPool.QueueUserWorkItem(delegate
            {
                LoginWorker.SendLoginRequest(
                    LoginRequest.UserName,
                    LoginRequest.Password,
                    successCallback : delegate(LungCare.SupportPlatform.Models.LoginResponse response)
                {
                    //Dispatcher.Invoke(new Action(delegate
                    {
                        LungCare.SupportPlatform.Security.TokenManager.Token      = response.Token;
                        LungCare.SupportPlatform.Security.SessionManager.UserName = LoginRequest.UserName;


                        LungCare.SupportPlatform.UI.UploadProgressWnd upw = new LungCare.SupportPlatform.UI.UploadProgressWnd();
                        //upw.Owner = LungCare_Airway_PlanNav.MainWindow.Instance;

                        InstitutionName       = "Zhongshan Hospital,Fudan Univ.";
                        PatientName           = "Gan^ Fuming";
                        PatientAge            = "062Y";
                        PatientSex            = "M";
                        SeriesInstanceUID     = "1.2.840.113619.2.55.3.269126727.31.1438774442.877.3";
                        StudyInstanceUID      = "1.2.840.113619.2.55.3.269126727.31.1438774442.873";
                        acquisitionDate       = "20150807";
                        acquisitionTime       = "130902";
                        upw.FileName          = filename;
                        upw.InstitutionName   = InstitutionName;
                        upw.PatientAge        = PatientAge;
                        upw.PatientName       = PatientName;
                        upw.PatientSex        = PatientSex;
                        upw.SeriesInstanceUID = SeriesInstanceUID;
                        upw.StudyInstanceUID  = StudyInstanceUID;
                        upw.acquisitionDate   = acquisitionDate;
                        upw.acquisitionTime   = acquisitionTime;

                        upw.ShowDialog();
                    }
                    //));
                },
                    failureCallback : delegate(string failureReason)
                {
                    //Dispatcher.Invoke(new Action(delegate
                    {
                        //MessageBox.Show("登录失败。" + failureReason, "", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Asterisk);
                    }
                    //));
                },
                    errorCallback : delegate(Exception ex)
                {
                    //Dispatcher.Invoke(new Action(delegate
                    {
                        Util.ShowExceptionMessage(ex, "登录出错。");
                    }
                    //));
                });
            });
        }