/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List <MonthInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { if (pPageIndex <= 1) { pPageIndex = 1; } List <MonthInfo> list = new List <MonthInfo>(); Query q = Month.CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression, pOrderBy.ToString()); MonthCollection collection = new MonthCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (Month month in collection) { MonthInfo monthInfo = new MonthInfo(); LoadFromDAL(monthInfo, month); list.Add(monthInfo); } pRecordCount = q.GetRecordCount(); return(list); }
/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List <MonthInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(MonthInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return(CachedEntityCommander.GetCache(cacheKey) as List <MonthInfo>); } else { List <MonthInfo> list = new List <MonthInfo>(); MonthCollection collection = new MonthCollection(); Query qry = new Query(Month.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach (Month month in collection) { MonthInfo monthInfo = new MonthInfo(); LoadFromDAL(monthInfo, month); list.Add(monthInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(MonthInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return(list); } }
public void Main() { var collection = new MonthCollection(); // Consumes values generated from collection's GetEnumerator method foreach (string n in collection) Console.Write(n + " "); Console.WriteLine("\n"); }
/// <summary> /// 批量装载 /// </summary> internal static void LoadFromDALPatch(List <MonthInfo> pList, MonthCollection pCollection) { foreach (Month month in pCollection) { MonthInfo monthInfo = new MonthInfo(); LoadFromDAL(monthInfo, month); pList.Add(monthInfo); } }
static void Main() { MonthCollection collection = new MonthCollection(); // Consumes values generated from collection's GetEnumerator method foreach (string n in collection) { Console.Write(n + " "); } }
static void Demo() { MonthCollection collection = new MonthCollection(); // Consumes values generated from collection's GetEnumerator method foreach (string n in collection) { Console.Write(n + " "); } Console.WriteLine("\n"); }
public IteratorViewModel() { MonthCollection collection = new MonthCollection(); foreach (string items in collection) { this.MonthsCollection.Add(new MonthName { Name = items }); } }
/// <summary> /// 批量装载 /// </summary> internal static void LoadFromDALPatch(List< MonthInfo> pList, MonthCollection pCollection) { foreach (Month month in pCollection) { MonthInfo monthInfo = new MonthInfo(); LoadFromDAL(monthInfo, month ); pList.Add(monthInfo); } }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List<MonthInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount) { if(pPageIndex<=1) pPageIndex=1; List< MonthInfo> list = new List< MonthInfo>(); Query q = Month .CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression,pOrderBy.ToString()); MonthCollection collection=new MonthCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (Month month in collection) { MonthInfo monthInfo = new MonthInfo(); LoadFromDAL(monthInfo, month); list.Add(monthInfo); } pRecordCount=q.GetRecordCount(); return list; }
/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List<MonthInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(MonthInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return CachedEntityCommander.GetCache(cacheKey) as List< MonthInfo>; } else { List< MonthInfo> list =new List< MonthInfo>(); MonthCollection collection=new MonthCollection(); Query qry = new Query(Month.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach(Month month in collection) { MonthInfo monthInfo= new MonthInfo(); LoadFromDAL(monthInfo,month); list.Add(monthInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(MonthInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return list; } }
static void Main(string[] args) { Console.WriteLine(new string('*', 20)); Console.WriteLine("Press 'h' for help"); MonthsList list = new MonthsList(); MonthCollection collection = new MonthCollection(); collection.Init(); #region Switch Menu bool tryAgain = true; while (tryAgain) { try { Console.Write(">> "); char caseSwitch = Console.ReadKey().KeyChar; Console.WriteLine(); switch (caseSwitch) { case 'h': Help(); break; case '1': try { Console.Write(">>id: "); int id = Convert.ToInt32(Console.ReadLine()); ShowById(id); } catch (FormatException) { Console.WriteLine("!-Wrong Format"); } break; case '2': try { Console.Write(">>days: "); int days = Convert.ToInt32(Console.ReadLine()); ShowByDays(days); } catch (FormatException) { Console.WriteLine("!-Wrong Format"); } break; case '3': ShowAll(); break; case 'q': tryAgain = false; break; default: Console.WriteLine($"Invalid selection ({caseSwitch})"); break; } } catch (FormatException) { Console.WriteLine("!-Wrong Format"); } } #endregion #region Print Methods void ShowById(int id) { Console.WriteLine("In development"); } void ShowByDays(int days) { Console.WriteLine("In development"); } void ShowAll() { Console.WriteLine("In development"); } void Help() { Console.WriteLine("1 - show by id\n" + "2 - show by days\n" + "3 - show all\n" + "q - exit"); } #endregion Console.WriteLine(new string('*', 20)); Console.Write("End of program..."); System.Threading.Thread.Sleep(1000); Console.ReadKey(); }
/// <summary> /// Resets the timeline to Now, loads PPItems in range and loads Stations /// <para>This method is using _initialTimer so its body will be run with a 10ms delay</para> /// </summary> public void ResetTimeLine() { //exit if loaded once if (_initialTimer != null) return; _initialTimer = new System.Threading.Timer(new System.Threading.TimerCallback (t => Dispatcher.Invoke(() => { _suppressUpdateRange = true; //initialize DateTimes var currentDate = Arash.PersianDate.Today.ToDateTime(); var startDate = currentDate.GetNorooz(); //initialize Timeline components Days = new DayCollection(); Months = new MonthCollection(startDate); Months.SelectedMonthChanged += month => SelectedMonth = month; Hours = new HourCollection(); //initialize PPItems PPItems = new PPItemCollection(this); PPItems.Manager.DayColorsUpdated += (startingDate, colors) => { //refetch it, if selected month is changed after fetch if (SelectedMonth.Data != startingDate) { PPItems.Manager.InitMonth(SelectedMonth.Data); return; } //colorize days for (int i = 0; i < colors.Length; i++) { Days[i].Color = colors[i]; } }; PPItems.Manager.WorkTimeAdded += item => { var vms = Soheil.Core.ViewModels.OrganizationCalendar.WorkTimeRangeVm.CreateAuto(item); foreach (var vm in vms) { ShiftsAndBreaks.Add(vm); } }; PPItems.Manager.WorkTimesRemoved += () => { ShiftsAndBreaks.Clear(); }; PPItems.BlockAdded += vm => { initializeCommands(vm); }; PPItems.BlockRemoved += id => { if (SelectedBlock != null && SelectedBlock.Id == id) SelectedBlock = null; }; PPItems.NptAdded += vm => { initializeCommands(vm); }; PPItems.NptRemoved += id => { if (SelectedNPT != null && SelectedNPT.Id == id) SelectedNPT = null; }; //Initialize stations var stationModels = new DataServices.StationDataService().FixAndGetActives(); NumberOfStations = stationModels.Count(); foreach (var stationModel in stationModels) { PPItems.Add(new StationVm { Text = stationModel.Name }); } //Set advanced timeline components SelectedMonth = Months[(int)currentDate.GetPersianMonth() - 1]; HoursPassed = currentDate.Subtract(SelectedMonth.Data).TotalHours; if (currentDate.Year % 4 == 3) { HoursInYear = 8784; DaysInYear = 366; } else { HoursInYear = 8760; DaysInYear = 365; } //Loads PPItems _suppressUpdateRange = false; GoToNowCommand.Execute(null); })), null, _initialTimerInterval, System.Threading.Timeout.Infinite); }