Exemplo n.º 1
0
 public void SaveOrderProcessFile(Sender sender, SaveOrderProcessFileArgs args)
 {
     try
     {
         using (ObjectProxy op = new ObjectProxy(true))
         {
             OrderProcessFile obj = new OrderProcessFile();
             obj.FileID = args.OrderProcessFile.FileID;
             if (op.LoadOrderProcessFileByFileID(obj) == 0)
             {
                 args.OrderProcessFile.Created    = DateTime.Now;
                 args.OrderProcessFile.CreatedBy  = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                 args.OrderProcessFile.Modified   = DateTime.Now;
                 args.OrderProcessFile.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                 op.InsertOrderProcessFile(args.OrderProcessFile);
             }
             else
             {
                 args.OrderProcessFile.Modified   = DateTime.Now;
                 args.OrderProcessFile.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                 op.UpdateOrderProcessFileByFileID(args.OrderProcessFile);
             }
             op.CommitTransaction();
         }
     }
     catch (Exception ex)
     {
         PLogger.LogError(ex);
         throw ex;
     }
 }
Exemplo n.º 2
0
        public override void ProcessRequest(HttpContext context)
        {
            base.ProcessRequest(context);
            try
            {
                if (!string.IsNullOrEmpty(this.Request.QueryString["fid"]))
                {
                    Guid pid = new Guid(this.Request.QueryString["fid"].ToString());
                    Response.ClearHeaders();
                    Response.ClearContent();

                    string FilePath = "";
                    using (ProxyBE p = new ProxyBE())
                    {
                        OrderProcessFile doc = p.Client.GetOrderProcessFile(SenderUser, pid);
                        if (doc != null)
                        {
                            FilePath = doc.FilePath;
                        }
                    }
                    //string dcFilePath = doc.FilePath;
                    //Response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlPathEncode(Path.GetFileName(dcFilePath)));
                    //if (File.Exists(dcFilePath))
                    //{
                    //    byte[] buffer = File.ReadAllBytes(dcFilePath);
                    //    if (buffer != null)
                    //    {
                    //        Response.BinaryWrite(buffer);
                    //    }
                    //}


                    //没有SE服务,暂时注释掉
                    //if (!string.IsNullOrEmpty(FilePath))
                    //{
                    //    using (ProxySE se = new ProxySE())
                    //    {
                    //        Response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlPathEncode(Path.GetFileName(FilePath)));

                    //        byte[] buffer = se.Client.GetDocumentFile(SenderUser, FilePath);
                    //        if (buffer != null)
                    //        {
                    //            Response.BinaryWrite(buffer);
                    //        }
                    //    }
                    //}
                }
                Response.End();
            }
            catch (Exception ex)
            {
                PLogger.LogError(ex);
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region  载文件
            try
            {
                string FileID = Request["FileID"];
                if (string.IsNullOrEmpty(FileID))
                {
                    throw new Exception("无效参数调用。");
                }
                string filePath = String.Empty;
                string fileName = String.Empty;
                using (ProxyBE pb = new ProxyBE())
                {
                    OrderProcessFile op = pb.Client.GetOrderProcessFile(SenderUser, new Guid(FileID));
                    if (op != null)
                    {
                        filePath = op.FilePath;
                        fileName = op.FileName;
                    }
                    else
                    {
                        throw new Exception("文件数据丢失,下载失败。");
                    }
                }

                //暂无SE服务,暂时注释
                //using (ProxySE ps = new ProxySE())
                //{
                //    byte[] buffer = ps.Client.GetDocumentFile(SenderUser, filePath);
                //    if (buffer != null)
                //    {
                //        Response.Clear();
                //        Response.ContentType = "application/octet-stream";
                //        //通知浏览器下载文件而不是打开
                //        Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName));
                //        Response.BinaryWrite(buffer);
                //        Response.Flush();
                //        Response.End();
                //    }
                //    else
                //    {
                //        throw new Exception("文件已经损坏,下载失败。");
                //    }
                //}
            }
            catch (Exception ex)
            {
                PLogger.LogError(ex);
                RedirectErrorPage(ex.Message);
            }
            #endregion
        }
Exemplo n.º 4
0
 public OrderProcessFile GetOrderProcessFile(Sender sender, Guid FileID)
 {
     try
     {
         using (ObjectProxy op = new ObjectProxy())
         {
             OrderProcessFile obj = new OrderProcessFile();
             obj.FileID = FileID;
             if (op.LoadOrderProcessFileByFileID(obj) == 0)
             {
                 return(null);
             }
             return(obj);
         }
     }
     catch (Exception ex)
     {
         PLogger.LogError(ex);
         throw ex;
     }
 }
Exemplo n.º 5
0
 public OrderProcessFile GetOrderProcessFileByOrderID_FileType_FileName(Sender sender, Guid OrderID, string FileType, string Filename)
 {
     try
     {
         using (ObjectProxy op = new ObjectProxy())
         {
             OrderProcessFile obj = new OrderProcessFile();
             obj.FileName = Filename;
             obj.FileType = FileType;
             obj.OrderID  = OrderID;
             if (op.LoadOrderProcessFileByFileType_OrderID_FileName(obj) == 0)
             {
                 return(null);
             }
             return(obj);
         }
     }
     catch (Exception ex)
     {
         PLogger.LogError(ex);
         throw ex;
     }
 }
Exemplo n.º 6
0
        public void SaveOrder()
        {
            try
            {
                using (ProxyBE p = new ProxyBE())
                {
                    #region Order
                    var   flag  = "false";
                    Order order = p.Client.GetOrder(SenderUser, parm.OrderID);
                    if (parm.OrderType == "")
                    {
                        throw new Exception("请选择订单类型");
                    }
                    if (order == null)
                    {
                        order         = new Order();
                        order.OrderID = parm.OrderID;
                    }

                    //修改订单保存
                    flag = Request["edit"];
                    if (flag == "true")
                    {
                        order.OrderNo = parm.OrderNo;
                    }
                    else
                    {
                        order.OrderNo = "";
                    }
                    order.PartnerID      = parm.PartnerID;
                    order.CustomerID     = parm.CustomerID;
                    order.OutOrderNo     = parm.OutOrderNo;
                    order.Address        = parm.Address;
                    order.CustomerName   = parm.CustomerName;
                    order.AttachmentFile = HttpUtility.UrlDecode(parm.AttachmentFile, Encoding.UTF8);
                    order.PartnerName    = parm.PartnerName;
                    order.SalesMan       = parm.SalesMan;
                    order.BookingDate    = parm.BookingDate;
                    order.Mobile         = parm.Mobile;
                    order.ShipDate       = parm.ShipDate;
                    order.OrderType      = parm.OrderType;
                    order.Remark         = parm.Remark;
                    order.Status         = OrderStatus.C.ToString();
                    order.StepNo         = p.Client.GetOrderStepByStepCode(SenderUser, StepCode.addorder.ToString()).StepNo;
                    SaveOrderArgs args = new SaveOrderArgs();
                    args.Order = order;
                    #endregion

                    #region OrderProduct
                    List <OrderProduct> list = new List <OrderProduct>();
                    string   Cabinets        = Request["Cabinets"];
                    JsonData sj = JsonMapper.ToObject(Cabinets);
                    if (sj.Count > 0)
                    {
                        foreach (JsonData item in sj)
                        {
                            OrderProduct model = new OrderProduct();
                            model.OrderID          = order.OrderID;
                            model.ProductID        = Guid.Parse(item["ProductID"].ToString());
                            model.ProductName      = item["ProductName"].ToString();
                            model.ProductGroup     = item["ProductGroup"].ToString();
                            model.Qty              = Decimal.Parse(item["Qty"].ToString());
                            model.Price            = Decimal.Parse(item["Price"].ToString());
                            model.Size             = item["Size"].ToString();
                            model.MaterialStyle    = item["MaterialStyle"].ToString();
                            model.Color            = item["Color"].ToString();
                            model.MaterialCategory = item["MaterialCategory"].ToString();
                            model.Unit             = item["Unit"].ToString();
                            model.Remark           = item["Remark"].ToString();
                            model.SalePrice        = 0;
                            model.TotalAreal       = 0;
                            model.TotalLength      = 0;
                            model.ProductStatus    = "N";
                            //Product.ProductCode = ((char)(64 + cabinet.Sequence)).ToString();
                            if (flag == "true")
                            {
                                model.Created   = DateTime.Now;
                                model.CreatedBy = SenderUser.UserCode + "." + SenderUser.UserName;
                            }
                            list.Add(model);
                        }
                    }
                    args.OrderProducts = list;
                    #endregion

                    #region  OrderLog /OrderTask
                    if (flag != "true")
                    {
                        OrderStep    step = p.Client.GetOrderStepByStepCode(SenderUser, StepCode.addorder.ToString());
                        OrderStepLog ot   = new OrderStepLog();
                        ot.StepID         = Guid.NewGuid();
                        ot.OrderID        = order.OrderID;
                        ot.StepNo         = step.StepNo;
                        ot.StepName       = step.StepName;
                        ot.Remark         = string.Empty;
                        args.OrderStepLog = ot;
                    }
                    #endregion

                    #region OrderProcessFile
                    string  filePath    = Config.StorageFolder;
                    Partner partner     = p.Client.GetPartner(SenderUser, order.PartnerID);
                    string  PartnerCode = partner.PartnerCode;
                    filePath = Path.Combine(filePath, DateTime.Now.ToString("yyyyMM"));
                    filePath = Path.Combine(filePath, PartnerCode);
                    filePath = Path.Combine(filePath, DateTime.Now.ToString("yyyyMM"));
                    filePath = Path.Combine(filePath, PartnerCode + "-" + DateTime.Now.ToString("yyyyMM"));
                    if (!Directory.Exists(filePath))
                    {
                        Directory.CreateDirectory(filePath);
                    }

                    List <OrderProcessFile> ProcessFiles = new List <OrderProcessFile>();
                    IList <HttpPostedFile>  SceneFiles   = Request.Files.GetMultiple("SceneFile");
                    foreach (HttpPostedFile file in SceneFiles)
                    {
                        if (file.ContentLength == 0)
                        {
                            continue;
                        }
                        string savepath = Path.Combine(filePath, "SceneFile");
                        if (!Directory.Exists(savepath))
                        {
                            Directory.CreateDirectory(savepath);
                        }
                        savepath = Path.Combine(savepath, file.FileName);
                        if (File.Exists(savepath))
                        {
                            File.Delete(savepath);
                        }
                        file.SaveAs(savepath);
                        OrderProcessFile pf = p.Client.GetOrderProcessFileByOrderID_FileType_FileName(SenderUser, order.OrderID, "SceneFile", Path.GetFileName(savepath));
                        if (pf == null)
                        {
                            pf          = new OrderProcessFile();
                            pf.OrderID  = parm.OrderID;
                            pf.FileID   = Guid.NewGuid();
                            pf.FileName = Path.GetFileName(savepath);
                            pf.FilePath = savepath;
                            pf.FileType = "SceneFile";
                        }
                        ProcessFiles.Add(pf);
                    }


                    if (ProcessFiles.Count > 0)
                    {
                        args.OrderProcessFiles = ProcessFiles;
                    }
                    #endregion

                    p.Client.SaveOrder(SenderUser, args);
                }
                WriteSuccess();
            }
            catch (Exception ex)
            {
                WriteError(ex.Message, ex);
            }
        }