年度变更建库软件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.

297 lines
12 KiB

6 months ago
using ESRI.ArcGIS.Geometry;
using KGIS.Framework.AE;
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.Plugin.MapView.Common;
using Kingo.Plugin.MapView.Interface;
using Kingo.PluginServiceInterface;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
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.MapView.Views.LookPhoto
{
/// <summary>
/// UCLookPhoto.xaml 的交互逻辑
/// </summary>
public partial class UCLookPhoto : UserControl, IDockPanel2, INotifyPropertyChanged
{
public bool showDetail { get; set; }
private int m_DataIndex { get; set; }
private int m_DataCount { get; set; }
public Action<bool> RowNext;
ProjectInfo info = (MapsManager.Instance.CurrProjectInfo as ProjectInfo);
string hcjgPath = string.Empty;
string tbybh = string.Empty;
public UCLookPhoto()
{
DevExpress.Xpf.Core.ThemeManager.SetTheme(this, DevExpress.Xpf.Core.Theme.Office2013LightGray);
InitializeComponent();
this.DockAreas = DockStyle.DockRight;
this.FloatSize = new System.Drawing.Size(520, 800);
this.DefaultArea = DockStyle.DockRight;
this.ShowCloseButton = true;
this.ShowAutoHideButton = false;
this.DockWidth = 520;
this.Title = "举证信息";
hcjgPath = info.ProjDir + "//jz_hcjg.sqlite";
ucImgXZZP.ChangedPointSymbol = ChangedPointSymbol;
}
private void ChangedPointSymbol(string fjmc)
{
EnvironmentVariables.Instance.cameraPoint.ChangedPointSymbol(fjmc);
}
Dictionary<string, string> lstFj = null;
List<string> lstTBYBH = null;
public void InitData(DataRow drSelect)
{
try
{
tbybh = drSelect["JCBH"].ToString();
lblJCBH.Content = tbybh;
lblWYBZ.Content = drSelect["BZ"].ToString();
lblBGDL.Content = drSelect["BGDL"].ToString();
DataTable dt = SQLiteDBOperate.Instance.ExceDataTable(info.DBPath, string.Format("select TBYBH,FJMC,XZB,YZB,Longitude,Latitude,PSJD,FJLX from FJ where TBYBH='{0}'", tbybh));
DataTable dtHCJG = SQLiteDBOperate.Instance.ExceDataTable(hcjgPath, string.Format("select * from JZHCJG where TBYBH='{0}'", tbybh));
if (dtHCJG != null && dtHCJG.Rows.Count > 0)
{
txtHCJG.Text = dtHCJG.Rows[0]["HCJG"].ToString();
}
else
{
txtHCJG.Text = "";
}
DataTable dtCheck = SQLiteDBOperate.Instance.ExceDataTable(hcjgPath, string.Format("select * from JZZP where TBYBH='{0}'", tbybh));
if (dt != null && dt.Rows.Count > 0)
{
List<ImageView.AttachEntity> lstAttach = new List<ImageView.AttachEntity>();
ImageView.AttachEntity entity = null;
lstFj = new Dictionary<string, string>();
lstTBYBH = new List<string>();
foreach (DataRow dr in dt.Rows)
{
entity = new ImageView.AttachEntity();
if (lstFj.ContainsKey(dr["FJMC"].ToString()))
{
continue;
}
lstFj.Add(dr["FJMC"].ToString(), "");
if (dtCheck != null && dtCheck.Rows.Count > 0)
{
DataRow[] drSet = dtCheck.Select(string.Format(" FJMC='{0}' ", dr["FJMC"].ToString()));
if (drSet != null && drSet.Length > 0)
{
entity.isCheck = true;
}
}
if (!lstTBYBH.Contains(dr["TBYBH"].ToString()))
lstTBYBH.Add(dr["TBYBH"].ToString());
entity.FJMC = dr["FJMC"].ToString();
entity.AttachLocationPath = info.ProjDir + "\\Picture\\" + dr["FJMC"].ToString();
double xzb, yzb;
if (double.TryParse(dr["Longitude"].ToString(), out xzb) && double.TryParse(dr["Latitude"].ToString(), out yzb))
{
IPoint mapPointC = new PointClass() { X = xzb, Y = yzb };
if (mapPointC.X != 0)
{
ISpatialReferenceFactory NewSpatialReference = new SpatialReferenceEnvironmentClass();
mapPointC.SpatialReference = NewSpatialReference.CreateGeographicCoordinateSystem(4490);
//创建图层
ISpatialReference spatiaReference = GeoDBAPI.CreteSpatialReference(info.PrjFileStr);
mapPointC.Project(spatiaReference);
entity.X = mapPointC.X;
entity.Y = mapPointC.Y;
System.Runtime.InteropServices.Marshal.ReleaseComObject(NewSpatialReference);
NewSpatialReference = null;
System.Runtime.InteropServices.Marshal.ReleaseComObject(mapPointC);
mapPointC = null;
}
else
{
continue;
}
}
else
{
if (dr["XZB"] != DBNull.Value)
{
entity.X = Convert.ToDouble(dr["XZB"]);
}
if (dr["YZB"] != DBNull.Value)
{
entity.Y = Convert.ToDouble(dr["YZB"]);
}
}
if (dr["PSJD"] != DBNull.Value)
{
entity.Angle = Convert.ToDouble(dr["PSJD"]);
}
if (dr["FJLX"].ToString() != "V")
lstAttach.Add(entity);
}
ExportPic(lstTBYBH, info.DBPath);
EnvironmentVariables.Instance.cameraPoint.AddCameraPoint((object)lstAttach as List<object>);
ucImgXZZP.InitData(lstAttach, true, false);
}
}
catch (Exception ex)
{
LogAPI.Debug("举证信息加载异常:" + ex.Message);
}
}
private void ExportPic(List<string> lstPic, string dbPath)
{
try
{
if (lstPic.Count > 0)
{
string picPath = string.Empty;
string picturePath = info.ProjDir + "\\Picture";
if (!Directory.Exists(picturePath))
{
Directory.CreateDirectory(picturePath);
}
foreach (string tbybh in lstPic)
{
DataTable tmDt = SQLiteDBOperate.Instance.ExceDataTable(dbPath, "select FJ,FJMC from FJ where TBYBH='" + tbybh + "'");
if (tmDt != null && tmDt.Rows.Count > 0)
{
foreach (DataRow tmpDr in tmDt.Rows)
{
if (tmpDr != null && tmpDr["FJ"] != System.DBNull.Value)
{
picPath = info.ProjDir + "\\Picture\\" + tmpDr["FJMC"].ToString();
if (!File.Exists(picPath))
{
File.WriteAllBytes(info.ProjDir + "\\Picture" + "\\" + tmpDr["FJMC"].ToString(), (tmpDr["FJ"] as byte[]));
}
}
}
}
}
}
}
catch (Exception ex)
{
LogAPI.Debug("举证照片写入本地异常:" + ex.Message);
}
}
private void BtnSave_Click(object sender, RoutedEventArgs e)
{
SaveData();
}
private void BtnPrev_Click(object sender, RoutedEventArgs e)
{
SaveData();
if (RowNext != null)
RowNext(false);
}
private void BtnNext_Click(object sender, RoutedEventArgs e)
{
SaveData();
if (RowNext != null)
RowNext(true);
}
private void SaveData()
{
if (!File.Exists(hcjgPath))
{
string sqlitePath = AppDomain.CurrentDomain.BaseDirectory + "Plugins\\Kingo.Plugin.DataLoad\\Resources\\model.sqlite";
File.Copy(sqlitePath, hcjgPath);
SQLiteDBOperate.Instance.NoQuerySQLAttach("Create table JZHCJG (TBYBH varchar(50),HCJG varchar(200))", "", hcjgPath);
SQLiteDBOperate.Instance.NoQuerySQLAttach("Create table JZZP (TBYBH varchar(50),FJMC varchar(200))", "", hcjgPath);
}
List<string> lstSql = new List<string>();
lstSql.Add(string.Format("delete from JZHCJG where TBYBH='{0}';", tbybh));
lstSql.Add(string.Format("delete from JZZP where TBYBH='{0}';", tbybh));
lstSql.Add(string.Format("Insert into JZHCJG (TBYBH,HCJG) values ('{0}','{1}');", tbybh, txtHCJG.Text.Trim()));
foreach (ImageView.AttachEntity entity in ucImgXZZP.GetAttachEntityList())
{
if (entity.isCheck)
lstSql.Add(string.Format("insert into JZZP (TBYBH,FJMC) values ('{0}','{1}');", tbybh, entity.FJMC));
}
SQLiteDBOperate.Instance.ExecuteNoQueryList(hcjgPath, lstSql);
}
public bool IsShowInMap { 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 event EventHandler CloseViewHandler;
public event PropertyChangedEventHandler PropertyChanged;
public void ClosePanel()
{
showDetail = false;
Platform.Instance.CloseView(this);
}
public void ClosePanelInvoke()
{
CloseViewHandler?.Invoke(this, null);
}
public void ShowPanel()
{
showDetail = true;
Platform.Instance.OpenView(this, false);
}
}
}