示例#1
0
        public IActionResult Login(LoginUserData loginUserData)
        {
            TokenResponse response;
            var           token = _loginJWT.Login(loginUserData);

            if (token != null)
            {
                response = new TokenResponse
                {
                    Success      = true,
                    ErrorMessage = "",
                    Data         = token
                };
            }
            else
            {
                response = new TokenResponse
                {
                    Success      = false,
                    ErrorMessage = "Invalid username or password.",
                    Data         = null
                };
            }
            return(Json(response));
        }
示例#2
0
        public void LogIn(LoginUserData data, Reactions reactions = null)
        {
            Thread logging = new Thread(() =>
            {
                if (!this.SendMessage("LOGIN", ("LoginData", data)))
                {
                    goto disconnection;
                }

                reactions?.RequestSentCallback?.Invoke();
                Message message = this.ReceiveMessage();
                if (message == null)
                {
                    goto disconnection;
                }
                reactions?.MessageReceivedCallback?.Invoke(message);
                if (message.Title == "SUCCESS")
                {
                    this.isAuthenticated             = true;
                    LadenEventArgs eventArgs         = new LadenEventArgs();
                    eventArgs.PayloadData["message"] = message;

                    this.Authenticated(this, eventArgs); //Thread.Sleep(10000);
                }
                return;

                disconnection: reactions?.DisconnectionErrorCallback?.Invoke();
            });

            logging.Start();
        }
示例#3
0
 public void LoginToAdslotPublisher(LoginUserData loginUserData)
 {
     OpenAndSwitchToNewWindow();
     driver.Navigate().GoToUrl(_publisherUrl);
     SetElementText(_txtUserName, loginUserData.Username);
     ClearInputAndTypeValue(_txtPassword, loginUserData.Password);
     ClickElement(_btnSubmit);
 }
示例#4
0
 public IHttpActionResult GetContacts([FromBody] LoginUserData loginUserData)
 {
     using (IDbConnection connection = base.ConnectionProvider.GetMySqlConnection())
     {
         IEnumerable <UserAccount> userContactList =
             service.GetContactListByUsernameAndPassword(connection, loginUserData.UserName,
                                                         loginUserData.Password);
         return(Ok(userContactList));
     }
 }
示例#5
0
 public IHttpActionResult Logout([FromBody] LoginUserData loginUserData)
 {
     using (IDbConnection connection = base.ConnectionProvider.GetMySqlConnection())
     {
         UserAccount loadedUserAccount = service.GetUserAccountByUsernameAndPassword(connection, loginUserData.UserName, loginUserData.Password);
         loadedUserAccount.UserAccountStatus = UserAccountStatus.Inactive;
         service.Update(connection, loadedUserAccount);
         return(Ok());
     }
 }
示例#6
0
 private void OnLogIn(LoginUserData data)
 {
     if (data != null)
     {
         UserController.Instance.LoginUser(data);
     }
     else
     {
         (Parent.Parent as RootPage).NavigateTo(MainMenuItemData.AgendaCongressoPage, false);
     }
 }
        public IRestRequest PostAuthentication(LoginUserData loginUserData)
        {
            var request = RequestFactory.GetRequest(Method.POST);

            request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
            request.AddHeader("Authorization", "Bearer VEVTVENMSUVOVDpVR0VrSkhkdg==");
            var bodyParameter = $"grant_type=password&username={loginUserData.Username.UrlEncode()}&password={loginUserData.Password.UrlEncode()}";

            request.AddParameter("application/x-www-form-urlencoded", bodyParameter, ParameterType.RequestBody);
            return(request);
        }
