public ActionResult EditTagProps(TagProps model) { if (ModelState.IsValid) { //если валидны и польз и стандратные, то сохраняем var IdForSave = model.Id; tagConfigurator.saveTagProps(model, IdForSave); ViewBag.Notification = 1; //ConfiguratorState confState = configuratorState.Where(c => c.NodeId == model.Id).FirstOrDefault();//найдем состояние для данного узла //confState.flags.ChangeProps = true;//установим для узла флаг изменений //for (int i = 0; i < confState.Users.Count; i++) //{ // if (confState.Users[i].UserName != User.Identity.Name) // { // confState.Users[i].NeedShowNews = true; // } //} } else { ViewBag.Notification = 0; } List <moduleCondition> ActiveModules = connectedModules.Where(m => m.isConnected == true).ToList(); ViewBag.ActiveModules = ActiveModules; ViewBag.OPCservers = OPCServersName; ViewBag.SelectChannel = tagConfigurator.getChannels(model.Id); return(PartialView("TagPartial", model)); }
public void GetAllNormalShot(string tag, ref GameObject decal, ref GameObject fx, ref GameObject hitSound, ref float piercePower) { TagProps tagProps = TagList.Find(x => x.tagName == tag); if (tagProps == null) { return; } if (tagProps.copyAllFromOtherTag) { tagProps = TagList.Find(x => x.tagName == tagProps.otherTagName); } if (tagProps != null) { if (tagProps.bulletHitEffects.Count > 0) { fx = tagProps.bulletHitEffects[Random.Range(0, tagProps.bulletHitEffects.Count)]; } if (tagProps.bulletHoles.Count > 0) { decal = tagProps.bulletHoles[Random.Range(0, tagProps.bulletHoles.Count)]; } if (tagProps.bulletHitSounds.Count > 0) { hitSound = tagProps.bulletHitSounds[Random.Range(0, tagProps.bulletHitSounds.Count)]; } piercePower = tagProps.bulletPowerDecreaser; } }
public void saveTagProps(TagProps tagProps, int id) { var serProps = json.Serialize(tagProps); var sel = context.Properties.Where(c => c.ObjectId == id && c.PropId == 0).FirstOrDefault(); sel.Value = serProps; context.SaveChanges(); }
public void pasteNode(int copyNode, int newNode) { Objects rootCopy = copyObjects.Where(r => r.Id == copyNode).FirstOrDefault(); var rootCopyChilds = copyObjects.Where(r => r.ParentId == copyNode).ToList(); int childrenCount = rootCopyChilds.Count(); for (int i = 0; i < childrenCount; i++) { int currentIdd = ++baseId; copyObjects.Remove(rootCopy);//типа оптимизирую //проверка чтобы избежать бесконечной вставки набора копируемых узлов. if (rootCopyChilds[i].ParentId == nodePaste) return; Objects newPasteNode = new Objects() { Id = currentIdd, ParentId = newNode, Type = rootCopyChilds[i].Type, Name = rootCopyChilds[i].Name }; pasteObjects.Add(newPasteNode); Property rootPropsCopy = propertyList.Where(p => p.ObjectId == rootCopyChilds[i].Id).FirstOrDefault(); propertyList.Remove(rootPropsCopy);//типа оптимизирую string newPropJson = ""; //если у узла есть свойства if (rootPropsCopy.Value != "") { //поправим значение OpcID и Connection в строке свойств newPropJson = rootPropsCopy.Value; if (rootCopyChilds[i].Type == 2) { tagPropsForCopy = new TagProps(); tagPropsForCopy = (TagProps)json.Deserialize(rootPropsCopy.Value, tagPropsForCopy.GetType()); string newConnStr = tagPropsForCopy.Connection; string newConnStrRepl = newConnStr.Replace(oldControllerName, newControllerName); tagPropsForCopy.Opc = OPCIDglobal; tagPropsForCopy.Connection = newConnStrRepl; newPropJson = json.Serialize(tagPropsForCopy); } } //вставка строки со свойствами в таблицу свойств Property objProp = new Property { ObjectId = currentIdd, PropId = 0, Value = newPropJson }; pastePropertyList.Add(objProp); int nextParentId = 0; if (i == 0)//если это первый потомок, то просто наращиваем на 1 Id nextParentId = newNode + 1; else // если же последующие, то присваиваем макс Id для родителя nextParentId = pasteObjects.Last().Id; pasteNode(rootCopyChilds[i].Id, nextParentId); } }
public GameObject getRandomFootStepFx(string tag) { TagProps list = TagList.Find(x => x.tagName == tag); if (list == null || list.footStepFx.Count == 0) { return(null); } return(list.footStepFx[Random.Range(0, list.footStepFx.Count)]); }
public TagProps getTagProps(int id) { var sel1 = context.Properties.AsNoTracking().Where(c => c.ObjectId == id && c.PropId == 0).FirstOrDefault(); var sel2 = context.Objects.Find(id); var tagProps = new TagProps(); string JSONprop = sel1.Value; var props = json.Deserialize(JSONprop, tagProps.GetType()); tagProps = (TagProps)props; tagProps.Id = id; tagProps.Name = sel2.Name; return(tagProps); }
public PartialViewResult AddEvent(TagProps model) //вспомогательный метод для добавления событий тегу { var newEvent = new WebSphere.Domain.Entities.EventValMessage { Value = 0, Message = "Сообщение сигнала с ID=" + model.Id }; if (model.Events.EventMessages == null) { var evMsgList = new List <WebSphere.Domain.Entities.EventValMessage>(); model.Events.EventMessages = new List <WebSphere.Domain.Entities.EventValMessage>(); } model.Events.EventMessages.Add(newEvent); return(PartialView("AddEventPartial", model)); }
public ActionResult EditTagProps(TagProps model) { if (ModelState.IsValid) { var IdForSave = model.Id; tagConfigurator.saveTagProps(model, IdForSave); ViewBag.Notification = 1; } else { ViewBag.Notification = 0; } var userProps = tagConfigurator.getUserProps(model.Id); ViewBag.UserProps = userProps; ViewBag.OPCservers = tagConfigurator.getOpcServersName(); ViewBag.ActiveModules = tagConfigurator.GetConnectedModules(); return(PartialView("TagPartial", model)); }
public string pasteNodeRoot(int idPasteParentElem, int idCopyParentElem, string newContName) { pasteObjects = new List<Objects>(); pastePropertyList = new List<Property>(); nodePaste = idPasteParentElem; copyObjects = context.Objects.Where(o => o.Id >= idCopyParentElem).AsNoTracking().ToList();//попытка хоть немного уменьшить количество объектов по которым идет перебор propertyList = context.Properties.Where(p => p.PropId == 0 && p.ObjectId >= idCopyParentElem).AsNoTracking().ToList(); var rootCopy = copyObjects.Find(m => m.Id == idCopyParentElem);//корневой узел oldControllerName = rootCopy.Name; newControllerName = newContName;//название,которое ввел пользователь string Name = rootCopy.Name;//если узел конечный, то название оставим if (rootCopy.Type == 5 && newContName != "")//если же нет, то заменим на пользовательское { Name = newContName; } Property rootPropsCopy = propertyList.Find(p => p.ObjectId == idCopyParentElem); Objects newNode = new Objects() { Name = Name, Type = rootCopy.Type, ParentId = idPasteParentElem }; context.Objects.Add(newNode); context.SaveChanges(); baseId = newNode.Id;//От него будут отсчитываться последующие Id string newPropJson = ""; if (rootPropsCopy.Value != "") { newPropJson = rootPropsCopy.Value; string newConnSrtId = getConnectionProp(idPasteParentElem, out OPCIDglobal).Trim('/'); if (rootCopy.Type == 2) { tagPropsForCopy = new TagProps(); tagPropsForCopy = (TagProps)json.Deserialize(rootPropsCopy.Value, tagPropsForCopy.GetType()); tagPropsForCopy.Opc = OPCIDglobal; tagPropsForCopy.Connection = newConnSrtId; newPropJson = json.Serialize(tagPropsForCopy); } } Property objProp = new Property { ObjectId = newNode.Id, PropId = 0, Value = newPropJson }; context.Properties.Add(objProp); context.SaveChanges(); //Stopwatch sw = new Stopwatch(); //sw.Start(); pasteNode(idCopyParentElem, newNode.Id); int countPasteNodes = pasteObjects.Count(); context.Configuration.AutoDetectChangesEnabled = false; context.BulkInsert(pasteObjects); context.SaveChanges(); context.BulkInsert(pastePropertyList); context.SaveChanges(); //sw.Stop(); return CreateJsTreeHelp(newNode.Id); }