private PromotionResult PromoteToCertifying() { if (WorkOrderStatus == WorkOrderStatus.Processed) { WorkOrderStatus = WorkOrderStatus.Certifying; } PromotionResult promotionResult = new PromotionResult(); promotionResult.Success = WorkOrderStatus == WorkOrderStatus.Certifying; if (promotionResult.Success) { promotionResult.Message = String.Format("Work Order {0} successfully 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 Certifying status because its current status prevented it."; } Log4NetHelper.Log(promotionResult.Message, LogLevel.INFO, EntityFormalNamePlural, WorkOrderId, HttpContext.Current.User.Identity.Name, null); 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 required a Target Date, Drop Dead Date and a Description."; } if (promotionResult.Success) { WorkOrderStatus = WorkOrderStatus.Created; promotionResult.Message = String.Format("Work Order {0} successfully promortedto status {1}", WorkOrderId, WorkOrderStatus); } Log4NetHelper.Log(promotionResult.Message, LogLevel.INFO, EntityFormalNamePlural, WorkOrderId, 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 leaset one part or labor."; } else if (String.IsNullOrWhiteSpace(Description)) { promotionResult.Success = false; promotionResult.Message = "Failed to promote the work order to Processed status because it requires a Description."; } if (promotionResult.Success) { WorkOrderStatus = WorkOrderStatus.Processed; promotionResult.Message = String.Format("Work Order {0} successfully promortedto status {1}", WorkOrderId, WorkOrderStatus); } Log4NetHelper.Log(promotionResult.Message, LogLevel.INFO, EntityFormalNamePlural, WorkOrderId, HttpContext.Current.User.Identity.Name, null); 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); }
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 auto-promotion from Certified to Approved if (WorkOrderStatus == WorkOrderStatus.Certified && Parts.Sum(p => p.ExtendedPrice) + Labors.Sum(l => l.ExtendedPrice) < 5000) { PromotionResult autoPromotionReuslt = PromoteToApproved(); if (autoPromotionReuslt.Success) { promotionResult = autoPromotionReuslt; promotionResult.Message = "AUTOMATIC PROMOTION: " + promotionResult.Message; } } } return(promotionResult); }
private PromotionResult PromoteToCertified() { PromotionResult promotionResult = new PromotionResult { Success = true }; promotionResult = CertifyingTest(promotionResult); promotionResult = CertificationRequirementsTest(promotionResult); promotionResult = OnePartAndLaborTest(promotionResult); promotionResult = PartsInstalledLaborCompleteTest(promotionResult); //Tests refactored: ma non esce subito //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 Created status because it did not contain Part or 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 Created status because not all parts have been installed or labors been completed."; //} if (promotionResult.Success) { WorkOrderStatus = WorkOrderStatus.Certified; promotionResult.Message = String.Format("Work Order {0} successfully promortedto status {1}", WorkOrderId, WorkOrderStatus); } Log4NetHelper.Log(promotionResult.Message, LogLevel.INFO, EntityFormalNamePlural, WorkOrderId, HttpContext.Current.User.Identity.Name, null); 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; 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); }
public PromotionResult RelinquishWorkListItem() { PromotionResult promotionResult = new PromotionResult { Success = true }; if (CurrentWorkerId == null || Status.Substring(Status.Length - 3, 3) != "ing") { promotionResult.Success = false; promotionResult.Message = String.Format("Work Order {0} cannot be relinquished because it is not currently being worked on.", WorkOrderId); } if (promotionResult.Success) { CurrentWorker = null; CurrentWorkerId = null; switch (WorkOrderStatus) { case WorkOrderStatus.Processing: WorkOrderStatus = WorkOrderStatus.Created; break; case WorkOrderStatus.Certifying: WorkOrderStatus = WorkOrderStatus.Processed; break; case WorkOrderStatus.Approving: WorkOrderStatus = WorkOrderStatus.Certified; break; } promotionResult.Message = String.Format("Work Order {0} was successfully relinquished and its status was reset to {1}.", WorkOrderId, WorkOrderStatus); } Log4NetHelper.Log(promotionResult.Message, LogLevel.INFO, EntityFormalNamePlural, WorkOrderId, HttpContext.Current.User.Identity.Name, null); 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; } Log4NetHelper.Log(promotionResult.Message, LogLevel.INFO, "WorkOrders", WorkOrderId, HttpContext.Current.User.Identity.Name, null); if (promotionResult.Success) { CurrentWorkerId = userId; } return(promotionResult); }
private PromotionResult PromoteToApproved() { PromotionResult promotionResult = new PromotionResult(); promotionResult.Success = true; if (WorkOrderStatus != WorkOrderStatus.Approving && WorkOrderStatus != WorkOrderStatus.Certified) { promotionResult.Success = false; promotionResult.Message = "Failed to promote the work order to Approved status because its current status prevented it."; } if (promotionResult.Success) { WorkOrderStatus = WorkOrderStatus.Approved; promotionResult.Message = String.Format("Work Order {0} successfully promortedto status {1}", WorkOrderId, WorkOrderStatus); } Log4NetHelper.Log(promotionResult.Message, LogLevel.INFO, EntityFormalNamePlural, WorkOrderId, HttpContext.Current.User.Identity.Name, null); return(promotionResult); }