12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using WWPipeLine.MapBasic.Conditions;
- using Sunny.UI;
- using WeifenLuo.WinFormsUI.Docking;
- using SuperMap.Mapping;
- using WWPipeLine.MapBasic;
- using SuperMap.Data.Conversion;
- using SuperMap.Data;
- namespace WWPipeLine.MapTools.Conditions.ShuJuChuLi
- {
- public partial class OutGIS : ConditionPanel
- {
- private LayerWithDataListPanel LayerPanel;
- private string fileName = string.Empty;
- private string fileType = string.Empty;
- private string dviName = string.Empty;
- public OutGIS()
- {
- this.ConditionPanelName = "地图输出GIS数据文件";
- InitializeComponent();
- }
- protected override void OnLoad(EventArgs e)
- {
- LayerPanel = new LayerWithDataListPanel();
- LayerPanel.LoadToVector(true);
- uiGBlayer.Controls.Add(LayerPanel);
- }
- private void uiButton1_Click(object sender, EventArgs e)
- {
- SaveFileDialog sfd = new SaveFileDialog();
- sfd.InitialDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory);
- sfd.Title = "请选择要保存的文件路径";
- sfd.Filter = "所有文件|*.*";
- sfd.RestoreDirectory = true;
- if (sfd.ShowDialog() == DialogResult.OK)
- {
- fileName = sfd.FileName;
- uiTextBox1.Text = fileName;
- }
- }
- public override object Do(DockPanel dockPanel = null)
- {
- this.IsShowResultWindow = false;
- if (string.IsNullOrEmpty(fileName))
- { UIMessageTip.ShowError("请选择要保存文件的路径"); return false; }
- if (LayerPanel.SelectLayers.Count == 0)
- { UIMessageTip.ShowError("请选择要保存文件的图层"); return false; }
- FileType outFileType = FileType.None;
- DataExport ex = new DataExport();
- if (uiRadioButtonCSV.Checked)//ExportSettingCSV
- {
- outFileType = FileType.CSV;
- }
- if (uiRadioButtonGDB.Checked)//ExportSettingFileGDBVector
- {
- outFileType = FileType.FileGDBVector;
- }
- if (uiRadioButtonSHP.Checked)//ExportSettingSHP
- {
- outFileType = FileType.SHP;
- }
- if (uiRadioButtonSimpleJson.Checked)//ExportSettingPersonalGDBVector
- {
- outFileType = FileType.SimpleJson;
- }
- foreach (Layer lyr in LayerPanel.SelectLayers)
- {
- ExportSetting es = new ExportSetting();
- es.TargetFileType = outFileType;
- es.TargetFilePath = fileName + "-" + DateTime.Now.Ticks.ToString();
- System.Threading.Thread.Sleep(2);
- es.SourceData = lyr.Dataset as DatasetVector;
- ex.ExportSettings.Add(es);
- }
- ExportResult exResult = ex.Run();
- if (ex.ExportSettings.Count == exResult.SucceedSettings.Length)
- ComsStatic.ShowOKLog(string.Format("地图导出GIS数据" + outFileType.ToString() + ",应导出{0}条,共导出{1}条", ex.ExportSettings.Count, exResult.SucceedSettings.Length));
- else
- ComsStatic.ShowErrorLog(string.Format("地图导出GIS数据" + outFileType.ToString() + ",应导出{0}条,失败导出{1}条", ex.ExportSettings.Count, exResult.FailedSettings.Length));
- if (ComsStatic.Datasource.Datasets.Contains(dviName))
- ComsStatic.Datasource.Datasets.Delete(dviName);
- return true;
- }
- }
- }
|