コード例 #1
0
ファイル: WORawData.cs プロジェクト: ChaoLiou/others
 private void SingleZipProcess(string sourcePath)
 {
     try
     {
         using (var zipFile = ZipFile.Read(sourcePath))
         {
             foreach (var entry in zipFile.Where(x => x.FileName.ToUpper().EndsWith(".XML")))
             {
                 try
                 {
                     _log.Trace($"{entry.FileName}");
                     Console.SetCursorPosition(0, Console.CursorTop - 1);
                     using (var sr = new StreamReader(entry.OpenReader()))
                     {
                         var el            = XElement.Parse(sr.ReadToEnd());
                         var newWOFullText = new NewWO(_woDataSource);
                         if (newWOFullText.Parse(el))
                         {
                             insert(newWOFullText, sourcePath, entry.FileName);
                         }
                     }
                 }
                 catch (Exception e)
                 {
                     _log.Error(sourcePath);
                     _log.Error(entry.FileName);
                     _log.Error(e.Message);
                 }
             }
         }
     }
     catch (Exception e)
     {
         _log.Error(sourcePath);
         _log.Error(e.Message);
     }
 }
コード例 #2
0
ファイル: WORawData.cs プロジェクト: ChaoLiou/others
        private void insert(NewWO newWO, string zipPath, string xmlPath)
        {
            Conn.Query(@"
INSERT INTO RawData.NewWO
(
    [pn],[apn],[pd],[apd],[kindCode],[docRoot],[doc],[vol],[zipPath],[xmlPath]
)
VALUES
(
    @pn, @apn, @pd, @apd, @kindCode, @docRoot, @doc, @vol, @zipPath, @xmlPath
)", new
            {
                pn       = newWO.PN,
                apn      = newWO.APN,
                pd       = newWO.PD,
                apd      = newWO.APD,
                kindCode = newWO.KindCode,
                docRoot  = newWO.El.Name.ToString(),
                doc      = newWO.El.ToString(),
                vol      = NewWO.FormatVol(_woDataSource, zipPath, xmlPath),
                zipPath  = zipPath.Replace(@"\\per7204\WIPOData\", string.Empty),
                xmlPath  = xmlPath
            });
        }
コード例 #3
0
ファイル: WORawData.cs プロジェクト: ChaoLiou/others
        public void SingleTarGzProcess(string sourcePath)
        {
            Conn.Open();
            try
            {
                using (FileStream reader = File.OpenRead(sourcePath))
                {
                    using (GZipStream gzData = new GZipStream(reader, CompressionMode.Decompress, true))
                    {
                        TarInputStream tarIn = new TarInputStream(gzData);
                        TarEntry       tarEntry;
                        while ((tarEntry = tarIn.GetNextEntry()) != null)
                        {
                            try
                            {
                                if (tarEntry.Name.ToUpper().EndsWith(".XML"))
                                {
                                    using (MemoryStream ms = new MemoryStream())
                                    {
                                        tarIn.CopyEntryContents(ms);
                                        ms.Position = 0;
                                        using (var sr = new StreamReader(ms))
                                        {
                                            _log.Trace($"{tarEntry.Name.Substring(0, tarEntry.Name.LastIndexOf("/"))}");
                                            Console.SetCursorPosition(0, Console.CursorTop - 1);
                                            var el    = XElement.Parse(sr.ReadToEnd());
                                            var newWO = new NewWO(_woDataSource);
                                            if (newWO.Parse(el))
                                            {
                                                insert(newWO, sourcePath, tarEntry.Name);
                                                _count++;
                                            }
                                        }
                                    }
                                }
                            }
                            catch (Exception e)
                            {
                                _log.Error(sourcePath);
                                _log.Error(tarEntry.Name);
                                _log.Error(e.Message);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                _log.Error(sourcePath);
                _log.Error(e.Message);
            }

            Conn.Close();

            #region checking counts

            var volFolderPath = sourcePath.Substring(0, sourcePath.LastIndexOf("\\"));
            var expectedCount = NewWO.GetIndexlstCount(_woDataSource, Path.Combine(volFolderPath, ConnectionStringsAndAppSettings.IndexlstName));
            var sign          = expectedCount == _count ? "==" : "<>";
            _log.Debug($"{Path.GetFileName(volFolderPath)}|Expected Count: {expectedCount} {sign} Real Count: {_count}");

            #endregion checking counts
        }