public ActionResult EditXmlFileForm(int id) { HttpResponseMessage resp = GlobalVariables.WebApiClient.GetAsync("api/pocxml/" + id.ToString()).Result; ConversionXmlViewModel model = resp.Content.ReadAsAsync <ConversionXmlViewModel>().Result; return(PartialView("_EditXmlFileForm", model)); }
public JsonResult XmlFileTree(int id) { XmlSerialization xs = new XmlSerialization(); HttpResponseMessage resp = GlobalVariables.WebApiClient.GetAsync("api/pocxml/" + id.ToString()).Result; ConversionXmlViewModel model = resp.Content.ReadAsAsync <ConversionXmlViewModel>().Result; var xmlModel = xs.ProcessXml(model.XmlFile); return(Json(xmlModel, JsonRequestBehavior.AllowGet)); }
public ActionResult Texteditor(int id) { HttpResponseMessage resp = GlobalVariables.WebApiClient.GetAsync("api/pocxml/" + id.ToString()).Result; ConversionXmlViewModel model = resp.Content.ReadAsAsync <ConversionXmlViewModel>().Result; XmlSerialization xs = new XmlSerialization(); var elements = xs.GetAllUniqueElements(model.XmlFile); model.XmlElements = elements; return(PartialView("_TextEditor", model)); }
public void AddChildRecursive(XElement element, int nodeId, ConversionXmlViewModel xmlFile) { var node = xmlFile.XmlModel; var childList = xmlFile.XmlModel.Where(s => s.ParentId == nodeId).ToList(); foreach (var item in childList) { XElement newchild = new XElement(item.NodeName, item.NodeValue); GetAttributes(item, newchild); element.Add(newchild); AddChildRecursive(newchild, item.NodeId, xmlFile); } }
public ActionResult UpdateXMLFile(ConversionXmlViewModel xmlfile) { XmlSerialization xs = new XmlSerialization(); XDocument xdoc = xs.SerializeObjectintoXml(xmlfile); HttpResponseMessage resp = GlobalVariables.WebApiClient.PutAsJsonAsync("api/pocxml/" + xmlfile.Xml_id.ToString(), xmlfile).Result; if (resp.IsSuccessStatusCode) { return(Json("success")); } else { return(Json("fail")); } }
public XDocument SerializeObjectintoXml(ConversionXmlViewModel xmlFile) { var childList = xmlFile.XmlModel.Where(s => s.ParentId == 1).ToList(); XDocument xdoc = new XDocument(); XElement xe = new XElement(xmlFile.XmlModel[0].NodeName); GetAttributes(xmlFile.XmlModel[0], xe); for (int i = 0; i < childList.Count(); i++) { XElement newchild = new XElement(childList[i].NodeName, childList[i].NodeValue); GetAttributes(childList[i], newchild); AddChildRecursive(newchild, childList[i].NodeId, xmlFile); xe.Add(newchild); } xdoc.Add(xe); return(xdoc); }