public void Start() { SystemLogger logger = new SystemLogger(); Console.WriteLine("Fetching Booking Carts.."); WebClient wc = new WebClient(); string url = ConfigurationManager.AppSettings.Get(URL_BOOKINGCART); try { string result = wc.DownloadString(url); System.Net.Mail.MailMessage mailMsg = new System.Net.Mail.MailMessage(); mailMsg.From = new System.Net.Mail.MailAddress(ConfigurationManager.AppSettings.Get("EmailId"), "Staybazar"); mailMsg.IsBodyHtml = true; // mailMsg.Subject = ConfigurationManager.AppSettings.Get(MAIL_SUBJECT); mailMsg.Subject = "Notice: Booking Carts Report"; try { result = Mailer.MessageFromHtml(url); } catch (Exception ex) { logger.LogError(ex.Message); } if (result != "") { mailMsg.Body = result; mailMsg.To.Add(new System.Net.Mail.MailAddress(ConfigurationManager.AppSettings.Get(CUSTOMERCARE), "Staybazar")); string emailids = ConfigurationManager.AppSettings.Get(BOOKINGCARTCC); if (emailids != "") { string[] emails = emailids.Split(','); foreach (string ToEMailId in emails) { mailMsg.CC.Add(new System.Net.Mail.MailAddress(ToEMailId)); } } Mailer mail = new Mailer(); //#if !DEBUG mail.SendMail(mailMsg); //throw new Exception("testing"); //#endif } } catch (Exception ex) { logger.LogError(ex.Message); } }
public void Start() { SystemLogger logger = new SystemLogger(); Console.WriteLine("Fetching PartialPayment.."); WebClient wc = new WebClient(); string url = ConfigurationManager.AppSettings.Get(URL_PARTIALPAYMENTCANCEL_LIST); string urlbody = ConfigurationManager.AppSettings.Get(URL_PARTIALPAYMENTCANCEL); string mailccs = ConfigurationManager.AppSettings.Get(MAIL_CC); string ids = ""; string[] strids; string[] payData; string Bookid, Useremail; Common.Mailer PartialPaymentMailer = new Mailer(); System.Net.Mail.MailMessage mailMsg = new System.Net.Mail.MailMessage(); mailMsg.From = new System.Net.Mail.MailAddress(ConfigurationManager.AppSettings.Get("EmailId"), "Staybazar"); mailMsg.IsBodyHtml = true; mailMsg.Subject = "Booking Cancellation"; if (mailccs != null && mailccs != "") { mailccs = mailccs.Trim(); if (mailccs != "") { strids = mailccs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in strids) { if (s != null && s != "") { mailMsg.Bcc.Add(s); } } } } //mailMsg.CC.Add(mailccs); Console.WriteLine("Sending Mails.."); ids = wc.DownloadString(url); if (ids == null) { return; } if (ids.Trim() == "") { return; } strids = ids.Split(','); foreach (string paydt in strids) { payData = paydt.Split('#'); if (payData.Length != 2) { continue; } Useremail = payData[1].Trim(); Bookid = payData[0].Trim(); string result = wc.DownloadString(urlbody + Bookid); mailMsg.Body = result; if (mailMsg.Body != "") { mailMsg.To.Clear(); mailMsg.To.Add(Useremail); try { PartialPaymentMailer.SendMail(mailMsg); } catch (Exception ex) { logger.LogError(ex.Message); } } } }
public void Start() { SystemLogger logger = new SystemLogger(); Console.WriteLine("Fetching suppliers.."); WebClient wc = new WebClient(); string url = ConfigurationManager.AppSettings.Get(URL_SUPPLIER_COUNT); // url += "from=" + (DateTime.Today.AddDays(-1)).ToString("dd/MM/yyyy"); string result = wc.DownloadString(url); int cnt = 0; int.TryParse(result, out cnt); Console.WriteLine(cnt + " suppliers found."); if (cnt == 0) { return; } url = ConfigurationManager.AppSettings.Get(URL_SUPPLIER_LIST); url += "limit=" + RECORDS_LIMIT.ToString() + "&start="; string customercare = ConfigurationManager.AppSettings.Get(SB_MAIL); int cpage = 0; string ids = ""; long sid; string[] strids; string supEmailUrl = ConfigurationManager.AppSettings.Get(URL_SUPPLIERMAIL); supEmailUrl += "supplierId="; //&SupplierId=310&FromDate=16/11/2014& string propEmailUrl = ConfigurationManager.AppSettings.Get(URL_SUPPROP_EMAILIDS); string[] supData; string[] propData; string[] propIds; string pid, pemail; bool foundEmptyPropertyEmail = false; Common.Mailer supplierMailer = new Mailer(); System.Net.Mail.MailMessage mailMsg = new System.Net.Mail.MailMessage(); mailMsg.From = new System.Net.Mail.MailAddress(ConfigurationManager.AppSettings.Get("EmailId"), "Staybazar"); mailMsg.IsBodyHtml = true; mailMsg.Subject = ConfigurationManager.AppSettings.Get(MAIL_SUBJECT); //string toMail = ""; string supMail = ""; Console.WriteLine("Sending Mails.."); while (cnt > 0) { ids = wc.DownloadString(url + (cpage * RECORDS_LIMIT).ToString()); if (ids == null) { return; } if (ids.Trim() == "") { return; } strids = ids.Split(','); foreach (string id in strids) { try { supData = id.Split('#'); if (supData.Length != 2) { continue; } sid = 0; long.TryParse(supData[0], out sid); //request html body foundEmptyPropertyEmail = false; //send mail if (sid > 0) { supMail = supData[1].Trim(); #if DEBUG // toMail = "*****@*****.**"; #endif ids = wc.DownloadString(propEmailUrl + supData[0].Trim()); propIds = ids.Split(','); foreach (string propId in propIds) { propData = propId.Split('#'); if (propData.Length != 2) { continue; } pemail = propData[0].Trim(); pid = propData[1].Trim(); if (pemail == "none") { foundEmptyPropertyEmail = true; continue; } mailMsg.Body = Common.Mailer.MessageFromHtml(supEmailUrl + sid.ToString() + "&propertyId=" + pid); //send seperate mail to property mail Id , cc to supplier email id if (mailMsg.Body != "") { mailMsg.To.Clear(); mailMsg.To.Add(pemail); mailMsg.CC.Clear(); mailMsg.CC.Add(supMail); mailMsg.CC.Add(customercare); try { supplierMailer.SendMail(mailMsg); } catch (Exception ex) { logger.LogError(ex.Message); } } } if (foundEmptyPropertyEmail) { mailMsg.Body = Common.Mailer.MessageFromHtml(supEmailUrl + sid.ToString() + "&propertyId=0"); if (mailMsg.Body != "") { mailMsg.To.Clear(); mailMsg.To.Add(supMail); mailMsg.CC.Clear(); mailMsg.CC.Add(customercare); try { supplierMailer.SendMail(mailMsg); } catch (Exception ex) { logger.LogError(ex.Message); } } } } } catch (Exception ex) { logger.LogError(ex.Message); } } //increments cnt = cnt - RECORDS_LIMIT; if (cnt < 0) { cnt = 0; } cpage++; } }
public void Start() { SystemLogger logger = new SystemLogger(); Console.WriteLine("Fetching Feedback.."); WebClient wc = new WebClient(); string url = ConfigurationManager.AppSettings.Get(URL_REVIEWSENDBOOKINGLIST); string urlbody = ConfigurationManager.AppSettings.Get(URL_REVIEWSENDLINK); string ids = ""; string[] strids; string[] RevData; string Bookid, Useremail, BookingUseremail; Common.Mailer FeedbackMailer = new Mailer(); System.Net.Mail.MailMessage mailMsg = new System.Net.Mail.MailMessage(); mailMsg.From = new System.Net.Mail.MailAddress(ConfigurationManager.AppSettings.Get("EmailId"), "Staybazar"); mailMsg.IsBodyHtml = true; mailMsg.Subject = "Feedback Form - Staybazar "; Console.WriteLine("Sending Mails.."); ids = wc.DownloadString(url); if (ids == null) { return; } if (ids.Trim() == "") { return; } strids = ids.Split(','); foreach (string revdt in strids) { RevData = revdt.Split('#'); if (RevData.Length != 3) { continue; } Bookid = RevData[0].Trim(); Useremail = RevData[1].Trim(); BookingUseremail = RevData[2].Trim(); string result = wc.DownloadString(urlbody + Bookid); mailMsg.Body = result; if (mailMsg.Body != "") { mailMsg.To.Clear(); if (BookingUseremail != null && BookingUseremail != "") { if (BookingUseremail != Useremail) { mailMsg.To.Add(BookingUseremail); mailMsg.Bcc.Add(Useremail); } else { mailMsg.To.Add(Useremail); } } else { mailMsg.To.Add(Useremail); } try { FeedbackMailer.SendMail(mailMsg); } catch (Exception ex) { logger.LogError(ex.Message); } } } }
static void Main(string[] args) { Common.SystemLogger logger = new Common.SystemLogger(); try { int i = 0; //#if !DEBUG if (args.Count() == 0 || args.Count() > 1) { HelpOut(); return; } int.TryParse(args[0], out i); //#endif #if DEBUG //i = 3; // throw new Exception("testing"); #endif switch (i) { case 1: Common.SupplierMail sm = new Common.SupplierMail(); sm.Start(); break; case 2: Common.FailedTransactionMail failed = new Common.FailedTransactionMail(); failed.Start(); break; case 3: Common.BookingCartMail Bookingcart = new Common.BookingCartMail(); Bookingcart.Start(); break; case 4: Common.PartialPaymentListForMail PartialPayment = new Common.PartialPaymentListForMail(); PartialPayment.Start(); break; case 5: Common.PartialPaymentBCancellation PartialPaymentBCancel = new Common.PartialPaymentBCancellation(); PartialPaymentBCancel.Start(); break; case 6: Common.Feedback Feedback = new Common.Feedback(); Feedback.Start(); break; default: HelpOut(); break; } //Common.SupplierMail sm = new Common.SupplierMail(); //sm.Start(); }catch (Exception ex) { logger.LogError(ex.Message); } Console.WriteLine("Finished.."); #if DEBUG // Console.ReadLine(); #endif }