コード例 #1
0
 public HttpResponseBase Load()
 {
     string json = string.Empty;
     if (!string.IsNullOrEmpty(Request.Params["content_id"]))
     {
         if (!string.IsNullOrEmpty(Request.Params["log_id"]))
         {
             int log_id = Convert.ToInt32(Request.Params["log_id"]);
             string openAveragePrecent = "0";
             string openAverageCount = "0";
             int content_id = Convert.ToInt32(Request.Params["content_id"]);
             List<EdmContentNew> store = new List<BLL.gigade.Model.EdmContentNew>();
             EdmContentNew query = new BLL.gigade.Model.EdmContentNew();
             EdmContentNew newQuery = new BLL.gigade.Model.EdmContentNew();
             _edmContentNewMgr = new EdmContentNewMgr(mySqlConnectionString);
             query.content_id = content_id;
             int count = 0;
             int successCount = 0;
             int failCount = 0;
             int totalPersonCount = 0;
             int totalCount = 0;
             //電子報主旨和發送時間
             newQuery = _edmContentNewMgr.GetECNList(query, out count).FirstOrDefault();
             string subject = newQuery.subject;
              string date=string.Empty;
           DataTable _dt=_edmContentNewMgr.GetScheduleDate(content_id, log_id);
           if (_dt != null && _dt.Rows.Count > 0)
           {
               date = Convert.ToDateTime(_dt.Rows[0][0].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
               //發信成功人數
               if (DateTime.Now > Convert.ToDateTime(date))
               {
                   successCount = _edmContentNewMgr.GetSendMailSCount(content_id, log_id);
                   //發信失敗人數
                   failCount = _edmContentNewMgr.GetSendMailFCount(content_id, log_id);
                   //總開信人數
                   totalPersonCount = _edmContentNewMgr.GetSendMailCount(content_id, log_id);
                   //開總信次數
                   totalCount = _edmContentNewMgr.GetSendCount(content_id, log_id);
                   //開信率
                   if (successCount == 0)
                   {
                       openAveragePrecent = "0";
                   }
                   else
                   {
                       openAveragePrecent = Math.Round((double)totalPersonCount / successCount * 100, 2) + "%";
                   }
                   //平均開信次數
                   if (totalPersonCount == 0)
                   {
                       openAverageCount = "0";
                   }
                   else
                   {
                       openAverageCount = Math.Round((double)totalCount / totalPersonCount, 2).ToString();
                   }
               }
           }
             json = "{success:true,successCount:'" + successCount + "',failCount:'" + failCount + "',totalPersonCount:'" + totalPersonCount + "',totalCount:'" + totalCount + "',openAveragePrecent:'" + openAveragePrecent + "',openAverageCount:'" + openAverageCount + "',subject:'" + subject + "',date:'" + date + "'}";
         }
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }