/// <summary> /// Main entry method /// </summary> public static int Main() { var commandLineParser = new clsParseCommandLine(); mLogLevel = BaseLogger.LogLevels.INFO; mMTSServer = string.Empty; mLogDBConnectionString = clsMyEMSLMTSFileCacher.LOG_DB_CONNECTION_STRING; mMinimumCacheFreeSpaceGB = clsMyEMSLMTSFileCacher.DEFAULT_MINIMUM_CACHE_FREE_SPACE_GB; mLocalServerMode = false; mPreviewMode = false; mTraceMode = false; try { var success = false; if (commandLineParser.ParseCommandLine()) { if (SetOptionsUsingCommandLineParameters(commandLineParser)) { success = true; } } if (!success || commandLineParser.NeedToShowHelp || commandLineParser.ParameterCount + commandLineParser.NonSwitchParameterCount == 0 || mMTSServer.Length == 0 && !mLocalServerMode) { ShowProgramHelp(); return(-1); } if (mLocalServerMode) { mMTSServer = string.Empty; } else { var updatesArePending = WindowsUpdateStatus.UpdatesArePending(out var pendingWindowsUpdateMessage); if (updatesArePending) { Console.WriteLine(pendingWindowsUpdateMessage); Console.WriteLine("Will not contact the MTS server to process cache requests"); return(0); } } var downloader = new clsMyEMSLMTSFileCacher(mMTSServer, mLogLevel, mLogDBConnectionString) { MinimumCacheFreeSpaceGB = mMinimumCacheFreeSpaceGB, TraceMode = mTraceMode }; // Attach the events downloader.DebugEvent += Downloader_DebugEvent; downloader.ErrorEvent += Downloader_ErrorEvent; downloader.StatusEvent += Downloader_StatusEvent; downloader.WarningEvent += Downloader_WarningEvent; downloader.ProgressUpdate += Downloader_ProgressUpdate; mPercentComplete = 0; mLastProgressUpdateTime = DateTime.UtcNow; // Initiate processing, which will contact the MTS Server to see if any files need to be cached success = downloader.Start(mPreviewMode); LogTools.FlushPendingMessages(); if (!success) { ShowErrorMessage("Error processing cache requests for MTS server " + mMTSServer + ": " + downloader.ErrorMessage); return(-3); } } catch (Exception ex) { LogTools.FlushPendingMessages(); Console.WriteLine("Error occurred in Program->Main: " + Environment.NewLine + ex.Message); Console.WriteLine(ex.StackTrace); Thread.Sleep(1500); return(-1); } return(0); }
public static int Main(string[] args) { var objParseCommandLine = new FileProcessor.clsParseCommandLine(); mLogLevel = clsLogTools.LogLevels.INFO; mMTSServer = string.Empty; mLogDBConnectionString = clsMyEMSLMTSFileCacher.LOG_DB_CONNECTION_STRING; mMinimumCacheFreeSpaceGB = clsMyEMSLMTSFileCacher.DEFAULT_MINIMUM_CACHE_FREE_SPACE_GB; mLocalServerMode = false; mPreviewMode = false; try { var success = false; if (objParseCommandLine.ParseCommandLine()) { if (SetOptionsUsingCommandLineParameters(objParseCommandLine)) success = true; } if (!success || objParseCommandLine.NeedToShowHelp || objParseCommandLine.ParameterCount + objParseCommandLine.NonSwitchParameterCount == 0 || mMTSServer.Length == 0 && !mLocalServerMode) { ShowProgramHelp(); return -1; } if (mLocalServerMode) { mMTSServer = string.Empty; } else { string pendingWindowsUpdateMessage; var updatesArePending = clsWindowsUpdateStatus.UpdatesArePending(out pendingWindowsUpdateMessage); if (updatesArePending) { Console.WriteLine(pendingWindowsUpdateMessage); Console.WriteLine("Will not contact the MTS server to process cache requests"); return 0; } } var downloader = new clsMyEMSLMTSFileCacher(mMTSServer, mLogLevel, mLogDBConnectionString) { MinimumCacheFreeSpaceGB = mMinimumCacheFreeSpaceGB }; // Attach the events downloader.ErrorEvent += downloader_ErrorEvent; downloader.MessageEvent += downloader_MessageEvent; // Initiate processing, which will contact the MTS Server to see if any files need to be cached success = downloader.Start(mPreviewMode); if (!success) { ShowErrorMessage("Error processing cache requests for MTS server " + mMTSServer + ": " + downloader.ErrorMessage); return -3; } } catch (Exception ex) { Console.WriteLine("Error occurred in Program->Main: " + Environment.NewLine + ex.Message); Console.WriteLine(ex.StackTrace); Thread.Sleep(1500); return -1; } return 0; }