示例#1
0
 public HttpResponseBase SaveBannerNewsContent()
 {
     string json = string.Empty;
     try
     {
         bncMgr = new BannerNewsContentMgr(mySqlConnectionString);
         BannerNewsContentQuery query = new BannerNewsContentQuery();
         if (!string.IsNullOrEmpty(Request.Params["news_id"]))
         {//如果是編輯獲取該id數據
             query.news_id = uint.Parse(Request.Params["news_id"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["news_site_id"]))
         {
             query.news_site_id = uint.Parse(Request.Params["news_site_id"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["news_title"]))
         {
             query.news_title = Request.Params["news_title"];
         }
         if (!string.IsNullOrEmpty(Request.Params["news_link_url"]))
         {
             query.news_link_url = Request.Params["news_link_url"];
         }
         if (!string.IsNullOrEmpty(Request.Params["news_link_mode"]))
         {
             query.news_link_mode = Convert.ToInt32(Request.Params["news_link_mode"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["news_sort"]))
         {
             query.news_sort = Convert.ToUInt32(Request.Params["news_sort"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["news_status"]))
         {
             query.news_status = Convert.ToUInt32(Request.Params["news_status"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["news_start"]))
         {
             query.news_start = uint.Parse(CommonFunction.GetPHPTime(Request.Params["news_start"].Substring(0, 10) + " 00:00:00").ToString());
         }
         if (!string.IsNullOrEmpty(Request.Params["news_end"]))
         {
             query.news_end = uint.Parse(CommonFunction.GetPHPTime(Request.Params["news_end"].Substring(0, 10) + " 23:59:59").ToString());
         }
         query.news_createdate = uint.Parse(CommonFunction.GetPHPTime(DateTime.Now.ToString()).ToString());
         query.news_updatedate = query.news_createdate;
         query.news_ipfrom = CommonFunction.GetClientIPNew();
         if (query.news_ipfrom == "::1")
         {
             query.news_ipfrom = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName())[2].ToString();
         }
         if (query.news_id > 0)
         {//編輯
             if (bncMgr.UpdateBannerNewsContent(query) > 0)
             {
                 json = "{success:true,msg:'修改成功!'}";
             }
             else
             {
                 json = "{success:false,msg:'修改失敗!'}";
             }
         }
         else
         {//新增
             if (bncMgr.SaveBannerNewsContent(query) > 0)
             {
                 json = "{success:true,msg:'新增成功!'}";
             }
             else
             {
                 json = "{success:false,msg:'新增失敗!'}";
             }
         }
     }
     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,msg:'操作失敗!'}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
示例#2
0
 /// <summary>
 ///內容和歷史跳轉鏈接頁面  文字廣告列表
 /// </summary>
 /// <returns></returns>
 public HttpResponseBase GetBannerNewsList()
 {
     string json = string.Empty;
     BannerNewsContent query = new BannerNewsContent();
     try
     {
         query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
         query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
         if (!string.IsNullOrEmpty(Request.Params["sid"]))
         {
             query.news_site_id = uint.Parse(Request.Params["sid"]);
         }
         if (Request.Params["history"] == "1")
         {
             query.news_status = 3;
         }
         bncMgr = new BannerNewsContentMgr(mySqlConnectionString);
         int totalCount = 0;
         DataTable dt = bncMgr.GetBannerNewsContentList(query, out totalCount);
         IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
         //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
         timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss ";
         json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(dt, 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:false}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }