public void Update(
            int id,
            string name,
            int packageDuesInMonth,
            bool isActive,
            bool isOpenEnd,
            decimal freezeFee,
            IEnumerable <PackageDetailViewModel> detail)
        {
            ctx.PackageDetails.DeleteAllOnSubmit(
                ctx.PackageDetails.Where(row => row.PackageID == id));

            PackageHeader head = ctx.PackageHeaders.Single(row => row.ID == id);

            head.Name = name;
            head.PackageDuesInMonth = packageDuesInMonth;
            head.IsActive           = isActive;
            head.OpenEnd            = isOpenEnd;
            head.FreezeFee          = freezeFee;
            EntityHelper.SetAuditFieldForUpdate(head, HttpContext.Current.User.Identity.Name);
            foreach (PackageDetailViewModel item in detail)
            {
                PackageDetail obj = new PackageDetail();
                obj.ItemID    = item.ItemID;
                obj.PackageID = item.PackageID;
                obj.Quantity  = item.Quantity;
                obj.UnitPrice = item.UnitPrice;
                head.PackageDetails.Add(obj);
                ctx.PackageDetails.InsertOnSubmit(obj);
            }
            ctx.SubmitChanges();
        }
Beispiel #2
0
        public void Update(
            int id,
            string name,
            int packageDuesInMonth,
            bool isActive,
            bool isOpenEnd,
            decimal freezeFee,
            IEnumerable <PackageDetailViewModel> detail)
        {
            context.Delete(
                context.PackageDetails.Where(row => row.PackageID == id));

            PackageHeader head = context.PackageHeaders.Single(row => row.ID == id);

            head.Name = name;
            head.PackageDuesInMonth = packageDuesInMonth;
            head.IsActive           = isActive;
            head.OpenEnd            = isOpenEnd;
            head.FreezeFee          = freezeFee;
            EntityHelper.SetAuditFieldForUpdate(head, principal.Identity.Name);
            foreach (PackageDetailViewModel detailLine in detail)
            {
                var obj = new PackageDetail();
                obj.ItemID        = detailLine.ItemID;
                obj.PackageID     = detailLine.PackageID;
                obj.Quantity      = detailLine.Quantity;
                obj.UnitPrice     = detailLine.UnitPrice;
                obj.UnitName      = detailLine.UnitName;
                obj.PackageHeader = head;
                context.Add(obj);
            }
            context.SaveChanges();
        }
Beispiel #3
0
        static List <NuGetSearchMainDependencyGroup> CreateDepGroups(PackageDetail pd)
        {
            List <NuGetSearchMainDependencyGroup> newDepGroups = new List <NuGetSearchMainDependencyGroup>();

            if (pd.Dependencies == null || pd.Dependencies.Count == 0)
            {
                return(null);
            }

            foreach (var depGroup in pd.Dependencies)
            {
                var newDepGroup = new NuGetSearchMainDependencyGroup();

                newDepGroup.TargetFramework = depGroup.TargetFramework;
                newDepGroup.Dependencies    = new List <NuGetSearchMainDependency>();

                if (depGroup.Dependencies != null && depGroup.Dependencies.Count > 0)
                {
                    foreach (var dep in depGroup.Dependencies)
                    {
                        var newDep = new NuGetSearchMainDependency
                        {
                            Name         = dep.PackageName,
                            VersionRange = dep.Range
                        };
                        newDepGroup.Dependencies.Add(newDep);
                    }
                }

                newDepGroups.Add(newDepGroup);
            }

            return(newDepGroups);
        }
Beispiel #4
0
        /// <summary>
        /// Delte shipment Information from packingDetails table and Packing table
        /// </summary>
        /// <param name="ShippingNum">String ShipmentID</param>
        /// <returns>If sucess then true else false</returns>
        public Boolean DeleteShipment(Guid PackingID)
        {
            Boolean _return = false;

            try
            {
                //Delete from Packing Detail table first.
                var _PackingDetails = from _PckDetails in entx3v6.PackageDetails
                                      where _PckDetails.PackingId == PackingID
                                      select _PckDetails;

                foreach (var _PackingDetailsitem in _PackingDetails)
                {
                    PackageDetail _packDetails = entx3v6.PackageDetails.SingleOrDefault(i => i.PackingDetailID == _PackingDetailsitem.PackingDetailID);
                    entx3v6.PackageDetails.DeleteObject(_packDetails);
                }
                entx3v6.SaveChanges();
                // delete from the Packing table
                Package _packing = entx3v6.Packages.SingleOrDefault(i => i.PackingId == PackingID);
                entx3v6.Packages.DeleteObject(_packing);
                entx3v6.SaveChanges();

                _return = true;
            }
            catch (Exception Ex)
            {
                elAction.save("DeleteShipmentInfo.DeleteShipment()", Ex.ToString());
            }
            return(_return);
        }
        public PostageLabel GetPostageLabel(PackageDetail packageDetail)
        {
            // create request object
            var requestObject = RequestHelper.CreateLabelRequest(packageDetail);

            // send the request to change the passphrase
            var response = SoapHelper.ProcessRequest <LabelRequestResponse>(requestObject);

            if (response.Status != 0)
            {
                return new PostageLabel {
                           ErrorMessage = response.ErrorMessage
                }
            }
            ;

            return(new PostageLabel
            {
                Base64LabelImage = response.Base64LabelImage,
                TrackingNumber = response.TrackingNumber,
                TransactionId = response.TransactionID,
                TransactionDateTime = response.TransactionDateTime,
                PostmarkDate = response.PostmarkDate,
                PostageBalance = response.PostageBalance,
                PostageTotalPrice = response.PostagePrice.TotalAmount
            });
        }
    }
Beispiel #6
0
        public void Add(
            string name,
            int packageDuesInMonth,
            bool isActive,
            bool isOpenEnd,
            decimal freezeFee,
            IEnumerable <PackageDetailViewModel> detail)
        {
            var head = new PackageHeader();

            head.Name = name;
            head.PackageDuesInMonth = packageDuesInMonth;
            head.IsActive           = isActive;
            head.OpenEnd            = isOpenEnd;
            head.FreezeFee          = freezeFee;
            EntityHelper.SetAuditFieldForInsert(head, principal.Identity.Name);
            context.Add(head);
            foreach (PackageDetailViewModel detailLine in detail)
            {
                var obj = new PackageDetail();
                obj.ItemID        = detailLine.ItemID;
                obj.PackageID     = detailLine.PackageID;
                obj.Quantity      = detailLine.Quantity;
                obj.UnitPrice     = detailLine.UnitPrice;
                obj.UnitName      = detailLine.UnitName;
                obj.PackageHeader = head;
                context.Add(obj);
            }
            context.SaveChanges();
        }
Beispiel #7
0
        public void SavePackageDetail(Sender sender, SavePackageDetailArgs args)
        {
            try
            {
                using (ObjectProxy op = new ObjectProxy(true))
                {
                    if (args.PackageDetail != null)
                    {
                        PackageDetail obj = new PackageDetail();
                        obj.DetailID = args.PackageDetail.DetailID;
                        if (op.LoadPackageDetailByDetailID(obj) == 0)
                        {
                            args.PackageDetail.Created    = DateTime.Now;
                            args.PackageDetail.CreatedBy  = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                            args.PackageDetail.Modified   = DateTime.Now;
                            args.PackageDetail.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                            op.InsertPackageDetail(args.PackageDetail);
                        }
                        else
                        {
                            args.PackageDetail.Modified   = DateTime.Now;
                            args.PackageDetail.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                            op.UpdatePackageDetailByDetailID(args.PackageDetail);
                        }
                    }

                    if (args.PackageDetails != null)
                    {
                        foreach (PackageDetail item in args.PackageDetails)
                        {
                            PackageDetail subobj = new PackageDetail();
                            subobj.DetailID = item.DetailID;
                            if (op.LoadPackageDetailByDetailID(subobj) == 0)
                            {
                                item.Created    = DateTime.Now;
                                item.CreatedBy  = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                                item.Modified   = DateTime.Now;
                                item.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                                op.InsertPackageDetail(item);
                            }
                            else
                            {
                                item.Modified   = DateTime.Now;
                                item.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                                op.UpdatePackageDetailByDetailID(item);
                            }
                        }
                    }
                    op.CommitTransaction();
                }
            }
            catch (Exception ex)
            {
                PLogger.LogError(ex);
                throw ex;
            }
        }
Beispiel #8
0
        internal static PackageDetail GetPackageDetail(PackageInfo packageInfo)
        {
            var packageDetail = new PackageDetail
            {
                Id   = packageInfo.PackageId,
                Size = GetPackageSize(packageInfo.Size)
            };

            return(packageDetail);
        }
Beispiel #9
0
 public static LabelRequest CreateLabelRequest(PackageDetail detail)
 {
     return(new LabelRequest
     {
         Test = (_mode == "LIVE" ? "NO" : "YES"),
         RequesterID = _requesterId, // test requester id
         AccountID = _accountId,
         PassPhrase = _passPhrase,
         MailClass = detail.MailClass.ToString(),
         WeightOz = (double)detail.ItemDimension.Weight.Value, // Must be greater than zero and cannot exceed 1120 ounces (70 pounds).
         //MailpieceDimensions = new Dimensions // optional
         //{
         //    Length = (double)detail.ItemDimension.Length.Value,
         //    Width = (double)detail.ItemDimension.Width.Value,
         //    Height = (double)detail.ItemDimension.Height.Value
         //},
         ValidateAddress = "TRUE",
         IncludePostage = "TRUE",
         ShowReturnAddress = "TRUE",
         Description = "Test request label",
         ReferenceID = detail.OrderId,
         PartnerCustomerID = detail.RequestedBy,
         PartnerTransactionID = detail.OrderItemId,
         FromName = detail.FromName,
         FromCompany = detail.FromCompany,
         ReturnAddress1 = detail.FromAddress.Line1,
         ReturnAddress2 = detail.FromAddress.Line2,
         FromCity = detail.FromAddress.City,
         FromState = detail.FromAddress.StateOrRegion,
         FromCountryCode = detail.FromAddress.CountryCode,
         FromPostalCode = detail.FromAddress.PostalCode,
         FromPhone = detail.FromPhone,
         FromEMail = detail.FromEmail,
         ToName = detail.ToName,
         ToCompany = detail.ToCompany,
         ToAddress1 = detail.ToAddress.Line1,
         ToAddress2 = detail.ToAddress.Line2,
         ToCity = detail.ToAddress.City,
         ToState = detail.ToAddress.StateOrRegion,
         ToCountryCode = detail.ToAddress.CountryCode,
         ToPostalCode = detail.ToAddress.PostalCode,
         ToEMail = detail.ToEmail,
         ToPhone = detail.ToPhone,
         ResponseOptions = new ResponseOptions
         {
             PostagePrice = "TRUE"
         }
     });
 }
