【发布时间】:2020-10-17 06:21:11
【问题描述】:
尝试使用 C# 在 Tally(计量单位)中插入 xml 数据 我有一个硬编码值,我将其转换为 xml 格式,并尝试将 xml 数据插入到具有 http://localhost:9000 的 Tally 中。我将数据插入到 Tally 以创建分类帐,但对于来自 Inventory Info 的计量单位失败.
Xml 数据:
String xmlstc = "";
xmlstc = "<ENVELOPE>\r\n";
xmlstc = xmlstc + "<HEADER>\r\n";
xmlstc = xmlstc + "<TALLYREQUEST>Import Data</TALLYREQUEST>\r\n";
xmlstc = xmlstc + "</HEADER>\r\n";
xmlstc = xmlstc + "<BODY>\r\n";
xmlstc = xmlstc + "<IMPORTDATA>\r\n";
xmlstc = xmlstc + "<REQUESTDESC>\r\n";
xmlstc = xmlstc + "<REPORTNAME>All Masters</REPORTNAME>\r\n";
xmlstc = xmlstc + "<STATICVARIABLES><SVCURRENTCOMPANY>Siddharth</SVCURRENTCOMPANY></STATICVARIABLES>\r\n";
xmlstc = xmlstc + "</REQUESTDESC>\r\n";
xmlstc = xmlstc + "<REQUESTDATA>\r\n";
xmlstc = xmlstc + "<TALLYMESSAGE xmlns:UDF=" + "\"" + "TallyUDF" + "\">\r\n";
xmlstc = xmlstc + "<UNIT NAME=" + "\"" + "Kg" + "\" Action =" + "\"" + "Create" + "\">\r\n";
xmlstc = xmlstc + "<NAME>" + "Kg" + "</NAME>\r\n";
xmlstc = xmlstc + "<ORIGINALNAME>" + "Kilogram" + "</ORIGINALNAME>\r\n";
xmlstc = xmlstc + "<ISUPDATINGTARGETID>" + "No" + "</ISUPDATINGTARGETID>\r\n";
xmlstc = xmlstc + "<ASORIGINAL>" + "Yes" + "</ASORIGINAL>\r\n";
xmlstc = xmlstc + "<ISGSTEXCLUDED>" + "No" + "</ISGSTEXCLUDED>\r\n";
xmlstc = xmlstc + "<ISSIMPLEUNIT>" + "Yes" + "</ISSIMPLEUNIT>\r\n";
xmlstc = xmlstc + "<ALTERID>" + "1326" + "</ALTERID>\r\n";
xmlstc = xmlstc + "<DECIMALPLACES>" + "1" + "</DECIMALPLACES>\r\n";
xmlstc = xmlstc + "</UNIT>\r\n";
xmlstc = xmlstc + "</TALLYMESSAGE>\r\n";
xmlstc = xmlstc + "</REQUESTDATA>\r\n";
xmlstc = xmlstc + "</IMPORTDATA>\r\n";
xmlstc = xmlstc + "</BODY>";
xmlstc = xmlstc + "</ENVELOPE>";
在 Tally 中发送数据的代码(库存信息 => 计量单位)
String lTallyLocalHost = "http://localhost:9000";
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(lTallyLocalHost);
httpWebRequest.Method = "POST";
httpWebRequest.ContentLength = (long)xmlstc.Length;
httpWebRequest.ContentType = "application/x-www-form-urlencoded";
StreamWriter lStrmWritr = new StreamWriter(httpWebRequest.GetRequestStream());
lStrmWritr.Write(xmlstc);
lStrmWritr.Close();
HttpWebResponse lhttpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
Stream lreceiveStream = lhttpResponse.GetResponseStream();
StreamReader lStreamReader = new StreamReader(lreceiveStream, Encoding.UTF8);
lResponseStr = lStreamReader.ReadToEnd();
lhttpResponse.Close();
lStreamReader.Close();
【问题讨论】:
-
错误是什么?我猜是 XML 解析错误?
-
不,没有解析错误,我使用相同的 xml 格式将数据插入分类帐和库存组。它仅适用于度量单位..
-
什么不起作用?这意味着什么?你有错误吗?什么错误?你的代码哪一行失败了?确切的错误信息是什么?
-
我没有收到任何错误消息。我从 sql server 将数据放入数据表中。使用 ( for (int i = 0; i
-
我遇到了一个错误。您不能从度量单位将相同的值传递给符号和正式名称,并且不能同时传递字符串和数字。 tally 不会接受它。
标签: c# asp.net asp.net-mvc tally