コード例 #1
0
 //電子報
 public ActionResult EdmContentNew()
 {
     _edmContentNewMgr = new EdmContentNewMgr(mySqlConnectionString);
     DataTable _dt = _edmContentNewMgr.GetPraraData(3);
     if (_dt != null && _dt.Rows.Count > 0)
     {
         ViewBag.split_str = _dt.Rows[0][0].ToString();
     }
     else
     {
         ViewBag.split_str = "  ";
     }
     ViewBag.path = ConfigurationManager.AppSettings["webDavImage"];
     ViewBag.BaseAddress = ConfigurationManager.AppSettings["webDavBaseAddress"];
     ViewBag.subscribe = subscribe;
     ViewBag.subscribe_url = subscribe_url;
     return View();
 }
コード例 #2
0
        public bool SendEMail()
        {
            string json = string.Empty;

            try
            {
                #region
                string schedule_code = "send mail";//Request.Params["schedule_code"].ToString();
                MailModel mailModel = new MailModel();
                mailModel.MysqlConnectionString = mySqlConnectionString;
                string GroupCode = string.Empty;
                string MailTitle = string.Empty;
                string MailBody = string.Empty;
                bool IsSeparate = false;
                bool IsDisplyName = true;
                ScheduleServiceMgr _secheduleServiceMgr;
                List<MailRequest> MR = new List<MailRequest>();
                MailRequest model = new MailRequest();
                List<ScheduleConfigQuery> store_config = new List<ScheduleConfigQuery>();
                ScheduleConfigQuery query_config = new ScheduleConfigQuery();

                query_config.schedule_code = schedule_code;
                _secheduleServiceMgr = new ScheduleServiceMgr(mySqlConnectionString);
                store_config = _secheduleServiceMgr.GetScheduleConfig(query_config);
                foreach (ScheduleConfigQuery item in store_config)
                {
                    if (item.parameterCode.Equals("MailFromAddress"))
                    {
                        mailModel.MailFromAddress = item.value;
                    }
                    else if (item.parameterCode.Equals("MailHost"))
                    {
                        mailModel.MailHost = item.value;
                    }
                    else if (item.parameterCode.Equals("MailPort"))
                    {
                        mailModel.MailPort = item.value;
                    }
                    else if (item.parameterCode.Equals("MailFromUser"))
                    {
                        mailModel.MailFromUser = item.value;
                    }
                    else if (item.parameterCode.Equals("EmailPassWord"))
                    {
                        mailModel.MailFormPwd = item.value;
                    }
                    else if (item.parameterCode.Equals("GroupCode"))
                    {
                        GroupCode = item.value;
                    }
                    else if (item.parameterCode.Equals("MailTitle"))
                    {
                        MailTitle = item.value;
                    }
                    else if (item.parameterCode.Equals("MailTitle"))
                    {
                        MailTitle = item.value;
                    }
                    else if (item.parameterCode.Equals("MailBody"))
                    {
                        MailBody = item.value;
                    }
                    else if (item.parameterCode.Equals("IsSeparate"))
                    {
                        if (item.value.ToString().Trim().ToLower() == "false")
                        {
                            IsSeparate = false;
                        }
                        else if (item.value.ToString().Trim().ToLower() == "true")
                        {
                            IsSeparate = true;
                        }
                    }
                    else if (item.parameterCode.Equals("IsDisplyName"))
                    {
                        if (item.value.ToString().Trim().ToLower() == "false")
                        {
                            IsDisplyName = false;
                        }
                        else if (item.value.ToString().Trim().ToLower() == "true")
                        {
                            IsDisplyName = true;
                        }
                    }
                    else if (!string.IsNullOrEmpty(Request.Params["IsDisplyName"]))
                    {
                        if (Request.Params["IsDisplyName"].ToString().Trim().ToLower() == "false")
                        {
                            IsSeparate = false;
                        }
                        else if (Request.Params["IsDisplyName"].ToString().Trim().ToLower() == "true")
                        {
                            IsSeparate = true;
                        }
                    }
                }
                MailHelper mail = new MailHelper(mailModel);
                _edmcontentMgr = new EdmContentNewMgr(mySqlConnectionString);
                _edmcontentMgr.SendEMail(mail);

                #endregion
            }
            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}";
            }
            return true;
        }