Beispiel #10
0
 public ActionResult Create(PackageModel model)
 {
     if (model.PackageDetailList == null)
     {
         TempData["message"] = "Add items to package !!";
         return(View());
     }
     if (ent.PackageMasters.Any(x => x.PackageName == model.PackageName))
     {
         TempData["message"] = "Package with this name already exits !!";
         return(View(model));
     }
     try
     {
         var obj = AutoMapper.Mapper.Map <PackageModel, PackageMaster>(model);
         obj.Status      = true;
         obj.Vat         = Convert.ToDecimal(0);
         obj.VatAmount   = Convert.ToDecimal(0);
         obj.CreatedBy   = Utility.GetCurrentLoginUserId();
         obj.CreatedDate = DateTime.Now;
         ent.PackageMasters.Add(obj);
         ent.SaveChanges();
         foreach (var item in model.PackageDetailList)
         {
             var detail = new PackageDetail();
             detail.PackageId = obj.PackageId;
             detail.DeptId    = item.DeptId;
             detail.TestId    = item.TestId;
             if (item.DeptId == 1006)
             {
                 detail.SectionId = (int)ent.SetupPathoTests.Where(x => x.TestId == item.TestId).SingleOrDefault().SectionId;
             }
             else
             {
                 detail.SectionId = 0;
             }
             detail.Status = true;
             ent.PackageDetails.Add(detail);
         }
         ent.SaveChanges();
         TempData["message"] = "Package created successfully !!";
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Beispiel #11
0
        public void Should_Get_Postage_Label()
        {
            // arrange
            var dimension     = new Dimension(4, 2, 1, 2m);
            var packageDetail = new PackageDetail
            {
                RequestedBy = "unit_test_user",
                EisOrderId  = 123,
                OrderId     = "10000001",
                OrderItemId = "10000001-XXX-123",
                MailClass   = MailClass.PriorityExpress,
                FromName    = "CRIS DUANE GENITA",
                //FromCompany = "ALL ISLAND PACKAGE",
                FromAddress = new Address
                {
                    Line1         = "BUENAVISTA UABY BOHOL",
                    Line2         = "MANLAYAG DANAO CITY",
                    City          = "TAGBILARAN CITY",
                    StateOrRegion = "NY",
                    CountryCode   = "US",
                    PostalCode    = "10001"
                },
                FromPhone = "5045838417",
                FromEmail = "*****@*****.**",
                ToName    = "STATEFARM GISELE PLESSY",
                ToCompany = "TAGA COMPANY ABC",
                ToAddress = new Address
                {
                    Line1         = "6325 ELYSIAN FIELDS AVE STE A",
                    City          = "NEW ORLEANS",
                    StateOrRegion = "LA",
                    CountryCode   = "US",
                    PostalCode    = "55435",
                },
                ToPhone       = "504-583-8417",
                ToEmail       = "*****@*****.**",
                ItemDimension = dimension
            };
            var logger   = new LogService();
            var provider = new EndiciaLabelProvider(logger);

            // act
            var response = provider.GetPostageLabel(packageDetail);

            // assert
            Assert.NotNull(response);
        }
Beispiel #12
0
 public ActionResult Edit(int id, PackageModel model)
 {
     try
     {
         // TODO: Add update logic here
         var obj = ent.PackageMasters.Where(x => x.PackageId == id).SingleOrDefault();
         AutoMapper.Mapper.Map(model, obj);
         obj.Status           = true;
         obj.Vat              = Convert.ToDecimal(0);
         obj.VatAmount        = Convert.ToDecimal(0);
         ent.Entry(obj).State = System.Data.EntityState.Modified;
         foreach (var item in ent.PackageDetails.Where(x => x.PackageId == id).ToList())
         {
             ent.PackageDetails.Remove(item);
         }
         foreach (var item in model.PackageDetailList)
         {
             var detail = new PackageDetail();
             detail.PackageId = id;
             detail.DeptId    = item.DeptId;
             detail.TestId    = item.TestId;
             if (item.DeptId == 1006)
             {
                 detail.SectionId = (int)ent.SetupPathoTests.Where(x => x.TestId == item.TestId).SingleOrDefault().SectionId;
             }
             else
             {
                 detail.SectionId = 0;
             }
             detail.Status = true;
             ent.PackageDetails.Add(detail);
         }
         ent.SaveChanges();
         TempData["message"] = "Package updated successfully !!";
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         return(View());
     }
 }
Beispiel #13
0
 public PackageDetail GetPackageDetail(Sender sender, Guid DetailID)
 {
     try
     {
         using (ObjectProxy op = new ObjectProxy())
         {
             PackageDetail obj = new PackageDetail();
             obj.DetailID = DetailID;
             if (op.LoadPackageDetailByDetailID(obj) == 0)
             {
                 return(null);
             }
             return(obj);
         }
     }
     catch (Exception ex)
     {
         PLogger.LogError(ex);
         throw ex;
     }
 }
        /// <summary>
        /// Save the list values to the packing Detail table.
        /// </summary>
        /// <param name="lsPackingOb">list of values of packing Detail </param>
        /// <returns>Success if transaction Success else Fail.</returns>
        public string savePackageDetails(List <cstPackageDetails> lsPackingOb)
        {
            string Retuen = "Fail";

            try
            {
                foreach (var _PakingDetails in lsPackingOb)
                {
                    PackageDetail _Packing = new PackageDetail();
                    _Packing.PackingDetailID  = _PakingDetails.PackingDetailID;
                    _Packing.PackingId        = _PakingDetails.PackingId;
                    _Packing.SKUNumber        = _PakingDetails.SKUNumber;
                    _Packing.SKUQuantity      = _PakingDetails.SKUQuantity;
                    _Packing.SKUScanDateTime  = Convert.ToDateTime(_PakingDetails.PackingDetailStartDateTime);
                    _Packing.BoxNumber        = _PakingDetails.BoxNumber;
                    _Packing.ShipmentLocation = _PakingDetails.ShipmentLocation;

                    //view added extra
                    _Packing.ItemName        = _PakingDetails.ItemName;
                    _Packing.ProductName     = _PakingDetails.ProductName;
                    _Packing.UnitOfMeasure   = _PakingDetails.UnitOfMeasure;
                    _Packing.CountryOfOrigin = _PakingDetails.CountryOfOrigin;
                    _Packing.MAP_Price       = _PakingDetails.MAP_Price;
                    _Packing.TCLCOD_0        = _PakingDetails.TCLCOD_0;
                    _Packing.TarrifCode      = _PakingDetails.TarrifCode;
                    //created Time set
                    _Packing.CreatedDateTime = DateTime.UtcNow;
                    _Packing.CreatedBy       = GlobalClasses.ClGlobal.UserID;
                    entx3v6.AddToPackageDetails(_Packing);
                }
                entx3v6.SaveChanges();
                Retuen = "Success";
            }
            catch (Exception Ex)
            {
                Error_Loger.elAction.save("SetPakingDetailsCommand.Execute()", Ex.Message.ToString());
            }
            return(Retuen);
        }
Beispiel #15
0
        public ActionResult ExportToExcel(BoxQueryViewModel model)
        {
            IList <PackageDetail> lstPackageDetail = new List <PackageDetail>();

            PackageViewModel m = new PackageViewModel();

            using (PackageQueryServiceClient client = new PackageQueryServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    OrderBy = "Key.PackageNo,ItemNo",
                    Where   = GetQueryCondition(model)
                };
                MethodReturnResult <IList <PackageDetail> > result = client.GetDetail(ref cfg);

                if (result.Code == 0)
                {
                    lstPackageDetail = result.Data;
                }
            }

            //创建工作薄。
            IWorkbook wb = new HSSFWorkbook();
            //设置EXCEL格式
            ICellStyle style = wb.CreateCellStyle();

            style.FillForegroundColor = 10;
            //有边框
            style.BorderBottom = BorderStyle.THIN;
            style.BorderLeft   = BorderStyle.THIN;
            style.BorderRight  = BorderStyle.THIN;
            style.BorderTop    = BorderStyle.THIN;
            IFont font = wb.CreateFont();

            font.Boldweight = 10;
            style.SetFont(font);

            ISheet ws = null;

            for (int j = 0; j < lstPackageDetail.Count; j++)
            {
                if (j % 65535 == 0)
                {
                    ws = wb.CreateSheet();
                    IRow row = ws.CreateRow(0);
                    #region //列名
                    ICell cell = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(StringResource.ItemNo);  //序号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(ZPVCResources.StringResource.BoxViewModel_BoxNo);

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("项目号");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_PackageNo);

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_OrderNumber);

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_MaterialCode);

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("产品编号");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_Code);

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_Qty);


                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_Name);

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_Grade);

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_Color);

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_PNType);

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(ZPVCResources.StringResource.PackageViewModel_LineCode);

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("装箱时间");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("操作人");

                    #endregion
                    font.Boldweight = 5;
                }

                PackageDetail obj            = lstPackageDetail[j];
                IRow          rowData        = ws.CreateRow(j + 1);
                Package       packageObj     = m.GetPackage(obj.Key.ObjectNumber);
                PackageInfo   packageInfoObj = m.GetPackageInfo(obj.Key.ObjectNumber);
                //ProductionLine plObj = m.GetProductionLine(packageInfoObj.LineCode);

                #region //数据
                ICell cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(j + 1);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.Key.PackageNo);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.ItemNo);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.Key.ObjectNumber);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.OrderNumber);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.MaterialCode);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(packageInfoObj != null ? packageInfoObj.ProductId : string.Empty);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(packageInfoObj != null ? packageInfoObj.ConfigCode : string.Empty);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(packageObj != null ? packageObj.Quantity : 0);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(packageInfoObj != null ? packageInfoObj.EfficiencyName : string.Empty);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(packageInfoObj != null ? packageInfoObj.Grade : string.Empty);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(packageInfoObj != null ? packageInfoObj.Color : string.Empty);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(packageInfoObj != null ? packageInfoObj.PNType : string.Empty);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(packageInfoObj != null ? packageInfoObj.LineCode : string.Empty);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(string.Format("{0:yyyy-MM-dd HH:mm:ss}", obj.CreateTime));

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.Creator);
                #endregion
            }

            MemoryStream ms = new MemoryStream();
            wb.Write(ms);
            ms.Flush();
            ms.Position = 0;
            return(File(ms, "application/vnd.ms-excel", "BoxData.xls"));
        }
