private static void GenerateProject() { PushOutPut("Uploading the project"); DateTime dtn = DateTime.Now; var pr3 = CommonFunctions.ToNgProgect(pr); CommonFunctions.SaveXml("temp.xml", pr3); Boolean uploadStatus = false; string url = Constants.SITEURL + "FileHandling"; string filePath = @"\"; Random rnd = new Random(); string uploadFileName = CommonFunctions.RandomString(); uploadStatus = Upload(url, filePath, "temp.xml", uploadFileName); if (uploadStatus) { try { PushOutPut("Upload success"); PushOutPut("Generating the code"); PostData(uploadFileName + ".xml").Wait(); } catch (Exception ex) { PushOutPut(ex.Message); } } else { PushOutPut("Upload failed. Please try again."); MessageBox.Show("Upload failed. Please try again."); } }
public static void SaveXml(string strFileName, NgProject2 pr) { var pr2 = CommonFunctions.ToNgProgect(pr); XmlSerializer xsSubmit = new XmlSerializer(typeof(NgProject)); var xml = ""; using (var sww = new StringWriter()) { using (XmlWriter writer = XmlWriter.Create(sww)) { xsSubmit.Serialize(writer, pr2); xml = sww.ToString(); // Your XML } } CommonFunctions.WriteToFile(strFileName, xml); }