示例#1
0
        private PromotionResult PromoteToProcessing()
        {
            if (WorkOrderStatus == WorkOrderStatus.Created || WorkOrderStatus == WorkOrderStatus.Rejected)
            {
                WorkOrderStatus = WorkOrderStatus.Processing;
            }

            PromotionResult promotion = new PromotionResult();

            promotion.Success = WorkOrderStatus == WorkOrderStatus.Processing;

            if (promotion.Success)
            {
                promotion.Message =
                    $"Work order {WorkOrderId} successfullly created by " +
                    $"{HttpContext.Current.User.Identity.Name} and " +
                    $"promoted to status {WorkOrderStatus}";
            }

            else
            {
                promotion.Message = "Failed to promote the work order to approving status because of it's current status";
            }

            return(promotion);
        }
示例#2
0
        private PromotionResult PromoteToCertifying()
        {
            if (WorkOrderStatus == WorkOrderStatus.Processed)
            {
                WorkOrderStatus = WorkOrderStatus.Certifying;
            }

            PromotionResult promotion = new PromotionResult();

            promotion.Success = WorkOrderStatus == WorkOrderStatus.Certifying;

            if (promotion.Success)
            {
                promotion.Message =
                    $"Work order {WorkOrderId} successfully claimed by " +
                    $"{HttpContext.Current.User.Identity.Name} and " +
                    $"promoted to status {WorkOrderStatus}";
            }

            else
            {
                promotion.Message = "Failed to promote the work orderFailed to promote the work order to Certifying status because its current status prevented it.";
            }

            return(promotion);
        }
示例#3
0
        private PromotionResult PromoteToProcessed()
        {
            PromotionResult promotion = new PromotionResult
            {
                Success = true
            };

            if (WorkOrderStatus != WorkOrderStatus.Processing)
            {
                promotion.Success = false;
                promotion.Message = "Failed to promote the work order to Processed status because its current status prevented it.";
            }

            else if (Parts.Count == 0 || Labors.Count == 0)
            {
                promotion.Success = false;
                promotion.Message = "Failed to promote the work order to Processed status because it did not contain at least one part and at least one labor item.";
            }

            else if (string.IsNullOrWhiteSpace(Description))
            {
                promotion.Success = false;
                promotion.Message = "Failed to promote the work order to Processed status because it requires a Description.";
            }

            if (promotion.Success)
            {
                WorkOrderStatus   = WorkOrderStatus.Processed;
                promotion.Message = $"Work order {WorkOrderId} successfully promoted to status {WorkOrderStatus}";
            }

            return(promotion);
        }
示例#4
0
        public PromotionResult ClaimWorkOrder(string userId)
        {
            PromotionResult promotionResult = new PromotionResult();

            //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;
            }

            return(promotionResult);
        }
示例#5
0
        private PromotionResult DemoteToCreated()
        {
            PromotionResult promotion = new PromotionResult()
            {
                Success = true
            };

            if (WorkOrderStatus != WorkOrderStatus.Approving)
            {
                promotion.Success = false;
                promotion.Message = "Failed to demote the work order to Created status because its current status prevented it.";
            }

            if (String.IsNullOrWhiteSpace(ReworkNotes))
            {
                promotion.Success = false;
                promotion.Message = "Failed to demote the work order to Created status because Rework Notes must be present.";
            }

            if (promotion.Success)
            {
                WorkOrderStatus   = WorkOrderStatus.Created;
                promotion.Message = $"Work order {WorkOrderId} successfully demoted to status {WorkOrderStatus}";
            }

            return(promotion);
        }
示例#6
0
        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);
        }
示例#7
0
        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);
        }
示例#8
0
        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);
        }
示例#9
0
        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} 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 Approving status because its current status prevented it.";
            }

            return(promotionResult);
        }
示例#10
0
        private PromotionResult PromoteToApproved()
        {
            PromotionResult promotionResult = new PromotionResult();

            promotionResult.Success = true;


            if (WidgetStatus != WidgetStatus.Approving)
            {
                promotionResult.Success = false;
                promotionResult.Message = String.Format("Failed to promote the widget to Approved status because its current status prevented it.");
            }

            if (TestPassDateTime == null)
            {
                promotionResult.Success = false;
                promotionResult.Message = String.Format("Failed to promote the widget to Approved status because the Test Pass Date was not present.");
            }

            if (promotionResult.Success)
            {
                WidgetStatus            = WidgetStatus.Approved;
                promotionResult.Message = String.Format("Widget {0} successfully promoted to status {1}.", WidgetId, WidgetStatus);
            }


            return(promotionResult);
        }
示例#11
0
        private PromotionResult PromoteToIntegrated()
        {
            PromotionResult promotionResult = new PromotionResult();

            promotionResult.Success = true;


            if (WidgetStatus != WidgetStatus.Integrating)
            {
                promotionResult.Success = false;
                promotionResult.Message = String.Format("Failed to promote the widget to Integrated status because its current status prevented it.");
            }

            if (String.IsNullOrWhiteSpace(MainBusCode))
            {
                promotionResult.Success = false;
                promotionResult.Message = String.Format("Failed to promote the widget to Integrated status because the Main Bus Code was not present.");
            }

            if (promotionResult.Success)
            {
                WidgetStatus            = WidgetStatus.Integrated;
                promotionResult.Message = String.Format("Widget {0} successfully promorted to status {1}.", WidgetId, WidgetStatus);
            }


            return(promotionResult);
        }
示例#12
0
        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} successfully demoted to status {1}.",
                                                    WorkOrderId,
                                                    WorkOrderStatus);

            return(promotionResult);
        }
示例#13
0
        private PromotionResult PromoteToCreated()
        {
            PromotionResult promotion = new PromotionResult
            {
                Success = true
            };

            if (WorkOrderStatus != WorkOrderStatus.Creating)
            {
                promotion.Success = false;
                promotion.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))
            {
                promotion.Success = false;
                promotion.Message = "Failed to promote the work order to Created status because its current status prevented it.";
            }

            if (promotion.Success)
            {
                WorkOrderStatus   = WorkOrderStatus.Created;
                promotion.Message = $"Work order {WorkOrderId} successfully promoted to status {WorkOrderStatus}";
            }

            return(promotion);
        }
示例#14
0
        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);
        }
示例#15
0
        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);
        }
示例#16
0
 private PromotionResult CertificationRequirementsTest(PromotionResult promotionResult)
 {
     if (String.IsNullOrWhiteSpace(CertificationRequirements))
     {
         promotionResult.Success = false;
         promotionResult.Message = "Failed to promote the work order to Certified status because Certification Requirements were not present.";
     }
     return(promotionResult);
 }
示例#17
0
 private PromotionResult PartsInstalledLaborCompleteTest(PromotionResult promotionResult)
 {
     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.";
     }
     return(promotionResult);
 }
示例#18
0
 private PromotionResult OnePartAndLaborTest(PromotionResult promotionResult)
 {
     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.";
     }
     return(promotionResult);
 }
示例#19
0
        private PromotionResult CertifyingTest(PromotionResult promotionResult)
        {
            if (WorkOrderStatus != WorkOrderStatus.Certifying)
            {
                promotionResult.Success = false;
                promotionResult.Message = "Failed to promote the work order to Certified status because its current status prevented it.";
            }

            return(promotionResult);
        }
示例#20
0
        public PromotionResult PromoteWorkOrder(string command)
        {
            PromotionResult promotion = new PromotionResult();

            switch (command)
            {
            case "PromoteToCreated":
                promotion = PromoteToCreated();
                break;

            case "PromoteToProcessed":
                promotion = PromoteToProcessed();
                break;

            case "PromoteToCertified":
                promotion = PromoteToCertified();
                break;

            case "PromoteToApproved":
                promotion = PromoteToApproved();
                break;

            case "DemoteToCreated":
                promotion = DemoteToCreated();
                break;

            case "DemoteToRejected":
                promotion = DemoteToRejected();
                break;

            case "DemoteToCanceled":
                promotion = DemoteToCanceled();
                break;
            }

            if (promotion.Success)
            {
                CurrentWorker   = null;
                CurrentWorkerId = null;

                // Attempt to auto-promote from certified to Approved
                if (WorkOrderStatus == WorkOrderStatus.Certified && Parts.Sum(p => p.ExtendedPrice) + Labors.Sum(l => l.ExtendedPrice) < 5000)
                {
                    PromotionResult autoPromote = PromoteToApproved();

                    if (autoPromote.Success)
                    {
                        promotion         = autoPromote;
                        promotion.Message = $"AUTOMATIC PROMOTION: {promotion.Message}";
                    }
                }
            }

            return(promotion);
        }
