public ExceptionTypes SaveUser(DOADM_UserMaster objDOADM_UserMaster, out string errorMessage)
        {
            retValue = new ExceptionTypes();
            DALUserAdministration objDALUserAdministration = new DALUserAdministration();

            return(retValue = objDALUserAdministration.SaveUser(objDOADM_UserMaster, out errorMessage));
        }
        public ExceptionTypes SearchUser(long?TimeZone, DOADM_UserMaster objDOADM_UserMaster, out List <DOADM_UserMaster> lstDOADM_UserMaster, out string errorMessage)
        {
            retValue = new ExceptionTypes();
            DALUserAdministration objDALUserAdministration = new DALUserAdministration();

            return(retValue = objDALUserAdministration.SearchUser(TimeZone, objDOADM_UserMaster, out lstDOADM_UserMaster, out errorMessage));
        }
示例#3
0
        public ExceptionTypes GetUserBasedOnMSID(string MSID, out DOADM_UserMaster objDOADM_UserMaster)
        {
            retValue = new ExceptionTypes();
            UserAdministrationDAL objUserAdministrationDAL = new UserAdministrationDAL();

            return(retValue = objUserAdministrationDAL.GetUserBasedOnMSID(MSID, out objDOADM_UserMaster));
        }
        public ExceptionTypes GetUserBasedOnMSID(long?TimeZone, string MSID, out DOADM_UserMaster objDOADM_UserMaster)
        {
            retValue = new ExceptionTypes();
            DALUserAdministration objDALUserAdministration = new DALUserAdministration();

            return(retValue = objDALUserAdministration.GetUserBasedOnMSID(TimeZone, MSID, out objDOADM_UserMaster));
        }
 public ActionResult Search(string strMSID = "", string strEmail = "", string strFullname = "", bool bIsActive = true)
 {
     try
     {
         DOADM_UserMaster        objDOADM_UserMaster = new DOADM_UserMaster();
         List <DOADM_UserMaster> lstDOADM_UserMaster = new List <DOADM_UserMaster>();
         string strErrorMessage = string.Empty;
         objDOADM_UserMaster.MSID     = strMSID;
         objDOADM_UserMaster.Email    = strEmail;
         objDOADM_UserMaster.FullName = strFullname;
         objDOADM_UserMaster.IsActive = bIsActive;
         long?TimeZone = currentUser.ADM_UserPreference.TimezoneLkup != null ? currentUser.ADM_UserPreference.TimezoneLkup : (long)DefaultTimeZone.CentralStandardTime;
         lstDOADM_UserMaster = GetUserSearchResult(TimeZone, objDOADM_UserMaster, out strErrorMessage);
         if (strErrorMessage != "")
         {
             BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.ManageUsers, (long)ExceptionTypes.Uncategorized, string.Empty, "error occred while retriving search results");
             lstDOADM_UserMaster = new List <DOADM_UserMaster>();
         }
         return(PartialView("_SearchResults", lstDOADM_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() }));
     }
 }
        private void AddAccessGroups(DOADM_UserMaster objDOADM_UserMaster)
        {
            long?         TimeZone         = (long)DefaultTimeZone.CentralStandardTime;
            BLAccessGroup objBLAccessGroup = new BLAccessGroup();

            //get List of Access groups to be added
            List <DOADM_AccessGroupMaster> lstDOADM_AccessGroupMaster;

            objBLAccessGroup.GetAccessGroupBasedOnSearch(TimeZone, new DOADM_AccessGroupMaster {
                AccessGroupName = ConstantTexts.MIIMAccessGroupSearchKey, IsActive = true
            }, out lstDOADM_AccessGroupMaster);

            if (lstDOADM_AccessGroupMaster.Count > 0)
            {
                foreach (DOADM_AccessGroupMaster objDOADM_AccessGroupMaster in lstDOADM_AccessGroupMaster)
                {
                    DOADM_AccessGroupUserCorrelation objDOADM_AccessGroupUserCorrelation = new DOADM_AccessGroupUserCorrelation();
                    objDOADM_AccessGroupUserCorrelation.IsActive = true;
                    objDOADM_AccessGroupUserCorrelation.ADM_AccessGroupMasterRef = objDOADM_AccessGroupMaster.ADM_AccessGroupMasterId;
                    objDOADM_AccessGroupUserCorrelation.ADM_UserMasterRef        = 0;
                    objDOADM_AccessGroupUserCorrelation.CreatedByRef             = _currentLoginUserId;
                    objDOADM_AccessGroupUserCorrelation.UTCCreatedOn             = DateTime.UtcNow;
                    objDOADM_AccessGroupUserCorrelation.LastUpdatedByRef         = _currentLoginUserId;
                    objDOADM_AccessGroupUserCorrelation.UTCLastUpdatedOn         = DateTime.UtcNow;
                    objDOADM_UserMaster.lstDOADM_AccessGroupUserCorrelation.Add(objDOADM_AccessGroupUserCorrelation);
                }
            }
        }
        public ActionResult GetUserDetailsLdap(string data)
        {
            ExceptionTypes result        = new ExceptionTypes();
            string         returnMessage = string.Empty;

            try
            {
                DOADM_UserMaster user        = null;
                bool             isUserFound = GetUserDetails(data, true, out user);

                if (!isUserFound)
                {
                    isUserFound = GetUserDetails(data, false, out user);
                }

                if (isUserFound)
                {
                    result = ExceptionTypes.Success;
                }
                else
                {
                    result        = ExceptionTypes.Exception;
                    returnMessage = "User not found in Active directory.";
                }
                return(Json(new { ID = result, Message = returnMessage, data = user }));
            }
            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 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 Search()
        {
            List <DOADM_UserMaster> lstDOADM_UserMaster = new List <DOADM_UserMaster>();
            string           strErrorMessage            = string.Empty;
            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;

            lstDOADM_UserMaster = GetUserSearchResult(TimeZone, objDOADM_UserMaster, out strErrorMessage);
            if (strErrorMessage != "")
            {
                BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.ManageUsers, (long)ExceptionTypes.Uncategorized, string.Empty, "error occred while retriving search results");
                lstDOADM_UserMaster = new List <DOADM_UserMaster>();
            }
            return(View(lstDOADM_UserMaster));
        }
        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);
        }
        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"));
            }
        }
        /// <summary>
        /// Method to load user details by user id, Msid.
        /// </summary>
        /// <param name="strMSID"></param>
        /// <param name="isMSDomain"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool GetUserDetails(string strMSID, bool isMSDomain, out DOADM_UserMaster user)
        {
            bool isUserFound = false;

            user = new DOADM_UserMaster();
            string errorMessage = string.Empty;

            long?TimeZone = (long)DefaultTimeZone.CentralStandardTime;  //just dummy time for Search SP. Not actually used

            try
            {
                DirectoryEntry entry = null;

                if (isMSDomain)
                {
                    string serviceAccountName = WebConfigData.DmLogin;
                    string decryptPwd         = WebConfigData.DmPwd;

                    string strDomain = WebConfigData.MSDomain;// "ms.ds.uhc.com";
                    entry = new DirectoryEntry("LDAP://" + strDomain, serviceAccountName, decryptPwd);
                }
                else
                {
                    string strDomain = "XLHEALTH";
                    entry = new DirectoryEntry("LDAP://" + strDomain);
                }

                DirectorySearcher search = new DirectorySearcher(entry);
                search.ReferralChasing = ReferralChasingOption.All;
                search.Filter          = ("(SAMAccountName=" + strMSID + ")");
                //Searcher.Filter = ("(anr=" + strLoginName + ")");
                SearchResultCollection searchResult = search.FindAll();

                StringBuilder sbResult = new StringBuilder();
                Regex         rxCnName = new Regex("CN\\=([^\\,]+)");

                if (searchResult != null)
                {
                    foreach (SearchResult sr in searchResult)
                    {
                        isUserFound = true;
                        string strUserName = (sr.GetDirectoryEntry().Name).Replace("CN=", "").Replace(@"\", "");
                        //user full name
                        PropertyValueCollection displayName       = null;
                        PropertyValueCollection displayName_Fname = null;
                        PropertyValueCollection displayName_Lname = null;

                        displayName       = sr.GetDirectoryEntry().Properties["displayName"];
                        displayName_Fname = sr.GetDirectoryEntry().Properties["givenname"];
                        displayName_Lname = sr.GetDirectoryEntry().Properties["sn"];

                        if (displayName != null && displayName.Value != null)
                        {
                            //user.FullName = displayName.Value.ToString();
                        }
                        if (displayName_Fname != null && displayName_Fname.Value != null && displayName_Lname != null && displayName_Lname.Value != null)
                        {
                            user.FullName = displayName_Fname.Value.ToString() + " " + displayName_Lname.Value.ToString();
                        }
                        else if ((displayName_Fname != null && displayName_Fname.Value != null) && (displayName_Lname == null && displayName_Lname.Value == null))
                        {
                            user.FullName = displayName_Fname.Value.ToString();
                        }
                        else if ((displayName_Fname == null && displayName_Fname.Value == null) && (displayName_Lname != null && displayName_Lname.Value != null))
                        {
                            user.FullName = displayName_Lname.Value.ToString();
                        }
                        else
                        {
                            user.FullName = displayName.Value.ToString();
                        }

                        if (!user.FullName.IsNullOrEmpty())
                        {
                            if (user.FullName.Split(' ').Length > 0)
                            {
                                user.FirstName = user.FullName.Split(' ')[0].IsNullOrEmpty() ? "" : user.FullName.Split(' ')[0].ToString();
                            }
                            if (user.FullName.Split(' ').Length > 1)
                            {
                                user.LastName = user.FullName.Split(' ')[1].IsNullOrEmpty() ? "" : user.FullName.Split(' ')[1].ToString();
                            }
                        }

                        //manager
                        PropertyValueCollection manager = null;
                        manager = sr.GetDirectoryEntry().Properties["manager"];
                        if (manager != null)
                        {
                            Match  mManager    = rxCnName.Match(manager[0].ToString());
                            string managerMsid = "";
                            if (mManager.Success)
                            {
                                managerMsid = mManager.Groups[1].Value;
                                DOADM_UserMaster mgrDOADM_UserMaster = new DOADM_UserMaster();
                                mgrDOADM_UserMaster.MSID     = managerMsid;
                                mgrDOADM_UserMaster.IsActive = true;
                                //get manager id by msid
                                var listUsers = GetUserSearchResult(TimeZone, mgrDOADM_UserMaster, out errorMessage);
                                if (listUsers.Count > 0)
                                {
                                    user.ManagerId = listUsers.FirstOrDefault().ADM_UserMasterId;
                                }
                            }
                        }

                        //mail

                        if (isMSDomain)
                        {
                            PropertyValueCollection mail = null;
                            mail = sr.GetDirectoryEntry().Properties["mail"];
                            if (mail != null && mail.Value != null)
                            {
                                user.Email = mail.Value.ToString();
                            }
                        }
                        else
                        {
                            PropertyValueCollection mail = null;
                            mail = sr.GetDirectoryEntry().Properties["userPrincipalName"];
                            if (mail != null && mail.Value != null)
                            {
                                user.Email = mail.Value.ToString().Replace("local", "com");
                            }
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.ManageUsers, (long)ExceptionTypes.Uncategorized, string.Empty, ex.ToString());
            }

            return(isUserFound);
        }
        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() }));
            }
        }
示例#15
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() }));
            }
        }