示例#1
0
        public JsonResult CheckDuplicateConfigName(string ConfigName)
        {
            long?                     TimeZone            = currentUser.ADM_UserPreference.TimezoneLkup != null ? currentUser.ADM_UserPreference.TimezoneLkup : (long)DefaultTimeZone.CentralStandardTime;
            var                       data                = "";
            BLConfigurations          objBLConfigurations = new BLConfigurations();
            List <DOMGR_ConfigMaster> lstDDOMGR_ConfigMaster;

            DOMGR_ConfigMaster objDOMGR_ConfigMaster = new DOMGR_ConfigMaster();

            objDOMGR_ConfigMaster.ConfigName = ConfigName;
            objDOMGR_ConfigMaster.IsActive   = true;

            string         errorMessage = string.Empty;
            ExceptionTypes result       = objBLConfigurations.SearchConfiguration(TimeZone, objDOMGR_ConfigMaster, out lstDDOMGR_ConfigMaster, out errorMessage);

            if (result != (long)ExceptionTypes.Success)
            {
                //Log error
                BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Configurations, (long)ExceptionTypes.Uncategorized, errorMessage.ToString(), errorMessage.ToString());
            }
            else if (result == ExceptionTypes.ZeroRecords)
            {
                lstDDOMGR_ConfigMaster.Add(objDOMGR_ConfigMaster);
                lstDDOMGR_ConfigMaster = new List <DOMGR_ConfigMaster>();
            }

            int i = lstDDOMGR_ConfigMaster.Count;

            if (i > 0)
            {
                data = "Configuration Name already exists.";
            }
            return(Json(new { Data = data }, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        public ActionResult Add(DOMGR_ConfigMaster ConfigMaster)
        {
            string         errorMessage  = string.Empty;
            string         returnMessage = string.Empty;
            ExceptionTypes result        = new ExceptionTypes();

            try
            {
                long               loginUserId           = currentUser.ADM_UserMasterId;
                BLConfigurations   objBLConfigurations   = new BLConfigurations();
                DOMGR_ConfigMaster objDOMGR_ConfigMaster = new DOMGR_ConfigMaster();
                objDOMGR_ConfigMaster.MGR_ConfigMasterId = ConfigMaster.MGR_ConfigMasterId;
                if (objDOMGR_ConfigMaster.MGR_ConfigMasterId > 0) // Edit Mode
                {
                    BLCommon objCommon = new BLCommon();
                    if (!objCommon.ValidateLockBeforeSave(loginUserId, (long)ScreenType.Configuration, objDOMGR_ConfigMaster.MGR_ConfigMasterId))
                    {
                        errorMessage = "Record not locked, please reload the page.";
                        result       = ExceptionTypes.UnknownError;
                        return(Json(new { ID = result, Message = errorMessage }));
                    }
                    objDOMGR_ConfigMaster.CreatedByRef = loginUserId;
                    returnMessage = "Record updated successfully.";
                }
                else
                {
                    objDOMGR_ConfigMaster.CreatedByRef = loginUserId;  //Add Mode
                    returnMessage = "Record saved successfully.";
                }
                objDOMGR_ConfigMaster.ConfigName  = ConfigMaster.ConfigName;
                objDOMGR_ConfigMaster.ConfigValue = ConfigMaster.ConfigValue;
                objDOMGR_ConfigMaster.StartDate   = ConfigMaster.StartDate;
                objDOMGR_ConfigMaster.EndDate     = ConfigMaster.EndDate;
                objDOMGR_ConfigMaster.IsActive    = ConfigMaster.IsActive;
                result = objBLConfigurations.SaveConfigMaster(objDOMGR_ConfigMaster, out errorMessage);

                if (result != (long)ExceptionTypes.Success)
                {
                    BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Configurations, (long)ExceptionTypes.Uncategorized, errorMessage.ToString(), errorMessage.ToString());
                    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.Configurations, (long)ExceptionTypes.Uncategorized, ex.ToString(), ex.ToString());
                return(Json(new { ID = result, Message = "An error occured while performing Save action." }));
            }
        }
示例#3
0
        /// <summary>
        /// Get All master configuration
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        private static void GetAllConfigurationIfNoCache()
        {
            long?  TimeZone     = (long)DefaultTimeZone.CentralStandardTime;
            string errorMessage = string.Empty;

            if (System.Web.HttpContext.Current.Cache[ConstantTexts.MasterConfigurarionsCacheKey] == null)
            {
                BLConfigurations          objBLConfigurations   = new BLConfigurations();
                List <DOMGR_ConfigMaster> lstDOMGR_ConfigMaster = new List <DOMGR_ConfigMaster>();
                DOMGR_ConfigMaster        objDOMGR_ConfigMaster = new DOMGR_ConfigMaster();
                objDOMGR_ConfigMaster.IsActive = true;
                ExceptionTypes reportResult = objBLConfigurations.SearchConfiguration(TimeZone, objDOMGR_ConfigMaster, out lstDOMGR_ConfigMaster, out errorMessage);
                AddToCache(ConstantTexts.MasterConfigurarionsCacheKey, lstDOMGR_ConfigMaster);
            }
        }
示例#4
0
        /// <summary>
        /// Fetch all Configurations If no Cache is available
        /// </summary>
        private static void GetAllConfigurationIfNoCache()
        {
            long TimeZone = (long)DefaultTimeZone.CentralStandardTime;

            if (!MemoryCache.Default.Contains(ConstantTexts.ConfigurationsCacheKey))
            {
                BLConfigurations   objBLConfigurations   = new BLConfigurations();
                DOMGR_ConfigMaster objDOMGR_ConfigMaster = new DOMGR_ConfigMaster()
                {
                    IsActive = true
                };
                ExceptionTypes exResult = objBLConfigurations.SearchConfiguration(TimeZone, objDOMGR_ConfigMaster, out List <DOMGR_ConfigMaster> lstDOMGR_ConfigMaster, out string errorMessage);
                // Store data in the cache
                AddToCache(ConstantTexts.ConfigurationsCacheKey, lstDOMGR_ConfigMaster, DateTime.Now.AddHours(1));
            }
        }
示例#5
0
        internal List <DOMGR_ConfigMaster> PGetConfiguration(string strConfigName = "", bool isActive = true)
        {
            long?                     TimeZone            = currentUser.ADM_UserPreference.TimezoneLkup != null ? currentUser.ADM_UserPreference.TimezoneLkup : (long)DefaultTimeZone.CentralStandardTime;
            BLConfigurations          objBLConfigurations = new BLConfigurations();
            List <DOMGR_ConfigMaster> lstDOMGR_ConfigMaster;

            try
            {
                DOMGR_ConfigMaster objDOMGR_ConfigMaster = new DOMGR_ConfigMaster();
                objDOMGR_ConfigMaster.ConfigName = strConfigName;
                if (isActive)
                {
                    objDOMGR_ConfigMaster.IsActive = Convert.ToBoolean(isActive);
                }
                else
                {
                    objDOMGR_ConfigMaster.IsActive = false;
                }
                string         errorMessage = string.Empty;
                ExceptionTypes result       = objBLConfigurations.SearchConfiguration(TimeZone, objDOMGR_ConfigMaster, out lstDOMGR_ConfigMaster, out errorMessage);
                if (result != (long)ExceptionTypes.Success)
                {
                    //Log error
                    BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Configurations, (long)ExceptionTypes.Uncategorized, errorMessage.ToString(), errorMessage.ToString());
                }
                else if (result == ExceptionTypes.ZeroRecords)
                {
                    lstDOMGR_ConfigMaster.Add(objDOMGR_ConfigMaster);
                    lstDOMGR_ConfigMaster = new List <DOMGR_ConfigMaster>();
                }
                return(lstDOMGR_ConfigMaster);
            }
            catch (Exception ex)
            {
                BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Configurations, (long)ExceptionTypes.Uncategorized, ex.ToString(), ex.ToString());
                throw ex;
            }
        }