示例#8
0
        public LoginUserData InitiateRegistration()
        {
            LoginUserData userData = new LoginUserData();

            String  Test_Result = string.Empty;
            DataSet Data        = new DataSet();
            RegistrationQueueRequest request1 = new RegistrationQueueRequest();

            request1.Country      = "US";
            request1.AccountCRMId = "AC260915";
            request1.ProgramCode  = "BBB";
            request1.FirstName    = "Test";
            request1.LastName     = "Lastname";
            Random rr = new Random();

            request1.Email           = "SonilTest_" + rr.Next(99999999) + "@cebtestaccount2.com";
            request1.Title           = "Tester";
            request1.InvitationToken = null;
            request1.DestinationURL  = "www.cebtestaccount1.com";

            try
            {
                InitiateRegistrationRequest request_IRR = new InitiateRegistrationRequest();
                request_IRR.emailVariables      = obj;
                request_IRR.registrationRequest = request1;

                InitiateRegistrationResponse1 response_IRR = target.InitiateRegistration(request_IRR);
                InitiateRegistrationResponse  response     = response_IRR.InitiateRegistrationResult;
                RegistrationToken = response.RegistrationToken;

                //Call Complete Registration if Initiate Registration is successfully generated Registration Token
                string[] UserTokenDetails = new string[6];
                UserTokenDetails[0] = response.RegistrationToken;
                UserTokenDetails[1] = request1.AccountCRMId;
                UserTokenDetails[2] = request1.DestinationURL;
                UserTokenDetails[3] = request1.ProgramCode;
                UserTokenDetails[4] = request1.Email;
                string contactCrmId = string.Empty;
                bool   res          = CompleteRegistration_Valid(UserTokenDetails, userType, ref contactCrmId);
                if (res)
                {
                    userData.UserName     = request1.Email;
                    userData.Password     = "******";
                    userData.ContactCrmId = contactCrmId;
                }
            }

            catch (FaultException)
            {
                ////throw;
            }
            return(userData);
        }
示例#9
0
        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            try
            {
                LoginUserData staffData = StaffBiz.GetLoginUserData(Login1.UserName.Trim());

                if (staffData != null)
                //if (staffData != null && IsAuthenticated(Login1.UserName.Trim(), Login1.Password.Trim()))
                {
                    Guid sessionId = Guid.NewGuid();
                    LoginBiz.InsertSession(Login1.UserName.Trim(), sessionId);

                    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                        1,
                        Login1.UserName.Trim(),
                        DateTime.Now,
                        DateTime.Now.AddMinutes(FormsAuthentication.Timeout.TotalMinutes),
                        Login1.RememberMeSet,
                        staffData != null ? staffData.StaffNameTH + "|" + staffData.BranchName + "|" + sessionId.ToString() : _displayName + "|" + "",
                        FormsAuthentication.FormsCookiePath);

                    string encTicket = FormsAuthentication.Encrypt(ticket);
                    Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));
                    //Response.Redirect(FormsAuthentication.GetRedirectUrl(Login1.UserName, Login1.RememberMeSet), false);

                    InsertLoginLog(true, "");

                    if (Request["ticketid"] != null && Request["accflag"] == "email")
                    {
                        Response.Redirect("COC_SCR_003.aspx?ticketid=" + Request["ticketid"], false);
                    }
                    else
                    {
                        Response.Redirect(FormsAuthentication.DefaultUrl, false);
                    }
                }
                else
                {
                    InsertLoginLog(false, "Logon failure: unknown user name or bad password.");
                    _log.Debug("Logon failure: unknown user name or bad password.");
                    AppUtil.ClientAlert(Page, "Logon failure: unknown user name or bad password.");
                }
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;

                InsertLoginLog(false, message);
                _log.Debug("(" + Login1.UserName + ") " + message);
                AppUtil.ClientAlert(Page, "Logon failure: unknown user name or bad password.");
            }
        }
示例#10
0
 public IHttpActionResult GetChats([FromBody] LoginUserData loginUserData)
 {
     using (IDbConnection connection = base.ConnectionProvider.GetMySqlConnection())
     {
         IEnumerable <Chat> chats = chatService.GetChatsByUserAccount(connection, loginUserData.UserName, loginUserData.Password);
         foreach (Chat chat in chats)
         {
             chat.ChatMembers = new List <ChatMember>(chatMemberService.GetChatsMembersByChat(connection, chat.Id));
             //could also be loaded just if the chat is clicked (if there are a lot of chats available)
             chat.ChatMessages = new List <ChatMessage>(chatMessageService.GetChatsMessagesByChat(connection, chat.Id));
         }
         return(Ok(chats));
     }
 }
示例#11
0
        public string Login(LoginUserData loginUserData)
        {
            var identity = GetIdentity(loginUserData.Login, loginUserData.Password);
            var now      = DateTime.UtcNow;
            // создаем JWT-токен
            var jwt = new JwtSecurityToken(
                issuer: AuthOptions.ISSUER,
                audience: AuthOptions.AUDIENCE,
                notBefore: now,
                claims: identity.Claims,
                expires: now.Add(TimeSpan.FromMinutes(AuthOptions.LIFETIME)),
                signingCredentials: new SigningCredentials(_authOptions.GetSymmetricSecurityKey(), SecurityAlgorithms.HmacSha256));
            var encodedJwt = new JwtSecurityTokenHandler().WriteToken(jwt);

            return(encodedJwt);
        }
