Esempio n. 1
0
 public HttpResponseBase EmailGroupStore()
 {
     string json = string.Empty;
     try
     {
         EmailGroup query = new BLL.gigade.Model.EmailGroup();
         query.group_id = 0;
         query.group_name = "無";
         List<EmailGroup> store = new List<EmailGroup>();
         _emailGroupMgr = new EmailGroupMgr(mySqlConnectionString);
         store = _emailGroupMgr.EmailGroupStore();
         store.Insert(0, query);
         json = "{success:true,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 = "{success:false}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
Esempio n. 2
0
 public HttpResponseBase DelEmailGroupList()
 {
     string json = string.Empty;
     EmailGroup query = new EmailGroup();
     List<EmailGroup> list = new List<EmailGroup>();
     try
     {
          _emailGroupMgr =  new EmailGroupMgr(mySqlConnectionString);
         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 EmailGroup();
                         query.group_id =Convert.ToInt32(id);
                         list.Add(query);
                     }
                 }
             }
         }
         json = _emailGroupMgr.DelEmailGroupList(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);
         json = "{success:false}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
Esempio n. 3
0
 public void ExportExcel()
 {
     try
     {
         if (!string.IsNullOrEmpty(Request.Params["group_id"]))
         {
             _emailGroupMgr = new EmailGroupMgr(mySqlConnectionString);
             DataTable _dt = _emailGroupMgr.Export(Convert.ToInt32(Request.Params["group_id"]));
             DataTable _newDt = new DataTable();
             _newDt.Columns.Add("群組代碼", typeof(string));
             _newDt.Columns.Add("電子信箱地址", typeof(string));
             _newDt.Columns.Add("收件人名稱", typeof(string));
             for (int i = 0; i < _dt.Rows.Count; i++)
             {
                 DataRow newRow = _newDt.NewRow();
                 newRow[0] = _dt.Rows[i]["group_id"];
                 newRow[1] = _dt.Rows[i]["email_address"];
                 newRow[2] = _dt.Rows[i]["name"];
                 _newDt.Rows.Add(newRow);
             }
             string fileName = "信箱名單管理匯出" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
             MemoryStream ms = ExcelHelperXhf.ExportDT(_newDt, "");
             Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
             Response.BinaryWrite(ms.ToArray());
         }
     }
     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);
     }
 }
Esempio n. 4
0
 public HttpResponseBase ImportExcel()
 {
     string json = string.Empty;
     string excelPath = "../ImportUserIOExcel/";
     try
     {
         if (Request.Files.Count > 0)
         {
             int group_id = Convert.ToInt32(Request.Params["group_id"]);
             HttpPostedFileBase excelFile = Request.Files["ImportExcel"];
             FileManagement fileManagement = new FileManagement();
             string newExcelName = Server.MapPath(excelPath) + "email_group" + fileManagement.NewFileName(excelFile.FileName);
             excelFile.SaveAs(newExcelName);
             NPOI4ExcelHelper helper = new NPOI4ExcelHelper(newExcelName);
             DataTable _dt = helper.SheetData();
             _emailGroupMgr = new EmailGroupMgr(mySqlConnectionString);
             _newDt.Clear();
             int totalCount = 0;
             _newDt = _emailGroupMgr.ImportEmailList(_dt, group_id, out totalCount);//匯入失敗的數據
             if (_newDt.Rows.Count > 0 && _newDt != null)
             {
                 int totalCountData = totalCount;
                 int wrongCount = _newDt.Rows.Count;
                 json = "{success:true,totalCount:'" + totalCountData + "',wrongCount:'" + wrongCount + "'}";
             }
             else
             {
                 json = "{success:true,wrongCount:'" + 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}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
Esempio n. 5
0
 public HttpResponseBase SaveEmailGroup()
 {
     string json = string.Empty;
     EmailGroup query = new EmailGroup();
     try
     {
         if (!string.IsNullOrEmpty(Request.Params["group_id"]))
         {
             query.group_id = Convert.ToInt32(Request.Params["group_id"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["group_name"]))
         {
             query.group_name = Request.Params["group_name"];
         }
         query.group_create_userid = (Session["caller"] as Caller).user_id;
         query.group_update_userid = (Session["caller"] as Caller).user_id;
         _emailGroupMgr = new EmailGroupMgr(mySqlConnectionString);
         if (_emailGroupMgr.SaveEmailGroup(query))
         {
             json = "{success:true}";
         }
         else
         {
             json = "{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);
         json = "{success:false}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
Esempio n. 6
0
        public HttpResponseBase EmailGroupList()
        {
            string json = string.Empty;

            try
            {
                EmailGroup query = new EmailGroup();
                List<EmailGroup> store = new List<EmailGroup>();
                if (!string.IsNullOrEmpty(Request.Params["group_name"]))
                {
                    query.group_name = Request.Params["group_name"];
                }
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");
                int totalCount = 0;
                _emailGroupMgr = new EmailGroupMgr(mySqlConnectionString);
                store = _emailGroupMgr.EmailGroupList(query, out totalCount);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";
            }
            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,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;

        }
Esempio n. 7
0
 public HttpResponseBase GetTestSendList()
 {
     string json  = string.Empty;
     try
     {
       _emailGroupMgr = new EmailGroupMgr(mySqlConnectionString);
       json=  _emailGroupMgr.GetTestSendList();
     }
     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}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }