コード例 #1
0
		public DefectionReportCollection(ProcessReportVm parent)
		{
			Parent = parent;
			AddCommand = new Commands.Command(o =>
			{
				var model = new Model.DefectionReport
				{
					ProcessReport = parent.Model,
					LostCount = 0,
					LostTime = 0,
					ProductDefection = null,
					ModifiedBy = LoginInfo.Id,
				};
				foreach (var po in Parent.Model.Process.ProcessOperators)
				{
					model.OperatorDefectionReports.Add(new Model.OperatorDefectionReport
					{
						Operator = po.Operator,
						DefectionReport = model,
						Code = po.Operator.Code,
						ModifiedBy = LoginInfo.Id,
					});
				}
				parent.Model.DefectionReports.Add(model);
				var vm = new DefectionReportVm(this, model);
				List.Add(vm);
			});
		}
コード例 #2
0
ファイル: PPTableVm.cs プロジェクト: T1Easyware/Soheil
		/// <summary>
		/// Initializes BlockVm commands of vm that can be assigned in this class
		/// </summary>
		/// <param name="vm"></param>
		void initializeCommands(BlockVm vm)
		{
			//Task editor
			vm.AddBlockToEditorCommand = new Commands.Command(o =>
			{
				try
				{
					var ppeBlock = new Editor.BlockEditorVm(vm.Model);
					TaskEditor.BlockList.Add(ppeBlock);
					TaskEditor.SelectedBlock = ppeBlock;
				}
				catch (Exception exp) { vm.Message.AddEmbeddedException(exp.Message); }
			}, () => vm.Model != null);
			vm.EditItemCommand = new Commands.Command(o =>
			{
				try
				{
					TaskEditor.Reset();
					TaskEditor.IsVisible = true;
					JobEditor.IsVisible = false;
					vm.AddBlockToEditorCommand.Execute(o);
				}
				catch (Exception exp) { vm.Message.AddEmbeddedException(exp.Message); }
			});
			//Job editor
			vm.AddJobToEditorCommand = new Commands.Command(o =>
			{
				try { JobEditor.Append(vm.Job); }
				catch (Exception exp) { vm.Message.AddEmbeddedException(exp.Message); }
			}, () =>
			{
				if (vm.Job == null) return false;
				if (vm.Job.Id == 0) return false;
				return true;
			});
			vm.EditJobCommand = new Commands.Command(o =>
			{
				try
				{
					TaskEditor.IsVisible = false;
					JobEditor.IsVisible = true;
					JobEditor.Reset();
					vm.AddJobToEditorCommand.Execute(o);
				}
				catch (Exception exp) { vm.Message.AddEmbeddedException(exp.Message); }
			}, () =>
			{
				if (vm.Job == null) return false;
				if (vm.Job.Id == 0) return false;
				return true;
			});


			vm.DeleteJobCommand = new Commands.Command(o =>
			{
				lock (PPItems.Manager)
				{
					try
					{
						new DataServices.JobDataService().DeleteModel(vm.Job.Model);
						RemoveBlocks(vm.Job);
					}
					catch (RoutedException exp)
					{
						if (exp.Target is TaskVm)
							(exp.Target as TaskVm).Message.AddEmbeddedException(exp.Message);
						else //if(exp.Target is BlockVm)
							vm.Message.AddEmbeddedException(exp.Message);
					}
					catch (Exception exp) { vm.Message.AddEmbeddedException(exp.Message); }
				}
			}, () => { return vm.Job != null; });

			//report
			vm.EditReportCommand = new Commands.Command(o =>
			{
				try
				{
					vm.BlockReport = new Report.BlockReportVm(vm);
					vm.BlockReport.ProcessReportBuilderChanged += val => CurrentProcessReportBuilder = val;
					SelectedBlock = vm;
				}
				catch (Exception exp) { vm.Message.AddEmbeddedException(exp.Message); }
			});
			//EditReportCommand reloads *ALL* reports for its block 
			//vm.TaskList.CollectionChanged += (s, e) =>
			//{
			//	if (e.NewItems != null)
			//		foreach (var task in e.NewItems.OfType<TaskVm>())
			//		{
			//			if (task != null)
			//				task.EditReportCommand = new Commands.Command(o =>
			//				{
			//					SelectedBlock = vm;
			//					vm.ReloadReports();
			//				});
			//		}
			//};
		}
コード例 #3
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();
					}
				}
			}
		}
コード例 #4
0
		public OperatorReportCollection(ProcessReportVm parent)
		{
			Parent = parent;
		}