Beispiel #1
0
 public HttpResponseBase GetConditionList()
 {
     string json = string.Empty;
     List<EdmListConditionMain> store = new List<EdmListConditionMain>();
     EdmListConditionMain item = new EdmListConditionMain();
 
     _edmlistmainMgr = new EdmListConditionMainMgr(sqlConnectionString);
     try
     {
         store = _edmlistmainMgr.GetConditionList();
         item.elcm_id = 0;
         item.elcm_name = "無";
         //store.Add(item);
         store.Insert(0, item);
       //  store.Insert(0,
         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,data:[]}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
Beispiel #2
0
 public EdmContentNewMgr(string connectionString)
 {
     _edmContentNewDao = new EdmContentNewDao(connectionString);
     _mySql = new MySqlDao(connectionString);
     _emailGroup = new EmailGroupDao(connectionString);
     _edmListConditionMgr = new EdmListConditionMainMgr(connectionString);
 }
Beispiel #3
0
 public HttpResponseBase DeleteListInfo()
 {
     string json = string.Empty;
     _edmlistmainMgr = new EdmListConditionMainMgr(sqlConnectionString);
     EdmListConditionMain query = new EdmListConditionMain();
     try
     {
         if (!string.IsNullOrEmpty(Request.Params["elcm_name"]))
         {
             query.elcm_name = Request.Params["elcm_name"];
         }
         if (query.elcm_name == "無")
         {
             json = "{success:true,msg:1}";
         }
         else
         {
             int i = _edmlistmainMgr.DeleteListInfo(query);
             if (i > 0)
             {
                 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,data:[]}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
Beispiel #4
0
 public HttpResponseBase UpdateCondition() 
 {
     string json = string.Empty;
     _edmlistmainMgr = new EdmListConditionMainMgr(sqlConnectionString);
     _edmlistsubMgr = new EdmListConditoinSubMgr(sqlConnectionString);
     EdmListConditoinSubQuery query = new EdmListConditoinSubQuery();        
     try
     {
         SetQueryValue(query);            
         int i = _edmlistmainMgr.UpdateCondition(query);
         if (i > 0)
         {
             json = "{success: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 = "{success:false}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
Beispiel #5
0
 public HttpResponseBase Export()
 {
     string json = string.Empty;
     EdmListConditoinSubQuery query=new EdmListConditoinSubQuery();
     try
     {
         _edmlistmainMgr = new EdmListConditionMainMgr(sqlConnectionString);
         SetQueryValue(query);
         DataTable _dt = new DataTable();
         string filename = "EDM名單篩選_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv";
         string newFileName = Server.MapPath(excelPath_export + filename);
         DataTable _newdt = new DataTable();
         DataRow dr;
         if (query.MailorPhone == 1)
         {
             _dt = _edmlistmainMgr.GetUserNum(query);
             string[] colName = { "電子信箱,用戶ID" };
             _newdt.Columns.Add("user_email", typeof(string));
             _newdt.Columns.Add("user_id", typeof(string));
             for (int i = 0; i < _dt.Rows.Count; i++)
             {
                 dr = _newdt.NewRow();
                 _newdt.Rows.Add(dr);
                 _newdt.Rows[i]["user_email"] = _dt.Rows[i]["user_email"];
                 _newdt.Rows[i]["user_id"] = _dt.Rows[i]["user_id"];
             }
             CsvHelper.ExportDataTableToCsv(_newdt, newFileName, colName, true);
             json = "{success:true,fileName:\'" + filename + "\'}";
         }
         else
         {
             _dt = _edmlistmainMgr.GetUserNum(query);
             string[] colName = { "手機號碼,用戶ID" };
             _newdt.Columns.Add("user_mobile", typeof(string));
             _newdt.Columns.Add("user_id", typeof(string));             
             for (int i = 0; i < _dt.Rows.Count; i++)
             {
                 dr = _newdt.NewRow();
                 _newdt.Rows.Add(dr);
                 _newdt.Rows[i]["user_mobile"] = _dt.Rows[i]["user_mobile"];
                 _newdt.Rows[i]["user_id"] = _dt.Rows[i]["user_id"];                                     
             }
             CsvHelper.ExportDataTableToCsv(_newdt, newFileName, colName, true);
             json = "{success:true,fileName:\'" + filename + "\'}";
         }             
     }
     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;
 }
Beispiel #6
0
 public HttpResponseBase GetUserNum()
 {
     string json = string.Empty;
     DataTable store = new DataTable();
     int totalCount = 0;
     _edmlistmainMgr = new EdmListConditionMainMgr(sqlConnectionString);
     EdmListConditoinSubQuery query = new EdmListConditoinSubQuery();
     try
     {
         SetQueryValue(query);
         store = _edmlistmainMgr.GetUserNum(query);
         if (store != null && store.Rows.Count > 0)
         {
             totalCount = store.Rows.Count;
         }
         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 = "{success:false,data:[]}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
Beispiel #7
0
 public HttpResponseBase SaveListInfo()
 {
     string json = string.Empty;
     _edmlistmainMgr = new EdmListConditionMainMgr(sqlConnectionString);
     _edmlistsubMgr = new EdmListConditoinSubMgr(sqlConnectionString);
     EdmListConditoinSubQuery query = new EdmListConditoinSubQuery();
     int id = 0;
     int msg = 0;
     try
     {
         SetQueryValue(query);
         query.elcm_creator_id = Convert.ToInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
         int i = _edmlistmainMgr.SaveListInfoName(query, out id, out msg);
         if (i > 0)
         {
             query.elcm_id = id;
             _edmlistsubMgr.SaveListInfoCondition(query);
             json = "{success:true}";
         }
         else if (msg == 1)
         {
             json = "{success:false,msg:1}"; //篩選條件名稱已存在
         }
         else
         {
             json = "{success:false,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}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }