Пример #1
0
        /// <summary>
        /// 獲取賣場列表
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase GetChannel()
        {
            string json = String.Empty;
            List<Channel> store = new List<Channel>();

            try
            {
                Channel channel = new Channel();
                _channelMgr = new ChannelMgr(mySqlConnectionString);
                store = _channelMgr.QueryList(0);
                channel.channel_id = 0;
                channel.channel_name_simple = "全部";
                store.Insert(0, channel);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd";
                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,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Пример #2
0
        public HttpResponseBase GetChannel()
        {
            string json = string.Empty;
            try
            {
                channelMgr = new ChannelMgr(connectionString);
                json = JsonConvert.SerializeObject(channelMgr.QueryList(1));

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