public GetExpertStatsHandler(PredictionsContext context, IMapper mapper)
 {
     _context           = context;
     _mapper            = mapper;
     _statService       = new StatService();
     _predictionService = new PredictionService();
 }
Пример #2
0
 public LoremIpsumHub(StatService statService, LoggerFactory loggerFactory)
 {
     _statService = statService;
     _logger      = loggerFactory.CreateLogger <LoremIpsumHub>();
     _logger.LogDebug("SignalR Hub is initializing");
     _statService.StatsHasChanged += OnStatHasChanged;
 }
Пример #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hall of Beorn Card Search\r\nHTML TemplateBuilder 0.0.1");

            var productRepo = new ProductRepository();
            var cardRepo    = new CardRepository(productRepo);

            statService = new StatService(cardRepo);

            const string file1 = "templates1.txt";
            const string file2 = "templates2.txt";

            foreach (var c in cardRepo.Cards())
            {
                if (string.IsNullOrEmpty(c.HtmlTemplate))
                {
                    Console.WriteLine("  Writing template1 for : " + c.Slug);
                    var text = string.Format("AddHtml(\"{0}\", \"{1}\");\r\n", c.Slug, GetTemplate(c, c.Text, c.Shadow, c.FlavorText));
                    File.AppendAllText(file1, text);
                }

                if (string.IsNullOrEmpty(c.HtmlTemplate2) && !string.IsNullOrEmpty(c.OppositeText))
                {
                    Console.WriteLine("  Writing template2 for : " + c.Slug);
                    var text = string.Format("AddHtml(\"{0}\", \"{1}\");\r\n", c.Slug, GetTemplate(c, c.OppositeText, string.Empty, c.OppositeFlavorText));
                    File.AppendAllText(file2, text);
                }
            }

            Console.WriteLine("DONE");
            Console.ReadLine();
        }
Пример #4
0
 public VariableNode(StatService statService, string id, StatId?parentId)
     : base(id, NodeType.Stat, 1)
 {
     _statService = statService;
     Id           = new VariableId(id, parentId);
     _parentId    = parentId;
 }
Пример #5
0
 public void Dump()
 {
     foreach (var asset in m_hashAssetDic.Values)
     {
         StatService.Get().LogStat("AssetDump", asset.ToString(), "");
     }
 }
Пример #6
0
        //TODO: нужно разделять id юзера и группы
        //TODO: выкладка на стену сообщества
        //TODO: английский алфавит
        //TODO: валидация

        static void Main(string[] args)
        {
            var ids = new List <string>();

            while (true)
            {
                var id = Console.ReadLine();

                if (string.IsNullOrWhiteSpace(id))
                {
                    break;
                }
                ids.Add(id);
            }

            var vkService   = new VkService();
            var statService = new StatService();

            try
            {
                var dict = vkService.GetWallPosts(ids, 5);

                foreach (var item in dict)
                {
                    Console.WriteLine($"{item.Key}, статистика для последних 5 постов: ");
                    Console.WriteLine(statService.GetStat(item.Value));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Пример #7
0
        public GameObject Instantiate(Transform parent, bool stayWorldPosition)
        {
            GameObject go;

            if (m_pool == null)
            {
                go = Object.Instantiate(UnityObject, parent, stayWorldPosition) as GameObject;
                var direct = go.AddComponent <DirectDestroyGO>();
                direct.PrefabAsset = this;
                direct.Instantiated();
            }
            else
            {
                go = m_pool.Get(parent, stayWorldPosition);
                var cached = go.GetComponent <PoolCacheGO>();
                cached.Instantiated();
            }

            if (m_autoRecyclePrefab)
            {
                var autoRecycle = go.GetComponent <AutoRecycle>();
                autoRecycle.ResetAll();
            }

            StatService.Get().Increase(StatService.StatName.IN_USE_GO, 1);
#if UNITY_EDITOR
            StatService.Get().LogStat("Instantiate", UnityObject.name, m_transformCount);
#endif

#if UNITY_DEBUG
            var service = CSharpServiceManager.Get <AssetFullStatService>(CSharpServiceManager.ServiceType.ASSET_FULL_STAT);
            service.OnInstantiateGameObject(go);
#endif
            return(go);
        }
Пример #8
0
        private StatService CreateStatService()
        {
            var statId  = Guid.Parse(User.Identity.GetUserId());
            var service = new StatService(statId);

            return(service);
        }
Пример #9
0
        public Form1()
        {
            InitializeComponent();

            this.ShowInTaskbar = false;

            ToolStripMenuItem v = new ToolStripMenuItem("退出", null, this.onExit);

            m_notifyMenu.Items.Add(v);
            // 关联快捷菜单
            m_notify.ContextMenuStrip = m_notifyMenu;

            CheckForIllegalCrossThreadCalls = false;

            m_lblCurState.ForeColor = Color.Green;

            XmlConfig cfg = ResMgr.getInstance().getRes("dbserver.xml");

            this.Text     = "数据统计--" + cfg.getString("title", "");
            m_notify.Text = this.Text;

            StatService sys =
                ServiceMgr.getInstance().getSys <StatService>(ServiceType.serviceTypeStat);

            if (sys != null)
            {
                sys.setForm(this);
            }
        }
Пример #10
0
        public ActionResult Index()
        {
            var statId  = Guid.Parse(User.Identity.GetUserId());
            var service = new StatService(statId);
            var model   = service.GetStat();

            return(View(model));
        }
Пример #11
0
        public void BuildCharsStats_Empty()
        {
            var target = new StatService();
            var result = target.BuildCharsStats(null, null);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.TotalCharsInText, 0);
            Assert.IsNull(result.AllCharsOrderedByAppearance);
        }
 public SandwichModule(IServiceProvider provider)
 {
     _SS    = provider.GetService <SandwichService>();
     _DB    = provider.GetService <SandwichDatabase>();
     _ADB   = provider.GetService <ArtistDatabase>();
     _LDB   = provider.GetService <ListingDatabase>();
     _UDB   = provider.GetService <UserDatabase>();
     _stats = provider.GetService <StatService>();
 }
 public StatsController()
 {
     _context           = new PredictionsContext();
     _expertService     = new ExpertService(_context);
     _tourService       = new TourService(_context);
     _predictionService = new PredictionService(_context);
     _matchService      = new MatchService(_context);
     _teamService       = new TeamService(_context);
     _statService       = new StatService(_context);
 }
Пример #14
0
        public ActionResult SaveStats(string data)
        {
            var userStat = JsonConvert.DeserializeObject <UserStat>(data);

            using (var statSvc = new StatService(ConfigurationManager.ConnectionStrings["db"].ConnectionString))
            {
                statSvc.AddStat(userStat);
            }
            return(Content("OK"));
        }
Пример #15
0
        public void WhenRunWithAllTiger_ShouldHave100PercentPredictResult()
        {
            var scores = new Score[]
            {
                Score.Tiger,
                Score.Tiger,
                Score.Tiger,
                Score.Tiger,
                Score.Tiger,
                Score.Tiger,
                Score.Tiger,
                Score.Tiger,
                Score.Tiger
            };

            var predictors = new IPredictor[]
            {
                new SameDifferentPredictor(),
                new Anti12Predictor(),
                new Anti2Predictor()
            };

            var resultPredictor = new DummyPredictor();

            var predictService = new PredictionService(predictors, resultPredictor);
            var mappingScores  = new Score[]
            {
                Score.Tiger,
                Score.Tiger,
                Score.Tiger,
                Score.Tiger,
                Score.Tiger,
                Score.Tiger,
                Score.Tiger,
                Score.Tiger
            };

            var gameStates = scores.Select(s => new GameStateInput(s, None));

            var result = predictService.PredictScore(gameStates, mappingScores)
                         .ToList();

            Assert.AreEqual(scores.Count() + 1, result.Count());

            var sdResult = result
                           .Select(r => r.ScorePredictions.Find(Constants.SameDiffPredictionName).Bind(p => p.Result))
                           .Where(r => r.IsSome)
                           .Map(r => r.IfNone(Result.Lose));

            var stat = StatService.Calculate(
                Constants.SameDiffPredictionName,
                sdResult);

            Assert.AreEqual(100, stat.WinRate);
        }
Пример #16
0
        public void BuildCharsStats_Positive()
        {
            var target = new StatService();
            var result = target.BuildCharsStats(_totalText, _chars);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.TotalCharsInText, _totalText.Length);
            Assert.IsNotNull(result.AllCharsOrderedByAppearance);
            Assert.AreEqual(result.AllCharsOrderedByAppearance.ElementAtOrDefault(0)?.AChar, 'e');
            Assert.AreEqual(result.AllCharsOrderedByAppearance.ElementAtOrDefault(4)?.AChar, 'a');
        }
Пример #17
0
        public void BuildWordsStats_Empty()
        {
            var target = new StatService();
            var result = target.BuildWordsStats(null);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.TotalWordsInText, 0);
            Assert.IsNull(result.FiveSmallest);
            Assert.IsNull(result.FiveLargest);
            Assert.IsNull(result.TenMostUsed);
        }
Пример #18
0
        public void BuildWordsStats_Positive()
        {
            var target = new StatService();
            var result = target.BuildWordsStats(_words);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.TotalWordsInText, 104);
            Assert.IsNotNull(result.FiveSmallest);
            Assert.AreEqual(result.FiveSmallest.ElementAtOrDefault(0)?.Text, "test");
            Assert.AreEqual(result.FiveLargest.ElementAtOrDefault(0)?.Text, "thebiggestone");
            Assert.AreEqual(result.TenMostUsed.ElementAtOrDefault(0)?.Text, "evenbigger");
        }
Пример #19
0
        private GameObject GetFromCache()
        {
            if (m_cached.Count > 0)
            {
                var go = m_cached[0];
                m_cached.RemoveSwapAt(0);
                StatService.Get().Increase(StatService.StatName.IN_POOL_GO, -1);
                return(go);
            }

            return(null);
        }
Пример #20
0
        public static void Recycle(GameObject go)
        {
            var cache = go.GetComponent <AssetServiceManagedGO>();

#if UNITY_DEBUG
            if (!cache)
            {
                Debug.LogError($"Recycle a destroy go : {go.name}");
                return;
            }
#endif
            cache.Recycle();
            StatService.Get().Increase(StatService.StatName.IN_USE_GO, -1);
        }
Пример #21
0
        public override void Destroy()
        {
            if (Status == AssetStatus.DONE)
            {
                StatService.Get().Increase(StatService.StatName.ASSET_COUNT, -1);
#if UNITY_DEBUG
                var service = CSharpServiceManager.Get <AssetFullStatService>(CSharpServiceManager.ServiceType.ASSET_FULL_STAT);
                service.OnAssetUnloaded(this);
#endif
            }
            Status      = AssetStatus.DESTROYED;
            UnityObject = null;
            RefAssetBundle?.Release();
            RefAssetBundle = null;
        }
Пример #22
0
        public ActionResult Stats()
        {
            List <UserStat> statistics;

            using (var statSvc = new StatService(ConfigurationManager.ConnectionStrings["db"].ConnectionString))
            {
                statistics = statSvc.GetStatistics().ToList();
            }
            var data = JsonConvert.SerializeObject(new
            {
                stats   = statistics,
                success = true
            });

            return(Content(data));
        }
