Пример #1
0
        public async Task ExecuteAsync()
        {
            try
            {
                var smtpUser = Environment.GetEnvironmentVariable("SmtpUser");
                var username = Environment.GetEnvironmentVariable("TheraNestUsername");

                var smtpPass = await DecodeEnvVarAsync("SmtpPass");

                var password = await DecodeEnvVarAsync("TheraNestPassword");

                var toEmail = Environment.GetEnvironmentVariable("ToEmail");
                var ccEmail = Environment.GetEnvironmentVariable("CcEmail");

                Log($"SmtpUser: {smtpUser}");
                Log($"TheraNest User: {username}");
                Log($"To Email: {toEmail}");
                Log($"Cc Email: {ccEmail}");

                var se = new ScheduleExecute();
                await se.ExecuteAsync(smtpUser, smtpPass, smtpUser, toEmail, ccEmail, username, password);
            }
            catch (Exception ex)
            {
                Log($"An error occurred {ex.Message}: {ex.StackTrace}");
                throw;
            }
        }
Пример #2
0
        public static void Main(string[] args)
        {
            var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());

            XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));

            try
            {
                if (args.Length < 5)
                {
                    throw new Exception("Usage ... smtpuser smtppass to user password cc");
                }

                var smtpuser = args[0];
                var smtppass = args[1];
                var toemail  = args[2];
                var username = args[3];
                var password = args[4];
                var cc       = string.Join(", ", args.Skip(5));

                Task.Run(async() =>
                {
                    var se = new ScheduleExecute();
                    await se.ExecuteAsync(smtpuser, smtppass, smtpuser, toemail, cc, username, password);
                }).Wait();
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }

            Console.WriteLine("Press any key to continue...");
            Console.ReadLine();
        }