Esempio n. 1
0
        private int CreateLabel(LabelOutputViewModel model)
        {
            var label = new Label
            {
                OrderDetailId       = model.OrderDetailId,
                TypeId              = model.Type,
                ItemCode            = model.ItemCode,
                LotNumber           = model.LotNumber,
                Description         = model.Description,
                PoundWeight         = model.PoundWeight,
                KilogramWeight      = model.KilogramWeight,
                ProcessDate         = model.ProcessDate.ToString("d"),
                SlaughterDate       = model.SlaughterDate.ToString("d"),
                BestBeforeDate      = model.BestBeforeDate,
                SpeciesBugPath      = model.SpeciesBugPath,
                LogoPath            = model.LogoPath,
                BornIn              = model.BornInRegionName,
                RaisedIn            = model.RaisedInRegionName,
                ProductOf           = model.ProductOfRegionName,
                DistributedBy       = model.DistributedBy,
                GermanDescription   = model.GermanDescription,
                FrenchDescription   = model.FrenchDescription,
                ItalianDescription  = model.ItalianDescription,
                SwedishDescription  = model.SwedishDescription,
                IsPrinted           = model.IsPrinted,
                CreatedDate         = model.WeighedDate,
                LabelFile           = model.LabelFile,
                Customer            = model.Customer,
                CustomerProductCode = model.CustomerProductCode,
                GradeName           = model.GradeName,
                SerialNumber        = model.SerialNumber,
                Organic             = model.Organic,
                Primal              = model.Primal,
                SubPrimal           = model.SubPrimal,
                Trim                       = model.Trim,
                Refrigeration              = model.Refrigeration,
                PackedFor                  = model.PackedFor,
                VarCustomerJobValue        = model.VarCustomerJobValue,
                CustomerProductDescription = model.VarCustomerProductValue
            };

            Logger.Debug(
                string.Format("OrderDetailId:{0}; PoundWeight:{1}; KiloWeight:{2}; LabelFile:{3}; LogoPath:{4}; ",
                              label.OrderDetailId, label.PoundWeight, label.KilogramWeight, label.LabelFile,
                              label.LogoPath));
            _labelRepository.Add(label);
            _labelRepository.Save();
            return(label.Id);
        }
Esempio n. 2
0
 private void ProduceLabel(OmsLabelType labelType, LabelOutputViewModel model, OrderDetail orderDetail, bool isCustombagLabel, DateTime?processDate)
 {
     model.SerialNumber = GetSerialNumber();
     if (isCustombagLabel)
     {
         model.OrderDetailId = orderDetail.Id;
     }
     model.Printer   = SettingsManager.Current.Printer;
     model.LabelFile = SetLabelFile(labelType, orderDetail.Order.Customer, false);
     if (processDate.HasValue)
     {
         model.ProcessDate = processDate.GetValueOrDefault();
     }
     CreateLabel(model);
     if (SettingsManager.Current.IsSecondaryLabel)
     {
         model.Printer   = SettingsManager.Current.SecondaryPrinter;
         model.LabelFile = SetLabelFile(labelType, orderDetail.Order.Customer, true);
         CreateLabel(model);
     }
 }
Esempio n. 3
0
        private void CreateLabel(LabelOutputViewModel model)
        {
            var context = new OmsContext();

            _labelRepository = new LabelRepository(context);
            var label = new Label
            {
                OrderDetailId       = model.OrderDetailId,
                TypeId              = model.Type,
                ItemCode            = model.ItemCode,
                LotNumber           = model.LotNumber,
                Description         = model.Description,
                PoundWeight         = model.PoundWeight,
                KilogramWeight      = model.KilogramWeight,
                ProcessDate         = model.ProcessDate.ToString("d"),
                SlaughterDate       = model.SlaughterDate.ToString("d"),
                BestBeforeDate      = model.BestBeforeDate,
                SpeciesBugPath      = model.SpeciesBugPath,
                LogoPath            = model.LogoPath,
                BornIn              = model.BornInRegionName,
                RaisedIn            = model.RaisedInRegionName,
                ProductOf           = model.ProductOfRegionName,
                SlaughteredIn       = model.SlaughteredInRegionName,
                DistributedBy       = model.DistributedBy,
                GermanDescription   = model.GermanDescription,
                FrenchDescription   = model.FrenchDescription,
                ItalianDescription  = model.ItalianDescription,
                SwedishDescription  = model.SwedishDescription,
                IsPrinted           = model.IsPrinted,
                CreatedDate         = model.WeighedDate,
                LabelFile           = model.LabelFile,
                Customer            = model.Customer,
                CustomerPO          = model.CustomerPO,
                CustomerProductCode = model.CustomerProductCode,
                GradeName           = model.GradeName,
                SerialNumber        = model.SerialNumber,
                Organic             = model.Organic,
                Primal              = model.Primal,
                SubPrimal           = model.SubPrimal,
                AnimalName          = model.AnimalName,
                Species             = model.Species,
                Trim                       = model.Trim,
                Refrigeration              = model.Refrigeration,
                PackedFor                  = model.PackedFor,
                JulianProductionDate       = model.JulianProductionDate,
                VarCustomerJobValue        = model.VarCustomerJobValue,
                CustomerProductDescription = model.VarCustomerProductValue,
                Gtin                       = model.Gtin,
                PricePerPound              = model.PricePerPound,
                Price                      = model.Price,
                Printer                    = model.Printer,
                TareWeight                 = model.TareWeight,
                NutritionDescription       = model.NutritionDescription,
                NutritionServingSize       = model.NutritionServingSize,
                NutritionServingContainer  = model.NutritionServingContainer,
                NutritionCalories          = model.NutritionCalories,
                NutritionCaloriesFat       = model.NutritionCaloriesFat,
                NutritionTotalFat          = model.NutritionTotalFat,
                NutritionSatFat            = model.NutritionSatFat,
                NutritionTransFat          = model.NutritionTransFat,
                NutritionPolyFat           = model.NutritionPolyFat,
                NutritionMonoFat           = model.NutritionMonoFat,
                NutritionCholesterol       = model.NutritionCholesterol,
                NutritionSodium            = model.NutritionSodium,
                NutritionCarbs             = model.NutritionCarbs,
                NutritionProtein           = model.NutritionProtein,
                NutritionVitA              = model.NutritionVitA,
                NutritionVitC              = model.NutritionVitC,
                NutritionCalcium           = model.NutritionCalcium,
                NutritionIron              = model.NutritionIron,
                CustomerStateCode          = model.CustomerStateCode,
                CustomerName               = model.CustomerName,
                CustomerPhone              = model.CustomerPhone,
                CustomerEmail              = model.CustomerEmail,
                CustomerCity               = model.CustomerCity,
                CustomerZipCode            = model.CustomerZipCode,
                CustomerFax                = model.CustomerFax,
                CustomerAddress2           = model.CustomerAddress2,
                CustomerAddress1           = model.CustomerAddress1
            };

            Logger.Debug(string.Format("OrderDetailId:{0}; PoundWeight:{1}; KiloWeight:{2}; LabelFile:{3}; LogoPath:{4}; ",
                                       label.OrderDetailId,
                                       label.PoundWeight,
                                       label.KilogramWeight,
                                       label.LabelFile,
                                       label.LogoPath));

            _labelRepository.Add(label);
            _labelRepository.Save();
            context.Dispose();
        }
