using KGIS.Framework.Common.Interface; using KGIS.Framework.Maps; using KGIS.Framework.Platform; using KGIS.Framework.Platform.Helper; using KGIS.Framework.Utils; using KGIS.Framework.Utils.Helper; using Kingo.Plugin.YJJK.Interface; using Kingo.PluginServiceInterface; using System; using System.Collections.Generic; using System.Data; using System.Linq; using UIShell.OSGi; namespace Kingo.Plugin.YJJK.ModelEntity { public class BGExportHelper : IStatisticExport { public string OutPath { get; set; } public string NCDataDir { get; set; } public ReportFileTypeEnum AreaUnit { get; set; } /// /// 获取变更报表列表 /// /// public List GetReportEntityClassList() { List result = new List(); return result; } /// /// 获取变更文字输出报表列表 /// /// public List GetReportlanguageOutEntityClassList() { List result = new List(); return result; } public List TreeList { get { List dicList = Platform.Instance.DicHelper.GetDic(DicTypeEnum.QSDM, true); if (dicList == null) return null; return GetTree(dicList); } } private List GetTree(List dicList) { try { if (dicList == null) return null; List result = new List(); foreach (DataDicTionary dic in dicList) { if (dic.CODE.Length < 6 || dic.CODE.Length > 12) { if (dic.SubDic != null && dic.SubDic.Count > 0) { result.AddRange(GetTree(dic.SubDic)); } continue; } var n1 = new XZQTreeNode(); n1.XZQDM = dic.CODE; n1.XZQMC = dic.NAME; n1.Tag = dic; n1.GroupName = "XZQ"; result.Add(n1); if (dic.SubDic != null && dic.SubDic.Count > 0) { n1.Nodes = GetTree(dic.SubDic); } if (n1.XZQDM.Length == 6) { n1.IsExpanded = true; } } result = result.OrderBy(x => x.XH).ToList(); return result; } catch (Exception ex) { LogAPI.Debug(ex); } return null; } public ReportEntityClass GetReportEntityClass(BGReportTypeEnum re) { var relist = GetReportEntityClassList(); return relist.FirstOrDefault(x => x.BGReportType == re); } public ReportEntityClass GetWordReportEntityClass(BGReportTypeEnum re) { var relist = GetReportlanguageOutEntityClassList(); return relist.FirstOrDefault(x => x.BGReportType == re); } IReportService _ReportService = null; public void Export(ReportTypeEnum re) { //IRDBHelper dbHelper = null; try { if (string.IsNullOrWhiteSpace((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE)) { MessageHelper.Show("县行政区划代码不能为空,请在工程属性界面中填写6位县区划代码!"); return; } if (System.IO.File.Exists(OutPath)) { System.IO.File.Delete(OutPath); } string dbPath = System.IO.Path.GetDirectoryName((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetProjFilePath()) + @"\BGTJ.sqlite"; //创建数据库连接 //dbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite); ////第一步:首先判断是否已经缓存过表 //string sql = " select * from BGYLB "; //DataTable dtBGYLB = null; //try //{ // dtBGYLB = dbHelper.ExecuteDatatable("BGYLB", sql, true); //} //catch //{ //} //if (dtBGYLB == null || dtBGYLB.Rows.Count == 0) //{ // LogAPI.Debug("BGYLB 数据为空"); //} string saveCurrentPath = string.Format("{0}.xlsx", OutPath); if (_ReportService == null) _ReportService = BundleRuntime.Instance.GetFirstOrDefaultService(); if (_ReportService != null) { _ReportService.ExportBGReportNEW(saveCurrentPath, null, re.ToString(), NCDataDir); } else { LogAPI.Debug("未能获取到报表输出服务,无法进行报表输出!"); } } catch (Exception ex) { ProgressHelper.CloseProcessBar(); MessageHelper.ShowError("导出失败!"); LogAPI.Debug("导出失败:" + ex); } finally { //if (dbHelper != null) // dbHelper.DisConnect(); } } public void ExportReport(ReportTypeEnum pReportType) { } public void ExportWordReport(ReportTypeEnum pReportType) { //if (string.IsNullOrWhiteSpace((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).CODE)) //{ // MessageHelper.Show("县行政区划代码不能为空,请在工程属性界面中填写6位县区划代码!"); // return; //} //if (System.IO.File.Exists(OutPath)) //{ // System.IO.File.Delete(OutPath); //} //ExportHelper eh = new ExportHelper(); //List exportTypes = eh.GetReportEntityBGWordClassList(); //string name = System.IO.Path.GetFileName(OutPath); //name = name.Substring(name.IndexOf(")") + 1); //System.IO.File.Copy(SysAppPath.GetCurrentAppPath() + "TempalateReports\\统一时点更新文档\\" + exportTypes.Where(x => x.Name == name).ToList()[0].TempalateFileName, OutPath + ".docx"); } } }