public HttpResponseBase AddCallid() { List<MailGroupMapQuery> list = new List<MailGroupMapQuery>(); MailGroupMapQuery query = new MailGroupMapQuery(); string json = string.Empty; _IMailGroupMgr = new MailGroupMgr(mySqlConnectionString); try { if (!string.IsNullOrEmpty(Request.Form["groupId"])) { query.group_id = Int32.Parse(Request.Form["groupId"]); } if (!string.IsNullOrEmpty(Request.Form["callid"])) { string[] callid = Request.Form["callid"].IndexOf(",") != -1 ? Request.Form["callid"].Split(',') : new string[] { Request.Form["callid"] }; _IMailGroupMgr.DeleteMailMap(query.group_id); for (int i = 0; i < callid.Length; i++) { query = new MailGroupMapQuery(); query.group_id = Int32.Parse(Request.Form["groupId"]); query.user_id = Convert.ToInt32(callid[i]); query.create_time = DateTime.Now; query.update_time = query.create_time; query.create_user = (Session["caller"] as Caller).user_id; query.update_user = (Session["caller"] as Caller).user_id; query.status = _IMailGroupMgr.GetStatus(query.user_id); list.Add(query); } if (_IMailGroupMgr.SaveMailMap(list)) { json = "{success:true,msg:\"新增成功\"}"; } else { json = "{success:true,msg:\"新增失败\"}"; } } else { if (_IMailGroupMgr.DeleteMailMap(query.group_id) > 0) { json = "{success:true,msg:\"人员已清空\"}"; } else { json = "{success:true,msg:\"人员已清空\"}"; } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:true,msg:\"新增失败\"}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
//add by wwei0216w 2015/4/9 public HttpResponseBase GetMemberInfo() { string json = ""; MailGroupMapQuery query = new MailGroupMapQuery(); try { if (!string.IsNullOrEmpty(Request.Form["rowId"])) { query.group_id = Convert.ToInt32(Request.Form["rowId"]); query.status = 1; _IMailGroupMgr = new MailGroupMgr(mySqlConnectionString); var list = _IMailGroupMgr.QueryUserInfo(query); //StringBuilder sb = new StringBuilder("["); //sb.Append("{rowId:" + query.group_id + ",groupName:\"" + list[0].group_name + "\",item:["); //foreach(MailGroupMapQuery mm in list) //{ // sb.Append("{user_name:\"" + mm.user_mail + "\",row_id:" + mm.row_id + "}"); //} //sb.Append("]}"); //sb.Append("]"); //json = sb.ToString().Replace("}{", "},{"); json = "{items:" + JsonConvert.SerializeObject(list) + "}"; } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public string QueryUserById() { string json = string.Empty; MailGroupMapQuery query = new MailGroupMapQuery(); try { if (!string.IsNullOrEmpty(Request.Form["groupId"])) { query.group_id = Convert.ToInt32(Request.Form["groupId"]); } query.status = 1; _IMailGroupMgr = new MailGroupMgr(mySqlConnectionString); json = _IMailGroupMgr.QueryUserById(query); } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "[]"; } return json; }
public JsonResult UpMailGroupStatus() { string json = string.Empty; try { MailGroupQuery query = new MailGroupQuery(); if (!string.IsNullOrEmpty(Request.Params["id"])) { query.row_id = Convert.ToInt32(Request.Params["id"]); } if (!string.IsNullOrEmpty(Request.Params["active"])) { query.status = Convert.ToInt32(Request.Params["active"]); } query.update_time = DateTime.Now; query.update_user = (Session["caller"] as Caller).user_id; _IMailGroupMgr = new MailGroupMgr(mySqlConnectionString); if (_IMailGroupMgr.UpMailGroupStatus(query) > 0) { return Json(new { success = "true" }); } else { return Json(new { success = "false" }); } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); return Json(new { success = "false" }); } }
public HttpResponseBase DeleteMailGroup() { string json = string.Empty; MailGroupQuery query = null; _IMailGroupMgr = new MailGroupMgr(mySqlConnectionString); List<MailGroupQuery> list = new List<MailGroupQuery>(); try { if (!string.IsNullOrEmpty(Request.Form["rowID"])) { string rowIDs = Request.Form["rowID"]; if (rowIDs.IndexOf("|") != -1) { foreach (string id in rowIDs.Split('|')) { if (!string.IsNullOrEmpty(id)) { query = new MailGroupQuery(); query.row_id = Convert.ToInt32(id); list.Add(query); } } } if (_IMailGroupMgr.DeleteMailGroup(list)) { json = "{success:true}"; } else { json = "{failure:true}"; } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{failure:true}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase SaveMailGroup() { MailGroupQuery query = new MailGroupQuery(); string json = string.Empty; try { if (!string.IsNullOrEmpty(Request.Params["row_id"])) { query.row_id = Convert.ToInt32(Request.Params["row_id"]); } if (!string.IsNullOrEmpty(Request.Params["groupName"])) { query.group_name = Request.Params["groupName"]; } if (!string.IsNullOrEmpty(Request.Params["groupCode"])) { query.group_code = Request.Params["groupCode"]; } if (!string.IsNullOrEmpty(Request.Params["remark"])) { query.remark = Request.Params["remark"]; } query.create_time = DateTime.Now; query.update_time = query.create_time; query.create_user = (Session["caller"] as Caller).user_id; query.update_user = (Session["caller"] as Caller).user_id; query.status = 1; _IMailGroupMgr = new MailGroupMgr(mySqlConnectionString); int result = _IMailGroupMgr.SaveMailGroup(query); if (result > 0) { json = "{success:true}"; } else if (result == -1)//羣組或編碼重複 { json = "{failure:true,msg:'-1'}"; } else { json = "{failure:true,msg:'0'}"; } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{failure:true,msg:'0'}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase MailGroupList() { string json = string.Empty; MailGroupQuery query = new MailGroupQuery(); if (!string.IsNullOrEmpty(Request["isPage"])) query.IsPage = bool.Parse(Request["isPage"]); List<MailGroupQuery> store = new List<MailGroupQuery>(); _IMailGroupMgr = new MailGroupMgr(mySqlConnectionString); int totalCount = 0; try { query.status = 1; query.Start = Convert.ToInt32(Request.Params["start"] ?? "0"); query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25"); store = _IMailGroupMgr.MailGroupList(query, out totalCount); json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented) + "}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{failure:true}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }