zoukankan      html  css  js  c++  java
  • U8 EAI实现XML的生成

    /********************************************************************************************************************************************/
    /*时间:2019-8-24*/
    /*功能:分别实现U8 XML交换数据文件*/
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Xml;
    using Tools;
    namespace EAI
    {
       public static class ApplicationDataToU8XML
        {
            static string XmlModelTemplatePath = "D:\EAI\XML\";  //为了便于理解此处路径都以绝对路径表示
            //static string XmlModel = "OughtReceive001.xml";
            public static void ApplicationDataToOughtReceiveXML()
            {
                XmlTextWriter xmlTextWriter = new XmlTextWriter(XmlModelTemplatePath + "OughtReceive001.xml", Encoding.Default);
                xmlTextWriter.Formatting = Formatting.Indented;
                xmlTextWriter.WriteStartDocument();
                xmlTextWriter.WriteComment("应收单 roottag:类型 billtype:系统用 docid:唯一编号 receiver:接收方 sender:发送方编码 proc:操作码 codeexchanged:编码是否转换 exportneedexch导出时是否要根据对照表替换");
                xmlTextWriter.WriteStartElement("ufinterface");
                xmlTextWriter.WriteAttributeString("roottag", "oughtreceive");
                xmlTextWriter.WriteAttributeString("billtype", "");
                xmlTextWriter.WriteAttributeString("docid", "");
                xmlTextWriter.WriteAttributeString("receiver", "u8");
                xmlTextWriter.WriteAttributeString("sender", "999");
                xmlTextWriter.WriteAttributeString("proc", "add");
                xmlTextWriter.WriteAttributeString("codeexchanged", "N");
                xmlTextWriter.WriteAttributeString("exportneedexch", "N");
                xmlTextWriter.WriteAttributeString("paginate", "0");
                xmlTextWriter.WriteAttributeString("display", "应收单");
                xmlTextWriter.WriteAttributeString("family", "应收管理");
                xmlTextWriter.WriteAttributeString("timestamp", "");
                xmlTextWriter.WriteAttributeString("version", "2.0");
                xmlTextWriter.WriteStartElement("oughtreceive");
                xmlTextWriter.Indentation = 2;
                xmlTextWriter.WriteStartElement("header");
                xmlTextWriter.Indentation = 2;
                 //以下部分用第三方系统的数据替换,具体实现过程根据实际情况
                xmlTextWriter.WriteElementString("vouchtype", "R0");
                xmlTextWriter.WriteElementString("code", "");
                xmlTextWriter.WriteElementString("relatevouchercode", "");
                xmlTextWriter.WriteElementString("date","2019-08-20");
                xmlTextWriter.WriteElementString("cust_vendor_code", "02004");
                xmlTextWriter.WriteElementString("deptcode","");
                xmlTextWriter.WriteElementString("personcode", "");
                xmlTextWriter.WriteElementString("item_classcode", "");
                xmlTextWriter.WriteElementString("item_code", "");
                xmlTextWriter.WriteElementString("digest", "");
                xmlTextWriter.WriteElementString("subjectcode", ""); //科目编码项目本例填空,实际应用是可以根据实际情况选择
                xmlTextWriter.WriteElementString("currency_name", "人民币");
                xmlTextWriter.WriteElementString("currency_rate", "");
                xmlTextWriter.WriteElementString("bdebitcredit", "");
                xmlTextWriter.WriteElementString("natamount", "");
                xmlTextWriter.WriteElementString("amount", "");
                xmlTextWriter.WriteElementString("natbalance", "500");
                xmlTextWriter.WriteElementString("balancy", "");
                xmlTextWriter.WriteElementString("paycondition_code", "");
                xmlTextWriter.WriteElementString("operator", "");
                xmlTextWriter.WriteElementString("flag", "AR");
                xmlTextWriter.WriteElementString("quantity", "");
                xmlTextWriter.WriteElementString("leavquantity", "");
                xmlTextWriter.WriteElementString("define1", "");
                xmlTextWriter.WriteElementString("define2", "");
                xmlTextWriter.WriteElementString("define3", "");
                xmlTextWriter.WriteElementString("define4", "");
                xmlTextWriter.WriteElementString("define5", "");
                xmlTextWriter.WriteElementString("define6", "");
                xmlTextWriter.WriteElementString("define7", "");
                xmlTextWriter.WriteElementString("define8","");
                xmlTextWriter.WriteElementString("define9", "");
                xmlTextWriter.WriteElementString("define10", "");
                xmlTextWriter.WriteElementString("define11", "");
                xmlTextWriter.WriteElementString("define12", "");
                xmlTextWriter.WriteElementString("define13", "");
                xmlTextWriter.WriteElementString("define14", "");
                xmlTextWriter.WriteElementString("define15", "");
                xmlTextWriter.WriteElementString("define16", "");
                xmlTextWriter.WriteElementString("startflag", "");
                xmlTextWriter.WriteEndElement();
                //本例为了简化以一条明细项的实现举例
                for (int i = 0; i < 2; i++)
                {
                    xmlTextWriter.WriteStartElement("body");
                    xmlTextWriter.Indentation = 2;
                    xmlTextWriter.WriteStartElement("entry");
                    xmlTextWriter.Indentation = 2;
                    xmlTextWriter.WriteElementString("headid", "");
                    xmlTextWriter.WriteElementString("cust_vendor_code","");
                    xmlTextWriter.WriteElementString("deptcode", "202");
                    xmlTextWriter.WriteElementString("personcode", "202002");
                    xmlTextWriter.WriteElementString("item_classcode","");
                    xmlTextWriter.WriteElementString("item_code", "");
                    xmlTextWriter.WriteElementString("digest", "");
                    xmlTextWriter.WriteElementString("subjectcode", "");
                    xmlTextWriter.WriteElementString("currency_name", "人民币");
                    xmlTextWriter.WriteElementString("currency_rate", "1");
                    xmlTextWriter.WriteElementString("bdebitcredit", "0");
                    xmlTextWriter.WriteElementString("natamount", "500");
                    xmlTextWriter.WriteElementString("amount", "500");
                    xmlTextWriter.WriteElementString("shouldquantity", "");
                    xmlTextWriter.WriteElementString("shouldnumber", "");
                    xmlTextWriter.WriteElementString("quantity","1");
                    xmlTextWriter.WriteElementString("assitantunit", "");
                    xmlTextWriter.WriteElementString("number", "");
                    xmlTextWriter.WriteElementString("price", "500");
                    xmlTextWriter.WriteElementString("cost", "");
                    xmlTextWriter.WriteElementString("plancost", "");
                    xmlTextWriter.WriteElementString("planprice", "");
                    xmlTextWriter.WriteElementString("serial", "");
                    xmlTextWriter.WriteElementString("makedate", "");
                    xmlTextWriter.WriteElementString("validdate", "");
                    xmlTextWriter.WriteElementString("transitionid","");
                    xmlTextWriter.WriteElementString("subbillcode", "");
                    xmlTextWriter.WriteElementString("subpurchaseid", "");
                    xmlTextWriter.WriteElementString("position","");
                    xmlTextWriter.WriteElementString("itemclasscode","");
                    xmlTextWriter.WriteElementString("itemclassname", "");
                    xmlTextWriter.WriteElementString("itemcode", "");
                    xmlTextWriter.WriteElementString("itemname", "");
                    xmlTextWriter.WriteEndElement();
                    xmlTextWriter.WriteEndElement();
                }
                xmlTextWriter.Flush();
                xmlTextWriter.Close();
    
            }
            public static void ApplicationDataToVoucherXML()
            {
                XmlTextWriter xmlTextWriter = new XmlTextWriter(XmlModelTemplatePath + "voucher001.xml", Encoding.Default);
                xmlTextWriter.Formatting = Formatting.Indented;
                xmlTextWriter.WriteStartDocument();
                xmlTextWriter.WriteComment("凭证 roottag:类型 billtype:系统用 docid:唯一编号 receiver:接收方 sender:发送方编码 proc:操作码 codeexchanged:编码是否转换 exportneedexch导出时是否要根据对照表替换");
                xmlTextWriter.WriteStartElement("ufinterface");
                xmlTextWriter.WriteAttributeString("roottag", "voucher");
                xmlTextWriter.WriteAttributeString("billtype", "gl");
                xmlTextWriter.WriteAttributeString("docid", "");
                xmlTextWriter.WriteAttributeString("receiver", "u8");
                xmlTextWriter.WriteAttributeString("sender", "999");
                xmlTextWriter.WriteAttributeString("proc", "add");
                xmlTextWriter.WriteAttributeString("codeexchanged", "N");
                xmlTextWriter.WriteAttributeString("exportneedexch", "N");
                xmlTextWriter.WriteAttributeString("renewproofno", "y");
                xmlTextWriter.WriteAttributeString("timestamp", "");
                xmlTextWriter.WriteAttributeString("version", "2.0");
                xmlTextWriter.WriteStartElement("voucher");
                xmlTextWriter.WriteAttributeString("id", "");
                xmlTextWriter.Indentation = 2;
                xmlTextWriter.WriteStartElement("voucher_head");
                xmlTextWriter.Indentation = 2;
                //以下部分用第三方系统的数据替换,具体实现过程根据实际情况
                xmlTextWriter.WriteElementString("company", "");
                xmlTextWriter.WriteElementString("voucher_type", "");
                xmlTextWriter.WriteElementString("fiscal_year", "2006");
                xmlTextWriter.WriteElementString("accounting_period", "10");
                xmlTextWriter.WriteElementString("voucher_id", "1");
                xmlTextWriter.WriteElementString("attachment_number", "1");
                xmlTextWriter.WriteElementString("date", "2006-10-25");
                xmlTextWriter.WriteElementString("enter", "demo");
                xmlTextWriter.WriteElementString("cashier", "");
                xmlTextWriter.WriteElementString("signature", "");
                xmlTextWriter.WriteElementString("checker", "");
                xmlTextWriter.WriteElementString("posting_date", "");
                xmlTextWriter.WriteElementString("posting_person", "");
                xmlTextWriter.WriteElementString("voucher_making_system", "AR");
                xmlTextWriter.WriteElementString("memo1", "");
                xmlTextWriter.WriteElementString("memo2", "");
                xmlTextWriter.WriteElementString("reserve1", "AR");
                xmlTextWriter.WriteElementString("reserve2", "");
                xmlTextWriter.WriteElementString("revokeflag", "");
                xmlTextWriter.WriteEndElement();
                //本例为了简化以一条明细项的实现举例
                for (int i = 0; i < 2; i++)
                {
                    xmlTextWriter.WriteStartElement("voucher_body");
                    xmlTextWriter.Indentation = 2;
                    xmlTextWriter.WriteStartElement("entry");
                    xmlTextWriter.Indentation = 2;
                    xmlTextWriter.WriteElementString("entry_id", "1");
                    xmlTextWriter.WriteElementString("account_code", "1131 ");
                    xmlTextWriter.WriteElementString("abstract", "其他应收单");
                    xmlTextWriter.WriteElementString("settlement", "");
                    xmlTextWriter.WriteElementString("document_id", "");
                    xmlTextWriter.WriteElementString("document_date", "");
                    xmlTextWriter.WriteElementString("currency", "");
                    xmlTextWriter.WriteElementString("unit_price", "");
                    xmlTextWriter.WriteElementString("exchange_rate1", "");
                    xmlTextWriter.WriteElementString("exchange_rate2", "0");
                    xmlTextWriter.WriteElementString("debit_quantity", "0");
                    xmlTextWriter.WriteElementString("primary_debit_amount", "0");
                    xmlTextWriter.WriteElementString("secondary_debit_amount", "600");
                    xmlTextWriter.WriteElementString("natural_debit_currency", "0");
                    xmlTextWriter.WriteElementString("credit_quantity", "");
                    xmlTextWriter.WriteElementString("primary_credit_amount", "0");
                    xmlTextWriter.WriteElementString("secondary_credit_amount", "");
                    xmlTextWriter.WriteElementString("natural_credit_currency", "600");
                    xmlTextWriter.WriteElementString("bill_type", "R0");
                    xmlTextWriter.WriteElementString("bill_id", "0000000003");
                    xmlTextWriter.WriteElementString("bill_date", "2006-10-20");
                    xmlTextWriter.WriteStartElement("detail");
                    xmlTextWriter.WriteElementString("cash_flow_statement", "");
                    xmlTextWriter.WriteElementString("code_remark_statement", "");
                    xmlTextWriter.WriteEndElement();
                    xmlTextWriter.WriteEndElement();
    
                    xmlTextWriter.WriteElementString("entry_id", "2");
                    xmlTextWriter.WriteElementString("account_code", "5503 ");
                    xmlTextWriter.WriteElementString("abstract", "其他应收单");
                    xmlTextWriter.WriteElementString("settlement", "");
                    xmlTextWriter.WriteElementString("document_id", "");
                    xmlTextWriter.WriteElementString("document_date", "");
                    xmlTextWriter.WriteElementString("currency", "");
                    xmlTextWriter.WriteElementString("unit_price", "");
                    xmlTextWriter.WriteElementString("exchange_rate1", "");
                    xmlTextWriter.WriteElementString("exchange_rate2", "0");
                    xmlTextWriter.WriteElementString("debit_quantity", "0");
                    xmlTextWriter.WriteElementString("primary_debit_amount", "0");
                    xmlTextWriter.WriteElementString("secondary_debit_amount", "600");
                    xmlTextWriter.WriteElementString("natural_debit_currency", "0");
                    xmlTextWriter.WriteElementString("credit_quantity", "");
                    xmlTextWriter.WriteElementString("primary_credit_amount", "0");
                    xmlTextWriter.WriteElementString("secondary_credit_amount", "");
                    xmlTextWriter.WriteElementString("natural_credit_currency", "600");
                    xmlTextWriter.WriteElementString("bill_type", "R0");
                    xmlTextWriter.WriteElementString("bill_id", "0000000003");
                    xmlTextWriter.WriteElementString("bill_date", "2006-10-20");
                    xmlTextWriter.WriteStartElement("detail");
                    xmlTextWriter.WriteElementString("cash_flow_statement", "");
                    xmlTextWriter.WriteElementString("code_remark_statement", "");
                    xmlTextWriter.WriteEndElement();
                    xmlTextWriter.WriteEndElement();
    
    
                    xmlTextWriter.WriteEndElement();
    
    
                }
                xmlTextWriter.Flush();
                xmlTextWriter.Close();
    
            }
        }
    }
     
      
  • 相关阅读:
    将方法作为方法的参数
    远程桌面无响应解决方案(转)
    QQ通信机制(转)
    电脑管家禁止程序修改文档后如何恢复权限
    SQL Sever——远程过程调用失败(0x800706be)
    JavaScript学习笔记之JavaScript调用C#编写的COM组件
    kendoUI 免费部分开发部分经验。
    mongoDB连接信息及生成对应的collection生成代码
    写个匹配某段html dom代码某属性的正则匹配方法
    微信获取用户支付共享地址
  • 原文地址:https://www.cnblogs.com/ddlzq/p/11581372.html
Copyright © 2011-2022 走看看