Пример #1
0
        //GetArticle

        #endregion

        #region 獲取商品名稱
        public HttpResponseBase GetProductName()
        {
            List<Product> store = new List<Product>();
            string json = "{success:true,msg:'0'}";
            try
            {
                Product query = new Product();
                _productMgr = new ProductMgr(mySqlConnectionString);
                if (!string.IsNullOrEmpty(Request.Params["id"]))
                {
                    query.Product_Id = Convert.ToUInt32(Request.Params["id"]);
                }
                if (query.Product_Id > 0)
                {
                    store = _productMgr.GetProductName(query);
                    foreach (var item in store)
                    {
                        json = "{success:true,msg:'" + item.Product_Name + "'}";//返回json數據
                    }
                }
                else
                {
                    json = "{success:true,msg:'0'}";//返回json數據
                }
                //IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //json = "{success:true,data:" + JsonConvert.SerializeObject(store, 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;
        }