Beispiel #16
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.listPackage.Items.Count == 0)
                {
                    throw new Exception("未添加任何包数据。");
                }
                using (ProxyBE bll = new ProxyBE())
                {
                    Order order = bll.Client.GetOrder(CGlobal.SenderUser, OrderID);
                    //订单添加板件明细
                    List <OrderDetail> suborders = new List <OrderDetail>();

                    List <OrderDetail> details = bll.Client.GetOrderDetails(CGlobal.SenderUser, OrderID);
                    Order2Cabinet      cabinet = bll.Client.GetOrder2Cabinet(CGlobal.SenderUser, this.CabinetID);
                    int itemsQty = 1;
                    foreach (ListViewItem li in this.listPackage.Items)
                    {
                        int Qty = int.Parse(li.SubItems[2].Text);
                        for (int i = 0; i < Qty; i++)
                        {
                            OrderDetail subOrder = new OrderDetail();
                            subOrder.ItemID           = Guid.NewGuid();
                            subOrder.OrderID          = this.OrderID;
                            subOrder.BarcodeNo        = order.OrderNo + ((char)(64 + cabinet.Sequence)).ToString() + (itemsQty + details.Count + 50).ToString("000");
                            subOrder.ItemName         = li.SubItems[1].Text;
                            subOrder.MadeBattchNum    = "";
                            subOrder.MaterialType     = "";
                            subOrder.MadeLength       = 0;
                            subOrder.MadeWidth        = 0;
                            subOrder.MadeHeight       = 0;
                            subOrder.Qty              = 1;
                            subOrder.TextureDirection = "";
                            subOrder.Edge1            = "";
                            subOrder.Edge2            = "";
                            subOrder.Edge3            = "";
                            subOrder.Edge4            = "";
                            subOrder.HoleDesc         = "";
                            subOrder.EndLength        = 0;
                            subOrder.EndWidth         = 0;
                            subOrder.FrontLabel       = "";
                            subOrder.BackLabel        = "";
                            subOrder.PackageCategory  = "";
                            subOrder.PackageSizeType  = "";
                            subOrder.IsSpecialShap    = false;
                            subOrder.CabinetID        = this.CabinetID;
                            subOrder.Remarks          = "";
                            subOrder.EdgeDesc         = "";
                            subOrder.DamageQty        = 0;
                            subOrder.Created          = DateTime.Now;
                            suborders.Add(subOrder);

                            Mes.Client.Service.BE.Package p = new Mes.Client.Service.BE.Package();
                            p.OrderID = OrderID;
                            int pageNum = bll.Client.GetMaxPackageNum(CGlobal.SenderUser, OrderID, subOrder.CabinetID);
                            p.CabinetID      = subOrder.CabinetID;
                            p.PackageNum     = pageNum;
                            p.PackageBarcode = string.Format("0{0}{1}", order.Created.ToString("yyMMddHHmmss"), pageNum.ToString("00"));
                            p.PackageID      = Guid.NewGuid();
                            p.ItemsQty       = 1;

                            //保存条码数据
                            PackageDetail obj = new PackageDetail();
                            obj.DetailID    = Guid.NewGuid();
                            obj.ItemID      = subOrder.ItemID;
                            obj.PakageID    = p.PackageID;
                            obj.IsPlanning  = true;
                            obj.IsPakaged   = true;
                            obj.IsDisabled  = false;
                            obj.IsOptimized = true;
                            obj.LayerNum    = 0;
                            obj.Qty         = 1;
                            obj.CheckedBy   = CGlobal.SenderUser.UserCode + "." + CGlobal.SenderUser.UserName;

                            SavePackageArgs saveArgs = new SavePackageArgs();
                            saveArgs.Package = p;

                            PackageDetail detail = new PackageDetail();
                            detail.DetailID = Guid.NewGuid();

                            detail.CheckedBy       = CGlobal.SenderUser.UserCode;
                            detail.IsDisabled      = false;
                            detail.IsOptimized     = true;
                            detail.IsPakaged       = true;
                            detail.IsPlanning      = true;
                            detail.ItemID          = subOrder.ItemID;
                            detail.LayerNum        = 0;
                            detail.PakageID        = obj.PakageID;
                            detail.Qty             = 1;
                            saveArgs.PackageDetail = detail;
                            bll.Client.SavePackage(CGlobal.SenderUser, saveArgs);

                            itemsQty++;
                        }
                    }
                    SaveOrderArgs saveOrderArgs = new SaveOrderArgs();
                    saveOrderArgs.Order        = order;
                    saveOrderArgs.OrderDetails = suborders;
                    bll.Client.SaveOrder(CGlobal.SenderUser, saveOrderArgs);
                }

                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        public async Task <ActionResult> ExportToExcel(LotPackageQueryViewModel model)
        {
            IList <PackageDetail> lstLotPackage = new List <PackageDetail>();

            ZPVMLotPackageViewModel m = new ZPVMLotPackageViewModel();

            using (PackageQueryServiceClient client = new PackageQueryServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        OrderBy  = "Key.PackageNo,ItemNo",
                        Where    = GetQueryCondition(model)
                    };
                    MethodReturnResult <IList <PackageDetail> > result = client.GetDetail(ref cfg);

                    if (result.Code == 0)
                    {
                        lstLotPackage = result.Data;
                    }
                });
            }
            //创建工作薄。
            IWorkbook wb = new HSSFWorkbook();
            //设置EXCEL格式
            ICellStyle style = wb.CreateCellStyle();

            style.FillForegroundColor = 10;
            //有边框
            style.BorderBottom = BorderStyle.Thin;
            style.BorderLeft   = BorderStyle.Thin;
            style.BorderRight  = BorderStyle.Thin;
            style.BorderTop    = BorderStyle.Thin;
            IFont font = wb.CreateFont();

            font.Boldweight = 10;
            style.SetFont(font);

            ISheet ws = null;

            for (int j = 0; j < lstLotPackage.Count; j++)
            {
                if (j % 65535 == 0)
                {
                    ws = wb.CreateSheet();
                    IRow row = ws.CreateRow(0);
                    #region //列名
                    ICell cell = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(StringResource.ItemNo);  //项目号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("包装号");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("项目号");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("批次号");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("工单号");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("物料编码");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("等级");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("花色");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("功率");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("电流");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("最大电流");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("电压");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("最大电压");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("填充因子");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("分档名称");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("子分档代码");

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("包装日期");
                    #endregion
                    font.Boldweight = 5;
                }
                PackageDetail obj     = lstLotPackage[j];
                IRow          rowData = ws.CreateRow(j + 1);
                Lot           lot     = m.GetLotData(obj.Key.ObjectNumber);
                IVTestData    ivtest  = m.GetIVTestData(obj.Key.ObjectNumber);
                List <string> dic     = null;
                string        ff      = "";
                OemData       oemData = m.GetOemData(obj.Key.ObjectNumber);
                if (oemData != null)
                {
                    dic = m.GetCodeAndItemNo(oemData);
                    ff  = (oemData.FF * 100).ToString("F4");
                }
                else
                {
                    lot    = m.GetLotData(obj.Key.ObjectNumber);
                    ivtest = m.GetIVTestData(obj.Key.ObjectNumber);
                }

                #region //数据
                ICell cellData = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(j + 1);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.Key.PackageNo);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.ItemNo);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.Key.ObjectNumber);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.OrderNumber);

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(obj.MaterialCode);

                if (oemData != null)
                {
                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(oemData.Grade);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(oemData.Color);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(oemData.PMAX);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(oemData.ISC);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(oemData.IPM);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(oemData.VOC);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(oemData.VPM);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ff);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(oemData.PnName == null ? string.Empty : oemData.PnName);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(oemData.PsSubCode);
                }
                else
                {
                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(lot != null ? lot.Grade : string.Empty);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(lot != null ? lot.Color : string.Empty);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtest != null ? ivtest.CoefPM : 0);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtest != null ? ivtest.CoefISC : 0);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtest != null ? ivtest.CoefIPM : 0);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtest != null ? ivtest.CoefVOC : 0);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtest != null ? ivtest.CoefVPM : 0);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtest != null ? ivtest.CoefFF : 0);

                    string powerName = string.Empty;
                    if (ivtest != null &&
                        !string.IsNullOrEmpty(ivtest.PowersetCode) &&
                        ivtest.PowersetItemNo != null)
                    {
                        powerName = m.GetPowersetName(ivtest.Key.LotNumber, ivtest.PowersetCode, ivtest.PowersetItemNo.Value);
                    }
                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(powerName);

                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    cellData.SetCellValue(ivtest != null ? ivtest.PowersetSubCode : string.Empty);
                }

                cellData           = rowData.CreateCell(rowData.Cells.Count);
                cellData.CellStyle = style;
                cellData.SetCellValue(string.Format("{0:yyyy-MM-dd}", obj.CreateTime));
                #endregion
            }

            MemoryStream ms = new MemoryStream();
            wb.Write(ms);
            ms.Flush();
            ms.Position = 0;
            return(File(ms, "application/vnd.ms-excel", "LotPackageData.xls"));
        }
