Example #1
0
		private OeeType GetCurrentInfo()
		{
			var oeeType = new OeeType();
			if (IsMonthly) oeeType.Interval = OeeType.OeeInterval.Monthly;
			else if (IsWeekly) oeeType.Interval = OeeType.OeeInterval.Weekly;
			else if (IsDaily) oeeType.Interval = OeeType.OeeInterval.Daily;
			oeeType.DayStart = DayStart;
			oeeType.MonthStart = MonthStart;
			return oeeType;
		}
Example #2
0
		/// <summary>
		/// View calls this method to load its index infromation from database
		/// </summary>
		public void Load(OeeType ot)
		{
			Timeline.Clear();
			var dt = DateTime.Now.GetNorooz();
			switch (ot.Interval)
			{
				case OeeType.OeeInterval.Monthly:
					dt = dt.AddDays(ot.MonthStart - 1);
					int months = (int)DateTime.Now.GetPersianMonth();
					for (int i = 0; i < months; i++)
					{
						var vm = new OeeMachineDetailVm();
						vm.Selected += () =>
						{
							if (SelectedDetail != null)
								SelectedDetail.IsSelected = false;
							SelectedDetail = vm;
						};
						Timeline.Add(vm);

						//load data
						var start = dt;
						if (i == months - 1)
						{
							dt = DateTime.Now;
						}
						else
						{
							dt = dt.AddDays(dt.GetPersianMonthDays());
						}
						var end = dt;

						var data = new OeeRecord(Model.Id, start, end);
						data.TimeRange = start.GetPersianMonth().ToString();
						_data.Add(data);
						vm.Load(data);
					}
					break;
				case OeeType.OeeInterval.Weekly:
					dt = dt.AddDays(-(int)dt.GetPersianDayOfWeek());
					int weeks = DateTime.Now.GetPersianWeekOfYear() + 2;
					for (int i = 0; i < weeks; i++)
					{
						var vm = new OeeMachineDetailVm();
						vm.Selected += () =>
						{
							if (SelectedDetail != null)
								SelectedDetail.IsSelected = false;
							SelectedDetail = vm;
						};
						Timeline.Add(vm);

						//load data
						var start = dt;
						if (i == weeks - 1)
						{
							dt = DateTime.Now;
						}
						else
						{
							dt = dt.AddDays(7);
						}
						var end = dt;

						var data = new OeeRecord(Model.Id, start, end);
						data.TimeRange = string.Format("از {0} الی {1}", start.ToPersianDateString(), end.ToPersianDateString());
						_data.Add(data);
						vm.Load(data);
					}
					break;
				case OeeType.OeeInterval.Daily:
					dt = dt.Add(ot.DayStart);
					int days = DateTime.Now.GetPersianDayOfYear();
					for (int i = 0; i < days; i++)
					{
						var vm = new OeeMachineDetailVm();
						vm.Selected += () =>
						{
							if (SelectedDetail != null)
								SelectedDetail.IsSelected = false;
							SelectedDetail = vm;
						};
						Timeline.Add(vm);

						//load data
						var start = dt;
						if (i == days - 1)
						{
							dt = DateTime.Now;
						}
						else
						{
							dt = dt.AddDays(1);
						}
						var end = dt;

						var data = new OeeRecord(Model.Id, start, end);
						data.TimeRange = start.ToPersianCompactDateString();
						_data.Add(data);
						vm.Load(data);
					}
					break;
				default:
					break;
			}


			if (Timeline.Any()) Timeline.LastOrDefault().SelectCommand.Execute();
		}