Ejemplo n.º 1
0
        public void proceedUndoneData(DbInserter dbi)
        {
            IEnumerable <String> undoneFiles = this.getUndoneFiles();
            int c = undoneFiles.Count();

            if (c == 0)
            {
                Trace.TraceInformation("Nothing to process");
                return;
            }
            else
            {
                Trace.TraceInformation("Have to process " + c + " new file(s)");
            }
            foreach (String filePath in undoneFiles)
            {
                //parsing file
                Hashtable info = this.parseOneFile(filePath);
                if (info == null)
                {
                    Trace.TraceInformation("The file '" + filePath + "' was broken, skipping it");
                    continue;
                }
                //inserting info to database
                try
                {
                    dbi.insertPrevedData(info);
                } catch (System.Data.Common.DbException e) {
                    Trace.TraceError("Database quering exception '" + e.GetType() + "' for file '" + filePath + "' thrown, trace:\r\n" + e.StackTrace + "\r\n skipping file");
                    continue;
                }
                //setting file as done
                this.makeFileDone(filePath);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            //Console.OutputEncoding = Encoding.GetEncoding(1251);

            //setting up log folder
            String appPath = AppDomain.CurrentDomain.BaseDirectory;
            foreach (TraceListener t in Trace.Listeners) {
                if (t is Essential.Diagnostics.RollingFileTraceListener) {
                    Essential.Diagnostics.RollingFileTraceListener e_t = (Essential.Diagnostics.RollingFileTraceListener)t;
                    String targetDirName = Path.GetDirectoryName(e_t.FilePathTemplate);
                    if (!Directory.Exists(targetDirName)) {
                        Directory.CreateDirectory(targetDirName);
                    }
                }
            }

            Trace.TraceInformation("Starting...");

            try
            {
                NameValueCollection prevedSection = (NameValueCollection)ConfigurationManager.GetSection("preved");
                NameValueCollection whsdSection = (NameValueCollection)ConfigurationManager.GetSection("whsd");
                //
                DataCollector dc = new DataCollector(prevedSection);
                DbInserter dbi = new DbInserter(whsdSection);
                dc.proceedUndoneData(dbi);
                dbi.disconnect();
                Trace.TraceInformation("...Task finished");
            } catch (Exception e) {
                Trace.TraceError("Critical error happened, exception '" + e.GetType() + "' thrown, trace: \r\n" + e.StackTrace);
            }
        }
Ejemplo n.º 3
0
 public void proceedUndoneData(DbInserter dbi)
 {
     IEnumerable<String> undoneFiles = this.getUndoneFiles();
     int c = undoneFiles.Count();
     if (c == 0) {
         Trace.TraceInformation("Nothing to process");
         return;
     } else {
         Trace.TraceInformation("Have to process " + c + " new file(s)");
     }
     foreach (String filePath in undoneFiles) {
         //parsing file
         Hashtable info = this.parseOneFile(filePath);
         if (info == null) {
             Trace.TraceInformation("The file '" + filePath + "' was broken, skipping it");
             continue;
         }
         //inserting info to database
         try
         {
             dbi.insertPrevedData(info);
         } catch (System.Data.Common.DbException e) {
             Trace.TraceError("Database quering exception '" + e.GetType() + "' for file '" + filePath + "' thrown, trace:\r\n" + e.StackTrace + "\r\n skipping file");
             continue;
         }
         //setting file as done
         this.makeFileDone(filePath);
     }
 }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            //Console.OutputEncoding = Encoding.GetEncoding(1251);

            //setting up log folder
            String appPath = AppDomain.CurrentDomain.BaseDirectory;

            foreach (TraceListener t in Trace.Listeners)
            {
                if (t is Essential.Diagnostics.RollingFileTraceListener)
                {
                    Essential.Diagnostics.RollingFileTraceListener e_t = (Essential.Diagnostics.RollingFileTraceListener)t;
                    String targetDirName = Path.GetDirectoryName(e_t.FilePathTemplate);
                    if (!Directory.Exists(targetDirName))
                    {
                        Directory.CreateDirectory(targetDirName);
                    }
                }
            }

            Trace.TraceInformation("Starting...");

            try
            {
                NameValueCollection prevedSection = (NameValueCollection)ConfigurationManager.GetSection("preved");
                NameValueCollection whsdSection   = (NameValueCollection)ConfigurationManager.GetSection("whsd");
                //
                DataCollector dc  = new DataCollector(prevedSection);
                DbInserter    dbi = new DbInserter(whsdSection);
                dc.proceedUndoneData(dbi);
                dbi.disconnect();
                Trace.TraceInformation("...Task finished");
            } catch (Exception e) {
                Trace.TraceError("Critical error happened, exception '" + e.GetType() + "' thrown, trace: \r\n" + e.StackTrace);
            }
        }