年度变更建库软件5.0版本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

459 lines
18 KiB

using ESRI.ArcGIS.Controls;
using KGIS.Framework.DBOperator;
using KGIS.Framework.Maps;
using KGIS.Framework.Platform;
using KGIS.Framework.Utils;
using KGIS.Framework.Utils.Helper;
using KGIS.Framework.Utils.Interface;
using KGIS.Framework.Views;
using Kingo.PluginServiceInterface;
using Kingo.PluginServiceInterface.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Xml;
using KUI.Windows;
using Kingo.Plugin.General.Helper;
namespace Kingo.Plugin.General.View
{
/// <summary>
/// UCSHInfo.xaml 的交互逻辑
/// </summary>
public partial class UCSHInfo : UserControl, IElementInfo
{
/// <summary>
/// 数据源集合
/// </summary>
private DataTable Data
{
get;
set;
}
private IHookHelper hookHelper { get; set; }
public NYYSInfo SHData { get; set; }
private TaskPackage CurrentTask { get; set; }
public List<WYSketch> ListDdeleteWYSketck { get; set; }
public bool IsShow { get; set; }
public int ShowIndex { get; set; }
public bool ResetSize { get; set; }
public bool AllowEdit { get; set; }
public Guid ID { get; set; }
public DockStyle DockAreas { get; set; }
public System.Drawing.Size FloatSize { get; set; }
public int DockWidth { get; set; }
public int DockHeight { get; set; }
public DockStyle DefaultArea { get; set; }
public bool ShowCloseButton { get; set; }
public bool ShowAutoHideButton { get; set; }
public string Title { get; set; }
public UCSHInfo()
{
InitializeComponent();
this.Title = "审核结果";
List<KeyValue> listSF = new List<KeyValue>()
{
new KeyValue(){ Code="通过", Name="通过"},
new KeyValue(){ Code="不通过", Name="不通过"}
};
XmlDocument doc = new XmlDocument();
//SysAppPath.GetConfigPath() + SysAppPath.SystemConfigName;
string strPath = SysAppPath.GetCurrentAppPath() + @"工作空间DTBJK\DTBConfigs\LoadCustomConfig.xml";
if (System.IO.File.Exists(strPath))
{
doc.Load(strPath);
this.comBoxDLHCJG.ItemsSource = listSF;
this.comBoxDLHCJG.SelectedIndex = -1;
this.comBoxDLHCSM.ItemsSource = GetListHCSM("DLHCSM", doc);
this.comBoSXHCJG.ItemsSource = listSF;
this.comBoSXHCJG.SelectedIndex = -1;
this.comBoxSXHCSM.ItemsSource = GetListHCSM("SXHCSM", doc);
this.comBoxTXHCJG.ItemsSource = listSF;
this.comBoxTXHCJG.SelectedIndex = -1;
this.comBoxTXHCSM.ItemsSource = GetListHCSM("TXHCSM", doc);
this.comBoxDLHCJG.SelectedIndex = 0;
this.comBoSXHCJG.SelectedIndex = 0;
this.comBoxTXHCJG.SelectedIndex = 0;
}
}
/// <summary>
/// 获取核查说明
/// </summary>
/// <param name="name">DLHCSM:地类核查说明 SXHCSM:属性核查说明 TXHCSM:图形核查说明</param>
/// <returns></returns>
public static List<KeyValue> GetListHCSM(string name, XmlDocument doc)
{
List<KeyValue> listHCSM = new List<KeyValue>();
try
{
XmlNode xmlSysNode = doc.SelectSingleNode($"configuration/CustomConfig/{name}");
if (xmlSysNode.ChildNodes != null && xmlSysNode.ChildNodes.Count > 0)
{
foreach (XmlNode node in xmlSysNode.ChildNodes)
{
if (node.Attributes["Name"] == null)
{
continue;
}
string value = node.Attributes["Name"].Value;
listHCSM.Add(new KeyValue() { Code = value, Name = value });
}
}
return listHCSM;
}
catch (Exception ex)
{
LogAPI.Debug("获取核查说明失败:" + ex.Message);
throw ex;
}
}
private NYYSInfo nYYSInfo = null;
public void BindData(object obj)
{
if (obj is NYYSInfo)
{
hookHelper = new HookHelperClass
{
Hook = MapsManager.Instance.MapService.getAxMapControl().Object
};
nYYSInfo = obj as NYYSInfo;
if (nYYSInfo != null && nYYSInfo.WYRWTB != null && nYYSInfo.TaskPackages != null)
BindData(nYYSInfo.TaskPackages, nYYSInfo.WYRWTB.TBBSM, hookHelper);
}
}
public void SaveEdit()
{
bool ZTIsUploaded = false;
IRDBHelper rdbHelper = null;
try
{
if (nYYSInfo == null) return;
if (nYYSInfo.TaskPackages.State.Equals("已输出"))
{
MessageHelper.ShowTips("当前任务包为“已输出”状态,若要继续编辑,请右键任务包将其改为其他状态!");
return;
}
ProjectInfo projectInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo;
if (string.IsNullOrWhiteSpace(projectInfo.UserName))
{
MessageHelper.Show("未获取到当前用户信息,请先进行用户信息设置!");
return;
}
if (string.IsNullOrWhiteSpace(this.SHData.SHJG.DLHCJG))
{
MessageHelper.Show("请选择地类核查结果!");
return;
}
if (string.IsNullOrWhiteSpace(this.SHData.SHJG.SXHCJG))
{
MessageHelper.Show("请选择属性核查结果!");
return;
}
if (string.IsNullOrWhiteSpace(this.SHData.SHJG.TXHCJG))
{
MessageHelper.Show("请选择图形核查结果!");
return;
}
if (string.IsNullOrWhiteSpace(this.SHData.SHJG.SHRY))
{
this.SHData.SHJG.SHRY = projectInfo.UserName;
}
txtTBBSM.Focus();
this.ShowLoading("正在保存数据......", 0, 0);
System.Threading.Thread.Sleep(1000);
rdbHelper = RDBFactory.CreateDbHelper($"{nYYSInfo.TaskPackages.PackageTempPath}{(MapsManager.Instance.CurrProjectInfo as ProjectInfo).Pathpassword}", DatabaseType.SQLite);
//已上传状态
ZTIsUploaded = DTBDBLoadHelper.JudgeZTIsUploaded(rdbHelper, nYYSInfo.WYRWTB.TBBSM);
rdbHelper.BeginTransaction();
//审核结果保存
string excuteSQL = "insert into shjg(tbbsm,dlhcjg,dlhcsm,sxhcjg,sxhcsm,txhcjg,txhcsm,shsj,shry,shsm,shjb)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')";
if (rdbHelper.TableIsExist("shjg"))
rdbHelper.ExecuteNonQueryWithException($"delete from shjg where tbbsm='{nYYSInfo.WYRWTB.TBBSM}'", CommandType.Text);
else
{
string CreatSql = "CREATE TABLE IF NOT EXISTS SHJG (Id INTEGER PRIMARY KEY, TBBSM TEXT,DLHCJG TEXT,DLHCSM TEXT,SXHCJG TEXT,SXHCSM TEXT,TXHCJG TEXT,TXHCSM TEXT,SHSJ TEXT,SHRY TEXT,SHSM TEXT,SHJB TEXT)";
rdbHelper.ExecuteNonQueryWithException(CreatSql);
}
rdbHelper.ExecuteNonQueryWithException(string.Format(excuteSQL, nYYSInfo.WYRWTB.TBBSM, this.SHData.SHJG.DLHCJG, this.SHData.SHJG.DLHCSM, this.SHData.SHJG.SXHCJG, this.SHData.SHJG.SXHCSM, this.SHData.SHJG.TXHCJG, this.SHData.SHJG.TXHCSM, DateTime.Now, projectInfo.UserName, this.SHData.SHJG.JGSM, this.SHData.SHJG.SHJB), CommandType.Text);
if (!ZTIsUploaded)
rdbHelper.ExecuteNonQueryWithException($"update wyrw set ZT='已完成' where tbbsm='{nYYSInfo.WYRWTB.TBBSM}'", CommandType.Text);
rdbHelper.Commit();
rdbHelper.DisConnect();
this.CloseLoading();
Platform.Instance.SendMsg(new NotifyMsgPackage() { Content = "已完成", MsgType = "RefreshTreeNodeState" });
}
catch (Exception ex)
{
if (rdbHelper != null)
{
rdbHelper.Rollback();
}
LogAPI.Debug("审核信息保存异常:" + ex);
this.CloseLoading();
MessageHelper.ShowError("保存失败:" + ex.Message);
}
finally
{
if (rdbHelper != null)
rdbHelper.DisConnect();
}
}
public void BindData(TaskPackage taskPackage, string bsm, IHookHelper hook)
{
IRDBHelper rdbHelper = null;
try
{
this.SHData = new NYYSInfo();
this.SHData.SHJG = new SHJGInfo();
this.SHData.SHBZ = new List<WYSketch>();
if (taskPackage == null || string.IsNullOrWhiteSpace(bsm))
{
return;
}
if (ListDdeleteWYSketck == null)
{
ListDdeleteWYSketck = new List<WYSketch>();
}
ListDdeleteWYSketck.Clear();
CurrentTask = taskPackage;
rdbHelper = RDBFactory.CreateDbHelper($"{taskPackage.PackageTempPath}{(MapsManager.Instance.CurrProjectInfo as ProjectInfo).Pathpassword}", DatabaseType.SQLite);
this.hookHelper = hook;
//审核结果
string excuteSQL = string.Format("select * from shjg where tbbsm='{0}' order by shsj desc", bsm);
if (!rdbHelper.TableIsExist("shjg"))
{
this.SHData.SHJG.TBBSM = nYYSInfo.WYRWTB.TBBSM;
this.DataContext = this.SHData;
return;
}
DataTable dataTable = rdbHelper.ExecuteDatatable("shjg", excuteSQL, true);
if (dataTable != null && dataTable.Rows.Count > 0)
{
this.SHData.SHJG = KGIS.Framework.Utils.Utility.TBToList.ConvertEntity<SHJGInfo>(dataTable.Rows[0]);
}
else
{
this.SHData.SHJG = new SHJGInfo() { BSM = 1, TBBSM = bsm, SHRY = (KGIS.Framework.Maps.MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).UserName, SHSJ = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), SHJB = "县级" };//DLHCJG = "通过", TXHCJG = "通过", SXHCJG = "通过"
if (SysConfigsOprator.GetAppsetingValueByKey("ArearName").Equals("43"))
{
this.SHData.SHJG.DLHCJG = "通过";
this.SHData.SHJG.SXHCJG = "通过";
this.SHData.SHJG.TXHCJG = "通过";
}
}
Data = null;
this.DataContext = this.SHData;
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (rdbHelper != null)
{
rdbHelper.DisConnect();
}
}
}
private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
{
try
{
if (this.ActualWidth > 300)
{
txtWBGYY.MaxWidth = (int)this.ActualWidth - 80;
}
}
catch (Exception)
{
}
}
private void ComBoxDLHCJG_SelectedIndexChanged(object sender, RoutedEventArgs e)
{
try
{
KeyValue keyValue = comBoxDLHCJG.SelectedItem as KeyValue;
if (keyValue != null && keyValue.Name.Equals("不通过"))
{
layoutDLHCSM.Visibility = Visibility.Visible;
comBoxDLHCSM.SelectedIndex = 0;
}
else
{
layoutDLHCSM.Visibility = Visibility.Collapsed;
comBoxDLHCSM.SelectedIndex = -1;
if (this.SHData != null)
if (this.SHData.SHJG != null)
this.SHData.SHJG.DLHCSM = "";
}
}
catch (Exception ex)
{
LogAPI.Debug(ex);
}
}
private void ComBoxTXHCJG_SelectedIndexChanged(object sender, RoutedEventArgs e)
{
try
{
KeyValue keyValue = comBoxTXHCJG.SelectedItem as KeyValue;
if (keyValue != null && keyValue.Name.Equals("不通过"))
{
layoutTXHCSM.Visibility = Visibility.Visible;
comBoxTXHCSM.SelectedIndex = 0;
}
else
{
layoutTXHCSM.Visibility = Visibility.Collapsed;
comBoxTXHCSM.SelectedIndex = -1;
if (this.SHData != null)
if (this.SHData.SHJG != null)
this.SHData.SHJG.TXHCSM = "";
}
}
catch (Exception ex)
{
LogAPI.Debug(ex);
}
}
private void ComBoSXHCJG_SelectedIndexChanged(object sender, RoutedEventArgs e)
{
try
{
KeyValue keyValue = comBoSXHCJG.SelectedItem as KeyValue;
if (keyValue != null && keyValue.Name.Equals("不通过"))
{
layoutSXHCSM.Visibility = Visibility.Visible;
comBoxSXHCSM.SelectedIndex = 0;
}
else
{
layoutSXHCSM.Visibility = Visibility.Collapsed;
comBoxSXHCSM.SelectedIndex = -1;
if (this.SHData != null)
if (this.SHData.SHJG != null)
this.SHData.SHJG.SXHCSM = "";
}
}
catch (Exception ex)
{
LogAPI.Debug(ex);
}
}
private void ComBoxSXHCSM_SelectedIndexChanged(object sender, RoutedEventArgs e)
{
try
{
if (this.SHData.SHJG == null)
{
return;
}
if (this.comBoxSXHCSM.SelectedIndex > -1)
{
this.SHData.SHJG.SXHCSM = (this.comBoxSXHCSM.SelectedItem as KeyValue).Name;
}
else
{
this.SHData.SHJG.SXHCSM = string.Empty;
}
}
catch (Exception ex)
{
LogAPI.Debug(ex);
}
}
private void ComBoxDLHCSM_SelectedIndexChanged(object sender, RoutedEventArgs e)
{
try
{
if (this.SHData.SHJG == null)
{
return;
}
if (this.comBoxDLHCSM.SelectedIndex > -1)
{
this.SHData.SHJG.DLHCSM = (this.comBoxDLHCSM.SelectedItem as KeyValue).Name;
}
else
{
this.SHData.SHJG.DLHCSM = string.Empty;
}
}
catch (Exception ex)
{
LogAPI.Debug(ex);
}
}
private void ComBoxTXHCSM_SelectedIndexChanged(object sender, RoutedEventArgs e)
{
try
{
if (this.SHData.SHJG == null)
{
return;
}
if (this.comBoxTXHCSM.SelectedIndex > -1)
{
this.SHData.SHJG.TXHCSM = (this.comBoxTXHCSM.SelectedItem as KeyValue).Name;
}
else
{
this.SHData.SHJG.TXHCSM = string.Empty;
}
}
catch (Exception ex)
{
LogAPI.Debug(ex);
}
}
/// <summary>
/// 失去焦点时,设置快捷键生效
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TxtWBGYY_LostFocus(object sender, RoutedEventArgs e)
{
if ((KGIS.Framework.Maps.MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo) != null)
{
(KGIS.Framework.Maps.MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).EnableShortcut = true;
}
}
/// <summary>
/// 获取焦点时,设置快捷键失效
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TxtWBGYY_GotFocus(object sender, RoutedEventArgs e)
{
if ((KGIS.Framework.Maps.MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo) != null)
{
(KGIS.Framework.Maps.MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).EnableShortcut = false;
}
}
}
}