public CMCResponse Add(CMCRequest req) { string msg = ""; UserInfo user = UserFactory.Instance.SearchUser(this.UserName); bool isAdmin = false; if (user.UserType == UserType.Administrator) { isAdmin = true; } try { SystemFactory.Instance.Add(req.Data, isAdmin); } catch (Exception ex) { if (ex.Message.Split(':')[0] == "ORA-00001") { throw new Exception("请不要插入重复的 AppID!"); } else if (ex.Message.Contains("违反了 PRIMARY KEY 约束")) { throw new Exception("请不要插入重复的 AppID!"); } else { throw new Exception("新增APP失败" + ex.Message); } } Response.message = msg; Log("{\"LogMenu\":\"系统管理\",\"LogAction\":\"添加应用程序\"}", this.UserName, this.IP); return(Response); }
//更新应用 public CMCResponse Update(CMCRequest req) { AppSettingInfo info = JsonConvert.DeserializeObject <AppSettingInfo>(req.Data); SystemFactory.Instance.Update(info); Log("{\"LogMenu\":\"系统管理\",\"LogAction\":\"修改应用程序[" + info.AppSettingID + "]\"}", this.UserName, this.IP); return(Response); }