Esempio n. 1
0
        /// <summary>
        /// 打印公共方法
        /// </summary>
        /// <param name="reportName"></param>
        /// <param name="dv">数据视图</param>
        /// <returns></returns>
        public void DoPrint(string reportName, DataView dv)
        {
            string reportPath = startPath + @"\Reports\" + reportName + ".mrt";

            ////报表文件是否存在
            if (!System.IO.File.Exists(reportPath))
            {
                TXMessageBoxExtensions.Info("报表文件丢失!");
                return;
            }

            this.stiReport = new StiReport();
            this.stiReport.Load(reportPath);
            this.stiReport.RegData(reportName, dv);
            this.stiReport.Compile();
            this.stiReport.Render();
            string pdfPath  = string.Empty;
            string rootPath = startPath + @"\Reports\printPdf_temp\";

            MyCommon.DeleteAndCreateEmptyDirectory(rootPath, true);

            pdfPath = rootPath + reportName + ".pdf";
            stiReport.ExportDocument(StiExportFormat.Pdf, pdfPath);
            frmReports = new frmReport(pdfPath);
            frmReports.ShowDialog();
        }
Esempio n. 2
0
 /// <summary>
 /// 珠海的不要DWG字库,不要原文
 /// </summary>
 /// <returns></returns>
 private bool CreateXML2()
 {
     try
     {
         ERM.CBLL.CreateSip projectFactory = new ERM.CBLL.CreateSip(Globals.ProjectNO);
         GetProjectXML(projectFactory);
         GetListArchiveXML(projectFactory);
         GetDocumentXML(projectFactory);
         lblMsg.Text = "正在输出元数据信息...";
         Application.DoEvents();
         DataSet ds = CBFinalArchive.GetFinal_FileISP("ProjectNO='" + Globals.ProjectNO + "'");
         for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
         {
             GetZHDocModel(ds, i);
             if (progressBar2.Value < progressBar2.Maximum)
             {
                 progressBar2.Value++;
             }
             else
             {
                 progressBar2.Value = 1;
             }
             Application.DoEvents();
         }
         return(true);
     }
     catch (System.SystemException ex)
     {
         MyCommon.DeleteAndCreateEmptyDirectory(Application.StartupPath + "\\temp");
         return(false);
     }
 }
Esempio n. 3
0
        private bool?Confirm()
        {
            if (txtLoc.Text == "")
            {
                MyCommon.ShowWarning("请选择导出文件的存储路径!");
                txtLoc.Focus();
                return(null);
            }
            string destFilename = MyCommon.GetFileShortName(txtLoc.Text);

            destFolder = Path.GetDirectoryName(txtLoc.Text);
            if (!Directory.Exists(destFolder))
            {
                MyCommon.ShowWarning("存储的路径不存在!");
                return(null);
            }
            panelBottom.Visible = true;
            panelTop.Visible    = false;
            Application.DoEvents();
            butClose.Enabled = false;
            MyCommon.DeleteAndCreateEmptyDirectory(Application.StartupPath + "\\temp");
            ////开始遍历
            if (Properties.Settings.Default.SipIncludeDoc)
            {
                if (!this.CreateXML())
                {
                    return(false);
                }
            }
            else
            {
                if (!this.CreateXML2())
                {
                    return(false);
                }
            }
            lblMsg.Text = "正在对数据包进行封装...";
            Application.DoEvents();
            Common.ZipFile zip = new Common.ZipFile(Application.StartupPath + "\\temp", txtLoc.Text);
            if (!zip.StartZip())
            {
                MyCommon.DeleteAndCreateEmptyDirectory(Application.StartupPath + "\\temp");
                MyCommon.ShowWarning("封装数据时发生意外!");
                return(false);
            }
            tmrStart.Enabled   = false;
            progressBar1.Value = progressBar1.Maximum;
            progressBar2.Value = progressBar2.Maximum;
            butClose.Text      = "关闭";
            butClose.Enabled   = true;
            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// 文件转换成PDF
        /// </summary>
        /// <param name="fnOri">源文件</param>
        /// <param name="fnPDF">生成的PDF文件</param>
        /// <returns></returns>
        private bool FileConverToPDF(string fnOri, string fnPDF)
        {
            //.JPG,.JPEG,.PNG,.GIF,.BMP,.DOC,.DOCX,.XLS,.XLSX,.TIF,.TIFF,.PDF
            bool   result_flg = false;
            string sExt       = System.IO.Path.GetExtension(fnOri);

            if (sExt.Equals(".jpg", StringComparison.InvariantCultureIgnoreCase) ||
                sExt.Equals(".jpeg", StringComparison.InvariantCultureIgnoreCase) ||
                sExt.Equals(".tif", StringComparison.InvariantCultureIgnoreCase) ||
                sExt.Equals(".tiff", StringComparison.InvariantCultureIgnoreCase) ||
                sExt.Equals(".bmp", StringComparison.InvariantCultureIgnoreCase) ||
                sExt.Equals(".png", StringComparison.InvariantCultureIgnoreCase) ||
                sExt.Equals(".gif", StringComparison.InvariantCultureIgnoreCase) ||
                sExt.Equals(".doc", StringComparison.InvariantCultureIgnoreCase) ||
                sExt.Equals(".docx", StringComparison.InvariantCultureIgnoreCase) ||
                sExt.Equals(".xls", StringComparison.InvariantCultureIgnoreCase) ||
                sExt.Equals(".xlsx", StringComparison.InvariantCultureIgnoreCase))
            {
                MyCommon.DeleteAndCreateEmptyDirectory(tempFolder, false);
                MyCommon.DeleteAndCreateEmptyDirectory(tempFolder, true);
                try
                {
                    using (TransAndSignFile.UserControl1 s = new TransAndSignFile.UserControl1())
                    {
                        if (s.TransFileToPDF(fnOri, tempFolder, "error"))
                        {
                            string file_pdf = Path.Combine(tempFolder, Path.GetFileNameWithoutExtension(fnOri) + ".pdf");
                            if (File.Exists(file_pdf))
                            {
                                File.Copy(file_pdf, fnPDF, true);
                            }
                            result_flg = true;
                        }
                        else
                        {
                            MyCommon.WriteLog("ConvertCell2PDF转换PDF错误:" + s.GetLastError());
                        }
                    }
                }
                catch (Exception ex)
                {
                    MyCommon.WriteLog("ConvertCell2PDF转换PDF错误:" + fnOri + " " + ex.Message);
                }
            }
            return(result_flg);
        }
Esempio n. 5
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnProjectDelete_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection rows = this.dgProject.SelectedRows;

            if (rows.Count == 0)
            {
                return;
            }
            else
            {   //询问是否删除
                if (TXMessageBoxExtensions.Question("确定要删除工程:" + rows[0].Cells["ProjectName"].Value.ToString() + "吗?  \n 【温馨提示:删除工程后信息将无法恢复!请慎重!!!】") == DialogResult.Cancel)
                {
                    return;
                }
                else//确定删除
                {
                    string ProjectNO = rows[0].Cells["ProjectNO"].Value.ToString();
                    ERM.BLL.T_Projects_BLL ProjectsDB = new ERM.BLL.T_Projects_BLL();
                    T_Item_BLL             item       = new T_Item_BLL();
                    item.Delete(ProjectsDB.Find(ProjectNO).ItemID);

                    ProjectsDB.Delete(ProjectNO);
                    BLL.BLLMore bllMore = new BLLMore();

                    bllMore.DeleteUnitByProjectNO(ProjectNO);
                    bllMore.DeleteFileListByProjectNO(ProjectNO);
                    bllMore.DeleteCellFileByProjectNO(ProjectNO);
                    bllMore.DeleteArchiveByProjectNO(ProjectNO);
                    bllMore.DeleteGdListByProjectNO(ProjectNO);

                    bllMore.DeleteBrigeByProjectNO(ProjectNO);
                    bllMore.DeleteRoadLampByProjectNO(ProjectNO);
                    bllMore.DeleteTrafficByProjectNO(ProjectNO);

                    bllMore.DeletePointByPorjectNo(ProjectNO);
                    bllMore.DeleteYW_CellAndEFileByPorjectNo(ProjectNO);
                    MyCommon.DeleteAndCreateEmptyDirectory(Globals.ProjectPathParent + ProjectNO, false);
                    BindGridViewData(false);//重新绑定数据
                }
            }
        }
Esempio n. 6
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         ListView.CheckedListViewItemCollection items = this.listView1.CheckedItems;
         this.label2.Text = "正在删除文件!";
         while (items.Count > 0)
         {
             if (System.IO.Directory.Exists(items[0].Text))
             {
                 MyCommon.DeleteAndCreateEmptyDirectory(items[0].Text);
                 listView1.Items.Remove(items[0]);
             }
         }
         this.label2.Text = "删除成功!";
     }
     catch
     {
         MyCommon.Show("DWG字库文件删除失败!!");
     }
 }
Esempio n. 7
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            #region 异步调整压缩
            string dest_temp = Path.GetDirectoryName(txtLoc.Text);
            if (!Directory.Exists(dest_temp))
            {
                TXMessageBoxExtensions.Info("存储的路径不存在!");
                return;
            }
            #endregion

            #region 调整压缩
            bool?b = ConfirmSplitForfrmArchive();
            if (System.IO.Directory.Exists(tempFullName))
            {
                MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, false);
            }
            if (b.HasValue)
            {
                this.Close();
            }
            #endregion
        }
