using KGIS.Framework.Maps; using KGIS.Framework.Utils; using KGIS.Framework.Utils.Helper; using Kingo.Plugin.General.Helper; using Kingo.PluginServiceInterface; using Kingo.PluginServiceInterface.Helper; using Kingo.PluginServiceInterface.Model; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Windows; using System.Windows.Controls; namespace Kingo.Plugin.DTBJK_XJ.View { /// /// UCUploadTask.xaml 的交互逻辑 /// public partial class UCUploadTask : BaseWindow { List taskPackages = new List(); ProjectInfo projectInfo = null; public UCUploadTask() { InitializeComponent(); this.Height = 520; this.Width = 1000; BindData(); } private void BindData() { try { projectInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo; string taskPath = projectInfo.TaskPath + "\\临时"; if (string.IsNullOrEmpty(taskPath) || !Directory.Exists(taskPath)) { MessageBox.Show("未检测到任务目录,请先设置任务目录。", "提示信息", MessageBoxButton.OK); return; } if (projectInfo != null && projectInfo.ListTaskPackage != null && projectInfo.ListTaskPackage.Count != 0) { taskPackages = projectInfo.ListTaskPackage; } else { string[] filePaths = Directory.GetDirectories(taskPath); string fileName = ""; foreach (string filePath in filePaths) { fileName = System.IO.Path.GetFileName(filePath); taskPackages.Add(new TaskPackage() { Ischeck = false, State = "未上传", PackageName = fileName, PackagePath = filePath }); } } dgTableMapping.ItemsSource = taskPackages; } catch (Exception ex) { LogAPI.Debug("任务包数据上传获取包数据失败!" + ex); } } /// /// 上传数据 /// /// /// private void btnSubmitJKTB_Click(object sender, RoutedEventArgs e) { try { if (taskPackages == null || taskPackages.Count == 0) { MessageHelper.ShowTips("未找到可上传的任务包数据!"); return; } IJKTBTask taskHelper = new JKTBTaskHelper(); List chooseTaskPackages = taskPackages.FindAll(a => a.Ischeck == true); if (chooseTaskPackages == null || chooseTaskPackages.Count == 0) { MessageHelper.ShowTips("未选中任务包数据!"); return; } string ywlx = UserLoginHelper.GetAppsetingValueByKey("JkTaskDBYWLX"); if (string.IsNullOrEmpty(ywlx)) { MessageHelper.ShowTips("获取业务类型失败!"); LogAPI.Debug("获取业务类型失败!"); return; } string userid = UserLoginHelper.GetAppsetingValueByKey("UserId"); if (string.IsNullOrEmpty(userid)) { MessageHelper.ShowTips("获取用户ID失败!"); LogAPI.Debug("获取用户ID失败!"); return; } foreach (TaskPackage item in chooseTaskPackages) { var result = taskHelper.SaveJTTBData(item.PackageTempPath, ywlx, userid, out int ZT); if (result != null && result.Code == 200) { LogAPI.Debug(item.PackageName + "数据上报成功," + result.Message); //MessageBox.Show(result.Message, "提示信息", MessageBoxButton.OK); //修改包状态 是否上传状态 if (projectInfo != null) { if (projectInfo.ListTaskPackage.Contains(item)) { projectInfo.ListTaskPackage.FirstOrDefault(a => a.PackageName == item.PackageName).State = ZT == 0 ? "已上传" : "部分成功"; } else { item.State = ZT == 0 ? "已上传" : "部分成功"; projectInfo.ListTaskPackage.Add(item); } } else item.State = ZT == 0 ? "已上传" : "部分成功"; } else { LogAPI.Debug("数据上报失败," + result.Error); //MessageBox.Show("数据上报失败," + result.Error, "提示信息", MessageBoxButton.OK); if (projectInfo != null) { if (projectInfo.ListTaskPackage.Contains(item)) { projectInfo.ListTaskPackage.FirstOrDefault(a => a.PackageName == item.PackageName).State = ZT == 2 ? "上传失败" : "未完成"; } else { item.State = ZT == 2 ? "上传失败" : "未完成"; projectInfo.ListTaskPackage.Add(item); } } else item.State = ZT == 2 ? "上传失败" : "未完成"; } LogAPI.Debug("任务包" + item.PackageName + ":" + result.Message); MessageHelper.ShowTips("任务包" + item.PackageName + ":" + result.Message); } if (projectInfo != null) projectInfo.Save(); //刷新页面 dgTableMapping.ItemsSource = null; dgTableMapping.ItemsSource = taskPackages; } catch (Exception ex) { LogAPI.Debug("数据上报失败" + ex.Message); LogAPI.Debug("数据上报失败" + ex.StackTrace); MessageBox.Show("数据上报失败。", "提示信息", MessageBoxButton.OK); } } private void AllCheckEidt_EditValueChanged(object sender, DevExpress.Xpf.Editors.EditValueChangedEventArgs e) { try { if (this.dgTableMapping == null || (dgTableMapping.ItemsSource as List) == null) { return; } List listTableMapping = dgTableMapping.ItemsSource as List; bool check = (sender as DevExpress.Xpf.Editors.CheckEdit).IsChecked == null ? false : bool.Parse((sender as DevExpress.Xpf.Editors.CheckEdit).IsChecked.Value.ToString()); if (check) { listTableMapping.ForEach(a => a.Ischeck = true); } else { listTableMapping.ForEach(a => a.Ischeck = false); } dgTableMapping.RefreshData(); dgTableMapping.ItemsSource = null; dgTableMapping.ItemsSource = listTableMapping; } catch (Exception ex) { MessageHelper.ShowTips("全选发生异常:" + ex.Message); } } private void checkBox_Click(object sender, RoutedEventArgs e) { TaskPackage tbm = dgTableMapping.SelectedItem as TaskPackage; if (tbm != null) { tbm.Ischeck = (bool)(sender as CheckBox).IsChecked; } } } }