示例#21
0
        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 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 cannot claim any more work list items because you already have {0} and the maximum number allowed is {1}", numberOfClaimedWorkListItems, MaximumNumberOfWorkListItemsAUserMayClaim);
                promotionResult.Success = false;
            }

            return promotionResult;
        }
示例#23
0
        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);
        }
示例#24
0
        private PromotionResult DemoteToCancelled()
        {
            var promotionResult = new PromotionResult();

            promotionResult.Success = true;

            if (WorkOrderStatus != WorkOrderStatus.Approving)
            {
                promotionResult.Success = false;
                promotionResult.Message = "Failed to demote the work order to Cancelled status because its current status prevented it.";
            }

            if (promotionResult.Success)
            {
                WorkOrderStatus         = WorkOrderStatus.Cancelled;
                promotionResult.Message = $"Work order {WorkOrderId} successfully demoted to status {WorkOrderStatus}.";
            }

            return(promotionResult);
        }
示例#25
0
        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(wo => wo.CurrentWorkerId == userId);

            PromotionResult promotionResult = new PromotionResult {
                Success = true
            };

            if (numberOfClaimedWorkListItems >= MaximumNumberOfWorkListItemsAUserMayClaim)
            {
                promotionResult.Message = String.Format("You cannot claim any more work list items because you already have {0} and the maximum is {1}", numberOfClaimedWorkListItems, MaximumNumberOfWorkListItemsAUserMayClaim);
                promotionResult.Success = false;
            }

            return(promotionResult);
        }
示例#26
0
        private PromotionResult DemoteToRejected()
        {
            PromotionResult promotion = new PromotionResult
            {
                Success = true
            };

            if (WorkOrderStatus != WorkOrderStatus.Approving)
            {
                promotion.Success = false;
                promotion.Message = "Failed to demote the work order to Rejected status because its current status prevented it.";
            }

            if (promotion.Success)
            {
                WorkOrderStatus   = WorkOrderStatus.Rejected;
                promotion.Message = $"Work order {WorkOrderId} successfully demoted to status {WorkOrderStatus}";
            }

            return(promotion);
        }
示例#27
0
        // Claiming a work order does two things: First, it promotes the work order
        // to its next active status "ing status". Second, it relates the work order
        // to the authenticated user who claimed it.
        public PromotionResult ClaimWorkListItem(string userId)
        {
            var promotionResult = new PromotionResult();

            //if (!promotionResult.Success)
            //{
            //    return promotionResult;
            //}

            // A work order could be claimed in Rejected, Created, Processed or Certified
            // status. Use a switch statement to handle those scenarios.
            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;
            }

            // After the switch statement, we assign userId to CurrentWorkerId
            // if the promotion succeeded. E.g. When the current status is Rejected and
            // the work order is claimed, it's status is promoted to Processing.
            if (promotionResult.Success)
            {
                CurrentWorkerId = userId;
            }

            return(promotionResult);
        }
示例#28
0
        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);
        }
示例#29
0
        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} successfully claimed by {1} and promoted to status {2}.", WidgetId, HttpContext.Current.User.Identity.Name, WidgetStatus);
            }
            else
            {
                promotionResult.Message = String.Format("Failed to promote the widget to Approving status because its current status prevented it.");
            }

            return(promotionResult);
        }
示例#30
0
        private PromotionResult DemoteToCanceled()
        {
            PromotionResult promotionResult = new PromotionResult();

            promotionResult.Success = true;

            if (WorkOrderStatus != WorkOrderStatus.Approving)
            {
                promotionResult.Success = false;
                promotionResult.Message = "Failed to demote the work order to Canceled status because its current status prevented it.";
            }

            if (promotionResult.Success)
            {
                WorkOrderStatus = WorkOrderStatus.Canceled;
            }
            promotionResult.Message = String.Format("Work Order {0} successfully demoted to status {1}.",
                                                    WorkOrderId,
                                                    WorkOrderStatus);

            return(promotionResult);
        }
示例#31
0
        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);
        }
示例#32
0
        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} successfully demoted to status {1}.", WidgetId, WidgetStatus);
            }

            return promotionResult;
        }
