コード例 #1
0
        public static void createNewFileXML(General dateFromForm, string file, bool checkDoc, ParseDocuments document, List <ModelXMLParsePosition> itemRoster)
        {
            General dateForm = dateFromForm;
            List <ModelXMLParsePosition> itemRosterXMl = itemRoster;
            ParseDocuments documents     = document;
            bool           checkStatDocs = checkDoc;
            string         itemXML       = "";

            //XmlTextWriter writeXmlFile = new XmlTextWriter("e:\\Winners.xml", Encoding.UTF8);
            //writeXmlFile.WriteStartDocument();
            // writeXmlFile.WriteStartElement("issuance");
            //writeXmlFile.WriteEndElement();
            // writeXmlFile.Close();
            foreach (var item in itemRosterXMl)
            {
                string itemRost = " <rosterItem> " +
                                  "<number>" + item.numberItemRoster + "</number>" +
                                  "<name>" + item.nameRoster + "</name>" +
                                  "<count>" + item.countRoster + "</count>" +
                                  "<price>" + item.prisceRoster + "</price>" +
                                  "<cost>" + item.costRoster + "</cost>" +
                                  "<summaExcise>" + item.summaExciseRoster + "</summaExcise>" +
                                  "<vat>" +
                                  "<rate>" + item.rateNdsRoster + "</rate>" +
                                  "<rateType>" + item.rateTypeRoster + "</rateType>" +
                                  "<summaVat>" + item.summaVatRoster + "</summaVat>" +
                                  "</vat>" +
                                  "<costVat>" + item.costVatRoster + "</costVat>" +
                                  "</rosterItem>";
                itemXML = itemXML + itemRost;
            }
            string docsForXml = "";

            if (checkStatDocs == true)
            {
                docsForXml = createNewDocXML(document.docType, document);

                /* docsForXml = "<documents>" +
                 *                    "<document>" +
                 *                        "<docType>" +
                 *                           "<code>" + documents.docType + "</code>" +
                 *                         "</docType>" +
                 *                               "<date>" + documents.date + "</date>" +
                 *                               "<blankCode>" + documents.blankCode + "</blankCode>" +
                 *                               "<seria>" + documents.serial + "</seria>" +
                 *                               "<number>" + documents.number + "</number>" +
                 *                     "</document>" +
                 *               "</documents>";*/
            }
            else
            {
                docsForXml = "";
            }



            string xmlShema = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + " <issuance xmlns=\"http://www.w3schools.com\" sender=\"" + dateFromForm.unpProvider + "\"> " +
                              "<general> " +
                              "<number>" + dateFromForm.number + "</number>" +
                              "<dateIssuance>" + dateFromForm.dateIssuance + "</dateIssuance>" +
                              "<dateTransaction>" + dateFromForm.dateTransaction + "</dateTransaction>" +
                              "<documentType>" + dateFromForm.documentType + "</documentType>" +
                              "</general>" +
                              "<provider>" +
                              "<providerStatus>" + dateFromForm.providerStatus + "</providerStatus>" +
                              "<dependentPerson>" + boolToString(dateFromForm.dependentPersonProvider) + "</dependentPerson>" +
                              "<residentsOfOffshore>" + boolToString(dateFromForm.residentsOfOffshoreProvider) + "</residentsOfOffshore>" +
                              "<specialDealGoods>" + boolToString(dateFromForm.specialDealGoodsProvider) + "</specialDealGoods>" +
                              "<bigCompany>" + boolToString(dateFromForm.bigCompanyProvider) + "</bigCompany>" +
                              "<countryCode>" + dateFromForm.countryCodeProvider + "</countryCode>" +
                              "<unp>" + dateFromForm.unpProvider + "</unp>" +
                              "<name>" + dateFromForm.nameProvider + "</name>" +
                              "<address>" + dateFromForm.addressProvider + "</address>" +
                              "</provider>" +
                              "<recipient>" +
                              "<recipientStatus>" + dateFromForm.recipientStatus + "</recipientStatus>" +
                              "<dependentPerson>" + boolToString(dateFromForm.dependentPersonRecipient) + "</dependentPerson>" +
                              "<residentsOfOffshore>" + boolToString(dateFromForm.residentsOfOffshoreRecipient) + "</residentsOfOffshore>" +
                              "<specialDealGoods>" + boolToString(dateFromForm.specialDealGoodsRecipient) + "</specialDealGoods>" +
                              "<bigCompany>" + boolToString(dateFromForm.bigCompanyRecipient) + "</bigCompany>" +
                              "<countryCode>" + dateFromForm.countryCodeRecipient + "</countryCode>" +
                              "<unp>" + dateFromForm.unpRecipient + "</unp>" +
                              "<name>" + dateFromForm.nameRecipient + "</name>" +
                              "<address>" + dateFromForm.addressRecipient + "</address>" +
                              "</recipient>" +
                              "<senderReceiver>" +
                              "<consignors/>" +
                              "<consignees/>" +
                              "</senderReceiver>" +
                              "<deliveryCondition>" +
                              "<contract>" +
                              "<number>" + dateFromForm.numberDeliveryCondition + "</number>" +
                              "<date>" + dateFromForm.dateDeliveryCondition + "</date>" +
                              docsForXml +
                              "</contract>" +
                              "</deliveryCondition>" +
                              "<roster totalCostVat=\"" + dateFromForm.totalCostVatAttrib + "\" totalExcise=\"" + dateFromForm.totalExciseAttrib + "\" totalVat=\"" + dateFromForm.totalVatAttrib + "\" totalCost=\"" + dateFromForm.totalCostAttrib + "\">" +
                              itemXML +
                              "</roster>" +
                              "</issuance>";


            XmlDocument docXml = new XmlDocument();

            //docXml.Load("e:\\Winners.xml");
            docXml.LoadXml(xmlShema);
            //Создаем XML
            // XmlNode element = docXml.CreateElement("issuance");
            //   docXml.DocumentElement.AppendChild(element);

            // XmlAttribute attributeXMNLS = docXml.CreateAttribute("xmlns");
            //attributeXMNLS.Value = "http://www.w3schools.com";
            // docXml.Attributes.Append(attributeXMNLS);

            // XmlAttribute attributeSender = docXml.CreateAttribute("sender");
            // attributeSender.Value = dateForm.unpProvider;
            // docXml.Attributes.Append(attributeSender);

            // String s = docXml.InnerXml;
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Encoding = new UTF8Encoding(false);
            using (XmlWriter w = XmlWriter.Create(file, settings))
            {
                docXml.Save(w);
            }
        }
