Exemplo n.º 1
0
        public string ReadCache(string key)
        {
            Object obj = mcache.Get(key);

            if (obj == null)
            {
                return(null);
            }
            return(obj.ToString());
        }
Exemplo n.º 2
0
        public void LoadGlobalCalendar(DateTime start, DateTime end)
        {
            var globalCalendar = ApplicationCache.Get <Dictionary <DateTime, Dictionary <string, bool> > >(Global.GlobalCalendar);

            foreach (var calendarEvent in _calendarEventRepository.GetByRange <CalendarEvent>(start, end))
            {
                var dateKey = calendarEvent.Start.Date;
                while (dateKey < calendarEvent.End.Date)
                {
                    if (!globalCalendar.ContainsKey(dateKey))
                    {
                        globalCalendar[dateKey] = new Dictionary <string, bool>();
                    }

                    calendarEvent.SaftyInvoke <Holiday>(h =>
                    {
                        globalCalendar[dateKey][h.Country] = true;
                    });

                    calendarEvent.SaftyInvoke <DaylightSavingTime>(d =>
                    {
                        globalCalendar[dateKey][d.TimeZone.Id] = true;
                    });

                    dateKey = dateKey.AddDays(1);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the latest blogs.
        /// </summary>
        /// <returns>List&lt;BlogPost&gt;.</returns>
        public async Task <List <BlogPost> > GetLatestBlogs()
        {
            IEnumerable <BlogPost> cacheResult;
            TableContinuationToken token;

            //// Check in cache first. Retry operation on first failure. Product Issue :(
            try
            {
                cacheResult = ApplicationCache.Get <IEnumerable <BlogPost> >(ApplicationConstants.BlogsCacheKey);
                token       = ApplicationCache.Get <TableContinuationToken>(ApplicationConstants.BlogsFirstTokenCacheKey);
            }
            catch (Exception)
            {
                cacheResult = ApplicationCache.Get <IEnumerable <BlogPost> >(ApplicationConstants.BlogsCacheKey);
                token       = ApplicationCache.Get <TableContinuationToken>(ApplicationConstants.BlogsFirstTokenCacheKey);
            }

            if (null != cacheResult)
            {
                //// We need to add token to user page dictionary as well.
                if (null != token)
                {
                    UserPageDictionary.PageDictionary.AddPage(token);
                }

                return(cacheResult.ToList());
            }

            var result = await this.GetPagedBlogPreviews(null, true);

            var firstPageBlogs = result.Select(TableBlogEntity.GetBlogPost).ToList();

            ApplicationCache.Set(ApplicationConstants.BlogsCacheKey, firstPageBlogs);
            return(firstPageBlogs);
        }
Exemplo n.º 4
0
        public void Execute(IRoutedMessage message, IInteractionNode handlingNode, MessageProcessingOutcome outcome)
        {
            var content = LanguageKey.IsNullOrEmpty() ? Message : LanguageReader.GetValue(LanguageKey);

            ServiceLocator.Current.GetInstance <IAuditLogModel>().Write(new AuditLog {
                Action = content, CurrentUser = ApplicationCache.Get <string>(Global.LoggerId)
            });
        }
Exemplo n.º 5
0
 public virtual LaborRule SetDefaultProperty()
 {
     //TODO:Verify who set DefaultMaxLaborHour value to cache
     this.MaxLaborHour = new TimeSpan(ApplicationCache.Get <int>(Global.DefaultMaxLaborHour), 0, 0);
     this.MinLaborHour = new TimeSpan(ApplicationCache.Get <int>(Global.DefaultMinLaborHour), 0, 0);
     //xGroupingArrangeShift = new GroupingArrangeShift();
     DayOffRule = new DayOffRule();
     DayOffMask = new MaskOfDay();
     return(this);
 }
Exemplo n.º 6
0
        private static bool Is(this DateTime dateTime, string key)
        {
            var globalCalendar = ApplicationCache.Get <Dictionary <DateTime, Dictionary <string, bool> > >(Global.GlobalCalendar);

            if (globalCalendar == null || !globalCalendar.ContainsKey(dateTime) || string.IsNullOrEmpty(key))
            {
                return(false);
            }

            return(globalCalendar[dateTime].ContainsKey(key) && globalCalendar[dateTime][key]);
        }
        public void AddAdherenceEvents(IEnumerable <AdherenceEvent> itmes)
        {
            var currentAgentId = ApplicationCache.Get <string>(Global.LoggerId);

            foreach (var o in itmes)
            {
                o.Assigner = currentAgentId;
                o.Remark   = string.Empty;
                _adherenceEventRepository.MakePersistent(o);
            }
        }
Exemplo n.º 8
0
        public bool Execute(IRoutedMessage message, IInteractionNode handlingNode, object[] parameters)
        {
            message.AvailabilityEffect = Effect;

            var functionKeys = ApplicationCache.Get <ICollection <string> >(Global.LoginUserFunctionKeys);

            if (functionKeys == null || functionKeys.Count == 0)
            {
                //Admin
                return(true);
            }
            return(functionKeys.Contains(FunctionKey));
        }
        public void GetReturnsDefaultIfNotFoundValueType()
        {
            Cache cache = HttpRuntime.Cache;

            ApplicationCache appCache = new ApplicationCache(cache);

            string key = "key";

            cache.Remove(key);

            int actual = appCache.Get <int>(key);

            Assert.Equal(default(int), actual);
        }
Exemplo n.º 10
0
        public void GetReturnsNullIfNotFound()
        {
            Cache cache = HttpRuntime.Cache;

            ApplicationCache appCache = new ApplicationCache(cache);

            string key = "key";

            cache.Remove(key);

            string actual = appCache.Get <string>(key);

            Assert.Null(actual);
        }
Exemplo n.º 11
0
        public void GetReturnsItem()
        {
            Cache cache = HttpRuntime.Cache;

            ApplicationCache appCache = new ApplicationCache(cache);

            string key  = "key";
            string item = "item";

            cache.Insert(key, item);

            string actual = appCache.Get <string>(key);

            Assert.Equal(item, actual);
        }
Exemplo n.º 12
0
        private void SaveLog(IStatelessSession session, TermLog entity)
        {
            if (session == null)
            {
                return;
            }

            using (var tx = session.BeginTransaction())
            {
                var currentEmployee = ApplicationCache.Get <Entity>(Global.LoginEmployee);
                if (currentEmployee != null)
                {
                    entity.AlterEmployeeId = currentEmployee.Id;
                }
                session.Insert(entity);

                tx.Commit();
            }
        }
Exemplo n.º 13
0
        /// <summary>
        ///     Testimonials this instance.
        /// </summary>
        /// <returns>ViewResult.</returns>
        public ViewResult Testimonials()
        {
            this.profileService = new ProfileService(this.documentDbAccess);
            var result = new List <Testimonial>();
            List <Testimonial> cacheResult;

            //// Check in cache first. Retry operation on first failure. Product Issue :(
            try
            {
                cacheResult = ApplicationCache.Get <List <Testimonial> >(ApplicationConstants.TestimonialCacheKey);
            }
            catch (Exception)
            {
                cacheResult = ApplicationCache.Get <List <Testimonial> >(ApplicationConstants.TestimonialCacheKey);
            }

            if (null != cacheResult)
            {
                return(this.View("Testimonials", cacheResult));
            }

            var testimonialCount = Convert.ToInt32(WebConfigurationManager.AppSettings[ApplicationConstants.TopTestimonialCount]);
            ////Get top N Testimonials.
            var documentsFeatured = this.profileService.QueryDocument <Testimonial>(testimonialCount);
            var featured          = documentsFeatured.Where(document => document.IsFeatured && document.IsApproved).OrderByDescending(document => document.TestimonialId).ToList();

            result.AddRange(featured);
            if (testimonialCount - featured.Count() <= 0)
            {
                return(this.View("Testimonials", result));
            }

            var documentsApproved = this.profileService.QueryDocument <Testimonial>(testimonialCount - featured.Count());
            var approved          = documentsApproved.Where(document => document.IsApproved && !document.IsFeatured).OrderByDescending(document => document.TestimonialId).ToList();

            result.AddRange(approved);
            ApplicationCache.Set(ApplicationConstants.TestimonialCacheKey, result);
            return(this.View("Testimonials", result));
        }
Exemplo n.º 14
0
        public string BatchDeleteTerm(TimeBox timeBox, string @operator, long[] ids)
        {
            if (ids.Length == 0)
            {
                return(string.Empty);
            }

            using (var s = Factory.OpenStatelessSession())
            {
                using (var tx = s.BeginTransaction())
                {
                    var resultCount = s.CreateQuery(@"select count(o) from TimeBox o where o.Id = :timeBoxId")
                                      //and (o.Operator = :operator or o.Operator is null)")
                                      .SetGuid("timeBoxId", timeBox.Id)
                                      //.SetString("operator", @operator)
                                      .UniqueResult <Int64>();

                    if (resultCount > 0)
                    {
                        var alterBy = string.Format("{0}@{1:yyyy/MM/dd HH:mm:ss.fff}",
                                                    ApplicationCache.Get <string>(Global.LoggerId),
                                                    DateTime.Now);
                        s.CreateQuery(@"delete from Term o where o.Id IN (:ids)")
                        .SetParameterList("ids", ids)
                        .ExecuteUpdate();
                        //s.CreateQuery("update TimeBox o set o.Operator = :alterBy where o.Id = :timeBoxId")
                        //    .SetGuid("timeBoxId", timeBox.Id)
                        //    .SetString("alterBy", alterBy)
                        //    .ExecuteUpdate();
                        tx.Commit();
                        return(alterBy);
                    }
                    return(string.Empty);
                }
            }
        }