void timer_Tick(object sender, EventArgs e)
 {
     if (CheckStationRegistred.IsRegistered() == false)
     {
         wndStationMaster _Station = new wndStationMaster();
         _Station.ShowDialog();
     }
 }
 /// <summary>
 /// Timer for refresh and lagel clock
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void timer_Tick(object sender, EventArgs e)
 {
     try
     {
         lblTime.Content = DateTime.UtcNow.ToString("MMM dd, yyyy hh:mm:ss tt");
         string sec = DateTime.UtcNow.Second.ToString();
         if (sec == "30")
         {
             if (CheckStationRegistred.IsRegistered() == false)
             {
                 wndStationMaster _Station = new wndStationMaster();
                 _Station.ShowDialog();
             }
         }
     }
     catch (Exception Ex)
     {
         //Log the Error to the Error Log table
         ErrorLoger.save("wndShipmentScanPage - timer_Tick", "[" + DateTime.UtcNow.ToString() + "]" + Ex.ToString(), DateTime.UtcNow, Global.LoggedUserId);
     }
 }
示例#3
0
        /// <summary>
        /// Login Code
        /// </summary>
        public void login_Prorgam()
        {
            List <cstUserMasterTbl> _lsUseMaster = new List <cstUserMasterTbl>();

            try
            {
                //find the username and password.
                _lsUseMaster = modelUser.UserFunctions.GetUserMaster(txtUserName.Text);
            }
            catch (Exception Ex)
            {
                //Log the Error to the Error Log table
                ErrorLoger.save("wndLogin - login_Prorgam_Sub1", "[" + DateTime.UtcNow.ToString() + "]" + Ex.ToString());
            }

            try
            {
                if (_lsUseMaster.Count() > 0)
                {
                    modelUser = new model_User(_lsUseMaster[0].UserID);

                    Global.LoggedUserModel = modelUser;

                    Global.LoggedUserId = modelUser.UserInfo.UserID;

                    //Set UserID for created and update responsible operations, in all application for Audit table and Error log table.
                    Global.controller.SetCreatedOrUpdatedUserID(Global.LoggedUserId);

                    Global.WindowTopUserName = modelUser.UserInfo.UserFullName;

                    Global.LastLoginDateTime = modelUser.LastLoginTime;
                    //Admin User Check and rediract to the Home screen.
                    if (Global.controller.IsSuperUser(Global.LoggedUserId))
                    {
                        if (CheckStationRegistred.IsRegistered() == false)
                        {
                            wndStationMaster _Station = new wndStationMaster();
                            this.Dispatcher.Invoke(new Action(() => { _Station.ShowDialog(); }));
                            try
                            {
                                _addLogUserStationtable();
                            }
                            catch (Exception Ex)
                            {
                                //Log the Error to the Error Log table
                                ErrorLoger.save("wndLogin - login_Prorgam_Sub2", "[" + DateTime.UtcNow.ToString() + "]" + Ex.ToString());
                            }
                        }
                        else if (CheckStationRegistred.IsRegistered())
                        {
                            _addLogUserStationtable();
                        }

                        txtUserName.Text = "";
                        txtMask.Text     = "";

                        //save User Log
                        SaveUserLogsTbl.logThis(csteActionType.Login.ToString());

                        HomeScreen _Home = new HomeScreen();
                        this.Dispatcher.Invoke(new Action(() => { _Home.Show(); }));
                        this.Close();
                    }
                    else
                    {
                        #region station Registration Check
                        if (CheckStationRegistred.IsRegistered() == false)
                        {
                            wndStationMaster _Station = new wndStationMaster();
                            this.Dispatcher.Invoke(new Action(() => { _Station.ShowDialog(); }));
                            try
                            {
                                //save new station.
                                _addLogUserStationtable();
                            }
                            catch (Exception Ex)
                            {
                                //Log the Error to the Error Log table
                                ErrorLoger.save("wndLogin - login_Prorgam_Sub3", "[" + DateTime.UtcNow.ToString() + "]" + Ex.ToString());
                            }
                        }
                        else
                        {
                            _addLogUserStationtable();
                            Global.StationModel = new model_Station(MACAddresss);
                        }
                        #endregion

                        txtUserName.Text = "";
                        txtMask.Text     = "";
                        //Set Error message on the Sctrip and Visible it to animate.
                        _scrollMsg("Welcome " + Global.LoggedUserModel.UserInfo.UserFullName, Color.FromRgb(38, 148, 189));
                        //save User Log
                        SaveUserLogsTbl.logThis(csteActionType.Login.ToString());

                        //Open admin home page for admin.
                        MainWindow ScanWindow = new MainWindow();
                        this.Dispatcher.Invoke(new Action(() => { ScanWindow.Show(); }));

                        //close this window
                        this.Close();
                    }
                }
                else
                {
                    txtUserName.Text = "";
                    txtMask.Text     = "";

                    //Set Error message on the Sctrip and Visible it to animate.
                    _scrollMsg("Warning : Access Denied. Incorrect User Name.", Color.FromRgb(222, 87, 24));
                }
            }
            catch (Exception Ex)
            {
                //Log the Error to the Error Log table
                ErrorLoger.save("wndLogin - login_Prorgam_Sub3", "[" + DateTime.UtcNow.ToString() + "]" + Ex.ToString());
            }
        }