Exemplo n.º 1
0
		public Product(ProductGroup parentVm, Model.Product model, bool isRowHeader)
		{
			Id = model.Id;
			Name = model.Name;
			Code = model.Code;
			CellType = isRowHeader ? CellType.ProductRowHeaderCell : CellType.ProductColumnHeaderCell;
			Color = new SolidColorBrush(model.Color);
			ProductGroup = parentVm;
			//if mainProduct is not included, add it as an 'invalid=true'
			if (!model.ProductReworks.Any(x => x.Rework == null))
			{
				Reworks.Add(Rework.InvalidMainProduct(this, isRowHeader));
			}

			foreach (var productReworkModel in model.ProductReworks)
			{
				Reworks.Add(new Rework(this, productReworkModel, isRowHeader));
			}
		}
Exemplo n.º 2
0
		public void Reload()
		{
			var pgModelList = new DataServices.ProductGroupDataService(null).GetActivesRecursive(Id);

			#region Reload Sync
			int col = 0;
			int row = 0;
			foreach (var pgModel in pgModelList)
			{
				if (!pgModel.Products.Any()) continue;

				//Add ProductGroup To ColumnHeaders
				var cpg = new ProductGroup(pgModel, this, isRowHeader: false);
				cpg.RowIndex = 0;
				cpg.ColumnIndex = col++;//pg itself is a column
				ColumnHeaders.Add(cpg);
				ColumnPGList.Add(cpg);
				foreach (var p in cpg.Products)
				{
					foreach (var r in p.Reworks)
					{
						//Add Rework To ColumnHeaders
						r.RowIndex = 0;
						r.ColumnIndex = col;
						ColumnHeaders.Add(r);
						//...
						col++;
					}
				}

				//Add ProductGroup To RowHeaders
				var rpg = new ProductGroup(pgModel, this, isRowHeader: true);
				rpg.RowIndex = row++;//pg itself is a row
				rpg.ColumnIndex = 0;
				RowHeaders.Add(rpg);
				RowPGList.Add(rpg);
				foreach (var p in rpg.Products)
				{
					foreach (var r in p.Reworks)
					{
						//Add Rework to RowHeaders
						r.RowIndex = row;
						r.ColumnIndex = 0;
						RowHeaders.Add(r);
						//Add Checkbox
						r.Checkbox.RowIndex = row;
						r.Checkbox.ColumnIndex = 1;
						RowHeaders.Add(r.Checkbox);
						//Add Warmup
						r.Warmup.RowIndex = row;
						r.Warmup.ColumnIndex = 2;
						RowHeaders.Add(r.Warmup);

						//...
						row++;
					}
				}
			}

			//				*********
			//use of Context in a non DataService class
			//This is to speed up the reading of changeovers
			//				*********
			using (var context = new Dal.SoheilEdmContext())
			{
				//Add ChangeoverCells
				foreach (var rpg in RowPGList)
				{
					foreach (var cpg in ColumnPGList)
					{
						ChangeoverCells.Add(Cell.Blank(rpg, cpg));
						foreach (var cp in cpg.Products)
							foreach (var cr in cp.Reworks)
								ChangeoverCells.Add(Cell.Blank(rpg, cr, columnColor: cp.Color));
					}
					foreach (var rp in rpg.Products)
						foreach (var rr in rp.Reworks)
							foreach (var cpg in ColumnPGList)
							{
								ChangeoverCells.Add(Cell.Blank(rr, cpg, rowColor: rr.Product.Color));
								foreach (var cp in cpg.Products)
									foreach (var cr in cp.Reworks)
										if (cr.IsValid)
											ChangeoverCells.Add(new ChangeoverCell(rr, cr, this.Id, context));
										else
											ChangeoverCells.Add(Cell.Blank(rr, cr, rowColor: rr.Product.Color, columnColor: cr.Product.Color));
							}
				}
			}
			//				*********
			TotalVisualColumns = col;
			TotalVisualRows = row;
			#endregion
		}