示例#6
0
        public ActionResult Add(long ConfigId = 0, bool isActive = true)
        {
            long?TimeZone = currentUser.ADM_UserPreference.TimezoneLkup != null ? currentUser.ADM_UserPreference.TimezoneLkup : (long)DefaultTimeZone.CentralStandardTime;
            // Bind Dropdown List.
            string errorMessage = string.Empty;

            List <DOCMN_LookupMaster> lstTimezone;

            lstTimezone = CacheUtility.GetAllLookupsFromCache((long)LookupTypes.Timezone);
            BLConfigurations          objBLConfigurations   = new BLConfigurations();
            List <DOMGR_ConfigMaster> lstDOMGR_ConfigMaster = new List <DOMGR_ConfigMaster>();
            DOMGR_ConfigMaster        objDOMGR_ConfigMaster = new DOMGR_ConfigMaster();

            objDOMGR_ConfigMaster.IsActive = true;
            if (ConfigId != 0)
            {
                // Fetch Record By Configuration ID.
                objDOMGR_ConfigMaster.MGR_ConfigMasterId = ConfigId;
                objDOMGR_ConfigMaster.IsActive           = isActive;
                ExceptionTypes result = objBLConfigurations.SearchConfigId(TimeZone, objDOMGR_ConfigMaster, out lstDOMGR_ConfigMaster, out errorMessage);
                if (result != (long)ExceptionTypes.Success)
                {
                    //Log Error
                    BLCommon.LogError(currentUser.ADM_UserMasterId, MethodBase.GetCurrentMethod().Name, (long)ErrorModuleName.Configurations, (long)ExceptionTypes.Uncategorized, errorMessage.ToString(), errorMessage.ToString());
                }
                if (lstDOMGR_ConfigMaster.Count > 0)
                {
                    objDOMGR_ConfigMaster = lstDOMGR_ConfigMaster.FirstOrDefault();
                }
            }
            else
            {
                objDOMGR_ConfigMaster.StartDate = DateTime.UtcNow;
            }
            objDOMGR_ConfigMaster.lstTimeZone = lstTimezone;
            return(View("Add", objDOMGR_ConfigMaster));
        }