public void CancelOverdueServices() { // load store settings StoreSettings settings = StorehouseController.GetStoreSettings(SecurityContext.User.UserId, StoreSettings.SYSTEM_SETTINGS); // int threshold = Convert.ToInt32(settings["SvcCancelThreshold"]); // TimeSpan ts = new TimeSpan(threshold, 0, 0, 0); // calculate actual suspend date DateTime dueDate = DateTime.Now.Subtract(ts); // lookup for overdue invoices List <InvoiceItem> items = InvoiceController.GetInvoicesItemsOverdue(SecurityContext.User.UserId, dueDate); // TRACE TaskManager.Write("Cancel overdue services"); TaskManager.WriteParameter("Items found", items.Count); // foreach (InvoiceItem item in items) { try { TaskManager.Write("Cancelling service"); // cancelling GenericSvcResult result = CancelService(item.ServiceId, true); // LOG ERROR if (!result.Succeed) { TaskManager.WriteError(result.Error); if (!String.IsNullOrEmpty(result.ErrorCode)) { TaskManager.WriteParameter("Error code", result.ErrorCode); } TaskManager.WriteParameter("Result code", result.ResultCode); // go to next item continue; } // TaskManager.Write("Cancelled"); } catch (Exception ex) { TaskManager.WriteError(ex); } } }
public void SuspendOverdueServices() { // lookup for today's overdue invoices List <InvoiceItem> items = InvoiceController.GetInvoicesItemsOverdue(SecurityContext.User.UserId, DateTime.Now); // TRACE TaskManager.Write("Suspend overdue services"); TaskManager.WriteParameter("Items found", items.Count); // foreach (InvoiceItem item in items) { try { TaskManager.Write("Suspending service"); // suspending GenericSvcResult result = SuspendService(item.ServiceId, true); // LOG ERROR if (!result.Succeed) { TaskManager.WriteError(result.Error); if (!String.IsNullOrEmpty(result.ErrorCode)) { TaskManager.WriteParameter("Error code", result.ErrorCode); } TaskManager.WriteParameter("Result code", result.ResultCode); // go to next item continue; } // TaskManager.Write("Suspended"); } catch (Exception ex) { TaskManager.WriteError(ex); } } }