示例#1
0
        private async Task ValidateAndUpdateCumulativeDataAsync(long session_seconds)
        {
            TimeData td = await TimeDataManager.Instance.UpdateSessionAndFileSecondsAsync(this.project, session_seconds);

            // get the current payloads so we can compare our last cumulative seconds
            PluginData lastKpm = FileManager.GetLastSavedKeystrokeStats();

            if (SoftwareCoUtil.IsNewDay())
            {
                // the days don't match. don't use the editor or session seconds for a different day
                lastKpm = null;
                // clear out data from the previous day
                await WallclockManager.Instance.GetNewDayCheckerAsync();

                if (td != null)
                {
                    td = null;
                    this.project_null_error = "TimeData should be null as its a new day";
                }
            }

            this.workspace_name             = SoftwareCoUtil.workspace_name;
            this.hostname                   = SoftwareCoUtil.getHostname();
            this.cumulative_session_seconds = 60;
            this.cumulative_editor_seconds  = 60;

            if (td != null)
            {
                this.cumulative_editor_seconds  = td.editor_seconds;
                this.cumulative_session_seconds = td.session_seconds;
            }
            else if (lastKpm != null)
            {
                // no time data found, project null error
                this.project_null_error         = "TimeData not found using " + this.project.directory + " for editor and session seconds";
                this.cumulative_editor_seconds  = lastKpm.cumulative_editor_seconds + 60;
                this.cumulative_session_seconds = lastKpm.cumulative_session_seconds + 60;
            }

            if (this.cumulative_editor_seconds < this.cumulative_session_seconds)
            {
                this.cumulative_editor_seconds = cumulative_session_seconds;
            }
        }
        public async Task GetNewDayCheckerAsync()
        {
            if (SoftwareCoUtil.IsNewDay())
            {
                SessionSummaryManager.Instance.ÇlearSessionSummaryData();

                // send the offline data
                SoftwareCoPackage.SendOfflinePluginBatchData();

                // clear the last payload in memory
                FileManager.ClearLastSavedKeystrokeStats();

                // send the offline events
                EventManager.Instance.SendOfflineEvents();

                // send the offline TimeData payloads
                // this will clear the time data summary as well
                TimeDataManager.Instance.SendTimeDataAsync();

                // day does't match. clear the wall clock time,
                // the session summary, time data summary,
                // and the file change info summary data
                ClearWcTime();

                // set the current day
                NowTime nowTime = SoftwareCoUtil.GetNowTime();
                _currentDay = nowTime.day;

                // update the current day
                FileManager.setItem("currentDay", _currentDay);
                // update the last payload timestamp
                FileManager.setNumericItem("latestPayloadTimestampEndUtc", 0);

                // update the session summary global and averages for the new day
                Task.Delay(ONE_MINUTE).ContinueWith((task) => { WallclockManager.Instance.UpdateSessionSummaryFromServerAsync(); });
            }
        }