////////////////////////////////////////////////////////
        ///
        ///  Here is the actual workhorse
        ///
        ///
        public static void ScanForForeCastData()
        {
            try
            {
                while (true)
                {
                    ////////////////////////////////
                    ///
                    ///  Clean up all the data
                    ///
                    CSyntaxErrorLog.Cleanup();
                    CSemanticErrorLog.Cleanup();
                    GlobalSettings.Cleanup();
                    ///////////////////
                    ///
                    ///  Do Processing
                    ///

                    ScanAndProcess();
                    /////////////////////////////////////////
                    ///
                    ///  Sleep the Thread for 2 minutes.
                    ///  in the production build , it should run
                    ///  in an interval of at least 10 minutes
                    ///
                    ///
                    System.GC.Collect();
                    System.Threading.Thread.Sleep(60000 * 5);
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.EventLog.WriteEntry("ForeCastLog", "Exception thrown by the Thread");
                System.Diagnostics.EventLog.WriteEntry("ForeCastLog", e.ToString());
            }

            return;
        }
        /// <summary>
        ///    Update Routine
        ///    Loop as long as a valid file is found
        /// </summary>
        public bool Update()
        {
            bool bVal = true;

            while (true)
            {
                CDirectoryWalker x = new CDirectoryWalker();
                x.Visit(m_rootPath, "*.XLS", true);
                ArrayList r = x.GetAllXls();

                ///////////////////////////////
                ///  if no more file is found ...
                ///  stop this iteration
                ///
                if (r.Count == 0)
                {
                    break;
                }

                foreach (ForeCastFileInfo s in r)
                {
                    ////////////////////////////////////////////////////
                    ///
                    ///  Stop processing , if thread has been requested to stop processing
                    ///
                    ///
                    if (GlobalSettings.request_processing_thread_abort == true)
                    {
                        return(bVal);
                    }
                    ///////////////////////////////
                    /// Clean up the Error Logs before
                    /// we go for fresh processing
                    ///	CSemanticErrorLog.Cleanup();
                    CSyntaxErrorLog.Cleanup();
                    CSemanticErrorLog.Cleanup();

                    ////////////////////////////////////////
                    ///
                    ///  Try to Validate the file
                    ///
                    GlobalSettings.oracle_connection_count = 0;
                    GlobalSettings.excel_connection_count  = 0;
                    if (ValidateFile(s))
                    {
                        System.GC.Collect();

                        ///////////////////////////////////////////////
                        ///
                        ///  Validation and updation is successful
                        ///  Check for the backup_sheets flag and
                        ///  Back up the File , if it is true
                        ///

                        if (GlobalSettings.oracle_connection_count != 0)
                        {
                            System.Diagnostics.EventLog.WriteEntry("ForeCastLog", "Oracle Connection" + Convert.ToString(GlobalSettings.oracle_connection_count));
                        }


                        if (GlobalSettings.excel_connection_count != 0)
                        {
                            System.Diagnostics.EventLog.WriteEntry("ForeCastLog", "Oracle Connection" + Convert.ToString(GlobalSettings.excel_connection_count));
                        }


                        if (GlobalSettings.backup_sheets == true)
                        {
                            BackupFile(s);
                        }
                    }
                    else
                    {
                        ///////////////////////////////////
                        /// At least one stuff failed in this iteration
                        /// left unused
                        ///
                        if (bVal)
                        {
                            bVal = false;
                        }

                        ///////////////////////////////////////////////////
                        ///
                        ///  Failure in updating ForeCast Data
                        ///  Try to Quarantine the file , if
                        ///  quarantine_sheets flag is true
                        ///

                        if (GlobalSettings.oracle_connection_count > 0)
                        {
                            System.Diagnostics.EventLog.WriteEntry("ForeCastLog", "Oracle Connection" + Convert.ToString(GlobalSettings.oracle_connection_count));
                        }


                        if (GlobalSettings.excel_connection_count > 0)
                        {
                            System.Diagnostics.EventLog.WriteEntry("ForeCastLog", "Oracle Connection" + Convert.ToString(GlobalSettings.excel_connection_count));
                        }
                        if (GlobalSettings.quarantine_sheets == true)
                        {
                            MoveToQuarantine(s);
                        }
                    }
                }

                break;
            }

            return(bVal);
        }