/// <summary> /// we need to email users who have currently not filled out their profiles every 30 days and tell them, come back to /// fill it out!! /// </summary> public static int ProcessRollinNewsMassPayments() { try { var dc = new ManagementContext(); int type = Convert.ToInt32(TaskTypeEnum.ProcessRollinNewsMassPayments); var emailTask = dc.AutomatedTasks.Where(x => x.TaskIdForDescription == type).FirstOrDefault(); if (emailTask == null) { TaskForRunning newTask = new TaskForRunning(); newTask.FirstRun = DateTime.UtcNow; newTask.HoursBetweenEachRunOfTask = HOURS_BETWEEN_MASS_ROLLIN_NEWS_PAYMENTS; newTask.LastRun = DateTime.UtcNow; newTask.TaskIdForDescription = type; dc.AutomatedTasks.Add(newTask); dc.SaveChanges(); } else { emailTask.HoursBetweenEachRunOfTask = HOURS_BETWEEN_MASS_ROLLIN_NEWS_PAYMENTS; if (emailTask.LastRun.AddHours(HOURS_BETWEEN_MASS_ROLLIN_NEWS_PAYMENTS) < DateTime.UtcNow) { Payment.PaymentGateway pg = new Payment.PaymentGateway(); pg.StartInvoiceWizard() .Initalize(RollinNewsConfig.MERCHANT_ID, "USD", Payment.Enums.PaymentProvider.Paypal, SiteSingleton.Instance.IsPayPalLive , Payment.Enums.ChargeTypeEnum.RollinNewsWriterPayouts) .FinalizeInvoice(); } } } catch (Exception exception) { Error.ErrorDatabaseManager.AddException(exception, exception.GetType()); } return 0; }