コード例 #1
0
        private static Dictionary <int, Tuple <DateTime, int> > GetEmployeeIdentifiableByLot(PackScheduleDTO packSchedule)
        {
            if (packSchedule == null || string.IsNullOrWhiteSpace(packSchedule.Serialized))
            {
                return(new Dictionary <int, Tuple <DateTime, int> >());
            }

            try
            {
                var lotKeyParser = new LotKey();
                var employeeKey  = new EmployeeKey();
                return(SerializablePackSchedule.Deserialize(packSchedule.Serialized).Batches.ToDictionary(b =>
                {
                    var lotKey = lotKeyParser.Parse(b.LotKey);
                    return LotNumberBuilder.BuildLotNumber(lotKey).LotNumber;
                }, b => new Tuple <DateTime, int>(b.TimeStamp, employeeKey.Parse(b.EmployeeKey).EmployeeKey_Id)));
            }
            catch (Exception ex)
            {
                throw new Exception("Error parsing PackSchedule deserialized data.", ex);
            }
        }
コード例 #2
0
        public static bool DeserializeIntoPackSchedule(PackSchedule packSchedule, string serializedPackSchedule, out int?pkgID)
        {
            pkgID = null;
            var deserialized = Deserialize(serializedPackSchedule);

            if (deserialized == null)
            {
                return(false);
            }

            var employeeKeyParser = new EmployeeKey();
            var lotKeyParser      = new LotKey();

            pkgID = deserialized.PkgID;

            IEmployeeKey employeeKey;

            if (employeeKeyParser.TryParse(deserialized.EmployeeKey, out employeeKey))
            {
                packSchedule.EmployeeId = employeeKey.EmployeeKey_Id;
            }
            packSchedule.TimeStamp = deserialized.TimeStamp;

            packSchedule.DefaultBatchTargetParameters = new ProductionBatchTargetParameters(deserialized.TargetParameters);
            packSchedule.ProductionBatches            = deserialized.Batches.Select(b =>
            {
                var lotKey            = lotKeyParser.Parse(b.LotKey);
                var batchEmployeeKey  = employeeKeyParser.Parse(b.EmployeeKey);
                var pickedEmployeeKey = employeeKeyParser.Parse(b.PickedInventory.EmployeeKey);

                var productionBatch = new ProductionBatch
                {
                    EmployeeId = batchEmployeeKey.EmployeeKey_Id,
                    TimeStamp  = b.TimeStamp,

                    LotDateCreated  = lotKey.LotKey_DateCreated,
                    LotDateSequence = lotKey.LotKey_DateSequence,
                    LotTypeId       = lotKey.LotKey_LotTypeId,

                    PackScheduleDateCreated = packSchedule.DateCreated,
                    PackScheduleSequence    = packSchedule.SequentialNumber,

                    ProductionHasBeenCompleted = false,
                    TargetParameters           = new ProductionBatchTargetParameters(b.TargetParameters),

                    Production = new ChileLotProduction
                    {
                        EmployeeId = batchEmployeeKey.EmployeeKey_Id,
                        TimeStamp  = b.TimeStamp,

                        LotDateCreated  = lotKey.LotKey_DateCreated,
                        LotDateSequence = lotKey.LotKey_DateSequence,
                        LotTypeId       = lotKey.LotKey_LotTypeId,

                        ProductionType = ProductionType.ProductionBatch,

                        PickedInventory = new Models.PickedInventory
                        {
                            EmployeeId   = pickedEmployeeKey.EmployeeKey_Id,
                            TimeStamp    = b.PickedInventory.TimeStamp,
                            PickedReason = PickedReason.Production,
                            Archived     = false,
                            Items        = new List <PickedInventoryItem>()
                        }
                    }
                };
                return(productionBatch);
            }).ToList();

            return(true);
        }