Ejemplo n.º 1
0
        /// <summary>
        /// 用戶管理列表頁
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase MailUserList()
        {
            string jsonStr = string.Empty;

            try
            {
                List<MailUserQuery> MailUserStore = new List<MailUserQuery>();
                MailUserQuery query = new MailUserQuery();
                if (!string.IsNullOrEmpty(Request.Params["user_name"]))
                {
                    query.user_name = Request.Params["user_name"];
                }
                if (!string.IsNullOrEmpty(Request.Params["user_mail"]))
                {
                    query.user_mail = Request.Params["user_mail"];
                }

                if (!string.IsNullOrEmpty(Request.Params["relation_id"]))//待回覆
                {
                    query.row_id = Convert.ToInt32(Request.Params["relation_id"]);
                }
                List<ManageUserQuery> ManageUseStore = new List<ManageUserQuery>();
                ManageUserQuery ManageUserQuery = new ManageUserQuery();
                ManageUserQuery.IsPage = false;
                #region 查詢管理人員綁定到表中
                DataTable _dtManageUser = new DataTable();
                _dtManageUser.Columns.Add("user_id", typeof(String));
                _dtManageUser.Columns.Add("user_name", typeof(String));
                int total = 0;
                _IManageUserMgr = new ManageUserMgr(mySqlConnectionString);
                ManageUseStore = _IManageUserMgr.GetNameMail(ManageUserQuery, out total);
                foreach (var item in ManageUseStore)
                {
                    DataRow dr = _dtManageUser.NewRow();
                    dr[0] = item.user_id;
                    dr[1] = item.user_name;
                    _dtManageUser.Rows.Add(dr);
                }
                #endregion


                if (!string.IsNullOrEmpty(Request.Params["pagers"]))
                {
                    if (Convert.ToInt32(Request.Params["pagers"]) == 0)
                    {
                        query.IsPage = false;
                    }
                }
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
                _IMailUserMgr = new MailUserMgr(mySqlConnectionString);

                int totalCount = 0;
                MailUserStore = _IMailUserMgr.GetMailUserStore(query, out totalCount);//查询出供應商出貨單
                foreach (var item in MailUserStore)
                {
                    item.nameemail = item.user_name + "(" + item.user_mail + ")";
                    DataRow[] rows = _dtManageUser.Select("user_id='" + item.create_user + "'");
                    foreach (DataRow row in rows)//篩選出的最多只有一條數據,
                    {
                        item.create_user_name = item.create_user.ToString();
                        if (!string.IsNullOrEmpty(row["user_id"].ToString()))
                        {
                            item.create_user_name = row["user_name"].ToString();//---創建人
                        }
                    }
                    rows = _dtManageUser.Select("user_id='" + item.update_user + "'");
                    foreach (DataRow row in rows)//篩選出的最多只有一條數據,
                    {
                        item.update_user_name = item.update_user.ToString();
                        if (!string.IsNullOrEmpty(row["user_id"].ToString()))
                        {
                            item.update_user_name = row["user_name"].ToString();//---修改人
                        }
                    }
                    if (Convert.ToBoolean(Request.Params["isSecret"]))
                    {

                        if (!string.IsNullOrEmpty(item.user_name))
                        {
                            item.user_name = item.user_name.Substring(0, 1) + "**";
                        }
                        item.user_mail = item.user_mail.Split('@')[0] + "@***";

                        if (item.nameemail.ToString().Length > 3)
                        {
                            item.nameemail = item.nameemail.Substring(0, 3) + "***";
                        }
                        else
                        {
                            item.nameemail = item.nameemail + "***";
                        }
                    }
                }

                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                jsonStr = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(MailUserStore, Formatting.Indented, timeConverter) + "}";//返回json數據
            }
            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);
                jsonStr = "{success:false,msg:0}";
            }
            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 刪除用戶信息
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase DeleteMailUser()
        {
            MailUserQuery query = new MailUserQuery();
            string json = string.Empty;
            try
            {

                if (!string.IsNullOrEmpty(Request.Params["rowId"]))
                {
                    string Row_id = Request.Params["rowId"];
                    Row_id = Row_id.TrimEnd(',');
                    query.row_id_in = Row_id;
                }
                _IMailUserMgr = new MailUserMgr(mySqlConnectionString);
                int result = _IMailUserMgr.DeleteMailUser(query);
                if (result > 0)
                {
                    json = "{success:true,msg:\"" + result + "\"}";
                }
                else
                {
                    json = "{success:false,msg:\"" + result + "\"}";
                }
            }
            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:false,msg:'0'}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;

        }
Ejemplo n.º 3
0
        /// <summary>
        /// 修改狀態
        /// </summary>
        /// <returns></returns>
        public JsonResult UpdateActive()
        {
            string jsonStr = string.Empty;
            try
            {
                MailUserQuery query = new MailUserQuery();
                if (!string.IsNullOrEmpty(Request.Params["active"]))
                {
                    query.status = Convert.ToInt32(Request.Params["active"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["id"]))
                {
                    query.row_id = Convert.ToInt32(Request.Params["id"]);
                }
                query.update_user = (Session["caller"] as Caller).user_id;
                query.update_time = DateTime.Now;
                _IMailUserMgr = new MailUserMgr(mySqlConnectionString);

                if (_IMailUserMgr.UpdateMailUserStatus(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" });
            }

        }
Ejemplo n.º 4
0
 /// <summary>
 /// 修改或者保存用戶信息
 /// </summary>
 /// <returns></returns>
 public HttpResponseBase SaveMailUser()
 {
     MailUserQuery query = new MailUserQuery();
     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["user_name"]))
         {
             query.user_name = Request.Params["user_name"];
         }
         if (!string.IsNullOrEmpty(Request.Params["user_mail"]))
         {
             query.user_mail = Request.Params["user_mail"];
         }
         if (!string.IsNullOrEmpty(Request.Params["user_pwd"]))
         {
             query.user_pwd = Request.Params["user_pwd"];
         }
         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;
         _IMailUserMgr = new MailUserMgr(mySqlConnectionString);
         int result = _IMailUserMgr.SaveMailUser(query);
         if (result > 0)
         {
             json = "{success:true,msg:\"" + result + "\"}";
         }
         else
         {
             json = "{success:true,msg:\"" + result + "\"}";
         }
         //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 = "{success:false,msg:'0'}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }