Пример #1
0
 private void set_blvalue_ApiUrl(int _ServerId)
 {
     bl.AppService = AppServiceFactory.CreateApp((AdminAppType)blvalue.AplicationId);
     if (_ServerId != -1)
     {
         AppMain.AppValue.ApiUrlApp = __List_ApplicationServer.Where(l => l.Id == _ServerId).FirstOrDefault().ApiLocal;
         UseLocal();
         AppMain.AppValue.RunningLocalApp = string.IsNullOrEmpty(AppMain.AppValue.ApiUrlApp);
         bl.AppService.CreateBlc();
     }
 }
Пример #2
0
        private void set_DatabaseIdValue(int _DataBaseId)
        {
            if (__OldDatabaseId != _DataBaseId)
            {
                __OldDatabaseId = _DataBaseId;
            }
            else
            {
                return;
            }

            int _ServerId   = Convert.ToInt32(lc_serverList.EditValue);
            int _DatabaseId = Convert.ToInt32(lc_database.EditValue);

            var server = __List_ApplicationServer.Where(l => l.Id == _ServerId).FirstOrDefault().ApplicationDatabase.Where(l => l.Id == _DatabaseId).FirstOrDefault();

            __ConnectionString = server.ConnectionString;

            __Sql_Server   = __List_ApplicationServer.Where(l => l.Id == _ServerId).FirstOrDefault().Server;
            __Sql_User     = __List_ApplicationServer.Where(l => l.Id == _ServerId).FirstOrDefault().Username;
            __Sql_Password = __List_ApplicationServer.Where(l => l.Id == _ServerId).FirstOrDefault().Password;

            __Sql_Database = __List_ApplicationServer.Where(l => l.Id == _ServerId).FirstOrDefault().ApplicationDatabase.Where(l => l.Id == _DatabaseId).FirstOrDefault().DatabaseName;

            set_blvalue_ApiUrl((int)lc_serverList.EditValue);
            SIS.Data.App.GetValue _GetValue = SIS.Client.Admin.bl.get_GetValue();
            _GetValue.ConStr = __ConnectionString;

            _GetValue.IdStr = txt_userCode.Text;

            bl.AppService = AppServiceFactory.CreateApp((AdminAppType)blvalue.AplicationId);
            try
            {
                AppMain.List_UserCompanyRight  = bl.AppService.GetUserCompanyRights(_GetValue);
                bs_UserCompanyRight.DataSource = AppMain.List_UserCompanyRight;
            }
            catch (Exception _Exception)
            {
                bl.message.get_Warning(_Exception.InnerException == null ? _Exception.Message : _Exception.InnerException.Message, AppMain.AppValue.Language);
                txt_userCode.EditValue = "";
                txt_userCode.Focus();
            }
            finally
            {
                GetUsers(_GetValue);
            }
        }
Пример #3
0
        private void do_login()
        {
            if (lc_Company.EditValue == null)
            {
                return;
            }

            string   _Password  = txt_Password.Text.Trim();
            int      _CompanyId = (int)lc_Company.EditValue;
            GetValue _GetValue  = new GetValue();

            _GetValue.ConStr    = __ConnectionString;
            _GetValue.CompanyId = _CompanyId;
            bl.AppService       = AppServiceFactory.CreateApp((AdminAppType)blvalue.AplicationId);
            string _HashPassword = _user.HashPassword.Trim();

            if (bl.AppService.GetHashPassword(_Password) != _HashPassword)
            {
                __LoginTryCount++;
                if (__LoginTryCount == 3)
                {
                    bl.message.get_Warning("Three times a failed login attempt, the user has been made inactive, ask your system administrator.", AppMain.AppValue.Language);
                    blvalue.UserLoginOk = false;

                    this.Close();

                    return;
                }
                bl.message.get_Warning("Wrong Password", AppMain.AppValue.Language);
                txt_Password.Focus();
                return;
            }
            blvalue.UserLoginOk       = true;
            AppMain.AppId             = (int)lc_Application.GetColumnValue("Id");
            AppMain.AppValue.UserCode = _user.UserCode;

            _GetValue.ConStr = __ConnectionString;
            _GetValue.IdStr  = AppMain.AppValue.UserCode;
            bl.AppService.Login(_GetValue);

            this.Close();
        }
Пример #4
0
        private void txt_userCode_Leave(object sender, EventArgs e)
        {
            string _UserCode = txt_userCode.Text.ToString().Trim();

            if (_PasswordFocus)
            {
                if (_User_old == _UserCode)
                {
                    _PasswordFocus = false;
                    return;
                }
            }

            if (_UserCode == "")
            {
                _User_old = "";
                txt_userCode.EditValue            = "";
                lc_serverList.EditValue           = -1;
                lc_database.EditValue             = -1;
                bs_ApplicationServer.DataSource   = null;
                bs_ApplicationDatabase.DataSource = null;

                bs_UserCompanyRight.DataSource = null;
                __OldServerId   = 0;
                __OldDatabaseId = 0;
                lc_serverList.Refresh();
                lc_database.Refresh();
                return;
            }

            blvalue.AplicationId = (int)lc_Application.EditValue;
            if (_User_old != _UserCode)
            {
                __OldServerId   = 0;
                __OldDatabaseId = 0;
                if (!get_User_ServerDatabase(txt_userCode.Text.ToString(), AppMain.AppValue.CustomerGuidId))
                {
                    _User_old = "";
                    txt_userCode.EditValue  = "";
                    txt_Password.EditValue  = "";
                    lc_serverList.EditValue = -1;
                    lc_database.EditValue   = -1;

                    bs_ApplicationServer.DataSource   = null;
                    bs_ApplicationDatabase.DataSource = null;
                    bs_UserCompanyRight.DataSource    = null;
                    __OldServerId   = 0;
                    __OldDatabaseId = 0;
                    lc_serverList.Refresh();
                    lc_database.Refresh();
                    lc_Company.Refresh();
                    bl.message.get_Warning("User not found.", AppMain.AppValue.Language);
                    txt_userCode.Focus();
                    return;
                }
                else
                {
                    GetValue _GetValue = SIS.Client.Admin.bl.get_GetValue();
                    _GetValue.ConStr = __ConnectionString;
                    _GetValue.IdStr  = txt_userCode.Text;

                    bl.AppService = AppServiceFactory.CreateApp((AdminAppType)blvalue.AplicationId);
                    try
                    {
                        var users = GetUsers(_GetValue);
                        //txt_userCode.EditValue = users?.UserName;
                    }
                    catch (Exception _Exception)
                    {
                        bl.message.get_Warning(_Exception.InnerException == null ? _Exception.Message : _Exception.InnerException.Message, AppMain.AppValue.Language);
                    }


                    _PasswordFocus = true;
                    txt_Password.Focus();
                }

                _User_old = txt_userCode.Text.ToString();
            }
        }