public ActionResult SaveUserPreference(DOADM_UserPreference objUserPreference)
 {
     try
     {
         string         errorMessage = string.Empty;
         ExceptionTypes result       = new ExceptionTypes();
         objUserPreference.ADM_UserMasterRef = currentUser.ADM_UserMasterId;
         BLUserAdministration objUserAdministration = new BLUserAdministration();
         result = objUserAdministration.SaveUserPreference(objUserPreference, out errorMessage);
         if (result != (long)ExceptionTypes.Success)
         {
             BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.UserPreference, (long)ExceptionTypes.Uncategorized, "An error occured while saving userpreference.", "An error occured while saving userpreference.");
             return(Json(new { ID = result, Message = "An error occured while saving." }));
         }
         if (currentUser != null)
         {
             currentUser.ADM_UserPreference = objUserPreference;
             System.Web.HttpContext.Current.Session[ConstantTexts.CurrentUserSessionKey] = currentUser;
         }
         string returnMessage = "User Preferences Saved Successfully.";
         return(Json(new { ID = 0, Message = returnMessage }));
     }
     catch (Exception ex)
     {
         BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.UserPreference, (long)ExceptionTypes.Uncategorized, string.Empty, ex.ToString());
         return(RedirectToAction("Maintenance", "Error", new { Error = MethodBase.GetCurrentMethod().Name + " Action terminated and redirected to Maintenance. Error:" + ex.ToString() }));
     }
 }
Пример #2
0
        public ActionResult Logout()
        {
            try
            {
                string[]             strLoginName            = System.Web.HttpContext.Current.User.Identity.Name.Split(new string[] { @"\" }, StringSplitOptions.RemoveEmptyEntries);
                string               domain                  = strLoginName[0];
                string               loginName               = strLoginName[1];
                BLUserAdministration objBLUserAdministration = new BLUserAdministration();
                objBLUserAdministration.UserLogout(loginName);

                Session[ConstantTexts.CurrentUserSessionKey]     = null;
                Session[ConstantTexts.UserSessionBeforeLoginKey] = null;
                Session.Clear();
                Session.RemoveAll();
                Session.Abandon();
                Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.Cache.SetNoStore();

                return(View());
            }
            catch
            {
                Session.Clear();
                Session.RemoveAll();
                Session.Abandon();
                return(RedirectToAction("Maintenance", "Error", new { Error = MethodBase.GetCurrentMethod().Name + " Action terminated and redirected to Maintenance. Error:Something went wrong while logout." }));
            }
        }
Пример #3
0
        public bool CheckUserDBAccess(out long userId, out string errosMsg)
        {
            userId   = _userid;
            errosMsg = string.Empty;
            string loginName = HttpContext.Current.User.Identity.Name.Replace("MS\\", "");
            BLUserAdministration objBLUserAdministration = new BLUserAdministration();
            UIUserLogin          loggedInUser;
            ExceptionTypes       res = objBLUserAdministration.GetUserAccessPermission(loginName, null, null, null, out loggedInUser);

            if (res == ExceptionTypes.ZeroRecords)
            {
                errosMsg = "You are not part of ERS DB, Please contact your Administrator.";
                return(false);
            }
            else if (res != ExceptionTypes.Success)
            {
                errosMsg = "An error occured while authorization, Please contact your Administrator.";
                return(false);
            }
            else
            {
                userId = loggedInUser.ADM_UserMasterId;
                return(true);
            }
        }
        public ActionResult Add(long UserId = 0, bool IsActive = true)
        {
            string errorMessage = string.Empty;

            Session[ConstantTexts.UserAccessGroupSessionKey] = null;
            try
            {
                DOADM_UserMaster     objDOADM_UserMaster     = new DOADM_UserMaster();
                BLUserAdministration objBLUserAdministration = new BLUserAdministration();
                objDOADM_UserMaster.IsManager = false;//set value since it is nullable
                objDOADM_UserMaster.StartDate = DateTime.UtcNow;
                objDOADM_UserMaster.EndDate   = DateTime.UtcNow.AddYears(10);
                objDOADM_UserMaster.IsActive  = true;
                long?TimeZone = currentUser.ADM_UserPreference.TimezoneLkup != null ? currentUser.ADM_UserPreference.TimezoneLkup : (long)DefaultTimeZone.CentralStandardTime;

                if (UserId != 0)
                {
                    List <DOADM_UserMaster> lstDOADM_UserMaster = new List <DOADM_UserMaster>();
                    objDOADM_UserMaster.ADM_UserMasterId = UserId;
                    objDOADM_UserMaster.IsActive         = IsActive;
                    objBLUserAdministration.SearchUser(TimeZone, objDOADM_UserMaster, out lstDOADM_UserMaster, out errorMessage);
                    if (lstDOADM_UserMaster.Count > 0)
                    {
                        objDOADM_UserMaster = lstDOADM_UserMaster.FirstOrDefault();
                        Session[ConstantTexts.UserAccessGroupSessionKey] = objDOADM_UserMaster.lstDOADM_AccessGroupUserCorrelation;
                    }
                }

                DOADM_UserMaster objManagerSearch = new DOADM_UserMaster()
                {
                    IsActive  = true,
                    IsManager = true
                };

                ExceptionTypes result = objBLUserAdministration.SearchUser(TimeZone, objManagerSearch, out List <DOADM_UserMaster> lstManagers, out errorMessage);

                objDOADM_UserMaster.lstManagers = lstManagers.OrderBy(x => x.FullName).ToList();
                if (UserId != 0)
                {
                    objDOADM_UserMaster.lstManagers.RemoveAll(x => x.ADM_UserMasterId == UserId);
                }

                objDOADM_UserMaster.lstLocation   = CacheUtility.GetAllLookupsFromCache((long)LookupTypes.Location);
                objDOADM_UserMaster.lstTimeZone   = CacheUtility.GetAllLookupsFromCache((long)LookupTypes.Timezone);
                objDOADM_UserMaster.lstState      = CacheUtility.GetAllLookupsFromCache((long)LookupTypes.State);
                objDOADM_UserMaster.lstSalutation = CacheUtility.GetAllLookupsFromCache((long)LookupTypes.Salutation);
                ViewBag.AccessGroups = GetAllAccessGroups();

                return(View(objDOADM_UserMaster));
            }
            catch (Exception ex)
            {
                BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.ManageUsers, (long)ExceptionTypes.Uncategorized, string.Empty, ex.ToString());
                return(RedirectToAction("Maintenance", "Error", new { Error = MethodBase.GetCurrentMethod().Name + " Action terminated and redirected to Maintenance. Error:" + ex.ToString() }));
            }
        }
        public ActionResult CheckUserExistsUsingMSID(string MSID)
        {
            string strErrorMessage = string.Empty;
            string strMessage      = string.Empty;
            bool   MsidExists      = false;
            long?  TimeZone        = currentUser.ADM_UserPreference.TimezoneLkup != null ? currentUser.ADM_UserPreference.TimezoneLkup : (long)DefaultTimeZone.CentralStandardTime;

            try
            {
                BLUserAdministration objBLUserAdministration = new BLUserAdministration();
                DOADM_UserMaster     objDOADM_UserMaster     = new DOADM_UserMaster();
                objDOADM_UserMaster.MSID     = MSID;
                objDOADM_UserMaster.IsActive = true;
                List <DOADM_UserMaster> lstDOADM_UserMaster;

                ExceptionTypes result = objBLUserAdministration.SearchUser(TimeZone, objDOADM_UserMaster, out lstDOADM_UserMaster, out strErrorMessage);
                if (lstDOADM_UserMaster.Count > 0)
                {
                    MsidExists = true;
                }
                else
                {
                    objDOADM_UserMaster.IsActive = false;//search again to check for not active records
                    result = objBLUserAdministration.SearchUser(TimeZone, objDOADM_UserMaster, out lstDOADM_UserMaster, out strErrorMessage);
                    if (lstDOADM_UserMaster.Count > 0)
                    {
                        MsidExists = true;
                    }
                    else
                    {
                        MsidExists = false;
                    }
                }
            }
            catch (Exception ex)
            {
                BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.ManageUsers, (long)ExceptionTypes.Uncategorized, string.Empty, ex.ToString());
                return(RedirectToAction("Maintenance", "Error", new { Error = MethodBase.GetCurrentMethod().Name + " Action terminated and redirected to Maintenance. Error:" + ex.ToString() }));
            }
            return(Json(new { MsidExists = MsidExists, strMessage = strMessage }, JsonRequestBehavior.AllowGet));
        }
        public List <DOADM_UserMaster> GetUserSearchResult(long?TimeZone, DOADM_UserMaster objDOADM_UserMaster, out string strErrorMessage)
        {
            BLUserAdministration    objBLUserAdministration = new BLUserAdministration();
            List <DOADM_UserMaster> lstDOADM_UserMaster     = new List <DOADM_UserMaster>();

            try
            {
                ExceptionTypes result = objBLUserAdministration.SearchUser(TimeZone, objDOADM_UserMaster, out lstDOADM_UserMaster, out strErrorMessage);
                if (result != (long)ExceptionTypes.Success)
                {
                    //Log Error
                    BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.ManageUsers, (long)ExceptionTypes.Uncategorized, string.Empty, "Error Occured while doing User Search");
                }
            }
            catch (Exception ex)
            {
                BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.ManageUsers, (long)ExceptionTypes.Uncategorized, string.Empty, ex.ToString());
                strErrorMessage = ex.ToString();
            }
            return(lstDOADM_UserMaster);
        }