Beispiel #18
0
        private void ScanBarcode()
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new dreadbarcode(ScanBarcode), null);
            }
            else
            {
                if (WorkFlowID == Guid.Empty)
                {
                    throw new Exception("请在参数设置中设置班次和分拣对应的工序名称。");
                }
                if (WorkShiftID == Guid.Empty)
                {
                    throw new Exception("请在参数设置中设置班次和分拣对应的工序名称。");
                }
                string ItemBarcode = this.txtBarcode.Text.Trim();
                if (string.IsNullOrEmpty(ItemBarcode))
                {
                    this.txtBarcode.Clear();
                    this.txtBarcode.Focus();
                    lblMsg.Text = "【提示】请扫描板件条码";
                    PlayVoice("请扫描板件条码");
                    return;
                }
                #region 完成当前分包操作
                if (ItemBarcode.IndexOf(FinishedBarcode) >= 0 && !string.IsNullOrEmpty(FinishedBarcode))
                {
                    try
                    {
                        //打印分包标签
                        PlayVoice("打印标签");
                        //PrintDocument();
                        StartPrint(this.CurrentPackage.PackageID);
                        this.txtBarcode.Text = "";
                        this.txtBarcode.Focus();
                        this.CurrentPackage = null;
                    }
                    catch (Exception ex)
                    {
                        this.CurrentPackage = null;
                        throw ex;
                    }
                    return;
                }
                #endregion

                using (ProxyBE p = new ProxyBE())
                {
                    OrderDetail subOrder = p.Client.GetOrderDetailByBarcode(CGlobal.SenderUser, ItemBarcode);
                    if (subOrder == null)
                    {
                        this.txtBarcode.Clear();
                        this.txtBarcode.Focus();
                        lblMsg.Text = string.Format("提示:【{0}】条码无效", ItemBarcode);
                        PlayVoice("条码错误");
                        return;
                    }

                    Order order = p.Client.GetOrder(CGlobal.SenderUser, subOrder.OrderID);
                    //初始化订单数据:如果当前订单ID与条码的订单ID不一至时则重置订单信息
                    if (CurrentOrder == null)
                    {
                        this.CurrentOrder    = order;
                        this.txtOrderNo.Text = this.CurrentOrder.OrderNo;
                    }
                    //判断当前的板件是否为同一订单板件
                    else if (subOrder.OrderID != this.CurrentOrder.OrderID)
                    {
                        this.txtBarcode.Clear();
                        this.txtBarcode.Focus();
                        lblMsg.Text = "【错误】板件订单号不一致";
                        PlayVoice("订单不一致");
                        MessageBox.Show("板件订单号不一致");
                        return;
                    }

                    List <PackageDetail> pdsubOrder = p.Client.GetPackageDetailsByItemID(CGlobal.SenderUser, subOrder.ItemID);
                    pdsubOrder = pdsubOrder.FindAll(li => li.IsPakaged == false);
                    if (pdsubOrder.Count == 0)
                    {
                        this.txtBarcode.Clear();
                        this.txtBarcode.Focus();
                        lblMsg.Text = string.Format("提示:【{0}】条码重复扫描", ItemBarcode);
                        PlayVoice("重复扫描");
                        return;
                    }


                    decimal weight = subOrder.MadeHeight * subOrder.MadeLength * subOrder.MadeWidth * 0.000001M * Density;
                    if (this.CurrentPackage != null)
                    {
                        if (this.CurrentPackage.Weight + weight >= MaxWeight)
                        {
                            //打印分包标签
                            PlayVoice("打印标签");
                            StartPrint(this.CurrentPackage.PackageID);
                            this.txtBarcode.Text = "";
                            this.txtBarcode.Focus();
                            this.CurrentPackage = null;
                        }
                    }

                    Order2Cabinet cabinet = p.Client.GetOrder2Cabinet(CGlobal.SenderUser, subOrder.CabinetID);
                    if (cabinet != null)
                    {
                        //初始化包数据
                        if (this.CurrentPackage == null)
                        {
                            Mes.Client.Service.BE.Package pack = new Mes.Client.Service.BE.Package();
                            pack.OrderID = this.CurrentOrder.OrderID;
                            int pageNum = 0;
                            pageNum                  = p.Client.GetMaxPackageNum(CGlobal.SenderUser, pack.OrderID, subOrder.CabinetID);
                            pack.CabinetID           = subOrder.CabinetID;
                            pack.PackageNum          = pageNum;
                            pack.PackageID           = Guid.NewGuid();
                            pack.PackageBarcode      = string.Format("0{0}{1}", CurrentOrder.Created.ToString("yyMMddHHmmss"), pageNum.ToString("00"));
                            pack.PackageLength       = 0;
                            pack.PackageHeight       = 0;
                            pack.PackageWidth        = 0;
                            pack.ItemsQty            = 0;
                            this.CurrentPackage      = pack;
                            this.txtCabinetName.Text = cabinet.CabinetName;
                        }
                        else if (CurrentPackage.CabinetID != cabinet.CabinetID)
                        {
                            this.txtBarcode.Clear();
                            this.txtBarcode.Focus();
                            lblMsg.Text = "【错误】柜体不一致!";
                            PlayVoice("柜体不一致");
                            return;
                        }
                    }
                    else
                    {
                        lblMsg.Text = string.Format("提示:【{0}】条码所属柜体数据丢失,请查看订单是否有误!", ItemBarcode);
                        PlayVoice("订单错误");
                        return;
                    }


                    try
                    {
                        p.Client.ScanBarcode(CGlobal.SenderUser, ItemBarcode, WorkShiftID, WorkFlowID);
                    }
                    catch (Exception ex)
                    {
                        PLogger.LogError(ex);
                        this.txtBarcode.Clear();
                        this.txtBarcode.Focus();
                        lblMsg.Text = ex.Message;
                        PlayVoice("扫描失败");
                        return;
                    }

                    this.CurrentPackage.Weight   += weight;
                    this.CurrentPackage.ItemsQty += 1;

                    SavePackageArgs saveArgs = new SavePackageArgs();
                    saveArgs.Package = this.CurrentPackage;
                    PackageDetail packageDetail = pdsubOrder[0];
                    packageDetail.IsPakaged = true;
                    packageDetail.PakageID  = this.CurrentPackage.PackageID;
                    saveArgs.PackageDetail  = packageDetail;
                    p.Client.SavePackage(CGlobal.SenderUser, saveArgs);

                    this.CurrentPackage = p.Client.GetPackage(CGlobal.SenderUser, this.CurrentPackage.PackageID);
                    this.gbPackage.Text = string.Format("当前:第{0}包", this.CurrentPackage.PackageNum);

                    //刷新列表
                    biForm();
                    this.txtBarcode.Clear();
                    this.txtBarcode.Focus();
                    lblMsg.Text = "扫描完成";
                    PlayVoice("OK");

                    //检查是否已经全部扫描完成
                    if (this.listBarcodes.Items.Count == 0)
                    {
                        //打印分包标签
                        PlayVoice("打印标签");
                        //PrintDocument();
                        StartPrint(this.CurrentPackage.PackageID);
                        this.txtBarcode.Text = "";
                        this.txtBarcode.Focus();
                        this.CurrentPackage = null;

                        cabinet.CabinetStatus = "F";
                        SaveOrder2CabinetArgs cabinetArgs = new SaveOrder2CabinetArgs();
                        cabinetArgs.Order2Cabinet = cabinet;
                        p.Client.SaveOrder2Cabinet(CGlobal.SenderUser, cabinetArgs);

                        SearchPackageDetailArgs p_args = new SearchPackageDetailArgs();
                        p_args.IsDisabled = false;
                        p_args.OrderID    = CurrentOrder.OrderID;
                        p_args.IsPakaged  = false;

                        SearchResult p_sr = p.Client.SearchPackageDetail(CGlobal.SenderUser, p_args);
                        if (p_sr.Total == 0)
                        {
                            //Order order = p.Client.GetOrder(CGlobal.SenderUser, CurrentOrder.OrderID);
                            order.Status = "I"; //全部打包完成后,订单状态变成待入库
                            SaveOrderArgs saveOrderArgs = new SaveOrderArgs();
                            saveOrderArgs.Order = order;
                            p.Client.SaveOrder(CGlobal.SenderUser, saveOrderArgs);
                        }
                    }
                    //加载树
                    initTree();
                }
            }
        }
