Esempio n. 1
0
        private void barButtonItem7_ItemClick_1(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //------------------测试-----------------------------
           // string xlsPath = @"D:\移动风险监测\新数据测试数据\6风险图应用业务相关数据\";
           // string fileName =  "6.4避洪转移展示支撑数据 .xls"; //"6.3影响分析支撑数据.xls";//"6.1查询业务支撑数据.xls";//
           // string sheetName = "6.4.1转移单元-转移路线-安置区对应关系表";
           ////生成csv
           // string[] sheetNameList = importTool.GetSheetNameList(xlsPath + fileName);

           // importTool.ExcelToCsv(xlsPath + fileName, xlsPath + sheetNameList[0] + "_Attr.csv", sheetNameList[0], "|#|", 1);
           // //导入csv
           // // importTool.toCSVTest(xlsPath + fileName, xlsPath + "bhzyAttr.csv");

           //// string mm=importTool.XLSSavesaCSV(xlsPath + fileName);
           // //DataTable dt = importTool.ExcelToDataTable(xlsPath + fileName, sheetNameList[1]);
           // //dataGridViewX1.DataSource = dt;
           // MessageBox.Show("Success");
            //------------------测试----------------------------



            TIFF tif = new TIFF(undeal_path.Text);
            tif.StartPosition = FormStartPosition.CenterScreen;
            tif.Show();
            //tif.TopMost = true;
        }
Esempio n. 2
0
        /*主处理函数需要执行的操作:
         * 1、传入参数:河段路径
         * 2、方法:数据转换、溃口数据导入、淹没过程数据导入、影响分析数据导入、模板、属性替换、生成处理报告、更改文件名
         * 3、定义参数:输出路径
         * 
         */
        //主处理函数
//=======================================================================================
        public void DealAll(string dataPath, string password)
        {
            set.passWod = password;
            DateTime dt = DateTime.Now;
            string tiff = null;
            string mod = null;
            string fxtb = null;
            string outPath = null;
            string outPath_Mid = null;
            string outPath_Final=null;
            //string mxdPath = null;//完整地图路径
            try
            {
                if (dataPath.Substring(dataPath.Length - 3) == "已处理")
                    return;//判断该编制单元是否被处理,是则返回,不是则继续执行
                di = new DirectoryInfo(dataPath);
                FileInfo[] information = di.GetFiles("*信息.txt",SearchOption.AllDirectories);
                FileInfo[] yuanData = di.GetFiles("元数据.xml", SearchOption.AllDirectories);
                
                //成果图的获取
                DirectoryInfo[] picture = di.GetDirectories("*成果图件*", SearchOption.AllDirectories);
                //checkPath(picture[0].FullName);
                //地图数据获取
                FileInfo[] mxd = di.GetFiles("完整地图.mxd", SearchOption.AllDirectories);
                //checkPath(mxd[0].FullName);
                //设置淹没过程影像文件路径
                DirectoryInfo[] tiff1 = di.GetDirectories("tiffPath", SearchOption.AllDirectories);
                if (tiff1.Length > 0)
                    tiff = tiff1[0].FullName;
                else
                {
                    if (MessageBox.Show("未找到淹没过程数据,是否即时生成?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        TIFF tif = new TIFF(dataPath);
                        tif.StartPosition = FormStartPosition.CenterScreen;
                        tif.TopMost = true;
                        tif.Show();
                        return;
                    }
                    else
                        return;
                }
                
                
                MessageShow.Clear();
                mod = set.mod;//设置地图模板路径
                //设置编制单元名称,用于信息输出
                fxtb = dataPath.Substring(dataPath.LastIndexOf("\\") + 1);
                datetime = DateTime.Now;//设置开始实时间
                lab_progress.Text = "正在处理:【" + fxtb + "】";
                Msg("正在处理河段:" + fxtb);
                //创建输出对应目录
                outPath = importTool.createFolder(set.deal_path + "\\" + fxtb + "_已处理");
                //创建输出中间数据目录
                outPath_Mid = importTool.createFolder(outPath + "\\" + "中间数据");
                //创建超图结果数据目录
                outPath_Final = importTool.createFolder(outPath + "\\" + fxtb);
                File.Copy(information[0].FullName, outPath_Final +"\\"+ information[0].Name,true);
                File.Copy(yuanData[0].FullName, outPath_Final + "\\"+yuanData[0].Name,true);
               #region 测试
                //测试读取属性数据
                

                DateTime dt1 = DateTime.Now;
                //ymgcImport(outPath_Final, tiff);
               //ImportMapModel(mod, outPath_Final + "\\" + "MapResult", outPath_Final, set.mod);

                //bhzy(outPath_Mid, outPath_Final);
                //slgc(outPath_Final, outPath_Mid);
                //ztdt(outPath_Final, outPath_Mid);
                //bhzyImport(dataPath, outPath_Final);
                //string xlsPath1 = @"D:\移动风险监测\新数据测试数据\6风险图应用业务相关数据\";
                //string fileName = "6.1查询业务支撑数据.xls";//"6.4避洪转移展示支撑数据 .xls"; //"6.3影响分析支撑数据.xls";
                //string xmlPath = @"D:\移动风险监测\配图模版_v2.1\jcdt (2).xml";//ymgc1.xml地图模版_fhys.xml
                //ModelApplication(readXML(xmlPath), outPath_Final + "\\" + "MapResult.smwu","测试地图1");
               // string csvName = "Attr.csv";// "6.1.1编制方案信息_Attr.csv";//"6.5.1综合经济指标表_Attr.csv"; //"6.4.1转移单元-转移路线-安置区对应关系表_Attr.csv";// ;
               //CSVImport(csvName, outPath_Final, "test.udb");
                //ExcelDataImport("*查询业务支撑数据.xls", outPath_Final, "ywcxAttr", "ywcx.udb");
               //DevComponents.DotNetBar.Controls.RichTextBoxEx failedBoxText = new DevComponents.DotNetBar.Controls.RichTextBoxEx();
               ////failedBoxText.Text = failedRecord;
               ////failedBoxText.SaveFile(outPath_Final + "_错误日志1.txt", RichTextBoxStreamType.TextTextOleObjs);
               //MessageShow.Text = failedRecord;
               //MessageShow.SaveFile(outPath_Final + "_错误日志1.txt", RichTextBoxStreamType.TextTextOleObjs);
                //yxfx(dataPath, outPath_Final);
                //Feature2Raster(gp, @"D:\移动风险监测\新数据测试数据\6风险图应用业务相关数据\6.2淹没过程动态展示支撑数据\ymss1.shp", @"D:\移动风险监测\新数据测试数据\tiffPath\time1.tif");
                //string txtPath = @"D:\移动风险监测\新数据测试数据\6风险图应用业务相关数据\6.2淹没过程动态展示支撑数据\time1.txt";
                string shpFilePath = @"D:\移动风险监测\新数据测试数据\6风险图应用业务相关数据\6.2淹没过程动态展示支撑数据";
                string shpFileName = "ymss1";//;
                //ceshiSelect(shpFileName, shpFilePath);
                //string SavaPath = @"D:\移动风险监测\新数据测试数据\tiffPath\ymss1";
                //ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown();
                //Feature2Raster(gp,shpFilePath+"\\"+shpFileName+".shp", SavaPath+"\\time.tif");
                //JoinPoint(gp, shpFilePath+"\\", shpFileName, "czLayer","ymcz");

                //MessageBox.Show(caculateCountry("ymcz", shpFilePath).ToString());
                //MessageBox.Show(Caculate(shpFileName, shpFilePath, "GRIDAREA").ToString());
                //DataTable dTable=ymStatistics(tiff,@"D:\移动风险监测\新数据测试数据\6风险图应用业务相关数据\6.2淹没过程动态展示支撑数据\copy\czLayer.shp");
                //dataTableToCsv(dTable, @"D:\1.xls"); //调用函数

                //System.Diagnostics.Process.Start(@"D:\1.xls"); //打开excel文件
                //readTXT(txtPath, shpFilePath, shpFileName, SavaPath);
                //MessageBox.Show(ExecDateDiff(dt1, DateTime.Now));
               //setValue("ymss1", @"D:\移动风险监测\新数据测试数据\6风险图应用业务相关数据\6.2淹没过程动态展示支撑数据", value);

                /*tlab_progress.Text = "【" + fxtb + "】正在导入避洪转移数据···";
                bhzy(dataPath, outPath_Final);
                lab_progress.Text = "【" + fxtb + "】避洪转移数据导入完成";
                ry
                {
                    lab_progress.Text = "【" + fxtb + "】正在加载地图模板···";
                    Msg("正在加载地图模板···");
                    ImportMapModel(mod, outPath_Final + "\\" + "MapResult", outPath_Final, set.mod);

                }
                catch(Exception ex)
                {
                    Msg(ex.Message);
                }
                //ymgc(fxtb, outPath_Final, outPath_Mid, tiff);//set.TIFFPath
                //ymgc(fxtb, outPath_Final, outPath_Mid, tiff);//淹没过程影像数据导入

                //  ImportMapModel(mod, outPath_Final + "\\" + "MapResult", outPath_Final, set.mod);*/
                #endregion
                //接下来进行mxd的加载;
                //string ph = mxd[0].FullName;
               
                
 //----------------------------------------------------------------------------------
              
//--------------------提取数据--------------------------------------------------------------------
                Msg(lab_progress.Text = "【" + fxtb + "】正在进行数据转换···");
                axMapControl.LoadMxFile(mxd[0].FullName, 0, Type.Missing);
                //提取数据函数调用
                getGroupLayer(axMapControl, outPath_Mid);
                Msg("本次处理数据总数为:" + (vec_count + ras_count).ToString() + "条" + "\r\n" + "其中处理矢量数据:" + vec_count.ToString() + "条" + "\r\n" + "处理栅格数据:" + ras_count.ToString() + "条");
                Msg("用时:" + ExecDateDiff(datetime, DateTime.Now));//显示用时
//---------------------------------------------------------------------------------------
               
                //System.Threading.Thread.Sleep(100);
                Msg(lab_progress.Text = "【" + fxtb + "】正在导入淹没过程影像数据···");
               //淹没过程影像数据导入//savapath  是栅格数据存放位置
                ymgcImport(outPath_Final, tiff);
                //lab_progress.Text = "【" + fxtb + "】淹没过程影像数据导入完成";
                //System.Threading.Thread.Sleep(100);
//----------------------------------------------------------------------------------------
                //水利工程数据导入
                Msg(lab_progress.Text = "【" + fxtb + "】正在导入水利工程数据···");
                slgcImport(outPath_Final, outPath_Mid);
                //lab_progress.Text = "【" + fxtb + "】水利工程数据导入完成";
                //System.Threading.Thread.Sleep(100);
//----------------------------------------------------------------------------------------
                //专题地图的导入
                Msg(lab_progress.Text = "【" + fxtb + "】正在导入专题地图数据···");
                ztdtImport(outPath_Final, outPath_Mid);
                //lab_progress.Text = "【" + fxtb + "】专题地图导入完成";
                //System.Threading.Thread.Sleep(100);
 //----------------------------------------------------------------------------------------
                //避洪转移数据导入
                Msg(lab_progress.Text = "【" + fxtb + "】正在导入避洪转移数据···");
                bhzyImport(dataPath, outPath_Final);
                //lab_progress.Text = "【" + fxtb + "】避洪转移数据导入完成";
                //System.Threading.Thread.Sleep(100);
 //----------------------导入excel数据-------------------------
                Msg(lab_progress.Text = "【" + fxtb + "】正在导入Excel支撑数据···");
                ExcelDataImport("*避洪转移展示支撑数据 .xls", outPath_Final, "bhzyAttr", "bhzy.udb");
                ExcelDataImport("*查询业务支撑数据.xls", outPath_Final, "ywcxAttr", "ywcx.udb");
 //----------------------------------------------------------------------------------------
                //复合要素数据导入
                Msg(lab_progress.Text = "【" + fxtb + "】正在导入复合要素数据···");
                fhysImport(outPath_Final, outPath_Mid);
                //lab_progress.Text = "【" + fxtb + "】避洪转移数据导入完成";
                //System.Threading.Thread.Sleep(100);
//----------------------------------------------------------------------------------------
//影响分析数据导入
                Msg(lab_progress.Text = "【" + fxtb + "】正在导入影响分析数据···");
                yxfxImport(dataPath, outPath_Final);
                //lab_progress.Text = "【" + fxtb + "】影响分析数据导入完成";
                //System.Threading.Thread.Sleep(100);
                
//----------------------------------------------------------------------------------------
//更新影响分析数据属性表
                Msg(lab_progress.Text = "【" + fxtb + "】正在更新属性数据···");
                try
                {

                    FileInfo[] xlsPath = di.GetFiles("*数据*.xls*", SearchOption.TopDirectoryOnly);
                    foreach (FileInfo xx in xlsPath)
                    {
                        ConnectAttribute(xx.FullName, outPath_Final + "\\" + "yxfx");
                    }
                }
                catch
                {
                    Msg("更新属性数据不存在,跳过更新");
                }
               
//----------------------------------------------------------------------------------------
              //导入地图模板
                Msg(lab_progress.Text = "【" + fxtb + "】正在加载地图模板···");
                
                datetime = DateTime.Now;
                ImportMapModel(mod, outPath_Final + "\\" + "MapResult", outPath_Final, set.mod);
                //Msg(importTool.mo);
                Msg("用时:" + DataConverTool.ExecDateDiff(datetime, DateTime.Now));
                //lab_progress.Text = "【" + fxtb + "】加载地图模板完成";
//----------------------------------------------------------------------------------------
                //复制成果图
                Msg(lab_progress.Text = "【" + fxtb + "】正在复制成果图···");

                importTool.createFolder(outPath_Final + "\\成果图");
                di = new DirectoryInfo(picture[0].FullName);
                max = di.GetFiles().Length;
                foreach (FileInfo jpg in di.GetFiles())
                {
                    int p = 0;
                    File.Copy(jpg.FullName, outPath_Final + "\\成果图\\" + jpg.Name, true);
                    pgrs(p++);
                }
                Msg("复制成果图成功!");
                //File.Copy(information[0].FullName, outPath_Final + information[0].Name);
                //File.Copy(yuanData[0].FullName, outPath_Final + yuanData[0].Name);

//----------------------------------------------------------------------------------------
//生成处理报告
                Msg("正在生成处理报告····");
                Msg("本编制单元用时:" + DataConverTool.ExecDateDiff(dt, DateTime.Now));
                MessageShow.SaveFile(outPath_Final + "_处理报告.txt", RichTextBoxStreamType.TextTextOleObjs);
                Msg(outPath_Final + "_处理报告.txt  已生成成功!");
               
                Msg("正在生成错误日志····");
                //DevComponents.DotNetBar.Controls.RichTextBoxEx failedBox = new DevComponents.DotNetBar.Controls.RichTextBoxEx();
                MessageShow.Text = failedRecord;
                MessageShow.SaveFile(outPath_Final + "_错误日志.txt", RichTextBoxStreamType.TextTextOleObjs);
     
                
               // Msg("错误日志已生成");
                
                lab_progress.Text = "【" + fxtb + "】处理完成";
                //Directory.Move(dataPath, dataPath + "_已处理");
                //System.Threading.Thread.Sleep(1000);//等待一秒;
            }
            catch (Exception ex)
            {
                Msg(ex.Message);
            }
        }