示例#33
0
        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("Widget {0} cannot be relinquished because it is not currently being worked on.", WidgetId);
            }

            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, Status);
            }

            Log4NetHelper.Log(promotionResult.Message, LogLevel.INFO, EntityFormalNamePlural, WidgetId, HttpContext.Current.User.Identity.Name, null);

            return promotionResult;
        }
示例#34
0
        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;
        }
        public ActionResult Edit([Bind(Include = "WidgetId,Description,MainBusCode,TestPassDateTime,WidgetStatus,CurrentWorkerId")] Widget widget, string command)
        {
            if (ModelState.IsValid)
            {
                PromotionResult promotionResult = new PromotionResult();

                if (command == "Save")
                {
                    promotionResult.Success = true;
                    promotionResult.Message = String.Format("Changes to widget {0} have been successfully saved.", widget.WidgetId);
                    Log4NetHelper.Log(promotionResult.Message, LogLevel.INFO, widget.EntityFormalNamePlural, widget.WidgetId, User.Identity.Name, null);
                }
                else if (command == "Claim")
                    promotionResult = widget.ClaimWorkListItem(User.Identity.GetUserId());
                else if (command == "Relinquish")
                    promotionResult = widget.RelinquishWorkListItem();
                else
                    promotionResult = widget.PromoteWorkListItem(command);

                if (!promotionResult.Success)
                    TempData["MessageToClient"] = promotionResult.Message;

                _applicationDbContext.Entry(widget).State = EntityState.Modified;
                _applicationDbContext.SaveChanges();

                if (command == "Claim" && promotionResult.Success)
                    return RedirectToAction("Edit", widget.WidgetId);

                return RedirectToAction("Index", "WorkList");
            }

            return View(widget);
        }
示例#36
0
        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 Date, and Description.";
            }

            if (promotionResult.Success)
            {
                WorkOrderStatus = WorkOrderStatus.Created;
                promotionResult.Message = String.Format("Work order {0} successfully promoted to status {1}.", WorkOrderId, WorkOrderStatus);
            }

            return promotionResult;
        }
示例#37
0
 private PromotionResult PartsInstalledLaborCompleteTest(PromotionResult promotionResult)
 {
     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 labor completed.";
     }
     return promotionResult;
 }
示例#38
0
        private PromotionResult PromoteToIntegrating()
        {
            if (WidgetStatus == WidgetStatus.Created)
            {
                WidgetStatus = WidgetStatus.Integrating;
            }

            PromotionResult promotionResult = new PromotionResult();
            promotionResult.Success = WidgetStatus == WidgetStatus.Integrating;

            if (promotionResult.Success)
                promotionResult.Message = String.Format("Widget {0} successfully claimed by {1} and promoted to status {2}.", WidgetId, HttpContext.Current.User.Identity.Name, WidgetStatus);
            else
                promotionResult.Message = "Failed to promote the widget to Integrating status because its current status prevented it.";

            return promotionResult;
        }
示例#39
0
        private PromotionResult PromoteToCertified()
        {
            PromotionResult promotionResult = new PromotionResult { Success = true };
            promotionResult = CertifyingTest(promotionResult);
            promotionResult = CertificationRequirementsTest(promotionResult);
            promotionResult = OnePartAndLaborTest(promotionResult);
            promotionResult = PartsInstalledLaborCompleteTest(promotionResult);

            if (promotionResult.Success)
            {
                WorkOrderStatus = WorkOrderStatus.Certified;
                promotionResult.Message = String.Format("Work order {0} successfully promoted to status {1}.", WorkOrderId, WorkOrderStatus);
            }

            return promotionResult;
        }
示例#40
0
        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, EntityFormalNamePlural, Id, 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 autoPromotionResult = PromoteToApproved();

                    if (autoPromotionResult.Success)
                    {
                        promotionResult = autoPromotionResult;
                        promotionResult.Message = "AUTOMATIC PROMOTION: " + promotionResult.Message;
                        Log4NetHelper.Log(promotionResult.Message, LogLevel.INFO, EntityFormalNamePlural, Id, HttpContext.Current.User.Identity.Name, null);
                    }
                }
            }

            return promotionResult;
        }
示例#41
0
        private PromotionResult PromoteToProcessing()
        {
            if (WorkOrderStatus == WorkOrderStatus.Created || WorkOrderStatus == WorkOrderStatus.Rejected)
            {
                WorkOrderStatus = WorkOrderStatus.Processing;
            }

            PromotionResult promotionResult = new PromotionResult();
            promotionResult.Success = WorkOrderStatus == WorkOrderStatus.Processing;

            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 Processing status because its current status prevented it.";

            return promotionResult;
        }
