0

尝试使用 C# 在 Tally(计量单位)中插入 xml 数据我有一个硬编码值,我将其转换为 xml 格式,并尝试将 xml 数据插入到具有 http://localhost:9000.I 插入数据的 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();
4

1 回答 1

0

下载Tally 连接器库并添加对您的项目的引用现在您可以与 Tally 交互,而无需在代码中使用 XML

要在 Tally 中创建单元,请使用以下代码

Using TallyConnector //Importing TallyConnector Library
using TallyConnector.Models;

Ctally = new Tally();

Unit NewUnit = new Unit();
NewUnit.Name = "Kg";
NewUnit.OriginalName = "Kg";
NewUnit.DecimalPlaces= 1;

await Ctally.PostUnit(NewUnit);// Creates Unit in Tally
于 2021-06-11T07:31:59.527 回答