public void ProcessRequest(HttpContext context) { HttpRequest Request = HttpContext.Current.Request; string type = Request["type"]; AnnualPassManager passManager = new AnnualPassManager(); string output = ""; string date = Request["date"]; DateTime formedDate = CRM.Code.Utils.Text.Text.FormatInputDate(date); switch (type) { case "bydate": { int activeOnDate = passManager.GetMembersOnDate(formedDate); int joinedDate = passManager.GetMembersOnJoinDate(formedDate); output = JsonConvert.SerializeObject(new { ActiveOnDate = activeOnDate, JoinedOnDate = joinedDate }); break; } } context.Response.Write(output); context.Response.End(); }
public void ProcessRequest(HttpContext context) { MainDataContext db = new MainDataContext(); var dueReminders = (from p in db.CRM_AnnualPasses where !p.IsArchived where !p.IsPending where p.ExpiryDate.Date >= new DateTime(2014, 08, 01) where p.ExpiryDate.Date < UKTime.Now where p.PaymentMethod == (byte)CRM.Code.Helpers.PaymentType.Types.Cash || p.PaymentMethod == (byte)CRM.Code.Helpers.PaymentType.Types.CreditCard select p); HttpContext.Current.Response.Write("Sending " + dueReminders.Count()); foreach (CRM_AnnualPass pass in dueReminders) { try { EmailManager manager = new EmailManager(); AnnualPassManager passManager = new AnnualPassManager(); CRM_Person person = passManager.GetPrimaryContact(pass); if (person != null && !String.IsNullOrEmpty(person.PrimaryEmail)) { if (person.PrimaryEmail != "*****@*****.**" && person.PrimaryEmail != "*****@*****.**") { manager.SendRenewalEmail(pass, db, person.PrimaryEmail); } HttpContext.Current.Response.Write("Sent"); } } catch { EmailManager manager = new EmailManager(); manager.AddTo(Constants.DeveloperEmail); manager.SendNonTemplate("Failed pass reminder on jupiter CRM - ID " + pass.ID.ToString(), "Failed Jupiter CRM reminder"); } } }