Esempio n. 1
0
File: Service.cs Progetto: r00ti/ZTP
        public void Start()
        {
            Log.Information("Start service...");
            string    baseAddress = "http://localhost:9000/";
            BusSender sender      = new BusSender();

            using (WebApp.Start <Startup>(url: baseAddress))
            {
                RecurringJob.AddOrUpdate(() => Tasks.Process(sender), Cron.Minutely);
                Console.WriteLine("Hangfire on");
                Console.ReadKey();
            }
        }
Esempio n. 2
0
        public static async Task Process(BusSender busSender)
        {
            string datafile = ConfigurationManager.AppSettings["DataFile"];
            string address  = ((SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp")).From;

            using (var sr = new StreamReader(datafile))
            {
                var reader = new CsvReader(sr);
                IEnumerable <DataRecord> records = reader.GetRecords <DataRecord>();

                foreach (DataRecord record in records.Take(3))
                {
                    busSender.Sender(record);
                    Log.Information("{0} ,{1}, {2}, {3}", record.CommonName, record.CountryCode, record.FormalName,
                                    record.TelephoneCode);
                }
            }
        }