Пример #7
0
        /// <summary>
        /// load session while session timeout in Login Page
        /// </summary>
        /// <returns></returns>
        private bool LoadCurrentUserSession(out UIUserLogin loggedInUser)
        {
            bool isSuccess = false;
            BLUserAdministration objBLUserAdministration = new BLUserAdministration();

            try
            {
                string[] strLoginName = System.Web.HttpContext.Current.User.Identity.Name.Split(new string[] { @"\" }, StringSplitOptions.RemoveEmptyEntries);
                string   domain       = strLoginName[0];
                string   loginName    = strLoginName[1];

                ExceptionTypes result = objBLUserAdministration.GetUserAccessPermission(loginName, null, null, null, out loggedInUser);
                if (result == ExceptionTypes.ZeroRecords)
                {
                    loggedInUser.IsAuthorizedUser = false;
                    loggedInUser.ErrorMessage     = ConstantTexts.NotPartOfERSDBError;
                    return(isSuccess);
                }
                if (result != (long)ExceptionTypes.Success)
                {
                    BLCommon.LogError(0, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Login, (long)ExceptionTypes.Uncategorized, string.Empty, "Error while fetching logged in user data");
                    return(isSuccess);
                }
                else
                {
                    #region Check User AD Groups

                    System.Security.Principal.WindowsIdentity             winIdnt = System.Web.HttpContext.Current.User.Identity as System.Security.Principal.WindowsIdentity;
                    System.Security.Principal.IdentityReferenceCollection grps    = winIdnt.Groups;
                    ////Admin
                    if (IsUserInADGroup(grps, WebConfigData.AdminSID))
                    {
                        loggedInUser.IsAdminUser = true;
                    }

                    //OST
                    if (IsUserInADGroup(grps, WebConfigData.AdminOSTSID))
                    {
                        loggedInUser.IsAdmOSTUser = true;
                    }
                    if (IsUserInADGroup(grps, WebConfigData.ManagerOSTSID))
                    {
                        loggedInUser.IsMgrOSTUser = true;
                    }
                    if (IsUserInADGroup(grps, WebConfigData.ProcessorOSTSID))
                    {
                        loggedInUser.IsPrcrOSTUser = true;
                    }
                    if (IsUserInADGroup(grps, WebConfigData.ViewerOSTSID))
                    {
                        loggedInUser.IsVwrOSTUser = true;
                    }

                    //Eligibility
                    if (IsUserInADGroup(grps, WebConfigData.AdminEligSID))
                    {
                        loggedInUser.IsAdmEligUser = true;
                    }
                    if (IsUserInADGroup(grps, WebConfigData.ManagerEligSID))
                    {
                        loggedInUser.IsMgrEligUser = true;
                    }
                    if (IsUserInADGroup(grps, WebConfigData.ProcessorEligSID))
                    {
                        loggedInUser.IsPrcrEligUser = true;
                    }
                    if (IsUserInADGroup(grps, WebConfigData.ViewerEligSID))
                    {
                        loggedInUser.IsVwrEligUser = true;
                    }

                    //RPR
                    if (IsUserInADGroup(grps, WebConfigData.AdminRPRSID))
                    {
                        loggedInUser.IsAdmRPRUser = true;
                    }
                    if (IsUserInADGroup(grps, WebConfigData.ManagerRPRSID))
                    {
                        loggedInUser.IsMgrRPRUser = true;
                    }
                    if (IsUserInADGroup(grps, WebConfigData.ProcessorRPRSID))
                    {
                        loggedInUser.IsPrcrRPRUser = true;
                    }
                    if (IsUserInADGroup(grps, WebConfigData.ViewerRPRSID))
                    {
                        loggedInUser.IsVwrRPRUser = true;
                    }
                    #endregion

                    //check if user has atleast one AD group assigned
                    if (loggedInUser.IsAdminUser || loggedInUser.IsAdmOSTUser || loggedInUser.IsAdmEligUser || loggedInUser.IsAdmRPRUser ||
                        loggedInUser.IsMgrOSTUser || loggedInUser.IsMgrEligUser || loggedInUser.IsMgrRPRUser || loggedInUser.IsPrcrOSTUser ||
                        loggedInUser.IsPrcrEligUser || loggedInUser.IsPrcrRPRUser || loggedInUser.IsVwrOSTUser || loggedInUser.IsVwrEligUser ||
                        loggedInUser.IsVwrRPRUser || loggedInUser.IsWebServiceUser || loggedInUser.IsMacroServiceUser)
                    {
                        if (loggedInUser.UserSkills != null && loggedInUser.UserSkills.Count > 0)
                        {
                            loggedInUser.IsAuthorizedUser = true;
                            loggedInUser = LoadDataForLogin(loggedInUser);
                            Session[ConstantTexts.UserSessionBeforeLoginKey] = loggedInUser;
                            isSuccess = true;
                        }
                        else
                        {
                            loggedInUser.IsAuthorizedUser = false;
                            loggedInUser.ErrorMessage     = ConstantTexts.NoAccessGroupAssignedError;
                        }
                    }
                    else
                    {
                        loggedInUser.IsAuthorizedUser = false;
                        loggedInUser.ErrorMessage     = ConstantTexts.NotPartOfADGroupError;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(isSuccess);
        }
Пример #8
0
        public ActionResult Login()
        {
            try
            {
                //check If session exists
                if (System.Web.HttpContext.Current.Session[ConstantTexts.CurrentUserSessionKey] == null)
                {
                    string[] strLoginName = System.Web.HttpContext.Current.User.Identity.Name.Split(new string[] { @"\" }, StringSplitOptions.RemoveEmptyEntries);
                    string   domain       = strLoginName[0];
                    string   loginName    = strLoginName[1];

                    //Checking user in Database.
                    BLUserAdministration objBLUserAdministration = new BLUserAdministration();
                    ExceptionTypes       result = objBLUserAdministration.GetUserAccessPermission(loginName, null, null, null, out UIUserLogin loggedInUser);
                    if (result == ExceptionTypes.ZeroRecords)
                    {
                        loggedInUser.IsAuthorizedUser = false;
                        loggedInUser.ErrorMessage     = string.Format(ConstantTexts.NotPartOfERSDBError, loginName);
                        return(View(loggedInUser));
                    }
                    if (result != (long)ExceptionTypes.Success)
                    {
                        BLCommon.LogError(0, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Login, (long)ExceptionTypes.Uncategorized, string.Empty, "Error while fetching logged in user data");
                        return(RedirectToAction("Maintenance", "Error", new { Error = MethodBase.GetCurrentMethod().Name + " Action terminated and redirected to Maintenance. Error:Something went wrong while retriving user details from login." }));
                    }
                    else
                    {
                        #region Check User AD Groups

                        System.Security.Principal.WindowsIdentity             winIdnt = System.Web.HttpContext.Current.User.Identity as System.Security.Principal.WindowsIdentity;
                        System.Security.Principal.IdentityReferenceCollection grps    = winIdnt.Groups;
                        ////Admin
                        if (IsUserInADGroup(grps, WebConfigData.AdminSID))
                        {
                            loggedInUser.IsAdminUser = true;
                        }

                        //OST
                        if (IsUserInADGroup(grps, WebConfigData.AdminOSTSID))
                        {
                            loggedInUser.IsAdmOSTUser = true;
                        }
                        if (IsUserInADGroup(grps, WebConfigData.ManagerOSTSID))
                        {
                            loggedInUser.IsMgrOSTUser = true;
                        }
                        if (IsUserInADGroup(grps, WebConfigData.ProcessorOSTSID))
                        {
                            loggedInUser.IsPrcrOSTUser = true;
                        }
                        if (IsUserInADGroup(grps, WebConfigData.ViewerOSTSID))
                        {
                            loggedInUser.IsVwrOSTUser = true;
                        }

                        //Eligibility
                        if (IsUserInADGroup(grps, WebConfigData.AdminEligSID))
                        {
                            loggedInUser.IsAdmEligUser = true;
                        }
                        if (IsUserInADGroup(grps, WebConfigData.ManagerEligSID))
                        {
                            loggedInUser.IsMgrEligUser = true;
                        }
                        if (IsUserInADGroup(grps, WebConfigData.ProcessorEligSID))
                        {
                            loggedInUser.IsPrcrEligUser = true;
                        }
                        if (IsUserInADGroup(grps, WebConfigData.ViewerEligSID))
                        {
                            loggedInUser.IsVwrEligUser = true;
                        }

                        //RPR
                        if (IsUserInADGroup(grps, WebConfigData.AdminRPRSID))
                        {
                            loggedInUser.IsAdmRPRUser = true;
                        }
                        if (IsUserInADGroup(grps, WebConfigData.ManagerRPRSID))
                        {
                            loggedInUser.IsMgrRPRUser = true;
                        }
                        if (IsUserInADGroup(grps, WebConfigData.ProcessorRPRSID))
                        {
                            loggedInUser.IsPrcrRPRUser = true;
                        }
                        if (IsUserInADGroup(grps, WebConfigData.ViewerRPRSID))
                        {
                            loggedInUser.IsVwrRPRUser = true;
                        }

                        if (IsUserInADGroup(grps, WebConfigData.RestrictedSID))
                        {
                            loggedInUser.IsRestrictedUser = true;
                        }
                        #endregion

                        //check if user has atleast one AD group assigned
                        if (loggedInUser.IsAdminUser || loggedInUser.IsAdmOSTUser || loggedInUser.IsAdmEligUser || loggedInUser.IsAdmRPRUser ||
                            loggedInUser.IsMgrOSTUser || loggedInUser.IsMgrEligUser || loggedInUser.IsMgrRPRUser || loggedInUser.IsPrcrOSTUser ||
                            loggedInUser.IsPrcrEligUser || loggedInUser.IsPrcrRPRUser || loggedInUser.IsVwrOSTUser || loggedInUser.IsVwrEligUser ||
                            loggedInUser.IsVwrRPRUser || loggedInUser.IsWebServiceUser || loggedInUser.IsMacroServiceUser)
                        {
                            if (loggedInUser.UserSkills != null && loggedInUser.UserSkills.Count > 0)
                            {
                                loggedInUser.IsAuthorizedUser = true;
                                loggedInUser = LoadDataForLogin(loggedInUser);
                                Session[ConstantTexts.UserSessionBeforeLoginKey] = loggedInUser;
                                return(View(loggedInUser));
                            }
                            else
                            {
                                loggedInUser.IsAuthorizedUser = false;
                                loggedInUser.ErrorMessage     = string.Format(ConstantTexts.NoAccessGroupAssignedError, loginName);
                                return(View(loggedInUser));
                            }
                        }
                        else
                        {
                            loggedInUser.IsAuthorizedUser = false;
                            loggedInUser.ErrorMessage     = string.Format(ConstantTexts.NotPartOfADGroupError, loginName);
                            return(View(loggedInUser));
                        }
                    }
                }
                else
                {
                    //session exists
                    return(RedirectToAction("Home", "Home"));
                }
            }
            catch (Exception ex)
            {
                BLCommon.LogError(0, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Login, (long)ExceptionTypes.Uncategorized, string.Empty, ex.ToString());
                return(RedirectToAction("Maintenance", "Error", new { Error = MethodBase.GetCurrentMethod().Name + " Action terminated and redirected to Maintenance. Error:" + ex.ToString() }));
            }
        }
Пример #9
0
        public ActionResult Login(long BusinessSegmentLkup = 0, long WorkBasketLkup = 0, long RoleLkup = 0)
        {
            try
            {
                ReLogin : string s = string.Empty;
                if (BusinessSegmentLkup > 0 && WorkBasketLkup > 0 && RoleLkup > 0)
                {
                    string[] strLoginName = System.Web.HttpContext.Current.User.Identity.Name.Split(new string[] { @"\" }, StringSplitOptions.RemoveEmptyEntries);
                    string   domain       = strLoginName[0];
                    string   loginName    = strLoginName[1];

                    if (Session[ConstantTexts.UserSessionBeforeLoginKey] != null)
                    {
                        DO.UIUserLogin loggedInUser = (DO.UIUserLogin)Session[ConstantTexts.UserSessionBeforeLoginKey];

                        loggedInUser.WorkBasketLkup      = WorkBasketLkup;
                        loggedInUser.BusinessSegmentLkup = BusinessSegmentLkup;
                        loggedInUser.RoleLkup            = RoleLkup;

                        bool   IsADGroupAssigned         = true;
                        string WorkBasletADGroupRequired = "";
                        string RoleADGroupRequired       = "";

                        //check if user has AD group access to slected Role and Workbasket
                        switch (RoleLkup)
                        {
                        case (long)Utility.RoleLkup.Admin:
                            RoleADGroupRequired = Utility.RoleLkup.Admin.ToString();
                            switch (WorkBasketLkup)
                            {
                            case (long)Utility.WorkBasket.GPSvsMMR:
                                IsADGroupAssigned         = loggedInUser.IsAdmEligUser;
                                WorkBasletADGroupRequired = Utility.WorkBasket.GPSvsMMR.ToString();
                                break;

                            case (long)Utility.WorkBasket.OST:
                                IsADGroupAssigned         = loggedInUser.IsAdmOSTUser;
                                WorkBasletADGroupRequired = Utility.WorkBasket.OST.ToString();
                                break;

                            case (long)Utility.WorkBasket.RPR:
                                IsADGroupAssigned         = loggedInUser.IsAdmRPRUser;
                                WorkBasletADGroupRequired = Utility.WorkBasket.RPR.ToString();
                                break;
                            }
                            break;

                        case (long)Utility.RoleLkup.Processor:
                            RoleADGroupRequired = Utility.RoleLkup.Processor.ToString();
                            switch (WorkBasketLkup)
                            {
                            case (long)Utility.WorkBasket.GPSvsMMR:
                                IsADGroupAssigned         = loggedInUser.IsPrcrEligUser;
                                WorkBasletADGroupRequired = Utility.WorkBasket.GPSvsMMR.ToString();
                                break;

                            case (long)Utility.WorkBasket.OST:
                                IsADGroupAssigned         = loggedInUser.IsPrcrOSTUser;
                                WorkBasletADGroupRequired = Utility.WorkBasket.OST.ToString();
                                break;

                            case (long)Utility.WorkBasket.RPR:
                                IsADGroupAssigned         = loggedInUser.IsPrcrRPRUser;
                                WorkBasletADGroupRequired = Utility.WorkBasket.RPR.ToString();
                                break;
                            }
                            break;

                        case (long)Utility.RoleLkup.Manager:
                            RoleADGroupRequired = Utility.RoleLkup.Manager.ToString();
                            switch (WorkBasketLkup)
                            {
                            case (long)Utility.WorkBasket.GPSvsMMR:
                                IsADGroupAssigned         = loggedInUser.IsMgrEligUser;
                                WorkBasletADGroupRequired = Utility.WorkBasket.GPSvsMMR.ToString();
                                break;

                            case (long)Utility.WorkBasket.OST:
                                IsADGroupAssigned         = loggedInUser.IsMgrOSTUser;
                                WorkBasletADGroupRequired = Utility.WorkBasket.OST.ToString();
                                break;

                            case (long)Utility.WorkBasket.RPR:
                                IsADGroupAssigned         = loggedInUser.IsMgrRPRUser;
                                WorkBasletADGroupRequired = Utility.WorkBasket.RPR.ToString();
                                break;
                            }
                            break;

                        case (long)Utility.RoleLkup.Viewer:
                            RoleADGroupRequired = Utility.RoleLkup.Viewer.ToString();
                            switch (WorkBasketLkup)
                            {
                            case (long)Utility.WorkBasket.GPSvsMMR:
                                IsADGroupAssigned         = loggedInUser.IsVwrEligUser;
                                WorkBasletADGroupRequired = Utility.WorkBasket.GPSvsMMR.ToString();
                                break;

                            case (long)Utility.WorkBasket.OST:
                                IsADGroupAssigned         = loggedInUser.IsVwrOSTUser;
                                WorkBasletADGroupRequired = Utility.WorkBasket.OST.ToString();
                                break;

                            case (long)Utility.WorkBasket.RPR:
                                IsADGroupAssigned         = loggedInUser.IsVwrRPRUser;
                                WorkBasletADGroupRequired = Utility.WorkBasket.RPR.ToString();
                                break;
                            }
                            break;
                        }

                        if (!IsADGroupAssigned)
                        {
                            //If no AD group Access return error message
                            loggedInUser.ErrorMessage = string.Format(ConstantTexts.NotPartofADgroupForRoleError, RoleADGroupRequired, WorkBasletADGroupRequired);
                            return(View(loggedInUser));
                        }

                        BLUserAdministration objBLUserAdministration = new BLUserAdministration();
                        ExceptionTypes       result = objBLUserAdministration.LoginUser(loginName);
                        if (result != (long)ExceptionTypes.Success)
                        {
                            loggedInUser.ErrorMessage = ConstantTexts.LoginException;
                            return(View(loggedInUser));
                        }

                        //filter skills for slected workbasket and roles
                        loggedInUser.UserSkills = loggedInUser.UserSkills.Where(x => x.WorkBasketLkup.Equals(WorkBasketLkup) && x.RoleLkup.Equals(RoleLkup)).ToList();

                        //Filter Queues avalaible to user in current access group
                        loggedInUser.UserQueueList = (from UQL in loggedInUser.UserQueueList
                                                      join US in loggedInUser.UserSkills on UQL.QueueLkp equals US.WorkQueuesLkup
                                                      where US.WorkQueuesLkup > 0
                                                      select UQL).GroupBy(x => x.QueueLkp).Select(y => y.FirstOrDefault()).ToList();

                        //Set Menu Visibilities
                        switch (WorkBasketLkup)
                        {
                        case (long)WorkBasket.GPSvsMMR:
                            loggedInUser.IsMMREligibilityMenuVisible = loggedInUser.UserSkills.Any(x => x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.Eligibility);
                            if (loggedInUser.IsMMREligibilityMenuVisible)
                            {
                                loggedInUser.EligibilityMMRCanCreate = loggedInUser.UserSkills.Any(x => x.CanCreate && x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.Eligibility);
                                loggedInUser.EligibilityMMRCanSearch = loggedInUser.UserSkills.Any(x => x.CanSearch && x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.Eligibility);
                            }
                            loggedInUser.IsDOBMenuVisible = loggedInUser.UserSkills.Any(x => x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.DOB);
                            if (loggedInUser.IsDOBMenuVisible)
                            {
                                loggedInUser.EligibilityDOBCanCreate = loggedInUser.UserSkills.Any(x => x.CanCreate && x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.DOB);
                                loggedInUser.EligibilityDOBCanSearch = loggedInUser.UserSkills.Any(x => x.CanSearch && x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.DOB);
                            }
                            loggedInUser.IsGENDERMenuVisible = loggedInUser.UserSkills.Any(x => x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.Gender);
                            if (loggedInUser.IsGENDERMenuVisible)
                            {
                                loggedInUser.EligibilityGenderCanCreate = loggedInUser.UserSkills.Any(x => x.CanCreate && x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.Gender);
                                loggedInUser.EligibilityGenderCanSearch = loggedInUser.UserSkills.Any(x => x.CanSearch && x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.Gender);
                            }
                            break;

                        case (long)WorkBasket.OST:
                            loggedInUser.IsOOAMenuVisible = loggedInUser.UserSkills.Any(x => x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.OOA);
                            if (loggedInUser.IsOOAMenuVisible)
                            {
                                loggedInUser.OSTOOACanCreate = loggedInUser.UserSkills.Any(x => x.CanCreate && x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.OOA);
                                loggedInUser.OSTOOACanSearch = loggedInUser.UserSkills.Any(x => x.CanSearch && x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.OOA);
                            }
                            loggedInUser.IsSCCMenuVisible = loggedInUser.UserSkills.Any(x => x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.SCC);
                            if (loggedInUser.IsSCCMenuVisible)
                            {
                                loggedInUser.OSTSCCCanCreate = loggedInUser.UserSkills.Any(x => x.CanCreate && x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.SCC);
                                loggedInUser.OSTSCCCanSearch = loggedInUser.UserSkills.Any(x => x.CanSearch && x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.SCC);
                            }
                            loggedInUser.IsTRRMenuVisible = loggedInUser.UserSkills.Any(x => x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.TRR);
                            if (loggedInUser.IsTRRMenuVisible)
                            {
                                loggedInUser.OSTTRRCanCreate = loggedInUser.UserSkills.Any(x => x.CanCreate && x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.TRR);
                                loggedInUser.OSTTRRCanSearch = loggedInUser.UserSkills.Any(x => x.CanSearch && x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.TRR);
                            }
                            break;

                        case (long)WorkBasket.RPR:
                            loggedInUser.IsRPRMenuVisible = loggedInUser.UserSkills.Any(x => x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.RPR);
                            if (loggedInUser.IsRPRMenuVisible)
                            {
                                loggedInUser.RPRCanCreate  = loggedInUser.UserSkills.Any(x => x.CanCreate && x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.RPR);
                                loggedInUser.RPRCanCSearch = loggedInUser.UserSkills.Any(x => x.CanSearch && x.DiscrepancyCategoryLkup == (long)DiscripancyCategory.RPR);
                            }
                            break;
                        }

                        //Set Manager Sub Menu Visibilities
                        if (RoleLkup == (long)Utility.RoleLkup.Manager || RoleLkup == (long)Utility.RoleLkup.Admin)
                        {
                            loggedInUser.CanMassReassign = loggedInUser.UserSkills.Any(x => x.CanReassign && x.WorkBasketLkup == WorkBasketLkup);
                            loggedInUser.CanMassUnlock   = loggedInUser.UserSkills.Any(x => x.CanUnlock && x.WorkBasketLkup == WorkBasketLkup);
                            loggedInUser.CanMassUpdate   = loggedInUser.UserSkills.Any(x => x.CanMassUpdate && x.WorkBasketLkup == WorkBasketLkup);
                            loggedInUser.CanMassUpload   = loggedInUser.UserSkills.Any(x => x.CanUpload && x.WorkBasketLkup == WorkBasketLkup);
                        }

                        if (loggedInUser.LocationLkup == (long)Location.Onshore && loggedInUser.IsRestrictedUser)
                        {
                            loggedInUser.IsRestrictedUser = true;
                        }
                        else
                        {
                            loggedInUser.IsRestrictedUser = false;
                        }

                        LastActivity = DateTime.Now;

                        Session[ConstantTexts.CurrentUserSessionKey] = loggedInUser;
                        return(RedirectToAction("Home", "Home"));
                    }
                    else
                    {
                        Session[ConstantTexts.CurrentUserSessionKey] = null;
                        UIUserLogin loggedInUser;
                        if (LoadCurrentUserSession(out loggedInUser))
                        {
                            goto ReLogin;
                        }
                        return(View(loggedInUser));
                    }
                }
                Session[ConstantTexts.CurrentUserSessionKey] = null;
                return(RedirectToAction("Login", "Login"));
            }
            catch (Exception ex)
            {
                BLCommon.LogError(0, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Login, (long)ExceptionTypes.Uncategorized, string.Empty, ex.ToString());
                return(RedirectToAction("Maintenance", "Error", new { Error = MethodBase.GetCurrentMethod().Name + " Action terminated and redirected to Maintenance. Error:" + ex.ToString() }));
            }
        }
Пример #10
0
        private ExceptionTypes CreateSession(WorkBasket objWorkBasket)
        {
            ExceptionTypes result = ExceptionTypes.UnauthorizedAccessException;

            string[] strLoginName = System.Web.HttpContext.Current.User.Identity.Name.Split(new string[] { @"\" }, StringSplitOptions.RemoveEmptyEntries);
            string   domain       = strLoginName[0];
            string   loginName    = strLoginName[1];
            string   errorMessage = string.Empty;

            try
            {
                if (IsUserInADGroup())
                {
                    if (Session[ConstantTexts.CurrentUserSessionKey] == null)
                    {
                        BLUserAdministration        objBLUserAdministration        = new BLUserAdministration();
                        UserAdminstrationController objUserAdminstrationController = new UserAdminstrationController();

                        //check user access
                        result = objBLUserAdministration.GetUserAccessPermission(loginName, null, null, null, out UIUserLogin loggedInUser);
                        if (result == ExceptionTypes.ZeroRecords)
                        {
                            //insert new User to DB, get details from LDAP
                            bool isUserFound = objUserAdminstrationController.GetUserDetails(loginName, true, out DOADM_UserMaster objDOADM_UserMaster);
                            if (isUserFound)
                            {
                                objDOADM_UserMaster.CreatedByRef = _currentLoginUserId;
                                objDOADM_UserMaster.MSID         = loginName;
                                objDOADM_UserMaster.StartDate    = DateTime.UtcNow.AddYears(-1);
                                objDOADM_UserMaster.EndDate      = DateTime.UtcNow.AddYears(30);
                                objDOADM_UserMaster.lstDOADM_AccessGroupUserCorrelation = new List <DOADM_AccessGroupUserCorrelation>();
                                //AddAccessGroups(objDOADM_UserMaster);
                                result = objBLUserAdministration.SaveUser(objDOADM_UserMaster, out errorMessage);
                            }
                            else
                            {
                                //user details not found in LDAP
                                MIIMServiceLog(MethodBase.GetCurrentMethod().Name, "", "Session Creation failed for new User. LDAP details not found", _currentLoginUserId, TarceMethodLkup.Completed.ToLong(), (long)MIIMServiceMethod.GetCaseDetails);
                                BLCommon.LogError(_currentLoginUserId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.MIIMConnector, (long)ExceptionTypes.Uncategorized, "Session Creartion failed, LDAP Details not found", "CREATE session failed");
                                return(ExceptionTypes.UnknownError);
                            }
                            result = objBLUserAdministration.GetUserAccessPermission(loginName, null, null, null, out loggedInUser);
                        }
                        else if (result != ExceptionTypes.Success)
                        {
                            BLCommon.LogError(_currentLoginUserId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.MIIMConnector, (long)ExceptionTypes.Uncategorized, string.Empty, "Error while fetching logged in user data");
                            return(result);
                        }

                        // Not adding access groups to MIIM user, so they should not be able to access ERS web application.
                        //adding access groups if no access groups assigned
                        //if (loggedInUser.UserSkills == null || loggedInUser.UserSkills.Count <= 0)
                        //{
                        //    DOADM_UserMaster objDOADM_UserMaster = new DOADM_UserMaster();
                        //    objDOADM_UserMaster.IsActive = true;
                        //    objDOADM_UserMaster.MSID = loginName;
                        //    objDOADM_UserMaster = objUserAdminstrationController.GetUserSearchResult(objDOADM_UserMaster, out errorMessage).FirstOrDefault();
                        //    AddAccessGroups(objDOADM_UserMaster);
                        //    objBLUserAdministration.SaveUser(objDOADM_UserMaster, out errorMessage);
                        //}

                        _currentLoginUserId              = loggedInUser.ADM_UserMasterId;
                        loggedInUser.WorkBasketLkup      = (long)objWorkBasket;
                        loggedInUser.BusinessSegmentLkup = (long)BusinessSegment.MNR;
                        loggedInUser.RoleLkup            = (long)RoleLkup.Processor;

                        //login user
                        result = objBLUserAdministration.LoginUser(loginName);
                        if (result != (long)ExceptionTypes.Success)
                        {
                            BLCommon.LogError(_currentLoginUserId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.MIIMConnector, (long)ExceptionTypes.Uncategorized, string.Empty, "Error while fetching logged in user data");
                        }
                        //create session
                        Session[ConstantTexts.CurrentUserSessionKey] = loggedInUser;
                        return(ExceptionTypes.Success);
                    }
                    else
                    {
                        UIUserLogin loggedInUser = (UIUserLogin)Session[ConstantTexts.CurrentUserSessionKey];
                        _currentLoginUserId = loggedInUser.ADM_UserMasterId;
                        //pick current user object and check access group is assigned
                        //check user has access to AD group
                        return(ExceptionTypes.Success);
                    }
                }
                else
                {
                    return(ExceptionTypes.UnauthorizedAccessException);
                }
            }
            catch (Exception ex)
            {
                BLCommon.LogError(_currentLoginUserId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.MIIMConnector, (long)ExceptionTypes.Uncategorized, ex.ToString(), ex.Message);
                return(ExceptionTypes.UnknownError);
            }
        }
Пример #11
0
        public ActionResult CreateRPRCase(string memberFName = "", string memberLName = "", string memberDOB = "", string hICN = "", string mIIMReferenceId = "")
        {
            ViewBag.PageName = ConstantTexts.MiimPageName;
            try
            {
                string requestData = "memberFName : " + memberFName + ",memberLName : " + memberLName + ",memberDOB : " + memberDOB + ",string hICN : " + hICN + ",string mIIMReferenceId : " + mIIMReferenceId;

                MIIMServiceLog(MethodBase.GetCurrentMethod().Name, requestData, ConstantTexts.MIIMNew, _currentLoginUserId, TarceMethodLkup.New.ToLong(), (long)MIIMServiceMethod.CreateRPRCase);
                #region Create Session
                ExceptionTypes result = CreateSession(WorkBasket.RPR);
                #endregion

                if (result == ExceptionTypes.Success)
                {
                    MIIMServiceLog(MethodBase.GetCurrentMethod().Name, requestData, ConstantTexts.MIIMUserAuthSucc, _currentLoginUserId, TarceMethodLkup.InProgress.ToLong(), (long)MIIMServiceMethod.CreateRPRCase);
                    DOGEN_Queue objDOGEN_Queue = new DOGEN_Queue();
                    #region Dropdowns Binding
                    List <DOADM_UserMaster> lstUsers;
                    DOADM_UserMaster        objDOADM_UserMaster = new DOADM_UserMaster();
                    objDOADM_UserMaster.IsActive = true;
                    BLUserAdministration objBLUserAdministration = new BLUserAdministration();
                    long?TimeZone = (long)DefaultTimeZone.CentralStandardTime;
                    result = objBLUserAdministration.SearchUser(TimeZone, objDOADM_UserMaster, out lstUsers, out string errorMessage);
                    objDOGEN_Queue.ComplianceStartDate  = DateTime.UtcNow;
                    objDOGEN_Queue.DiscrepancyStartDate = objDOGEN_Queue.ComplianceStartDate.Value.AddMonths(1);
                    objDOGEN_Queue.DiscrepancyStartDate = new DateTime(objDOGEN_Queue.DiscrepancyStartDate.Value.Year, objDOGEN_Queue.DiscrepancyStartDate.Value.Month, 1);
                    objDOGEN_Queue.lstUsers             = lstUsers.Where(x => x.ADM_UserMasterId > 1000 && x.IsManager).OrderBy(x => x.Email).ToList();//Filtered 1st three Users as Admin.sort list by email id
                    objDOGEN_Queue.lstLob                = CacheUtility.GetAllLookupsFromCache((long)LookupTypes.LOB);
                    objDOGEN_Queue.lstDiscCategary       = CacheUtility.GetAllLookupMasterCorrelationFromCache((long)LookupTypesCorrelation.WorkBasketVsDiscripancyCategory, (long)WorkBasket.RPR);
                    objDOGEN_Queue.lstContractid         = CacheUtility.GetAllLookupsFromCache((long)LookupTypes.Contract);
                    objDOGEN_Queue.lstPbpid              = CacheUtility.GetAllLookupsFromCache((long)LookupTypes.PBPID);
                    objDOGEN_Queue.lstActionRequested    = CacheUtility.GetAllLookupsFromCache((long)LookupTypes.RPRActionRequested);
                    objDOGEN_Queue.lstTaskBeingPerformed = CacheUtility.GetAllLookupsFromCache((long)LookupTypes.Taskbeingperformedwhenthisdiscrepancywasidentified);
                    objDOGEN_Queue.lstDiscType           = CacheUtility.GetAllLookupMasterCorrelationFromCache((long)LookupTypesCorrelation.DiscripancyCategoryVsDiscripancyType, (long)DiscripancyCategory.RPR);
                    #endregion

                    objDOGEN_Queue.MemberFirstName = memberFName;
                    objDOGEN_Queue.MemberLastName  = memberLName;
                    objDOGEN_Queue.MIIMReferenceId = mIIMReferenceId;
                    bool isDobCorrect = DateTime.TryParse(memberDOB, out DateTime dtMemberDob);
                    if (isDobCorrect)
                    {
                        objDOGEN_Queue.MemberDOB = dtMemberDob.AddDays(1);
                    }
                    objDOGEN_Queue.MemberCurrentHICN = hICN;
                    MIIMServiceLog(MethodBase.GetCurrentMethod().Name, requestData, ConstantTexts.MIIMRequestCompleted, _currentLoginUserId, TarceMethodLkup.Completed.ToLong(), (long)MIIMServiceMethod.CreateRPRCase);
                    return(View("~/Views/RPR/Create.cshtml", objDOGEN_Queue));
                }
                else if (result == ExceptionTypes.UnknownError)
                {
                    MIIMServiceLog(MethodBase.GetCurrentMethod().Name, requestData, ConstantTexts.MIIMUserAuthFail, _currentLoginUserId, TarceMethodLkup.Completed.ToLong(), (long)MIIMServiceMethod.CreateRPRCase);
                    ViewBag.ErrorMessage = "\nYou are not part of ERS DB.\nPlease contact administrator";
                    return(View("~/Views/Shared/Error.cshtml"));
                }
                else
                {
                    MIIMServiceLog(MethodBase.GetCurrentMethod().Name, requestData, ConstantTexts.MIIMUserAuthFail, _currentLoginUserId, TarceMethodLkup.Completed.ToLong(), (long)MIIMServiceMethod.CreateRPRCase);
                    ViewBag.ErrorMessage = "\nYou do not have permission to access this page.\nPlease contact administrator";
                    return(View("~/Views/Shared/Error.cshtml"));
                }
            }
            catch (Exception ex)
            {
                MIIMServiceLog(MethodBase.GetCurrentMethod().Name, "", ex.ToString(), _currentLoginUserId, TarceMethodLkup.Failed.ToLong(), (long)MIIMServiceMethod.CreateRPRCase);
                BLCommon.LogError(_currentLoginUserId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.MIIMConnector, (long)ExceptionTypes.Uncategorized, ex.ToString(), ex.Message);
                return(View("~/Views/Shared/Error.cshtml"));
            }
        }
Пример #12
0
        private bool UserLoggedIn(out UIUserLogin loggedInUser)
        {
            loggedInUser = null;
            try
            {
                if (CurrentUser == null)
                {
                    string[] strLoginName = System.Web.HttpContext.Current.User.Identity.Name.Split(new string[] { @"\" }, StringSplitOptions.RemoveEmptyEntries);
                    string   domain       = strLoginName[0];
                    string   loginName    = strLoginName[1];

                    //Checking user in Database.
                    BLUserAdministration objBLUserAdministration = new BLUserAdministration();
                    ExceptionTypes       result = objBLUserAdministration.GetUserAccessPermission(loginName, null, null, null, out loggedInUser);
                    if (result == ExceptionTypes.ZeroRecords)
                    {
                        return(false);
                    }
                    if (result != (long)ExceptionTypes.Success)
                    {
                        return(false);
                    }
                    else
                    {
                        System.Security.Principal.WindowsIdentity             winIdnt = System.Web.HttpContext.Current.User.Identity as System.Security.Principal.WindowsIdentity;
                        System.Security.Principal.IdentityReferenceCollection grps    = winIdnt.Groups;
                        //Admin
                        if (IsUserInADGroup(grps, WebConfigData.AdminSID))
                        {
                            loggedInUser.IsAdminUser = true;
                        }

                        //OST
                        if (IsUserInADGroup(grps, WebConfigData.AdminOSTSID))
                        {
                            loggedInUser.IsAdmOSTUser = true;
                        }
                        if (IsUserInADGroup(grps, WebConfigData.ManagerOSTSID))
                        {
                            loggedInUser.IsMgrOSTUser = true;
                        }
                        if (IsUserInADGroup(grps, WebConfigData.ProcessorOSTSID))
                        {
                            loggedInUser.IsPrcrOSTUser = true;
                        }
                        if (IsUserInADGroup(grps, WebConfigData.ViewerOSTSID))
                        {
                            loggedInUser.IsVwrOSTUser = true;
                        }

                        //Eligibility
                        if (IsUserInADGroup(grps, WebConfigData.AdminEligSID))
                        {
                            loggedInUser.IsAdmEligUser = true;
                        }
                        if (IsUserInADGroup(grps, WebConfigData.ManagerEligSID))
                        {
                            loggedInUser.IsMgrEligUser = true;
                        }
                        if (IsUserInADGroup(grps, WebConfigData.ProcessorEligSID))
                        {
                            loggedInUser.IsPrcrEligUser = true;
                        }
                        if (IsUserInADGroup(grps, WebConfigData.ViewerEligSID))
                        {
                            loggedInUser.IsVwrEligUser = true;
                        }

                        //RPR
                        if (IsUserInADGroup(grps, WebConfigData.AdminRPRSID))
                        {
                            loggedInUser.IsAdmRPRUser = true;
                        }
                        if (IsUserInADGroup(grps, WebConfigData.ManagerRPRSID))
                        {
                            loggedInUser.IsMgrRPRUser = true;
                        }
                        if (IsUserInADGroup(grps, WebConfigData.ProcessorRPRSID))
                        {
                            loggedInUser.IsPrcrRPRUser = true;
                        }
                        if (IsUserInADGroup(grps, WebConfigData.ViewerRPRSID))
                        {
                            loggedInUser.IsVwrRPRUser = true;
                        }

                        if (loggedInUser.IsAdminUser == false &&
                            loggedInUser.IsAdmOSTUser == false &&
                            loggedInUser.IsAdmEligUser == false &&
                            loggedInUser.IsAdmRPRUser == false &&
                            loggedInUser.IsMgrOSTUser == false &&
                            loggedInUser.IsMgrEligUser == false &&
                            loggedInUser.IsMgrRPRUser == false &&
                            loggedInUser.IsPrcrOSTUser == false &&
                            loggedInUser.IsPrcrEligUser == false &&
                            loggedInUser.IsPrcrRPRUser == false &&
                            loggedInUser.IsVwrOSTUser == false &&
                            loggedInUser.IsVwrEligUser == false &&
                            loggedInUser.IsVwrRPRUser == false &&
                            loggedInUser.IsWebServiceUser == false &&
                            loggedInUser.IsMacroServiceUser == false
                            )
                        {
                            return(false);
                        }
                        else
                        {
                            CurrentUser = loggedInUser;
                        }
                    }
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        public ActionResult Add(DOADM_UserMaster objDOADM_UserMaster)
        {
            string         errorMessage  = string.Empty;
            ExceptionTypes result        = new ExceptionTypes();
            string         returnMessage = string.Empty;

            try
            {
                //check if this call is to update record or save new record
                if (objDOADM_UserMaster.ADM_UserMasterId > 0)
                {
                    //if old record is to be updated
                    BLCommon objCommon = new BLCommon();
                    //check if record is locked by current user
                    if (!objCommon.ValidateLockBeforeSave(currentUser.ADM_UserMasterId, (long)ScreenType.UserAdmin, objDOADM_UserMaster.ADM_UserMasterId))
                    {
                        //if record is not locked by current user dont save record and return error.
                        errorMessage = "Record not locked, please reload the page.";
                        result       = ExceptionTypes.UnknownError;
                        return(Json(new { ID = result, Message = errorMessage }));
                    }
                    returnMessage = "Record updated successfully.";
                }
                else
                {
                    objDOADM_UserMaster.CreatedByRef = currentUser.ADM_UserMasterId;
                    //If new record to be saved
                    returnMessage = "Record saved successfully.";
                }

                objDOADM_UserMaster.FullName        = objDOADM_UserMaster.FirstName != null ? objDOADM_UserMaster.LastName + ", " + objDOADM_UserMaster.FirstName : objDOADM_UserMaster.LastName;
                objDOADM_UserMaster.SpecialistFax   = String.IsNullOrEmpty(objDOADM_UserMaster.SpecialistFax) ? "" : String.Join("", objDOADM_UserMaster.SpecialistFax.Split('-'));
                objDOADM_UserMaster.SpecialistPhone = String.IsNullOrEmpty(objDOADM_UserMaster.SpecialistPhone) ? "" : String.Join("", objDOADM_UserMaster.SpecialistPhone.Split('-'));
                objDOADM_UserMaster.UserZip         = String.IsNullOrEmpty(objDOADM_UserMaster.UserZip) ? "" : String.Join("", objDOADM_UserMaster.UserZip.Split('-'));
                objDOADM_UserMaster.IsActive        = objDOADM_UserMaster.IsActive;
                objDOADM_UserMaster.IsManager       = objDOADM_UserMaster.IsManager;

                objDOADM_UserMaster.CreatedByRoleLkup = currentUser.RoleLkup;
                objDOADM_UserMaster.UpdatedByRoleLkup = currentUser.RoleLkup;
                objDOADM_UserMaster.LastUpdatedByRef  = currentUser.ADM_UserMasterId;

                if (Session[ConstantTexts.UserAccessGroupSessionKey] != null)
                {
                    objDOADM_UserMaster.lstDOADM_AccessGroupUserCorrelation = Session[ConstantTexts.UserAccessGroupSessionKey] as List <DOADM_AccessGroupUserCorrelation>;
                }

                BLUserAdministration objBLUserAdministration = new BLUserAdministration();
                result = objBLUserAdministration.SaveUser(objDOADM_UserMaster, out errorMessage);
                if (result != (long)ExceptionTypes.Success)
                {
                    BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.ManageUsers, (long)ExceptionTypes.Uncategorized, string.Empty, "error occured while saving data");
                    return(Json(new { ID = result, Message = "An error occured while updating DB." }));
                }
                return(Json(new { ID = result, Message = returnMessage }));
            }
            catch (Exception ex)
            {
                BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.ManageUsers, (long)ExceptionTypes.Uncategorized, string.Empty, ex.ToString());
                return(RedirectToAction("Maintenance", "Error", new { Error = MethodBase.GetCurrentMethod().Name + " Action terminated and redirected to Maintenance. Error:" + ex.ToString() }));
            }
        }
Пример #14
0
        public ActionResult Add(long AlertId = 0, bool isActive = true)
        {
            DOADM_AlertDetails objDOADM_AlertDetails = new DOADM_AlertDetails();

            objDOADM_AlertDetails.IsActive = true;
            string errorMessage = string.Empty;

            try
            {
                ExceptionTypes result;

                //get list of users for Send ALert to Indiviual drop down
                List <DOADM_UserMaster> lstUsers;
                BLUserAdministration    objBLUserAdministration = new BLUserAdministration();
                DOADM_UserMaster        objDOADM_UserMaster     = new DOADM_UserMaster();
                objDOADM_UserMaster.IsActive = true;
                long?TimeZone = currentUser.ADM_UserPreference.TimezoneLkup != null ? currentUser.ADM_UserPreference.TimezoneLkup : (long)DefaultTimeZone.CentralStandardTime;
                result = objBLUserAdministration.SearchUser(TimeZone, objDOADM_UserMaster, out lstUsers, out errorMessage);
                //check result for DB action
                if (result != (long)ExceptionTypes.Success)
                {
                    BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Alerts, (long)ExceptionTypes.Uncategorized, errorMessage, errorMessage);
                }
                //Filtered 1st three Users as Admin.sort list by email id
                lstUsers = lstUsers.Where(x => x.ADM_UserMasterId > 1000).OrderBy(x => x.Email).ToList();

                //get list of Depatments for Send ALert to Department drop down
                List <DOCMN_Department> lstCMN_Department;
                BLDepartment            objBLDepartment     = new BLDepartment();
                DOCMN_Department        objDOCMN_Department = new DOCMN_Department();
                objDOCMN_Department.IsActive = true;
                result = objBLDepartment.SearchDepartment(TimeZone, objDOCMN_Department, out lstCMN_Department, out errorMessage);
                //check result for DB action
                if (result != (long)ExceptionTypes.Success)
                {
                    BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Alerts, (long)ExceptionTypes.Uncategorized, errorMessage, errorMessage);
                }
                //sort list by Depatment name
                lstCMN_Department = lstCMN_Department.OrderBy(x => x.ERSDepartmentName).ToList();

                if (AlertId != 0)
                {
                    //temporary list to hold search alerts results
                    List <DOADM_AlertDetails> lstDOADM_AlertDetails = new List <DOADM_AlertDetails>();
                    //temporary object for search alerts function
                    DOADM_AlertDetails objDOADM_AlertDetails_Find = new DOADM_AlertDetails();
                    objDOADM_AlertDetails_Find.ADM_AlertDetailsId = AlertId;
                    objDOADM_AlertDetails_Find.IsActive           = isActive;
                    result = _objBLAlerts.SearchAlerts(TimeZone, objDOADM_AlertDetails_Find, out lstDOADM_AlertDetails, out errorMessage);
                    //check result for DB action
                    if (result != (long)ExceptionTypes.Success)
                    {
                        BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Alerts, (long)ExceptionTypes.Uncategorized, errorMessage, errorMessage);
                    }
                    if (lstDOADM_AlertDetails.Count > 0)
                    {
                        objDOADM_AlertDetails = lstDOADM_AlertDetails.FirstOrDefault();
                    }
                }

                objDOADM_AlertDetails.lstUsers          = lstUsers;
                objDOADM_AlertDetails.lstCMN_Department = lstCMN_Department;
                //Alert criticality lookup from Cache
                objDOADM_AlertDetails.lstAlertCriticalityLkup = CacheUtility.GetAllLookupsFromCache((long)LookupTypes.AlertCriticality);
                //Send Alert To lookup from Cache
                objDOADM_AlertDetails.lstSendAlertToLkup = CacheUtility.GetAllLookupsFromCache((long)LookupTypes.SendAlertTo);
                //Alert Time Zone lookup from Cache
                objDOADM_AlertDetails.lstTimeZone = CacheUtility.GetAllLookupsFromCache((long)LookupTypes.Timezone);
                return(View(objDOADM_AlertDetails));
            }
            catch (Exception ex)
            {
                BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Alerts, (long)ExceptionTypes.Uncategorized, ex.ToString(), ex.ToString());
                return(RedirectToAction("Maintenance", "Error", new { Error = ex.ToString() }));
            }
        }