Esempio n. 1
0
        public List <UserRole> UsersInRolesGet(string user)
        {
            string cacheKey  = user + "Roles";
            object cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                cacheItem = dal.UsersInRolesGet(user.Substring(user.LastIndexOf("\\") + 1));
                MarsV2Cache.AddObjectToCache(cacheKey, cacheItem);
            }
            return(new List <UserRole>((List <UserRole>)cacheItem));
        }
        public List <CarGroup> CarGroupListGetByCountryID(string countryID)
        {
            string cacheKey  = "CarGroupAll_" + countryID;
            object cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                cacheItem = DAL.CarGroupListGetByCountryID(countryID);
                MarsV2Cache.AddObjectToCache(cacheKey, cacheItem);
            }
            return(new List <CarGroup>((List <CarGroup>)cacheItem));
        }
Esempio n. 3
0
        public List <Country> CountryGetAllByRole(string user)
        {
            string cacheKey  = user + "Country";
            object cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                cacheItem = dal.CountryGetAllByRole(user.Substring(user.LastIndexOf("\\") + 1));
                MarsV2Cache.AddObjectToCacheWithNoSlidingExpiry(cacheKey, cacheItem);
            }
            return(new List <Country>((List <Country>)cacheItem));
        }
        public List <Country> CountryGetAll()
        {
            string cacheKey  = MarsV2Cache.CountryList;
            object cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                cacheItem = DAL.CountryGetAll();
                MarsV2Cache.AddObjectToCache(cacheKey, cacheItem);
            }
            return(new List <Country>((List <Country>)cacheItem));
        }
Esempio n. 5
0
        internal static List <BranchHolder> GetAllBranches()
        {
            var cacheKey  = MarsV2Cache.MarsBranchList;
            var cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                cacheItem = ParameterDataAccess.GetAllBranches();
                MarsV2Cache.AddObjectToCache(cacheKey, cacheItem);
            }

            return((List <BranchHolder>)cacheItem);
        }
Esempio n. 6
0
        /// <summary>
        /// Retrieves the List of Location Groups either from the Cache or Database
        /// </summary>
        /// <returns>Location Pool Ids and Names</returns>
        internal static List <LocationGroupHolder> GetAllLocationGroups()
        {
            var cacheKey  = MarsV2Cache.MarsLocationGroupList;
            var cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                cacheItem = ParameterDataAccess.GetAllLocationPools();
                MarsV2Cache.AddObjectToCache(cacheKey, cacheItem);
            }

            return((List <LocationGroupHolder>)cacheItem);
        }
Esempio n. 7
0
        public List <CMSReportingTimeZone> CMSReportingTimeZoneGetAll()
        {
            string cacheKey  = MarsV2Cache.CMSReportingTimeZone;
            object cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                cacheItem = _dal.CMSReportingTimeZoneGetAll();
                MarsV2Cache.AddObjectToCache(cacheKey, cacheItem);
            }

            return((List <CMSReportingTimeZone>)cacheItem);
        }
Esempio n. 8
0
        public List <CMSForecastType> CMSForecastTypeGetAll(bool frozenZoneSelected)
        {
            string cacheKey  = frozenZoneSelected ? MarsV2Cache.CMSForecastTypeWithAlreadyBooked : MarsV2Cache.CMSForecastTypeWithoutAlreadyBooked;
            object cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                cacheItem = _dal.CMSForecastTypeGetAll(frozenZoneSelected);
                MarsV2Cache.AddObjectToCache(cacheKey, cacheItem);
            }

            return((List <CMSForecastType>)cacheItem);
        }
Esempio n. 9
0
        public List <CMSFleetPlan> CMSFleetPlanGetAll(bool hideScenarios)
        {
            string cacheKey  = hideScenarios ? MarsV2Cache.CMSFrozenZoneFleetPlanList : MarsV2Cache.CMSFleetPlanList;
            object cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                cacheItem = _dal.CMSFleetPlanGetAll(hideScenarios);
                MarsV2Cache.AddObjectToCache(cacheKey, cacheItem);
            }

            return((List <CMSFleetPlan>)cacheItem);
        }
Esempio n. 10
0
        internal static List <string> GetAllLicencePlates()
        {
            var cacheKey  = MarsV2Cache.LicencePlate;
            var cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                using (var dataAccess = new MarsDBDataContext())
                {
                    cacheItem = NonRevParameterDataAccess.GetLicecePlates(dataAccess);
                }
                MarsV2Cache.AddObjectToCache(cacheKey, cacheItem);
            }

            return((List <string>)cacheItem);
        }