Beispiel #19
0
        public void CreatedScheduling(Sender sender, SaveCreatedSchedulingArgs args)
        {
            try
            {
                using (ObjectProxy op = new ObjectProxy(true))
                {
                    #region 部件工序
                    if (args.OrderWorkFlows != null)
                    {
                        foreach (OrderWorkFlow workflow in args.OrderWorkFlows)
                        {
                            OrderWorkFlow ow = new OrderWorkFlow();
                            ow.WorkingID = workflow.WorkingID;
                            if (op.LoadOrderWorkFlowByWorkingID(ow) == 0)
                            {
                                op.InsertOrderWorkFlow(workflow);
                            }
                            else
                            {
                                op.UpdateOrderWorkFlowByWorkingID(workflow);
                            }
                        }
                    }
                    #endregion

                    #region 排产计划
                    if (args.OrderSchedulings != null)
                    {
                        foreach (OrderScheduling item in args.OrderSchedulings)
                        {
                            OrderScheduling subobj = new OrderScheduling();
                            subobj.MadeID = item.MadeID;
                            if (op.LoadOrderSchedulingByMadeID(subobj) == 0)
                            {
                                item.Created    = DateTime.Now;
                                item.CreatedBy  = sender.UserCode + "." + sender.UserName;
                                item.Modified   = DateTime.Now;
                                item.ModifiedBy = sender.UserCode + "." + sender.UserName;
                                op.InsertOrderScheduling(item);
                            }
                            else
                            {
                                item.Modified   = DateTime.Now;
                                item.ModifiedBy = sender.UserCode + "." + sender.UserName;
                                op.UpdateOrderSchedulingByMadeID(item);
                            }
                        }
                    }
                    //工作车间生产计划
                    if (args.WorkCenterSchedulings != null)
                    {
                        foreach (WorkCenterScheduling item in args.WorkCenterSchedulings)
                        {
                            WorkCenterScheduling wcs = new WorkCenterScheduling();
                            wcs.WorkID = item.WorkID;
                            if (op.LoadWorkCenterSchedulingByWorkID(wcs) == 0)
                            {
                                item.Created    = DateTime.Now;
                                item.CreatedBy  = sender.UserCode + "." + sender.UserName;
                                item.Modified   = DateTime.Now;
                                item.ModifiedBy = sender.UserCode + "." + sender.UserName;
                                op.InsertWorkCenterScheduling(item);
                            }
                            else
                            {
                                item.Modified   = DateTime.Now;
                                item.ModifiedBy = sender.UserCode + "." + sender.UserName;
                                op.UpdateWorkCenterSchedulingByWorkID(item);
                            }
                        }
                    }
                    #endregion

                    #region 包装数据
                    if (args.PackageDetails != null)
                    {
                        foreach (PackageDetail item in args.PackageDetails)
                        {
                            PackageDetail subobj = new PackageDetail();
                            subobj.DetailID = item.DetailID;
                            if (op.LoadPackageDetailByDetailID(subobj) == 0)
                            {
                                item.Created    = DateTime.Now;
                                item.CreatedBy  = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                                item.Modified   = DateTime.Now;
                                item.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                                op.InsertPackageDetail(item);
                            }
                            else
                            {
                                item.Modified   = DateTime.Now;
                                item.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                                op.UpdatePackageDetailByDetailID(item);
                            }
                        }
                    }
                    #endregion

                    #region 修改柜体状态
                    List <Guid> OrderIDs = new List <Guid>();
                    if (args.CabinetIDs != null)
                    {
                        foreach (Guid CabinetID in args.CabinetIDs)
                        {
                            Order2Cabinet cabinet = new Order2Cabinet();
                            cabinet.CabinetID = CabinetID;
                            if (op.LoadOrder2CabinetByCabinetID(cabinet) != 0)
                            {
                                if (!OrderIDs.Contains(cabinet.OrderID))
                                {
                                    OrderIDs.Add(cabinet.OrderID);
                                }
                                Order order = new Order();
                                order.OrderID = cabinet.OrderID;
                                if (op.LoadOrder(order) != 0)
                                {
                                    //订单日志
                                    OrderLog log = new OrderLog();
                                    log.LogID     = Guid.NewGuid();
                                    log.OrderID   = order.OrderID;
                                    log.LogType   = "订单排产";
                                    log.Remark    = "完成排产";
                                    log.Created   = DateTime.Now;
                                    log.CreatedBy = sender.UserCode + "." + sender.UserName;
                                    op.InsertOrderLog(log);

                                    //流程步骤
                                    //OrderTask ot = new OrderTask();
                                    //ot.Action = "排产完成,待订单优化";
                                    //ot.CurrentStep = "订单排产";
                                    //ot.ActionRemarksType = "订单系统操作";
                                    //ot.ActionRemarks = "排产完成,待订单优化";
                                    //ot.Resource = "订单排产组";
                                    //ot.NextResources = "订单优化组";
                                    //ot.NextStep = "待生产优化";

                                    cabinet.BattchCode    = args.BattchCode;
                                    cabinet.CabinetStatus = "M";//待生产
                                    op.UpdateOrder2CabinetByCabinetID(cabinet);

                                    SaveOrderArgs orderargs = new SaveOrderArgs();
                                    orderargs.Order = order;
                                    //orderargs.OrderTask = ot;
                                    //orderargs.Order2Cabinets = new List<Order2Cabinet>() { cabinet };
                                    //this.SubmitTask(op, sender, orderargs);
                                }
                            }
                        }

                        foreach (Guid orderID in OrderIDs)
                        {
                            //op.UpdateMadeOrderStatus(orderID);
                        }
                    }
                    #endregion

                    op.CommitTransaction();
                }
            }
            catch (Exception ex)
            {
                PLogger.LogError(ex);
                throw ex;
            }
        }
