コード例 #1
0
ファイル: BlockReportVm.cs プロジェクト: T1Easyware/Soheil
		/// <summary>
		/// Reloads all activities, ssas and processReports for this block
		/// </summary>
		public void ReloadReports()
		{
			_parent.ReloadTasks();
			if (_parent.TaskList.Count > 0)
				_parent.TaskList[0].ReloadTaskReports();

			ActivityList.Clear();
			
			foreach (var ssaGroup in entity.StateStation.StateStationActivities.GroupBy(x => x.Activity))
			{
				var activityVm = new ActivityRowVm(ssaGroup.Key);
				ActivityList.Add(activityVm);
			}

			var ssaModels = new List<Model.StateStationActivity>();
			foreach (var task in entity.Tasks.OrderBy(x => x.StartDateTime))
			{
				//load ProcessReports
				foreach (var processGroup in task.Processes.GroupBy(x=>x.StateStationActivity.Activity))
				{
					//find activity
					var activityVm = ActivityList.FirstOrDefault(x => x.Id == processGroup.Key.Id);
					if (activityVm == null) continue;
					//load processes
					foreach (var process in processGroup)
					{
						//find ssa (row)
						var rowVm = activityVm.SsaRowList.FirstOrDefault(x => x.Id == process.StateStationActivity.Id);
						if (rowVm == null) continue;
						//create processVm
						var processVm = new ProcessVm(process, UOW);
						processVm.LayoutChanged += ReloadReports;
						rowVm.ProcessList.Add(processVm);
						//load process reports
						foreach (var processReport in process.ProcessReports.OrderBy(x => x.StartDateTime))
						{
							var processReportVm = new ProcessReportVm(processReport, UOW);
							//process report events
							processReportVm.LayoutChanged += ReloadReports;
							processReportVm.ProcessReportSelected += vm =>
							{
								if (ProcessReportBuilderChanged != null)
									ProcessReportBuilderChanged(vm);
							};

							//correct next/previous links
							var lastpr = processVm.ProcessReportList.LastOrDefault();
							if (lastpr != null)
							{
								processReportVm.Timing.PreviousReport = lastpr.Timing;
								processReportVm.Timing.PreviousReport.NextReport = processReportVm.Timing;
							}

							//add the report to its processVm
							processVm.ProcessReportList.Add(processReportVm);
						}
					}
				}

				//put processes in order
				foreach (var activityVm in ActivityList)
				{
					foreach (var rowVm in activityVm.SsaRowList)
					{
						rowVm.RearrangeRows();
					}
				}
			}
		}
コード例 #2
0
ファイル: ProcessRowVm.cs プロジェクト: T1Easyware/Soheil
		public void RemoveProcessReport(ProcessVm vm)
		{
			ProcessList.RemoveWhere(x => x.Id == vm.Id);
		}