Example #1
0
        private void DeleteRecycle(string FileID, ref frm2PDFProgressMsg frmMsg)
        {
            BLL.T_FileList_BLL     fileBLL  = new ERM.BLL.T_FileList_BLL();
            IList <MDL.T_FileList> fileList = fileBLL.FindByParentID(FileID, Globals.ProjectNO);

            foreach (MDL.T_FileList obj in fileList)
            {
                DeleteRecycle(obj.FileID, ref frmMsg);
            }

            BLL.T_CellAndEFile_BLL     cellBLL  = new ERM.BLL.T_CellAndEFile_BLL();
            IList <MDL.T_CellAndEFile> cellList = cellBLL.FindByFileID(FileID, Globals.ProjectNO, 0);

            foreach (MDL.T_CellAndEFile obj in cellList)
            {
                if (System.IO.File.Exists(Globals.ProjectPath + obj.filepath))
                {
                    System.IO.File.Delete(Globals.ProjectPath + obj.filepath);
                }
                if (System.IO.File.Exists(Globals.ProjectPath + obj.fileTreePath))
                {
                    System.IO.File.Delete(Globals.ProjectPath + obj.fileTreePath);
                }
                cellBLL.Delete(obj.CellID, Globals.ProjectNO);
            }

            fileBLL.Delete(FileID, Globals.ProjectNO);

            if (frmMsg.progressBar1.Value < frmMsg.progressBar1.Maximum)
            {
                frmMsg.progressBar1.Value++;
            }
            frmMsg.label2.Text = "正在删除:" + frmMsg.progressBar1.Value.ToString() + "/" + frmMsg.progressBar1.Maximum.ToString();
            Application.DoEvents();
        }
Example #2
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);
        }
Example #3
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;
            }
        }
Example #4
0
        /// <summary>
        /// 删除当前节点
        /// </summary>
        private void DelNode()
        {
            frm2PDFProgressMsg dfmsg = null;

            try
            {
                TreeNodeEx theNode = (TreeNodeEx)treeView1.SelectedNode;
                if (theNode == null)
                {
                    return;
                }
                TreeNodeEx parentNode = (TreeNodeEx)theNode.Parent;
                if (parentNode == null)
                {
                    return;
                }
                if (parentNode.Tag != null && parentNode.Tag.ToString() == "")
                {
                    MyFavorites myFav1 = new MyFavorites();
                    myFav1.Delete(theNode.Name);
                    theNode.Remove();
                    return;
                }

                int DelCount = 0;
                if (theNode.ImageIndex == 1)
                {
                    bool check_flg = false;
                    CheckFileNodeIsArch(theNode, ref check_flg, ref DelCount);
                    if (check_flg)
                    {
                        TXMessageBoxExtensions.Info("提示:已经组卷的文件目录不允许修改!");
                        return;
                    }
                }
                DialogResult ret = TXMessageBoxExtensions.Question("确定删除 [" + GetTrueText(theNode.Text) + "] 及其子节点?");
                if (ret == DialogResult.OK)
                {
                    this.Enabled = false;

                    MDL.T_FileList fileMDL = (new BLL.T_FileList_BLL()).Find(theNode.Name, Globals.ProjectNO);
                    if (fileMDL != null)
                    {
                        if (int.Parse(fileMDL.fileStatus) > 3)
                        {
                            TXMessageBoxExtensions.Info("该文件已经 登记或组卷,无法进行删除操作!");
                            this.Enabled = true;
                            return;
                        }
                        dfmsg = new frm2PDFProgressMsg();
                        if (theNode.ImageIndex == 1)
                        {
                            dfmsg.progressBar1.Maximum = DelCount;
                            dfmsg.label2.Text          = "正在删除:0/" + DelCount.ToString();
                            dfmsg.Show();
                            Application.DoEvents();
                        }
                        else
                        {
                            dfmsg.progressBar1.Maximum = 2;
                            dfmsg.progressBar1.Value   = 1;
                            dfmsg.label2.Text          = "正在删除:1/1";
                            dfmsg.Show();
                            Application.DoEvents();
                        }

                        DeleteRecycle(theNode.Name, ref dfmsg);
                        theNode.Remove();
                        CheckEnable();
                        tssLabel1.Text = Globals.NormalStatus;
                    }
                    this.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                this.Enabled = true;
                if (dfmsg != null)
                {
                    dfmsg.Dispose();
                    dfmsg.Close();
                }
            }
            finally
            {
                this.Enabled = true;
                if (dfmsg != null)
                {
                    dfmsg.Dispose();
                    dfmsg.Close();
                }
            }
        }