using KGIS.Framework.DBOperator;
using KGIS.Framework.Maps;
using KGIS.Framework.Utils;
using KGIS.Framework.Views;
using Kingo.PluginServiceInterface;
using Kingo.PluginServiceInterface.Enums;
using Kingo.PluginServiceInterface.Model;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Kingo.Plugin.General.View
{
///
/// UCHCFKYJ.xaml 的交互逻辑
///
public partial class UCHCFKYJ : UserControl, IElementInfo, INotifyPropertyChanged
{
#region 接口实现
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 bool IsShowInMap { get; set; }
public bool IsShow { get; set; }
public int ShowIndex { get; set; }
public bool ResetSize { get; set; }
public bool AllowEdit { get; set; }
#endregion
//审核意见说明
Dictionary dic = null;
public UCHCFKYJ()
{
InitializeComponent();
DevExpress.Xpf.Core.ThemeManager.SetTheme(this, DevExpress.Xpf.Core.Theme.Office2013LightGray);
this.Title = "核查反馈意见";
dic = new Dictionary();
dic.Add("DLCW", "地类认定明显错误");
dic.Add("WZZZW", "新增耕地举证照片未种植作物");
dic.Add("WAYDLDC", "推堆土区图斑未按原地类调查");
dic.Add("WAYJGWDC", "拆除未尽图斑未按原建构筑物地类调查");
dic.Add("WADBDLDC", "光伏用地图斑未按地表地类调查");
dic.Add("WAGYYDDC", "光伏用地图斑在部监管平台范围内未按工业用地调查");
dic.Add("EJDLRDCW", "二级地类明显认定错误");
dic.Add("GDWBWG", "新增耕地标未耕");
dic.Add("SXBZCW", "属性标注错误");
dic.Add("XHDMCW", "细化代码错误");
dic.Add("DDTCYTJ", "单独图层应增加");
dic.Add("DDTCYJS", "单独图层应减少");
dic.Add("DDTCTZ", "单独图层应内部调整");
dic.Add("ZPYDLBYZ", "照片地类与调查地类不一致");
dic.Add("ZZSXCW", "照片地类与调查地类一致, 种植属性编注错误");
dic.Add("YJWJ", "应举未举");
dic.Add("BCJZ", "补充举证");
dic.Add("QTCW", "其他错误");
}
public event PropertyChangedEventHandler PropertyChanged;
public void BindData(object obj)
{
IRDBHelper rdbHelper = null;
HCFKYJInfo hcfkyjMessage = null;
try
{
NYYSInfo nYYSInfo = obj as NYYSInfo;
if (nYYSInfo != null && nYYSInfo.TaskPackages != null && nYYSInfo.WYRWTB != null)
{
TaskPackage taskPackage = nYYSInfo.TaskPackages;
rdbHelper = RDBFactory.CreateDbHelper($"{taskPackage.PackageTempPath}{(MapsManager.Instance.CurrProjectInfo as ProjectInfo).Pathpassword}", DatabaseType.SQLite);
if (rdbHelper == null) return;
var data = rdbHelper.ExecuteScalar($" select HZSH from dtbdltbgx where BSM='{nYYSInfo.DTBDLTBGX.BSM}' and tbbsm = '{nYYSInfo.DTBDLTBGX.TBBSM}'", CommandType.Text);
if (data != null && !string.IsNullOrEmpty(data.ToString()))
{
hcfkyjMessage = JsonConvert.DeserializeObject(data.ToString());
if(hcfkyjMessage != null)
{
txtXjshjg.Text = hcfkyjMessage.XJSH.SHJG;
txtXjshsm.Text = GetShsmValue(hcfkyjMessage.XJSH.SHSM);
txtCjshjg.Text = hcfkyjMessage.XJSH.SHJG;
txtCjshsm.Text = GetShsmValue(hcfkyjMessage.XJSH.SHSM);
txtSjshjg.Text = hcfkyjMessage.SJSH.SHJG;
txtSjshsm.Text = GetShsmValue(hcfkyjMessage.SJSH.SHSM);
txtSjshsj.Text = hcfkyjMessage.SJSH.SHSJ;
txtSjshbz.Text = hcfkyjMessage.SJSH.SHBZ;
}
else
{
SetNull();
}
}
}
else
{
SetNull();
}
}
catch (Exception ex)
{
LogAPI.Debug("绑定外业核查成果异常:" + ex.Message);
LogAPI.Debug("绑定外业核查成果异常:" + ex.StackTrace);
throw ex;
}
}
public void SaveEdit()
{
//throw new NotImplementedException();
}
private string GetShsmValue(string shsm)
{
string strValue = string.Empty;
if(dic == null || string.IsNullOrEmpty(shsm))
{
return strValue;
}
string value;
if (dic.TryGetValue(shsm, out value))
{
strValue = value;
}
return strValue;
}
private void SetNull()
{
txtXjshjg.Text = "";
txtXjshsm.Text = "";
txtCjshjg.Text = "";
txtCjshsm.Text = "";
txtSjshjg.Text = "";
txtSjshsm.Text = "";
txtSjshsj.Text = "";
txtSjshbz.Text = "";
}
}
}