private void OnChanged(object sender, FileSystemEventArgs e)
 {
     FileTypes.LogModel localLog = new FileTypes.LogModel();
     if (File.Exists(e.FullPath))
     {
         SendEmail mail = null;
         eventLog1.WriteEntry("In OnChange - " + e.FullPath);
         // Wait 3 seconds.
         System.Threading.Thread.Sleep(3000);
         eventLog1.WriteEntry("In OnChange - Upload File");
         localLog.WriteLog("SUCCESS", "In OnChange - " + e.FullPath);
         UploadFiles upload = new UploadFiles();
         if (upload.LoadFiles(e.FullPath, eventLog1))
         {
             //eventLog1.WriteEntry("In OnChange - Export File");
             //ExportTables exportfiles = new ExportTables();
             //if (exportfiles.CreateCSVfile(e.Name, eventLog1))
             //    mail = new SendEmail("*****@*****.**", "", "", "HMMS File Processed", " Load /Export File had been processed : " + e.Name, eventLog1);
             //else
             //    mail = new SendEmail("*****@*****.**", "", "", "HMMS File Processed - Falid", "Exporting of the Files has Faild : " + e.Name, eventLog1);
         }
         else
         {
             //mail = new SendEmail("*****@*****.**", "", "", "HMMS File Processed - Falid", "Files have Faild check the HMMSLoad/Error Folder : " + e.Name, eventLog1);
             localLog.WriteLog("ERROR", "In OnChange - " + e.FullPath);
         }
     }
 }
Example #2
0
        protected override void OnStart(string[] args)
        {
            string DirName = System.Configuration.ConfigurationManager.AppSettings["ReadDir"];

            FileTypes.LogModel log = new FileTypes.LogModel();
            log.WriteLog("SUCCESS", "ON-Start");
            // Set up a timer that triggers every minute.
            //System.Timers.Timer timer = new System.Timers.Timer();
            //timer.Interval = 60000; // 60 seconds
            //timer.Elapsed += new ElapsedEventHandler(this.OnTimer);
            //timer.Start();
            eventLog1.WriteEntry("In OnStart.");
            FileProcessor fp = new FileProcessor(DirName);

            fp.Watch();
        }
Example #3
0
 protected override void OnStop()
 {
     FileTypes.LogModel log = new FileTypes.LogModel();
     log.WriteLog("SUCCESS", "ON-Stop");
     eventLog1.WriteEntry("In OnStop.");
 }