Ejemplo n.º 1
0
        public async Task Store(Contracts.Entities.Item item)
        {
            // search und update machine

            int id        = item.ItemID;
            var optValues = item.ItemProperties?.ToList() ?? new List <Contracts.Entities.ItemProperty>();

            var itemInDb = await Context.Items.
                           Where(m => m.ItemID == id).
                           Include(d => d.ItemProperties).
                           FirstOrDefaultAsync();

            if (itemInDb == default(Contracts.Entities.Item))
            {
                // add new
                Uow.MarkNew(item);
                foreach (var iv in optValues)
                {
                    Uow.MarkNew(iv);
                }
            }
            else
            {
                // syn with existing

                Uow.SetValue(itemInDb, item);

                // search und update machinecommands (add and delete)

                Sync <Contracts.Entities.ItemProperty>(
                    itemInDb.ItemProperties,
                    optValues,
                    (x, y) => x.ItemID > 0 && x.ItemID == y.ItemID && x.Name == y.Name);
            }
        }
Ejemplo n.º 2
0
        public async Task Delete(Contracts.Entities.Item e)
        {
            e.ItemProperties = null;
            Uow.MarkDeleted(e);
            await Task.FromResult(0);

            // Uow.ExecuteSqlCommand("delete from ItemProperty where ItemID = " + e.ItemID); => delete cascade
        }
Ejemplo n.º 3
0
        private static void ItemSeed(CNCLibContext context)
        {
            var cutItem = new Item
            {
                ClassName = @"CNCLib.Logic.Contracts.DTO.LoadOptions,CNCLib.Logic.Contracts.DTO",
                Name = @"cut laser 160mg"
            };
            var cutHoleItem = new Item
            {
                ClassName = @"CNCLib.Logic.Contracts.DTO.LoadOptions,CNCLib.Logic.Contracts.DTO",
                Name = @"cut laser hole 130mg black"
            };

            var graveItem = new Item
            {
                ClassName = @"CNCLib.Logic.Contracts.DTO.LoadOptions,CNCLib.Logic.Contracts.DTO",
                Name = @"grave"
            };
            var graveIMGItem = new Item
            {
                ClassName = @"CNCLib.Logic.Contracts.DTO.LoadOptions,CNCLib.Logic.Contracts.DTO",
                Name = @"grave image"
            };
            var graveIMGG00G01Item = new Item
            {
                ClassName = @"CNCLib.Logic.Contracts.DTO.LoadOptions,CNCLib.Logic.Contracts.DTO",
                Name = @"grave image (G0G1)"
            };

            var items = new[] { cutItem, cutHoleItem, graveItem, graveIMGItem, graveIMGG00G01Item };

            context.Items.AddRange(items);

            var itemproperties = new[]
            {
                //cut
                new ItemProperty() { Item = cutItem, Name = @"SettingName",         Value=cutItem.Name    },
                new ItemProperty() { Item = cutItem, Name = @"LaserFirstOnCommand", Value=@"M106 S255\ng4 P0.3"    },
                new ItemProperty() { Item = cutItem, Name = @"LaserOnCommand",      Value=@"M106\ng4 P0.3"    },
                new ItemProperty() { Item = cutItem, Name = @"PenMoveType",         Value=@"CommandString"    },
                new ItemProperty() { Item = cutItem, Name = @"AutoScale",           Value=@"true"    },
                new ItemProperty() { Item = cutItem, Name = @"AutoScaleSizeX",      Value=@"150"    },
                new ItemProperty() { Item = cutItem, Name = @"AutoScaleSizeY",      Value=@"150"    },
                new ItemProperty() { Item = cutItem, Name = @"MoveSpeed",           Value=@"450"    },
				new ItemProperty() { Item = cutItem, Name = @"LoadType",            Value=@"HPGL"    },

                //cut-image
                new ItemProperty() { Item = cutHoleItem, Name = @"SettingName",         Value=cutHoleItem.Name    },
                new ItemProperty() { Item = cutHoleItem, Name = @"LaserFirstOnCommand", Value=@"M106 S255\ng4 P0.25"    },
                new ItemProperty() { Item = cutHoleItem, Name = @"LaserOnCommand",      Value=@"M106\ng4 P0.25"    },
                new ItemProperty() { Item = cutHoleItem, Name = @"PenMoveType",         Value=@"CommandString"    },
                new ItemProperty() { Item = cutHoleItem, Name = @"AutoScale",           Value=@"true"    },
                new ItemProperty() { Item = cutHoleItem, Name = @"AutoScaleSizeX",      Value=@"200"    },
                new ItemProperty() { Item = cutHoleItem, Name = @"AutoScaleSizeY",      Value=@"290"    },
                new ItemProperty() { Item = cutHoleItem, Name = @"MoveSpeed",           Value=@"500"    },
                new ItemProperty() { Item = cutHoleItem, Name = @"ImageDPIX",           Value=@"12"    },
                new ItemProperty() { Item = cutHoleItem, Name = @"ImageDPIY",           Value=@"12"    },
                new ItemProperty() { Item = cutHoleItem, Name = @"DotDistX",            Value=@"0.7"    },
                new ItemProperty() { Item = cutHoleItem, Name = @"DotDistY",            Value=@"0.7"    },
                new ItemProperty() { Item = cutHoleItem, Name = @"HoleType",            Value=@"Diamond"    },
				new ItemProperty() { Item = cutHoleItem, Name = @"LoadType",            Value=@"ImageHole"    },

                //grave
                new ItemProperty() { Item = graveItem, Name = @"SettingName",         Value=graveItem.Name    },
                new ItemProperty() { Item = graveItem, Name = @"PenMoveType",         Value=@"CommandString"    },
                new ItemProperty() { Item = graveItem, Name = @"MoveSpeed",           Value=@"450"    },
				new ItemProperty() { Item = graveItem, Name = @"LoadType",            Value=@"HPGL"    },

                //grave Image
                new ItemProperty() { Item = graveIMGItem, Name = @"SettingName",         Value=graveIMGItem.Name    },
                new ItemProperty() { Item = graveIMGItem, Name = @"PenMoveType",         Value=@"CommandString"    },
                new ItemProperty() { Item = graveIMGItem, Name = @"MoveSpeed",           Value=@"450"    },
                new ItemProperty() { Item = graveIMGItem, Name = @"AutoScale",           Value=@"true"    },
                new ItemProperty() { Item = graveIMGItem, Name = @"ImageDPIX",           Value=@"66.7"    },
                new ItemProperty() { Item = graveIMGItem, Name = @"ImageDPIY",           Value=@"66.7"    },
                new ItemProperty() { Item = graveIMGItem, Name = @"AutoScaleSizeX",      Value=@"150"    },
                new ItemProperty() { Item = graveIMGItem, Name = @"AutoScaleSizeY",      Value=@"150"    },
				new ItemProperty() { Item = graveIMGItem, Name = @"LoadType",            Value=@"Image"    },

                //grave Image (G0G1)
                new ItemProperty() { Item = graveIMGG00G01Item, Name = @"SettingName",         Value=graveIMGG00G01Item.Name    },
                new ItemProperty() { Item = graveIMGG00G01Item, Name = @"LaserFirstOnCommand", Value=@"M106 S255"    },
                new ItemProperty() { Item = graveIMGG00G01Item, Name = @"LaserOnCommand",      Value=@""    },
                new ItemProperty() { Item = graveIMGG00G01Item, Name = @"LaserOffCommand",      Value=@""    },
                new ItemProperty() { Item = graveIMGG00G01Item, Name = @"PenMoveType",         Value=@"CommandString"    },
                new ItemProperty() { Item = graveIMGG00G01Item, Name = @"MoveSpeed",           Value=@"450"    },
                new ItemProperty() { Item = graveIMGG00G01Item, Name = @"AutoScale",           Value=@"true"    },
                new ItemProperty() { Item = graveIMGG00G01Item, Name = @"ImageDPIX",           Value=@"66.7"    },
                new ItemProperty() { Item = graveIMGG00G01Item, Name = @"ImageDPIY",           Value=@"66.7"    },
                new ItemProperty() { Item = graveIMGG00G01Item, Name = @"AutoScaleSizeX",      Value=@"150"    },
                new ItemProperty() { Item = graveIMGG00G01Item, Name = @"AutoScaleSizeY",      Value=@"150"    },
                new ItemProperty() { Item = graveIMGG00G01Item, Name = @"LoadType",            Value=@"Image"    }
            };

            context.ItemProperties.AddRange(itemproperties);
        }