コード例 #3
0
        /*
         編輯的預覽按鈕和列表頁的預覽都訪問這個方法
         * 1.
         * 
         */
        public HttpResponseBase GetPreviewHtml()
        {
            string html = string.Empty;
            string replaceStr = string.Empty;
            string contentStr = string.Empty;
            string templateStr = string.Empty;
            string recommendStr = string.Empty;
            string previewStr = string.Empty;
            string editStr = string.Empty;
            try
            {
                _edmContentNewMgr = new EdmContentNewMgr(mySqlConnectionString);
                EdmContentNew query = new EdmContentNew();

                //將傳過來的html加上根據當前登入者的id獲得的推薦html替換掉content_url中的替換符
                if (!string.IsNullOrEmpty(Request.Params["content_id"]))
                {
                    query.content_id = Convert.ToInt32(Request.Params["content_id"]);
                    string content_url = _edmContentNewMgr.GetContentUrlByContentId(query.content_id);
                    if (!string.IsNullOrEmpty(content_url))
                    {
                        #region 獲取網頁內容
                        HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(content_url);
                        httpRequest.Timeout = 9000;
                        httpRequest.Method = "GET";
                        HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse();
                        StreamReader sr = new StreamReader(httpResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("UTF-8"));
                        contentStr = sr.ReadToEnd();
                        #endregion
                    }
                    else
                    {
                        contentStr = "";
                    }
                    
                }
                //列表頁的預覽按鈕不進這個方法
                if (!string.IsNullOrEmpty(Request.Params["template_id"]))
                {
                    query.template_id = Convert.ToInt32(Request.Params["template_id"]);
                    edmtemplatemgr = new EdmTemplateMgr(mySqlConnectionString);
                    if (edmtemplatemgr.GetStaticTemplate(query.template_id))
                    {
                        recommendStr = string.Empty;
                    }
                    else
                    {
                        recommendStr = _edmContentNewMgr.GetRecommendHtml(Convert.ToUInt32((Session["caller"] as Caller).user_id));
                    }
                }
                //獲取template_data(編輯器中的內容或者是表中的template_data)
                if (!string.IsNullOrEmpty(Request.Params["template_data"]))
                {
                    templateStr = Request.Params["template_data"];
                }
                else
                {
                    templateStr = _edmContentNewMgr.GetHtml(query);
                }
                //編輯的預覽按鈕不進這個方法
                //根據user_id獲得精準推薦
                if (!string.IsNullOrEmpty(Request.Params["static_template"]))
                {
                    if (Request.Params["static_template"] == "0")// 動態範本,精準推薦
                    {
                        recommendStr = _edmContentNewMgr.GetRecommendHtml(Convert.ToUInt32((Session["caller"] as Caller).user_id));
                    }
                    else
                    {
                        recommendStr = string.Empty;
                    }
                }
             
                //替換符
                DataTable _dt = _edmContentNewMgr.GetPraraData(1);
                if (_dt != null && _dt.Rows.Count > 0)
                {
                    replaceStr = _dt.Rows[0][0].ToString();
                }
                else
                {
                    replaceStr = "&nbsp;&nbsp;";
                }
                //分隔符
                DataTable _dtEdit = _edmContentNewMgr.GetPraraData(3);
                if (_dtEdit != null && _dtEdit.Rows.Count > 0)
                {
                    editStr = _dtEdit.Rows[0][0].ToString();
                }
                else
                {
                    editStr = "&nbsp;&nbsp;";
                }
                    templateStr = templateStr.Replace(editStr,"") + recommendStr;
                    if (Request.Params["checked"] == "true")
                    {
                        if (!string.IsNullOrEmpty(contentStr))
                        {
                            previewStr = contentStr.Replace(replaceStr, templateStr) + subscribe_url;
                        }
                        else
                        {
                            previewStr = templateStr + subscribe_url;
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(contentStr))
                        {
                            previewStr = contentStr.Replace(replaceStr, templateStr);
                        }
                        else
                        {
                            previewStr = templateStr;
                        }
                         
                    }

            }
            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);
                previewStr = "";
            }
            this.Response.Clear();
            this.Response.Write(previewStr);
            this.Response.End();
            return this.Response;

        }