Esempio n. 4
0
        private LabelOutputViewModel GetLabelLayoutViewModel(double poundWeight, OrderDetail orderDetail, OmsLabelType labelType, bool needSetSerialNumber = true, QualityGrade qualityGrade = null, AnimalLabelsViewModel animalLabel = null, CaseSize customCaseSize = null)
        {
            var model = new LabelOutputViewModel();


            model.PoundWeight    = GetNetPoundWeight(poundWeight, labelType, orderDetail);
            model.KilogramWeight = GetCorrectKilogramWeight(model.PoundWeight);

            var order    = orderDetail.Order;
            var product  = orderDetail.Product;
            var customer = order.Customer;

            var productData = GetCustomerProductData(product, order);

            model.CustomerStateCode = orderDetail.CustomerLocation.StateCode;
            model.CustomerAddress1  = orderDetail.CustomerLocation.Address1;
            model.CustomerAddress2  = orderDetail.CustomerLocation.Address2;
            model.CustomerCity      = orderDetail.CustomerLocation.City;
            model.CustomerEmail     = orderDetail.CustomerLocation.Email;
            model.CustomerFax       = orderDetail.CustomerLocation.Fax;
            model.CustomerZipCode   = orderDetail.CustomerLocation.ZipCode;
            model.CustomerPhone     = orderDetail.CustomerLocation.Phone;
            model.CustomerName      = orderDetail.CustomerLocation.Name;
            model.OrderDetailId     = orderDetail.Id;
            model.Type                      = labelType;
            model.ItemCode                  = product.Upc;
            model.LotNumber                 = GetLotNumber(order.Id);
            model.Description               = product.EnglishDescription;
            model.ProcessDate               = order.ProcessDate ?? DateTime.Today;
            model.SlaughterDate             = order.SlaughterDate ?? DateTime.Today;
            model.BestBeforeDate            = order.BestBeforeDate ?? DateTime.Today.AddDays(45);
            model.SpeciesBugPath            = GetSpeciesBugPath(product);
            model.LogoPath                  = GetLogoPath(customer);
            model.BornInRegionName          = order.BornRegion.With(x => x.Name);
            model.RaisedInRegionName        = order.RaisedRegion.With(x => x.Name);
            model.ProductOfRegionName       = order.ProductOfRegion.With(x => x.Name);
            model.SlaughteredInRegionName   = order.SlaughteredRegion.With(x => x.Name);
            model.DistributedBy             = customer.DistributedBy;
            model.LabelFile                 = SetLabelFile(labelType, customer, false);
            model.GermanDescription         = product.GermanDescription;
            model.FrenchDescription         = product.FrenchDescription;
            model.ItalianDescription        = product.ItalianDescription;
            model.SwedishDescription        = product.SwedishDescription;
            model.Organic                   = GetOrganicPath(animalLabel != null && animalLabel.IsOrganic);
            model.SerialNumber              = (needSetSerialNumber) ? GetSerialNumber() : null;
            model.JulianProductionDate      = DateTime.Now.DayOfYear.ToString(CultureInfo.InvariantCulture).PadLeft(3, '0');
            model.VarCustomerJobValue       = order.AdditionalInfoOnLabel;
            model.AnimalName                = animalLabel != null ? animalLabel.Name : "";
            model.Species                   = (animalLabel != null && animalLabel.Species != null) ? animalLabel.Species.Name : "";
            model.NutritionDescription      = product.NutritionDescription;
            model.NutritionServingSize      = product.NutritionServingSize;
            model.NutritionServingContainer = product.NutritionServingContainer;
            model.NutritionCalories         = product.NutritionCalories;
            model.NutritionCaloriesFat      = product.NutritionCaloriesFat;
            model.NutritionTotalFat         = product.NutritionTotalFat;
            model.NutritionSatFat           = product.NutritionSatFat;
            model.NutritionTransFat         = product.NutritionTransFat;
            model.NutritionPolyFat          = product.NutritionPolyFat;
            model.NutritionMonoFat          = product.NutritionMonoFat;
            model.NutritionCholesterol      = product.NutritionCholesterol;
            model.NutritionSodium           = product.NutritionSodium;
            model.NutritionCarbs            = product.NutritionCarbs;
            model.NutritionProtein          = product.NutritionProtein;
            model.NutritionVitA             = product.NutritionVitA;
            model.NutritionVitC             = product.NutritionVitC;
            model.NutritionCalcium          = product.NutritionCalcium;
            model.NutritionIron             = product.NutritionIron;

            model.PackedFor     = customer.Name;
            model.Refrigeration = order.Refrigeration.Return(x => x.Name);
            model.Trim          = product.TrimCut.Return(x => x.Name);
            model.GradeName     = qualityGrade != null? qualityGrade.Name: "";

            model.CustomerProductCode = productData == null || productData.ProductCode == null
                ? product.Code
                : productData.ProductCode;
            model.PricePerPound = productData == null || productData.PricePerPound == null
                ? product.PricePerPound
                : productData.PricePerPound;
            model.Price = model.PricePerPound != null
                ? model.PricePerPound.Value *Convert.ToDecimal(model.PoundWeight)
                : (decimal?)null;

            model.Gtin = productData == null || productData.Gtin == null
                ? product.Gtin
                : productData.Gtin.Value;
            model.VarCustomerProductValue = productData == null || productData.ProductDescription == null
                ? null
                : productData.ProductDescription;

            model.Customer    = customer.Name;
            model.CustomerPO  = order.POCustomer;
            model.Printer     = SettingsManager.Current.Printer;
            model.WeighedDate = DateTime.Now;

            // todo (alexm): should be checked
            model.TareWeight = labelType == OmsLabelType.Box? GetBoxTareWeight(customCaseSize, orderDetail) : GetBagTareWeight(customCaseSize, orderDetail);

            return(model);
        }
