internal static CommandLineCommands GetCommands(string[] commandLine) { CommandLineCommands _ret = new CommandLineCommands(); foreach (string _arg in commandLine) { if (_arg.ToLower().StartsWith("/d")) { _ret.CommandsList[CommandsSet.CreateRecentEmailsList] = new Tuple <CommandsSet, string>(CommandsSet.CreateRecentEmailsList, _arg.Substring(2)); } else if (_arg.ToLower().StartsWith("/l")) { _ret.CommandsList[CommandsSet.AnalyzeLinks] = new Tuple <CommandsSet, string>(CommandsSet.AnalyzeLinks, _arg.Substring(2)); } } return(_ret); }
public static void Main(string[] args) { Task <IEnumerable <DNNDataClassesDataContext.UserEmail> > _listOfEmailsTask = null; string[] _commandLine = Environment.GetCommandLineArgs(); try { CommandLineCommands _commandToDo = CommandLineCommands.GetCommands(_commandLine); DateTime _startDate = DateTime.ParseExact(_commandToDo.CommandsList[CommandLineCommands.CommandsSet.CreateRecentEmailsList].Item2, Settings.Default.DateFormat, CultureInfo.InvariantCulture); _listOfEmailsTask = GetEmailAsync(_startDate); _listOfEmailsTask.Wait(); IEnumerable <string> _listOfEmails = _listOfEmailsTask.Result.Select <DNNDataClassesDataContext.UserEmail, string>(x => x.Email).FilterEmails(new Progress <int>()); string _finalList = String.Join <string>(";", _listOfEmails.ToArray <string>()); Console.WriteLine(); Console.WriteLine("Final list of emails:"); Console.WriteLine(_finalList); Console.WriteLine(); Settings.Default.LastDate = DateTime.Today.ToString(Settings.Default.DateFormat); string _fileName = $"{Settings.Default.LastDate}_adresy_strona_commserver.txt"; File.WriteAllText(_fileName, _finalList); Console.WriteLine($"Final list of emails registered since {_startDate.ToString(Settings.Default.DateFormat)} saved to file {_fileName}"); Settings.Default.Save(); } catch (AggregateException _ex) { foreach (Exception _item in _ex.InnerExceptions) { Console.WriteLine(_listOfEmailsTask.Exception.ToString()); } } catch (Exception _ge) { Console.WriteLine(_ge.ToString()); } Console.Write("Press enter to close the window:"); Console.ReadLine(); }