示例#12
0
        public void LoginToApplication(LoginUserData loginUserData)
        {
            if (IsOctopusVariable(loginUserData.Username) || IsOctopusVariable(loginUserData.Password))
            {
                throw new ArgumentException($"Errors in test data found: \n{loginUserData.Username} and/or {loginUserData.Password}");
            }

            SetElementText(_txtUserName, loginUserData.Username);
            SetElementText(_txtPassword, loginUserData.Password);

            var stopwatch = Stopwatch.StartNew();

            ClickElement(_btnSubmit);
            Assert.IsFalse(IsLoginFailed(), "Login failed. Username and/or password might be incorrect.");
            WaitForElementToBeClickable(By.XPath("//div[@class='avatar-component-initials']"));
            stopwatch.Stop();
            FeatureContext[ContextStrings.ElapsedTime] = stopwatch.Elapsed;
        }
        public bool LogIn(LoginUserData loginUserData)
        {
            bool valid = LoginDataMatch(loginUserData);

            if (valid)
            {
                if (this.client.Authenticated)
                {
                    MarkOffline();
                }
                this.client.Username = loginUserData.Username;
                this.MarkOnline();
                this.client.SendMessage("SUCCESS", ("description", "Successfully logged in"));
            }
            else
            {
                this.client.SendMessage("FAIL", ("description", "Username or password is incorrect"));
            }
            return(valid);
        }
示例#14
0
        ///// <summary>
        ///// Create new password for newly created user.
        ///// </summary>
        ///// <param name="request"></param>
        ///// <returns></returns>
        public static LoginUserData UpdatePassword(string userName, string password = null)
        {
            LoginUserData result = null;

            if (userName != null)
            {
                UpdatePasswordRequest  req = new UpdatePasswordRequest();
                UpdatePasswordResponse res = new UpdatePasswordResponse();
                req.username    = userName;
                req.oldPassword = password;
                req.newPassword = password + "_Update";
                res             = target4.UpdatePassword(req);

                if (res != null && res.UpdatePasswordResult != null && res.UpdatePasswordResult.ResponseCode == "VR")
                {
                    result          = new LoginUserData();
                    result.Password = req.newPassword;
                    result.UserName = userName;
                }
            }
            return(result);
        }
示例#15
0
        public void CreateCampaign(CampaignData campaignData, LoginUserData loginUserData, string token)
        {
            CampaignRequestModel model = new CampaignRequestModel
            {
                Name       = campaignData.DetailsData.CampaignName + DateTime.Now.ToString($"{SHORT_DATE_FORMAT} hh:mm:ss.fff tt"),
                StartDate  = string.IsNullOrEmpty(campaignData.DetailsData.StartDate) ? DateTime.Now.ToString(SHORT_DATE_FORMAT) : campaignData.DetailsData.StartDate,
                EndDate    = string.IsNullOrEmpty(campaignData.DetailsData.EndDate) ? DateTime.Now.AddDays(3).ToString(SHORT_DATE_FORMAT) : campaignData.DetailsData.EndDate,
                IsDeleted  = false,
                Advertiser = new AdvertiserRequestModel
                {
                    Id = campaignData.DetailsData.ClientId
                },
                Brand = new BrandRequestModel
                {
                    Name = campaignData.DetailsData.Product
                },
                AgencyContact = new AgencyContactRequestModel
                {
                    Email = loginUserData.Username
                }
            };

            new ApiExecutor(HttpStatusCode.Created).Execute <CampaignService>(s => s.PostCampaign(model, token));
        }
示例#16
0
        public void RegisterUserLinkedin(CreateUserData data, String serverImagePath)
        {
            var popTask = AppController.Instance.AppRootPage.CurrentPage.Navigation.PopModalAsync();

            popTask.ContinueWith((_pTask) =>
            {
                // AppController.Instance.AppRootPage.NavigateTo(MainMenuItemData.LoginPage, true);


                UserDialogs.Instance.ShowLoading(AppResources.LoadingCreatingUser);
                var registerTask = new RegisterUserBackgroundTask(data);
                registerTask.ContinueWith((task, result) =>
                {
                    UserDialogs.Instance.HideLoading();

                    if (task.Exception != null)
                    {
                        ServerException exception = (ServerException)task.Exception.InnerException;
                        var serverError           = JsonConvert.DeserializeObject <ServerError>(exception.ErrorMessage);

                        AppProvider.PopUpFactory.ShowMessage(serverError.ErrorMessage, AppResources.Warning);
                    }
                    else
                    {
                        LoginUserData lud = new LoginUserData();
                        lud.Email         = result.Email;
                        lud.Password      = result.Password;
                        LoginUser(lud);

                        //Device.BeginInvokeOnMainThread(() => AppController.Instance.AppRootPage.NavigateTo(MainMenuItemData.ProfilePage, true));
                        // () => AppController.Instance.AppRootPage.NavigateTo(MainMenuItemData.LoginPage, true, result.Email, result.Password));
                    }
                });
                _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(registerTask);
            });
        }