コード例 #4
0
        /*public HttpResponseBase GetContentUrl()
        {
            string json = string.Empty;
            string template_data = string.Empty;
            string contentJson = string.Empty;
            string replaceStr = string.Empty;
            string editStr = string.Empty;
            try
            {
                _edmContentNewMgr = new EdmContentNewMgr(mySqlConnectionString);
                if (!string.IsNullOrEmpty(Request.Params["content_url"]))
                {
                    #region 獲取網頁內容方法
                    string url = Request.Params["content_url"].ToString();
                    HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(url);
                    httpRequest.Timeout = 9000;
                    httpRequest.Method = "GET";
                    HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse();
                    StreamReader sr = new StreamReader(httpResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("UTF-8"));
                    contentJson = sr.ReadToEnd();
                    #endregion
                }
                else
                {
                    int template_id = Convert.ToInt32(Request.Params["template_id"]);
                    string url = _edmContentNewMgr.GetContentUrl(template_id);
                    HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(url);
                    httpRequest.Timeout = 9000;
                    httpRequest.Method = "GET";
                    HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse();
                    StreamReader sr = new StreamReader(httpResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("UTF-8"));
                    contentJson = sr.ReadToEnd();
                }
                if (!string.IsNullOrEmpty(Request.Params["template_data"]))
                {
                    template_data = Request.Params["template_data"];
                }

                DataTable _dt = _edmContentNewMgr.GetPraraData(1);
                if (_dt != null && _dt.Rows.Count > 0)
                {
                    replaceStr = _dt.Rows[0][0].ToString();
                }
                else
                {
                    replaceStr = "&nbsp;&nbsp;";
                }
                DataTable _dtEdit = _edmContentNewMgr.GetPraraData(3);
                if (_dtEdit != null && _dtEdit.Rows.Count > 0)
                {
                    editStr = _dtEdit.Rows[0][0].ToString();
                }
                else
                {
                    editStr = "&nbsp;&nbsp;";
                }
                template_data = template_data.Replace(editStr,"");
                contentJson=contentJson.Replace(replaceStr,template_data);
                json = contentJson;
            }
            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 = "獲取網頁出現異常!";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }*/
        #endregion

        #region 發送電子報 (測試發送/正式發送)
        public HttpResponseBase SendEdm()
        {
            string json = string.Empty;
            EdmSendLog eslQuery = new EdmSendLog();
            MailRequest mQuery = new MailRequest();
            try
            {
                _edmContentNewMgr = new EdmContentNewMgr(mySqlConnectionString);
                if (!string.IsNullOrEmpty(Request.Params["content_id"]))
                {
                    eslQuery.content_id = mQuery.content_id = Convert.ToInt32(Request.Params["content_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["group_id"]))
                {
                    mQuery.group_id = Convert.ToInt32(Request.Params["group_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["sender_email"]))
                {
                    mQuery.sender_address = Request.Params["sender_email"];
                }
                if (!string.IsNullOrEmpty(Request.Params["sender_name"]))
                {
                    mQuery.sender_name = Request.Params["sender_name"];
                }
                if (!string.IsNullOrEmpty(Request.Params["subject"]))
                {
                    mQuery.subject = Request.Params["subject"]; 
                }
                if (!string.IsNullOrEmpty(Request.Params["template_id"]))
                {
                    mQuery.template_id = Convert.ToInt32(Request.Params["template_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["static_template"]))
                {
                    mQuery.static_template = Convert.ToUInt64(Request.Params["static_template"]);
                }
                eslQuery.create_userid = (Session["caller"] as Caller).user_id;
                mQuery.user_id = 0;
                if (!string.IsNullOrEmpty(Request.Params["testSend"]))
                {
                    if (Request.Params["testSend"] == "true")//
                    {
                        eslQuery.test_send_end = true;
                        #region 字段賦值
                        eslQuery.test_send = 1;
                        eslQuery.receiver_count = 1;
                        eslQuery.schedule_date = DateTime.Now;
                        eslQuery.expire_date = eslQuery.schedule_date.AddHours(1);
                        eslQuery.createdate = eslQuery.schedule_date;
                        mQuery.schedule_date = eslQuery.schedule_date;
                        mQuery.valid_until_date = eslQuery.expire_date;
                        mQuery.retry_count = 0;
                        mQuery.next_send = eslQuery.schedule_date;
                        mQuery.max_retry = 1;
                        if (!string.IsNullOrEmpty(Request.Params["test_send_list"]))
                        {
                            string[] test_send_arr = Request.Params["test_send_list"].ToString().TrimEnd('\n').Split('\n');
                            for (int i = 0; i < test_send_arr.Length; i++)
                            {
                                if (test_send_arr[i] != "")
                                {
                                    
                                    mQuery.receiver_address = test_send_arr[i];
                                    eslQuery.receiver_count = test_send_arr.Length;
                                    if (!string.IsNullOrEmpty(Request.Params["body"]))
                                    {
                                        if (mQuery.static_template == 0)//非靜態範本,需動態生成推薦
                                        {
                                            mQuery.bodyData = Request.Params["body"] + _edmContentNewMgr.GetRecommendHtml(0);
                                        }
                                        else//靜態範本
                                        {
                                            mQuery.bodyData = Request.Params["body"];
                                        }
                                        
                                        #region   得到電子報整體內容
                                            string replaceStr = string.Empty;
                                            string editStr = string.Empty;
                                            string content_url = _edmContentNewMgr.GetContentUrlByContentId(eslQuery.content_id);
                                            if (!string.IsNullOrEmpty(content_url))
                                            {
                                                #region 獲取網頁內容
                                                HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(content_url);
                                                httpRequest.Timeout = 9000;
                                                httpRequest.Method = "GET";
                                                HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse();
                                                StreamReader sr = new StreamReader(httpResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("UTF-8"));
                                                
                                                string contentStr = sr.ReadToEnd();
                                                DataTable _dt = _edmContentNewMgr.GetPraraData(1);
                                                if (_dt != null && _dt.Rows.Count > 0)
                                                {
                                                    replaceStr = _dt.Rows[0][0].ToString();
                                                }
                                                else
                                                {
                                                    replaceStr = "&nbsp;&nbsp;";
                                                }
                                                DataTable _dtEdit = _edmContentNewMgr.GetPraraData(3);
                                                if (_dtEdit != null && _dtEdit.Rows.Count > 0)
                                                {
                                                    editStr = _dtEdit.Rows[0][0].ToString();
                                                }
                                                else
                                                {
                                                    editStr = "&nbsp;&nbsp;";
                                                }
                                                if (mQuery.bodyData.IndexOf(subscribe) > 0)//找到了埋的那個code,證明是點擊了訂閱電子報
                                                {
                                                    mQuery.bodyData = contentStr.Replace(replaceStr, mQuery.bodyData.Replace(subscribe, "\n").Replace(editStr,"") ) + subscribe_url; ;
                                                }
                                                else
                                                {
                                                    mQuery.bodyData = contentStr.Replace(replaceStr, mQuery.bodyData.Replace(editStr, ""));
                                                }
                                                #endregion
                                            }
                                            #endregion
                                    }
                                    MailHelper mail = new MailHelper();
                                    mail.SendMailAction(test_send_arr[i], mQuery.subject, mQuery.bodyData + "   ");
                                    json = _edmContentNewMgr.MailAndRequest(eslQuery, mQuery);
                                }
                            }
                        }
                        else
                        {
                            MailHelper mail = new MailHelper();
                            mQuery.bodyData = Request.Params["body"];
                            if (mQuery.bodyData.IndexOf(subscribe) > 0)//找到了埋的那個code,證明是點擊了訂閱電子報
                            {
                                mQuery.bodyData = mQuery.bodyData.Replace(subscribe, "\n") + _edmContentNewMgr.GetRecommendHtml(Convert.ToUInt32((Session["caller"] as Caller).user_id)) + subscribe_url;
                            }
                            mail.SendMailAction((Session["caller"] as Caller).user_email, mQuery.subject, mQuery.bodyData + "   ");
                            json = _edmContentNewMgr.MailAndRequest(eslQuery, mQuery);
                        }
                        #endregion
                    }
                    else//正式發送,寫入排程所用表
                    {
                        if (!string.IsNullOrEmpty(Request.Params["body"]))
                        {
                            mQuery.body = Request.Params["body"];
                        }
                        eslQuery.test_send_end = false;
                        eslQuery.test_send = 0;
                        //eslQuery.receiver_count=""; 經計算後寫入
                        if (!string.IsNullOrEmpty(Request.Params["schedule_date"]))
                        {
                            eslQuery.schedule_date = Convert.ToDateTime(Request.Params["schedule_date"]);
                            mQuery.schedule_date = eslQuery.schedule_date;
                        }
                        if (!string.IsNullOrEmpty(Request.Params["email_group_id"]))
                        {
                            eslQuery.email_group_id = Convert.ToInt32(Request.Params["email_group_id"]);
                        }
                        if (!string.IsNullOrEmpty(Request.Params["expire_date"]))
                        {
                            eslQuery.expire_date = Convert.ToDateTime(Convert.ToDateTime(Request.Params["expire_date"]).ToString("yyyy-MM-dd 23:59:59"));
                            mQuery.valid_until_date = eslQuery.expire_date;
                        }
                        eslQuery.createdate = DateTime.Now;
                        if (!string.IsNullOrEmpty(Request.Params["elcm_id"]))
                        {
                            eslQuery.elcm_id = Convert.ToInt32(Request.Params["elcm_id"]);
                        }
                        if (!string.IsNullOrEmpty(Request.Params["extra_send"]))
                        {
                            mQuery.extra_send = Request.Params["extra_send"];
                        }
                        if (!string.IsNullOrEmpty(Request.Params["extra_no_send"]))
                        {
                            mQuery.extra_no_send = Request.Params["extra_no_send"];
                        }
                        if (!string.IsNullOrEmpty(Request.Params["is_outer"]))
                        {
                            if (Request.Params["is_outer"] == "true")
                            {
                                mQuery.is_outer = true;
                            }
                            else
                            {
                                mQuery.is_outer = false;
                            }
                        }
                       json = _edmContentNewMgr.MailAndRequest(eslQuery, mQuery);
                    }
                }
            }
            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;
        }
コード例 #5
0
        public HttpResponseBase GetEdmPMStore()
        {
            string json = string.Empty;
            try
            {

                _edmContentNewMgr = new EdmContentNewMgr(mySqlConnectionString);
                string para = "edm_pm_name";
                DataTable _dt = _edmContentNewMgr.GetParaStore(para);
                json = "{success:true,data:" + JsonConvert.SerializeObject(_dt, 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;
        }
コード例 #6
0
 public HttpResponseBase AdvanceContent()
 {
     string contentStr = string.Empty;
     try
     {
         if (!string.IsNullOrEmpty(Request.Params["group_id"]))
         {
             int group_id = Convert.ToInt32(Request.Params["group_id"]);
             _edmContentNewMgr = new EdmContentNewMgr(mySqlConnectionString);
             contentStr = Server.HtmlDecode(_edmContentNewMgr.GetContentIDAndUrl(group_id, (Session["caller"] as Caller).user_id));
         }
     }
     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(contentStr);
     this.Response.End();
     return this.Response;
 }
コード例 #7
0
        public HttpResponseBase GetECNList()
        {
            string json = string.Empty;

            try
            {
                EdmContentNew query = new EdmContentNew();
                List<EdmContentNew> store = new List<EdmContentNew>();
                if (!string.IsNullOrEmpty(Request.Params["group_id"]))
                {
                    query.group_id = Convert.ToInt32(Request.Params["group_id"]);
                }
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");
                int totalCount = 0;
                _edmContentNewMgr = new EdmContentNewMgr(mySqlConnectionString);
                store = _edmContentNewMgr.GetECNList(query, out totalCount);
                foreach (var item in store)
                {
                    item.template_data = Server.HtmlDecode(Server.HtmlDecode(item.template_data));
                }
                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;
        }
コード例 #8
0
        public HttpResponseBase EdmContentNewReportList()
        {
            string json = string.Empty;
            try
            {
                EdmTrace query = new EdmTrace();
                if (!string.IsNullOrEmpty(Request.Params["content_id"]))
                {
                    query.content_id = Convert.ToInt32(Request.Params["content_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["log_id"]))
                {
                    query.log_id = Convert.ToInt32(Request.Params["log_id"]);
                }
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");
                int totalCount = 0;
                _edmContentNewMgr = new EdmContentNewMgr(mySqlConnectionString);
                DataTable _dt = _edmContentNewMgr.EdmContentNewReportList(query);
                _dt.Columns.Add("avgPerson", typeof(string));
                _dt.Columns.Add("avgCount", typeof(string));
                int totalOpenPerson = 0;
                int totalOpenCount = 0;
                for (int i = 0; i < _dt.Rows.Count; i++)
                {
                    if (_dt.Rows[i]["openPerson"] != "")
                    {
                        totalOpenPerson += Convert.ToInt32(_dt.Rows[i]["openPerson"]);
                    }
                    if (_dt.Rows[i]["openCount"] != "")
                    {
                        totalOpenCount += Convert.ToInt32(_dt.Rows[i]["openCount"]);
                    }
                }

                for (int i = 0; i < _dt.Rows.Count; i++)
                {
                    //Math.Round((double)item.total_person / sum_total_person * 100, 2);
                    if (_dt.Rows[i]["openPerson"] != "")
                    {
                        _dt.Rows[i]["avgPerson"] = Math.Round((double)Convert.ToInt32(_dt.Rows[i]["openPerson"]) / totalOpenPerson * 100, 2) + "%";
                    }
                    if (_dt.Rows[i]["openCount"] != "")
                    {
                        _dt.Rows[i]["avgCount"] = Math.Round((double)Convert.ToInt32(_dt.Rows[i]["openCount"]) / totalOpenCount * 100, 2) + "%";
                    }
                }

                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(_dt, 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;
        }
コード例 #9
0
        public HttpResponseBase EdmSendListCount()
        {
            string json = string.Empty;
            try
            {
                EdmTrace query = new EdmTrace();
                if (!string.IsNullOrEmpty(Request.Params["content_id"]))
                {
                    query.content_id = Convert.ToInt32(Request.Params["content_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["log_id"]))
                {
                    query.log_id = Convert.ToInt32(Request.Params["log_id"]);
                }
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");
                int totalCount = 0;
                _edmContentNewMgr = new EdmContentNewMgr(mySqlConnectionString);
                DataTable _dt = _edmContentNewMgr.FXMD(query);
                foreach (DataRow item in _dt.Rows)
                {
                    if (item["name"] != "")
                    {
                        item["name"] = item["name"].ToString().Substring(0, 1) + "**";
                    }
                    if (item["email"] != "")
                    {
                        item["email"] = item["email"].ToString().Split('@')[0] + "@***";
                    }
                }
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(_dt, 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;
        }
コード例 #10
0
        public void ImportWKXMD()
        {
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["content_id"]))
                {
                    if (!string.IsNullOrEmpty(Request.Params["log_id"]))
                    {
                        int log_id = Convert.ToInt32(Request.Params["log_id"]);
                        _edmContentNewMgr = new EdmContentNewMgr(mySqlConnectionString);
                        DataTable _newDt = new DataTable();
                        DataTable _dt = _edmContentNewMgr.WKXMD(Convert.ToInt32(Request.Params["content_id"]), log_id);
                        _newDt.Columns.Add("發信狀態", typeof(string));
                        _newDt.Columns.Add("姓名", typeof(string));
                        _newDt.Columns.Add("信箱", typeof(string));
                        _newDt.Columns.Add("信箱編號", typeof(string));
                        _newDt.Columns.Add("開信次數", typeof(string));
                        _newDt.Columns.Add("寄信時間", typeof(string));

                        for (int i = 0; i < _dt.Rows.Count; i++)
                        {
                            #region 轉換dt
                            DataRow newRow = _newDt.NewRow();
                            newRow[0] = "success";
                            if (_dt.Rows[i]["name"] == "")
                            {
                                newRow[1] = "";
                            }
                            else
                            {
                                newRow[1] = _dt.Rows[i]["name"].ToString().Substring(0, 1) + "**";
                            }

                            if (_dt.Rows[i]["email"] == "")
                            {
                                newRow[2] = "";
                            }
                            else
                            {
                                newRow[2] = _dt.Rows[i]["email"].ToString().Split('@')[0] + "@***";
                            }
                            newRow[3] = (_dt.Rows[i]["email_id"]).ToString();
                            if (_dt.Rows[i]["count"] == "")
                            {
                                newRow[4] = "0";
                            }
                            else
                            {
                                newRow[4] = Convert.ToInt32(_dt.Rows[i]["count"]);
                            }
                            if (_dt.Rows[i]["send_date"] == "")
                            {
                                newRow[5] = "";
                            }
                            else
                            {
                                DateTime request_createdate;
                                if (DateTime.TryParse(_dt.Rows[i]["send_date"].ToString(), out request_createdate))
                                {
                                    newRow[5] = Convert.ToDateTime(_dt.Rows[i]["send_date"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
                                }
                                else
                                {
                                    newRow[5] = "";
                                }

                            }

                            _newDt.Rows.Add(newRow);
                            #endregion
                        }
                        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);
            }
        }
コード例 #11
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;
 }
コード例 #12
0
 public HttpResponseBase GetHtml()
 {
     string htmlStr = string.Empty;
     try
     {
         EdmContentNew query = new EdmContentNew();
         if (!string.IsNullOrEmpty(Request.Params["content_id"]))
         {
             query.content_id = Convert.ToInt32(Request.Params["content_id"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["template_id"]))
         {
             query.template_id = Convert.ToInt32(Request.Params["template_id"]);
         }
         _edmContentNewMgr = new EdmContentNewMgr(mySqlConnectionString);
         htmlStr=_edmContentNewMgr.GetHtml(query);
         htmlStr = Server.HtmlDecode(Server.HtmlDecode(htmlStr));
     }
     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(htmlStr);
     this.Response.End();
     return this.Response;
 }