| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Configuration; |
| | | using System.Data; |
| | | using System.Diagnostics; |
| | | using System.IO; |
| | | using System.Linq; |
| | |
| | | return i.ToString(); |
| | | } |
| | | |
| | | private static readonly string selectResSql = "select a.id, a.url, b.url || case when length(b.args) > 0 then '?' || b.args else '' end \"surl\" from lf.sys_layer a left join lf.sys_res b on a.resid = b.id where a.category = 3 and a.is_layer = 1 and a.id in ({0})"; |
| | | |
| | | public ExportUtil() { } |
| | | |
| | | /// <summary> |
| | | /// 生成 |
| | | /// </summary> |
| | |
| | | //.Replace("{date}", args.date) |
| | | .Replace("{date}", DateTime.Now.ToString("yyyy.MM.dd")) |
| | | .Replace("{layers}", args.layers) |
| | | .Replace("{imgPath}", imgPath); |
| | | .Replace("{imgPath}", imgPath) |
| | | .Replace("{wmsUrl}", getWmtsUrl(args)); |
| | | |
| | | File.WriteAllText(qptFile, xml); |
| | | } |
| | |
| | | |
| | | return str; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取WMTS地址,多个以英文逗号隔开 |
| | | /// </summary> |
| | | public static string getWmtsUrl(ExportArgs args) |
| | | { |
| | | List<string> list = new List<string>(); |
| | | foreach (int id in args.layerIds) |
| | | { |
| | | List<string> resList = SelectMapUrls(id); |
| | | if (null != resList && resList.Count > 0) |
| | | { |
| | | list.AddRange(resList); |
| | | } |
| | | } |
| | | |
| | | if (0 == list.Count) |
| | | { |
| | | string defaultUrl = Tools.GetSetting("wmtsUrl"); |
| | | if (!string.IsNullOrEmpty(defaultUrl)) list.Add(defaultUrl); |
| | | } |
| | | |
| | | string wmtsUrl = string.Join(",", list); |
| | | |
| | | return wmtsUrl; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 查询地图Url |
| | | /// </summary> |
| | | public static List<string> SelectMapUrls(int id) |
| | | { |
| | | string sql = string.Format(selectResSql, id); |
| | | DataTable dt = Tools.DBHelper.GetDataTable(sql); |
| | | if (null == dt || 0 == dt.Rows.Count) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | List<SysRes> resList = ModelHandler.FillModel<SysRes>(dt); |
| | | if (null == resList || 0 == resList.Count) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | List<string> list = new List<string>(); |
| | | foreach (SysRes res in resList) |
| | | { |
| | | if (!string.IsNullOrEmpty(res.surl)) |
| | | { |
| | | list.Add(res.surl); |
| | | continue; |
| | | } |
| | | if (!string.IsNullOrEmpty(res.url)) |
| | | { |
| | | list.Add(res.url); |
| | | } |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | } |
| | | } |