|
|
|
|
using KGIS.Framework.DBOperator;
|
|
|
|
|
using KGIS.Framework.Maps;
|
|
|
|
|
using Kingo.PluginServiceInterface;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Plugin.SystemSetting.View.ViewSystemSetting
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 系统设置-变更图斑检查规则设置 的交互逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class ViewZLRuleSetting : UserControl
|
|
|
|
|
{
|
|
|
|
|
public List<CheckingRule> FieldsTempData = null;
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
public ViewZLRuleSetting()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
BindData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BindData()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string dbPath = System.IO.Path.GetDirectoryName((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetProjFilePath()) + @"\BGTJ.sqlite";
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
|
|
|
|
|
DataTable dataTable = rdbHelper.ExecuteDatatable("tab", " select ID,case when charindex('{1}',RuleName)>0 THEN '地类图斑更新'||REPLACE(RuleName,'{1}','') ELSE RuleName END RuleName,RuleType,RuleCode,ZLLayerName,ZLIsSelect from CheckingRule where BGLayerName ISNULL AND RuleType='图形拓扑' ", true);
|
|
|
|
|
DataTable dataTablegroupby = rdbHelper.ExecuteDatatable("dataTablegroupby", " select RuleType,RuleType RuleName from CheckingRule where BGLayerName ISNULL AND RuleType='图形拓扑' GROUP BY RuleType ", true);
|
|
|
|
|
FieldsTempData = new List<CheckingRule>();
|
|
|
|
|
var _ID = dataTable.Rows.Count + 1;
|
|
|
|
|
foreach (DataRow row in dataTablegroupby.Rows)
|
|
|
|
|
{
|
|
|
|
|
int isSelectCount = 0;
|
|
|
|
|
var RuleTypeTab = dataTable.Select($"RuleType = '{row["RuleType"].ToString()}'").ToList();
|
|
|
|
|
foreach (var item in RuleTypeTab)
|
|
|
|
|
{
|
|
|
|
|
if (Convert.ToBoolean(item["ZLIsSelect"].ToString()) == true) isSelectCount++;
|
|
|
|
|
}
|
|
|
|
|
CheckingRule checkingRule = new CheckingRule()
|
|
|
|
|
{
|
|
|
|
|
ID = _ID,
|
|
|
|
|
PID = _ID,
|
|
|
|
|
RuleType = row["RuleType"].ToString(),
|
|
|
|
|
RuleName = row["RuleName"].ToString(),
|
|
|
|
|
ZLIsSelect = isSelectCount == RuleTypeTab.Count
|
|
|
|
|
};
|
|
|
|
|
FieldsTempData.Add(checkingRule);
|
|
|
|
|
if (RuleTypeTab.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (DataRow item in RuleTypeTab)
|
|
|
|
|
{
|
|
|
|
|
FieldsTempData.Add(new CheckingRule()
|
|
|
|
|
{
|
|
|
|
|
ID = Convert.ToInt32($"{checkingRule.ID}{item["ID"].ToString()}"),
|
|
|
|
|
PID = checkingRule.ID,
|
|
|
|
|
RuleName = item["RuleName"].ToString(),
|
|
|
|
|
RuleType = item["RuleType"].ToString(),
|
|
|
|
|
ZLIsSelect = Convert.ToBoolean(item["ZLIsSelect"].ToString()),
|
|
|
|
|
RuleCode = item["RuleCode"].ToString(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_ID++;
|
|
|
|
|
}
|
|
|
|
|
treeList.ItemsSource = FieldsTempData;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug($"变更图斑检查规则设置执行失败:{ex.Message}");
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void View_CellValueChanged(object sender, DevExpress.Xpf.Grid.TreeList.TreeListCellValueChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var checkingRule = e.Cell.Row as CheckingRule;
|
|
|
|
|
if (checkingRule != null)
|
|
|
|
|
{
|
|
|
|
|
string dbPath = System.IO.Path.GetDirectoryName((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetProjFilePath()) + @"\BGTJ.sqlite";
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
|
|
|
|
|
if (checkingRule.ID == checkingRule.PID)
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteNonQuery($"Update CheckingRule set ZLIsSelect={e.Value} where RuleType='{checkingRule.RuleType}' ", CommandType.Text);
|
|
|
|
|
FieldsTempData.Where(x => x.RuleType == checkingRule.RuleType).ForEach(y => y.ZLIsSelect = (bool)e.Value);
|
|
|
|
|
treeList.RefreshData();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteNonQuery($"Update CheckingRule set ZLIsSelect={e.Value} where RuleCode='{checkingRule.RuleCode}' ", CommandType.Text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug($"View_CellValueChange执行失败:{ex.Message}");
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|