示例#1
0
        static void Replay_Created(object sender, FileSystemEventArgs e)
        {
            try
            {
                Thread.Sleep(3000);

                if (!FileInvestigator.IsFileFree(e.FullPath, 25))
                {
                    return;
                }

                ReplayMapper mapper = new ReplayMapper(Config.PlayerName);
                var          match  = mapper.ParseReplay(e.FullPath);

                if (match != null)
                {
                    MatchViewModel.ProcessMatch(match);
                    dataStore.AddMatch(match);
                }
                dataStore.Save();
                ApplicationState.MatchViewModel.UpdateBindings();
            }
            catch (Exception)
            { }
        }
示例#2
0
        internal static void InitializeData()
        {
            dataStore = new MatchPersister(Config.PlayerName);

            Task.Factory.StartNew(() =>
            {
                try
                {
                    LoadingVM.UpdateLoadingText("Checking for Stored Matches");

                    var savedMatches = dataStore.GetMatches();

                    if (savedMatches.Count() > 0)
                    {
                        LoadingVM.UpdateLoadingText("Processing Stored Matches");
                    }

                    MatchViewModel.ProcessMatches(savedMatches);

                    ReplayMapper mapper = new ReplayMapper(Config.PlayerName);

                    var baseDir = Config.ReplayPath;
                    var files   = Directory.GetFiles(baseDir, "*.stormreplay").Where(f => !savedMatches.Select(m => m.FileName).Contains(f.Split('\\').Last()));

                    Parallel.ForEach(files, file =>
                    {
                        var match = mapper.ParseReplay(file);

                        if (match != null)
                        {
                            LoadingVM.UpdateLoadingText("Processing " + match.FileName);
                            MatchViewModel.ProcessMatch(match);
                            dataStore.AddMatch(match);
                        }
                    });

                    dataStore.Save();

                    LoadingVM.UpdateLoadingText("Done!");

                    MatchViewModel.UpdateBindings();

                    loadDefaultView();
                    InitializeReplayWatcher();
                }
                catch (Exception ex)
                {
                    Logger.Log("Error initializing data: " + ex.ToString());
                    MessageBox.Show("Error loading replay data, for assistance please open a ticket at https://github.com/Stickymaddness/StormVault and include your error.log file.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            });
        }