public string ReadCache(string key) { Object obj = mcache.Get(key); if (obj == null) { return(null); } return(obj.ToString()); }
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); } } }
/// <summary> /// Gets the latest blogs. /// </summary> /// <returns>List<BlogPost>.</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); }
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) }); }
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); }
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); } }
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); }
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); }
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); }
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(); } }
/// <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)); }
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); } } }