示例#17
0
        public static bool CompleteRegistration_Valid(String[] UserTokenDetails, string usertype, ref string ContactCrmId)
        {
            bool          IsCompleted = false;
            String        Test_Result = string.Empty;
            string        password    = "******";
            DataSet       Data        = new DataSet();
            LoginUserData userData    = new LoginUserData();

            CompleteRegistrationRequest request_CRR = new CompleteRegistrationRequest();

            request_CRR.emailVariables    = obj;
            request_CRR.password          = password;
            request_CRR.registrationToken = UserTokenDetails[0];
            CompleteRegistrationResponse1 response_CRR = target.CompleteRegistration(request_CRR);

            UnitTesting.Registration.CompleteRegistrationResponse response = response_CRR.CompleteRegistrationResult;
            if (response != null)
            {
                ContactCrmId = response.ContactCrmId;
                IsCompleted  = true;
            }

            return(IsCompleted);
        }
示例#18
0
        public void LoginUser(LoginUserData data)
        {
            UserDialogs.Instance.ShowLoading(AppResources.LoadingLoginUser);
            var loginTask = new LoginBackgroundTask(data);

            loginTask.ContinueWith((task, result) =>
            {
                if (task.Exception != null)
                {
                    ServerException exception = (ServerException)task.Exception.InnerException;

                    if (exception != null)
                    {
                        UserDialogs.Instance.HideLoading();
                        var serverError = JsonConvert.DeserializeObject <ServerError>(exception.ErrorMessage);
                        AppProvider.PopUpFactory.ShowMessage(serverError.ErrorMessage, AppResources.Warning);
                    }
                }
                else
                {
                    if (result != null)
                    {
                        UserDialogs.Instance.HideLoading();
                        Device.BeginInvokeOnMainThread(() => AppModel.Instance.LoginUser(result, data.Password));

                        /* TODO Ativar Push notification -  UserController - Login
                         * var getUserPushNotificationData = new DownloadPushNotificationsByUserBackgroundTask(
                         *  result.Id, AppModel.Instance.AppInformation.PushNotificationPlatform);
                         *
                         * getUserPushNotificationData.ContinueWith((getPushTask, getPushResult) =>
                         * {
                         *  if (getPushResult == null)
                         *  {
                         *      UserDialogs.Instance.HideLoading();
                         *      ShowServerError();
                         *  }
                         *  else
                         *  {
                         *      bool isUserHavePushForDevice = getPushResult.Find(temp => temp.UserId.Equals(result.Id) &&
                         *          temp.Token.Equals(AppModel.Instance.AppInformation.PushNotificationToken)) != null &&
                         *          getPushResult.Count > 0;
                         *
                         *      if (string.IsNullOrEmpty(AppModel.Instance.AppInformation.PushNotificationToken))
                         *      {
                         *          UserDialogs.Instance.HideLoading();
                         *          Device.BeginInvokeOnMainThread(() => AppModel.Instance.LoginUser(result, data.Password));
                         *      }
                         *      else if (isUserHavePushForDevice)
                         *      {
                         *          UserDialogs.Instance.HideLoading();
                         *          Device.BeginInvokeOnMainThread(() => AppModel.Instance.LoginUser(result, data.Password));
                         *      }
                         *      else
                         *      {
                         *          //check if current token is registered
                         *
                         *          string query = QueryBuilder.Instance.GetPushNotificationsByTokenQuery(
                         *              AppModel.Instance.AppInformation.PushNotificationToken,
                         *              AppModel.Instance.AppInformation.PushNotificationPlatform);
                         *
                         *          AppProvider.Log.WriteLine(LogChannel.All, query);
                         *          var getTokenPushNotificationData = new DownloadPushNotificationsByUserBackgroundTask(query);
                         *
                         *          getTokenPushNotificationData.ContinueWith((tokenTask, tokenResult) =>
                         *          {
                         *              if (tokenResult == null)
                         *              {
                         *                  UserDialogs.Instance.HideLoading();
                         *                  ShowServerError();
                         *              }
                         *              else
                         *              {
                         *                  bool isPost = tokenResult.Count == 0;
                         *                  string notifQuery = !isPost ? QueryBuilder.Instance.GetPutPushNotificationsQuery(tokenResult[0].Id) :
                         *                      QueryBuilder.Instance.GetPostPushNotificationsQuery();
                         *
                         *                  PushNotificationData pushData = new PushNotificationData(AppModel.Instance.AppInformation, result.Id);
                         *
                         *                  var pushNotificationTask = new PostPushNotificationsBackgroundTask(pushData, isPost, notifQuery);
                         *                  pushNotificationTask.ContinueWith((pushTask, pushTaskResult) =>
                         *                  {
                         *                      UserDialogs.Instance.HideLoading();
                         *                      Device.BeginInvokeOnMainThread(() => AppModel.Instance.LoginUser(result, data.Password));
                         *                  });
                         *                  _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(pushNotificationTask);
                         *              }
                         *          });
                         *          _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(getTokenPushNotificationData);
                         *      }
                         *  }
                         * });
                         * _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(getUserPushNotificationData);
                         */
                    }
                }
            });
            _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(loginTask);
        }