Ejemplo n.º 4
0
        private static async Task<int> WriteItem(Item item)
        {
            int id;
            using (var uowwrite = Dependency.Resolve<IUnitOfWork>())
            using (var repwrite = Dependency.ResolveRepository<IItemRepository>(uowwrite))
            {
                await repwrite.Store(item);
				await uowwrite.Save();
                id = item.ItemID;
                Assert.AreNotEqual(0, id);
            }

            return id;
        }
Ejemplo n.º 5
0
		private static void CompareItem(Item e1, Item e2)
		{
			Assert.AreEqual(true, e1.CompareProperties(e2));
            Assert.AreEqual(e1.ItemProperties == null ? 0 : e1.ItemProperties.Count, e2.ItemProperties.Count);

			foreach (ItemProperty mc in e2.ItemProperties)
			{
				Assert.AreEqual(true, mc.CompareProperties(e1.ItemProperties.Single(m => m.Name == mc.Name)));
			}
		}
Ejemplo n.º 6
0
		private static int AddItemProperties(Item e)
		{
			int count = 3;
			e.ItemProperties = new List<ItemProperty>();
            e.ItemProperties.Add(new ItemProperty() { Name = "Name1", Value = "Test1" });
            e.ItemProperties.Add(new ItemProperty() { Name = "Name2", Value = "Test2" });
            e.ItemProperties.Add(new ItemProperty() { Name = "Name3" });
            return count;
		}
Ejemplo n.º 7
0
		private static Item CreateItem(string name)
		{
			var e = new Item()
			{
				Name = name,
                ClassName = "Dummy"
			};
			return e;
		}