Пример #23
0
        public void Update()
        {
            if (m_cached.Count == 0)
            {
                return;
            }

            if (m_cached.Count <= PreferSize)
            {
                return;
            }

            if (Time.time - m_cacheStart > 30)
            {
                Object.Destroy(m_cached[0]);
                StatService.Get().Increase(StatService.StatName.IN_POOL_GO, -1);
                m_cached.RemoveSwapAt(0);
            }
        }
Пример #24
0
        public virtual void SetAsset(Object unityObj, AssetBundleInstance refAssetBundle)
        {
            UnityObject = unityObj;
            if (refAssetBundle != null)
            {
                RefAssetBundle = refAssetBundle;
                RefAssetBundle.IncRef();
            }
            Status = UnityObject ? AssetStatus.DONE : AssetStatus.FAIL;
            if (Status == AssetStatus.DONE)
            {
                StatService.Get().Increase(StatService.StatName.ASSET_COUNT, 1);
                CreateTime = Time.realtimeSinceStartup;
#if UNITY_DEBUG
                var service = CSharpServiceManager.Get <AssetFullStatService>(CSharpServiceManager.ServiceType.ASSET_FULL_STAT);
                service.OnAssetLoaded(this);
#endif
            }
        }
Пример #25
0
        public void ANIMA_DICE_WHOOOOOO()
        {
            var rand = A.Fake <Random>();

            A.CallTo(rand)
            .WithReturnType <int>()
            .ReturnsNextFromSequence(
                50,                  // simple roll
                1, 100,              // critical failure
                95, 96, 95           // two critical success
                );

            var functionService = new FunctionService(rand);
            var statService     = new StatService(functionService);

            new Parser().Parse(out var expression,
                               @"
(
$IF{			$1 >= 95 + $2, 
					$1 + $D{1, 100, $ANIMA_DICE{$1, $IF {$2 = 5, 5, $2 + 1}}},
				$1 < 5,
					$1 - $D{1, 100},

					$1
			 }
)
",
                               new ParsingContext(statService, functionService)
            {
                FunctionId = new FunctionId("$ANIMA_DICE")
            }
                               ).Should().BeEmpty();
            functionService.Add(new UserFunction(new FunctionId("$ANIMA_DICE"), expression !));

            statService.Add("ROLL", "$D {1, 100, $ANIMA_DICE{$1, 0}}").Should().BeEmpty();

            statService.GetValue("ROLL").Should().Be(50);
            statService.GetValue("ROLL").Should().Be(-99);
            statService.GetValue("ROLL").Should().Be(286);
        }
Пример #26
0
        public void ParseDiceWithReroll()
        {
            var rand = A.Fake <Random>();

            A.CallTo(rand)
            .WithReturnType <int>()
            .ReturnsNextFromSequence(100, 17);

            var functionService = new FunctionService(rand);
            var statService     = new StatService(functionService);

            new Parser().Parse(out var expression,
                               @"$D{ 1, 100, $IF{ $1 >= 50, $F{ 0, $1 + $2 }, $1 + $2}",                             //reroll while rolling 50+
                               new ParsingContext(_statService, functionService)
            {
                FunctionId = new FunctionId("$F")
            }
                               ).Should().BeEmpty();

            functionService.Add(new UserFunction(new FunctionId("$F"), expression !)).Should().BeEmpty();
            statService.Add("A", "$F{ 0, 0 }").Should().BeEmpty();
            statService.GetValue("A").Should().Be(117);
        }