Beispiel #20
0
        public SkyPostalRequestModel MapDirectBookingDetailToShipmentRequestDto(DirectBookingShipmentDraftDetail directBookingDetail)
        {
            SkyPostalRequestModel skyPostalRequestModel = new SkyPostalRequestModel();

            skyPostalRequestModel.Key                        = "";
            skyPostalRequestModel.method                     = "insert_order";
            skyPostalRequestModel.include_label_data         = "0";
            skyPostalRequestModel.include_label_zpl          = "1";
            skyPostalRequestModel.zpl_encode_base64          = "1";
            skyPostalRequestModel.include_label_base64_image = "0";
            skyPostalRequestModel.label_pdf_rotate           = "0";
            skyPostalRequestModel.header                     = new Header();
            skyPostalRequestModel.header.EXTR_TRACKING       = directBookingDetail.FrayteNumber + "-" + directBookingDetail.ReferenceDetail.Reference1;
            skyPostalRequestModel.header.COUNTRY_CODE        = directBookingDetail.ShipTo.Country.Code2;
            skyPostalRequestModel.header.STATE_CODE          = 0;
            skyPostalRequestModel.header.CITY_CODE           = 0;
            skyPostalRequestModel.header.STATE_NAME          = directBookingDetail.ShipTo.State;
            skyPostalRequestModel.header.CITY_NAME           = directBookingDetail.ShipTo.City;
            skyPostalRequestModel.header.FIRST_NAME          = directBookingDetail.ShipTo.FirstName;
            skyPostalRequestModel.header.LAST_NAME           = directBookingDetail.ShipTo.LastName;
            skyPostalRequestModel.header.ADDRESS_CONSIGNEE   = directBookingDetail.ShipTo.Address;
            skyPostalRequestModel.header.ADDRESS2            = directBookingDetail.ShipTo.Address2;
            skyPostalRequestModel.header.ZIPCODE             = directBookingDetail.ShipTo.PostCode;
            skyPostalRequestModel.header.PHONE               = directBookingDetail.ShipTo.Phone;
            skyPostalRequestModel.header.MOBILE_PHONE        = directBookingDetail.ShipTo.Phone;
            skyPostalRequestModel.header.EMAIL               = directBookingDetail.ShipTo.Email;
            skyPostalRequestModel.header.ID_NUMBER           = directBookingDetail.DirectShipmentDraftId.ToString();
            skyPostalRequestModel.header.MERCHANT_NAME       = "FRAYTE LOGISTICS LTD";
            skyPostalRequestModel.header.MERCHANT_NUMBER     = 665;
            skyPostalRequestModel.header.MERCHANT_BOX        = directBookingDetail.CustomerRateCard.CourierAccountNo;
            if (directBookingDetail.CustomerRateCard.LogisticDescription == SKYPostalLogisticType.SkyPostalMexico)
            {
                skyPostalRequestModel.header.MERCHANT_CS_EMAIL = SKYPostalMerchantEmail.MexicoMerchantEmail;
            }
            if (directBookingDetail.CustomerRateCard.LogisticDescription == SKYPostalLogisticType.SkyPostalBrazil)
            {
                skyPostalRequestModel.header.MERCHANT_CS_EMAIL = SKYPostalMerchantEmail.BrazilMerchantEmail;
            }
            if (directBookingDetail.CustomerRateCard.LogisticDescription == SKYPostalLogisticType.SkyPostalChile)
            {
                skyPostalRequestModel.header.MERCHANT_CS_EMAIL = SKYPostalMerchantEmail.ChileMerchantEmail;
            }

            skyPostalRequestModel.header.MERCHANT_RETURN_ADDRESS = null;
            skyPostalRequestModel.header.MERCHANT_CS_NAME        = "FRAYTE Logistics Ltd";
            skyPostalRequestModel.header.ORDER_NUMBER            = directBookingDetail.ReferenceDetail.Reference1 + "-" + directBookingDetail.FrayteNumber;
            skyPostalRequestModel.header.ORDER_AMOUNT            = directBookingDetail.Packages.Sum(k => k.Value);
            skyPostalRequestModel.header.ORDER_DATE         = directBookingDetail.ReferenceDetail.CollectionDate.Value.ToString("dd/MM/yyyy");
            skyPostalRequestModel.header.INTERNAL_NUMBER    = directBookingDetail.FrayteNumber;
            skyPostalRequestModel.header.MANIFEST_TYPE      = "DDP";
            skyPostalRequestModel.header.CONSOLIDATED       = 0;
            skyPostalRequestModel.header.CURRENCY_ISO_CODE  = directBookingDetail.Currency.CurrencyCode;
            skyPostalRequestModel.header.SHIPMENT_FREIGHT   = 0;
            skyPostalRequestModel.header.SHIPMENT_INSURANCE = 0;
            skyPostalRequestModel.header.SHIPMENT_DISCOUNT  = 0;

            skyPostalRequestModel.detail = new List <PackageDetail>();

            foreach (var item in directBookingDetail.Packages)
            {
                PackageDetail package = new PackageDetail();

                package.HSC                = "";
                package.FMPR_CDG           = "";
                package.CONTENT_OF_PRODUCT = item.Content;
                package.PHYSICAL_WEIGHT    = item.Weight;
                package.WEIGHT_TYPE        = directBookingDetail.PakageCalculatonType == "kgToCms" ? "KG" : "LB";
                package.DIMEN_LENGTH       = item.Length;
                package.DIMEN_HEIGHT       = item.Height;
                package.DIMEN_WIDTH        = item.Width;
                package.DIMEN_UNIT         = directBookingDetail.PakageCalculatonType == "kgToCms" ? "CM" : "IN";
                package.MERCHANDISE_VALUE  = item.Value;
                package.QUANTITY           = item.CartoonValue;
                skyPostalRequestModel.detail.Add(package);
            }

            return(skyPostalRequestModel);
        }