Esempio n. 8
0
        public List <ConvertPdfFile> GeneratePDFList(ListView.SelectedListViewItemCollection ListItems, frm2PDFProgressMsg dlg, string strNameBK = "", TreeNodeEx targeNode = null)
        {
            List <ConvertPdfFile> cplist = new List <ConvertPdfFile>();
            int i1 = 0;

            TransAndSignFile.UserControl1 s = null;
            s = new TransAndSignFile.UserControl1();

            foreach (ListViewItem item in ListItems)
            {
                string eFileID = Guid.NewGuid().ToString();
                string fnOri   = item.Name;
                string sExt    = System.IO.Path.GetExtension(fnOri);
                string fnPDF   = Globals.ProjectPath + "PDF\\" + eFileID + ".pdf";
                if ((sExt.Equals(".jpg", StringComparison.InvariantCultureIgnoreCase) ||
                     sExt.Equals(".jpeg", StringComparison.InvariantCultureIgnoreCase) ||
                     sExt.Equals(".tif", StringComparison.InvariantCultureIgnoreCase) ||
                     sExt.Equals(".tiff", StringComparison.InvariantCultureIgnoreCase) ||
                     sExt.Equals(".bmp", StringComparison.InvariantCultureIgnoreCase) ||
                     sExt.Equals(".png", StringComparison.InvariantCultureIgnoreCase) ||
                     sExt.Equals(".gif", StringComparison.InvariantCultureIgnoreCase) ||
                     sExt.Equals(".doc", StringComparison.InvariantCultureIgnoreCase) ||
                     sExt.Equals(".docx", StringComparison.InvariantCultureIgnoreCase) ||
                     sExt.Equals(".xls", StringComparison.InvariantCultureIgnoreCase) ||
                     sExt.Equals(".xlsx", StringComparison.InvariantCultureIgnoreCase)) && fnOri != "")
                {
                    MyCommon.DeleteAndCreateEmptyDirectory(tempFolder, false);
                    MyCommon.DeleteAndCreateEmptyDirectory(tempFolder, true);
                    try
                    {
                        i1++;
                        if (dlg.label2.Text != "")
                        {
                            dlg.label2.Text        = "正在导入:" + i1.ToString() + "/" + ListItems.Count.ToString();
                            dlg.progressBar1.Value = i1;
                            Application.DoEvents();
                        }
                        targeNode.Text = "导入中(" + i1 + "/" + ListItems.Count + ") " + strNameBK;
                        if (s.TransFileToPDF(fnOri, tempFolder, "error"))
                        {
                            string file_pdf = Path.Combine(tempFolder, Path.GetFileNameWithoutExtension(fnOri) + ".pdf");
                            if (File.Exists(file_pdf))
                            {
                                File.Copy(file_pdf, fnPDF);
                            }
                            ConvertPdfFile cp = new ConvertPdfFile();
                            cp.SourceFilePath = fnOri;
                            cp.PDFFilePath    = fnPDF;
                            cplist.Add(cp);
                        }
                        else
                        {
                            MyCommon.WriteLog("转换PDF错误:" + s.GetLastError());
                        }
                    }
                    catch (Exception ex)
                    {
                        MyCommon.WriteLog("转换PDF错误:" + fnOri + " " + ex.Message);
                    }
                }
            }
            if (dlg != null)
            {
                dlg.Close();
            }
            if (s != null)
            {
                s = null;
            }
            return(cplist);
        }
