Exemple #1
0
        public bool DrawReplace(string formNo, string empNo)
        {
            string newMd5 = this.DrawReplace2(formNo, empNo);

            if (string.IsNullOrEmpty(newMd5))
            {
                return(false);
            }
            string sourcePath = System.IO.Path.GetFullPath(BaseHelper.UpPath);
            string targetPath = System.IO.Path.GetFullPath(BaseHelper.PublishedPath);

            return(BaseHelper.CopyFile(sourcePath + newMd5, targetPath + newMd5));
        }
Exemple #2
0
        public int OldImport(DataSet ds)
        {
            var customers = new TpaModule.TpaCustomerBll().GetList();
            var formTyps  = new BaseServices <FormType>().LoadEntities(c => true);

            DataTable dt          = ds.Tables[0];
            string    publishType = dt.ToString();


            int success = 0;

            foreach (var row in dt.Rows)
            {
                try
                {
                    string fileName = ((DataRow)(row)).ItemArray[0].ToString();
                    string ver      = ((DataRow)(row)).ItemArray[1].ToString();
                    int    pageSize = int.Parse(((DataRow)(row)).ItemArray[2].ToString());
                    string filePath = @"\\192.168.0.4\Minicut\公司文件\文控\图纸电子档\勿动\" + ((DataRow)(row)).ItemArray[3] + ".pdf";

                    string       reason      = ((DataRow)(row)).ItemArray[4].ToString();
                    DateTime     publishDate = DateTime.Parse(((DataRow)(row)).ItemArray[5].ToString());
                    const string publishEmp  = "1109004";
                    bool         isPass      = int.Parse(((DataRow)(row)).ItemArray[7].ToString()) == 1;

                    string fileType = Path.GetExtension(filePath);


                    Guid fileGroup = Guid.NewGuid();
                    using (var fs = new FileStream(filePath, FileMode.Open))
                    {
                        var md5 = DirFileHelper.GetMd5StringByStream(fs);

                        string targetPath = Path.GetFullPath(BaseHelper.UpPath);

                        //将文什上传至文档临时目录
                        BaseHelper.CopyFile(filePath, targetPath + md5);
                        using (var context = ContextFactory.ContextHelper)
                        {
                            //组建文件群组
                            context.FileGroups.Add(new FileGroup()
                            {
                                GroupGuid   = fileGroup,
                                CreateTime  = DateTime.Now,
                                CreateEmpNo = "1109001"
                            });

                            //上传文件

                            if (!context.Fileses.Any(c => c.Md5 == md5))
                            {
                                context.Fileses.Add(new Files()
                                {
                                    Md5         = md5,
                                    FileName    = fileName,
                                    FileType    = fileType,
                                    ContentType = "application/pdf",
                                });
                            }

                            context.FilesFileGroups.AddRange(new List <FilesFileGroup> {
                                new FilesFileGroup()
                                {
                                    Md5 = md5, GroupGuid = fileGroup
                                }
                            });
                            context.SaveChanges();
                        }


                        //组建文件关系
                    }

                    int formId = formTyps.Single(c => c.FormName.Contains(publishType)).FormId;

                    //创建表单内容
                    var form = new Form()
                    {
                        FormNo      = new Applying().CreateFormNo(new object()),
                        FormId      = formId,
                        CreateEmpNo = "1109001",
                        CreateTime  = publishDate,
                        SignPath    = null,
                        FormStatus  = (int)Form.StatusEnum.签核完成,
                        IsEmergents = false,
                        CloseTime   = DateTime.Now
                    };

                    //生成表单
                    new BaseServices <Form>().AddEntity(form);

                    #region insert
                    //生成表单详细页
                    switch (publishType)
                    {
                    case "BOM":
                        new BaseServices <FormDrawingsBom>().AddEntity(new FormDrawingsBom()
                        {
                            CustomerNo  = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            DrawPartNo  = ((DataRow)(row)).ItemArray[9].ToString(),
                            ProductNo   = ((DataRow)(row)).ItemArray[10].ToString(),
                            ProductName = ((DataRow)(row)).ItemArray[11].ToString(),
                            FileCode    = ((DataRow)(row)).ItemArray[12].ToString(),
                            Author      = ((DataRow)(row)).ItemArray[13].ToString(),

                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "ECN":
                        new BaseServices <FormDrawingsEcn>().AddEntity(new FormDrawingsEcn()
                        {
                            CustomerNo  = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            ProductNo   = ((DataRow)(row)).ItemArray[9].ToString(),
                            ProductName = ((DataRow)(row)).ItemArray[10].ToString(),
                            EcnNo       = ((DataRow)(row)).ItemArray[11].ToString(),
                            PublishEmp  = ((DataRow)(row)).ItemArray[12].ToString(),



                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "SOP":
                        new BaseServices <FormDrawingsSop>().AddEntity(new FormDrawingsSop()
                        {
                            CustomerNo = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            DrawPartNo = ((DataRow)(row)).ItemArray[9].ToString(),
                            Tag        = ((DataRow)(row)).ItemArray[10].ToString(),
                            Author     = ((DataRow)(row)).ItemArray[11].ToString(),

                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "包装工艺卡":
                        new BaseServices <FormDrawingsPackage>().AddEntity(new FormDrawingsPackage()
                        {
                            CustomerNo  = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            ProductNo   = ((DataRow)(row)).ItemArray[9].ToString(),
                            ProductName = ((DataRow)(row)).ItemArray[10].ToString(),
                            Author      = ((DataRow)(row)).ItemArray[11].ToString(),

                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "工艺流程图":
                        new BaseServices <FormDrawingsProcess>().AddEntity(new FormDrawingsProcess()
                        {
                            CustomerNo  = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            DrawPartNo  = ((DataRow)(row)).ItemArray[9].ToString(),
                            ProductNo   = ((DataRow)(row)).ItemArray[10].ToString(),
                            ProductName = ((DataRow)(row)).ItemArray[11].ToString(),
                            Drafter     = ((DataRow)(row)).ItemArray[12].ToString(),



                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "检规指导书":
                        new BaseServices <FormDrawingsFqc>().AddEntity(new FormDrawingsFqc()
                        {
                            CustomerNo  = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            DrawPartNo  = ((DataRow)(row)).ItemArray[9].ToString(),
                            ProductNo   = ((DataRow)(row)).ItemArray[10].ToString(),
                            ProductName = ((DataRow)(row)).ItemArray[11].ToString(),
                            Author      = ((DataRow)(row)).ItemArray[12].ToString(),


                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "客户图纸":
                        new BaseServices <FormDrawingsCustomer>().AddEntity(new FormDrawingsCustomer()
                        {
                            CustomerNo  = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            DrawPartNo  = ((DataRow)(row)).ItemArray[9].ToString(),
                            ProductNo   = ((DataRow)(row)).ItemArray[10].ToString(),
                            ProductName = ((DataRow)(row)).ItemArray[11].ToString(),
                            ManagerHead = ((DataRow)(row)).ItemArray[12].ToString(),

                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "内部图纸":
                        new BaseServices <FormDrawingsInside>().AddEntity(new FormDrawingsInside()
                        {
                            CustomerNo  = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            DrawPartNo  = ((DataRow)(row)).ItemArray[9].ToString(),
                            ProductNo   = ((DataRow)(row)).ItemArray[10].ToString(),
                            ProductName = ((DataRow)(row)).ItemArray[11].ToString(),
                            Drafter     = ((DataRow)(row)).ItemArray[12].ToString(),



                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "内部型材图":
                        new BaseServices <FormDrawingsProfile>().AddEntity(new FormDrawingsProfile()
                        {
                            CustomerNo  = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            ProfileNo   = ((DataRow)(row)).ItemArray[9].ToString(),
                            ProductNo   = ((DataRow)(row)).ItemArray[10].ToString(),
                            ProductName = ((DataRow)(row)).ItemArray[11].ToString(),
                            Drafter     = ((DataRow)(row)).ItemArray[12].ToString(),



                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "外来文件":
                        new BaseServices <FormDrawingsExternal>().AddEntity(new FormDrawingsExternal()
                        {
                            CustomerNo  = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            FileName    = ((DataRow)(row)).ItemArray[9].ToString(),
                            FileCode    = ((DataRow)(row)).ItemArray[10].ToString(),
                            MinicutCode = ((DataRow)(row)).ItemArray[11].ToString(),
                            ReciveEmpNo = ((DataRow)(row)).ItemArray[12].ToString(),



                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;

                    case "控制计划":
                        new BaseServices <FormDrawingsControlPlan>().AddEntity(new FormDrawingsControlPlan()
                        {
                            CustomerNo = customers.Single(c => c.CustomerName.Contains(((DataRow)(row)).ItemArray[8].ToString())).CustomerNo,
                            ProductNo  = ((DataRow)(row)).ItemArray[9].ToString(),
                            Author     = ((DataRow)(row)).ItemArray[10].ToString(),



                            FormNo = form.FormNo,
                            Mark   = "系统自动导入",

                            DrawVer     = ver,
                            PageSize    = pageSize,
                            FileGroup   = fileGroup,
                            Reason      = reason,
                            IsPublished = false,
                        });
                        break;
                    }
                    #endregion



                    //发行
                    if (this.Published(form.FormNo, 0, publishEmp, publishDate, isPass))
                    {
                        success++;
                    }
                }
                catch (Exception exception)
                {
                    return(Link.ErrorBy(new Exception($"成功导入{success}:Error:{exception.Message}"), this.GetType()));
                }
            }

            return(success);
        }
Exemple #3
0
        //表单发行
        private bool PublishPara <T>(T formEntity, Func <T, bool> whereLambda, int item, string empNo, FormType formType, DateTime?publishTime, bool isPass) where T : DrawingsBase, new()
        {
            //待发行的表单
            //  T formEntity = DALFactory.ContextHelperFactory<T>.Helper.LoadEntities(c => c.FormNo == formNo).First();

            string formNo = formEntity.FormNo;


            //已发行直接返回失败
            if (formEntity.IsPublished)
            {
                return(false);
            }

            //发行次数
            var publishedList = new BaseServices <T>().LoadEntities(whereLambda).ToList();

            //转换成版本
            var array = new byte[1];

            array[0] = (byte)(Convert.ToInt32(65 + publishedList.Count)); //ASCII码强制转换二进制

            //生成发行记录
            var published = new Published()
            {
                PubishedGuid = Guid.NewGuid(),
                FormNo       = formEntity.FormNo,
                PublishTime  = publishTime ?? DateTime.Now,
                PublishType  = formType.FormId,

                CustomerNo = formEntity.CustomerNo,
                FileGroup  = formEntity.FileGroup,
                ProductNo  = formEntity.ProductNo,



                EmpNo      = empNo,
                IsDel      = false,
                IsPass     = isPass,
                Identity   = Guid.NewGuid(),
                PublishVer = Convert.ToString(System.Text.Encoding.ASCII.GetString(array))
            };

            //Copy文件至发行目录

            string sourcePath = System.IO.Path.GetFullPath(BaseHelper.UpPath);
            string targetPath = System.IO.Path.GetFullPath(BaseHelper.PublishedPath);
            var    files      = formEntity.FileGroup;

            foreach (var file in new Carlzhu.Iooin.Business.BaseModule.FilesFileGroupBll().GetFileListByGroupGuid(files))
            {
                var ff = DataFactory.Database().FindEntity <Files>(file.Md5);
                BaseHelper.CopyFile(sourcePath + ff.Md5, targetPath + ff.Md5);
            }



            //添加标识
            if (publishedList.Count > 0)
            {
                this.UpdatePublishIdentity <T>(publishedList, published.Identity);
            }



            //发行
            if (item == 0)//记录导入,不用签核
            {
                return
                    (this.Publishing <T>
                         (formEntity, published));
            }
            return
                (new Signing().Agree(formNo, item, empNo)
                 &&
                 this.Publishing <T>(formEntity, published));
        }