Beispiel #1
0
        /// <summary>
        /// 城建档案转换PDF
        /// </summary>
        /// <param name="ProjectID"></param>
        /// <param name="FromFile"></param>
        /// <param name="ToFile"></param>
        /// <param name="CurProgressPercent"></param>
        /// <param name="CurProgressCount"></param>
        /// <returns></returns>
        public int PdfMergerList(int ContentID, int FromFile, int ToFile, ref int CurProgressPercent, ref int CurProgressCount)
        {
            int AllTaskCount;

            if (FromFile > ToFile)
            {
                //交换大小
                int tmpFile = FromFile;
                FromFile = ToFile;
                ToFile   = tmpFile;
            }

            string sql = "SELECT COUNT(a.文件ID) " +
                         "FROM WS_文件 as a INNER JOIN WS_案卷 as b ON a.案卷ID = b.案卷ID " +
                         "where b.目录ID={0} and b.案卷号 between {1} and {2}";

            switch (PdfMergerCommand.archivesType)
            {
                #region sql
            case ArchivesType.编制档案:
                sql = "SELECT COUNT(a.文件ID) " +
                      "FROM BZ_文件 as a INNER JOIN BZ_案卷 as b ON a.案卷ID = b.案卷ID " +
                      "where b.目录ID={0} and b.案卷号 between {1} and {2}";
                break;

            case ArchivesType.城建档案旧:
                sql = "SELECT COUNT(a.文件ID) " +
                      "FROM view城建文件旧 as a INNER JOIN view城建案卷旧 as b ON a.案卷ID = b.案卷ID " +
                      "where b.分类号ID={0} and b.案卷号 between {1} and {2}";
                break;

            case ArchivesType.城建档案新:
                sql = "SELECT COUNT(a.文件ID) " +
                      "FROM 城建文件 as a INNER JOIN 城建案卷 as b ON a.案卷ID = b.案卷ID " +
                      "where b.项目ID={0} and b.案卷号 between {1} and {2}";
                break;

            case ArchivesType.公安业务档案:
                sql = "SELECT COUNT(a.文件ID) " +
                      "FROM YW_文件 as a INNER JOIN YW_案卷 as b ON a.案卷ID = b.案卷ID " +
                      "where b.目录ID={0} and b.案卷号 between {1} and {2}";
                break;

            case ArchivesType.归档文件:
                sql = "select Count(文件ID) from GD_文件 where 类目ID={0} and 件号 between {1} and {2}";
                break;

            case ArchivesType.科技档案_2000:
                sql = "SELECT COUNT(a.文件ID) " +
                      "FROM KeJi_文件 as a INNER JOIN KeJi_案卷 as b ON a.案卷ID = b.案卷ID " +
                      "where b.目录ID={0} and b.案卷号 between {1} and {2}";
                break;

            case ArchivesType.社保业务档案:
                sql = "SELECT COUNT(a.文件ID) " +
                      "FROM SBYW_文件 as a INNER JOIN SBYW_案卷 as b ON a.案卷ID = b.案卷ID " +
                      "where b.目录ID={0} and b.案卷号 between {1} and {2}";
                break;

            case ArchivesType.文书档案:
                sql = "SELECT COUNT(a.文件ID) " +
                      "FROM WS_文件 as a INNER JOIN WS_案卷 as b ON a.案卷ID = b.案卷ID " +
                      "where b.目录ID={0} and b.案卷号 between {1} and {2}";
                break;

            case ArchivesType.沿革档案:
                sql = "SELECT COUNT(a.文件ID) " +
                      "FROM YG_文件 as a INNER JOIN YG_案卷 as b ON a.案卷ID = b.案卷ID " +
                      "where b.目录ID={0} and b.案卷号 between {1} and {2}";
                break;
                #endregion
            }

            sql          = String.Format(sql, ContentID, FromFile, ToFile);
            AllTaskCount = GetTaskCount(sql);//获取需要转换的文件数量

            if (AllTaskCount > 0)
            {
                ShowMsg("已完成任务 " + "0" + " / " + AllTaskCount.ToString());

                for (int i = FromFile; i <= ToFile; i++)
                {
                    string sqlForFileID = "select 案卷ID from BZ_案卷 where 目录ID={0} and 案卷号={1}";
                    switch (PdfMergerCommand.archivesType)
                    {
                    case ArchivesType.编制档案:
                        sqlForFileID = "select 案卷ID from BZ_案卷 where 目录ID={0} and 案卷号={1}";
                        break;

                    case ArchivesType.城建档案旧:
                        sqlForFileID = "select 案卷ID from view城建案卷旧 where 分类号ID={0} and 案卷号={1}";
                        break;

                    case ArchivesType.城建档案新:
                        sqlForFileID = "select 案卷ID from 城建案卷 where 项目ID={0} and 案卷号={1}";
                        break;

                    case ArchivesType.公安业务档案:
                        sqlForFileID = "select 案卷ID from YW_案卷 where 目录ID={0} and 案卷号={1}";
                        break;

                    case ArchivesType.归档文件:
                        //sqlForFileID = "select 案卷ID from GD_文件 where 类目ID={0} and 件={1}";
                        break;

                    case ArchivesType.科技档案_2000:
                        sqlForFileID = "select 案卷ID from KeJi_案卷 where 目录ID={0} and 案卷号={1}";
                        break;

                    case ArchivesType.社保业务档案:
                        sqlForFileID = "select 案卷ID from SBYW_案卷 where 目录ID={0} and 案卷号={1}";
                        break;

                    case ArchivesType.文书档案:
                        sqlForFileID = "select 案卷ID from WS_案卷 where 目录ID={0} and 案卷号={1}";
                        break;

                    case ArchivesType.沿革档案:
                        sqlForFileID = "select 案卷ID from YG_案卷 where 目录ID={0} and 案卷号={1}";
                        break;
                    }
                    //需要考虑案卷号重复的问题
                    //这种情况下,需要用案卷ID进行区别
                    sql = String.Format(sqlForFileID, ContentID, i);
                    DataSet ds = Archives.DataAccess.DataSql.Query(sql);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                        {
                            string sqlForDocID = "SELECT COUNT(文件ID) FROM WS_文件 where 案卷ID={0}";

                            switch (PdfMergerCommand.archivesType)
                            {
                            case ArchivesType.编制档案:
                                sql = "SELECT COUNT(文件ID) FROM BZ_文件 where 案卷ID={0}";
                                break;

                            case ArchivesType.城建档案旧:
                                sql = "SELECT COUNT(文件ID) FROM view城建文件旧 where 案卷ID={0}";
                                break;

                            case ArchivesType.城建档案新:
                                sql = "SELECT COUNT(文件ID) FROM 城建文件 where 案卷ID={0}";
                                break;

                            case ArchivesType.公安业务档案:
                                sql = "SELECT COUNT(文件ID) FROM YW_文件 where 案卷ID={0}";
                                break;

                            case ArchivesType.归档文件:
                                //sql = "SELECT COUNT(文件ID) FROM GD_文件 where 类目ID={0}";
                                break;

                            case ArchivesType.科技档案_2000:
                                sql = "SELECT COUNT(文件ID) FROM KeJi_文件 where 案卷ID={0}";
                                break;

                            case ArchivesType.社保业务档案:
                                sql = "SELECT COUNT(文件ID) FROM SBYW_文件 where 案卷ID={0}";
                                break;

                            case ArchivesType.文书档案:
                                sql = "SELECT COUNT(文件ID) FROM WS_文件 where 案卷ID={0}";
                                break;

                            case ArchivesType.沿革档案:
                                sql = "SELECT COUNT(文件ID) FROM YG_文件 where 案卷ID={0}";
                                break;
                            }
                            //按文件数显示进度条
                            sql = string.Format(sqlForDocID, ds.Tables[0].Rows[j][0].ToString());
                            DataSet ds2 = Archives.DataAccess.DataSql.Query(sql);
                            if (ds2.Tables[0].Rows.Count > 0)
                            {
                                CurProgressCount += Convert.ToInt16(ds2.Tables[0].Rows[0][0].ToString());
                            }
                            CurProgressPercent = Convert.ToInt16(100 * CurProgressCount / AllTaskCount);

                            lastFileID = ds.Tables[0].Rows[j][0].ToString();

                            //Archives.InterFace.PdfMerger.Pdf.PdfMakerBz.TopClassID = TopClassID.ToString();
                            //Archives.InterFace.PdfMerger.Pdf.PdfMakerBz.FileID = lastFileID;
                            //Archives.InterFace.PdfMerger.Pdf.PdfMakerBz.MakePdf();


                            PdfMaker.FileID = lastFileID;
                            PdfMaker.MakePdf();

                            ShowMsg("已完成任务 " + CurProgressCount.ToString() + " / " + AllTaskCount.ToString());
                            SetProgressBarValue(CurProgressPercent);
                        }
                    }
                }
                return(AllTaskCount);
            }
            else
            {
                return(-1);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 城建档案转换PDF(单独一卷)
        /// </summary>
        /// <param name="ProjectID"></param>
        /// <param name="FromFile"></param>
        /// <param name="ToFile"></param>
        /// <param name="CurProgressPercent"></param>
        /// <param name="CurProgressCount"></param>
        /// <returns></returns>
        private int PdfMergerSingle(int FileID, ref int CurProgressPercent, ref int CurProgressCount)
        {
            int AllTaskCount;

            string sql = "SELECT COUNT(文件ID) FROM WS_文件 where 案卷ID={0}";

            switch (PdfMergerCommand.archivesType)
            {
            case ArchivesType.编制档案:
                sql = "SELECT COUNT(文件ID) FROM BZ_文件 where 案卷ID={0}";
                break;

            case ArchivesType.城建档案旧:
                sql = "SELECT COUNT(文件ID) FROM view城建文件旧 where 案卷ID={0}";
                break;

            case ArchivesType.城建档案新:
                sql = "SELECT COUNT(文件ID) FROM 城建文件 where 案卷ID={0}";
                break;

            case ArchivesType.公安业务档案:
                sql = "SELECT COUNT(文件ID) FROM YW_文件 where 案卷ID={0}";
                break;

            case ArchivesType.归档文件:
                sql = "SELECT COUNT(文件ID) FROM GD_文件 where 类目ID={0}";
                break;

            case ArchivesType.科技档案_2000:
                sql = "SELECT COUNT(文件ID) FROM KeJi_文件 where 案卷ID={0}";
                break;

            case ArchivesType.社保业务档案:
                sql = "SELECT COUNT(文件ID) FROM SBYW_文件 where 案卷ID={0}";
                break;

            case ArchivesType.文书档案:
                sql = "SELECT COUNT(文件ID) FROM WS_文件 where 案卷ID={0}";
                break;

            case ArchivesType.沿革档案:
                sql = "SELECT COUNT(文件ID) FROM YG_文件 where 案卷ID={0}";
                break;
            }

            sql          = String.Format(sql, FileID);
            AllTaskCount = GetTaskCount(sql);//获取需要转换的文件数量

            if (AllTaskCount > 0)
            {
                ShowMsg("已完成任务 " + "0" + " / " + AllTaskCount.ToString());

                //按文件数显示进度条
                //sql = string.Format("select count(文件ID) from BZ_文件 where 案卷ID={0}", FileID);
                //DataSet ds2 = DataAccess.DataSql.Query(sql);
                //if (ds2.Tables[0].Rows.Count > 0)
                //{
                //    CurProgressCount += Convert.ToInt16(ds2.Tables[0].Rows[0][0].ToString());
                //}
                //CurProgressPercent = Convert.ToInt16(100 * CurProgressCount / AllTaskCount);
                if (AllTaskCount > 0)
                {
                    CurProgressCount += AllTaskCount;
                }
                CurProgressPercent = Convert.ToInt16(100 * CurProgressCount / AllTaskCount);


                //Archives.InterFace.PdfMerger.Pdf.PdfMakerBz.FileID = FileID.ToString();
                //Archives.InterFace.PdfMerger.Pdf.PdfMakerBz.TopClassID = TopClassID.ToString();
                //Archives.InterFace.PdfMerger.Pdf.PdfMakerBz.MakePdf();

                PdfMaker.FileID = FileID.ToString();
                PdfMaker.MakePdf();


                ShowMsg("已完成任务 " + CurProgressCount.ToString() + " / " + AllTaskCount.ToString());
                SetProgressBarValue(CurProgressPercent);

                return(AllTaskCount);
            }
            else
            {
                return(-1);
            }
        }