// Delete public void Delete(int[] arrId) { JArray arrEquip = new JArray(); foreach (var id in arrId) { Equipment equipment = db.Equipments.Find(id); JObject obEquip = new JObject(); obEquip.Add("Name", equipment.Name); obEquip.Add("FormalName", equipment.FormalName); obEquip.Add("Group", equipment.Group); arrEquip.Add(obEquip); db.Equipments.Remove(equipment); } Log log = new Log { ActionType = "Delete", DataType = "P.Equipment", Date = DateTime.Now, User = User.Identity.Name, ChangeData = arrEquip.ToString() }; db.Add(log); db.SaveChanges(); }
public void Create(WordMap wordmap, string variants) { wordmap.ComponentGroup = string.IsNullOrEmpty(wordmap.ComponentGroup) ? null : wordmap.ComponentGroup.Trim(); wordmap.Mass = string.IsNullOrEmpty(wordmap.Mass) ? null : wordmap.Mass.Trim(); wordmap.ElementName = string.IsNullOrEmpty(wordmap.ElementName) ? null : wordmap.ElementName.Trim(); wordmap.ElementType = string.IsNullOrEmpty(wordmap.ElementType) ? null : wordmap.ElementType.Trim(); wordmap.Object = string.IsNullOrEmpty(wordmap.Object) ? null : wordmap.Object.Trim(); wordmap.Desc = string.IsNullOrEmpty(wordmap.Desc) ? null : wordmap.Desc.Trim(); wordmap.Method = string.IsNullOrEmpty(wordmap.Method) ? null : wordmap.Method.Trim(); wordmap.Value = string.IsNullOrEmpty(wordmap.Value) ? null : wordmap.Value.Trim(); wordmap.VariantIds = string.IsNullOrEmpty(wordmap.VariantIds) ? null : wordmap.VariantIds.Trim(); wordmap.Date = DateTime.Now; wordmap.User = User.Identity.Name; db.Add(wordmap); db.SaveChanges(); }
public void Create(VisioMap visiomap, string strRelations, string strShapes) { visiomap.Group = string.IsNullOrEmpty(visiomap.Group) ? null : visiomap.Group.Trim(); visiomap.Title = string.IsNullOrEmpty(visiomap.Title) ? null : visiomap.Title.Trim(); visiomap.Default = string.IsNullOrEmpty(visiomap.Default) || visiomap.Group != "INTERFACE" ? null : visiomap.Default.Trim(); visiomap.EnableLayer = string.IsNullOrEmpty(visiomap.EnableLayer) ? null : visiomap.EnableLayer.Trim(); visiomap.Date = DateTime.Now; visiomap.User = User.Identity.Name; db.Add(visiomap); #region Shapes if (!string.IsNullOrEmpty(strShapes)) { foreach (string strShape in JArray.Parse(strShapes)) { string[] arrVal = strShape.Split(','); string type = arrVal[0]; string name = arrVal[1]; string text = arrVal[2]; string reShape = arrVal[3]; Shape shape = new Shape { VisioMapId = visiomap.Id, Type = string.IsNullOrEmpty(type) ? null : type, Name = string.IsNullOrEmpty(name) ? null : name, Text = string.IsNullOrEmpty(text) ? null : text, Date = DateTime.Now, User = User.Identity.Name }; visiomap.Shapes.Add(shape); db.SaveChanges(); if (!string.IsNullOrEmpty(reShape)) { RelationShape newReShape = new RelationShape { ShapeId = shape.Id, ReShapeId = int.Parse(reShape) }; shape.RelationShapes.Add(newReShape); } } db.SaveChanges(); } #endregion #region Relation if (!string.IsNullOrEmpty(strRelations)) { foreach (var strRelation in JArray.Parse(strRelations)) { string method = (string)strRelation["Method"]; string value = (string)strRelation["Value"]; string variantIds = (string)strRelation["VariantIds"]; int? intEquipmentId = (int?)strRelation["IntEquipmentId"]; int? intProductId = (int?)strRelation["IntProductId"]; int? reLayerId = (int?)strRelation["ReLayerId"]; string reLayerValue = (string)strRelation["ReLayerValue"]; RelationVisiomap relation = new RelationVisiomap { VisiomapId = visiomap.Id, Method = string.IsNullOrEmpty(method) ? null : method.Trim(), Value = string.IsNullOrEmpty(value) ? null : value.Trim(), VariantIds = string.IsNullOrEmpty(variantIds) ? null : value.Trim(), IntEquipmentId = intEquipmentId, IntProductId = intProductId, ReLayerId = reLayerId, ReLayerValue = string.IsNullOrEmpty(reLayerValue) ? null : reLayerValue.Trim() }; db.RelationVisiomaps.Add(relation); } db.SaveChanges(); } #endregion }
public void CreateProduct(Product product) { db.Add(product); JObject obProduct = new JObject(); obProduct.Add("Model", product.Model); obProduct.Add("Title", product.Title); obProduct.Add("Completion", product.Completion); obProduct.Add("EquipmentId", product.EquipmentId); obProduct.Add("Mass", product.Mass); obProduct.Add("componentIdx", product.ComponentIdx); obProduct.Add("State", product.State); obProduct.Add("Group", product.Group); obProduct.Add("TableCol", product.TableCol); Log log = new Log { RefId = product.Id, DataType = "Product", Date = DateTime.Now, User = User.Identity.Name, ChangeData = obProduct.ToString(), ActionType = "CreateProduct" }; db.Add(log); db.SaveChanges(); }