public List<EdmTemplateQuery> GetEdmTemplateList(EdmTemplateQuery query, out int totalCount) { query.Replace4MySQL(); StringBuilder str = new StringBuilder(); StringBuilder strcont = new StringBuilder(); totalCount = 0; try { str.AppendFormat(" select et.template_id,et.template_name,et.edit_url,et.content_url,et.enabled,et.static_template, mu1.user_username as template_create_user,mu2.user_username as template_update_user,et.template_createdate,et.template_updatedate from edm_template et "); str.Append(" LEFT JOIN manage_user mu1 on mu1.user_id=et.template_create_userid "); str.Append(" LEFT JOIN manage_user mu2 on mu2.user_id=et.template_update_userid "); str.Append(" order by enabled desc, template_name "); str.Append(strcont); if (query.IsPage) { StringBuilder strpage = new StringBuilder(); StringBuilder strcontpage = new StringBuilder(); strpage.AppendFormat(" SELECT count(biao.template_id) as totalCount FROM(select et.template_id from edm_template et "); strpage.Append(strcont); strpage.AppendFormat(")as biao "); DataTable _dt = _access.getDataTable(strpage.Append(strcontpage).ToString()); if (_dt.Rows.Count > 0) { totalCount = Convert.ToInt32(_dt.Rows[0]["totalCount"]); str.AppendFormat(" limit {0},{1}", query.Start, query.Limit); } } return _access.getDataTableForObj<EdmTemplateQuery>(str.ToString());// 獲取查詢記錄 } catch (Exception ex) { throw new Exception("EdmTemplateDao-->GetEdmTemplateList-->" + ex.Message); } }
public string UpdateStats_ET(EdmTemplateQuery query) // add by yachao1120j 2015-9-22 { string josn; string sql = ""; try { if (query.enabled == 0) { query.enabled = 1; } else { query.enabled = 0; } sql = _edmtemplatedao.UpdateStats_ET(query); if (_dbAccess.execCommand(sql) > 0) { josn = "{success:true}"; } else { josn = "{success:false}"; } return josn; } catch (Exception ex) { throw new Exception("EdmTemplateMgr-->UpdateStats_ET-->" + ex.Message + sql, ex); } }
//判断是新增 还是 编辑 public int SaveEdmTemplateAdd(EdmTemplateQuery query) // add by yachao1120j 2015-9-22 { if (query.template_id == 0)//新增 { return _edmtemplatedao.EdmTemplateInsert(query); } else//編輯 { return _edmtemplatedao.EdmTemplateUpdate(query); } }
public List<EdmTemplateQuery> GetEdmTemplateList(EdmTemplateQuery query, out int totalCount) // add by yachao1120j 2015-9-22 { try { List<EdmTemplateQuery> store = new List<EdmTemplateQuery>(); store = _edmtemplatedao.GetEdmTemplateList(query, out totalCount); return store; } catch (Exception ex) { throw new Exception("EdmTemplateMgr->GetEdmTemplateList" + ex.Message); } }
public string UpdateStats_ET(EdmTemplateQuery query) // add by yachao1120j 2015-9-22 { StringBuilder strSql = new StringBuilder(); try { strSql.AppendFormat(@"Update edm_template set enabled='{0}' WHERE template_id='{1}'", query.enabled, query.template_id); return strSql.ToString(); } catch (Exception ex) { throw new Exception("EdmTemplateDao-->UpdateStats_ET-->" + ex.Message + strSql.ToString(), ex); } }
//插入信息 public int EdmTemplateInsert(EdmTemplateQuery query) { StringBuilder sql = new StringBuilder(); query.Replace4MySQL(); try { sql.Append("insert into edm_template (template_name, edit_url, content_url,template_create_userid,template_update_userid,template_createdate,static_template)values "); sql.AppendFormat("('{0}','{1}','{2}','{3}','{4}',NOW(),{5})", query.template_name, query.edit_url, query.content_url, query.template_create_userid, query.template_update_userid,query.static_template); return _access.execCommand(sql.ToString()); } catch (Exception ex) { throw new Exception("EdmTemplateDao-->EdmTemplateInsert-->" + sql.ToString() + ex.Message); } }
public HttpResponseBase SaveEdmTemplateAdd() //add by yachao1120j 2015-9-22 { string json = string.Empty; try { EdmTemplateQuery query = new EdmTemplateQuery(); edmtemplatemgr = new EdmTemplateMgr(mySqlConnectionString); if (!string.IsNullOrEmpty(Request.Params["template_id"])) { query.template_id = Convert.ToInt32(Request.Params["template_id"]); } if (!string.IsNullOrEmpty(Request.Params["template_name"])) { query.template_name = Request.Params["template_name"]; } if (!string.IsNullOrEmpty(Request.Params["edit_url"])) { query.edit_url = Request.Params["edit_url"]; } if (!string.IsNullOrEmpty(Request.Params["content_url"])) { query.content_url = Request.Params["content_url"]; } if (!string.IsNullOrEmpty(Request.Params["static_template"])) { if (Request.Params["static_template"] == "true") { query.static_template = 1; } else { query.static_template = 0; } } query.template_update_userid = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id; query.template_create_userid = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id; int _dt = edmtemplatemgr.SaveEdmTemplateAdd(query); if (_dt > 0) { json = "{success:true}"; } else { json = "{success:false}"; } } 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 Response; }
//EdmTemplate 中的狀態啟用 public HttpResponseBase UpdateStats_ET() { string json = string.Empty; try { edmtemplatemgr = new EdmTemplateMgr(mySqlConnectionString); EdmTemplateQuery query = new EdmTemplateQuery(); if (!string.IsNullOrEmpty(Request.Params["id"])) { query.template_id = Convert.ToInt32(Request.Params["id"]); } if (!string.IsNullOrEmpty(Request.Params["active"])) { query.enabled = Convert.ToInt32(Request.Params["active"]); } json = edmtemplatemgr.UpdateStats_ET(query); } 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; }
public HttpResponseBase GetEdmTemplateList() //add by yachao1120j 2015-9-22 { string json = string.Empty; int totalcount = 0; try { EdmTemplateQuery query = new EdmTemplateQuery(); query.Start = Convert.ToInt32(Request.Params["start"] ?? "0"); query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25"); edmtemplatemgr = new EdmTemplateMgr(mySqlConnectionString); List<EdmTemplateQuery> list = edmtemplatemgr.GetEdmTemplateList(query, out totalcount); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; // timeConverter.DateTimeFormat = "yyyy-MM-dd "; json = "{success:true,totalCount:" + totalcount + ",data:" + JsonConvert.SerializeObject(list, 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 Response; }
//更新信息 public int EdmTemplateUpdate(EdmTemplateQuery query) { StringBuilder sql = new StringBuilder(); query.Replace4MySQL(); try { sql.AppendFormat("update edm_template set template_name = '{0}', edit_url = '{1}', content_url = '{2}',template_update_userid='{3}',static_template={4} where template_id='{5}' ", query.template_name, query.edit_url, query.content_url, query.template_update_userid, query.static_template,query.template_id); return _access.execCommand(sql.ToString()); } catch (Exception ex) { throw new Exception("EdmTemplateDao-->EdmTemplateUpdate-->" + sql.ToString() + ex.Message); } }