Esempio n. 1
0
        /// <summary>
        /// 停止服务
        /// </summary>
        /// <param name="hostControl"></param>
        /// <returns></returns>
        public bool Stop(HostControl hostControl)
        {
            HistoryDataTable.Save();
            KingProcesser.CloseListener();
            Debugger.Log(0, null, "Save HistoryDataTable Datas OK ..");

            if (sslProxyServer != null)
            {
                sslProxyServer.Dispose();
            }
            FiddlerApplication.Shutdown();
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// 处理会话
        /// </summary>
        /// <param name="session">会话</param>
        /// <returns></returns>

        public static async void ProcessSessionAsync(Session session)
        {
            var url = session.fullUrl;

            if (url.Contains("question/bat/findQuiz") == true)
            {
                await SearchAnswerAsync(session);
            }
            else if (url.Contains("question/bat/choose") == true)
            {
                UpdateBestAndSave(session);
            }
            else if (url.Contains("question/bat/fightResult") == true)
            {
                var notifyData = new WsNotifyData <object> {
                    Cmd = WsCmd.GameOver
                };
                WsNotifyByClientIP(notifyData, session.clientIP);
                HistoryDataTable.Save();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 导入json数据
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public static int TryImport(HttpFile file)
        {
            try
            {
                var temp = "temp.tmp";
                File.WriteAllBytes(temp, file.Stream);
                var json = File.ReadAllText(temp, Encoding.UTF8);
                File.Delete(temp);

                var datas = JsonConvert.DeserializeObject <HistoryData[]>(json);
                var count = datas.Select(d => TryAdd(d)).Count(item => item);
                if (count > 0)
                {
                    HistoryDataTable.Save();
                }
                return(count);
            }
            catch (Exception)
            {
                return(0);
            }
        }