Example #1
0
 /// <summary>
 /// 獲取列表
 /// </summary>
 /// <param name="appmsg"></param>
 /// <param name="totalCount"></param>
 /// <returns></returns>
 public List<AppmessageQuery> GetAppmessageList(AppmessageQuery appmsg, out int totalCount)
 {
     try
     {
         return _iappmessageImplDao.GetAppmessageList(appmsg, out totalCount);
     }
     catch (Exception ex)
     {
         throw new Exception("AppmessageMgr-->GetAppmessageList-->" + ex.Message, ex);
     }
 }
Example #2
0
 /// <summary>
 /// 查找列表數據
 /// </summary>
 /// <param name="appmsg"></param>
 /// <param name="totalCount"></param>
 /// <returns></returns>
 public List<AppmessageQuery> GetAppmessageList(AppmessageQuery appmsg, out int totalCount)
 {
     StringBuilder sql = new StringBuilder();
     StringBuilder sqlcount = new StringBuilder();
     StringBuilder sqlwhere = new StringBuilder();
     CommonFunction.GetPHPTime();
     sql.AppendFormat("SELECT message_id,`type`,title,content,FROM_UNIXTIME(messagedate) as messagedate_time,`group`,linkurl,display_type,FROM_UNIXTIME(msg_start) as msg_start_time,FROM_UNIXTIME(msg_end) as msg_end_time,fit_os,appellation,need_login FROM appmessage where 1=1 ");
     sqlcount.AppendFormat("SELECT message_id FROM appmessage where 1=1 ");
     if (appmsg.msg_start_first != 0)
     {
         sqlwhere.AppendFormat(" and msg_start >= {0}", appmsg.msg_start_first);
     }
     if (appmsg.msg_start_second != 0)
     {
         sqlwhere.AppendFormat(" and msg_start <= {0}", appmsg.msg_start_second);
     }
     if (appmsg.msg_end_first != 0)
     {
         sqlwhere.AppendFormat(" and msg_end >= {0} ", appmsg.msg_end_first);
     }
     if (appmsg.msg_end_second != 0)
     {
         sqlwhere.AppendFormat(" and msg_end <= {0} ", appmsg.msg_end_second);
     }
     totalCount = 0;
     try
     {
         sqlcount.AppendFormat(sqlwhere.ToString());
         sql.AppendFormat(sqlwhere.ToString());
         if (appmsg.IsPage)
         {
             System.Data.DataTable _dt = _access.getDataTable(sqlcount.ToString());
             if (_dt != null && _dt.Rows.Count > 0)
             {
                 totalCount = _dt.Rows.Count;
             }
             
             sql.AppendFormat(" limit {0},{1}", appmsg.Start, appmsg.Limit);
         }
         return _access.getDataTableForObj<AppmessageQuery>(sql.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("AppmessageDao.GetAppmessageList-->" + ex.Message + sql.ToString(), ex);
     }
 }
        /// <summary>
        /// 獲取表單數據
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase GetAppMessageList()
        {
            List<AppmessageQuery> stores = new List<AppmessageQuery>();

            string json = string.Empty;
            try
            {
                AppmessageQuery query = new AppmessageQuery();
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
                if (!string.IsNullOrEmpty(Request.Form["msg_start_first"]))//判斷分類一是否為空
                {
                    //query.msg_start_first = uint.Parse(CommonFunction.GetPHPTime(Request.Form["msg_start_first"]).ToString());
                    //modify by jiaohe0625j
                    query.msg_start_first = (uint)CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["msg_start_first"]).ToString("yyyy-MM-dd HH:mm:ss"));
                }
                if (!string.IsNullOrEmpty(Request.Form["msg_start_second"]))//判斷分類一是否為空
                {
                    //query.msg_start_second = uint.Parse(CommonFunction.GetPHPTime(Request.Form["msg_start_second"]).ToString()) + 86399;
                    //時間戳,86399表示時間是23時59分59秒,用於比較時間的大小進行查詢
                    //modify by jiaohe0625j
                    query.msg_start_second = (uint)CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["msg_start_second"]).ToString("yyyy-MM-dd HH:mm:ss"));
                }
                if (!string.IsNullOrEmpty(Request.Form["msg_end_first"]))//判斷分類一是否為空
                {
                    //query.msg_end_first = uint.Parse(CommonFunction.GetPHPTime(Request.Form["msg_end_first"]).ToString());
                    //modify by jiaohe0625j
                    query.msg_end_first = (uint)CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["msg_end_first"]).ToString("yyyy-MM-dd HH:mm:ss"));
                }
                if (!string.IsNullOrEmpty(Request.Form["msg_end_second"]))//判斷分類一是否為空
                {
                    //query.msg_end_second = uint.Parse(CommonFunction.GetPHPTime(Request.Form["msg_end_second"]).ToString()) + 86399;
                    //modify by jiaohe0625j
                    query.msg_end_second = (uint)CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["msg_end_second"]).ToString("yyyy-MM-dd HH:mm:ss"));
                }
                _iappmessageMgr = new AppmessageMgr(mySqlConnectionString);
                int totalCount = 0;
                stores = _iappmessageMgr.GetAppmessageList(query, out totalCount);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                //listUser是准备转换的对象
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores, 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);
                json = "{success:true,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }