示例#1
0
        void Settlement_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(GlobalClass.TConnectionString))
                {
                    if (e.PropertyName == "TRNDATE")
                    {
                        SettlementList = new ObservableCollection <CashSettlement>(
                            conn.Query <CashSettlement>(
                                string.Format("SELECT SETTLEMENT_ID, TRNDATE, AMOUNT, TERMINAL_CODE, SETTLED_UID, TRNTIME, SETTLER_UID, POST FROM CashSettlement WHERE TRNDATE = '{0}'", Settlement.TRNDATE.ToString("MM/dd/yyyy"))
                                ));
                        foreach (CashSettlement cs in SettlementList)
                        {
                            cs.Terminal     = TerminalList.First(x => x.TERMINAL_CODE == cs.TERMINAL_CODE);
                            cs.Settled_User = UserList.First(x => x.UID == cs.SETTLED_UID);
                            cs.Settler_User = UserList.First(x => x.UID == cs.SETTLER_UID);
                        }
                        if (SettlementList.Count > 0)
                        {
                            SettlementList.Add(new CashSettlement {
                                Settler_User = new User {
                                    UserName = "******"
                                }, AMOUNT = SettlementList.Sum(x => x.AMOUNT)
                            });
                        }
                    }
                    else if (e.PropertyName == "SETTLED_UID" || e.PropertyName == "TERMINAL_CODE")
                    {
                        string strSql = string.Empty;
                        switch (GlobalClass.SettlementMode)
                        {
                        case 0:     // Userwise Settlement
                            strSql = string.Format("SELECT ISNULL(SUM(GROSSAMOUNT),0) FROM ParkingSales PS JOIN [SESSION] S ON PS.SESSION_ID = S.SESSION_ID WHERE S.[UID] = {0} AND SESSION_SETTLED = 0 AND LEFT(BillNo,2) IN ('SI', 'TI')", Settlement.SETTLED_UID);
                            break;

                        case 1:     // Terminal wise Settlement
                            strSql = string.Format("SELECT ISNULL(SUM(GROSSAMOUNT),0) FROM ParkingSales PS JOIN [SESSION] S ON PS.SESSION_ID = S.SESSION_ID WHERE SESSION_SETTLED = 0 AND TERMINAL_CODE = '{1}' AND LEFT(BillNo,2) IN ('SI', 'TI')", Settlement.TERMINAL_CODE);
                            break;

                        case 2:     // User And Terminal wise  Settlement
                            strSql = string.Format("SELECT ISNULL(SUM(GROSSAMOUNT),0) FROM ParkingSales PS JOIN [SESSION] S ON PS.SESSION_ID = S.SESSION_ID WHERE S.[UID] = {0} AND SESSION_SETTLED = 0 AND TERMINAL_CODE = '{1}' AND LEFT(BillNo,2) IN ('SI', 'TI')", Settlement.SETTLED_UID, Settlement.TERMINAL_CODE);
                            break;

                        default:
                            strSql = string.Format("SELECT ISNULL(SUM(GROSSAMOUNT),0) FROM ParkingSales PS JOIN [SESSION] S ON PS.SESSION_ID = S.SESSION_ID WHERE S.[UID] = {0} AND SESSION_SETTLED = 0 AND LEFT(BillNo,2) IN ('SI', 'TI')", Settlement.SETTLED_UID);
                            break;
                        }

                        Settlement.CollectionAmount = conn.ExecuteScalar <decimal>(strSql);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Cash Settlement", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#2
0
        private void sortByUserId()
        {
            List <USER> sortedList = UserList.OrderBy(x => x.ID.ToString() == Convert.ToString(SearchByUserId)).ToList();

            sortedList.Reverse();
            UserList.Clear();
            foreach (var sortedItem in sortedList)
            {
                UserList.Add(sortedItem);
            }
            SelectedUser = UserList.First();
            OnPropertyChanged("UserList");
        }
示例#3
0
        private async void OnNextUserList(object obj)
        {
            IsBusy = true;
            _initialIndexes.Add(UserList.First().Id - 1);
            if (_initialIndexes.Count > 0)
            {
                IsBackUserListEnabled = true;
            }
            var users = await _userRepository.GetAllUser(UserList.Last().Id);

            UserList = new ObservableCollection <User>(users);
            IsBusy   = false;
        }
示例#4
0
        private void sortByName()
        {
            List <USER> sortedList = UserList.OrderBy(x => x.NAME.ToUpper().Contains(SortByName.ToUpper())).ToList();

            sortedList.Reverse();
            UserList.Clear();
            foreach (var sortedItem in sortedList)
            {
                UserList.Add(sortedItem);
            }
            SelectedUser = UserList.First();
            OnPropertyChanged("UserList");
        }
示例#5
0
        public async void Initialize()
        {
            //自動的にサインインする サインイン情報がなければ
            foreach (var user in await SignIn.AutoSignIn())
            {
                UserList.Add(user);
            }

            //一番最初に来たユーザーがカレントになる
            CurrentUser = UserList.First();

            //セッションを保存
            SignIn.SaveSession(UserList.ToList(), CurrentUser);

            Status = "サインイン完了";

            MainContent.AddSystemTab(WebView = new WebViewViewModel());
            MainContent.AddSystemTab(Ranking = new RankingViewModel());
            MainContent.AddSystemTab(Search  = new SearchViewModel());
            MainContent.AddSystemTab(new FollowViewModel());
            MainContent.AddSystemTab(new NicoRepoViewModel());
            MainContent.AddSystemTab(new MylistViewModel());
            MainContent.AddSystemTab(LiveNotify = new LiveNotifyViewModel());

            MainContent.AddSystemTab(History = new HistoryViewModel());
            MainContent.AddSystemTab(new OtherViewModel());
            MainContent.AddSystemTab(Setting = new SettingsViewModel());


            if (await UpdateChecker.IsUpdateAvailable())
            {
                Messenger.Raise(new TransitionMessage(typeof(Views.UpdateFoundView), new UpdaterViewModel(), TransitionMode.Modal));
            }


            var args = Environment.GetCommandLineArgs();

            if (args.Length == 2)
            {
                var commandline = Environment.GetCommandLineArgs()[1];

                NicoNicoOpener.TryOpen(commandline);
            }
        }
示例#6
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            string lockoutMsg = "";
            User   u          = null;
            bool   validUser  = users.Any(x => ((User)x).userLogin.ToLower() == usernameTextBox.Text.ToLower());

            if (validUser)
            {
                u = (User)(users.First(x => ((User)x).userLogin.ToLower() == usernameTextBox.Text.ToLower()));
            }

            // begin jdg 10/30/15
            NameValueCollection values = Configurator.GetConfig("AppSettings");

            if (values != null)
            {
                LDAPSecurityContext = values["SecurityContext"];
            }
            if (String.IsNullOrEmpty(LDAPSecurityContext))
            {
                LDAPSecurityContext = "Off";
            }
            bool bLDAPSuccess = false;
            bool bLDAP        = (((LDAPSecurityContext.ToUpper() == "MACHINE") || (LDAPSecurityContext.ToUpper() == "DOMAIN")) ? true : false);

            try
            {
                if (bLDAP)
                {
                    switch (LDAPSecurityContext.ToUpper())
                    {
                    case "MACHINE":
                        using (var context = new PrincipalContext(ContextType.Machine))
                        {
                            if (context.ValidateCredentials(usernameTextBox.Text, passwordTextBox.Text))
                            {
                                bLDAPSuccess = true;
                            }
                        }
                        break;

                    case "DOMAIN":
                        using (var context = new PrincipalContext(ContextType.Domain))
                        {
                            if (context.ValidateCredentials(usernameTextBox.Text, passwordTextBox.Text))
                            {
                                bLDAPSuccess = true;
                            }
                        }
                        break;

                    default:

                        break;
                    }
                }
            }
            catch (Exception excLDAP)
            {
                RiskApps3.Utilities.Logger.Instance.WriteToLog("LDAP Authentication failed for user " + usernameTextBox.Text + " for this reason: " + excLDAP.ToString());
            }
            // end jdg 10/30/15

            String encryptedPassword = RiskAppCore.User.encryptPassword(passwordTextBox.Text);

            bool authenticated     = false;
            int  numFailedAttempts = 0;
            int  numMaxFailures    = 5;
            int  lockoutPeriod     = 0;

            lockoutMsg = "";

            Utilities.ParameterCollection pc = new Utilities.ParameterCollection();
            pc.Add("ntLoginName", DBUtils.makeSQLSafe(ntUser));
            pc.Add("userLogin", DBUtils.makeSQLSafe((u != null) ? u.userLogin : usernameTextBox.Text));

            //if (SessionManager.Instance.MetaData.Globals.encryptPasswords)
            if ((SessionManager.Instance.MetaData.Globals.encryptPasswords) && (!bLDAP))
            {
                pc.Add("userPassword", DBUtils.makeSQLSafe(encryptedPassword));
            }
            else
            {
                pc.Add("userPassword", DBUtils.makeSQLSafe(passwordTextBox.Text));
            }
            // begin jdg 10/30/15
            pc.Add("bLDAP", (bLDAP ? 1 : 0));
            pc.Add("bLDAPSuccess", (bLDAPSuccess ? 1 : 0));
            // end jdg 10/30/15

            SqlDataReader reader = BCDB2.Instance.ExecuteReaderSPWithParams("sp_Authenticate_User", pc);

            if (reader != null)
            {
                if (reader.Read())
                {
                    authenticated     = (bool)reader.GetSqlBoolean(0);
                    numFailedAttempts = (int)reader.GetInt32(1);
                    numMaxFailures    = (int)reader.GetInt32(2);
                    lockoutPeriod     = (int)reader.GetInt32(3);
                }
                reader.Close();
            }
            if ((!validUser) || (!authenticated))  //note that if they're not a valid user they won't be authenticated, but we've updated the failed count and timeout values
            {
                if (lockoutPeriod > 0)
                {
                    lockoutMsg = "\r\nLogin attempts will be blocked for " + lockoutPeriod.ToString() + " minute" + ((lockoutPeriod > 1) ? "s." : ".");
                }
                else
                {
                    lockoutMsg = "\r\nYou have made " + numFailedAttempts.ToString() + " failed Login attempt" + ((numFailedAttempts > 1) ? "s" : "") + " of a maximum " + numMaxFailures.ToString() + " allowed.";
                }
            }

            if (validUser && authenticated)
            {
                //see if user is forced to change password
                if (!bLDAP) // jdg 10/30/15
                {
                    if (ApplicationUtils.checkPasswordForceChange(u.userLogin))
                    {
                        String username = usernameTextBox.Text;
                        SessionManager.Instance.MetaData.Users.BackgroundListLoad();
                        passwordTextBox.Text = "";
                        usernameTextBox.Text = username;
                        this.DialogResult    = System.Windows.Forms.DialogResult.None;
                        return;
                    }

                    if (ApplicationUtils.checkPasswordDateOK(u.userLogin) == false)
                    {
                        String username = usernameTextBox.Text;
                        SessionManager.Instance.MetaData.Users.BackgroundListLoad();
                        passwordTextBox.Text = "";
                        usernameTextBox.Text = username;
                        this.DialogResult    = System.Windows.Forms.DialogResult.None;
                        return;
                    }
                }
                roleID   = RiskAppCore.User.fetchUserRoleID(u.userLogin);
                roleName = RiskAppCore.User.fetchUserRoleName(u.userLogin);

                switch (roleName)
                {
                case "Tablet":
                    RiskAppCore.ErrorMessages.Show(RiskAppCore.ErrorMessages.ROLE_ACCESS_DENIED);
                    return;

                default:
                    break;
                }
                SessionManager.Instance.ActiveUser = u;
                InitUserGUIPrefs(u);
                u.UserClinicList.user_login = u.userLogin;
                u.UserClinicList.AddHandlersWithLoad(null, UserClinicListLoaded, null);
                //DialogResult = DialogResult.OK;

                HraObject.AuditUserLogin(u.userLogin);

                stopWatch.Stop();
                // Get the elapsed time as a TimeSpan value.
                TimeSpan ts = stopWatch.Elapsed;
                if (ts.TotalSeconds < requiredSplashTime)
                {
                    progressBar1.Style = ProgressBarStyle.Blocks;
                    progressBar1.Value = progressBar1.Maximum;
                    progressBar1.Refresh();
                    Application.DoEvents();
                    Thread.Sleep((int)(1000 * (requiredSplashTime - ts.TotalSeconds)));
                }

                return;
            }

            if (numFailedAttempts == 1)
            {
                MessageBox.Show(
                    "You have provided an incorrect username or password.\r\nPlease correct your password or try a different user." + lockoutMsg,
                    "Incorrect Username/Password",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
            }
            else if (numFailedAttempts > 1)
            {
                MessageBox.Show(
                    lockoutMsg,
                    "Incorrect Username/Password",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
            }
            return;
        }