public static void QuarterLookupTemplate(ref AggregateCaseHeader obj) { if (_QuarterLookupTemplate == null) { _QuarterLookupTemplate = new BaseReferenceList("rftSampleStatus"); using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { _QuarterLookupTemplate.Add(BaseReference.Accessor.Instance(null).CreateDummy(manager, null, 1L, "1")); _QuarterLookupTemplate.Add(BaseReference.Accessor.Instance(null).CreateDummy(manager, null, 2L, "2")); _QuarterLookupTemplate.Add(BaseReference.Accessor.Instance(null).CreateDummy(manager, null, 3L, "3")); _QuarterLookupTemplate.Add(BaseReference.Accessor.Instance(null).CreateDummy(manager, null, 4L, "4")); } } long thisYear = (long)System.DateTime.Now.Year; obj.QuarterAggrLookup.RemoveAll(m => (long)m.Key > 0L); if (obj.YearForAggr == thisYear) { obj.QuarterAggrLookup.AddRange(_QuarterLookupTemplate.Where(m => (m.idfsBaseReference - 1) * 3 < (long)DateTime.Now.Month)); } else { obj.QuarterAggrLookup.AddRange(_QuarterLookupTemplate); } long?val = obj.QuarterForAggr; obj.QuarterAggr = obj.QuarterAggrLookup .Where(c => c.idfsBaseReference == val) .SingleOrDefault(); }
public static BaseReferenceList ToBaseReferenceList(this IEnumerable <BaseReference> source, string section) { var ret = new BaseReferenceList(section); ret.AddRange(source); return(ret); }
public static void WeekLookupTemplate(ref AggregateCaseHeader obj) { if (_WeekLookupTemplate == null) { _WeekLookupTemplate = new BaseReferenceList("rftSampleStatus"); } _WeekLookupTemplate.Clear(); if (obj.YearForAggr != null) { using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { foreach (WeekPeriod wp in DatePeriodHelper.GetWeeksList((int)obj.YearForAggr)) { _WeekLookupTemplate.Add(BaseReference.Accessor.Instance(null).CreateDummy(manager, null, (long)wp.WeekNumber, String.Format("{0:d}-{1:d}", wp.WeekStartDate, wp.WeekStartDate.AddDays(6)))); } } } long thisYear = (long)DateTime.Now.Year; obj.WeekAggrLookup.RemoveAll(m => (long)m.Key > 0L); if (obj.YearForAggr == thisYear) { obj.WeekAggrLookup.AddRange(_WeekLookupTemplate.Where(m => m.idfsBaseReference <= (long)DatePeriodHelper.GetWeekOfYear(DateTime.Now))); } else { obj.WeekAggrLookup.AddRange(_WeekLookupTemplate); } long?val = obj.WeekForAggr; obj.WeekAggr = obj.WeekAggrLookup .Where(c => c.idfsBaseReference == val) .SingleOrDefault(); }