using KGIS.Framework.Commands; using KGIS.Framework.DBOperator; using KGIS.Framework.Maps; using KGIS.Framework.Utils.Helper; using Kingo.Plugin.DTBYCL.View; using Kingo.PluginServiceInterface; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Kingo.Plugin.DTBYCL.Commands { /// /// 成果输出 /// class CmdWYResultExport : BaseMenuCommand { private UCYSResultExport uCYSResultExport { get; set; } private string SaveResultPath { get; set; } public override void OnCreate(object hook) { } public override void OnClick() { try { ProjectInfo ProjectInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo; if (string.IsNullOrWhiteSpace(ProjectInfo.JCKPath)) { MessageHelper.Show("请先使用“基础数据加载”功能设置基础库数据!"); return; } if (ProjectInfo.ListTaskPackage == null || ProjectInfo.ListTaskPackage.Count == 0) { MessageHelper.Show("请先使用“任务目录设置或新建任务包”功能加载或创建外业任务包!"); return; } if (string.IsNullOrWhiteSpace(ProjectInfo.UserName)) { MessageHelper.Show("请先使用“用户设置”功能设置用户名!"); return; } if (uCYSResultExport == null) { uCYSResultExport = new UCYSResultExport(false); uCYSResultExport.Width = 850; uCYSResultExport.Height = 450; uCYSResultExport.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; uCYSResultExport.Closed += UCYSResultExport_Closed; uCYSResultExport.ShowInMainForm(false); } } catch (Exception ex) { KGIS.Framework.Utils.LogAPI.Debug("预处理成果输出界面加载异常:" + ex.Message); MessageHelper.ShowError("预处理成果输出界面加载异常:" + ex.Message); } finally { try { if (System.IO.File.Exists(this.SaveResultPath)) { System.IO.File.Delete(this.SaveResultPath); } } catch (Exception ex) { KGIS.Framework.Utils.LogAPI.Debug(ex); } } } private void UCYSResultExport_Closed(object sender, EventArgs e) { try { if (uCYSResultExport != null) { uCYSResultExport.Close(); } uCYSResultExport = null; } catch (Exception ex) { KGIS.Framework.Utils.LogAPI.Debug(ex); } } /// /// 验证包表结构是否都存在 /// private void CheckTableExist(IRDBHelper rdbHelper) { try { string excuteSQL = @"CREATE TABLE if not exists NYYSResult ( BSM INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, TBBSM TEXT, NYYPDL TEXT, SFXYWY INTEGER, YPSM TEXT, YPRY TEXT, YPSJ TEXT ); CREATE TABLE if not exists YSJ ( BType TEXT, BEdition TEXT, Encrypted INTEGER, Pwd TEXT, CreateTime TEXT, CreateUser TEXT, UpdateUser TEXT, LastUpdateTime TEXT ); CREATE TABLE if not exists WYSketch ( BSM INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, TBBSM TEXT, BZType TEXT, BZMessage TEXT, Geometry TEXT, CONSTRAINT WYZDCT_PK PRIMARY KEY(BSM) ); "; rdbHelper.ExecuteNonQueryWithException(excuteSQL, CommandType.Text); } catch (Exception ex) { throw ex; } } public override bool Enabled { get { ProjectInfo ProjectInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo; if (ProjectInfo == null) return false; return true; } } } }