public static void ExecuteRecurring(RecurringBooking RecurringBooking) { using (UnitOfWork unitOfWork = new UnitOfWork(RecurringBooking.Session.DataLayer)) { var myCloner = new DevExpress.Persistent.Base.Cloner(); RecurringBooking recurringBooking = unitOfWork.FindObject <RecurringBooking>(CriteriaOperator.Parse("Oid == ?", RecurringBooking.Oid)); Booking booking = null; if (recurringBooking.WorkFlowStatus == WorkFlowStatus.Enabled && (recurringBooking.NextDate == null || recurringBooking.NextDate <= MyWorkbench.BaseObjects.Constants.Constants.DateTimeTimeZone(unitOfWork))) { booking = new Booking(unitOfWork); recurringBooking.CopyProperties(booking); booking.BookedTime = recurringBooking.NextDate != null ? recurringBooking.NextDate : recurringBooking.Starting; booking.Party = recurringBooking.Party; if (recurringBooking.Items.Count >= 1) { var j = recurringBooking.Items.Count; for (int i = 0; i < j; i++) { booking.Items.Add(myCloner.CloneTo(recurringBooking.Items[i], typeof(WorkflowItem)) as WorkflowItem); } } if (recurringBooking.WorkflowResources.Count >= 1) { var j = recurringBooking.WorkflowResources.Count; for (int i = 0; i < j; i++) { booking.WorkflowResources.Add(myCloner.CloneTo(recurringBooking.WorkflowResources[i], typeof(WorkflowResource)) as WorkflowResource); } } recurringBooking.AdvanceNextDate(); // New Object Tracking (booking as WorkflowBase).ChildItems.Add(recurringBooking); (booking as WorkflowBase).Tracking.Add(CreateTracking(unitOfWork, booking, string.Format("Created from {0}", recurringBooking.No))); //Current Object Tracking recurringBooking.ChildItems.Add(booking as WorkflowBase); recurringBooking.Tracking.Add(CreateTracking(unitOfWork, booking, string.Format("Converted to {0}", (booking as WorkflowBase).GetType().Name))); } unitOfWork.CommitChanges(); } }
private void ProcessRecurringBooking(RecurringBooking RecurringBooking) { try { if (RecurringBooking.WorkFlowStatus == Ignyt.BusinessInterface.WorkFlow.Enum.WorkFlowStatus.Enabled) { MyWorkbench.BusinessObjects.Helpers.RecurringHelper.ExecuteRecurring(RecurringBooking); } } catch (Exception ex) { this.TaskExceptionList.TaskExceptions.Add(ex); } }