Beispiel #1
0
 /// <summary>
 /// 初始化
 /// </summary>
 public static void Flush()
 {
     AppConfig.Initialize();
     RouteChahe.Flush();
     RuntimeWaring.Flush();
     ZeroFlush();
     //Datas = new List<RouteData>();
 }
Beispiel #2
0
 /// <summary>
 /// 初始化
 /// </summary>
 public static void Initialize()
 {
     // 日志支持
     //Agebull.Common.Logging.LogRecorder.GetRequestIdFunc = () => ApiContext.RequestContext.RequestId;.
     LogRecorder.Initialize(new RemoteRecorder());
     AppConfig.Initialize(Path.Combine(Startup.Configuration["contentRoot"], "route_config.json"));
     StationProgram.Run();
     RouteChahe.Flush();
     RuntimeWaring.Flush();
     RouteCommand.ZeroFlush();
     //Datas = new List<RouteData>();
 }
Beispiel #3
0
        /*
         * /// <summary>
         * /// 数据
         * /// </summary>
         * internal static List<RouteData> Datas = new List<RouteData>();
         *
         * public static Mutex Mutex = new Mutex();
         *
         * /// <summary>
         * /// 流程结束后的处理
         * /// </summary>
         * internal static void PushFlowExtend(RouteData data)
         * {
         *  Datas.Add(data);
         *  Mutex.ReleaseMutex();
         * }
         *
         * /// <summary>
         * /// 流程结束后的处理
         * /// </summary>
         * internal static void FlowExtendTask()
         * {
         *  while (true)
         *  {
         *      if (!Mutex.WaitOne(1000))
         *      {
         *          continue;
         *      }
         *      var datas = Datas;
         *      Datas = new List<RouteData>();
         *      Mutex.ReleaseMutex();
         *      //最多处理后50行
         *      var index = 0;
         *      if (datas.Count > 50)
         *      {
         *          index = datas.Count - 50;
         *      }
         *      for (; index < datas.Count; index++)
         *      {
         *          ApiResult.CacheData(datas[index]);
         *      }
         *  }
         * }*/

        #endregion

        #region 内部命令处理


        /// <summary>
        ///     内部命令处理
        /// </summary>
        /// <param name="url"></param>
        /// <param name="response"></param>
        /// <returns></returns>
        public static bool InnerCommand(string url, HttpResponse response)
        {
            //命令
            switch (url)
            {
            case "/":
                response.WriteAsync("Wecome ZeroNet Http Router!", Encoding.UTF8);
                return(true);

            case "/_1_clear_1_":
                RouteChahe.Flush();
                response.WriteAsync(JsonConvert.SerializeObject(RouteOption.Option, Formatting.Indented),
                                    Encoding.UTF8);
                return(true);

            //case "/_1_counter_1_/info":
            //    response.WriteAsync(JsonConvert.SerializeObject(RouteCounter.Station, Formatting.Indented), Encoding.UTF8);
            //    return true;
            //case "/_1_counter_1_/save":
            //    RouteCounter.Save();
            //    response.WriteAsync(JsonConvert.SerializeObject(RouteCounter.Station, Formatting.Indented), Encoding.UTF8);
            //    return true;
            case "/_1_config_1_":
                response.WriteAsync(JsonConvert.SerializeObject(RouteOption.Option, Formatting.Indented),
                                    Encoding.UTF8);
                return(true);
                //case "/_1_warings_1_":
                //    response.WriteAsync(JsonConvert.SerializeObject(RuntimeWaring.WaringsTime, Formatting.Indented), Encoding.UTF8);
                //    return true;
                //case "/_1_cache_1_":
                //    response.WriteAsync(JsonConvert.SerializeObject(RouteChahe.Cache, Formatting.Indented), Encoding.UTF8);
                //    return true;
            }

            return(false);
        }
Beispiel #4
0
 /// <summary>
 ///     刷新
 /// </summary>
 public static void Flush()
 {
     RouteChahe.Flush();
 }