Пример #27
0
        // 开始检测收支平衡
        private void btnCheck_Click(object sender, EventArgs e)
        {
            StatService stat = ServiceMgr.getInstance().getSys <StatService>(ServiceType.serviceTypeStat);

            if (stat.isBusy())
            {
                MessageBox.Show("忙碌中,请稍候");
                return;
            }

            int playerId = 0;

            if (!int.TryParse(txtPlayerId.Text, out playerId))
            {
                MessageBox.Show("玩家ID非法");
                return;
            }

            DateTime mint = DateTime.Now, maxt = DateTime.Now;
            bool     res = Tool.splitTimeStr(txtGameTime.Text, ref mint, ref maxt);

            if (!res || mint.AddDays(1) != maxt)
            {
                MessageBox.Show("游戏时间非法");
                return;
            }

            ParamCheck param = new ParamCheck();

            param.m_gameId    = StrName.s_onlineGameIdList[m_gameList.SelectedIndex];
            param.m_playerId  = playerId;
            param.m_startTime = mint;
            param.m_endTime   = maxt;
            param.m_itemId    = s_itemId[m_moneyType.SelectedIndex];
            param.m_from      = this;
            stat.startCheck(param);
        }
Пример #28
0
        /// <summary>
        /// Creates an instance of <see cref="CharactersViewModel"/>
        /// </summary>
        public CharactersViewModel(Compendium compendium, CharacterSearchService characterSearchService, CharacterSearchInput characterSearchInput, StringService stringService,
                                   StatService statService, DialogService dialogService, XMLImporter xmlImporter, XMLExporter xmlExporter, DocumentService documentService, DataManager dataManager)
        {
            _compendium             = compendium;
            _characterSearchService = characterSearchService;
            _characterSearchInput   = characterSearchInput;
            _stringService          = stringService;
            _statService            = statService;
            _dialogService          = dialogService;
            _xmlImporter            = xmlImporter;
            _xmlExporter            = xmlExporter;
            _documentService        = documentService;
            _dataManager            = dataManager;

            _selectCharacterCommand     = new RelayCommand(obj => true, obj => SelectCharacter(obj as CharacterListItemViewModel));
            _editCharacterCommand       = new RelayCommand(obj => true, obj => EditCharacter(obj as CharacterViewModel));
            _exportCharacterCommand     = new RelayCommand(obj => true, obj => ExportCharacter(obj as CharacterViewModel));
            _cancelEditCharacterCommand = new RelayCommand(obj => true, obj => CancelEditCharacter());
            _saveEditCharacterCommand   = new RelayCommand(obj => HasUnsavedChanges, obj => SaveEditCharacter());
            _resetFiltersCommand        = new RelayCommand(obj => true, obj => InitializeSearch());
            _addCommand            = new RelayCommand(obj => true, obj => Add());
            _copyCommand           = new RelayCommand(obj => _selectedCharacter != null, obj => Copy());
            _deleteCommand         = new RelayCommand(obj => _selectedCharacter != null, obj => Delete());
            _importCommand         = new RelayCommand(obj => true, obj => Import());
            _selectNextCommand     = new RelayCommand(obj => true, obj => SelectNext());
            _selectPreviousCommand = new RelayCommand(obj => true, obj => SelectPrevious());

            _selectInfoEditCommand        = new RelayCommand(obj => true, obj => SelectInfoEdit());
            _selectLevelsEditCommand      = new RelayCommand(obj => true, obj => SelectLevelsEdit());
            _selectAbilitiesEditCommand   = new RelayCommand(obj => true, obj => SelectAbilitiesEdit());
            _selectProficiencyEditCommand = new RelayCommand(obj => true, obj => SelectProficiencyEdit());

            _compendium.CharacterChanged += _compendium_CharacterChanged;

            Search();
        }
Пример #29
0
        public void Cache(GameObject go)
        {
            if (m_cached.Count == 0)
            {
                m_cacheStart = Time.time;
            }

                        #if UNITY_DEBUG
            if (m_cached.Contains(go))
            {
                throw new Exception($"GameObject exist in pool {go.name}");
            }
                        #endif

            if (m_cached.Count >= MaxSize)
            {
                Object.Destroy(go);
                return;
            }

            go.transform.SetParent(PoolNode, false);
            StatService.Get().Increase(StatService.StatName.IN_POOL_GO, 1);
            m_cached.Add(go);
        }
 public StatServiceTests()
 {
     _statService = new StatService();
 }