Esempio n. 11
0
        protected int UpdateUserRoles(string racfid)
        {
            int result = -1;

            System.Web.UI.WebControls.CheckBoxList dropDownListRoles = (System.Web.UI.WebControls.CheckBoxList) this.MultiSelectDropDownListRoles.FindControl("ListBoxMultiSelect");
            string roleId         = null;
            string countryValue   = null;
            int    delimiterIndex = -1;

            //Delete Current roles for user
            Roles.DeleteUserRoles(racfid);

            // Insert roles for user
            foreach (var item in dropDownListRoles.Items.Cast <ListItem>().Where(d => d.Selected))
            {
                if (Convert.ToString(item.Value) == "1")
                {
                    //Administrator is selected
                    Users.UpdateUserRoles(racfid, 1, null);
                }
                else
                {
                    //Get role id and country from listbox
                    roleId         = Convert.ToString(item.Value);
                    delimiterIndex = roleId.IndexOf("|");
                    countryValue   = roleId.Remove(0, delimiterIndex + 1);
                    roleId         = roleId.Remove(delimiterIndex, roleId.Length - delimiterIndex);
                    //Update user roles
                    Users.UpdateUserRoles(racfid, Convert.ToInt32(roleId), countryValue);
                }
            }
            result = 0;

            //clear old cached roles and accessible countries
            string cacheKey = racfid + "Roles";

            MarsV2Cache.RemoveObjectFromCache(cacheKey);
            cacheKey = racfid + "Country";
            MarsV2Cache.RemoveObjectFromCache(cacheKey);

            return(result);
        }
Esempio n. 12
0
        internal static List <ListItem> GetLocationCountryListItems(MarsDBDataContext dataContext)
        {
            const string cacheKey  = MarsV2Cache.LocationCountry;
            var          cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                var countries = (from v in dataContext.Vehicles
                                 group v by v.LOCATION.COUNTRy1
                                 into groupedData
                                 orderby groupedData.Key.country_description
                                 select new ListItem(groupedData.Key.country_description, groupedData.Key.country1)).ToList();



                MarsV2Cache.AddObjectToCache(cacheKey, countries);
                return(countries);
            }
            return((List <ListItem>)cacheItem);
        }
Esempio n. 13
0
        internal static List <ListItem> GetOwningCountryListItems(MarsDBDataContext dataContext)
        {
            const string cacheKey  = MarsV2Cache.OwningCountry;
            var          cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                var countries = from v in dataContext.Vehicles
                                where v.IsFleet
                                join c in dataContext.COUNTRies on v.OwningCountry equals c.country1

                                select new ListItem(c.country_description, v.OwningCountry);

                var owningCountries = countries.Distinct().ToList().OrderBy(d => d.Text).ToList();

                MarsV2Cache.AddObjectToCache(cacheKey, owningCountries);
                return(owningCountries);
            }
            return((List <ListItem>)cacheItem);
        }
Esempio n. 14
0
        internal static List <string> GetVehicleAutoComplete(AutoCompleteTypes typeOfAutoComplete, string cacheKey)
        {
            var cacheItem = MarsV2Cache.GetCacheObject(cacheKey);

            if ((ConfigAccess.ByPassCache()) || (cacheItem == null))
            {
                using (var dataAccess = new MarsDBDataContext())
                {
                    switch (typeOfAutoComplete)
                    {
                    case AutoCompleteTypes.Vin:
                        cacheItem = NonRevParameterDataAccess.GetVins(dataAccess);
                        break;

                    case AutoCompleteTypes.LicencePlate:
                        cacheItem = NonRevParameterDataAccess.GetLicecePlates(dataAccess);
                        break;

                    case AutoCompleteTypes.UnitNumber:
                        cacheItem = NonRevParameterDataAccess.GetUnitNumbers(dataAccess);
                        break;

                    case AutoCompleteTypes.DriverName:
                        cacheItem = NonRevParameterDataAccess.GetDriverNames(dataAccess);
                        break;

                    case AutoCompleteTypes.Colour:
                        cacheItem = NonRevParameterDataAccess.GetVehicleColours(dataAccess);
                        break;

                    case AutoCompleteTypes.ModelDescription:
                        cacheItem = NonRevParameterDataAccess.GetModelDescription(dataAccess);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException("typeOfAutoComplete");
                    }
                }
            }
            return((List <string>)cacheItem);
        }