Esempio n. 9
0
        public int PrintCellToPDF(string cellFileName, string outFileName)
        {
            if (!System.IO.File.Exists(cellFileName))
            {
                return(0);
            }

            string FileExt = System.IO.Path.GetExtension(cellFileName);//文件后缀

            try
            {
                if (FileExt.ToLower() != ".cll")
                {
                    if (FileExt.ToLower() == ".pdf" ||
                        FileExt.ToLower() == ".daf")
                    {
                        System.IO.File.Copy(cellFileName, outFileName, true);
                        return(this.MergePDFFilesPages(outFileName));
                    }
                    else
                    {
                        if (this.FileConverToPDF(cellFileName, outFileName))
                        {
                            return(this.MergePDFFilesPages(outFileName));
                        }
                        else
                        {
                            return(0);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MyCommon.WriteLog("50cllPdf 转换pdf异常:" + ex.Message);
            }
            //System.Collections.ArrayList fileList = new System.Collections.ArrayList();
            //Cell2.SetPrinter(PrinterOperate.UsePrinterName);
            //Cell2.PrintPara(1, 1, 0, 0); //单色打印

            if (System.IO.Directory.Exists(tempPath))
            {
                MyCommon.DeleteAndCreateEmptyDirectory(tempPath, false);
                MyCommon.DeleteAndCreateEmptyDirectory(tempPath, true);
            }
            else
            {
                MyCommon.DeleteAndCreateEmptyDirectory(tempPath, true);
            }

            ArrayList fileList = new ArrayList();

            try
            {
                if (Cell2.OpenFile(cellFileName, "") != 1)
                {
                    return(0);
                }

                Cell2.PrintSetAlign(1, 1);
                Cell2.PrintSetMargin(5, 5, 5, 5);
                Cell2.PrintPara(1, 1, 0, 0); //单色打印
                //Cell2.SetCurSheet(j);
                //Cell2.PrintPageBreak(0);
            }
            catch (Exception ex)
            {
                MyCommon.WriteLog("Cell2 打开错误:" + ex.Message);
            }
            //判断当前页 所有的单元是否只读
            // 如果当前页的所有单元格只读,就不转换PDF
            // 否则 就直接转换PDF
            Assembly asm     = Assembly.GetExecutingAssembly();
            string   AppPath = asm.Location;

            try
            {
                bool isToPDF_flg = true;
                for (int j = 0; j < Cell2.GetTotalSheets(); j++)
                {
                    Cell2.SetCurSheet(j);
                    string TittleName = Cell2.GetSheetLabel(j);
                    if (TittleName != null)
                    {
                        if (TittleName.Contains("填表提示") || TittleName.Contains("填表说明") || TittleName.Trim() == "说明")//
                        {
                            continue;
                        }
                    }

                    string tempoutfileName = Guid.NewGuid().ToString() + ".pdf";
                    isToPDF_flg = true;
                    for (int iRow = 1; iRow < Cell2.GetRows(j) - 1; iRow++)
                    {
                        if (!isToPDF_flg)
                        {
                            break;
                        }
                        if (Cell2.IsRowHidden(iRow, j) == false && Cell2.GetRowHeight(1, iRow, j) > 10)
                        {
                            for (int iCol = 1; iCol < Cell2.GetCols(j) - 1; iCol++)
                            {
                                if (!isToPDF_flg)
                                {
                                    break;
                                }
                                if (Cell2.IsColHidden(iCol, j) == false && Cell2.GetColWidth(1, iCol, j) > 10)
                                {
                                    if (Cell2.GetCellInput(iCol, iRow, j) != 5)
                                    {
                                        isToPDF_flg = false;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if ((!isToPDF_flg))
                    {
                        //ConverToPDF.PreparePrint(Assembly.GetExecutingAssembly().FullName, "", tempPath + tempoutfileName);
                        //Cell2.PrintSheet(0, j);
                        //ConverToPDF.Wait4PringFinish("", tempPath + tempoutfileName);
                        if (Cell2.ExportPdfFile(tempPath + tempoutfileName, j, 0, 1))
                        {
                            fileList.Add(tempPath + tempoutfileName);
                        }
                    }
                }
                Cell2.closefile();
            }
            catch (Exception ex)
            {
                MyCommon.WriteLog("Cell2 转换PDF错误:" + ex.Message);
            }
            #region

            /*
             * //Cell2.ExportPdfFile(tempPath + tempoutfileName, -1, 0, Cell2.GetTotalSheets());
             *
             *
             * //for (int j = 0; j < Cell2.GetTotalSheets(); j++)
             * //{
             * //    string TittleName = Cell2.GetSheetLabel(j);
             * //    if (!TittleName.Contains(Globals.Descriptive))
             * //    {
             * //        fileList.Add(tempFile + j.ToString() + ".pdf");
             * //        outFile = tempFile + j.ToString() + ".pdf";
             * //        NewPrint();
             * //        oPrinterMonitor.OnPrinterInit += new _IPrinterMonitorEvents_OnPrinterInitEventHandler(oPrinterMonitor_OnPrinterInit);
             * //        Cell2.PrintSheet(0, j);
             * //        oPrinterMonitor.OnPrinterInit -= new _IPrinterMonitorEvents_OnPrinterInitEventHandler(oPrinterMonitor_OnPrinterInit);
             * //        Application.DoEvents();
             * //    }
             * //}
             *
             * //foreach (object obj in fileList)
             * //{
             * //    if(!System.IO.File.Exists(obj.ToString()))
             * //    {
             * //        fileList.Remove(obj);
             * //    }
             * //}
             * //if (fileList.Count <= 0)
             * //{
             * //    return 0;
             * //}
             * */
            #endregion
            string[] FileName = new string[fileList.Count];
            for (int i = 0; i < fileList.Count; i++)
            {
                FileName[i] = fileList[i].ToString();
            }
            if (FileName.Length <= 0)
            {
                return(0);
            }
            return(MergePDFFilesPages(outFileName));
        }
Esempio n. 10
0
        /// <summary>
        /// 复制
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Click(object sender, EventArgs e)
        {
            frm2PDFProgressMsg fmessage = new frm2PDFProgressMsg();

            fmessage.Text = "工程复制中...";
            try
            {
                string     sourceNO   = string.Empty;
                string     sourceName = string.Empty;
                string     targeNO    = string.Empty;
                string     targeName  = string.Empty;
                T_Projects sourcePorj;
                T_Projects targePorj;

                (cbx_Source.SelectedItem as System.Data.DataRowView)[0].ToString();

                if (cbx_Source.Items.Count == 1 || cbx_Trage.Items.Count == 1)
                {
                    TXMessageBoxExtensions.Info("提示:请选择需要复制的工程!");
                    cbx_Source.Focus();
                    return;
                }
                else if ((cbx_Source.SelectedItem as System.Data.DataRowView)[0].ToString() == "--请选择")
                {
                    TXMessageBoxExtensions.Info("提示:请选择复制的工程!");
                    cbx_Source.Focus();
                    return;
                }
                else if ((cbx_Trage.SelectedItem as System.Data.DataRowView)[0].ToString() == "--请选择")
                {
                    TXMessageBoxExtensions.Info("提示:请选择复制的目的工程!");
                    cbx_Trage.Focus();
                    return;
                }
                else
                {
                    sourceNO   = (cbx_Source.SelectedItem as System.Data.DataRowView)[1].ToString(); //要编辑的主键
                    sourceName = (cbx_Source.SelectedItem as System.Data.DataRowView)[0].ToString(); //要编辑的主键
                    targeNO    = (cbx_Trage.SelectedItem as System.Data.DataRowView)[1].ToString();  //要编辑的主键
                    targeName  = (cbx_Trage.SelectedItem as System.Data.DataRowView)[0].ToString();  //要编辑的主键

                    //根据工程编号查询工程类别
                    sourcePorj = projectBLL.Find(sourceNO);
                    targePorj  = projectBLL.Find(targeNO);
                    if (sourcePorj.ProjectCategory != targePorj.ProjectCategory)
                    {
                        TXMessageBoxExtensions.Info("复制的工程类别必须一致!");
                        return;
                    }
                    if (sourceNO == targeNO)
                    {
                        TXMessageBoxExtensions.Info("提示:同一工程不能复制!");
                        return;
                    }
                }
                if (TXMessageBoxExtensions.Question("提示:确定将工程\n编号:" + sourceNO + " 名称:" +
                                                    sourceName + "\n复制到工程\n编号:" + targeNO + " 名称:" + targeName
                                                    + "\n【温馨提示:复制之后工程信息将无法恢复!请慎重!!!】") == DialogResult.OK)
                {
                    status_flg        = true;
                    btn_Copy.Enabled  = false;
                    btn_Colse.Enabled = false;

                    fmessage      = new frm2PDFProgressMsg();
                    fmessage.Text = "工程复制中...";
                    fmessage.progressBar1.Maximum = 4;

                    fmessage.label2.Text        = "正在删除工程编号:" + targeNO + "信息...";
                    fmessage.progressBar1.Value = 1;
                    fmessage.Show();
                    Application.DoEvents();

                    //删除目的工程下信息
                    BLL.BLLMore bllMore = new BLL.BLLMore();
                    bllMore.DeleteUnitByProjectNO(targeNO);
                    bllMore.DeleteFileListByProjectNO(targeNO);
                    bllMore.DeleteCellFileByProjectNO(targeNO);
                    bllMore.DeleteArchiveByProjectNO(targeNO);
                    bllMore.DeleteGdFileByProjectNO(targeNO);//删除归档类别

                    #region add deleteProject
                    bllMore.DeleteTrafficByProjectNO(targeNO);
                    bllMore.DeleteRoadLampByProjectNO(targeNO);
                    bllMore.DeleteBrigeByProjectNO(targeNO);
                    bllMore.DeletePointByPorjectNo(targeNO);
                    #endregion

                    MyCommon.DeleteAndCreateEmptyDirectory(Globals.ProjectPathParent + targeNO);

                    //将源工程信息Copy到目的工程
                    fmessage.label2.Text        = "正在更新工程编号:" + targeNO + "信息...";
                    fmessage.progressBar1.Value = 2;
                    Application.DoEvents();

                    BLL.T_Projects_BLL Proj_bll        = new ERM.BLL.T_Projects_BLL();
                    ERM.MDL.T_Projects targe_proj_MDL  = Proj_bll.Find(targeNO);
                    ERM.MDL.T_Projects source_proj_MDL = Proj_bll.Find(sourceNO);
                    targe_proj_MDL.address     = source_proj_MDL.address;
                    targe_proj_MDL.area1       = source_proj_MDL.area1;
                    targe_proj_MDL.area2       = source_proj_MDL.area2;
                    targe_proj_MDL.begindate   = source_proj_MDL.begindate;
                    targe_proj_MDL.bgyfmj      = source_proj_MDL.bgyfmj;
                    targe_proj_MDL.bjdate      = source_proj_MDL.bjdate;
                    targe_proj_MDL.category    = source_proj_MDL.category;
                    targe_proj_MDL.cfmj        = source_proj_MDL.cfmj;
                    targe_proj_MDL.createdate  = source_proj_MDL.createdate;
                    targe_proj_MDL.district    = source_proj_MDL.district;
                    targe_proj_MDL.dxsmj       = source_proj_MDL.dxsmj;
                    targe_proj_MDL.enddate     = source_proj_MDL.enddate;
                    targe_proj_MDL.floors1     = source_proj_MDL.floors1;
                    targe_proj_MDL.floors2     = source_proj_MDL.floors2;
                    targe_proj_MDL.ghcode      = source_proj_MDL.ghcode;
                    targe_proj_MDL.high        = source_proj_MDL.high;
                    targe_proj_MDL.hjqk        = source_proj_MDL.hjqk;
                    targe_proj_MDL.jldwshr     = source_proj_MDL.jldwshr;
                    targe_proj_MDL.jsdwshr     = source_proj_MDL.jsdwshr;
                    targe_proj_MDL.passwd      = source_proj_MDL.passwd;
                    targe_proj_MDL.price1      = source_proj_MDL.price1;
                    targe_proj_MDL.price2      = source_proj_MDL.price2;
                    targe_proj_MDL.projecttype = source_proj_MDL.projecttype;
                    targe_proj_MDL.qtyfmj      = source_proj_MDL.qtyfmj;
                    targe_proj_MDL.sgbzz       = source_proj_MDL.sgbzz;
                    targe_proj_MDL.sgcode      = source_proj_MDL.sgcode;
                    targe_proj_MDL.stru        = source_proj_MDL.stru;
                    targe_proj_MDL.syyfmj      = source_proj_MDL.syyfmj;
                    targe_proj_MDL.tbr         = source_proj_MDL.tbr;
                    targe_proj_MDL.tempid      = source_proj_MDL.tempid;
                    targe_proj_MDL.ts1         = source_proj_MDL.ts1;
                    targe_proj_MDL.ts2         = source_proj_MDL.ts2;
                    targe_proj_MDL.ts3         = source_proj_MDL.ts3;
                    targe_proj_MDL.ts4         = source_proj_MDL.ts4;
                    targe_proj_MDL.tstotal     = source_proj_MDL.tstotal;
                    targe_proj_MDL.ydpzcode    = source_proj_MDL.ydpzcode;
                    targe_proj_MDL.ydxkcode    = source_proj_MDL.ydxkcode;
                    targe_proj_MDL.zjy         = source_proj_MDL.zjy;
                    targe_proj_MDL.zygz        = source_proj_MDL.zygz;
                    targe_proj_MDL.zzmj        = source_proj_MDL.zzmj;

                    targe_proj_MDL.ztcw   = source_proj_MDL.ztcw;
                    targe_proj_MDL.dstcw  = source_proj_MDL.dstcw;
                    targe_proj_MDL.dxtcw  = source_proj_MDL.dxtcw;
                    targe_proj_MDL.kzsfcd = source_proj_MDL.kzsfcd;
                    targe_proj_MDL.ts5    = source_proj_MDL.ts5;
                    targe_proj_MDL.XMJL   = source_proj_MDL.XMJL;
                    targe_proj_MDL.yjdw   = source_proj_MDL.yjdw;
                    targe_proj_MDL.XCJL   = source_proj_MDL.XCJL;

                    Proj_bll.Update(targe_proj_MDL);

                    //坐标信息
                    IList <T_Point> t_point_source = new T_Point_BLL().GetList(sourceNO);
                    foreach (var item in t_point_source)
                    {
                        item.ID        = Guid.NewGuid().ToString();
                        item.ProjectNo = targeNO;
                        new T_Point_BLL().Insert(item);
                    }

                    //电子文件
                    bllMore.CopyFileAndEFileList(sourceNO, targeNO);

                    BLL.T_Archive_BLL      archive_bll  = new ERM.BLL.T_Archive_BLL();      //案卷信息
                    BLL.T_FileList_BLL     filelist_bll = new ERM.BLL.T_FileList_BLL();     //文件表
                    BLL.T_CellAndEFile_BLL cellAndEfile = new ERM.BLL.T_CellAndEFile_BLL(); //电子文件
                    //单位
                    BLL.T_Units_BLL     units_bll = new ERM.BLL.T_Units_BLL();              //施工单位
                    IList <MDL.T_Units> IUnits    = units_bll.FindByProjectNO(sourceNO);
                    if (IUnits != null && IUnits.Count > 0)
                    {
                        foreach (MDL.T_Units units in IUnits)
                        {
                            units.UnitID    = Guid.NewGuid().ToString();
                            units.ProjectNO = targeNO;
                            units_bll.Add(units);//保存
                        }
                    }

                    //扩展信息
                    switch (sourcePorj.ProjectCategory)
                    {
                    case "Traffic":
                        T_Traffic_BLL trafficBll = new T_Traffic_BLL();
                        T_Traffic     traffic    = trafficBll.QueryTraffic_ByProjID(sourceNO);
                        if (traffic != null)
                        {
                            traffic.ID        = Guid.NewGuid().ToString();
                            traffic.ProjectID = targeNO;
                            trafficBll.Insert(traffic);
                        }
                        break;

                    case "RoadLamp":
                        T_Project_RoadLamp_BLL roadLampBll = new T_Project_RoadLamp_BLL();
                        T_Project_RoadLamp     roadLamp    = roadLampBll.QueryRoadLamp_ByProjID(sourceNO);
                        if (roadLamp != null)
                        {
                            roadLamp.ProjectID = targeNO;
                            roadLamp.ID        = Guid.NewGuid().ToString();
                            roadLampBll.Insert(roadLamp);
                        }
                        break;

                    case "Brige":
                        T_Project_Brige_BLL brigeBll = new T_Project_Brige_BLL();
                        T_Project_Brige     brige    = brigeBll.QueryBrige_ByProjID(sourceNO);
                        if (brige != null)
                        {
                            brige.ID        = Guid.NewGuid().ToString();
                            brige.ProjectID = targeNO;
                            brigeBll.Insert(brige);
                        }
                        break;
                    }

                    fmessage.progressBar1.Value = 3;
                    Application.DoEvents();

                    //迁移文件夹
                    string   mprojectPath  = Application.StartupPath + "\\Project\\" + sourceNO;
                    string   tprojectPath  = Application.StartupPath + "\\Project\\" + targeNO;
                    string[] DirectoryList = new string[] { "MPDF", "ODOC", "PDF" };

                    if (System.IO.Directory.Exists(tprojectPath))
                    {
                        MyCommon.DeleteAndCreateEmptyDirectory(tprojectPath, false);
                        MyCommon.DeleteAndCreateEmptyDirectory(tprojectPath, true);
                    }
                    else
                    {
                        MyCommon.DeleteAndCreateEmptyDirectory(tprojectPath, true);
                    }
                    string tempText  = fmessage.label2.Text;
                    char[] tempChar  = tempText.ToCharArray();
                    int    tempIndex = 0;
                    foreach (string dic in DirectoryList)
                    {
                        MyCommon.DeleteAndCreateEmptyDirectory(tprojectPath + "\\" + dic, true);
                        fmessage.label2.Text = "";
                        if (System.IO.Directory.Exists(mprojectPath))
                        {
                            if (System.IO.Directory.Exists(mprojectPath + "\\" + dic))
                            {
                                string[] files = System.IO.Directory.GetFiles(mprojectPath + "\\" + dic);
                                foreach (string filename in files)
                                {
                                    fmessage.label2.Text += tempChar[tempIndex];
                                    Application.DoEvents();
                                    tempIndex++;
                                    if (tempIndex >= tempChar.Length)
                                    {
                                        tempIndex            = 0;
                                        fmessage.label2.Text = "";
                                    }
                                    System.IO.FileInfo fileinfo = new System.IO.FileInfo(filename);
                                    if (System.IO.File.Exists(filename))
                                    {
                                        System.IO.File.Copy(filename, tprojectPath + "\\" + dic + "\\" + fileinfo.Name, true);
                                    }
                                }
                            }
                        }
                    }

                    fmessage.progressBar1.Value = 4;
                    Application.DoEvents();
                    fmessage.Close();

                    btn_Copy.Enabled  = true;
                    btn_Colse.Enabled = true;

                    TXMessageBoxExtensions.Info("提示:复制成功!");
                    BindGridViewData();
                }
            }
            catch (Exception ex)
            {
                if (fmessage != null)
                {
                    fmessage.Close();
                }
                TXMessageBoxExtensions.Info("提示:复制失败!");
                MyCommon.WriteLog("复制工程错误:" + ex.Message);
                btn_Copy.Enabled  = true;
                btn_Colse.Enabled = true;
            }
        }
Esempio n. 11
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            bool  bRun = true;
            Mutex m    = new Mutex(true, Application.ProductName, out bRun);

            if (bRun)
            {
                m.ReleaseMutex();
            }
            else
            {
                TXMessageBoxExtensions.Info("程序已经运行!");
                return;
            }
            if (!System.IO.Directory.Exists(Globals.ProjectPath))
            {
                System.IO.Directory.CreateDirectory(Globals.ProjectPath);
            }
            if (!System.IO.Directory.Exists(Globals.CellPath))
            {
                System.IO.Directory.CreateDirectory(Globals.CellPath);
            }
            if (!Globals.UpdateSettings() ||
                !System.IO.Directory.Exists(Globals.CellPath) ||
                !System.IO.Directory.Exists(Globals.ProjectPath))
            {
                return;
            }
            //启动清空临时打印目录
            #region
            System.Diagnostics.Process[] pro_Print = System.Diagnostics.Process.GetProcessesByName("JRPDFPrint");
            string tempFolder = string.Empty;
            if (pro_Print == null || pro_Print.Length == 0)
            {
                tempFolder =
                    System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "erm_print");
                if (System.IO.Directory.Exists(tempFolder))
                {
                    MyCommon.DeleteAndCreateEmptyDirectory(tempFolder, false);
                    MyCommon.DeleteAndCreateEmptyDirectory(tempFolder, true);
                }
                else
                {
                    MyCommon.DeleteAndCreateEmptyDirectory(tempFolder, true);
                }
            }
            ///移交时生成的临时目录
            tempFolder = System.IO.Path.Combine(Application.StartupPath, "temp_YJ");
            if (System.IO.Directory.Exists(tempFolder))
            {
                MyCommon.DeleteAndCreateEmptyDirectory(tempFolder, false);
                MyCommon.DeleteAndCreateEmptyDirectory(tempFolder, true);
            }
            else
            {
                MyCommon.DeleteAndCreateEmptyDirectory(tempFolder, true);
            }
            #endregion

            ReadWriteAppConfig config = new ReadWriteAppConfig();
            if (config.Read("Upload_ProjectSize") == "")
            {
                config.Write("Upload_ProjectSize", "4");
            }

            /**************************************************************************************************
             * 验证:
             * C7643B2A-EC98-4A8C-ACDD-1BF0A20F8C04:次数+天数
             * 99673744-DF8F-4001-83A9-8E77DF2D1EEB:时间
             * CC4526BE-800D-4EBC-BFE9-9D44C88ED7EE:次数
             **********************************************************************************************/
            //判断注册项表中的值
            //判断注册项表中的值
            //try
            //{
            //    RegistAction rAction = new RegistAction();
            //    ReadWriteAppConfig configAction = new ReadWriteAppConfig();
            //    if (configAction.Read("UseType") == "C7643B2A-EC98-4A8C-ACDD-1BF0A20F8C04")
            //    {
            //        if (rAction.IsRegeditExit("UseCount"))
            //        {
            //            string UseCount = rAction.GetRegistData("UseCount");
            //            string UseCurCount = rAction.GetRegistData("UseCurCount");
            //            string UseDay = rAction.GetRegistData("UseDay");
            //            if (Convert.ToInt32(UseCount) <= Convert.ToInt32(UseCurCount) ||
            //                DateTime.Now >= Convert.ToDateTime(UseDay))
            //            {
            //                TXMessageBoxExtensions.Info("提示:软件已过期 或 已过使用次数" + UseCount + "! \n  【温馨提示:如有疑问请与我们联系,0755-83995038】");
            //                return;
            //            }
            //            else
            //            {
            //                if (Convert.ToInt32(UseCount) - Convert.ToInt32(UseCurCount) <= 10)
            //                {
            //                    TXMessageBoxExtensions.Info("提示:软件使用次数只剩:" + (Convert.ToInt32(UseCount) - Convert.ToInt32(UseCurCount)) + " 次! \n  【温馨提示:如有疑问请与我们联系,0755-83995038】");
            //                }
            //                else if (Convert.ToInt32((Convert.ToDateTime(UseDay) - DateTime.Now).TotalDays) <= 10)
            //                {
            //                    TXMessageBoxExtensions.Info("提示:软件使用天数只剩:" + Convert.ToInt32((Convert.ToDateTime(UseDay) - DateTime.Now).TotalDays) + " 天! \n  【温馨提示:如有疑问请与我们联系,0755-83995038】");
            //                }
            //                rAction.WTRegedit("UseCurCount", (Convert.ToInt32(UseCurCount) + 1).ToString());
            //            }
            //        }
            //        else
            //        {
            //            rAction.WTRegedit("UseCount", configAction.Read("UseCount"));
            //            rAction.WTRegedit("UseCurCount", "1");
            //            rAction.WTRegedit("UseDay", DateTime.Now.AddDays(Convert.ToDouble(configAction.Read("UseDay"))).ToString("yyyy-MM-dd hh:mm:ss"));
            //        }
            //    }
            //    else if (configAction.Read("UseType") == "99673744-DF8F-4001-83A9-8E77DF2D1EEB")
            //    {
            //        if (rAction.IsRegeditExit("UseDate"))
            //        {
            //            string UseDate = rAction.GetRegistData("UseDate");
            //            if (DateTime.Compare(Convert.ToDateTime(UseDate), DateTime.Now) < 0)
            //            {
            //                TXMessageBoxExtensions.Info("提示:软件已过期 ! \n  【温馨提示:如有疑问请与我们联系,0755-83995038】");
            //                return;
            //            }
            //            else
            //            {
            //                if (Convert.ToInt32((Convert.ToDateTime(UseDate) - DateTime.Now).TotalDays) <= 10)
            //                {
            //                    TXMessageBoxExtensions.Info("提示:软件使用天数只剩:" + Convert.ToInt32((Convert.ToDateTime(UseDate) - DateTime.Now).TotalDays) + " 天! \n  【温馨提示:如有疑问请与我们联系,0755-83995038】");
            //                }
            //            }
            //        }
            //        else
            //        {
            //            string date_flg = configAction.Read("UseValue");
            //            string dataValue = rAction.Decrypt(date_flg, "digipowo");
            //            if (DateTime.Compare(Convert.ToDateTime(dataValue), DateTime.Now) < 0)
            //            {
            //                TXMessageBoxExtensions.Info("提示:软件已过期 ! \n  【温馨提示:如有疑问请与我们联系,0755-83995038】");
            //                return;
            //            }
            //            rAction.WTRegedit("UseDate", dataValue);
            //        }
            //    }
            //    else if (configAction.Read("UseType") == "CC4526BE-800D-4EBC-BFE9-9D44C88ED7EE")
            //    {
            //        //次数 100次:tkHPYaX8TwI= 150次:GnDjrw+KlkA= 0次:MoYeGrkYqas=
            //        //string temp = rAction.Decrypt("lrfJqKfPr2I=", "digipowo");
            //        string UseCount = configAction.Read("UseCount");
            //        string UseCurCount = configAction.Read("UseCurCount");
            //        UseCount = rAction.Decrypt(UseCount, "digipowo");
            //        UseCurCount = rAction.Decrypt(UseCurCount, "digipowo");

            //        if (Convert.ToInt32(UseCurCount) < Convert.ToInt32(UseCount))
            //        {
            //            configAction.Write("UseCurCount", rAction.Encrypt((Convert.ToInt32(UseCurCount) + 1).ToString(), "digipowo"));
            //        }
            //        else
            //        {
            //            TXMessageBoxExtensions.Info("提示:软件已过期 ! \n  【温馨提示:如有疑问请与我们联系,0755-83995038】");
            //            return;
            //        }
            //    }
            //    else
            //    {
            //        TXMessageBoxExtensions.Info("注册信息读取失败! \n     【温馨提示:如有疑问请与我们联系,0755-83995038】");
            //        return;
            //    }
            //}
            //catch (Exception ex)
            //{
            //    TXMessageBoxExtensions.Info("注册信息读取失败! \n     【温馨提示:如有疑问请与我们联系,0755-83995038】");
            //    return;
            //}

            //string system32Path = Environment.GetFolderPath(Environment.SpecialFolder.System);//"C:\\Windows\\system32"
            //try
            //{
            //    if (!System.IO.File.Exists(system32Path + "\\CellCtrl5.ocx"))
            //    {
            //        System.IO.File.Copy(Application.StartupPath + "\\SystemFiles\\CellCtrl5.ocx", system32Path + "\\CellCtrl5.ocx", true);
            //    }
            //}
            //catch (Exception ex) { MyCommon.WriteLog("注册插件失败:" + ex.Message); }

            frmLogin     frm = new frmLogin();
            DialogResult ret = frm.ShowDialog();
            if (ret == DialogResult.OK)
            {
                Application.Run(new frmMDIMain());
            }
            else
            {
                Application.Exit();
            }
        }
Esempio n. 12
0
        /// <summary>
        /// 按案卷上报
        /// </summary>
        /// <returns></returns>
        private bool?ConfirmSplitForfrmArchive()
        {
            if (txtLoc.Text == "")
            {
                MyCommon.ShowWarning("请选择导出文件的存储路径!");
                txtLoc.Focus();
                return(null);
            }
            string destFilename = Globals.ProjectNO;

            destFolder = txtLoc.Text + "\\" + destFilename;
            MyCommon.DeleteAndCreateEmptyDirectory(destFolder);
            panelBottom.Visible = true;
            panelTop.Visible    = false;
            Application.DoEvents();
            butClose.Enabled = false;
            ERM.CBLL.CreateSip projectFactory = new ERM.CBLL.CreateSip(Globals.ProjectNO);
            DataSet            dsFinalArchive = projectFactory.GetListArchive(Globals.ProjectNO, "");

            if (dsFinalArchive.Tables.Count < 1 || dsFinalArchive.Tables[0].Rows.Count < 1)
            {
                MyCommon.ShowWarning("没有任何案卷可以移交!");
                return(false);
            }
            int count_FinalArchive = dsFinalArchive.Tables[0].Rows.Count;

            progressBar2.Maximum = count_FinalArchive;
            progressBar2.Minimum = 0;
            progressBar2.MarqueeAnimationSpeed = 1000;
            progressBar2.Step = 1;
            lblMsg.Text       = "正在输出元数据信息...";
            Application.DoEvents();
            MyCommon.DeleteAndCreateEmptyDirectory(Application.StartupPath + "\\temp");
            //List<string> fontList = GetDWGFontInfo();
            //GetProjectXML(projectFactory, fontList);
            GetProjectXML(projectFactory);
            GetListArchiveXML(projectFactory);
            GetDocumentXML(projectFactory);
            for (int i = 0; i < count_FinalArchive; i++)
            {
                if (!Directory.Exists(Application.StartupPath + "\\temp"))
                {
                    Directory.CreateDirectory(Application.StartupPath + "\\temp");
                }
                if (Properties.Settings.Default.SipIncludeDoc)
                {
                    GetListArchiveXMLEx(dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString());
                    GetDocumentXMLEx(dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString());
                    BLL.T_FileList_BLL     fileBLL  = new ERM.BLL.T_FileList_BLL();
                    IList <MDL.T_FileList> fileList = fileBLL.FindByArchiveID(dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString(), Globals.ProjectNO);
                    foreach (MDL.T_FileList obj in fileList)
                    {
                        getDocModel(obj);
                    }
                }
                lblMsg.Text = "正在对数据包进行封装...";
                Application.DoEvents();
                try
                {
                    if (System.IO.File.Exists(Application.StartupPath + "\\temp\\index.dat"))
                    {
                        System.IO.File.Move(Application.StartupPath + "\\temp\\index.dat", destFolder + "\\index.dat");
                        string gcInfo  = System.IO.File.ReadAllText(Application.StartupPath + "\\temp\\a#sgwj_gc.xml", Encoding.GetEncoding("gb2312"));
                        string docList = System.IO.File.ReadAllText(destFolder + "\\index.dat");
                        gcInfo = gcInfo.Replace("</项目工程信息>", "<ArchiveFileList>" + docList + "</ArchiveFileList></项目工程信息>");
                        System.IO.File.WriteAllText(destFolder + "\\index.dat", gcInfo, Encoding.GetEncoding("gb2312"));
                    }
                }
                catch { }
                Common.ZipFile zip = new Common.ZipFile(Application.StartupPath + "\\temp", destFolder + "\\" + dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString() + ".sip");
                if (!zip.StartZip())
                {
                    MyCommon.DeleteAndCreateEmptyDirectory(Application.StartupPath + "\\temp");
                    MyCommon.ShowWarning("封装数据时发生意外!");
                    return(false);
                }
                MyCommon.DeleteAndCreateEmptyDirectory(Application.StartupPath + "\\temp");
                progressBar2.Value = progressBar2.Value + 1;
            }
            butClose.Text    = "关闭";
            butClose.Enabled = true;
            return(true);
        }
Esempio n. 13
0
 private void GotoError(string ex)
 {
     MyCommon.ShowWarning(ex);
     MyCommon.DeleteAndCreateEmptyDirectory(Application.StartupPath + "\\temp");
 }
Esempio n. 14
0
        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            txtLoc.Text = txtLoc.Text.Trim();
            if (txtLoc.Text == "")
            {
                TXMessageBoxExtensions.Info("提示:请选择导出文件的存储路径!");
                txtLoc.Focus();
                return;
            }
            string destFilename = MyCommon.GetFileShortName(txtLoc.Text);
            string destFolder   = Path.GetDirectoryName(txtLoc.Text);

            if (!Directory.Exists(destFolder))
            {
                TXMessageBoxExtensions.Info("存储的路径不存在!");
                return;
            }
            /// <summary>
            /// 导出功能涉及的文件临时存放目录
            /// </summary>
            string tempFullName =
                Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\ERM\\OutDataTemp";

            try
            {
                btnCancel.Enabled   = false;
                btnConfirm.Enabled  = false;
                btnExplorer.Enabled = false;

                if (System.IO.Directory.Exists(tempFullName))
                {
                    MyCommon.DeleteFilesAndFolders(tempFullName);
                }
                Directory.CreateDirectory(tempFullName);
                // MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, false);
                //MyCommon.DeleteAndCreateEmptyDirectory(tempFullName);

                MyCommon.DeleteAndCreateEmptyDirectory(tempFullName + "\\" + TheNode.Name + "\\T_GdList\\");
                MyCommon.DeleteAndCreateEmptyDirectory(tempFullName + "\\" + TheNode.Name + "\\T_FileList\\");
                MyCommon.DeleteAndCreateEmptyDirectory(tempFullName + "\\" + TheNode.Name + "\\T_CellAndEFile\\");
                MyCommon.DeleteAndCreateEmptyDirectory(tempFullName + "\\" + TheNode.Name + "\\T_CellAndEFile\\ODOC\\"); //原文
                MyCommon.DeleteAndCreateEmptyDirectory(tempFullName + "\\" + TheNode.Name + "\\T_CellAndEFile\\PDF\\");  //原文的PDF文件
                MyCommon.DeleteAndCreateEmptyDirectory(tempFullName + "\\" + TheNode.Name + "\\T_CellAndEFile\\MPDF\\"); //文件级电子文件,带章

                int sumCount = 0;
                GetNodesCount(TheNode, ref sumCount);
                GetChildToFileCount(TheNode, ref sumCount);
                progressBar1.Maximum = sumCount;

                ParentToFile(TheNode, tempFullName + "\\" + TheNode.Name);
                ChildToFile(TheNode, tempFullName + "\\" + TheNode.Name);

                lblTitle.Text      = @"正在压缩导出数据....";
                progressBar1.Value = progressBar1.Maximum / 2;
                Application.DoEvents();

                //Common.ZipFile zip = new Common.ZipFile(tempFullName + "\\", txtLoc.Text);
                //zip.StartZip();

                SevenZip.SevenZipCompressor.SetLibraryPath(Application.StartupPath + "\\7z.dll");
                SevenZip.SevenZipCompressor tmp = new SevenZip.SevenZipCompressor();
                tmp.ArchiveFormat = SevenZip.OutArchiveFormat.Zip;
                tmp.CompressDirectory(tempFullName + "\\", txtLoc.Text);

                System.Threading.Thread.Sleep(1000);

                MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, false);//删除文件夹

                lblTitle.Text = @"导出完成!";
                Application.DoEvents();

                this.DialogResult   = DialogResult.OK;
                btnCancel.Enabled   = true;
                btnConfirm.Enabled  = true;
                btnExplorer.Enabled = true;
            }
            catch (Exception ex)
            {
                TXMessageBoxExtensions.Info(ex.Message);
                this.DialogResult = DialogResult.Cancel;
                MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, false);//删除文件夹
            }
        }
Esempio n. 15
0
        private bool StartRemove(string saveLoc, System.ComponentModel.BackgroundWorker _bgWorker)
        {
            string destFilename = Globals.Projectname;

            destFolder = saveLoc;

            string dest_temp = Path.GetDirectoryName(saveLoc);

            tempFullName = dest_temp + "\\" + Guid.NewGuid().ToString();
            if (System.IO.Directory.Exists(tempFullName))
            {
                MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, false);
            }
            MyCommon.DeleteAndCreateEmptyDirectory(tempFullName);

            MyCommon.DeleteAndCreateEmptyDirectory(destFolder, false);
            MyCommon.DeleteAndCreateEmptyDirectory(destFolder, true);

            if (Index_temp > 100)
            {
                Index_temp = 0;
            }
            _bgWorker.ReportProgress(Index_temp++);


            ERM.CBLL.CreateSip projectFactory = new ERM.CBLL.CreateSip(Globals.ProjectNO);
            // DataSet dsFinalArchive = projectFactory.GetListArchive(Globals.ProjectNO, "");
            DataSet dsFinalArchive = new Archive().pb_setXmlInfo();

            if (dsFinalArchive.Tables.Count < 1 || dsFinalArchive.Tables[0].Rows.Count < 1)
            {
                TXMessageBoxExtensions.Info("没有任何案卷可以移交!");
                return(false);
            }
            int count_FinalArchive = dsFinalArchive.Tables[0].Rows.Count;

            //DataSet dsFinalArchive_temp = projectFactory.GetListArchive(Globals.ProjectNO, "");
            DataSet dsFinalArchive_temp = dsFinalArchive;

            dsFinalArchive_temp.DataSetName         = "案卷信息";
            dsFinalArchive_temp.Tables[0].TableName = "记录";

            string       _filename = tempFullName + "\\index.dat";
            StreamWriter w1        = new StreamWriter(_filename, false, Encoding.Default);

            if (dsFinalArchive_temp != null && dsFinalArchive_temp.Tables.Count > 0 && dsFinalArchive_temp.Tables[0].Rows.Count > 0)
            {
                for (int i1 = 0; i1 < dsFinalArchive_temp.Tables[0].Rows.Count; i1++)
                {
                    w1.WriteLine("<FileList><File>" + dsFinalArchive_temp.Tables[0].Rows[i1][0].ToString() + ".sip</File>");
                    w1.WriteLine("<Title>" + dsFinalArchive_temp.Tables[0].Rows[i1]["案卷题名"].ToString() + "</Title></FileList>");
                }
            }
            w1.Flush();
            w1.Close();

            if (Index_temp > 100)
            {
                Index_temp = 0;
            }
            _bgWorker.ReportProgress(Index_temp++);

            try
            {
                for (int i = 0; i < count_FinalArchive; i++)
                {
                    if (Index_temp > 100)
                    {
                        Index_temp = 0;
                    }
                    _bgWorker.ReportProgress(Index_temp++);

                    if (!Directory.Exists(tempFullName))
                    {
                        MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, true);
                    }

                    StreamWriter gc = new StreamWriter(tempFullName + "\\a#sgwj_gc.xml", false, Encoding.Default);
                    gc.WriteLine("<?xml version=\"1.0\" encoding=\"gb2312\" standalone=\"no\"?>");
                    gc.WriteLine("<项目工程信息>");
                    gc.WriteLine("  <项目信息>");
                    DataSet   ds    = new Item().pb_setXmlInfo(new T_Projects_BLL().Find(Globals.ProjectNO).ItemID);
                    Hashtable _Item = new Hashtable();
                    if (ds.Tables.Count > 0)
                    {
                        for (int n = 0; n < ds.Tables[0].Rows.Count; n++)
                        {
                            for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
                            {
                                _Item.Add(ds.Tables[0].Columns[j].ColumnName, ds.Tables[0].Rows[n][j].ToString());
                            }
                        }

                        foreach (System.Collections.DictionaryEntry objDE in _Item)
                        {
                            if (_Item[objDE.Key] != null)
                            {
                                if (_Item[objDE.Key].GetType() != typeof(System.String[]))
                                {
                                    gc.WriteLine("    <" + objDE.Key + ">" + objDE.Value + "</" + objDE.Key + ">");
                                }
                                else
                                {
                                    gc.WriteLine("    <" + objDE.Key + ">" + ((string[])_Item[objDE.Key])[0] + "</" + objDE.Key + ">");
                                }
                            }
                            else
                            {
                                gc.WriteLine("    <" + objDE.Key + "></" + objDE.Key + ">");
                            }
                        }
                    }
                    gc.WriteLine("  </项目信息>");
                    gc.WriteLine("  <工程信息>");
                    Hashtable _detail = new Hashtable();
                    DataSet   ds1     = new ERM.UI.Common.XmlMapping.Project().pb_setXmlInfo(new T_Projects_BLL().Find(Globals.ProjectNO).ProjectCategory);
                    if (ds1.Tables.Count > 0)
                    {
                        for (int n = 0; n < ds1.Tables[0].Rows.Count; n++)
                        {
                            for (int j = 0; j < ds1.Tables[0].Columns.Count; j++)
                            {
                                _detail.Add(ds1.Tables[0].Columns[j].ColumnName, ds1.Tables[0].Rows[n][j].ToString());
                            }
                        }

                        foreach (System.Collections.DictionaryEntry objDE in _detail)
                        {
                            if (_detail[objDE.Key] != null)
                            {
                                if (_detail[objDE.Key].GetType() != typeof(System.String[]))
                                {
                                    gc.WriteLine("    <" + objDE.Key + ">" + objDE.Value + "</" + objDE.Key + ">");
                                }
                                else
                                {
                                    gc.WriteLine("    <" + objDE.Key + ">" + ((string[])_detail[objDE.Key])[0] + "</" + objDE.Key + ">");
                                }
                            }
                            else
                            {
                                gc.WriteLine("    <" + objDE.Key + "></" + objDE.Key + ">");
                            }
                        }
                        gc.WriteLine("  </工程信息>");
                        gc.WriteLine("</项目工程信息>");
                        gc.Flush();
                        gc.Close();
                    }

                    if (Convert.ToBoolean(Properties.Settings.Default.SipIncludeDoc))
                    {
                        #region ==================================
                        //20120530 屏蔽XML文件

                        //DataSet dsFinalArchive_temp1 = projectFactory.GetListArchive(Globals.ProjectNO, dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString());
                        DataSet dsFinalArchive_temp1 = new Archive().pb_setXmlInfo(Globals.ProjectNO, dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString());
                        dsFinalArchive_temp1.DataSetName         = "案卷信息";
                        dsFinalArchive_temp1.Tables[0].TableName = "记录";

                        _filename = tempFullName + "\\a#sgwj_file.xml";
                        if (System.IO.File.Exists(_filename))
                        {
                            try
                            {
                                System.IO.File.Delete(_filename);
                            }
                            catch { }
                        }

                        gc = new StreamWriter(_filename, true, Encoding.Default);
                        gc.WriteLine("<?xml version=\"1.0\" encoding=\"gb2312\" standalone=\"no\"?>");
                        gc.Flush();
                        gc.Close();
                        System.IO.FileStream     stream_archive    = new System.IO.FileStream(_filename, System.IO.FileMode.Append);
                        System.Xml.XmlTextWriter xmlWriter_archive = new System.Xml.XmlTextWriter(stream_archive, System.Text.Encoding.Default);
                        dsFinalArchive_temp1.WriteXml(xmlWriter_archive);
                        xmlWriter_archive.Close();

                        #endregion

                        #region ===========================

                        //DataSet dsFinalFile = projectFactory.GetListFile(Globals.ProjectNO,
                        //  dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString());
                        DataSet dsFinalFile = new ERM.UI.Common.XmlMapping.File().pb_setXmlInfo("pb_queryByFileNo", dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString(), Globals.ProjectNO);

                        dsFinalFile.DataSetName         = "文件信息";
                        dsFinalFile.Tables[0].TableName = "记录";

                        _filename = tempFullName + "\\a#sgwj_document.xml";
                        if (System.IO.File.Exists(_filename))
                        {
                            try
                            {
                                System.IO.File.Delete(_filename);
                            }
                            catch { }
                        }

                        gc = new StreamWriter(_filename, true, Encoding.Default);
                        gc.WriteLine("<?xml version=\"1.0\" encoding=\"gb2312\" standalone=\"no\"?>");
                        gc.Flush();
                        gc.Close();
                        System.IO.FileStream     stream_file    = new System.IO.FileStream(_filename, System.IO.FileMode.Append);
                        System.Xml.XmlTextWriter xmlWriter_file = new System.Xml.XmlTextWriter(stream_file, System.Text.Encoding.Default);
                        dsFinalFile.WriteXml(xmlWriter_file);
                        xmlWriter_file.Close();

                        #endregion

                        BLL.T_FileList_BLL fileBLL = new ERM.BLL.T_FileList_BLL();
                        //IList<MDL.T_FileList> fileList = fileBLL.FindByArchiveID2(dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString(), Globals.ProjectNO);
                        DataSet fileList = new ERM.UI.Common.XmlMapping.File().pb_setXmlInfo("pb_FindByArchiveID2", dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString(), Globals.ProjectNO);
                        if (fileList.Tables.Count > 0)
                        {
                            for (int j = 0; j < fileList.Tables[0].Rows.Count; j++)
                            {
                                DataRow obj = fileList.Tables[0].Rows[j];
                                if (Index_temp > 100)
                                {
                                    Index_temp = 0;
                                }
                                _bgWorker.ReportProgress(Index_temp++);

                                string FileID = obj["FileID"].ToString();
                                if (obj["filepath"] != null)
                                {
                                    string tFilePath = obj["filepath"].ToString().Replace("MPDF\\", "");
                                    string decMfile  = tempFullName + "\\" + tFilePath;
                                    string sourMfile = Globals.ProjectPath + obj["filepath"];
                                    try
                                    {
                                        if (System.IO.File.Exists(sourMfile))
                                        {
                                            System.IO.File.Copy(sourMfile, decMfile, true);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        MyCommon.WriteLog("生成移交文件时,拷贝文件失败!错误信息:" + ex.Message);
                                    }
                                }
                                BLL.T_CellAndEFile_BLL     cellBLL  = new ERM.BLL.T_CellAndEFile_BLL();
                                IList <MDL.T_CellAndEFile> cellList = cellBLL.FindByFileID(FileID, Globals.ProjectNO, 1);

                                foreach (MDL.T_CellAndEFile obj2 in cellList)
                                {
                                    string yswjpath = obj2.filepath.Replace("ODOC\\", "");

                                    string dec  = tempFullName + "\\" + yswjpath;
                                    string sour = Globals.ProjectPath + obj2.filepath;
                                    try
                                    {
                                        if (System.IO.File.Exists(sour))
                                        {
                                            System.IO.File.Copy(sour, dec, true);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        MyCommon.WriteLog("生成移交文件时,拷贝原文件失败!错误信息:" + ex.Message);
                                    }
                                }
                            }
                        }
                    }
                    if (System.IO.File.Exists(tempFullName + "\\index.dat"))
                    {
                        System.IO.File.Move(tempFullName + "\\index.dat", destFolder + "\\index.dat");

                        string gcInfo  = System.IO.File.ReadAllText(tempFullName + "\\a#sgwj_gc.xml", Encoding.GetEncoding("gb2312"));
                        string docList = System.IO.File.ReadAllText(destFolder + "\\index.dat");
                        gcInfo = gcInfo.Replace("</项目工程信息>", "<ArchiveFileList>" + docList + "</ArchiveFileList></项目工程信息>");
                        System.IO.File.WriteAllText(destFolder + "\\index.dat", gcInfo, Encoding.GetEncoding("gb2312"));
                    }
                    SevenZip.SevenZipCompressor.SetLibraryPath(Application.StartupPath + "\\7z.dll");
                    SevenZip.SevenZipCompressor tmp = new SevenZip.SevenZipCompressor();
                    tmp.ArchiveFormat = SevenZip.OutArchiveFormat.Zip;
                    tmp.CompressDirectory(tempFullName, destFolder + "\\" + dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString() + ".sip");

                    MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, false);
                }
            }
            catch (Exception ex)
            {
                MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, false);
                TXMessageBoxExtensions.Info("封装数据时发生意外错误!错误002");
                MyCommon.WriteLog("生成移交文件时失败!错误信息:" + ex.Message);
                return(false);
            }
            return(true);
        }
Esempio n. 16
0
        /// <summary>
        /// 按案卷上报
        /// </summary>
        /// <returns></returns>
        private bool?ConfirmSplitForfrmArchive()
        {
            if (txtLoc.Text == "")
            {
                TXMessageBoxExtensions.Info("请选择导出文件的存储路径!");
                txtLoc.Focus();
                return(null);
            }
            string destFilename = Globals.Projectname;

            destFolder = txtLoc.Text;

            string dest_temp = Path.GetDirectoryName(txtLoc.Text);

            if (!Directory.Exists(dest_temp))
            {
                TXMessageBoxExtensions.Info("存储的路径不存在!");
                return(null);
            }

            double             projectSize = Convert.ToDouble(DirectoryInfoCommon.GetDirectorySpace(Application.StartupPath + "\\Project\\" + Globals.ProjectNO) / Convert.ToDouble(1024 * 1024 * 1024));
            ReadWriteAppConfig config      = new ReadWriteAppConfig();

            if (config.Read("Upload_ProjectSize") == "")
            {
                config.Write("Upload_ProjectSize", "4");
            }
            string upload_size = config.Read("Upload_ProjectSize");

            if (projectSize > Convert.ToDouble(upload_size))
            {
                DialogResult dresult = TXMessageBoxExtensions.Question("上报工程大于" + upload_size + "G,当前工程大小为:" + System.Math.Round(projectSize, 2) + "G \r\n\n 【温馨提示:工程太大,生成移交文件需要比较长得时间】  \r\n\n 是否继续生成移交?");
                if (dresult != DialogResult.OK)
                {
                    return(null);
                }
            }
            else if (MyCommon.CheckDisk(destFolder) < projectSize)
            {
                //硬盘空间不足
                TXMessageBoxExtensions.Info("上报工程大小为:" + System.Math.Round(projectSize, 2) + "G 保存目录硬盘空间不足,无法生成! \r\n 【温馨提示:请选择比较空闲的盘符】");
                txtLoc.Focus();
                return(null);
            }

            tempFullName = dest_temp + "\\" + Guid.NewGuid().ToString();
            if (System.IO.Directory.Exists(tempFullName))
            {
                MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, false);
            }
            MyCommon.DeleteAndCreateEmptyDirectory(tempFullName);

            MyCommon.DeleteAndCreateEmptyDirectory(destFolder, false);
            MyCommon.DeleteAndCreateEmptyDirectory(destFolder, true);

            panelBottom.Visible = true;
            panelTop.Visible    = false;
            Application.DoEvents();
            butClose.Enabled = false;
            ERM.CBLL.CreateSip projectFactory = new ERM.CBLL.CreateSip(Globals.ProjectNO);
            //DataSet dsFinalArchive = projectFactory.GetListArchive(Globals.ProjectNO, "");
            DataSet dsFinalArchive = new Archive().pb_setXmlInfo();

            if (dsFinalArchive.Tables.Count < 1 || dsFinalArchive.Tables[0].Rows.Count < 1)
            {
                TXMessageBoxExtensions.Info("没有任何案卷可以移交!");
                return(false);
            }
            int  count_FinalArchive = dsFinalArchive.Tables[0].Rows.Count;
            bool checkfile_flag     = true;

            for (int i = 0; i < count_FinalArchive; i++)
            {
                BLL.T_FileList_BLL     fileBLL  = new ERM.BLL.T_FileList_BLL();
                IList <MDL.T_FileList> fileList = fileBLL.FindByArchiveID2(dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString(), Globals.ProjectNO);
                foreach (MDL.T_FileList obj in fileList)
                {
                    if (obj.selected == 1 || obj.filepath == null || obj.filepath == "")
                    {
                        ConvertAllEFileToPDF(obj.FileID);
                    }
                    else
                    {
                        string tFilePath = obj.filepath.Replace("MPDF\\", "");
                        string sourMfile = Globals.ProjectPath + obj.filepath;
                        if (!System.IO.File.Exists(sourMfile))
                        {
                            ConvertAllEFileToPDF(obj.FileID);
                        }
                    }
                    IList <MDL.T_CellAndEFile> cellList   = (new ERM.BLL.T_CellAndEFile_BLL()).FindByGdFileID(obj.FileID, Globals.ProjectNO);
                    ERM.MDL.T_FileList         file_model = (new ERM.BLL.T_FileList_BLL()).Find(obj.FileID, Globals.ProjectNO);
                    if ((file_model.filepath == null || file_model.filepath == "") &&
                        cellList.Count > 0)
                    {
                        TXMessageBoxExtensions.Info("提示:文件【" + obj.gdwj + "】电子文件信息有误!无法移交,请审查");
                        checkfile_flag = false;
                        break;
                    }
                }
                if (!checkfile_flag)
                {
                    break;
                }
            }
            if (!checkfile_flag)
            {
                return(false);
            }

            progressBar2.Maximum = count_FinalArchive;
            progressBar2.Minimum = 0;
            progressBar2.MarqueeAnimationSpeed = 1000;
            progressBar2.Step = 1;
            lblMsg.Text       = "正在输出元数据信息...";
            Application.DoEvents();

            GetListArchiveXML(projectFactory, tempFullName);
            try
            {
                for (int i = 0; i < count_FinalArchive; i++)
                {
                    if (!Directory.Exists(tempFullName))
                    {
                        MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, true);
                    }
                    //20120530 屏蔽XML文件
                    GetProjectXML(projectFactory, tempFullName);

                    if (Convert.ToBoolean(Properties.Settings.Default.SipIncludeDoc))
                    {
                        //20120530 屏蔽XML文件
                        GetListArchiveXMLEx(dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString(), tempFullName);
                        GetDocumentXMLEx(dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString(), tempFullName);

                        BLL.T_FileList_BLL     fileBLL  = new ERM.BLL.T_FileList_BLL();
                        IList <MDL.T_FileList> fileList = fileBLL.FindByArchiveID2(dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString(), Globals.ProjectNO);
                        foreach (MDL.T_FileList obj in fileList)
                        {
                            //20120530 屏蔽XML文件
                            //getDocModel(obj);
                            getDocModel_NEW(obj, tempFullName);
                        }
                    }
                    lblMsg.Text = "正在对数据包进行封装...";
                    Application.DoEvents();

                    if (System.IO.File.Exists(tempFullName + "\\index.dat"))//Application.StartupPath + "\\temp\\index.dat"
                    {
                        System.IO.File.Move(tempFullName + "\\index.dat", destFolder + "\\index.dat");

                        string gcInfo  = System.IO.File.ReadAllText(tempFullName + "\\a#sgwj_gc.xml", Encoding.GetEncoding("gb2312"));
                        string docList = System.IO.File.ReadAllText(destFolder + "\\index.dat");
                        gcInfo = gcInfo.Replace("</项目工程信息>", "<ArchiveFileList>" + docList + "</ArchiveFileList></项目工程信息>");
                        System.IO.File.WriteAllText(destFolder + "\\index.dat", gcInfo, Encoding.GetEncoding("gb2312"));
                    }

                    SevenZip.SevenZipCompressor.SetLibraryPath(Application.StartupPath + "\\7z.dll");
                    SevenZip.SevenZipCompressor tmp = new SevenZip.SevenZipCompressor();
                    {
                        tmp.ArchiveFormat = SevenZip.OutArchiveFormat.Zip;
                        tmp.CompressDirectory(tempFullName, destFolder + "\\" + dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString() + ".sip");
                    }
                    MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, false);
                    progressBar2.Value = progressBar2.Value + 1;
                }
            }
            catch (Exception ex)
            {
                MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, false);
                TXMessageBoxExtensions.Info("封装数据时发生意外错误!错误002");
                MyCommon.WriteLog("生成移交文件时失败!错误信息:" + ex.Message);
                return(false);
            }
            butClose.Text    = "关闭";
            butClose.Enabled = true;
            TXMessageBoxExtensions.Info("已经成功生成上报文件!");
            return(true);
        }
