コード例 #1
0
        public override void ProcessPressing(MachinePresser presser)
        {
            var pressingProcess = Processes
                                  .OfType <ProcessPressing>()
                                  .FirstOrDefault();

            if (pressingProcess == null)
            {
                throw new Exception("Order not for PRESSING");
            }

            switch (CurrentProcess)
            {
            case ProcessRouting routing:
                if (!routing.EndTime.HasValue)
                {
                    throw new Exception($"Order is currently being routed on Router {routing.MachineRouter.Name}");
                }

                routing.IsCurrent = false;

                pressingProcess.StartTime = DateTime.Now;
                pressingProcess.MachineId = presser.Id;
                pressingProcess.IsCurrent = true;
                break;

            case ProcessPressing pressing:
                if (pressing.EndTime.HasValue)
                {
                    throw new Exception("Order has already been PRESSED");
                }

                if (pressing.MachineId != presser.Id)
                {
                    throw new Exception($"Order is currently on Presser {pressing.MachinePresser.Name}");
                }

                pressing.EndTime = DateTime.Now;
                break;

            default:
                throw new Exception("Order not valid for PRESSING");
            }
        }
コード例 #2
0
 public abstract void ProcessPressing(MachinePresser presser);