Exemplo n.º 1
0
 private void ParseB2B(string xmlPath)
 {
     doc = new XmlDocument();
     doc.Load(xmlPath);
     NClist = new List <schemas.Notification>();
     for (int i = 0; i < doc.SelectNodes(nodePath).Count; i++)
     {
         node = doc.SelectNodes(nodePath)[i];
         schemas.Notification NC = new schemas.Notification();
         NC.notice.notificationType   = GetNodeText("title");
         NC.notice.href               = GetNodeText("link");
         NC.notice.orderName          = GetNodeText("description");
         NC.notice.notificationNumber = GetNodeText("guid");
         NC.notice.publishDate        = Common.IsDate(GetNodeText("pubDate"));
         NC.notice.orgName            = GetNodeText("orgName");
         NC.notice.orgINN             = GetNodeText("orgInn");
         // фейковый лот для суммы и валюты
         NC.oneLot.maxPrice     = GetNodeText("price");
         NC.oneLot.currencyName = GetNodeText("currency");
         NC.notice.region       = GetNodeText("region");
         NC.notice.okdpPath     = GetNodeText("okdpPaths");
         if (!string.IsNullOrEmpty(NC.notice.okdpPath))
         {
             NC.notice.okdpPath = NC.notice.okdpPath.Replace(",,", ",");
             NC.notice.okdpPath = NC.notice.okdpPath.Remove(0, 1);
             NC.notice.okdpPath = NC.notice.okdpPath.Remove(NC.notice.okdpPath.Length - 1, 1);
         }
         NC.notice.notificationType = NC.notice.notificationType.Replace("&quot;", "\"");
         NC.notice.orderName        = NC.notice.orderName.Replace("&quot;", "\"");
         NC.notice.orgName          = NC.notice.orgName.Replace("&quot;", "\"");
         NClist.Add(NC);
     }
     File.Delete(path);
 }
