private PromotionResult PromoteToApproved() { PromotionResult promotionResult = new PromotionResult(); promotionResult.Success = true; if (WidgetStatus != WidgetStatus.Approving) { promotionResult.Success = false; promotionResult.Message = "Failed to promote the widget to Approved status because its current status prevented it."; } if (TestPassDateTime == null) { promotionResult.Success = false; promotionResult.Message = "Failed to promote the widget to Approved status because Test Pass Date was not present."; } if (promotionResult.Success) { WidgetStatus = WidgetStatus.Approved; promotionResult.Message = String.Format("Widget {0} successfuly promoted to status {1}.", WidgetId, WidgetStatus); } return(promotionResult); }
public PromotionResult PromoteWorkListItem(string command) { PromotionResult promotionResult = new PromotionResult(); switch (command) { case "PromoteToIntegrated": promotionResult = PromoteToIntegrated(); break; case "PromoteToApproved": promotionResult = PromoteToApproved(); break; case "DemoteToCanceled": promotionResult = DemoteToCanceled(); break; } Log4NetHelper.Log(promotionResult.Message, LogLevel.INFO, EntityFormalNamePlural, WidgetId, HttpContext.Current.User.Identity.Name, null); if (promotionResult.Success) { CurrentWorker = null; CurrentWorkerId = null; } return(promotionResult); }
private PromotionResult PromoteToIntegrated() { PromotionResult promotionResult = new PromotionResult(); promotionResult.Success = true; if (WidgetStatus != WidgetStatus.Integrating) { promotionResult.Success = false; promotionResult.Message = "Failed to promote the widget to Integrated status because its current status prevented it."; } if (String.IsNullOrWhiteSpace(MainBusCode)) { promotionResult.Success = false; promotionResult.Message = "Failed to promote the widget to Integrated status because Main Bus Code was not present."; } if (promotionResult.Success) { WidgetStatus = WidgetStatus.Integrated; promotionResult.Message = String.Format("Widget {0} successfuly promoted to status {1}.", WidgetId, WidgetStatus); } return(promotionResult); }
public PromotionResult RelinquishWorkListItem() { PromotionResult promotionResult = new PromotionResult { Success = true }; if (CurrentWorkerId == null || Status.Substring(Status.Length - 3, 3) != "ing") { promotionResult.Message = String.Format("Widget {0} can not be relinquished because it is not currently being worked on.", WidgetId); promotionResult.Success = false; } if (promotionResult.Success) { CurrentWorker = null; CurrentWorkerId = null; switch (WidgetStatus) { case WidgetStatus.Integrating: WidgetStatus = WidgetStatus.Created; break; case WidgetStatus.Approving: WidgetStatus = WidgetStatus.Integrated; break; } promotionResult.Message = String.Format("Widget {0} was successfully relinquished and its status was reset to {1}.", WidgetId, WidgetStatus); } Log4NetHelper.Log(promotionResult.Message, LogLevel.INFO, EntityFormalNamePlural, WidgetId, HttpContext.Current.User.Identity.Name, null); return(promotionResult); }
private PromotionResult PromoteToProcessed() { PromotionResult promotionResult = new PromotionResult(); promotionResult.Success = true; if (WorkOrderStatus != WorkOrderStatus.Processing) { promotionResult.Success = false; promotionResult.Message = "Failed to promote the work order to Processed status because its current status prevented it."; } else if (Parts.Count == 0 || Labors.Count == 0) { promotionResult.Success = false; promotionResult.Message = "Failed to promote the work order to Processed status because it did not contain at least one Part and labor."; } else if (String.IsNullOrWhiteSpace(Description)) { promotionResult.Success = false; promotionResult.Message = "Failed to promote the work order to Processed status because it requires Description."; } if (promotionResult.Success) { WorkOrderStatus = WorkOrderStatus.Processed; promotionResult.Message = String.Format("Work order {0} successfuly promoted to status {1}.", WorkOrderId, WorkOrderStatus); } return(promotionResult); }
public PromotionResult ClaimWorkListItem(string userId) { PromotionResult promotionResult = WorkListBusinessRules.CanClaimWorkListItem(userId); if (!promotionResult.Success) { Log4NetHelper.Log(promotionResult.Message, LogLevel.WARN, EntityFormalNamePlural, WidgetId, HttpContext.Current.User.Identity.Name, null); return(promotionResult); } switch (WidgetStatus) { case WidgetStatus.Created: promotionResult = PromoteToIntegrating(); break; case WidgetStatus.Integrated: promotionResult = PromoteToApproving(); break; } if (promotionResult.Success) { CurrentWorkerId = userId; } Log4NetHelper.Log(promotionResult.Message, LogLevel.INFO, EntityFormalNamePlural, WidgetId, HttpContext.Current.User.Identity.Name, null); return(promotionResult); }
private PromotionResult DemoteToCreated() { PromotionResult promotionResult = new PromotionResult(); promotionResult.Success = true; if (WorkOrderStatus != WorkOrderStatus.Approving) { promotionResult.Success = false; promotionResult.Message = "Failed to demote the work order to Created status because its current status prevented it."; } if (String.IsNullOrWhiteSpace(ReworkNotes)) { promotionResult.Success = false; promotionResult.Message = "Failed to demote the work order to Created status because Rework Notes must be present."; } if (promotionResult.Success) { WorkOrderStatus = WorkOrderStatus.Created; promotionResult.Message = String.Format("Work order {0} successfuly demoted to status {1}.", WorkOrderId, WorkOrderStatus); } return(promotionResult); }
private PromotionResult PromoteToCertified() { PromotionResult promotionResult = new PromotionResult(); promotionResult.Success = true; if (WorkOrderStatus != WorkOrderStatus.Certifying) { promotionResult.Success = false; promotionResult.Message = "Failed to promote the work order to Certified status because its current status prevented it."; } if (String.IsNullOrWhiteSpace(CertificationRequirements)) { promotionResult.Success = false; promotionResult.Message = "Failed to promote the work order to Certified status because Certification Requirements were not present."; } else if (Parts.Count == 0 || Labors.Count == 0) { promotionResult.Success = false; promotionResult.Message = "Failed to promote the work order to Certified status because it did not contain at least one Part and labor."; } else if (Parts.Count(p => p.IsInstalled == false) > 0 || Labors.Count(l => l.PercentComplete < 100) > 0) { promotionResult.Success = false; promotionResult.Message = "Failed to promote the work order to Certified status because not all Parts have been installed and ..."; } if (promotionResult.Success) { WorkOrderStatus = WorkOrderStatus.Certified; promotionResult.Message = String.Format("Work order {0} successfuly promoted to status {1}.", WorkOrderId, WorkOrderStatus); } return(promotionResult); }
private PromotionResult PromoteToCreated() { PromotionResult promotionResult = new PromotionResult(); promotionResult.Success = true; if (WorkOrderStatus != WorkOrderStatus.Creating) { promotionResult.Success = false; promotionResult.Message = "Failed to promote the work order to Created status because its current status prevented it."; } else if (String.IsNullOrWhiteSpace(TargetDateTime.ToString()) || String.IsNullOrWhiteSpace(DropDeadDateTime.ToString()) || String.IsNullOrWhiteSpace(Description)) { promotionResult.Success = false; promotionResult.Message = "Failed to promote the work order to Created status because it requires a Target Date, Drop Dead Time and Description."; } if (promotionResult.Success) { WorkOrderStatus = WorkOrderStatus.Created; promotionResult.Message = String.Format("Work order {0} successfuly promoted to status {1}.", WorkOrderId, WorkOrderStatus); } return(promotionResult); }
public PromotionResult ClaimWorkListItem(string userId) { PromotionResult promotionResult = WorkListBusinessRules.CanClaimWorkListItem(userId); if (!promotionResult.Success) { return(promotionResult); } switch (WorkOrderStatus) { case WorkOrderStatus.Rejected: promotionResult = PromoteToProcessing(); break; case WorkOrderStatus.Created: promotionResult = PromoteToProcessing(); break; case WorkOrderStatus.Processed: promotionResult = PromoteToCertifying(); break; case WorkOrderStatus.Certified: promotionResult = PromoteToApproving(); break; } if (promotionResult.Success) { CurrentWorkerId = userId; } Log4NetHelper.Log(promotionResult.Message, LogLevel.INFO, EntityFormalNamePlural, Id, HttpContext.Current.User.Identity.Name, null); return(promotionResult); }
public PromotionResult PromoteWorkListItem(string command) { PromotionResult promotionResult = new PromotionResult(); switch (command) { case "PromoteToCreated": promotionResult = PromoteToCreated(); break; case "PromoteToProcessed": promotionResult = PromoteToProcessed(); break; case "PromoteToCertified": promotionResult = PromoteToCertified(); break; case "PromoteToApproved": promotionResult = PromoteToApproved(); break; case "DemoteToCreated": promotionResult = DemoteToCreated(); break; case "DemoteToRejected": promotionResult = DemoteToRejected(); break; case "DemoteToCanceled": promotionResult = DemoteToCanceled(); break; } Log4NetHelper.Log(promotionResult.Message, LogLevel.INFO, "WorkOrders", WorkOrderId, HttpContext.Current.User.Identity.Name, null); if (promotionResult.Success) { CurrentWorker = null; CurrentWorkerId = null; // Attempt to auto-promotion from Certified To Approved if (WorkOrderStatus == WorkOrderStatus.Certified && Parts.Sum(p => p.ExtendedPrice) + Labors.Sum(l => l.ExtendedPrice) < 5000) { PromotionResult autoPromotionResult = PromoteToApproved(); if (autoPromotionResult.Success) { promotionResult = autoPromotionResult; promotionResult.Message = "AUTOMATIC PROMOTION: " + promotionResult.Message; } } } return(promotionResult); }
public static PromotionResult CanClaimWorkListItem(string userId) { const int MaximumNumberOfWorkListItemsAUserMayClaim = 3; int numberOfClaimedWorkListItems = 0; numberOfClaimedWorkListItems += _applicationDbContext.WorkOrders.Count(wo => wo.CurrentWorkerId == userId); //numberOfClaimedWorkListItems += _applicationDbContext.Widgets.Count(wi => wi.CurrentWorkerId == userId); PromotionResult promotionResult = new PromotionResult { Success = true }; if (numberOfClaimedWorkListItems >= MaximumNumberOfWorkListItemsAUserMayClaim) { promotionResult.Message = String.Format("You can not claim any more work list items because you already have {0} and the maximun", numberOfClaimedWorkListItems); promotionResult.Success = false; } return(promotionResult); }
private PromotionResult DemoteToRejected() { PromotionResult promotionResult = new PromotionResult(); promotionResult.Success = true; if (WorkOrderStatus != WorkOrderStatus.Approving) { promotionResult.Success = false; promotionResult.Message = "Failed to demote the work order to Rejected status because its current status prevented it."; } if (promotionResult.Success) { WorkOrderStatus = WorkOrderStatus.Rejected; promotionResult.Message = String.Format("Work order {0} successfuly demoted to status {1}.", WorkOrderId, WorkOrderStatus); } return(promotionResult); }
private PromotionResult DemoteToCanceled() { PromotionResult promotionResult = new PromotionResult(); promotionResult.Success = true; if (WidgetStatus != WidgetStatus.Approving && WidgetStatus != WidgetStatus.Integrating) { promotionResult.Success = false; promotionResult.Message = "Failed to demote the widget to Canceled status because its current status prevented it."; } if (promotionResult.Success) { WidgetStatus = WidgetStatus.Canceled; promotionResult.Message = String.Format("Widget {0} successfuly demoted to status {1}.", WidgetId, WidgetStatus); } return(promotionResult); }
private PromotionResult PromoteToApproving() { if (WidgetStatus == WidgetStatus.Integrated) { WidgetStatus = WidgetStatus.Approving; } PromotionResult promotionResult = new PromotionResult(); promotionResult.Success = WidgetStatus == WidgetStatus.Approving;; if (promotionResult.Success) { promotionResult.Message = String.Format("Widget {0} successfuly claimed by {1} and promoted to status {2}.", WidgetId, HttpContext.Current.User.Identity.Name, WidgetStatus); } else { promotionResult.Message = "Failed to promote the widget to Approving status because ies current status prevented it."; } return(promotionResult); }
private PromotionResult PromoteToApproving() { if (WorkOrderStatus == WorkOrderStatus.Certified) { WorkOrderStatus = WorkOrderStatus.Approving; } PromotionResult promotionResult = new PromotionResult(); promotionResult.Success = WorkOrderStatus == WorkOrderStatus.Approving; if (promotionResult.Success) { promotionResult.Message = String.Format("Work order {0} successfuly claimed by {1} and promoted to status {2}.", WorkOrderId, HttpContext.Current.User.Identity.Name, WorkOrderStatus); } else { promotionResult.Message = "Failed to promote the work order to Approving status because its current status prevented it."; } return(promotionResult); }