コード例 #2
0
        public static ParseDocuments documentsXMLparse(XmlDocument docs)
        {
            var document           = new ParseDocuments();
            XmlNamespaceManager ns = new XmlNamespaceManager(docs.NameTable);

            ns.AddNamespace("w3s", "http://www.w3schools.com");
            XmlNode doc = docs;
            XmlNode selectNodeDocument = doc.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract", ns);

            if (selectNodeDocument.SelectSingleNode("w3s:documents/w3s:document/w3s:docType/w3s:code", ns) != null)
            {
                document.docType = selectNodeDocument.SelectSingleNode("w3s:documents/w3s:document/w3s:docType/w3s:code", ns).InnerText;
                if (document.docType != null)
                {
                    if (document.docType == "601")
                    {
                        document.docType  = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:docType/w3s:code", ns).InnerText;
                        document.valueDoc = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:docType/w3s:value", ns).InnerText;
                        document.serial   = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:seria", ns).InnerText;
                        document.date     = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:date", ns).InnerText;
                        document.number   = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:number", ns).InnerText;
                        return(document);
                    }
                    if (document.docType == "608")
                    {
                        document.docType  = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:docType/w3s:code", ns).InnerText;
                        document.valueDoc = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:docType/w3s:value", ns).InnerText;
                        document.date     = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:date", ns).InnerText;
                        document.number   = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:number", ns).InnerText;
                        return(document);
                    }
                    if (document.docType == "611")
                    {
                        document.docType  = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:docType/w3s:code", ns).InnerText;
                        document.valueDoc = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:docType/w3s:value", ns).InnerText;
                        document.date     = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:date", ns).InnerText;
                        document.number   = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:number", ns).InnerText;
                        return(document);
                    }
                    if (document.docType == "612")
                    {
                        document.docType = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:docType/w3s:code", ns).InnerText;
                        document.date    = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:date", ns).InnerText;
                        document.number  = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:number", ns).InnerText;
                        return(document);
                    }

                    else
                    {
                        document.docType = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:docType/w3s:code", ns).InnerText;
                        document.date    = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:date", ns).InnerText;
                        document.serial  = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:seria", ns).InnerText;
                        document.number  = selectNodeDocument.SelectSingleNode("/w3s:issuance/w3s:deliveryCondition/w3s:contract/w3s:documents/w3s:document/w3s:number", ns).InnerText;
                        return(document);
                    }
                }
                else
                {
                    return(document = null);
                }
            }
            else
            {
                return(document = null);
            }
        }
