public ProofFile AddProofFile(int taskId, string proofId, string fullName, string displayName, string url, string processName)
        {
            var       task  = sdc.ProofTasks.SingleOrDefault(p => p.Id == taskId);
            var       proof = sdc.ProofOrders.Include(t => t.ProofStyle).SingleOrDefault(p => p.ProofOrderId == proofId);
            ProofFile pf    = new ProofFile()
            {
                FullName     = fullName,
                DisplayName  = displayName,
                Url          = url,
                ProofStyleId = proof.ProofStyle.ProofStyleId,
            };

            pf.SetCreateUser(_user.UserName);
            if (processName == "工艺")
            {
                pf.FileType = SG.Interface.Sys.FileType.TechnologyFile;
            }
            else if (processName == "程序")
            {
                pf.FileType = SG.Interface.Sys.FileType.PlatemakingFile;
            }
            sdc.ProofFiles.Add(pf);
            task.TaskFiles.Add(pf);
            proof.ProofStyle.ProofFiles.Add(pf);
            sdc.SaveChanges();

            return(pf);
        }
        public bool CreateProofOrder(ProofObj obj)
        {
            ProofOrder _proofOrder = new ProofOrder();
            ProofStyle _proofSryle = new ProofStyle();

            if (CheckObj(obj))
            {
                _proofSryle.ProofStyleId = obj.ProofStyleId;
                _proofSryle.ProofType    = sdc.ProofTypes.SingleOrDefault(p => p.TypeName == obj.ProofType);
                _proofSryle.ProofStyleNo = obj.ProofStyleNo;
                _proofSryle.ClentName    = obj.ClentName;
                _proofSryle.ClientNo     = obj.ClientNo;
                _proofSryle.StyleName    = obj.StyleName;
                _proofSryle.Counts       = obj.Counts;
                _proofSryle.Material     = obj.Material;
                _proofSryle.Weight       = obj.Weight;
                _proofSryle.Gauge        = obj.Gauge;
                _proofSryle.ProofOrderId = obj.ProofOrderId;
                obj.FileListItems.ForEach(f =>
                {
                    ProofFile npf = new ProofFile
                    {
                        FullName     = f.FullName,
                        DisplayName  = f.DisplayName,
                        Url          = f.Url,
                        ProofStyleId = _proofSryle.ProofStyleId,
                        FileType     = FileType.ClientFile
                    };
                    npf.SetCreateUser(_user.UserName);
                    _proofSryle.ProofFiles.Add(npf);
                });

                _proofOrder.ProofStyle         = _proofSryle;
                _proofOrder.ProofOrderId       = obj.ProofOrderId;
                _proofOrder.ProofApplyUserDdId = _user.DdId;
                _proofOrder.DesignatedCX       = obj.DesignatedCX;
                _proofOrder.DesignatedGY       = obj.DesignatedGY;
                _proofOrder.Remark             = obj.Remark;
                _proofOrder.Urgency            = obj.Urgency;
                _proofOrder.ProofApplyUserName = _user.UserName;
                _proofOrder.ProofApplyDeptName = _user.DepartName;
                _proofOrder.ProofStatus        = ProofStatus.草拟;
                _proofOrder.RequiredDate       = obj.FinshDate;
                _proofOrder.ProofNum           = obj.ProofNum;
                _proofSryle.SetCreateUser(_user.UserName);
                _proofOrder.SetCreateUser(_user.UserName);
            }
            sdc.ProofStyles.Add(_proofSryle);
            sdc.ProofOrders.Add(_proofOrder);
            return(true);
        }
        public void AgreeFinsh(string pid)
        {
            ApproveOper ao = new ApproveOper(_oper);
            var         re = ao.GetApprove(pid);
            var         po = sdc.ProofOrders.SingleOrDefault(p => p.DdFinshApprovalCode == pid);

            if (po != null)
            {
                re.FormComponentValues.ForEach(p =>
                {
                    if (p.Name == "评分")
                    {
                        int Rating = 3;
                        if (p.Value != null)
                        {
                            if (p.Value.IndexOf('1') > 0)
                            {
                                Rating = 1;
                            }
                            else if (p.Value.IndexOf('2') > 0)
                            {
                                Rating = 2;
                            }
                            else if (p.Value.IndexOf('3') > 0)
                            {
                                Rating = 3;
                            }
                            else if (p.Value.IndexOf('4') > 0)
                            {
                                Rating = 4;
                            }
                            else if (p.Value.IndexOf('5') > 0)
                            {
                                Rating = 5;
                            }
                        }
                        ;
                        po.Rating = Rating;
                        po.ProofTasks.ForEach(pt => pt.Rating = Rating);
                    }

                    if (p.Name == "样衣图片")
                    {
                        var picList = JsonHelper.JsonToList <string>(p.Value);
                        picList.ForEach(f =>
                        {
                            var fdata       = HttpHelper.DownloadData(f);
                            string name     = f.Substring(f.LastIndexOf('/') + 1);
                            string fullname = po.ProofStyle.ProofStyleId + "_" + name;
                            File.WriteAllBytes(SysPath + PicPath + fullname, fdata);
                            ProofFile pf = new ProofFile
                            {
                                FullName     = fullname,
                                DisplayName  = name,
                                Url          = PicPath + fullname,
                                FileType     = SG.Interface.Sys.FileType.Pic,
                                ProofStyleId = po.ProofStyle.ProofStyleId,
                            };
                            pf.SetCreateUser("钉钉审批");
                            po.ProofStyle.ProofFiles.Add(pf);
                        });
                    }
                });
                po.ProofStatus = ProofStatus.完成;
                sdc.SaveChanges();
            }
        }
        public bool UpdateProofOrder(ProofObj obj)
        {
            ProofOrder po = sdc.ProofOrders.Include(t => t.ProofStyle).Include(t => t.ProofStyle.ProofFiles).Include(t => t.ProofStyle.ProofType).Where(p => p.ProofOrderId == obj.ProofOrderId).SingleOrDefault();

            if (po != null)
            {
                ProofOrder _proofOrder = po;
                ProofStyle _proofSryle = po.ProofStyle;
                if (CheckObj(obj))
                {
                    _proofSryle.ProofStyleId = obj.ProofStyleId;
                    _proofSryle.ProofType    = sdc.ProofTypes.SingleOrDefault <ProofType>(p => p.TypeName == obj.ProofType);
                    _proofSryle.ProofStyleNo = obj.ProofStyleNo;
                    _proofSryle.ClentName    = obj.ClentName;
                    _proofSryle.ClientNo     = obj.ClientNo;
                    _proofSryle.StyleName    = obj.StyleName;
                    _proofSryle.Counts       = obj.Counts;
                    _proofSryle.Material     = obj.Material;
                    _proofSryle.Weight       = obj.Weight;
                    _proofSryle.Gauge        = obj.Gauge;
                    _proofSryle.ProofOrderId = obj.ProofOrderId;

                    _proofSryle.ProofFiles.ForEach(f =>
                    {
                        if (obj.FileListItems.Count(p => p.Id == f.Id) == 0)
                        {
                            f.Delete(_user.UserName);
                        }
                    });

                    obj.FileListItems.ForEach(f =>
                    {
                        if (f.Id == 0)
                        {
                            ProofFile npf = new ProofFile
                            {
                                FullName     = f.FullName,
                                DisplayName  = f.DisplayName,
                                Url          = f.Url,
                                ProofStyleId = _proofSryle.ProofStyleId,
                                FileType     = FileType.ClientFile
                            };
                            npf.SetCreateUser(_user.UserName);
                            _proofSryle.ProofFiles.Add(npf);
                        }
                    });
                    _proofOrder.ProofOrderId       = obj.ProofOrderId;
                    _proofOrder.ProofApplyUserDdId = _user.DdId;
                    _proofOrder.ProofApplyUserName = _user.UserName;
                    _proofOrder.ProofApplyDeptName = _user.DepartName;
                    _proofOrder.DesignatedCX       = obj.DesignatedCX;
                    _proofOrder.DesignatedGY       = obj.DesignatedGY;
                    _proofOrder.Remark             = obj.Remark;
                    _proofOrder.Urgency            = obj.Urgency;
                    _proofOrder.ProofStatus        = ProofStatus.草拟;
                    _proofOrder.RequiredDate       = obj.FinshDate;
                    _proofOrder.ProofNum           = obj.ProofNum;
                    _proofSryle.SetEditUser(_user.UserName);
                    _proofOrder.SetEditUser(_user.UserName);
                }

                return(true);
            }
            return(false);
        }