Esempio n. 5
0
        private LabelOutputViewModel GetLabelLayoutViewModel(int orderDetailId, OmsLabelType labelType)
        {
            var orderDetail = _orderDetailRepository.Get(orderDetailId);
            var order       = orderDetail.Order;
            var product     = orderDetail.Product;

            _customerRepository.Detach(order.Customer);
            var customer = order.Customer;

            var model = new LabelOutputViewModel();
            var customerProductCode = product.CustomerProductCode.FirstOrDefault(cpc => cpc.CustomerId == orderDetail.Order.CustomerId);

            model.OrderDetailId  = orderDetailId;
            model.Type           = labelType;
            model.ItemCode       = product.Upc;
            model.LotNumber      = GetLotNumber(order);
            model.Description    = product.Description;
            model.ProcessDate    = order.ProcessDate ?? DateTime.Today;
            model.SlaughterDate  = order.SlaughterDate ?? DateTime.Today;
            model.BestBeforeDate = order.BestBeforeDate;
            model.SpeciesBugPath = GetSpeciesBugPath(product);

            switch (customer.LogoTypeId)
            {
            case OmsLogoType.None:
                model.LogoPath = SettingsManager.Current.NoLogoImageFileName;
                break;

            case OmsLogoType.Customer:
                model.LogoPath = customer.LogoFileName ?? SettingsManager.Current.NoLogoImageFileName;
                break;

            case OmsLogoType.DoubleJ:
                model.LogoPath = SettingsManager.Current.DoubleJLogoFileName;
                break;

            default:
                throw new IndexOutOfRangeException("Order.LogoTypeId");
            }
            model.BornInRegionName    = order.BornRegion.With(x => x.Name);
            model.RaisedInRegionName  = order.RaisedRegion.With(x => x.Name);
            model.ProductOfRegionName = order.ProductOfRegion.With(x => x.Name);
            model.DistributedBy       = customer.DistributedBy;

            model.LabelFile          = SetLabelFile(labelType, customer);
            model.GermanDescription  = product.GermanDescription;
            model.FrenchDescription  = product.FrenchDescription;
            model.ItalianDescription = product.ItalianDescription;
            model.SwedishDescription = product.SwedishDescription;

            model.Organic             = GetOrganicPath(product);
            model.SerialNumber        = GetSerialNumber();
            model.VarCustomerJobValue = order.AdditionalInfoOnLabel;

            model.Primal        = product.PrimalCut.Return(x => x.Name);
            model.SubPrimal     = product.SubPrimalCut.Return(x => x.Name);
            model.PackedFor     = customer.Name;
            model.Refrigeration = order.Refrigeration.Return(x => x.Name);
            model.Trim          = product.TrimCut.Return(x => x.Name);
            model.GradeName     = product.QualityGrade.Return(x => x.Name);

            model.CustomerProductCode = customerProductCode == null || customerProductCode.ProductCode == null
                ? product.Code
                : customerProductCode.ProductCode;

            model.VarCustomerProductValue = customerProductCode == null || customerProductCode.ProductDescription == null
                ? null
                : customerProductCode.ProductDescription;

            model.Customer = customer.Name;

            model.WeighedDate = DateTime.Now;
            return(model);
        }