示例#19
0
 public LoginResponse(LoginStatusCode statusCode, LoginUserData userData)
 {
     StatusCode = statusCode;
     UserData   = userData;
 }
示例#20
0
        public ActionResult Index(LoginViewModel vm, string returnUrl)
        {
            LoggedInUser = null;
            DateTime?loginDateTime = null;

            if (ModelState.IsValid)
            {
                string username = vm.EmployeeNumber.Trim().ToUpper();
                string password = vm.Password.Trim();


                LdapHelper.LdapAuthResult ldapResult = null;

                //bypass user authentication in programming mode
                using (LdapHelper ldap = new LirrLdapHelper(false))
                //using (LdapHelper ldap = new LirrLdapHelper(true))
                {
                    ldapResult = ldap.Authenticate(
                        username: username,
                        password: password,
                        getUser: () =>
                    {
                        return(Dal.GetEmployeeByBsc(username));
                    });
                }


                if (!ldapResult.Valid)
                {
                    if (ldapResult.PasswordTimeToExpire.TotalSeconds < 0)
                    {
                        //Access BaseUI and show the reset password popup
                        vm.LoginErrorMessage = ldapResult.Message;
                        return(View(vm));
                    }
                    else
                    {
                        vm.LoginErrorMessage = ldapResult.Message;
                        return(View(vm));
                    }
                }

                if (vm.Date != null && vm.Time != null)
                {
                    loginDateTime = Helper.ConvertToDateTime(vm.Date, vm.Time);
                }
                else
                {
                    loginDateTime = DateTime.Now;
                }

                if (loginDateTime > DateTime.Now)
                {
                    vm.LoginErrorMessage = ("Login time cannot be in the future");
                    return(View(vm));
                }


                //// this is used to detect a session timeout and redirect the user to the login page
                //// See Global.asax.cs > Application_PreRequestHandlerExecute
                Session[SESSION_KEY_USED_TO_CHECK_SESSION_TIMEOUT] = DateTime.Now;

                FormsAuthentication.SetAuthCookie(vm.EmployeeNumber.ToUpper(), vm.KeepMeSignedIn);

                PasswordTimeToExpire = ldapResult.PasswordTimeToExpire;
                AppUser User = new AppUser()
                {
                    Username       = ldapResult.User.FullName,
                    EmployeeNumber = ldapResult.User.EmployeeNumber,
                    //LoggedInTime = DateTime.Now,
                    LoggedInTime      = (DateTime)loginDateTime,
                    BscEmployeeNumber = ldapResult.User.BscEmployeeNumber,
                    FirstName         = ldapResult.User.FirstName,
                    LastName          = ldapResult.User.LastName,
                    //JobDescription = ldapResult.User.JobCodeDescr,
                    JobDescription = ldapResult.User.JobDescription,
                    AgencyCode     = ldapResult.User.AgencyCode,
                    //below for testing only
                    //AgencyCode = "LIRR",
                    CraftCode = ldapResult.User.CraftCode
                };
                //Set the Logged in user session to Employee object in BaseController
                LoggedInUser = User;

                //string identityUsername = ldapResult.User.EmployeeNumber;
                string identityUsername = ldapResult.User.BscEmployeeNumber;

                //// log the user login event for auditing purposes
                Dal.SaveLoginInfo(username, Request.ServerVariables["REMOTE_HOST"]);

                DateTime      systemTimeUtc = DateTime.Now.ToUniversalTime();
                LoginUserData userData      = new LoginUserData
                {
                    SystemTimeUtcAtLogin = systemTimeUtc,
                    //LoginTimeUtc = systemTimeUtc,
                    LoginTimeUtc = loginDateTime.Value.ToUniversalTime(),
                };
                System.Web.HttpContext.Current.Session["UserLoginData"] = userData;

                HttpCookie cookie = CreateNewFormsAuthCookie(identityUsername, null);

                //// add cookie to response and redirect
                Response.Cookies.Add(cookie);

                _logger.Info("{0}: User Logged in Successfully", identityUsername);

                return(RedirectToAction("Index", "Home"));
            }
            return(View(vm));
        }
 public string GenerateAccessToken(LoginUserData loginUserData)
 {
     return(new ApiExecutor(HttpStatusCode.OK).Execute <AuthenticationService, AuthenticationResponseModel>(s => s.PostAuthentication(loginUserData)).Data.AccessToken);
 }
示例#22
0
        private void login_button_Click(object sender, EventArgs e)
        {
            /* if (DataServerDialog.Dialog.State != ConnectionState.Connected)
             * {
             *   MessageBox.Show("No connection!");
             * }
             * else if (DataServerDialog.Dialog.SendMessage("LOGIN", ("username", username_textbox.Text), ("password", password_textbox.Text)))
             * {
             *   Thread receiving = new Thread(() =>
             *   {
             *       this.Invoke((MethodInvoker)delegate
             *       {
             *           login_button.Text = "Connecting...";
             *           login_button.Enabled = false;
             *
             *           ReversiSerializableTypes.Message message = DataServerDialog.Dialog.ReceiveMessage();
             *
             *           login_button.Text = "Login";
             *           login_button.Enabled = true;
             *
             *           MessageBox.Show((string)message.Payload["description"], message.Title);
             *           if (message.Title == "SUCCESS")
             *           {
             *               DataServerDialog.Dialog.State = ConnectionState.Authenticated;
             *               this.Close();
             *           }
             *       });
             *
             *   });
             *   receiving.Start();
             * }*/
            void unmark_waiting()
            {
                this.login_button.Invoke((MethodInvoker)(() =>
                {
                    login_button.Text = "Login";
                    login_button.Enabled = true;
                    this.Cursor = Cursors.Default;
                }));
            }

            LoginUserData loginUserData = new LoginUserData()
            {
                Username = username_textbox.Text, Password = password_textbox.Text
            };

            Servers.DataServer.LogIn(loginUserData, new ServerDialog.Reactions
            {
                RequestSentCallback = () =>
                {
                    this.login_button.Invoke((MethodInvoker)(() =>
                    {
                        this.Cursor = Cursors.WaitCursor;
                        login_button.Text = "Waiting...";
                        login_button.Enabled = false;
                    }));
                },
                MessageReceivedCallback = (message) =>
                {
                    unmark_waiting();
                    this.Invoke((MethodInvoker)(() =>
                    {
                        //MessageBox.Show((string)message.Payload["description"], message.Title);
                        if (message.Title == "SUCCESS")
                        {
                            /* if (this.Owner is Menu) {
                             *   this.Owner.Invoke((MethodInvoker)(() =>
                             *   {
                             *       (this.Owner as Menu).Info.Text = (string)message.Payload["description"];
                             *       (this.Owner as Menu).Info.Show();
                             *   }));
                             * }*/
                            this.Close();
                        }
                        else
                        {
                            this.ShowInfo((string)message.Payload["description"]);
                            username_textbox.BackColor = Color.Tomato;
                            password_textbox.BackColor = Color.Tomato;
                        }
                    }));
                },
                DisconnectionErrorCallback = () =>
                {
                    unmark_waiting();

                    this.InvokeShowInfo("A connection error occured.");
                }
            });
        }
示例#23
0
 /// <summary>
 /// 更新LoginInfo
 /// </summary>
 /// <param name="logininfo"></param>
 public void UpdateLoginInfo(LoginUserData logininfo)
 {
     //if (this.Name == "login")
     CallContext_Parameter.LoginInfo = logininfo;
 }
示例#24
0
 public LoginBackgroundTask(LoginUserData data)
 {
     LoginData = data;
 }