Beispiel #21
0
        public void DeletePackageItem(Sender sender, string Barcode, Guid WorkFlowID, bool IsRemovePackage)
        {
            try
            {
                using (ObjectProxy op = new ObjectProxy(true))
                {
                    //包装数据
                    OrderDetail subOrder = new OrderDetail();
                    subOrder.BarcodeNo = Barcode;
                    if (op.LoadOrderDetailByBarcodeNo(subOrder) == 0)
                    {
                        throw new PException("【{0}】条码数据不存在。", Barcode);
                    }

                    Guid PackageID = Guid.Empty;
                    List <PackageDetail> PackageDetails = op.LoadPackageDetailsByItemID(subOrder.ItemID);
                    PackageDetail        packageDetail  = PackageDetails.Find(p => p.IsPackaged = true);
                    if (packageDetail != null)
                    {
                        PackageID = packageDetail.PakageID;
                        packageDetail.IsPackaged = false;
                        packageDetail.PakageID   = Guid.Empty;
                        packageDetail.LayerNum   = 0;
                        op.UpdatePackageDetailByDetailID(packageDetail);
                    }
                    else
                    {
                        throw new PException("【{0}】没有打包数据。", Barcode);
                    }

                    if (IsRemovePackage)
                    {
                        op.DeletePackageByPackageID(PackageID);
                    }
                    else
                    {
                        Package package = new Package();
                        package.PackageID = PackageID;
                        if (op.LoadPackageByPackageID(package) == 0)
                        {
                            throw new PException("【{0}】没有打包数据。", Barcode);
                        }
                        else
                        {
                            package.ItemsQty -= 1;
                            package.Weight   -= subOrder.MadeLength * subOrder.MadeWidth * subOrder.MadeHeight * 0.000008M;
                            op.UpdatePackageByPackageID(package);
                        }
                    }

                    //生产流程
                    List <OrderMadeState> lists_oms = op.LoadOrderMadeStatesByItemID_WorkFlowID(subOrder.ItemID, WorkFlowID);
                    if (lists_oms.Count > 0)
                    {
                        op.DeleteOrderMadeStateByDetailID(lists_oms[0].DetailID);
                    }

                    //生产状态:数量减少
                    OrderWorkFlow owf = new OrderWorkFlow();
                    owf.ItemID           = subOrder.ItemID;
                    owf.SourceWorkFlowID = WorkFlowID;
                    if (op.LoadOrderWorkFlowByItemID_SourceWorkFlowID(owf) != 0)
                    {
                        owf.MadeQty -= 1;
                        op.UpdateOrderWorkFlowByItemID_SourceWorkFlowID(owf);
                    }

                    //生产进度
                    OrderScheduling os = new OrderScheduling();
                    os.CabinetID  = subOrder.CabinetID;
                    os.WorkFlowID = WorkFlowID;
                    if (op.LoadOrderSchedulingByCabinetID_WorkFlowID(os) != 0)
                    {
                        os.MadeTotalQty    -= 1;
                        os.MadeTotalAreal  -= subOrder.MadeLength * subOrder.MadeWidth * 0.000001M;
                        os.MadeTotalLength -= (subOrder.MadeLength + subOrder.MadeWidth) * 2 * 0.001M;
                        op.UpdateOrderSchedulingByMadeID(os);
                    }

                    op.CommitTransaction();
                }
            }
            catch (Exception ex)
            {
                PLogger.LogError(ex);
                throw ex;
            }
        }
Beispiel #22
0
        async static Task <int> Initial(StreamWriter errLog)
        {
            DateTime startDate = new DateTime(1970, 1, 1);

            if (File.Exists(_cursorFile))
            {
                using (StreamReader sr = new StreamReader(_cursorFile))
                {
                    startDate = Convert.ToDateTime(sr.ReadToEnd());
                }
            }
            ;

            errLog.WriteLine("Starting with date: " + startDate.ToString());
            errLog.Flush();

            using (StreamWriter sw = new StreamWriter(_cursorFile, false))
            {
                sw.Write(startDate.ToString("o"));
            }

            FileInfo fi = new FileInfo(_metaDataFile);

            if (fi != null && fi.Exists && fi.Length > 0)
            {
                using (StreamReader metadataSR = new StreamReader(_metaDataFile))
                {
                    string line;
                    while ((line = metadataSR.ReadLine()) != null)
                    {
                        string[] sa = line.Split('\t');
                        _nameToIdMap[sa[0]] = new Guid(sa[1]);
                    }
                }
            }

            using (StreamWriter metaData = new StreamWriter(_metaDataFile, true))
            {
                RestClient restClient = new RestClient("https://api.nuget.org");
                restClient.AddDefaultHeader("X-NuGet-Protocol-Version", "4.1.0");
                restClient.AddDefaultHeader("X-NuGet-Session-Id", Guid.NewGuid().ToString());
                restClient.ClearHandlers();
                restClient.AddHandler(new JsonNetSerializer(), new string[] { "application/json" });

                RestRequest request = new RestRequest("v3/index.json", Method.GET);
                IRestResponse <Services> response = restClient.Execute <Services>(request);
                Services services = response.Data;

                string catalogRootUrl = services.Resources.Single(x => x.Type == "Catalog/3.0.0").Id;
                Uri    uri            = new Uri(catalogRootUrl);

                restClient.BaseUrl = new Uri(uri.Scheme + "://" + uri.Host);
                request            = new RestRequest(uri.AbsolutePath, Method.GET);

                CatalogIndex index;

                try
                {
                    index = restClient.Execute <CatalogIndex>(request).Data;
                }
                catch (Exception exc)
                {
                    errLog.WriteLine(exc);
                    metaData.Flush();
                    return(1);
                }


                foreach (CatalogPage page in index.Items.Where(x => x.CommitTimeStamp >= startDate).OrderBy(x => x.CommitTimeStamp))
                {
                    startDate = page.CommitTimeStamp;

                    uri = new Uri(page.Id);
                    restClient.BaseUrl = new Uri(uri.Scheme + "://" + uri.Host);
                    request            = new RestRequest(uri.AbsolutePath, Method.GET);
                    IRestResponse <CatalogPage> response2;

                    try
                    {
                        response2 = restClient.Execute <CatalogPage>(request);
                    }
                    catch (Exception exc)
                    {
                        errLog.WriteLine(exc.ToString());
                        metaData.Flush();
                        return(1);
                    }

                    if (response2.StatusCode != HttpStatusCode.OK)
                    {
                        continue;
                    }

                    CatalogPage details = response2.Data;

                    if (details.Items != null && details.Items.Count > 0)
                    {
                        foreach (var item in details.Items.OrderBy(x => x.CommitTimeStamp))
                        {
                            Guid id;
                            if (!_nameToIdMap.TryGetValue(item.PackageName, out id))
                            {
                                id = Guid.NewGuid();
                                _nameToIdMap.Add(item.PackageName, id);
                            }

                            await metaData.WriteLineAsync($"{item.PackageName}\t{id}\t{item.PackageVersion}\t" +
                                                          $"{item.CommitTimeStamp.ToUnixTime()}\t{item.IsDelete}");
                        }

                        var newest = details.Items.Where(x => !x.IsDelete).GroupBy(x => x.PackageName).Select(
                            x => x.OrderByDescending(y => y.CommitTimeStamp).First()).ToList();

                        foreach (var item in newest)
                        {
                            Guid id = _nameToIdMap[item.PackageName];

                            uri = new Uri(item.Id);
                            restClient.BaseUrl = new Uri(uri.Scheme + "://" + uri.Host);
                            request            = new RestRequest(uri.PathAndQuery, Method.GET);
                            IRestResponse <PackageDetail> response1;

                            try
                            {
                                response1 = restClient.Execute <PackageDetail>(request);
                            }
                            catch (Exception exc)
                            {
                                errLog.WriteLine(exc.ToString());
                                metaData.Flush();
                                return(1);
                            }

                            if (response1.StatusCode == HttpStatusCode.NotFound)
                            {
                                continue;
                            }

                            PackageDetail pd = response1.Data;

                            if (pd != null)
                            {
                                string directory = Path.Combine(_cacheFiles, id.ToString());
                                Directory.CreateDirectory(directory);

                                string myFile = Path.Combine(directory,
                                                             pd.CommitTimeStamp.ToUnixTime().ToString() + ".gz");

                                if (File.Exists(myFile))
                                {
                                    File.Delete(myFile);
                                }

                                using (FileStream outFile = File.Create(myFile))
                                    using (GZipStream compress = new GZipStream(outFile, CompressionMode.Compress))
                                        using (StreamWriter writer = new StreamWriter(compress))
                                        {
                                            writer.Write(JsonConvert.SerializeObject(pd));
                                        }
                            }
                        }
                    }

                    if (File.Exists(_cursorFile))
                    {
                        File.Delete(_cursorFile);
                    }

                    using (StreamWriter sw = new StreamWriter(_cursorFile, false))
                    {
                        sw.Write(startDate.ToString("o"));
                    }
                }
            }

            return(0);
        }