1
wangsheng
2022-03-22 49d5052a4a51a639d1c75d6feca56f8ae2e5e568
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<%@ WebHandler Language="C#" Class="SettingHandler" %>
 
using Common;
using Dao;
using Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Text.RegularExpressions;
 
public class SettingHandler : PageHandler<SysUser>
{
  public override JsonPageResult ProcessRequestInternal(PageContext<SysUser> context)
  {
    string @string = context.GetString("action");
    switch (@string)
    {
      case "save":
        return this.Save(context);
      default:
        throw new Exception("Invalid Action=" + @string);
    }
  }
 
  private JsonPageResult Save(PageContext<SysUser> context)
  {
    context.CheckRight("1071", FailedOperation.PromptOnly);
    string string1 = context.GetString("wxProfile");
    string string2 = context.GetString("smtpProfile");
    string string3 = context.GetString("smsProfile");
    string string4 = context.GetString("cmSegments");
    string string5 = context.GetString("cuSegments");
    string string6 = context.GetString("ctSegments");
    string string7 = context.GetString("gwName");
    string string8 = context.GetString("blackMoContent");
    if (JsonConvert.DeserializeObject<JToken>(string1) == null)
      throw new ArgumentException("WxProfile数据异常");
    if (JsonConvert.DeserializeObject<JToken>(string2) == null)
      throw new ArgumentException("SmtpProfile数据异常");
    if (JsonConvert.DeserializeObject<JToken>(string3) == null)
      throw new ArgumentException("SmsProfile数据异常");
    if (!Regex.IsMatch(string8, "^([\\u4e00-\\u9fa5]|[a-zA-Z0-9]|[*;])+$") && !string.IsNullOrEmpty(string8))
      throw new ArgumentException("多个上行内容之间用英文分号\" ; \"分割,内容中可以使用通配符\" * \",每个 * 号代表0-10个字符!");
    using (GwSettingDao gwSettingDao = new GwSettingDao())
      gwSettingDao.Update(string1, string2, string3, string4, string5, string6, string7, string8);
    Const.CurrentSetting.GwName = string7;
    return new JsonPageResult(true, (object) "系统参数保存成功!");
  }
}