Beispiel #1
0
        public List<PageMetaData> GetPageMetaDataList(PageMetaData query, ref int totalCount)
        {
            query.Replace4MySQL();
            StringBuilder sql = new StringBuilder();
            StringBuilder sqlCondi = new StringBuilder();
            sql.Append("SELECT pm_id,pm_url_para,pm_page_name,pm_title,pm_keywords, pm_description,pm_created,pm_modified");
            sqlCondi.Append(" FROM page_metadata ");
            sqlCondi.Append(" WHERE 1=1 ");
            if (!string.IsNullOrEmpty(query.pm_page_name))
            {
                sqlCondi.AppendFormat(" and (pm_page_name like N'%{0}%' or pm_title like N'%{0}%' or pm_keywords like N'%{0}%')", query.pm_page_name);
            }
            try
            {

                if (query.IsPage)
                {
                    DataTable dt = _access.getDataTable("select count(pm_id) as totalCount " + sqlCondi.ToString());
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        totalCount = Convert.ToInt32(dt.Rows[0]["totalCount"]);
                    }
                    sqlCondi.AppendFormat(" limit {0},{1} ", query.Start, query.Limit);
                }
                sql.Append(sqlCondi.ToString());
                return _access.getDataTableForObj<PageMetaData>(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("PageMetaDataDao-->GetPageMetaDataList-->" + ex.Message + sql.ToString(), ex);
            }

        }
Beispiel #2
0
        public int InsertPageMeta(PageMetaData query)
        {
            try
            {
                return _pageMetaDataDao.InsertPageMeta(query);
            }
            catch (Exception ex)
            {
                throw new Exception("PageMetaDataMgr-->InsertPageMeta-->" + ex.Message, ex);

            }
        }
Beispiel #3
0
        public List<PageMetaData> GetPageMetaDataList(PageMetaData query, ref int totalCount)
        {
            try
            {
                return _pageMetaDataDao.GetPageMetaDataList(query, ref totalCount);
            }
            catch (Exception ex)
            {
                throw new Exception("PageMetaDataMgr-->GetPageMetaDataList-->" + ex.Message, ex);

            }
        }
        public HttpResponseBase GetPageMetaList()
        {

            string json = string.Empty;
            try
            {
                PageMetaData query = new PageMetaData();
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");

                if (!string.IsNullOrEmpty(Request.Params["limit"]))
                {
                    query.Limit = Convert.ToInt32(Request.Params["limit"]);
                }
                else
                {
                    query.Limit = 25;
                }
                if (!string.IsNullOrEmpty(Request.Params["search_content"]))
                {
                    query.pm_page_name = Request.Params["search_content"].ToString();
                    query.pm_title = query.pm_page_name;
                    query.pm_keywords = query.pm_page_name;
                }
                int totalCount = 0;
                _pageMetaMgr = new PageMetaDataMgr(mySqlConnectionString);
                List<PageMetaData> stores = _pageMetaMgr.GetPageMetaDataList(query, ref totalCount);

                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";

                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:false,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Beispiel #5
0
        public int UpdatePageMeta(PageMetaData store)
        {
            store.Replace4MySQL();
            StringBuilder sql = new StringBuilder();
            try
            {
                sql.AppendFormat("update page_metadata set pm_url_para='{0}',pm_page_name='{1}',pm_title='{2}',pm_keywords='{3}'", store.pm_url_para
                    , store.pm_page_name, store.pm_title, store.pm_keywords);
                sql.AppendFormat(", pm_description='{0}',pm_modified='{1}',pm_modify_user='******'", store.pm_description, Common.CommonFunction.DateTimeToString(store.pm_modified), store.pm_modify_user);
                sql.AppendFormat(" where pm_id='{0}';", store.pm_id);
                return _access.execCommand(sql.ToString());

            }
            catch (Exception ex)
            {
                throw new Exception("PageMetaDataDao-->UpdatePageMeta-->" + ex.Message + sql.ToString(), ex);
            }

        }
Beispiel #6
0
        public int InsertPageMeta(PageMetaData store)
        {
            store.Replace4MySQL();
            StringBuilder sql = new StringBuilder();
            try
            {
                sql.Append("insert into page_metadata (pm_url_para,pm_page_name,pm_title,pm_keywords, pm_description,pm_created,pm_modified,pm_modify_user,pm_create_user)");
                sql.AppendFormat(" values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')",
                    store.pm_url_para, store.pm_page_name, store.pm_title, store.pm_keywords, store.pm_description,
                   Common.CommonFunction.DateTimeToString(store.pm_created), Common.CommonFunction.DateTimeToString(store.pm_modified),
                   store.pm_modify_user, store.pm_create_user);
                return _access.execCommand(sql.ToString());

            }
            catch (Exception ex)
            {
                throw new Exception("PageMetaDataDao-->InsertPageMeta-->" + ex.Message + sql.ToString(), ex);
            }

        }
        public HttpResponseBase SavePageMeta()
        {

            string json = "{success:false}";
            try
            {
                PageMetaData query = new PageMetaData();
                if (!string.IsNullOrEmpty(Request.Params["pm_id"]))
                {
                    query.pm_id = Convert.ToInt32(Request.Params["pm_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["pm_page_name"]))
                {
                    query.pm_page_name = Request.Params["pm_page_name"];
                }
                if (!string.IsNullOrEmpty(Request.Params["pm_title"]))
                {
                    query.pm_title = Request.Params["pm_title"];
                }
                if (!string.IsNullOrEmpty(Request.Params["pm_url_para"]))
                {
                    query.pm_url_para = Request.Params["pm_url_para"];
                }
                if (!string.IsNullOrEmpty(Request.Params["pm_keywords"]))
                {
                    query.pm_keywords = Request.Params["pm_keywords"];
                }
                if (!string.IsNullOrEmpty(Request.Params["pm_description"]))
                {
                    query.pm_description = Request.Params["pm_description"];
                }
                _pageMetaMgr = new PageMetaDataMgr(mySqlConnectionString);
                if (query.pm_id == 0)
                {
                    query.pm_created = DateTime.Now;
                    query.pm_modified = query.pm_created;
                    query.pm_create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                    query.pm_modify_user = query.pm_create_user;
                    if (_pageMetaMgr.InsertPageMeta(query) > 0)
                    {
                        json = "{success:true}";
                    }
                }
                else
                {
                    query.pm_modified = query.pm_created;
                    query.pm_modify_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                    if (_pageMetaMgr.UpdatePageMeta(query) > 0)
                    {
                        json = "{success:true}";
                    }
                }


            }
            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;
        }