|
@@ -22,6 +22,7 @@ using XdCxRhDW.WebApi;
|
|
|
using DevExpress.XtraPrinting;
|
|
|
using XdCxRhDW.Entity;
|
|
|
using DevExpress.XtraEditors.Controls;
|
|
|
+using System.Security.Policy;
|
|
|
|
|
|
namespace XdCxRhDW.App.UserControl
|
|
|
{
|
|
@@ -72,92 +73,62 @@ namespace XdCxRhDW.App.UserControl
|
|
|
bool needStartHttpSvr = false;
|
|
|
try
|
|
|
{
|
|
|
+ if (!int.TryParse(txtHttpPort.Text, out int port))
|
|
|
+ {
|
|
|
+ DxHelper.MsgBoxHelper.ShowError("Http端口错误!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (txtMapType.SelectedIndex != 0 && txtWMSType.EditValue == null)
|
|
|
{
|
|
|
- DxHelper.MsgBoxHelper.ShowInfo("请选择行政图类型!");
|
|
|
+ DxHelper.MsgBoxHelper.ShowError("请选择行政图类型!");
|
|
|
return;
|
|
|
}
|
|
|
if (txtMapType.SelectedIndex != 0 && string.IsNullOrEmpty(txtLayer.Text))
|
|
|
{
|
|
|
- DxHelper.MsgBoxHelper.ShowInfo("请填写地图图层名称!");
|
|
|
+ DxHelper.MsgBoxHelper.ShowError("请填写地图图层名称!");
|
|
|
return;
|
|
|
}
|
|
|
using (RHDWContext db = new RHDWContext())
|
|
|
{
|
|
|
var res = await db.SysSetings.FirstOrDefaultAsync();
|
|
|
- if (res == null)
|
|
|
+ if (res == null) res = new SysSetings();
|
|
|
+ res.HttpPort = port;
|
|
|
+ res.XLDirectory = txtXLDirectory.Text;
|
|
|
+ res.YDPZThreshold = string.IsNullOrWhiteSpace(txtYDPZThreshold.Text) ? 0 : Convert.ToInt32(txtYDPZThreshold.Text);
|
|
|
+ res.MapType = txtMapType.SelectedIndex;
|
|
|
+ if (txtMapType.SelectedIndex != 0)
|
|
|
{
|
|
|
- SysSetings resNull = new SysSetings();
|
|
|
- resNull.HttpPort = Convert.ToInt32(txtHttpPort.Text);
|
|
|
- resNull.XLDirectory = txtXLDirectory.Text;
|
|
|
- resNull.YDPZThreshold = string.IsNullOrWhiteSpace(txtYDPZThreshold.Text) ? 0 : Convert.ToInt32(txtYDPZThreshold.Text);
|
|
|
- resNull.MapType = txtMapType.SelectedIndex;
|
|
|
- //if (txtMapType.SelectedIndex == 0)
|
|
|
- //{
|
|
|
- // resNull.WMSType = null;
|
|
|
- // resNull.ZKXT_Url = null;
|
|
|
- // resNull.ZKXT_LayerName = null;
|
|
|
- // resNull.SJZX_Url = null;
|
|
|
- // resNull.SJZX_LayerName = null;
|
|
|
- // resNull.LW_Url = null;
|
|
|
- // resNull.LW_LayerName = null;
|
|
|
- //}
|
|
|
- if (txtMapType.SelectedIndex != 0)
|
|
|
+ res.WMSType = (EnumWmsType)txtWMSType.EditValue;
|
|
|
+ Uri url = null;
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ url = new Uri(txtUrl.Text);
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ DxHelper.MsgBoxHelper.ShowError("URL格式错误!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (res.WMSType == EnumWmsType.ZKXT)
|
|
|
{
|
|
|
- resNull.WMSType = (EnumWmsType)txtWMSType.EditValue;
|
|
|
- if (resNull.WMSType == EnumWmsType.ZKXT)
|
|
|
- {
|
|
|
- resNull.ZKXT_Url = txtUrl.Text;
|
|
|
- resNull.ZKXT_LayerName = txtLayer.Text;
|
|
|
- }
|
|
|
- else if (resNull.WMSType == EnumWmsType.SJZX)
|
|
|
- {
|
|
|
- resNull.SJZX_Url = txtUrl.Text;
|
|
|
- resNull.SJZX_LayerName = txtLayer.Text;
|
|
|
- }
|
|
|
- else if (resNull.WMSType == EnumWmsType.LW)
|
|
|
- {
|
|
|
- resNull.LW_Url = txtUrl.Text;
|
|
|
- resNull.LW_LayerName = txtLayer.Text;
|
|
|
- }
|
|
|
+ res.ZKXT_Url = url.ToString();
|
|
|
+ res.ZKXT_LayerName = txtLayer.Text;
|
|
|
}
|
|
|
+ else if (res.WMSType == EnumWmsType.SJZX)
|
|
|
+ {
|
|
|
|
|
|
- db.SysSetings.Add(resNull);
|
|
|
- needStartHttpSvr = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- needStartHttpSvr = res.HttpPort != Convert.ToInt32(txtHttpPort.Text);
|
|
|
- res.HttpPort = Convert.ToInt32(txtHttpPort.Text);
|
|
|
- res.XLDirectory = txtXLDirectory.Text;
|
|
|
- res.YDPZThreshold = string.IsNullOrWhiteSpace(txtYDPZThreshold.Text) ? 0 : Convert.ToInt32(txtYDPZThreshold.Text);
|
|
|
- res.MapType = txtMapType.SelectedIndex;
|
|
|
- //if (txtMapType.SelectedIndex == 0)
|
|
|
- //{
|
|
|
- // res.WMSType = EnumWmsType.LW;
|
|
|
- // res.LayerName = null;
|
|
|
- //}
|
|
|
- if (txtMapType.SelectedIndex != 0)
|
|
|
+ res.SJZX_Url = url.ToString();
|
|
|
+ res.SJZX_LayerName = txtLayer.Text;
|
|
|
+ }
|
|
|
+ else if (res.WMSType == EnumWmsType.LW)
|
|
|
{
|
|
|
- res.WMSType = (EnumWmsType)txtWMSType.EditValue;
|
|
|
- if (res.WMSType == EnumWmsType.ZKXT)
|
|
|
- {
|
|
|
- res.ZKXT_Url = txtUrl.Text;
|
|
|
- res.ZKXT_LayerName = txtLayer.Text;
|
|
|
- }
|
|
|
- else if (res.WMSType == EnumWmsType.SJZX)
|
|
|
- {
|
|
|
- res.SJZX_Url = txtUrl.Text;
|
|
|
- res.SJZX_LayerName = txtLayer.Text;
|
|
|
- }
|
|
|
- else if (res.WMSType == EnumWmsType.LW)
|
|
|
- {
|
|
|
- res.LW_Url = txtUrl.Text;
|
|
|
- res.LW_LayerName = txtLayer.Text;
|
|
|
- }
|
|
|
+ res.LW_Url = url.ToString();
|
|
|
+ res.LW_LayerName = txtLayer.Text;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ db.SysSetings.AddOrUpdate(res);
|
|
|
+ needStartHttpSvr = true;
|
|
|
await db.SaveChangesAsync();
|
|
|
DxHelper.MsgBoxHelper.ShowInfo("配置信息保存成功!");
|
|
|
Messenger.Defalut.Pub("系统配置改变", await db.SysSetings.FirstOrDefaultAsync());
|