Пример #1
0
        public HttpResponseBase AnnounceContentSave()
        {
            string json = string.Empty;
            List<AnnounceQuery> store = new List<AnnounceQuery>();
            AnnounceQuery query = new AnnounceQuery();
            AnnounceQuery oldquery = new AnnounceQuery();
            _announcemgr = new AnnounceMgr(mySqlConnectionString);
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["announce_id"]))//編輯
                {
                    query.announce_id = Convert.ToUInt32(Request.Params["announce_id"]);
                    oldquery = _announcemgr.GetAnnounce(query);
                    query.modify_date = DateTime.Now;
                    query.modifier = uint.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());

                }
                else
                {
                    query.create_date = DateTime.Now;
                    query.creator = uint.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                    query.modify_date = query.create_date;
                    query.modifier = query.creator;
                }
                if (!string.IsNullOrEmpty(Request.Params["title"].ToString()))
                {
                    query.title = Request.Params["title"].ToString();
                }
                else
                {
                    query.title = "";
                }
                uint isUint = 0;
                if (!string.IsNullOrEmpty(Request.Params["type"].ToString()))
                {

                    if (uint.TryParse(Request.Params["type"].ToString(), out isUint))
                    {
                        query.type = Convert.ToUInt32(Request.Params["type"].ToString());
                    }
                    else
                    {
                        query.type = oldquery.type;
                    }

                }
                if (!string.IsNullOrEmpty(Request.Params["sort"].ToString()))
                {
                    query.sort = Convert.ToUInt32(Request.Params["sort"].ToString());
                }
                else
                {
                    query.sort = 0;
                }
                if (!string.IsNullOrEmpty(Request.Params["content"].ToString()))
                {
                    query.content = Request.Params["content"].ToString();
                }
                else
                {
                    query.content = "";
                }
                if (!string.IsNullOrEmpty(Request.Params["status"].ToString()))
                {
                    if (uint.TryParse(Request.Params["status"].ToString(), out isUint))
                    {
                        query.status = Convert.ToUInt32(Request.Params["status"].ToString());
                    }
                    else
                    {
                        query.status = oldquery.status;
                    }

                }

                if (_announcemgr.AnnounceSave(query) > 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}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Пример #2
0
        public HttpResponseBase GetAnnounce()
        {
            string json = string.Empty;
            try
            {
                _announceMgr = new AnnounceMgr(mySqlConnectionString);

                json = _announceMgr.GetAnnounce();
            }
            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,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;

        }