Мое требование состоит в том, чтобы вставить мой ASP.NET данные приложения в tally.
public partial class WebForm1 : System.Web.UI.Page { private static string RequestXML; private static WebRequest TallyRequest; protected void Page_Load(object sender, EventArgs e) { } public static DataSet ConnectToTally() { //try //{ RequestXML = "<ENVELOPE><HEADER><TALLYREQUEST>Export Data</TALLYREQUEST></HEADER><BODY><EXPORTDATA><REQUESTDESC><REPORTNAME>List of Products</REPORTNAME><STATICVARIABLES><SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT><PRODUCTTYPE>All Inventory Masters</PRODUCTTTYPE></STATICVARIABLES></REQUESTDESC></EXPORTDATA></BODY></ENVELOPE>"; TallyRequest = WebRequest.Create("http://localhost:9000"); ((HttpWebRequest)TallyRequest).UserAgent = ".NET Framework Example Client"; TallyRequest.Method = "Post"; string postData = RequestXML; byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(postData); TallyRequest.ContentType = "application/x-www-form-urlencoded"; TallyRequest.ContentLength = byteArray.Length; Stream dataStream = TallyRequest.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); WebResponse response = TallyRequest.GetResponse(); string Response = (((HttpWebResponse)response).StatusDescription).ToString(); dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string responseFromTallyServer = reader.ReadToEnd().ToString(); DataSet TallyResponseDataSet = new DataSet(); TallyResponseDataSet.ReadXml(new StringReader(responseFromTallyServer)); reader.Close(); dataStream.Close(); response.Close(); byteArray = null; response = null; responseFromTallyServer = null; Response = null; dataStream = null; return TallyResponseDataSet; } protected void btn_Click(object sender, EventArgs e) { try { ConnectToTally(); string xmlstc = string.Empty; xmlstc = xmlstc + "<MultipleStockItems=" + "\"" + "All items" + "\" ACTION=" + "\"" + "Create" + "\">"; xmlstc = "<ENVELOPE>"; xmlstc = xmlstc + "<HEADER>"; xmlstc = xmlstc + "<TALLYREQUEST>Export Data</TALLYREQUEST>"; xmlstc = xmlstc + "</HEADER>"; xmlstc = xmlstc + "<BODY>"; xmlstc = xmlstc + "<IMPORTDATA>"; xmlstc = xmlstc + "<REQUESTDESC>"; xmlstc = xmlstc + "<REPORTNAME>ListOfProducts</REPORTNAME>"; xmlstc = xmlstc + "<STATICVARIABLES>"; xmlstc = xmlstc + "<SVCURRENTCOMPANY>Sphinx</SVCURRENTCOMPANY>"; xmlstc = xmlstc + "</STATICVARIABLES>"; xmlstc = xmlstc + "</REQUESTDESC>"; xmlstc = xmlstc + "<REQUESTDATA>"; string item= itm.Text; string group = grp.Text; string unit = unt.Text; string quantity = qnt.Text; string Rate = rate.Text; string msi = ""; xmlstc = xmlstc + "<TALLYMESSAGE >"; xmlstc = xmlstc + "<MultipleStockItems=" + "\"" + "All items" + "\" ACTION=" + "\"" + "Create" + "\">"; xmlstc = xmlstc + "<NameOfItem>" + item + "</NameOfItem>"; xmlstc = xmlstc + "<under>" + group + "</under>"; xmlstc = xmlstc + "<units>" + unit + "</units>"; xmlstc = xmlstc + "<OpeningQuantity>" + quantity + "</OpeningQuantity>"; xmlstc = xmlstc + "<Rate>" + rate + "</Rate>"; xmlstc = xmlstc + "<MultipleStockItems>" + msi + "</MultipleStockItems>"; xmlstc = xmlstc + "</MultipleStockItems>"; xmlstc = xmlstc + "</TALLYMESSAGE>"; xmlstc = xmlstc + "</REQUESTDATA>"; xmlstc = xmlstc + "</IMPORTDATA>"; xmlstc = xmlstc + "</BODY>"; xmlstc = xmlstc + "</ENVELOPE>"; string result = ""; HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("http://localhost:9000"); httpWebRequest.Method = "POST"; httpWebRequest.ContentLength = xmlstc.Length; httpWebRequest.ContentType = "application/x-www-form-urlencoded"; StreamWriter streamWriter; streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()); streamWriter.Write(xmlstc); Response.Write("Data inserted into Tally sucessfully"); streamWriter.Close();
Что я уже пробовал:
Я попробовал приведенный выше код. Но я не могу хранить данные моего текстового поля в tally. Пожалуйста, помогите мне в этом