/* * create /path/ [/date/] * answer /path/ * export /path/ /fileout/ /format/ */ private static int Main(string[] args) { try { var parser = new Parser(settings => { settings.CaseInsensitiveEnumValues = true; settings.CaseSensitive = false; settings.HelpWriter = Console.Out; settings.MaximumDisplayWidth = Console.BufferWidth; }); var retCode = parser.ParseArguments <AnswerOptions, CreateOptions, ExportOptions>(args) .MapResult <AnswerOptions, CreateOptions, ExportOptions, int>( DoAnswer, DoCreate, DoExport, error => 1); // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (Debugger.IsAttached && Debug) { Console.WriteLine("Press any key..."); Console.ReadKey(); } return(retCode); } catch (DirectoryNotFoundException e) { LoggingUtil.Log(EventLogEntryType.Error, EventLogIds.DirectoryNotFound.Id(), e.Message); return(2); } }
private static int DoAnswer(AnswerOptions answer) { switch (answer.Execute()) { case AnswerOptions.CallAnswer.NoCallToAnswerFound: LoggingUtil.Log(EventLogEntryType.Warning, EventLogIds.NoCallAtAll.Id(), "No call found."); return(0); case AnswerOptions.CallAnswer.LastCallAlreadyAnswered: LoggingUtil.Log(EventLogEntryType.Information, EventLogIds.CallAlreadyAnswered.Id(), "No new call to answer."); return(0); case AnswerOptions.CallAnswer.CallAnswered: LoggingUtil.Log(EventLogEntryType.Information, EventLogIds.CallAnswered.Id(), "New call answered."); return(0); default: throw new ArgumentOutOfRangeException(); } }
private static int DoCreate(CreateOptions create) { switch (create.Execute()) { case CreateResult.AlreadyExists: LoggingUtil.Log( EventLogEntryType.Error, EventLogIds.CallAlreadyExists.Id(), create.ScheduledDate == null ? "A call already exists for today." : $"A call already exists for that date ({create.UsedDate?.ToString(CallFolderManager.Format) ?? "Undefined date"})."); return(3); case CreateResult.Ok: LoggingUtil.Log(EventLogEntryType.Information, EventLogIds.CallCreated.Id(), "Call created."); return(0); default: throw new ArgumentOutOfRangeException(); } }
private static int DoExport(ExportOptions export) { export.Execute(); LoggingUtil.Log(EventLogEntryType.Information, EventLogIds.DoNotEventLog.Id(), "Done."); return(0); }