using ESRI.ArcGIS.Controls; using KGIS.Framework.DBOperator; using KGIS.Framework.Maps; using KGIS.Framework.Utils; using KGIS.Framework.Views; using Kingo.Plugin.General.Helper; using Kingo.PluginServiceInterface; //using KGIS.Framework.Utils.Models; using Kingo.PluginServiceInterface.Model; using System; using System.Collections.Generic; using System.Data; using System.Windows; using System.Windows.Controls; //using KGIS.Plugin.SH.View; namespace Kingo.Plugin.General.View { /// /// UCWyspInfo.xaml 的交互逻辑 /// public partial class UCWyspInfo : UserControl, IElementInfo { public IHookHelper hookHelper { get; set; } private IRDBHelper rdbHelper = null; private TaskPackage TaskPackage { get; set; } private UCVideo VideoForm { 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 string Bsm { get; set; } List list { get; set; } public UCWyspInfo() { InitializeComponent(); this.Title = "外业视频"; } private void PayVideo_Click(object sender, RoutedEventArgs e) { try { if (VideoForm == null) { VideoForm = new UCVideo(); } VideoForm.Title = "视频播放"; VideoForm.Height = 450; VideoForm.Width = 800; VideoForm.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; VideoForm.Closed += VideoForm_Closed; VideoForm.VideoPath = ((Kingo.Plugin.General.View.WyhcfjInfo)((System.Windows.FrameworkElement)sender).DataContext).FjPath; if (!string.IsNullOrEmpty(VideoForm.VideoPath)) { VideoForm.PlayVideo(); VideoForm.ShowInMainWindow(false); } } catch (Exception ee) { LogAPI.Debug("PayVideo_Click ERROR:" + ee.ToString()); } } private void VideoForm_Closed(object sender, EventArgs e) { if (VideoForm != null) { VideoForm = null; } } private void cboxVideo_Click(object sender, RoutedEventArgs e) { try { WyhcfjInfo videoObj = (Kingo.Plugin.General.View.WyhcfjInfo)((System.Windows.FrameworkElement)sender).DataContext; if (TaskPackage == null) { throw new Exception("相关附件获取任务包异常。"); } rdbHelper = RDBFactory.CreateDbHelper($"{TaskPackage.PackageTempPath}{(MapsManager.Instance.CurrProjectInfo as ProjectInfo).Pathpassword}", DatabaseType.SQLite); object obj = rdbHelper.ExecuteScalar($"select bsm from fjgx where wytbbsm = '{videoObj.Tbbsm}' and tbbsm ='{videoObj.Bsm}' and fjarg = '{videoObj.Arg}'", CommandType.Text); if (((System.Windows.Controls.Primitives.ToggleButton)e.Source).IsChecked == true) { videoObj.Sfxz = 1; if (obj == null) { rdbHelper.ExecuteNonQuery($"insert into fjgx (wytbbsm,fjarg,tbbsm) values ('{videoObj.Tbbsm}','{videoObj.Arg}','{videoObj.Bsm}')", CommandType.Text); } } else { videoObj.Sfxz = 0; if (obj != null && !string.IsNullOrEmpty(obj.ToString())) { rdbHelper.ExecuteNonQuery($"delete from fjgx where wytbbsm = '{videoObj.Tbbsm}' and tbbsm ='{videoObj.Bsm}' and fjarg = '{videoObj.Arg}'", CommandType.Text); } } } catch (Exception ee) { LogAPI.Debug("cboxVideo_Click ERROR :" + ee.ToString()); throw ee; } finally { if (rdbHelper.State == ConnectionState.Open) { rdbHelper.DisConnect(); } rdbHelper.Clear(); rdbHelper = null; } } public void BindData(object obj) { if (obj == null) { this.dgdVideo.ItemsSource = null; return; } IRDBHelper rdbHelper = null; try { NYYSInfo nYYSInfo = obj as NYYSInfo; if (nYYSInfo == null || nYYSInfo.TaskPackages == null) return; TaskPackage = nYYSInfo.TaskPackages; string strSql = "select BSM,HCLX,HCJLBSM,DKID,FJMC,FJLX,MODE,SEQUENCE,SUBTYPE,ARG,ARG2,ARG3,ARG4,LENGTH,POINTS_JSON,HCRY,GROUP_INDEX,GROUPCODE,SUBTASKID,CHECK_CODE,UserDelete,0 as IsChecked,CJSJ from wyhcfj where HCJLBSM='{0}' and (UserDelete=0 or UserDelete is null) and mode in (5)"; rdbHelper = RDBFactory.CreateDbHelper($"{nYYSInfo.TaskPackages.PackageTempPath}{(MapsManager.Instance.CurrProjectInfo as ProjectInfo).Pathpassword}", DatabaseType.SQLite); DataTable dataTable = rdbHelper.ExecuteDatatable("wyhcfj", string.Format(strSql, nYYSInfo.WYRWTB.TBBSM), true); if (dataTable != null && dataTable.Rows.Count > 0) { string videoPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(nYYSInfo.TaskPackages.PackageTempPath), "Video"); if (!System.IO.Directory.Exists(videoPath)) { System.IO.Directory.CreateDirectory(videoPath); } DataTable dt = rdbHelper.ExecuteDatatable("fjgx", $"select fjarg from fjgx where WYTBBSM='{nYYSInfo.DTBDLTBGX.TBBSM}' and tbbsm = '{nYYSInfo.DTBDLTBGX.BSM}'", true); list = JKTBTaskHelper.ToList(dataTable); foreach (var item in list) { try { item.ImagePath = System.IO.Path.Combine(videoPath, item.FJMC.ToString().Trim()); if (!System.IO.File.Exists(item.ImagePath)) { item.FJ = item.ARG4; System.IO.File.WriteAllBytes(item.ImagePath, item.ARG4); } if (dt != null && dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { if (item.ARG == row["fjarg"].ToString()) { item.SFXZ = 1; break; } else { item.SFXZ = 0; } } } else { item.SFXZ = 0; } } catch (Exception ex) { LogAPI.Debug(item.FJMC.ToString().Trim() + "视频下载失败:" + ex.Message); } } if (list != null && list.Count > 0) { List fjList = new List(); foreach (var item in list) { fjList.Add(new WyhcfjInfo(item.BSM.ToString(), item.BSM.ToString(), item.HCJLBSM, item.FJMC, item.ImagePath, item.ARG, item.HCRY, item.PSSJ, item.SFXZ)); } this.dgdVideo.ItemsSource = fjList; } else { this.dgdVideo.ItemsSource = null; } } else { this.dgdVideo.ItemsSource = null; } } catch (Exception ee) { LogAPI.Debug("外业视频BindData ERROR:" + ee.Message); LogAPI.Debug(ee.Source); } finally { if (rdbHelper != null && rdbHelper.State == ConnectionState.Open) { rdbHelper.DisConnect(); } rdbHelper = null; } } public void SaveEdit() { } } public class WyhcfjInfo { public WyhcfjInfo() { } public WyhcfjInfo(string id, string bsm, string tbbsm, string fjmc, string fjpath, string arg, string hcry, string hcsj, int isSelected) { this.Id = id; this.Bsm = bsm; this.Tbbsm = tbbsm; this.Fjmc = fjmc; this.FjPath = fjpath; this.Arg = arg; this.Hcry = hcry; this.Hcsj = hcsj; this.Sfxz = isSelected; } public string Id { get; set; } public string Bsm { get; set; } public string Tbbsm { get; set; } public string Fjmc { get; set; } public string Arg { get; set; } public string FjPath { get; set; } public string Hcry { get; set; } public string Hcsj { get; set; } public int Sfxz { get; set; } } }