Esempio n. 17
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            try
            {
                if (lstFiles.CheckedItems.Count == 0)
                {
                    return;
                }
                DataTable dt = ((DataView)lstFiles.DataSource).ToTable();
                for (int j = lstFiles.Items.Count - 1; j >= 0; j--)
                {
                    if (!lstFiles.GetItemChecked(j))
                    {
                        dt.Rows[j].Delete();
                    }
                }
                if (!CheckFileExist(dt))
                {
                    return;
                }
                if (dt.Rows.Count == 0)
                {
                    TXMessageBoxExtensions.Info("没有要打印的文件!");
                    return;
                }
                string PrintMode = "2";
                if (PrintMode.Equals("2") && tn != null)
                {
                    string[] printFileList = new string[dt.Rows.Count];
                    string   tempFolder    =
                        System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "erm_print");
                    if (!System.IO.Directory.Exists(tempFolder))
                    {
                        MyCommon.DeleteAndCreateEmptyDirectory(tempFolder, true);
                    }
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        /*
                         * * 拷贝到临时目录进行打印,因为隐藏章打印会删除掉,影响系统查看
                         * * */
                        string tempFile = System.IO.Path.Combine(tempFolder, dt.Rows[i]["title"].ToString() + ".pdf");
                        System.IO.File.Copy(dt.Rows[i]["filed"].ToString(), tempFile, true);
                        printFileList[i] = tempFile;
                    }

                    using (ConvertCell2PDF cl_print = new ConvertCell2PDF())
                    {
                        MyCommon.DeleteAndCreateEmptyDirectory(Application.StartupPath + @"\Reports\printPdf_temp", true);
                        cl_print.MergePDF(printFileList, Application.StartupPath + @"\Reports\printPdf_temp\printFile.pdf");
                        frmReport frmReports = new frmReport("printFile.pdf");
                        frmReports.ShowDialog();
                        //cl_print.BathPrintPDF(printFileList);
                    }
                    //switch (tn.ImageIndex)
                    //{
                    //    case 0://所有
                    //        string[] printFileList = new string[dt.Rows.Count];
                    //        for (int i = 0; i < dt.Rows.Count; i++)
                    //        {
                    //            printFileList[i] = dt.Rows[i]["filed"].ToString();
                    //        }
                    //        break;
                    //    case 1://案卷
                    //        //OperatorFile(dt, printername, ref hMenu, strDefault, dtNew, tn, StartPageNo);
                    //        break;
                    //    case 2://文件
                    //        //hMenu = OperatorTem(dt, printername, hMenu, strDefault, dtNew, StartPageNo);
                    //        break;
                    //    default:
                    //        break;
                    //}
                }
                else
                {
                    frmPrinterList frm = new frmPrinterList();
                    DialogResult   drs = frm.ShowDialog();
                    if (drs != DialogResult.OK)
                    {
                        return;
                    }
                    string printername = frm.GetSelected;
                    btnPrint.Enabled  = false;
                    btnCancel.Enabled = false;
                    lstFiles.Enabled  = false;
                    chkAll.Enabled    = false;
                    IntPtr hMenu = GetSystemMenu(this.Handle, 0);
                    EnableMenuItem(hMenu, SC_CLOSE, MF_DISABLED | MF_GRAYED);
                    string strDefault = "";
                    if (setDefaultPrinter)
                    {
                        strDefault = PrinterOperate.GetDefaultPrinterName();
                        if (string.Compare(strDefault, printername, true) != 0)
                        {
                            PrinterOperate.SetPrinter(printername);
                        }
                    }

                    hMenu = PrintFile(dt, printername, hMenu, strDefault);
                    if (setDefaultPrinter)//设回来
                    {
                        if (string.Compare(strDefault, printername, true) != 0)
                        {
                            PrinterOperate.SetPrinter(strDefault);
                        }
                    }
                    btnCancel.Enabled = true;
                    hMenu             = GetSystemMenu(this.Handle, 0);
                    EnableMenuItem(hMenu, SC_CLOSE, MF_ENABLED);
                    if (TXMessageBoxExtensions.Question("打印任务已经全部输送到打印机,现在可以关闭窗口了,请耐心等待打印机的处理。\n 是否继续打印?") != DialogResult.OK)
                    {
                        this.Close();
                    }
                    else
                    {
                        btnPrint.Enabled  = true;
                        btnCancel.Enabled = true;
                        lstFiles.Enabled  = true;
                        chkAll.Enabled    = true;
                    }
                }
                btnPrint.Enabled  = true;
                btnCancel.Enabled = true;
                lstFiles.Enabled  = true;
                chkAll.Enabled    = true;
            }
            catch (Exception ex)
            {
                btnPrint.Enabled  = true;
                btnCancel.Enabled = true;
            }
        }