using KGIS.Framework.Utils;
using KGIS.Framework.Utils.Helper;
using Kingo.PluginServiceInterface;
using System;
using System.Windows;
namespace Kingo.Plugin.General.ViewDTBResultCheck
{
///
/// FrmUserInfoSetting.xaml 的交互逻辑
///
public partial class FrmRuleSetting : BaseWindow
{
private ProjectInfo projectInfo { get; set; }
public FrmRuleSetting()
{
InitializeComponent();
this.labVersion.Content = KGIS.Framework.Utils.Helper.CommonHelper.GetVersion((new Kingo.RuleCheck.XJRuleCheck.SJJCCheck_DTB()).GetType());
}
private void BtnSave_Click(object sender, RoutedEventArgs e)
{
try
{
if (string.IsNullOrEmpty(this.txtRulePath.Text))
{
MessageHelper.Show("请选择规则库文件地址!");
return;
}
//string ruleName = "Kingo.RuleCheck.dll";
string rulePath = System.IO.Path.Combine(SysAppPath.GetCurrentAppPath());
SaveFile(rulePath, this.txtRulePath.Text);
MessageHelper.Show("更新成功,请重启系统!");
this.Close();
}
catch (Exception ex)
{
LogAPI.Debug(ex);
MessageHelper.Show("规则库界面设置失败:" + ex.Message);
}
}
public void SaveFile(string path, string fileName)
{
System.IO.FileInfo file = new System.IO.FileInfo(fileName);
string newName = file.Name;
file.CopyTo(path + @"\" + newName, true);
}
private void BtnCancel_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
///
/// 选择路径
///
///
///
private void BtntxtRulePath_Click(object sender, RoutedEventArgs e)
{
string path = string.Empty;
Microsoft.Win32.OpenFileDialog openFileDlg = new Microsoft.Win32.OpenFileDialog();
// 过滤文件扩展名,设置接受的扩展名
openFileDlg.DefaultExt = ".规则文件";
openFileDlg.Filter = "可执行程序 (.规则文件)|*.规则文件";
// 调用ShowDialog方法显示对话框
Nullable result = openFileDlg.ShowDialog();
// 显示路径
if (result == true)
txtRulePath.Text = openFileDlg.FileName;
}
public void saveFile(string path, string fileName)
{
System.IO.FileInfo file = new System.IO.FileInfo(fileName);
string newName = file.Name;
file.CopyTo(path + @"\" + newName, true);
}
}
}