Exemplo n.º 2
0
        public void ParseXML(string xmlPath)
        {
            Nlist = new List <schemas.Notification>();
            foreach (string oneXML in Directory.GetFiles(xmlPath))
            {
                // грузим документ
                doc = new XmlDocument();
                try
                {
                    doc.Load(oneXML);
                }
                catch
                {
                    // кривой файл пропускаем
                    continue;
                }

                xnm = new XmlNamespaceManager(doc.NameTable);
                xnm.AddNamespace("ns3", "http://zakupki.gov.ru/oos/printform/1");
                xnm.AddNamespace("oos", "http://zakupki.gov.ru/oos/types/1");
                xnm.AddNamespace("ns2", "http://zakupki.gov.ru/oos/export/1");
                // проверим что это EF документ
                // проверим что это Notice
                string noticeType;
                if (doc.SelectSingleNode(startNodeEF, xnm) != null)
                {
                    node       = doc.SelectNodes(startNodeEF, xnm)[0];
                    nodes      = doc.SelectNodes(startNodeEF, xnm);
                    noticeType = "EF";
                }
                else if (doc.SelectSingleNode(startNodeOK, xnm) != null)
                {
                    node       = doc.SelectNodes(startNodeOK, xnm)[0];
                    nodes      = doc.SelectNodes(startNodeOK, xnm);
                    noticeType = "OK";
                }
                else if (doc.SelectSingleNode(startNodeZK, xnm) != null)
                {
                    node       = doc.SelectNodes(startNodeZK, xnm)[0];
                    nodes      = doc.SelectNodes(startNodeZK, xnm);
                    noticeType = "ZK";
                }
                else if (doc.SelectSingleNode(startNodePO, xnm) != null)
                {
                    node       = doc.SelectNodes(startNodePO, xnm)[0];
                    nodes      = doc.SelectNodes(startNodePO, xnm);
                    noticeType = "PO";
                }
                else if (doc.SelectSingleNode(startNodeEP, xnm) != null)
                {
                    node       = doc.SelectNodes(startNodeEP, xnm)[0];
                    nodes      = doc.SelectNodes(startNodeEP, xnm);
                    noticeType = "EP";
                }
                else if (doc.SelectSingleNode(startNodeISM, xnm) != null)
                {
                    node       = doc.SelectNodes(startNodeISM, xnm)[0];
                    nodes      = doc.SelectNodes(startNodeISM, xnm);
                    noticeType = "ISM";
                }
                else if (doc.SelectSingleNode(startNodeISO, xnm) != null)
                {
                    node       = doc.SelectNodes(startNodeISO, xnm)[0];
                    nodes      = doc.SelectNodes(startNodeISO, xnm);
                    noticeType = "ISO";
                }
                else if (doc.SelectSingleNode(startNodeOKD, xnm) != null)
                {
                    node       = doc.SelectNodes(startNodeOKD, xnm)[0];
                    nodes      = doc.SelectNodes(startNodeOKD, xnm);
                    noticeType = "OKD";
                }
                else if (doc.SelectSingleNode(startNodeOKOU, xnm) != null)
                {
                    node       = doc.SelectNodes(startNodeOKOU, xnm)[0];
                    nodes      = doc.SelectNodes(startNodeOKOU, xnm);
                    noticeType = "OKOU";
                }
                else if (doc.SelectSingleNode(startNodeZakA, xnm) != null)
                {
                    node       = doc.SelectNodes(startNodeZakA, xnm)[0];
                    nodes      = doc.SelectNodes(startNodeZakA, xnm);
                    noticeType = "ZakA";
                }
                else if (doc.SelectSingleNode(startNodeZakKD, xnm) != null)
                {
                    node       = doc.SelectNodes(startNodeZakKD, xnm)[0];
                    nodes      = doc.SelectNodes(startNodeZakKD, xnm);
                    noticeType = "ZakKD";
                }
                else if (doc.SelectSingleNode(startNodeZakKOU, xnm) != null)
                {
                    node       = doc.SelectNodes(startNodeZakKOU, xnm)[0];
                    nodes      = doc.SelectNodes(startNodeZakKOU, xnm);
                    noticeType = "ZakKOU";
                }
                else if (doc.SelectSingleNode(startNodeZP, xnm) != null)
                {
                    node       = doc.SelectNodes(startNodeZP, xnm)[0];
                    nodes      = doc.SelectNodes(startNodeZP, xnm);
                    noticeType = "ZP";
                }
                else
                {
                    continue;
                }

                for (int i = 0; i < nodes.Count; i++)
                {
                    node = nodes[i];
                    schemas.Notification NC = new schemas.Notification();
                    // разбираем notification
                    NC.notice.notificationNumber = GetNodeText("oos:purchaseNumber");
                    NC.notice.notificationType   = noticeType;
                    NC.notice.orderName          = GetNodeText("oos:purchaseObjectInfo");
                    NC.notice.publishDate        = Convert.ToDateTime(GetNodeText("oos:docPublishDate")).ToString("yyyy-MM-dd hh-mm-ss");
                    NC.notice.href            = GetNodeText("oos:href");
                    NC.notice.placingWay_code = GetNodeText("oos:placingWay/oos:code");
                    NC.notice.orgName         = GetNodeText("oos:purchaseResponsible/oos:responsibleOrg/oos:fullName");
                    NC.notice.orgRegNum       = GetNodeText("oos:purchaseResponsible/oos:responsibleOrg/oos:regNum");
                    NC.notice.orgINN          = GetNodeText("oos:purchaseResponsible/oos:responsibleOrg/oos:INN");
                    // NC.notice.placementFeature_code = GetNodeText("oos:lots/oos:lot/oos:notificationFeatures/oos:notificationFeature/oos:placementFeature/oos:code");
                    // NC.notice.placementFeature_name = GetNodeText("oos:lots/oos:lot/oos:notificationFeatures/oos:notificationFeature/oos:placementFeature/oos:name");
                    NC.notice.ep_name = GetNodeText("ETP/name");
                    NC.notice.ep_url  = GetNodeText("ETP/url");
                    // определяем дату окончания подачи заявки (для каждого вида может быть свой узел)
                    switch (noticeType)
                    {
                    case "EF": NC.notice.submissionCloseDateTime = Convert.ToDateTime(GetNodeText("oos:procedureInfo/oos:collecting/oos:endDate")).ToString("yyyy-MM-dd hh-mm-ss"); break;

                    case "EP": NC.notice.submissionCloseDateTime = Convert.ToDateTime(GetNodeText("oos:procedureInfo/oos:collecting/oos:endDate")).ToString("yyyy-MM-dd hh-mm-ss"); break;

                    case "ISM": NC.notice.submissionCloseDateTime = Convert.ToDateTime(GetNodeText("oos:procedureInfo/oos:collectingEndDate")).ToString("yyyy-MM-dd hh-mm-ss"); break;

                    case "ISO": NC.notice.submissionCloseDateTime = Convert.ToDateTime(GetNodeText("oos:procedureInfo/oos:collectingEndDate")).ToString("yyyy-MM-dd hh-mm-ss"); break;

                    case "OKD": NC.notice.submissionCloseDateTime = Convert.ToDateTime(GetNodeText("oos:procedureInfo/oos:stageOne/oos:collecting/oos:endDate")).ToString("yyyy-MM-dd hh-mm-ss"); break;

                    case "OKOU": NC.notice.submissionCloseDateTime = Convert.ToDateTime(GetNodeText("oos:procedureInfo/oos:collecting/oos:endDate")).ToString("yyyy-MM-dd hh-mm-ss"); break;

                    case "OK": NC.notice.submissionCloseDateTime = Convert.ToDateTime(GetNodeText("oos:procedureInfo/oos:collecting/oos:endDate")).ToString("yyyy-MM-dd hh-mm-ss"); break;

                    case "ZakA": NC.notice.submissionCloseDateTime = Convert.ToDateTime(GetNodeText("oos:procedureInfo/oos:collecting/oos:endDate")).ToString("yyyy-MM-dd hh-mm-ss"); break;

                    case "ZakKD": NC.notice.submissionCloseDateTime = Convert.ToDateTime(GetNodeText("oos:procedureInfo/oos:stageOne/oos:collecting/oos:endDate")).ToString("yyyy-MM-dd hh-mm-ss"); break;

                    case "ZakKOU": NC.notice.submissionCloseDateTime = Convert.ToDateTime(GetNodeText("oos:procedureInfo/oos:collecting/oos:endDate")).ToString("yyyy-MM-dd hh-mm-ss"); break;

                    case "ZakK": NC.notice.submissionCloseDateTime = Convert.ToDateTime(GetNodeText("oos:procedureInfo/oos:collecting/oos:endDate")).ToString("yyyy-MM-dd hh-mm-ss"); break;

                    case "ZK": NC.notice.submissionCloseDateTime = Convert.ToDateTime(GetNodeText("oos:procedureInfo/oos:collecting/oos:endDate")).ToString("yyyy-MM-dd hh-mm-ss"); break;

                    case "PO": NC.notice.submissionCloseDateTime = Convert.ToDateTime(GetNodeText("oos:procedureInfo/oos:collecting/oos:endDate")).ToString("yyyy-MM-dd hh-mm-ss"); break;

                    case "ZP": NC.notice.submissionCloseDateTime = Convert.ToDateTime(GetNodeText("oos:procedureInfo/oos:collecting/oos:endDate")).ToString("yyyy-MM-dd hh-mm-ss"); break;
                        // case "SZ": NC.notice.submissionCloseDateTime = Convert.ToDateTime(GetNodeText("oos:notificationCommission/oos:p1Date")).ToString("yyyy-MM-dd hh-mm-ss"); break;
                    }
                    // разбираем документы
                    foreach (XmlNode oneDoc in node.SelectNodes("oos:attachments/oos:attachment", xnm))
                    {
                        NC.documents.Add(new schemas.Notification.Documents(GetNodeText("oos:fileName", oneDoc), GetNodeText("oos:docDescription", oneDoc),
                                                                            GetNodeText("oos:url", oneDoc)));
                    }
                    // разбираем лоты

                    /* ДОДЕЛАТЬ ЛОТЫ! */
                    if (noticeType == "ISO") // однолотовый
                    {
                        NC.oneLot.subject      = GetNodeText("oos:lot/oos:OKPD2/oos:name") ?? GetNodeText("oos:lot/oos:purchaseObjects/oos:purchaseObject/oos:name");
                        NC.oneLot.currencyCode = GetNodeText("oos:lot/oos:currency/oos:code");
                        NC.oneLot.currencyName = GetNodeText("oos:lot/oos:currency/oos:name");
                        NC.oneLot.maxPrice     = GetNodeText("oos:lot/oos:maxPrice");
                        NC.lots.Add(NC.oneLot);
                        NC.oneProduct.name = GetNodeText("oos:lot/oos:OKPD2/oos:name");
                        NC.oneProduct.code = GetNodeText("oos:lot/oos:OKPD2/oos:code");
                        if (NC.oneProduct.name == null)
                        {
                            NC.oneProduct.name     = GetNodeText("oos:lot/oos:purchaseObjects/oos:purchaseObject/oos:OKPD2/oos:name");
                            NC.oneProduct.code     = GetNodeText("oos:lot/oos:purchaseObjects/oos:purchaseObject/oos:OKPD2/oos:code");
                            NC.oneProduct.fullname = GetNodeText("oos:lot/oos:purchaseObjects/oos:purchaseObject/oos:name");
                            NC.oneProduct.price    = GetNodeText("oos:lot/oos:purchaseObjects/oos:purchaseObject/oos:sum");
                        }
                        NC.products.Add(NC.oneProduct);
                    }
                    else
                    {
                        if (node.SelectSingleNode("oos:lots/oos:lot", xnm) == null)
                        {
                            XmlNode oneLot = node.SelectSingleNode("oos:lot", xnm);
                            if (noticeType == "OKD" || noticeType == "OKOU" || noticeType == "OK" || noticeType == "ZakKD" || noticeType == "ZakKOU" || noticeType == "ZakK")
                            {
                                NC.oneLot.subject = GetNodeText("oos:lotObjectInfo", oneLot);
                            }
                            else
                            {
                                NC.oneLot.subject = GetNodeText("oos:purchaseObjects/oos:purchaseObject/oos:name", oneLot);
                            }
                            NC.oneLot.currencyCode = GetNodeText("oos:currency/oos:code", oneLot);
                            NC.oneLot.currencyName = GetNodeText("oos:currency/oos:name", oneLot);
                            if (NC.oneLot.currencyName.Length > 30)
                            {
                                NC.oneLot.currencyName = NC.oneLot.currencyName.Substring(0, 30);
                            }
                            NC.oneLot.maxPrice = GetNodeText("oos:maxPrice", oneLot);
                            NC.lots.Add(NC.oneLot);
                            // смотрим на продукты в лоте
                            foreach (XmlNode oneProduct in oneLot.SelectNodes("oos:purchaseObjects/oos:purchaseObject", xnm))
                            {
                                NC.oneProduct.name     = GetNodeText("oos:OKPD2/oos:name", oneProduct);
                                NC.oneProduct.code     = GetNodeText("oos:OKPD2/oos:code", oneProduct);
                                NC.oneProduct.fullname = GetNodeText("oos:name", oneProduct);
                                if (NC.oneProduct.fullname != null)
                                {
                                    if (NC.oneProduct.fullname.Length > 1000)
                                    {
                                        NC.oneProduct.fullname = NC.oneProduct.fullname.Substring(0, 1000);
                                    }
                                }
                                NC.oneProduct.price = GetNodeText("oos:sum", oneProduct);
                                NC.products.Add(NC.oneProduct);
                            }
                        }
                        else
                        {
                            foreach (XmlNode oneLot in node.SelectNodes("oos:lots/oos:lot", xnm))
                            {
                                if (noticeType == "OKD" || noticeType == "OKOU" || noticeType == "OK" || noticeType == "ZakKD" || noticeType == "ZakKOU" || noticeType == "ZakK")
                                {
                                    NC.oneLot.subject = GetNodeText("oos:lotObjectInfo", oneLot);
                                }
                                else
                                {
                                    NC.oneLot.subject = GetNodeText("oos:purchaseObjects/oos:purchaseObject/oos:name", oneLot);
                                }
                                NC.oneLot.currencyCode = GetNodeText("oos:currency/oos:code", oneLot);
                                NC.oneLot.currencyName = GetNodeText("oos:currency/oos:name", oneLot);
                                if (NC.oneLot.currencyName != null)
                                {
                                    if (NC.oneLot.currencyName.Length > 30)
                                    {
                                        NC.oneLot.currencyName = NC.oneLot.currencyName.Substring(0, 30);
                                    }
                                }
                                NC.oneLot.maxPrice = GetNodeText("oos:maxPrice", oneLot);
                                NC.lots.Add(NC.oneLot);
                                // смотрим на продукты в лоте
                                foreach (XmlNode oneProduct in oneLot.SelectNodes("oos:purchaseObjects/oos:purchaseObject", xnm))
                                {
                                    NC.oneProduct.name     = GetNodeText("oos:OKPD2/oos:name", oneProduct);
                                    NC.oneProduct.code     = GetNodeText("oos:OKPD2/oos:code", oneProduct);
                                    NC.oneProduct.fullname = GetNodeText("oos:name", oneProduct);
                                    if (NC.oneProduct.fullname != null)
                                    {
                                        if (NC.oneProduct.fullname.Length > 1000)
                                        {
                                            NC.oneProduct.fullname = NC.oneProduct.fullname.Substring(0, 1000);
                                        }
                                    }
                                    NC.oneProduct.price = GetNodeText("oos:sum", oneProduct);
                                    NC.products.Add(NC.oneProduct);
                                }
                            }
                        }
                    }
                    Nlist.Add(NC);
                    File.Delete(oneXML);
                }
            }
        }
Exemplo n.º 3
0
        public void ParseXML(string xmlPath)
        {
            Nlist = new List <schemas.Notification>();
            foreach (string oneXML in Directory.GetFiles(xmlPath))
            {
                doc = new XmlDocument();
                doc.Load(oneXML);
                xnm = new XmlNamespaceManager(doc.NameTable);
                xnm.AddNamespace("ns2", "http://zakupki.gov.ru/223fz/purchase/1");
                xnm.AddNamespace("typ", "http://zakupki.gov.ru/223fz/types/1");

                schemas.Notification NC = new schemas.Notification();
                // проверим что это Notice
                if (doc.SelectSingleNode(startNodeN, xnm) != null)
                {
                    node = doc.SelectNodes(startNodeN, xnm)[0];
                    NC.notice.notificationType = "NC";
                }
                else if (doc.SelectSingleNode(startNodeAE, xnm) != null)
                {
                    node = doc.SelectNodes(startNodeAE, xnm)[0];
                    NC.notice.notificationType = "AE";
                }
                else if (doc.SelectSingleNode(startNodeEP, xnm) != null)
                {
                    node = doc.SelectNodes(startNodeEP, xnm)[0];
                    NC.notice.notificationType = "EP";
                }
                else if (doc.SelectSingleNode(startNodeOA, xnm) != null)
                {
                    node = doc.SelectNodes(startNodeOA, xnm)[0];
                    NC.notice.notificationType = "OA";
                }
                else if (doc.SelectSingleNode(startNodeOK, xnm) != null)
                {
                    node = doc.SelectNodes(startNodeOK, xnm)[0];
                    NC.notice.notificationType = "OK";
                }
                else if (doc.SelectSingleNode(startNodeZK, xnm) != null)
                {
                    node = doc.SelectNodes(startNodeZK, xnm)[0];
                    NC.notice.notificationType = "ZK";
                }
                else
                {
                    continue;
                }

                // разбираем purchaceNoticeData
                NC.notice.notificationNumber = GetNodeText("ns2:registrationNumber");
                NC.notice.orderName          = GetNodeText("ns2:name");
                NC.notice.purchaseMethodCode = GetNodeText("ns2:purchaseMethodCode");
                // для Notice - purchaseCodeName, для остальных - purchaseMethodName
                NC.notice.purchaseMethodName      = GetNodeText(NC.notice.notificationType == "NC" ? "ns2:purchaseCodeName" : "ns2:purchaseMethodName");
                NC.notice.submissionCloseDateTime = GetNodeText("ns2:submissionCloseDateTime");
                try
                {
                    NC.notice.submissionCloseDateTime = NC.notice.submissionCloseDateTime.Replace('T', ' ');
                    NC.notice.submissionCloseDateTime = NC.notice.submissionCloseDateTime.Replace("+04:00", "");
                }
                catch { }
                NC.notice.publishDate = GetNodeText("ns2:publicationDateTime");
                try
                {
                    NC.notice.publishDate = NC.notice.publishDate.Replace('T', ' ');
                    NC.notice.publishDate = NC.notice.publishDate.Replace("+04:00", "");
                }
                catch { }
                NC.notice.status = GetNodeText("ns2:status");
                NC.notice.modificationDescription = GetNodeText("ns2:modificationDescription");
                NC.notice.modificationDate        = GetNodeText("ns2:modificationDate");
                try
                {
                    NC.notice.modificationDate = NC.notice.modificationDate.Replace('T', ' ');
                    NC.notice.modificationDate = NC.notice.modificationDate.Replace("+04:00", "");
                }
                catch { }
                NC.notice.ep_name = GetNodeText("ns2:electronicPlaceInfo/typ:name");
                NC.notice.ep_url  = GetNodeText("ns2:electronicPlaceInfo/typ:url");
                NC.notice.orgName = GetNodeText("ns2:customer/typ:mainInfo/typ:shortName");
                NC.notice.orgOGRN = GetNodeText("ns2:customer/typ:mainInfo/typ:ogrn");
                NC.notice.orgINN  = GetNodeText("ns2:customer/typ:mainInfo/typ:inn");
                // разбираем документы
                foreach (XmlNode oneDoc in node.SelectNodes("ns2:attachements/typ:document", xnm))
                {
                    NC.oneDocument.fileName       = GetNodeText("typ:fileName", oneDoc);
                    NC.oneDocument.docDescription = GetNodeText("typ:description", oneDoc);
                    NC.oneDocument.url            = GetNodeText("typ:url", oneDoc);
                    NC.documents.Add(NC.oneDocument);
                }

                // PurchaseNoticeData/lots
                int lotCount = 0;
                foreach (XmlNode oneLot in node.SelectNodes("ns2:lots/typ:lot/typ:lotData", xnm))
                {
                    NC.oneLot.subject      = GetNodeText("typ:subject", oneLot);
                    NC.oneLot.currencyCode = GetNodeText("typ:currency/typ:code", oneLot);
                    NC.oneLot.currencyName = GetNodeText("typ:currency/typ:name", oneLot);
                    NC.oneLot.maxPrice     = GetNodeText("typ:initialSum", oneLot);
                    NC.lots.Add(NC.oneLot);
                    foreach (XmlNode oneLotItem in oneLot.SelectNodes("typ:lotItems/typ:lotItem", xnm))
                    {
                        NC.oneProduct.code  = GetNodeText("typ:okpd2/typ:code", oneLotItem);
                        NC.oneProduct.name  = GetNodeText("typ:okpd2/typ:name", oneLotItem);
                        NC.oneProduct.lotID = lotCount;
                        NC.products.Add(NC.oneProduct);
                    }
                    lotCount++;
                }
                Nlist.Add(NC);
                File.Delete(oneXML);
            }
        }