示例#1
0
        ///<summary>
        ///validate User Name and Password of user. -PS
        ///</summary>
        ///<param name="obj"></param>
        private void ValidateUser(object obj)
        {
            SettingHelpers.LocalizationDictionary = _posRepository.GetLanguageWiseLabels(int.Parse(Language));

            if (!String.IsNullOrEmpty(UserName) && !String.IsNullOrEmpty(((System.Windows.Controls.PasswordBox)(obj)).Password))
            {
                isAuthenticated             = false;
                SettingHelpers.IsCustomerPO = false;
                MerchantService.Repository.ApplicationClasses.LoginViewModel loginViewController = new MerchantService.Repository.ApplicationClasses.LoginViewModel();
                loginViewController.UserName = UserName;
                loginViewController.Password = ((System.Windows.Controls.PasswordBox)(obj)).Password;
                var user = _posRepository.ValidateLogin(loginViewController.UserName, loginViewController.Password);
                if (user != null)
                {
                    var userDetail = _posRepository.GetUserDetailByAspNetUserId(user.Id);
                    if (userDetail != null)
                    {
                        //Admin User.
                        if (userDetail.RoleId == 1)
                        {
                            // you are not authorized.
                            isAuthenticated = true;
                            return;
                        }
                        //get the Branch Detail object by BranchId
                        var branchDetail = _posRepository.GetBranchById(userDetail.BranchId.Value);
                        if (branchDetail != null)
                        {
                            Utility.SettingHelpers.CurrentBranchId = branchDetail.Id;
                            var rolepermissionResponse = _posRepository.GetRolPermissionByChildPermissionId((int)MerchantService.DomainModel.Enums.RolePermission.POSSystemLogin, branchDetail.CompanyId);
                            if (rolepermissionResponse != null && rolepermissionResponse.Any())
                            {
                                //update by ankit
                                bool validRole = false;
                                foreach (var role in rolepermissionResponse)
                                {
                                    if (userDetail.RoleId == role.RoleId)
                                    {
                                        validRole = true;
                                    }
                                }
                                if (validRole)
                                {
                                    SettingHelpers.IsReconciled = true;
                                    var companyDetail = _posRepository.GetCompanyConfigurationByCompanyId(branchDetail.CompanyId);
                                    if (companyDetail != null)
                                    {
                                        SettingHelpers.CompanyConfigruationObject        = companyDetail;
                                        SettingHelpers.BalanceBarcodeConfigurationObject = _posRepository.GetBalanceBarcodeConfiguration(companyDetail.CompanyId);
                                        var currencyResponse = _posRepository.GetAllCurrencyDetail();
                                        if (currencyResponse.Any())
                                        {
                                            CurrencyDetail currencyDetail = currencyResponse.Where(x => x.Id == companyDetail.CurrencyId).FirstOrDefault();
                                            SettingHelpers.CurrentCultureInfo     = new System.Globalization.CultureInfo(currencyDetail.CultureInfoValue);
                                            Thread.CurrentThread.CurrentUICulture = SettingHelpers.CurrentCultureInfo;
                                            Thread.CurrentThread.CurrentCulture   = SettingHelpers.CurrentCultureInfo;
                                        }
                                        // Get the Incident Report Data for Cashier by compan id.
                                        var reponseIncidentReport = _posRepository.GetIncidentReportList(branchDetail.CompanyId);
                                        SettingHelpers.OperationIncidentReport = reponseIncidentReport;
                                    }
                                    Utility.SettingHelpers.CurrentUserId = userDetail.Id;
                                    BackgroundWorker bgCheckUserSession = new BackgroundWorker();
                                    bgCheckUserSession.DoWork             += bgCheckUserSession_DoWork;
                                    bgCheckUserSession.RunWorkerCompleted += bgCheckUserSession_RunWorkerCompleted;
                                    bgCheckUserSession.RunWorkerAsync();
                                }
                                else
                                {
                                    // not Authorized
                                    IsBusy          = false;
                                    isAuthenticated = true;
                                }
                            }
                            else
                            {
                                //not Authorized
                                IsBusy          = false;
                                isAuthenticated = true;
                            }
                        }
                        else
                        {
                            // User not Exists.
                            IsBusy          = false;
                            isAuthenticated = true;
                        }
                    }
                    else
                    {
                        // User not Exists.
                        IsBusy          = false;
                        isAuthenticated = true;
                    }
                }
                else
                {
                    //User not Exists.
                    IsBusy          = false;
                    isAuthenticated = true;
                    _loginScreen.txtUserName.Focus();
                }
            }
            else
            {
                IsBusy          = false;
                isAuthenticated = true;
                _loginScreen.txtUserName.Focus();
            }
        }
示例#2
0
        public void SubmitButtonCommand(object obj)
        {
            if (!String.IsNullOrEmpty(UserName) && !String.IsNullOrEmpty(((System.Windows.Controls.PasswordBox)(obj)).Password))
            {
                ErrorMessage = string.Empty;
                MerchantService.Repository.ApplicationClasses.LoginViewModel loginViewController = new MerchantService.Repository.ApplicationClasses.LoginViewModel();
                loginViewController.UserName = UserName;
                loginViewController.Password = ((System.Windows.Controls.PasswordBox)(obj)).Password;
                string jsonString  = JsonConvert.SerializeObject(loginViewController);
                var    httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json");

                var user = _posRepository.ValidateLogin(loginViewController.UserName, loginViewController.Password);
                if (user != null)
                {
                    var userDetail = _posRepository.GetUserDetailByAspNetUserId(user.Id);
                    if (userDetail != null)
                    {
                        //Admin User.
                        if (userDetail.RoleId == 1)
                        {
                            //you are not authorized.
                            ErrorMessage = StringConstants.InvalidUser;
                            return;
                        }

                        //get the Branch Detail object by BranchId

                        var branchDetail = _posRepository.GetBranchById(userDetail.BranchId.Value);
                        if (branchDetail != null)
                        {
                            Utility.SettingHelpers.CurrentBranchId = branchDetail.Id;
                            var rolePermissionObj = _posRepository.GetRolPermissionByChildPermissionId((int)MerchantService.DomainModel.Enums.RolePermission.UnRegisterItem, branchDetail.CompanyId);
                            if (rolePermissionObj != null && rolePermissionObj.Any())
                            {
                                bool validRole = false;
                                foreach (var role in rolePermissionObj)
                                {
                                    if (role.RoleId == userDetail.RoleId)
                                    {
                                        validRole = true;
                                    }
                                }

                                if (validRole)
                                {
                                    if (SettingHelpers.IsUnRegisteredItem)
                                    {
                                        //Open Item
                                        AddItem addItem = new AddItem(_supervisorLogin);
                                        addItem.Owner = _supervisorLogin;
                                        var result = addItem.ShowDialog();
                                        if (result == true)
                                        {
                                            SettingHelpers.IsUnRegisteredItem = false;
                                            _supervisorLogin.DialogResult     = true;
                                            _supervisorLogin.Close();
                                        }
                                    }
                                    if (SettingHelpers.IsOverQuantityItem)
                                    {
                                        SettingHelpers.IsOverQuantityItem = false;
                                        _supervisorLogin.DialogResult     = true;
                                        _supervisorLogin.Close();
                                    }
                                    if (SettingHelpers.IsInActiveItem)
                                    {
                                        SettingHelpers.IsInActiveItem = false;
                                        _supervisorLogin.DialogResult = true;
                                        _supervisorLogin.Close();
                                    }
                                    if (SettingHelpers.IsManageIncidentReport)
                                    {
                                        SettingHelpers.IsManageIncidentReport = false;
                                        _supervisorLogin.DialogResult         = true;
                                        _supervisorLogin.Close();
                                    }
                                }
                                else
                                {
                                    //not Authorized
                                    ErrorMessage = StringConstants.InvalidUser;
                                }
                            }
                            else
                            {
                                //not Authorized
                                ErrorMessage = StringConstants.InvalidUser;
                            }
                        }
                    }
                    else
                    {
                        //User not Exists.
                        ErrorMessage = StringConstants.InvalidUser;
                    }
                }
                else
                {
                    //User not Exists.
                    ErrorMessage = StringConstants.InvalidUser;
                    _supervisorLogin.txtUserName.Focus();
                }
            }
            else
            {
                ErrorMessage = StringConstants.InvalidUser;
                _supervisorLogin.txtUserName.Focus();
            }
        }