public ActionResult UploadContent(int id, IEnumerable <HttpPostedFileBase> fileUpload, bool closeWindow = false) { foreach (var file in fileUpload) { if (file == null) { continue; } byte[] fileContent = new byte[file.InputStream.Length]; file.InputStream.Read(fileContent, 0, fileContent.Length); string JsonContent = System.Text.Encoding.Default.GetString(fileContent); NodeControllerAdapter.SchemaEntity[] schemaContent = NodeControllerAdapter.GetSchema(JsonContent); for (int i = 0; i < schemaContent.Length; i++) { NodeControllerAdapter.SchemaEntity schemaEntity = schemaContent[i]; string entId = CreateEntity(schemaEntity, id.ToString()); } } if (closeWindow) { return(View("Close")); } else { return(RedirectToAction("UploadContent/" + id.ToString())); } }
//private string CreateEntity(string stereotypeName, string parentId, string entityName, NodeControllerAdapter.SchemaAttribute[] attrs, string guid = null) private string CreateEntity(NodeControllerAdapter.SchemaEntity schemaEntity, string parentId, string guid = null) { string stereotypeName = schemaEntity.StereotypeName; string entityName = schemaEntity.Name; NodeControllerAdapter.SchemaAttribute[] attrs = schemaEntity.schemaAttributes; string entityCreateResult = DnD(stereotypeName, parentId, 0); //"[{\"id\":10000361,\"text\":\"Entity\",\"icon\":\"Entity\",\"name\":\"Entity\"}]"; dynamic ES = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(entityCreateResult); string resultId = ""; if (ES.Count > 0) { resultId = ES[0].id.ToString(); Rename(resultId, entityName); if (guid != null) { Dersa.Common.Util.SetGuid(HttpContext.User.Identity.Name, resultId, guid); } } Common.DersaSqlManager DM = new Common.DersaSqlManager(); if (resultId != "" && attrs != null && attrs.Length > 0) { for (int a = 0; a < attrs.Length; a++) { //NodeControllerAdapter.SetAttribute(DM, "ENTITY$SetAttribute", resultId, attrs[a].Name, attrs[a].Value); NodeControllerAdapter.SetAttribute(DM, Common.AttributeOwnerType.Entity, resultId, attrs[a].Name, attrs[a].Value, 0); } } NodeControllerAdapter.SchemaEntity[] childEntities = schemaEntity.childEntities; for (int c = 0; c < childEntities.Length; c++) { NodeControllerAdapter.SchemaEntity childEntity = childEntities[c]; CreateEntity(childEntity, resultId); } return(resultId); }
public string SetTextProperty(int entity, string prop_name, string prop_value) { return(NodeControllerAdapter.SetTextProperty(entity, prop_name, prop_value)); }