コード例 #3
0
        public static string createNewDocXML(string codeForm, ParseDocuments documents)
        {
            int    code      = Convert.ToInt32(codeForm);
            string newDocXml = "";

            switch (code)
            {
            case 612: newDocXml = "<documents>" +
                                  "<document>" +
                                  "<docType>" +
                                  "<code>" + documents.docType + "</code>" +
                                  "<value>" + documents.blankCode + "</value>" +
                                  "</docType>" +
                                  "<date>" + documents.date + "</date>" +
                                  "<blankCode></blankCode>" +
                                  "<seria>" + documents.serial + "</seria>" +
                                  "<number>" + documents.number + "</number>" +
                                  "</document>" +
                                  "</documents>"; break;

            case 611:
                newDocXml = "<documents>" +
                            "<document>" +
                            "<docType>" +
                            "<code>" + documents.docType + "</code>" +
                            "<value>" + documents.valueDoc + "</value>" +
                            "</docType>" +
                            "<date>" + documents.date + "</date>" +
                            "<blankCode></blankCode>" +
                            "<seria>" + documents.serial + "</seria>" +
                            "<number>" + documents.number + "</number>" +
                            "</document>" +
                            "</documents>"; break;

            case 601: newDocXml = "<documents>" +
                                  "<document>" +
                                  "<docType>" +
                                  "<code>" + documents.docType + "</code>" +
                                  "<value>" + documents.valueDoc + "</value>" +
                                  "</docType>" +
                                  "<date>" + documents.date + "</date>" +
                                  "<blankCode></blankCode>" +
                                  "<seria>" + documents.serial + "</seria>" +
                                  "<number>" + documents.number + "</number>" +
                                  "</document>" +
                                  "</documents>";; break;

            case 608: newDocXml = "<documents>" +
                                  "<document>" +
                                  "<docType>" +
                                  "<code>" + documents.docType + "</code>" +
                                  "<value>" + documents.valueDoc + "</value>" +
                                  "</docType>" +
                                  "<date>" + documents.date + "</date>" +
                                  "<blankCode></blankCode>" +
                                  "<seria>" + documents.serial + "</seria>" +
                                  "<number>" + documents.number + "</number>" +
                                  "</document>" +
                                  "</documents>"; break;

            default: newDocXml = "<documents>" +
                                 "<document>" +
                                 "<docType>" +
                                 "<code>" + documents.docType + "</code>" +
                                 "</docType>" +
                                 "<date>" + documents.date + "</date>" +
                                 "<blankCode>" + documents.blankCode + "</blankCode>" +
                                 "<seria>" + documents.serial + "</seria>" +
                                 "<number>" + documents.number + "</number>" +
                                 "</document>" +
                                 "</documents>";; break;
            }

            return(newDocXml);
        }