Esempio n. 1
0
 private void onIntervalExpired(object sender, EventArgs e)
 {
     //Event handler for self timed operation
     try {
         if (this.mStartup)
         {
             //Set startup condition- create utility service
             this.mStartup        = false;
             this.mTimer.Interval = getTimerInterval();
             initServices();
         }
         if (!this.mShutdown)
         {
             //Run the service
             this.mIcon.Text = "File Utility running...";
             for (int i = 0; i < this.mSvcs.Length; i++)
             {
                 FileSvc oSvc = this.mSvcs[i];
                 oSvc.Execute();
             }
         }
         else
         {
             //Shutdown condition
             this.mTimer.Enabled = false;
             this.Close();
         }
     }
     catch (Exception ex) { FileLog.LogMessage("TIMER ERROR\t" + ex.Message); }
     finally { setServices(); }
 }
Esempio n. 2
0
        private void OnFormLoad(object sender, System.EventArgs e)
        {
            //Event handler for form load
            try {
                //Hide
                this.Visible = false;

                //Timed or one shot
                if (this.mUseTimer)
                {
                    //Log application as started; start the scheduler
                    FileLog.LogMessage("UTILTIY STARTED (TIMER=" + getTimerInterval().ToString() + "msec)");
                    this.mStartup        = true;
                    this.mTimer.Interval = 100;
                    this.mTimer.Enabled  = true;
                }
                else
                {
                    //Log application as started; create service instances; run one shot and shutdown
                    FileLog.LogMessage("UTILTIY STARTED (TIMER=OFF)");
                    initServices();
                    for (int i = 0; i < this.mSvcs.Length; i++)
                    {
                        FileSvc oSvc = this.mSvcs[i];
                        oSvc.Execute();
                    }
                    this.Close();
                }
            }
            catch (Exception ex) { FileLog.LogMessage("STARTUP ERROR\t" + ex.Message); }
        }
Esempio n. 3
0
 private void initServices()
 {
     //Create service instances based upon the configuration file
     try {
         //Read configuration from app.config
         IDictionary oDict = (IDictionary)ConfigurationManager.GetSection("dirs");
         int         dirs  = Convert.ToInt32(oDict["count"]);
         this.mSvcs = new FileSvc[dirs];
         for (int i = 1; i <= dirs; i++)
         {
             oDict = (IDictionary)ConfigurationManager.GetSection("dir" + i.ToString());
             string src     = oDict["src"].ToString();
             string pattern = oDict["pattern"].ToString();
             string dest    = oDict["dest"].ToString();
             bool   move    = Convert.ToBoolean(oDict["move"]);
             //Debug.Write("src=" + src + "pattern=" + pattern + "; dest=" + dest + "; move=" + move + "\n");
             FileSvc oSvc = new FileSvc(src, pattern, dest, move);
             this.mSvcs[i - 1] = oSvc;
         }
     }
     catch (Exception ex) { reportError(ex, false, true); }
 }