Exemple #1
0
 public static bool IsExists(string userName, Guid orgId)
 {
     Micajah.Common.Dal.ClientDataSet.UserRow _uRow = UserProvider.GetUserRow(userName, orgId);
     if (_uRow == null)
     {
         return(false);
     }
     return(true);
 }
        /// <summary>
        /// Gets display user name
        /// </summary>
        /// <param name="userId">User identifier</param>
        /// <returns>First + Last Name</returns>
        public static string GetDisplayUserName(Guid userId, Guid organizationId)
        {
            string result = string.Empty;

            Micajah.Common.Dal.ClientDataSet.UserRow userRow = Micajah.Common.Bll.Providers.UserProvider.GetUserRow(userId, organizationId);
            if (userRow != null)
            {
                result = userRow.FirstName + " " + userRow.LastName;
            }
            return(result);
        }
Exemple #3
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 or inactivated. Contact SherpaDesk for assistance. Email: [email protected] Phone: +1 (866) 996-1200, then press 2");
            }

            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"];
            m_DepartmentName = _row["company_name"].ToString();
            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.");
            }
            if ((bool)_row["btUserInactive"])
            {
                throw new HttpError(HttpStatusCode.Forbidden, "The user account is Inactive in this Department.");
            }
            m_Skype       = _row["Skype"].ToString();
            m_AccountName = ((string)_row["AccountName"]);
            if (string.IsNullOrWhiteSpace(m_AccountName))
            {
                m_AccountName = m_DepartmentName;
            }
            Micajah.Common.Dal.ClientDataSet.UserRow _uRow = UserProvider.GetUserRow(m_LoginEmail, m_OrganizationId);
            string TimeZoneId = null;

            if (_uRow != null)
            {
                m_TimeFormat = _uRow.IsTimeFormatNull() ? 0 : _uRow.TimeFormat;
                m_DateFormat = _uRow.IsTimeFormatNull() ? 0 : _uRow.DateFormat;

                if (!_uRow.IsTimeFormatNull())
                {
                    TimeZoneId = _uRow.TimeZoneId;
                }
                UpdateLastLoginDate(m_OrganizationId, _uRow.UserId);
            }
            if (string.IsNullOrEmpty(TimeZoneId) && !_row.IsNull("InstanceTimeZoneId"))
            {
                TimeZoneId = _row["InstanceTimeZoneId"].ToString();
            }

            try
            {
                m_TimeZoneOffset = TimeZoneInfo.FindSystemTimeZoneById(TimeZoneId).GetUtcOffset(new DateTimeOffset(DateTime.UtcNow, TimeSpan.Zero)).Hours;
                m_TimeZoneId     = TimeZoneId;
            }
            catch
            {
                m_TimeZoneOffset = DefaultTimeZoneOffset;
            }

            if (!_row.IsNull("tintTicketTimer"))
            {
                m_tintTicketTimer = (byte)_row["tintTicketTimer"];
            }
            else
            {
                m_tintTicketTimer = (byte)_row["tintDTicketTimer"];
            }

            bool isOrgAdmin = _row.Get <bool?>("OrganizationAdministrator") ?? false;

            m_IsUseWorkDaysTimer = tintTicketTimer > 0;

            int userType = (int)_row ["UserType_Id"];

            if (userType == 2 || userType == 3 || userType == 6 || isOrgAdmin)
            {
                m_IsTechAdmin = true;
            }
            if (userType == 3 || isOrgAdmin)
            {
                m_IsAdmin = true;
            }
            m_Roles[0] = userType == 3 ? "admin" : "";
            m_Roles[0] = userType == 5 ? "super" : m_Roles[0];
            m_Role     = (bigWebApps.bigWebDesk.UserAuth.UserRole)Enum.Parse(typeof(bigWebApps.bigWebDesk.UserAuth.UserRole), userType.ToString());

            m_OrganizationLogoImageUrl = BWA.Api.Models.Files.GetOrganizationLogoUrl(OrganizationId);
            m_InstanceLogoImageUrl     = BWA.Api.Models.Files.GetInstanceLogoUrl(m_InstanceId);

            bigWebApps.bigWebDesk.Data.Logins.UpdateUserLastLoginDate(m_OrganizationId, m_UserId);
        }