Пример #1
0
        public void ParseFile(WebClient iesoClient, string repPath, string repDate)
        {
            var hhResource = new HhResource();
            int? repPreVer;
            int repVer;
            XDocument xdoc;

            _context = new ShadowDataContext();

            repPreVer = (from pd in _context.HhShadowMains
                         where pd.CreatedFor == DateTime.ParseExact(repDate, "yyyyMMdd", CultureInfo.InvariantCulture)
                         select (int?)pd.ReportVersion).Max();

            repVer = (int)(repPreVer == null ? 1 : ++repPreVer);

            if (repVer > 32) return;

            try
            {
                xdoc = XDocument.Load(new StringReader(iesoClient.DownloadString(repPath + repDate + "_v" + repVer + ".xml")));
                _hhSdMain = new HhShadowMain
                {
                    TagType = "Energy",
                    CreatedAt =
                        DateTime.ParseExact(xdoc.Root.Element(_sdNs + "DocHeader").Element(_sdNs + "CreatedAt").Value,
                            "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture),
                    CreatedFor =
                        DateTime.ParseExact(xdoc.Root.Element(_sdNs + "DocBody").Element(_sdNs + "DeliveryDate").Value,
                            "yyyy-MM-dd", CultureInfo.InvariantCulture),
                    ReportVersion = repVer
                };

                foreach (var ele in (from sdNode in xdoc.Root.Element(_sdNs + "DocBody").Descendants(_sdNs + "NodePrices")
                                     where sdNode.Element(_sdNs + "NodeName").Value.Contains("HALTONHILLS-LT")
                                     select sdNode))
                {
                    ParseNodePrices(ele);
                }

                _context.HhShadowMains.InsertOnSubmit(_hhSdMain);
                _context.SubmitChanges();

            }
            catch (WebException ex)
            {

                Console.WriteLine(ex.Message);
            }
        }
Пример #2
0
 partial void UpdateHhResource(HhResource instance);
Пример #3
0
 partial void DeleteHhResource(HhResource instance);
Пример #4
0
 partial void InsertHhResource(HhResource instance);