Exemple #1
0
        public ControlService()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            logger.Trace("Initialize ControlService.");
            Settings.Update();

            //enure existence of all databases
            using (var c = new LogConnection()) { }
            using (var c = new StatisticsConnection()) { }

            CanStop             = true;
            CanShutdown         = true;
            CanPauseAndContinue = true;
            ServiceName         = "CrossoutLogView.ControlService";

            fsWatcher = new FileSystemWatcher();
            fsWatcher.EnableRaisingEvents   = false;
            fsWatcher.IncludeSubdirectories = true;
            fsWatcher.NotifyFilter          = NotifyFilters.CreationTime | NotifyFilters.FileName;
            fsWatcher.Path     = Settings.Current.LogRootPath;
            fsWatcher.Created += FileCreated;
            fsWatcher.Filter   = "combat.log";

            logChangeTrackTimer          = new Timer();
            logChangeTrackTimer.Enabled  = false;
            logChangeTrackTimer.Interval = 2000.0;
            logChangeTrackTimer.Elapsed += FileChangedElapsed;

            uploader = new StatisticsUploader(Settings.Current.StatisticsParseDateTime);

            logger.Trace("Initialized ControlService.");
        }
        public List <Task> getTasksByState(String state)
        {
            state = state.ToLower().Trim();
            int _state = -1;

            switch (state)
            {
            case "not selected":
                _state = (int)TaskState.UNSELECTED;
                break;

            case "ongoing":
                _state = (int)TaskState.ONGOING;
                break;

            case "finished":
                _state = (int)TaskState.FINISHED;
                break;

            case "abandoned":
                _state = (int)TaskState.ABANDONED;
                break;

            case "cancelled":
                _state = (int)TaskState.CANCELLED;
                break;
            }

            return(StatisticsConnection.readStatusTasks(_state));
        }
        private void InternalCommit(IEnumerable <ILogEntry> delta)
        {
            if (delta == null)
            {
                return;
            }

            bool hasFinish = false;

            using (var en = delta.GetEnumerator())
            {
                while (en.MoveNext())
                {
                    if (en.Current.TimeStamp > LogEntryTimeStampLowerLimit)
                    {
                        LogEntryTimeStampLowerLimit = en.Current.TimeStamp;
                    }
                    if (en.Current is LevelLoad ll)
                    {
                        if (yield)
                        {
                            if (!hasFinish)
                            {
                                gameLog.Add(DummyGameFinish(gameLog[gameLog.Count - 1].TimeStamp + 1));
                            }
                            FinalizeGameLog();
                        }
                        yield     = !IgnoreLevel(ll);
                        hasFinish = false;
                    }
                    if (yield)
                    {
                        gameLog.Add(en.Current);
                        if (en.Current is GameFinish)
                        {
                            hasFinish = true;
                        }
                    }
                }
            }
            if (games.Count != 0) //games were finished in the added logs
            {
                var users   = User.Parse(games);
                var weapons = WeaponGlobal.ParseWeapons(games);
                using (var statCon = new StatisticsConnection())
                {
                    using (var trans = statCon.BeginTransaction())
                    {
                        statCon.Insert(games);
                        trans.Commit();
                    }
                    using (var trans = statCon.BeginTransaction())
                    {
                        for (int i = 0; i < users.Count; i++)
                        {
                            statCon.UpdateUser(users[i]);
                        }
                        trans.Commit();
                    }
                    using (var trans = statCon.BeginTransaction())
                    {
                        for (int i = 0; i < weapons.Count; i++)
                        {
                            statCon.UpdateWeaponGlobal(weapons[i]);
                        }
                        trans.Commit();
                    }
                }
                if (OperatingMode == UploaderOperatingMode.Incremental)
                {
                    var userIDs     = users.Select(x => x.UserID);
                    var weaponNames = weapons.Select(x => x.Name);
                    var maps        = games.Select(x => x.Map.Name).Distinct();
                    //send event invalidating changed data
                    logger.Info("Invalidate existing data. {0} different maps played. {1} user changed. {2} weapons changed.", maps.Count(), userIDs.Count(), weapons.Count());
                    InvalidateCachedData?.Invoke(this, new InvalidateCachedDataEventArgs(userIDs, weaponNames, maps));
                }
                games.Clear();
            }
        }
 public List <spGetRankingEmployee_Result> getRankingEmployees(DateTime begin, DateTime end)
 {
     return(StatisticsConnection.readRankingEmployee(begin, end));
 }
 public List <spGetRankingTeam_Result> getRankingTeams(DateTime begin, DateTime end)
 {
     return(StatisticsConnection.readRankingTeams(begin, end));
 }
 public List <Task> getTasksByEmployee(String dni)
 {
     return(StatisticsConnection.readTasksByEmployee(dni));
 }
 public List <Task> getTasksByTeam(String code)
 {
     return(StatisticsConnection.readTasksByTeam(code));
 }
 public List <Task> getTasksByDate(DateTime begin, DateTime end)
 {
     return(StatisticsConnection.readTasksByDate(begin, end));
 }