Exemplo n.º 1
0
 public HttpResponseBase GetProNotice()
 {
     string json = string.Empty;
     try
     {
         StringBuilder strJson = new StringBuilder();
         _productNoticeMgr = new ProductNoticeMgr(connectionString);
         List<ProductNotice> notices = _productNoticeMgr.Query(new ProductNotice { notice_status = 1 });
         if (notices != null)
         {
             if (!string.IsNullOrEmpty(Request.Form["ProductId"]))
             {
                 uint productId = uint.Parse(Request.Form["ProductId"]);
                 _productNoticeSetMgr = new ProductNoticeSetMgr(connectionString);
                 List<ProductNoticeSet> noticeSets = _productNoticeSetMgr.Query(new ProductNoticeSet { product_id = productId });
                 foreach (var item in notices)
                 {
                     strJson.AppendFormat("<input type='checkbox' id='notice_{0}' name='notices' value='{0}' ", item.notice_id);
                     if (noticeSets.Exists(m => m.notice_id == item.notice_id))
                     {
                         strJson.Append("checked='true'");
                     }
                     strJson.AppendFormat("/><label for='notice_{0}'>{1}</label>", item.notice_id, item.notice_name);
                 }
             }
             else
             {
                 int writerId = (Session["caller"] as Caller).user_id;
                 _productNoticeSetTempMgr = new ProductNoticeSetTempMgr(connectionString);
                 _productTempMgr = new ProductTempMgr(connectionString);
                 ProductNoticeSetTemp query = new ProductNoticeSetTemp { Writer_Id = writerId, Combo_Type = COMBO_TYPE };
                 if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                 {
                     query.product_id = Request.Form["OldProductId"];
                 }
                 List<ProductNoticeSetTemp> noticeSetTemps = _productNoticeSetTempMgr.Query(query);
                 ProductTemp proTemp = _productTempMgr.GetProTemp(new ProductTemp { Writer_Id = writerId, Combo_Type = COMBO_TYPE });
                 bool check = (proTemp != null && !string.IsNullOrEmpty(proTemp.Page_Content_2)) ? false : true;
                 foreach (var item in notices)
                 {
                     strJson.AppendFormat("<input type='checkbox' id='notice_{0}' name='notices' value='{0}' ", item.notice_id);
                     if (check || noticeSetTemps.Exists(m => m.notice_id == item.notice_id))
                     {
                         strJson.Append("checked='true'");
                     }
                     strJson.AppendFormat("/><label for='notice_{0}'>{1}</label>", item.notice_id, item.notice_name);
                 }
             }
             json = strJson.ToString();
         }
     }
     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(json);
     this.Response.End();
     return this.Response;
 }