Example #1
0
 public static bool IsExists(string userName)
 {
     Micajah.Common.Dal.OrganizationDataSet.UserRow _uRow = UserProvider.GetUserRow(userName);
     if (_uRow == null)
     {
         return(false);
     }
     return(true);
 }
Example #2
0
        private void CompleteInitObject()
        {
            var      CurrOrganization = Micajah.Common.Bll.Providers.OrganizationProvider.GetOrganization(m_OrganizationId);
            byte     _graceDays       = (byte)CurrOrganization.GraceDays;
            DateTime _expire          = DateTime.UtcNow.AddMonths(1);

            if (CurrOrganization.ExpirationTime != null)
            {
                _expire = (DateTime)CurrOrganization.ExpirationTime;
            }
            DateTime _now = DateTime.UtcNow;

            _expire = _expire.AddDays(_graceDays);
            if (_expire < _now)
            {
                throw new HttpError(HttpStatusCode.Forbidden, "Your organization's account has expired.");
            }

            DataRow _row = bigWebApps.bigWebDesk.Data.Companies.SelectOne(m_OrganizationId, m_InstanceId);

            if (_row == null)
            {
                throw new HttpError(HttpStatusCode.NotFound, "Can't find department for OrganizationId/InstanceId=" + OrganizationId.ToString() + "/" + InstanceId.ToString());
            }
            m_DepartmentId = (int)_row["company_id"];
            int _userStatus = Logins.SelectLoginExists(m_OrganizationId, m_DepartmentId, m_LoginEmail, out m_UserId, out m_AccountId);

            if (_userStatus == 1)
            {
                throw new HttpError(HttpStatusCode.NotFound, "Can't find User \"" + m_LoginEmail + "\" in the bigWebApps database.");
            }
            else if (_userStatus == 2)
            {
                throw new HttpError(HttpStatusCode.Forbidden, "User \"" + m_LoginEmail + "\" is not associated with OrganizationId/InstanceId=" + OrganizationId.ToString() + "/" + InstanceId.ToString() + ".");
            }
            _row = Logins.SelectUserDetails(m_OrganizationId, m_DepartmentId, m_UserId);
            if (_row == null)
            {
                throw new HttpError(HttpStatusCode.Forbidden, "The user account is not associated with this Department.");
            }
            Micajah.Common.Dal.OrganizationDataSet.UserRow _uRow = UserProvider.GetUserRow(m_LoginEmail);
            string TimeZoneId = null;

            if (_uRow != null && !_uRow.IsTimeFormatNull())
            {
                TimeZoneId = _uRow.TimeZoneId;
            }
            if (string.IsNullOrEmpty(TimeZoneId) && !_row.IsNull("InstanceTimeZoneId"))
            {
                TimeZoneId = _row["InstanceTimeZoneId"].ToString();
            }
            try
            {
                m_TimeZoneOffset = TimeZoneInfo.FindSystemTimeZoneById(TimeZoneId).BaseUtcOffset.Hours;
                m_TimeZoneId     = TimeZoneId;
            }
            catch
            {
                m_TimeZoneOffset = DefaultTimeZoneOffset;
            }
            if ((bool)_row["btUserInactive"])
            {
                throw new HttpError(HttpStatusCode.Forbidden, "The user account is Inactive in this Department.");
            }
            if (!_row.IsNull("tintTicketTimer"))
            {
                m_IsUseWorkDaysTimer = (byte)_row["tintTicketTimer"] > 0;
            }
            else
            {
                m_IsUseWorkDaysTimer = (byte)_row["tintDTicketTimer"] > 0;
            }
            if ((int)_row["UserType_Id"] == 2 || (int)_row["UserType_Id"] == 3)
            {
                m_IsTechAdmin = true;
            }
        }
Example #3
0
        public void Load(DataRow companyRow, string loginEmail)
        {
            int     _userId = 0;
            DataRow _row    = null;

            this.IsOk = false;
            string message = null;

            if (!ValidateLoginInCompany(companyRow, OrgID, loginEmail, out _userId, out _row, out message))
            {
                this._errMessage = message;
                return;
            }

            int _did = (int)companyRow["company_id"];

            this.strGDName  = companyRow["company_name"].ToString();
            this._strGDGuid = companyRow["company_guid"].ToString();

            this._strUId   = _userId.ToString();
            this._strDId   = _did.ToString();
            this.strEmail  = loginEmail;
            this.strGFName = _row["FirstName"].ToString();
            this.strGLName = _row["LastName"].ToString();
            this._password = _row["Password"].ToString();
            if (!_row.IsNull("tintTicketTimer"))
            {
                this.tintTicketTimer = (byte)_row["tintTicketTimer"];
            }
            else
            {
                this.tintTicketTimer = (byte)_row["tintDTicketTimer"];
            }
            if (!_row.IsNull("configPartialSetup"))
            {
                this.IsConfigPartialSetup = (bool)_row["configPartialSetup"];
            }
            this._strGSpGrp = _row["SupGroupId"].ToString();
            this._strGFrame = "0";
            switch ((int)_row["UserType_Id"])
            {
            case 1:
                this.strGPerm = ",usr";
                _role         = UserRole.StandardUser;
                break;

            case 2:
                this.strGPerm = ",tch";
                _role         = UserRole.Technician;
                break;

            case 3:
                this.strGPerm = ",tch,adm";
                _role         = UserRole.Administrator;
                break;

            case 4:
                this.strGPerm = ",que";
                _role         = UserRole.StandardUser;
                break;

            case 5:
                this.strGPerm = ",usr";
                _role         = UserRole.StandardUser;
                int    _utype      = 0;
                int    _sutype     = 0;
                int    _suid       = 0;
                string _surlocid   = string.Empty;
                string _surlocname = string.Empty;
                string _sudomain   = string.Empty;
                int    _res        = Data.Logins.SelectSuperUserInfo(OrgID, _did, _userId, ref _utype, ref _sutype, ref _suid, ref _surlocid, ref _surlocname, ref _sudomain);
                if (_res >= 0 && _sutype != 0 && _suid != 0)
                {
                    this.strGPerm                 += ",susr";
                    _role                          = UserRole.SuperUser;
                    this._strGSUserType            = _sutype.ToString();
                    this._strGSUserId              = _suid.ToString();
                    this.vchGSUserDomain           = _sudomain;
                    this.strGSUserRootLocationId   = _surlocid;
                    this.strGSUserRootLocationName = _surlocname;
                }
                break;
            }
            if (!_row.IsNull("btGlobalFilterEnabled") && (bool)_row["btGlobalFilterEnabled"])
            {
                this.strGFilter = ",gf";
            }
            if (!_row.IsNull("btLimitToAssignedTkts") && (bool)_row["btLimitToAssignedTkts"])
            {
                this.strGFilter += ",tkt";
            }
            if (this.strGFilter.IndexOf(",gf") >= 0 && this.strGFilter.IndexOf(",tkt") >= 0 && !_row.IsNull("btDisabledReports") && (bool)_row["btDisabledReports"])
            {
                this.strGFilter += ",rpt";
            }
            this.IsOk = true;
            Micajah.Common.Dal.OrganizationDataSet.UserRow _usrRow = Micajah.Common.Bll.Providers.UserProvider.GetUserRow(loginEmail);
            if (_usrRow != null)
            {
                string timeZoneId = (_usrRow.IsTimeZoneIdNull() ? null : _usrRow.TimeZoneId);
                int?   timeFormat = (_usrRow.IsTimeFormatNull() ? null : new int?(_usrRow.TimeFormat));
                int?   dateFormat = (_usrRow.IsDateFormatNull() ? null : new int?(_usrRow.DateFormat));

                if (string.IsNullOrEmpty(timeZoneId) || (!timeFormat.HasValue) || (!dateFormat.HasValue))
                {
                    Micajah.Common.Bll.Instance inst = Micajah.Common.Bll.Providers.InstanceProvider.GetInstance(this.InstanceID, this.OrgID);
                    if (inst != null)
                    {
                        if (string.IsNullOrEmpty(timeZoneId))
                        {
                            timeZoneId = inst.TimeZoneId;
                        }

                        if (!timeFormat.HasValue)
                        {
                            timeFormat = inst.TimeFormat;
                        }

                        if (!dateFormat.HasValue)
                        {
                            dateFormat = inst.DateFormat;
                        }
                    }
                }

                if (string.IsNullOrEmpty(timeZoneId))
                {
                    timeZoneId = "Eastern Standard Time";
                }

                if (!timeFormat.HasValue)
                {
                    timeFormat = 0;
                }

                if (!dateFormat.HasValue)
                {
                    dateFormat = 0;
                }

                _tzi = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId);
                _tf  = timeFormat.Value;
                _df  = dateFormat.Value;
            }
        }