public void AddExistingMediaItemAsAnAttachment(int orderNodeId, string mediaNodeId, string title, string link, string eventId, bool doReindex = true, bool doSignal = true)
        {
            var content = _contentService.GetById(orderNodeId);

            if (!String.IsNullOrEmpty(title) && !String.IsNullOrEmpty(link))
            {
                string attachmentsStr = Convert.ToString(content.GetValue("attachments"));
                List <OrderAttachment> attachmentList;
                if (!String.IsNullOrEmpty(attachmentsStr))
                {
                    attachmentList = JsonConvert.DeserializeObject <List <OrderAttachment> >(attachmentsStr);
                }
                else
                {
                    attachmentList = new List <OrderAttachment>();
                }

                var att = new OrderAttachment();
                att.Title           = title;
                att.Link            = link;
                att.MediaItemNodeId = mediaNodeId;
                attachmentList.Add(att);

                content.SetValue("attachments", JsonConvert.SerializeObject(attachmentList));
                AddLogItem(orderNodeId, "ATTACHMENT", "Nytt dokument bundet till ordern.", eventId, false, false);
            }

            SaveWithoutEventsAndWithSynchronousReindexing(content, doReindex, doSignal);
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(int id, [Bind("OrderAttachmentId,OrderId,Created")] OrderAttachment orderAttachment)
        {
            if (id != orderAttachment.OrderAttachmentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(orderAttachment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderAttachmentExists(orderAttachment.OrderAttachmentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderId"] = new SelectList(_context.CustomerOrders, "OrderId", "OrderId", orderAttachment.OrderId);
            return(View(orderAttachment));
        }
Beispiel #3
0
        private async Task <JsonResult> SendCustomerTobeConfirmMsg(Order order, OrderAttachment designImage, bool isLog = false)
        {
            var accountBindingManager = new AccountBindingManager();
            var accountbing           = await accountBindingManager.GetAccountBindingByCustomerId(order.CustomerId);

            if (accountbing == null)
            {
                return(Json(InvokedResult.Fail("404", "客户未绑定微信")));
            }


            SendMesHelp.SendNews(new NewsMes()
            {
                OpenId   = accountbing.WxAccount,
                Articles = new List <Article>()
                {
                    new Article()
                    {
                        Title       = "设计稿确认",
                        Description = string.Format("订单{0}已上传设计稿,请确认!", order.Id),
                        Url         = "http://www.18k.hk/customer/order/list?OrderId=" + order.Id,
                        PicUrl      = string.Format("http://www.18k.hk/orderimage/{0}.jpg", designImage.FileInfoId)
                    }
                }
            });

            if (isLog)
            {
                var operationLogManager = new OrderOperationLogManager(User);
                await operationLogManager.AddLogAsync(OperationLogStatus.CuiQueRen, order.Id);
            }

            return(Json(InvokedResult.SucceededResult));
        }
Beispiel #4
0
        public void UpdateOrderAttachment(OrderAttachment attachment, AttachmentSummary summary, IPersistenceContext context)
        {
            AttachedDocumentAssembler mimeDocAssembler = new AttachedDocumentAssembler();

            attachment.Category = EnumUtils.GetEnumValue <OrderAttachmentCategoryEnum>(summary.Category, context);
            mimeDocAssembler.UpdateAttachedDocumentSummary(attachment.Document, summary.Document);
        }
Beispiel #5
0
        public AttachmentSummary CreateOrderAttachmentSummary(OrderAttachment attachment, IPersistenceContext context)
        {
            AttachedDocumentAssembler attachedDocAssembler = new AttachedDocumentAssembler();
            StaffAssembler            staffAssembler       = new StaffAssembler();

            return(new AttachmentSummary(
                       EnumUtils.GetEnumValueInfo(attachment.Category),
                       staffAssembler.CreateStaffSummary(attachment.AttachedBy, context),
                       attachment.AttachedTime,
                       attachedDocAssembler.CreateAttachedDocumentSummary(attachment.Document)));
        }
Beispiel #6
0
        public async Task <IActionResult> Create([Bind("OrderAttachmentId,OrderId,Created")] OrderAttachment orderAttachment)
        {
            orderAttachment.Created = DateTime.Now;
            if (ModelState.IsValid)
            {
                _context.Add(orderAttachment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderId"] = new SelectList(_context.CustomerOrders, "OrderId", "OrderId", orderAttachment.OrderId);
            return(View(orderAttachment));
        }
Beispiel #7
0
        public string FileUpload(HttpPostedFileBase Filedata)
        {
            try
            {
                Guid billGuid = Guid.Empty;
                if (Request.QueryString["fid"] != null)
                    Guid.TryParse(Request.QueryString["fid"], out billGuid);

                // 如果没有上传文件
                if (Filedata == null || string.IsNullOrEmpty(Filedata.FileName) || Filedata.ContentLength == 0)
                {
                    return "未找到上传文件!";
                }

                // 保存到 ~/photos 文件夹中,名称不变
                string filename = System.IO.Path.GetFileName(Filedata.FileName);
                string virtualPath = string.Format("~/FileUpload/Doc/{0}", filename);
                // 文件系统不能使用虚拟路径
                string path = this.Server.MapPath(virtualPath);

                Filedata.SaveAs(path);

                OrderAttachment att = new OrderAttachment();
                att.FileContent = GetFileBytes(path);
                att.FileLength = Filedata.ContentLength;
                att.FileName = Filedata.FileName;
                att.FilePath = path;
                att.FileType = Filedata.ContentType;
                att.FormID = billGuid;
                att.GUID = Guid.NewGuid();
                att.IsDelete = false;
                att.UploadTime = DateTime.Now;

                unitOfWork.OrderAttachmentBLL.InsertEntity(att);
                unitOfWork.Save();

                return "Success";
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
Beispiel #8
0
        // Save the file and create a database record
        private static async Task AddOrderAttachment(this AppDbContext db, IFormFile file, User user, int orderId)
        {
            var uploadUrl = $@"{uploadBase}{user.Guid.ToString()}\";
            var upload    = await file.WriteFile(uploadUrl);

            var attachment = new OrderAttachment
            {
                Name         = upload.Name,
                File         = upload.File,
                Url          = upload.Url,
                Path         = upload.Path,
                OrderId      = orderId,
                DateUploaded = DateTime.Now,
                UserId       = user.Id,
                IsDeleted    = false
            };

            await db.Attachments.AddAsync(attachment);

            await db.SaveChangesAsync();
        }
Beispiel #9
0
        public void Calculate(ref OrderInfo order)
        {
            List <SOItemInfo>      soItemList         = InternalHelper.ConvertToSOItemList(order, false);
            List <int>             soItemSysNoList    = soItemList.Select(f => f.ProductSysNo).Distinct().ToList();
            List <OrderAttachment> unitAttachmentList = PromotionDA.GetAttachmentListByProductSysNoList(soItemSysNoList);

            order.AttachmentItemList = new List <OrderAttachment>();
            foreach (OrderItemGroup itemGroup in order.OrderItemGroupList)
            {
                foreach (OrderProductItem item in itemGroup.ProductItemList)
                {
                    OrderAttachment unitAttachment = unitAttachmentList.Find(f => f.ParentProductSysNo == item.ProductSysNo);
                    if (unitAttachment != null)
                    {
                        unitAttachment                 = unitAttachment.Clone() as OrderAttachment;
                        unitAttachment.ParentCount     = itemGroup.Quantity * item.UnitQuantity;
                        unitAttachment.ParentPackageNo = itemGroup.PackageNo;
                        order.AttachmentItemList.Add(unitAttachment);
                    }
                }
            }
        }
Beispiel #10
0
 public void SaveOrderAttachment(OrderAttachment obj)
 {
     db.OrderAttachments.Add(obj);
     db.SaveChanges();
 }
Beispiel #11
0
        public void Calculate(ref OrderInfo orderInfo)
        {
            Dictionary <string, OrderInfo> subOrderInfoList = new Dictionary <string, OrderInfo>();

            #region 【 将加够商品合并至主商品 】

            foreach (var plusPriceItem in orderInfo.PlusPriceItemList)
            {
                if (plusPriceItem.IsSelect)
                {
                    orderInfo.OrderItemGroupList.Add(PlusPriceConvertToProduct(plusPriceItem, orderInfo.Customer.SysNo));
                }
            }

            #endregion

            #region 【 先处理主商品 】

            List <OrderProductItem> masterItemList = new List <OrderProductItem>();

            if (orderInfo.OrderItemGroupList != null)
            {
                foreach (var itemGroup in orderInfo.OrderItemGroupList)
                {
                    if (itemGroup.ProductItemList != null)
                    {
                        itemGroup.ProductItemList.ForEach(masterItem =>
                        {
                            //将主商品拆分到最细粒度,即一个商品一个OrderProductItem
                            for (int i = 0; i < masterItem.UnitQuantity * itemGroup.Quantity; i++)
                            {
                                OrderProductItem cloneItem = (OrderProductItem)masterItem.Clone();
                                cloneItem.UnitQuantity     = 1;
                                //设置商品上的套餐号和套餐类型,很别扭,先这样吧,下个项目再修改 at 【2014-08-08 13:25:43】
                                cloneItem["PackageNo"]   = itemGroup.PackageNo;
                                cloneItem["PackageType"] = itemGroup.PackageType;
                                masterItemList.Add(cloneItem);
                            }
                        });
                    }
                }
            }

            //先初步按照 供应商+仓库+存储运输方式 拆分
            Dictionary <string, List <OrderProductItem> > dicMasterItemPreSplitResult = GetMainItemSplitResult(masterItemList);

            Dictionary <string, List <OrderProductItem> > dicSubOrderMasterItemResult = new Dictionary <string, List <OrderProductItem> >();

            //取得每单最大限制金额
            Dictionary <string, decimal> maxPerOrderAmountConfig = GetMaxPerOrderAmountConfig();

            foreach (var kvs in dicMasterItemPreSplitResult)
            {
                kvs.Value.Sort((item1, item2) =>
                {
                    return((item1.TotalSalePrice).CompareTo(item2.TotalSalePrice));
                });

                //单个订单金额拆分规则
                string warehouseCountryCode = string.IsNullOrEmpty(kvs.Value[0].WarehouseCountryCode) ? string.Empty :
                                              kvs.Value[0].WarehouseCountryCode;

                decimal maxPerOrderAmount = decimal.MaxValue;
                if (maxPerOrderAmountConfig.ContainsKey(warehouseCountryCode.ToUpper().Trim()))
                {
                    maxPerOrderAmount = maxPerOrderAmountConfig[warehouseCountryCode.ToUpper().Trim()];
                }

                decimal shoppingItemPriceSum = 0;
                string  thisKey = string.Empty;
                List <OrderProductItem> thisGroupMasterItemList = new List <OrderProductItem>();

                //根据每单最大购买金额进行一次拆单
                foreach (OrderProductItem masterItem in kvs.Value)
                {
                    decimal currentItemAmtSum = masterItem.TotalSalePrice;
                    //判断当前订单金额是否大于出库地区每单最大金额
                    if (shoppingItemPriceSum + currentItemAmtSum > maxPerOrderAmount)
                    {
                        //如果大于出库地区每单最大金额,并且主商品分组为空的话,那么当前单商品金额就已经超出
                        //最大购买金额,单商品自成一单
                        if (thisGroupMasterItemList.Count <= 0)
                        {
                            shoppingItemPriceSum = masterItem.TotalSalePrice;
                            thisGroupMasterItemList.Add(masterItem);

                            //根据订单金额重新计算一次key值
                            thisKey = GetSubOrderKey(kvs.Key, shoppingItemPriceSum, dicSubOrderMasterItemResult);
                            dicSubOrderMasterItemResult[thisKey] = thisGroupMasterItemList;

                            shoppingItemPriceSum    = currentItemAmtSum;
                            thisGroupMasterItemList = new List <OrderProductItem>();
                        }
                        else
                        {
                            //主商品分组合并组成一个子单,清空之前的主商品分组,并且将当前主商品加入到分组中
                            //根据订单金额重新计算一次key值
                            thisKey = GetSubOrderKey(kvs.Key, shoppingItemPriceSum, dicSubOrderMasterItemResult);
                            dicSubOrderMasterItemResult[thisKey] = thisGroupMasterItemList;

                            shoppingItemPriceSum    = currentItemAmtSum;
                            thisGroupMasterItemList = new List <OrderProductItem>()
                            {
                                masterItem
                            };
                        }
                    }
                    else
                    {
                        //金额没有超过最大购买金额,将当前主商品加入到分组中
                        shoppingItemPriceSum += masterItem.TotalSalePrice;
                        thisGroupMasterItemList.Add(masterItem);
                    }
                }
                //处理剩下的主商品分组,这些主商品组成一个子单
                if (thisGroupMasterItemList.Count > 0)
                {
                    thisKey = GetSubOrderKey(kvs.Key, shoppingItemPriceSum, dicSubOrderMasterItemResult);
                    dicSubOrderMasterItemResult[thisKey] = thisGroupMasterItemList;
                }
            }

            foreach (var kvs in dicSubOrderMasterItemResult)
            {
                OrderInfo subOrderInfo = (OrderInfo)orderInfo.Clone();
                //设置订单的默认出库仓
                subOrderInfo["WarehouseNumber"]      = kvs.Value.FirstOrDefault().WarehouseNumber;
                subOrderInfo["WarehouseName"]        = kvs.Value.FirstOrDefault().WarehouseName;
                subOrderInfo["WarehouseCountryCode"] = kvs.Value.FirstOrDefault().WarehouseCountryCode;
                subOrderInfo["MerchantSysNo"]        = kvs.Value.FirstOrDefault().MerchantSysNo;
                subOrderInfo["StoreType"]            = kvs.Value.FirstOrDefault()["ProductStoreType"];

                subOrderInfo.OrderItemGroupList = new List <OrderItemGroup>();
                subOrderInfo.GiftItemList       = new List <OrderGiftItem>();
                subOrderInfo.AttachmentItemList = new List <OrderAttachment>();

                OrderItemGroup itemGroup = new OrderItemGroup();
                //商品在拆单后,购买行为上的分组失去意义,设置组上的购买数量为1,商品的上UnitQuantity及时真实的商品购买数量
                itemGroup.Quantity        = 1;
                itemGroup.ProductItemList = new List <OrderProductItem>();

                kvs.Value.ForEach(masterItem =>
                {
                    //itemGroup.ProductItemList.Add(masterItem);
                    //由于前面将主商品拆分到最细,这里需要将主商品合并
                    if (!itemGroup.ProductItemList.Exists(x =>
                    {
                        if (x.ProductSysNo == masterItem.ProductSysNo)
                        {
                            x.UnitQuantity += masterItem.UnitQuantity;
                            return(true);
                        }
                        return(false);
                    }))
                    {
                        itemGroup.ProductItemList.Add(masterItem);
                    }
                });
                subOrderInfo.OrderItemGroupList.Add(itemGroup);

                subOrderInfoList.Add(kvs.Key, subOrderInfo);
            }

            #endregion

            #region 【 处理赠品和附件 】

            List <OrderItem> giftAndAccessoryList = new List <OrderItem>();

            if (orderInfo.GiftItemList != null)
            {
                orderInfo.GiftItemList.ForEach(gift =>
                {
                    if (!giftAndAccessoryList.Exists(g =>
                    {
                        OrderGiftItem giftItem = (OrderGiftItem)g;
                        //赠品合并增加一个赠品活动编号维度,客户端考虑对相同商品编号的赠品合并
                        if (giftItem.ProductSysNo == gift.ProductSysNo &&
                            giftItem.ActivityNo == gift.ActivityNo)
                        {
                            g.UnitQuantity += gift.UnitQuantity * gift.ParentCount;
                            return(true);
                        }
                        return(false);
                    }))
                    {
                        OrderGiftItem cloneGift = (OrderGiftItem)gift.Clone();
                        cloneGift.UnitQuantity  = gift.UnitQuantity * gift.ParentCount;
                        //合并后赠品的组数量失去意义,设置赠品的组购买数量为1
                        cloneGift.ParentCount = 1;
                        giftAndAccessoryList.Add(cloneGift);
                    }
                });
            }

            if (orderInfo.AttachmentItemList != null)
            {
                orderInfo.AttachmentItemList.ForEach(attachment =>
                {
                    if (!giftAndAccessoryList.Exists(a =>
                    {
                        if (a.ProductSysNo == attachment.ProductSysNo)
                        {
                            a.UnitQuantity += attachment.UnitQuantity * attachment.ParentCount;
                            return(true);
                        }
                        return(false);
                    }))
                    {
                        OrderAttachment cloneAttachment = (OrderAttachment)attachment.Clone();
                        cloneAttachment.UnitQuantity    = attachment.UnitQuantity * attachment.ParentCount;
                        //合并后附件的组数量失去意义,设置附件的组购买数量为1
                        cloneAttachment.ParentCount = 1;
                        giftAndAccessoryList.Add(cloneAttachment);
                    }
                });
            }

            Dictionary <string, List <OrderItem> > dicGiftAndAccessorySplitResult = GetItemSplitResult(giftAndAccessoryList);

            //赠品和附件不会影响订单金额,将按照商家+仓库+存储运输方式拆好的单和前面主商品拆好的单进行合并
            foreach (var kvs in dicGiftAndAccessorySplitResult)
            {
                OrderInfo theSubOrderInfo = null;
                //赠品(附件)在新的子单中
                bool giftOrAccessoryInNewSubOrder = false;

                foreach (string thisKey in subOrderInfoList.Keys)
                {
                    //thisKey:vendorSysno|warehouseNumber|storeType|amt-1....n
                    string prefixKey = thisKey.Substring(0, thisKey.LastIndexOf('|'));
                    prefixKey = prefixKey.Substring(0, prefixKey.LastIndexOf('|'));

                    //kvs.Key: vendorSysno|warehouseNumber|storeType
                    string newKey = kvs.Key.Substring(0, kvs.Key.LastIndexOf('|'));
                    if (newKey.ToUpper().Trim() == prefixKey.ToUpper().Trim())
                    {
                        theSubOrderInfo = subOrderInfoList[thisKey];
                        break;
                    }
                }

                if (theSubOrderInfo == null)
                {
                    giftOrAccessoryInNewSubOrder = true;
                    theSubOrderInfo = (OrderInfo)orderInfo.Clone();
                    //设置订单的默认出库仓
                    theSubOrderInfo["WarehouseNumber"]      = kvs.Value.FirstOrDefault().WarehouseNumber;
                    theSubOrderInfo["WarehouseName"]        = kvs.Value.FirstOrDefault().WarehouseName;
                    theSubOrderInfo["WarehouseCountryCode"] = kvs.Value.FirstOrDefault().WarehouseCountryCode;
                    theSubOrderInfo["MerchantSysNo"]        = kvs.Value.FirstOrDefault().MerchantSysNo;
                    theSubOrderInfo["StoreType"]            = kvs.Value.FirstOrDefault()["ProductStoreType"];

                    theSubOrderInfo.OrderItemGroupList = new List <OrderItemGroup>();
                    theSubOrderInfo.GiftItemList       = new List <OrderGiftItem>();
                    theSubOrderInfo.AttachmentItemList = new List <OrderAttachment>();

                    subOrderInfoList.Add(kvs.Key, theSubOrderInfo);
                }

                foreach (var orderItem in kvs.Value)
                {
                    if (orderItem is OrderGiftItem)
                    {
                        OrderGiftItem giftItem = orderItem as OrderGiftItem;
                        //Modified by PoseidonTong at [2014-08-11 12:33:01]
                        //赠品在和主商品同仓的前提下,优先和关联的主商品拆在同一个订单
                        if (!giftOrAccessoryInNewSubOrder && giftItem.ParentProductSysNo > 0)
                        {
                            var giftMasterProductSubOrderInfos = subOrderInfoList.Select(_ => _.Value)
                                                                 .Where(x => x.OrderItemGroupList != null &&
                                                                        x.OrderItemGroupList.Exists(y =>
                                                                                                    y.ProductItemList != null &&
                                                                                                    y.ProductItemList.Exists(p => p.ProductSysNo == giftItem.ParentProductSysNo)
                                                                                                    ));

                            if (giftMasterProductSubOrderInfos.Count() > 0)
                            {
                                //取满足条件的第一个子单,考虑同一个主商品由于金额
                                //限制拆分成了多个子单的情况,这里将赠品放到第一个主单中
                                giftMasterProductSubOrderInfos.First().GiftItemList.Add(giftItem);
                                continue;
                            }
                        }
                        theSubOrderInfo.GiftItemList.Add(giftItem);
                    }
                    else if (orderItem is OrderAttachment)
                    {
                        OrderAttachment attrItem = orderItem as OrderAttachment;
                        //Modified by PoseidonTong at [2014-08-11 12:33:01]
                        //附件在和主商品同仓的前提下,优先和关联的主商品拆在同一个订单
                        if (!giftOrAccessoryInNewSubOrder && attrItem.ParentProductSysNo > 0)
                        {
                            var attMasterProductSubOrderInfos = subOrderInfoList.Select(_ => _.Value)
                                                                .Where(x => x.OrderItemGroupList != null &&
                                                                       x.OrderItemGroupList.Exists(y =>
                                                                                                   y.ProductItemList != null &&
                                                                                                   y.ProductItemList.Exists(p => p.ProductSysNo == attrItem.ParentProductSysNo)
                                                                                                   ));

                            if (attMasterProductSubOrderInfos.Count() > 0)
                            {
                                //取满足条件的第一个子单,考虑同一个主商品由于金额
                                //限制拆分成了多个子单的情况,这里将附件放到第一个主单中
                                attMasterProductSubOrderInfos.First().AttachmentItemList.Add(attrItem);
                                continue;
                            }
                        }
                        theSubOrderInfo.AttachmentItemList.Add(attrItem);
                    }
                }
            }

            #endregion

            #region 【 设置子单类型和商家模式 】

            foreach (var kvs in subOrderInfoList)
            {
                OrderInfo subOrderInfo = kvs.Value;
                #region 设置商家模式
                ECommerce.Entity.Product.VendorInfo vendorInfo = PipelineDA.GetVendorInfo((int)subOrderInfo["MerchantSysNo"]);
                subOrderInfo["ShippingType"] = vendorInfo.ShippingType;
                subOrderInfo["StockType"]    = vendorInfo.StockType;
                subOrderInfo["InvoiceType"]  = vendorInfo.InvoiceType;
                subOrderInfo["SellerType"]   = vendorInfo.SellerType;
                subOrderInfo["VendorName"]   = vendorInfo.VendorName;
                #endregion

                #region 设置子单类型
                subOrderInfo.SOType = (int)SOType.Normal;
                ////团购商品不能和普通商品混合下单,所以只要订单中有团购商品,那么订单一定就是团购订单
                //if (subOrderInfo.OrderItemGroupList != null)
                //{
                //    if (subOrderInfo.OrderItemGroupList.Exists(itemGroup =>
                //    {
                //        if (itemGroup.ProductItemList != null)
                //        {
                //            return itemGroup.ProductItemList.Exists(product =>
                //            {
                //                if (product.SpecialActivityType == 1 || product.SpecialActivityType == 3)
                //                {
                //                    //记录下团购编号
                //                    subOrderInfo["ReferenceSysNo"] = product.SpecialActivitySysNo;
                //                    return true;
                //                }
                //                return false;
                //            });
                //        }
                //        return false;
                //    }))
                //    {
                //        subOrderInfo.SOType = (int)SOType.GroupBuy;
                //    }
                //    else
                //    {
                //        subOrderInfo.SOType = (int)SOType.Normal;
                //    }
                //}
                //else
                //{
                //    subOrderInfo.SOType = (int)SOType.Normal;
                //}
                #endregion
            }

            #endregion

            orderInfo.SubOrderList = subOrderInfoList;
        }
Beispiel #12
0
        public OrderAttachment OrderAttachment(HttpPostedFileBase file, string orderid, string groupname)
        {
            try
            {
                var currentuser = UserManager.Current();
                var orderitems = _repository.GetOrderItemByOrderId(int.Parse(orderid));

                if (orderitems != null)
                {
                    // var product = _productrepository.SelectById(int.Parse(orderitems.Xero_Id.ToString()));

                    if (file != null && !string.IsNullOrEmpty(orderid))
                    {

                        byte[] data;
                        const int width = 300;
                        const int height = 300;
                        using (var srcImage = Image.FromStream(file.InputStream))
                        using (var newImage = new Bitmap(width, height))
                        using (var graphics = Graphics.FromImage(newImage))
                        using (var stream = new MemoryStream())
                        {
                            graphics.SmoothingMode = SmoothingMode.AntiAlias;
                            graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                            graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                            graphics.DrawImage(srcImage, new Rectangle(0, 0, width, height));
                            newImage.Save(stream, ImageFormat.Png);
                            data = stream.ToArray();
                        }
                        var objAttachment = new OrderAttachment();
                        objAttachment.Org_Id = int.Parse(currentuser.OrgId.ToString());
                        objAttachment.Order_Id = int.Parse(orderitems.Order_Id.ToString());
                        objAttachment.FileName = Path.GetFileName(file.FileName);
                        objAttachment.FileExtension = Path.GetExtension(file.FileName); ;
                        objAttachment.FileSize = file.ContentLength;
                        objAttachment.Folder = groupname;
                        objAttachment.Created = DateTime.Now;
                        objAttachment.CreatedBy = currentuser.UserType;
                        objAttachment.File = data;
                        //if (product!=null)
                        //{
                        //    objAttachment.GroupType = product.ProductGroupId.ToString();
                        //}
                        _repository.SaveOrderAttachment(objAttachment);
                    }
                }
            }
            catch (Exception ex)
            {

                string msg = ex.Message;
            }

            return null;
        }
Beispiel #13
0
 public async Task <bool> RemoveAttachment(OrderAttachment attachement)
 {
     DbContext.Set <OrderAttachment>().Remove(attachement);
     return(await DbContext.SaveChangesAsync() > 0);
 }