示例#42
0
        //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 at least one labor item.";
        //    }
        //    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 labor completed.";
        //    }
        //    if (promotionResult.Success)
        //    {
        //        WorkOrderStatus = WorkOrderStatus.Certified;
        //        promotionResult.Message = String.Format("Work order {0} successfully promoted to status {1}.", WorkOrderId, WorkOrderStatus);
        //    }
        //    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 promoted to status {1}.", WorkOrderId, WorkOrderStatus);
            }

            return promotionResult;
        }
示例#43
0
        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} successfully promoted to status {1}.", WidgetId, WidgetStatus);
            }

            return promotionResult;
        }
示例#44
0
        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} successfully demoted to status {1}.", WorkOrderId, WorkOrderStatus);
            }

            return promotionResult;
        }
示例#45
0
        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} successfully promoted to status {1}.", WidgetId, WidgetStatus);
            }

            return promotionResult;
        }
示例#46
0
 private PromotionResult OnePartAndLaborTest(PromotionResult promotionResult)
 {
     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 at least one labor item.";
     }
     return promotionResult;
 }
        public async Task<ActionResult> Edit([Bind(Include = "WorkOrderId,CustomerId,OrderDateTime,TargetDateTime,DropDeadDateTime,Description,WorkOrderStatus,CertificationRequirements,CurrentWorkerId,ReworkNotes,RowVersion")] WorkOrder workOrder, string command)
        {
            if (ModelState.IsValid)
            {
                // Populate Parts and Labors
                workOrder.Parts = _applicationDbContext.Parts.Where(p => p.WorkOrderId == workOrder.WorkOrderId).ToList();
                workOrder.Labors = _applicationDbContext.Labors.Where(l => l.WorkOrderId == workOrder.WorkOrderId).ToList();

                PromotionResult promotionResult = new PromotionResult();

                if (command == "Save")
                {
                    promotionResult.Success = true;
                    promotionResult.Message = String.Format("Changes to work order {0} have been successfully saved.", workOrder.Id);
                    Log4NetHelper.Log(promotionResult.Message, LogLevel.INFO, workOrder.EntityFormalNamePlural, workOrder.Id, User.Identity.Name, null);
                }
                else if (command == "Claim")
                    promotionResult = workOrder.ClaimWorkListItem(User.Identity.GetUserId());
                else if (command == "Relinquish")
                    promotionResult = workOrder.RelinquishWorkListItem();
                else
                    promotionResult = workOrder.PromoteWorkListItem(command);

                if (!promotionResult.Success)
                    TempData["MessageToClient"] = promotionResult.Message;

                _applicationDbContext.Entry(workOrder).State = EntityState.Modified;

                try
                {
                    await _applicationDbContext.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (command == "Claim")
                        TempData["MessageToClient"] = String.Format("Someone else has claimed work order {0} since you retrieved it.", workOrder.WorkOrderId);
                    else
                        TempData["MessageToClient"] = String.Format("Someone else has modified work order {0} since you retrieved it.  Your changes have not been applied.", workOrder.WorkOrderId);

                    return RedirectToAction("Index", "WorkList");
                }

                if (command == "Claim" && promotionResult.Success)
                    return RedirectToAction("Edit", workOrder.WorkOrderId);

                return RedirectToAction("Index", "WorkList");
            }

            return View(workOrder);
        }
示例#48
0
 private PromotionResult CertifyingTest(PromotionResult promotionResult)
 {
     if (WorkOrderStatus != WorkOrderStatus.Certifying)
     {
         promotionResult.Success = false;
         promotionResult.Message = "Failed to promote the work order to Certified status because its current status prevented it.";
     }
     return promotionResult;
 }
示例#49
0
 private PromotionResult CertificationRequirementsTest(PromotionResult promotionResult)
 {
     if (String.IsNullOrWhiteSpace(CertificationRequirements))
     {
         promotionResult.Success = false;
         promotionResult.Message = "Failed to promote the work order to Certified status because Certification Requirements were not present.";
     }
     return promotionResult;
 }
示例#50
0
        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 at least one labor item.";
            }
            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 promoted to status {1}.", WorkOrderId, WorkOrderStatus);
            }

            return promotionResult;
        }