private static async Task <SessionSummaryResult> GetSessionSummaryStatusAsync(bool forceRefresh = false)
        {
            SessionSummaryResult sessionSummaryResult = new SessionSummaryResult();

            _sessionSummary = getSessionSummayData();

            //if (SoftwareCoUtil.SessionSummaryFileExists())
            //{

            if (_sessionSummary.currentDayMinutes == 0 || forceRefresh)
            {
                bool online = await SoftwareUserSession.IsOnlineAsync();

                if (!online)
                {
                    sessionSummaryResult.sessionSummary = _sessionSummary;
                    sessionSummaryResult.status         = "OK";
                    updateStatusBarWithSummaryData();
                    return(sessionSummaryResult);
                }
                HttpResponseMessage response = await SoftwareHttpManager.SendRequestAsync(HttpMethod.Get, "/sessions/summary", null);

                if (SoftwareHttpManager.IsOk(response))
                {
                    string responseBody = await response.Content.ReadAsStringAsync();

                    IDictionary <string, object> jsonObj = (IDictionary <string, object>)SimpleJson.DeserializeObject(responseBody);
                    _sessionSummary = DictionaryToObject <SessionSummary>(jsonObj);

                    saveSessionSummaryToDisk(_sessionSummary);

                    updateStatusBarWithSummaryData();

                    sessionSummaryResult.sessionSummary = _sessionSummary;
                    sessionSummaryResult.status         = "OK";
                }
            }
            else
            {
                updateStatusBarWithSummaryData();
            }

            //}
            //else
            //{
            //    updateStatusBarWithSummaryData();
            //}

            sessionSummaryResult.sessionSummary = _sessionSummary;
            sessionSummaryResult.status         = "OK";
            return(sessionSummaryResult);
        }
示例#2
0
        public SessionSummary GetSessionSummayData()
        {
            if (!FileManager.SessionSummaryFileExists())
            {
                // create it
                SaveSessionSummaryToDisk(new SessionSummary());
            }

            string sessionSummary = FileManager.getSessionSummaryFileData();

            IDictionary <string, object> jsonObj = (IDictionary <string, object>)SimpleJson.DeserializeObject(sessionSummary, new Dictionary <string, object>());

            _sessionSummary = new SessionSummary();
            _sessionSummary = _sessionSummary.GetSessionSummaryFromDictionary(jsonObj);
            return(_sessionSummary);
        }
示例#3
0
        public void IncrementSessionSummaryData(KeystrokeAggregates aggregate, TimeGapData eTimeInfo)
        {
            _sessionSummary = GetSessionSummayData();

            if (eTimeInfo.session_seconds > 0)
            {
                _sessionSummary.currentDayMinutes += (eTimeInfo.session_seconds / 60);
            }

            long sessionSeconds = _sessionSummary.currentDayMinutes * 60;

            _sessionSummary.currentDayKeystrokes   += aggregate.keystrokes;
            _sessionSummary.currentDayLinesAdded   += aggregate.linesAdded;
            _sessionSummary.currentDayLinesRemoved += aggregate.linesRemoved;

            SaveSessionSummaryToDisk(_sessionSummary);
        }
 private static SessionSummary getSessionSummayData()
 {
     if (SoftwareCoUtil.SessionSummaryFileExists())
     {
         string sessionSummary = SoftwareCoUtil.getSessionSummaryFileData();
         if (!string.IsNullOrEmpty(sessionSummary))
         {
             IDictionary <string, object> jsonObj = (IDictionary <string, object>)SimpleJson.DeserializeObject(sessionSummary);
             _sessionSummary = DictionaryToObject <SessionSummary>(jsonObj);
         }
         else
         {
             return(_sessionSummary);
         }
     }
     return(_sessionSummary);
 }
        private static void saveSessionSummaryToDisk(SessionSummary sessionSummary)
        {
            string sessionSummaryFile = SoftwareCoUtil.getSessionSummaryFile();


            if (SoftwareCoUtil.SessionSummaryFileExists())
            {
                File.SetAttributes(sessionSummaryFile, FileAttributes.Normal);
            }

            try
            {
                //SoftwareCoUtil.WriteToFileThreadSafe(sessionSummary.GetSessionSummaryAsJson(), sessionSummaryFile);
                File.WriteAllText(sessionSummaryFile, sessionSummary.GetSessionSummaryAsJson());
                File.SetAttributes(sessionSummaryFile, FileAttributes.ReadOnly);
            }
            catch (Exception e)
            {
            }
        }
示例#6
0
        public void SaveSessionSummaryToDisk(SessionSummary sessionSummary)
        {
            string MethodName         = "saveSessionSummaryToDisk";
            string sessionSummaryFile = FileManager.getSessionSummaryFile();

            if (FileManager.SessionSummaryFileExists())
            {
                File.SetAttributes(sessionSummaryFile, FileAttributes.Normal);
            }

            try
            {
                string content = SimpleJson.SerializeObject(sessionSummary.GetSessionSummaryDict());
                content = content.Replace("\r\n", string.Empty).Replace("\n", string.Empty).Replace("\r", string.Empty);
                File.WriteAllText(sessionSummaryFile, content, System.Text.Encoding.UTF8);
            }
            catch (Exception e)
            {
                //
            }
        }
示例#7
0
        public async Task UpdateStatusBarWithSummaryDataAsync()
        {
            string MethodName = "UpdateStatusBarWithSummaryDataAsync";

            CodeTimeSummary ctSummary = TimeDataManager.Instance.GetCodeTimeSummary();

            string iconName = "";
            string currentDayMinutesTime = "";

            _sessionSummary = GetSessionSummayData();
            long averageDailyMinutesVal = _sessionSummary.averageDailyMinutes;

            currentDayMinutesTime = SoftwareCoUtil.HumanizeMinutes(ctSummary.activeCodeTimeMinutes);
            // string averageDailyMinutesTime = SoftwareCoUtil.HumanizeMinutes(averageDailyMinutesVal);

            // Code time today:  4 hrs | Avg: 3 hrs 28 min
            iconName = ctSummary.activeCodeTimeMinutes > averageDailyMinutesVal ? "rocket.png" : "cpaw.png";
            // string msg = string.Format("{0}{1}", inFlowIcon, currentDayMinutesTime);

            // it's ok not to await on this
            package.UpdateStatusBarButtonText(currentDayMinutesTime, iconName);
        }
        public async Task RebuildCodeMetricsAsync()
        {
            if (!SoftwareCoPackage.PLUGIN_READY)
            {
                return;
            }
            SessionSummary  summary   = SessionSummaryManager.Instance.GetSessionSummayData();
            CodeTimeSummary ctSummary = TimeDataManager.Instance.GetCodeTimeSummary();

            string editortimeToday = "Today: " + SoftwareCoUtil.HumanizeMinutes(ctSummary.codeTimeMinutes);

            if (Editortime.HasItems)
            {
                // update
                TreeViewItem parentItem = await GetParent(Editortime, "editortime");

                UpdateNodeValue(parentItem, "editortimetodayval", editortimeToday, "rocket.png");
            }
            else
            {
                List <TreeViewItem> editortimeChildren = new List <TreeViewItem>();
                editortimeChildren.Add(BuildMetricNode("editortimetodayval", editortimeToday, "rocket.png"));
                TreeViewItem editorParent = BuildMetricNodes("editortime", "Code time", editortimeChildren);
                Editortime.Items.Add(editorParent);
            }

            string codetimeBoltIcon = ctSummary.activeCodeTimeMinutes > summary.averageDailyMinutes ? "bolt.png" : "bolt-grey.png";
            string codetimeToday    = "Today: " + SoftwareCoUtil.HumanizeMinutes(ctSummary.activeCodeTimeMinutes);
            string codetimeAvg      = "Your average: " + SoftwareCoUtil.HumanizeMinutes(summary.averageDailyMinutes);
            string codetimeGlobal   = "Global average: " + SoftwareCoUtil.HumanizeMinutes(summary.globalAverageDailyMinutes);

            if (Codetime.HasItems)
            {
                // update
                TreeViewItem parentItem = await GetParent(Codetime, "codetime");

                UpdateNodeValue(parentItem, "codetimetodayval", codetimeToday, "rocket.png");
                UpdateNodeValue(parentItem, "codetimeavgval", codetimeAvg, codetimeBoltIcon);
                UpdateNodeValue(parentItem, "codetimeglobalval", codetimeGlobal, "global-grey.png");
            }
            else
            {
                List <TreeViewItem> codetimeChildren = new List <TreeViewItem>();
                codetimeChildren.Add(BuildMetricNode("codetimetodayval", codetimeToday, "rocket.png"));
                codetimeChildren.Add(BuildMetricNode("codetimeavgval", codetimeAvg, codetimeBoltIcon));
                codetimeChildren.Add(BuildMetricNode("codetimeglobalval", codetimeGlobal, "global-grey.png"));
                TreeViewItem codetimeParent = BuildMetricNodes("codetime", "Active code time", codetimeChildren);
                Codetime.Items.Add(codetimeParent);
            }

            string linesaddedBoltIcon = summary.currentDayLinesAdded > summary.averageDailyLinesAdded ? "bolt.png" : "bolt-grey.png";
            string linesaddedToday    = "Today: " + SoftwareCoUtil.FormatNumber(summary.currentDayLinesAdded);
            string linesaddedAvg      = "Your average: " + SoftwareCoUtil.FormatNumber(summary.averageDailyLinesAdded);
            string linesaddedGlobal   = "Global average: " + SoftwareCoUtil.FormatNumber(summary.globalAverageLinesAdded);

            if (Linesadded.HasItems)
            {
                // update
                TreeViewItem parentItem = await GetParent(Linesadded, "linesadded");

                UpdateNodeValue(parentItem, "linesaddedtodayval", linesaddedToday, "rocket.png");
                UpdateNodeValue(parentItem, "linesaddedavgval", linesaddedAvg, linesaddedBoltIcon);
                UpdateNodeValue(parentItem, "linesaddedglobalval", linesaddedGlobal, "global-grey.png");
            }
            else
            {
                List <TreeViewItem> linesaddedChildren = new List <TreeViewItem>();
                linesaddedChildren.Add(BuildMetricNode("linesaddedtodayval", linesaddedToday, "rocket.png"));
                linesaddedChildren.Add(BuildMetricNode("linesaddedavgval", linesaddedAvg, linesaddedBoltIcon));
                linesaddedChildren.Add(BuildMetricNode("linesaddedglobalval", linesaddedGlobal, "global-grey.png"));
                TreeViewItem linesaddedParent = BuildMetricNodes("linesadded", "Lines added", linesaddedChildren);
                Linesadded.Items.Add(linesaddedParent);
            }

            string linesremovedBoltIcon = summary.currentDayLinesRemoved > summary.averageDailyLinesRemoved ? "bolt.png" : "bolt-grey.png";
            string linesremovedToday    = "Today: " + SoftwareCoUtil.FormatNumber(summary.currentDayLinesRemoved);
            string linesremovedAvg      = "Your average: " + SoftwareCoUtil.FormatNumber(summary.averageDailyLinesRemoved);
            string linesremovedGlobal   = "Global average: " + SoftwareCoUtil.FormatNumber(summary.globalAverageLinesRemoved);

            if (Linesremoved.HasItems)
            {
                // update
                TreeViewItem parentItem = await GetParent(Codetime, "linesremoved");

                UpdateNodeValue(parentItem, "linesremovedtodayval", linesremovedToday, "rocket.png");
                UpdateNodeValue(parentItem, "linesremovedavgval", linesremovedAvg, linesremovedBoltIcon);
                UpdateNodeValue(parentItem, "linesremovedglobalval", linesremovedGlobal, "global-grey.png");
            }
            else
            {
                List <TreeViewItem> linesremovedChildren = new List <TreeViewItem>();
                linesremovedChildren.Add(BuildMetricNode("linesremovedtodayval", linesremovedToday, "rocket.png"));
                linesremovedChildren.Add(BuildMetricNode("linesremovedavgval", linesremovedAvg, linesremovedBoltIcon));
                linesremovedChildren.Add(BuildMetricNode("linesremovedglobalval", linesremovedGlobal, "global-grey.png"));
                TreeViewItem linesremovedParent = BuildMetricNodes("linesremoved", "Lines removed", linesremovedChildren);
                Linesremoved.Items.Add(linesremovedParent);
            }

            string keystrokesBoltIcon = summary.currentDayLinesRemoved > summary.averageDailyLinesRemoved ? "bolt.png" : "bolt-grey.png";
            string keystrokesToday    = "Today: " + SoftwareCoUtil.FormatNumber(summary.currentDayKeystrokes);
            string keystrokesAvg      = "Your average: " + SoftwareCoUtil.FormatNumber(summary.averageDailyKeystrokes);
            string keystrokesGlobal   = "Global average: " + SoftwareCoUtil.FormatNumber(summary.globalAverageDailyKeystrokes);

            if (Keystrokes.HasItems)
            {
                // update
                TreeViewItem parentItem = await GetParent(Keystrokes, "keystrokes");

                UpdateNodeValue(parentItem, "keystrokestodayval", keystrokesToday, "rocket.png");
                UpdateNodeValue(parentItem, "keystrokesavgval", keystrokesAvg, keystrokesBoltIcon);
                UpdateNodeValue(parentItem, "keystrokesglobalval", keystrokesGlobal, "global-grey.png");
            }
            else
            {
                List <TreeViewItem> keystrokeChildren = new List <TreeViewItem>();
                keystrokeChildren.Add(BuildMetricNode("keystrokestodayval", keystrokesToday, "rocket.png"));
                keystrokeChildren.Add(BuildMetricNode("keystrokesavgval", keystrokesAvg, keystrokesBoltIcon));
                keystrokeChildren.Add(BuildMetricNode("keystrokesglobalval", keystrokesGlobal, "global-grey.png"));
                TreeViewItem keystrokesParent = BuildMetricNodes("keystrokes", "Keystrokes", keystrokeChildren);
                Keystrokes.Items.Add(keystrokesParent);
            }

            // get the top keystrokes and code time files
            List <FileChangeInfo> topKeystrokeFiles = FileChangeInfoDataManager.Instance.GetTopKeystrokeFiles();

            if (topKeystrokeFiles.Count == 0)
            {
                TopKeystrokeFiles.Visibility = Visibility.Hidden;
            }
            else
            {
                TopKeystrokeFiles.Visibility = Visibility.Visible;
                // add or update

                if (TopKeystrokeFiles.HasItems)
                {
                    /**
                     * TreeViewItem parentItem = await GetParent(TopKeystrokeFiles, "topcodetimefiles");
                     * foreach (FileChangeInfo changeInfo in topKeystrokeFiles)
                     * {
                     *  string keystrokeNumStr = SoftwareCoUtil.FormatNumber(changeInfo.keystrokes);
                     *  string label = changeInfo.name + " | " + keystrokeNumStr;
                     *  UpdateNodeValue(parentItem, "topkeystrokes-" + changeInfo.name, label, "files.png");
                     * }
                     **/
                }
                List <TreeViewItem> topKeystrokeChildren = new List <TreeViewItem>();
                foreach (FileChangeInfo changeInfo in topKeystrokeFiles)
                {
                    string keystrokeNumStr = SoftwareCoUtil.FormatNumber(changeInfo.keystrokes);
                    string label           = changeInfo.name + " | " + keystrokeNumStr;
                    topKeystrokeChildren.Add(BuildMetricNode("topkeystrokes-" + changeInfo.name, label, "files.png"));
                }
                if (topKeystrokesParent == null)
                {
                    topKeystrokesParent = BuildMetricNodes("topkeystrokesfiles", "Top files by keystrokes", topKeystrokeChildren);
                    TopKeystrokeFiles.Items.Add(topKeystrokesParent);
                }
                else
                {
                    topKeystrokesParent.Items.Clear();
                    foreach (TreeViewItem item in topKeystrokeChildren)
                    {
                        topKeystrokesParent.Items.Add(item);
                    }
                }
            }
            List <FileChangeInfo> topCodetimeFiles = FileChangeInfoDataManager.Instance.GetTopCodeTimeFiles();

            if (topCodetimeFiles.Count == 0)
            {
                TopCodeTimeFiles.Visibility = Visibility.Hidden;
            }
            else
            {
                TopCodeTimeFiles.Visibility = Visibility.Visible;
                // add or update

                if (TopCodeTimeFiles.HasItems)
                {
                    /**
                     * TreeViewItem parentItem = await GetParent(TopCodeTimeFiles, "topcodetimefiles");
                     * foreach (FileChangeInfo changeInfo in topCodetimeFiles)
                     * {
                     *  string codetimeMinStr = SoftwareCoUtil.HumanizeMinutes(changeInfo.duration_seconds / 60);
                     *  string label = changeInfo.name + " | " + codetimeMinStr;
                     *  UpdateNodeValue(parentItem, "topcodetime-" + changeInfo.name, label, "files.png");
                     * }
                     **/
                }
                List <TreeViewItem> topCodetimeFilesChildren = new List <TreeViewItem>();
                foreach (FileChangeInfo changeInfo in topCodetimeFiles)
                {
                    string codetimeMinStr = SoftwareCoUtil.HumanizeMinutes(changeInfo.duration_seconds / 60);
                    string label          = changeInfo.name + " | " + codetimeMinStr;
                    topCodetimeFilesChildren.Add(BuildMetricNode("topcodetime-" + changeInfo.name, label, "files.png"));
                }
                if (topCodetimeParent == null)
                {
                    topCodetimeParent = BuildMetricNodes("topcodetimefiles", "Top files by code time", topCodetimeFilesChildren);
                    TopCodeTimeFiles.Items.Add(topCodetimeParent);
                }
                else
                {
                    topCodetimeParent.Items.Clear();
                    foreach (TreeViewItem item in topCodetimeFilesChildren)
                    {
                        topCodetimeParent.Items.Add(item);
                    }
                }
            }
        }
示例#9
0
        private async Task FetchCodeTimeDashboardAsync()
        {
            string summaryContent  = "";
            string summaryInfoFile = FileManager.getSessionSummaryInfoFile();

            bool online = await SoftwareUserSession.IsOnlineAsync();


            HttpResponseMessage resp =
                await SoftwareHttpManager.SendDashboardRequestAsync(HttpMethod.Get, "/dashboard?showMusic=false&showGit=false&showRank=false&showToday=false");

            if (SoftwareHttpManager.IsOk(resp))
            {
                summaryContent += await resp.Content.ReadAsStringAsync();
            }
            else
            {
                summaryContent = NO_DATA;
            }


            if (File.Exists(summaryInfoFile))
            {
                File.SetAttributes(summaryInfoFile, FileAttributes.Normal);
            }

            try
            {
                File.WriteAllText(summaryInfoFile, summaryContent, System.Text.Encoding.UTF8);
            }
            catch (Exception e)
            {
            }

            string dashboardFile    = FileManager.getDashboardFile();
            string dashboardContent = "";
            string suffix           = SoftwareCoUtil.CreateDateSuffix(DateTime.Now);
            string formattedDate    = DateTime.Now.ToString("ddd, MMM ") + suffix + DateTime.Now.ToString(" h:mm tt");

            dashboardContent  = "CODE TIME          " + "(Last updated on " + formattedDate + " )";
            dashboardContent += "\n\n";

            string todayDate  = DateTime.Now.ToString("ddd, MMM ") + suffix;
            string today_date = "Today " + "(" + todayDate + ")";

            dashboardContent += SoftwareCoUtil.getSectionHeader(today_date);

            SessionSummary  _sessionSummary = SessionSummaryManager.Instance.GetSessionSummayData();
            CodeTimeSummary ctSummary       = TimeDataManager.Instance.GetCodeTimeSummary();

            string codeTimeMinutes = SoftwareCoUtil.HumanizeMinutes(ctSummary.codeTimeMinutes);

            dashboardContent += SoftwareCoUtil.getDashboardRow("Code time today", codeTimeMinutes);
            string activeCodeTimeMinutes = SoftwareCoUtil.HumanizeMinutes(ctSummary.activeCodeTimeMinutes);

            dashboardContent += SoftwareCoUtil.getDashboardRow("Active code time today", activeCodeTimeMinutes);
            if (_sessionSummary != null)
            {
                string averageTime = SoftwareCoUtil.HumanizeMinutes(_sessionSummary.averageDailyMinutes);

                String liveshareTime = "";
                //if (_sessionSummary.liveshareMinutes != 0)
                //{
                //    liveshareTime = SoftwareCoUtil.HumanizeMinutes(_sessionSummary.liveshareMinutes);
                //}

                dashboardContent += SoftwareCoUtil.getDashboardRow("90-day avg", averageTime);
                //if (liveshareTime != "0")
                //{
                //    dashboardContent += SoftwareCoUtil.getDashboardRow("Live Share", liveshareTime);
                //}
                dashboardContent += "\n";
            }

            if (FileManager.SessionSummaryInfoFileExists())
            {
                string SummaryData = FileManager.getSessionSummaryInfoFileData();
                dashboardContent += SummaryData;
            }


            if (File.Exists(dashboardFile))
            {
                File.SetAttributes(dashboardFile, FileAttributes.Normal);
            }
            try
            {
                File.WriteAllText(dashboardFile, dashboardContent, System.Text.Encoding.UTF8);
            }
            catch (Exception e)
            {
            }
        }
示例#10
0
 public void ÇlearSessionSummaryData()
 {
     _sessionSummary = new SessionSummary();
     SaveSessionSummaryToDisk(_sessionSummary);
 }
        private static async Task FetchCodeTimeDashboardAsync(SessionSummary _sessionSummary)
        {
            string summaryContent  = "";
            string summaryInfoFile = SoftwareCoUtil.getSessionSummaryInfoFile();

            bool online = await SoftwareUserSession.IsOnlineAsync();

            long diff = SoftwareCoUtil.getNowInSeconds() - lastDashboardFetchTime;

            if (lastDashboardFetchTime == 0 || diff >= day_in_sec || !online)
            {
                if (!online)
                {
                    lastDashboardFetchTime = 0;
                }
                else
                {
                    lastDashboardFetchTime = SoftwareCoUtil.getNowInSeconds();
                }

                HttpResponseMessage resp =
                    await SoftwareHttpManager.SendDashboardRequestAsync(HttpMethod.Get, "/dashboard?showMusic=false&showGit=false&showRank=false&showToday=false");

                if (SoftwareHttpManager.IsOk(resp))
                {
                    summaryContent += await resp.Content.ReadAsStringAsync();
                }
                else
                {
                    summaryContent = NO_DATA;
                }


                if (File.Exists(summaryInfoFile))
                {
                    File.SetAttributes(summaryInfoFile, FileAttributes.Normal);
                }

                try
                {
                    File.WriteAllText(summaryInfoFile, summaryContent);
                    File.SetAttributes(summaryInfoFile, FileAttributes.ReadOnly);
                }
                catch (Exception e)
                {
                }
            }
            string dashboardFile    = SoftwareCoUtil.getDashboardFile();
            string dashboardContent = "";
            string suffix           = SoftwareCoUtil.CreateDateSuffix(DateTime.Now);
            string formattedDate    = DateTime.Now.ToString("ddd, MMM ") + suffix + DateTime.Now.ToString(" h:mm tt");

            dashboardContent  = "CODE TIME          " + "(Last updated on " + formattedDate + " )";
            dashboardContent += "\n\n";

            string todayDate  = DateTime.Now.ToString("ddd, MMM ") + suffix;
            string today_date = "Today " + "(" + todayDate + ")";

            dashboardContent += SoftwareCoUtil.getSectionHeader(today_date);

            if (_sessionSummary != null)
            {
                string averageTime     = SoftwareCoUtil.HumanizeMinutes(_sessionSummary.averageDailyMinutes);
                string hoursCodedToday = SoftwareCoUtil.HumanizeMinutes(_sessionSummary.currentDayMinutes);
                String liveshareTime   = "";
                //if (_sessionSummary.liveshareMinutes != 0)
                //{
                //    liveshareTime = SoftwareCoUtil.HumanizeMinutes(_sessionSummary.liveshareMinutes);
                //}
                dashboardContent += SoftwareCoUtil.getDashboardRow("Hours Coded", hoursCodedToday);
                dashboardContent += SoftwareCoUtil.getDashboardRow("90-day avg", averageTime);
                //if (liveshareTime != "0")
                //{
                //    dashboardContent += SoftwareCoUtil.getDashboardRow("Live Share", liveshareTime);
                //}
                dashboardContent += "\n";
            }

            if (SoftwareCoUtil.SessionSummaryInfoFileExists())
            {
                string SummaryData = SoftwareCoUtil.getSessionSummaryInfoFileData();
                dashboardContent += SummaryData;
            }


            if (File.Exists(dashboardFile))
            {
                File.SetAttributes(dashboardFile, FileAttributes.Normal);
            }
            try
            {
                //SoftwareCoUtil.WriteToFileThreadSafe(dashboardContent, dashboardFile);
                File.WriteAllText(dashboardFile, dashboardContent);
                File.SetAttributes(dashboardFile, FileAttributes.ReadOnly);
            }
            catch (Exception e)
            {
            }
        }
 private void incrementSessionSummaryData(int minute, long keystrokes)
 {
     _sessionSummary = getSessionSummayData();
     _sessionSummary.currentDayMinutes    += minute;
     _sessionSummary.currentDayKeystrokes += keystrokes;
 }
        public async Task InitializeListenersAsync()
        {
            await JoinableTaskFactory.SwitchToMainThreadAsync(DisposalToken);

            try
            {
                string PluginVersion = GetVersion();
                Logger.Info(string.Format("Initializing Code Time v{0}", PluginVersion));

                // VisualStudio Object
                Events2 events = (Events2)ObjDte.Events;
                _textDocKeyEvent = events.TextDocumentKeyPressEvents;
                _docEvents       = ObjDte.Events.DocumentEvents;

                // setup event handlers
                _textDocKeyEvent.AfterKeyPress += AfterKeyPressedAsync;
                _docEvents.DocumentOpened      += DocEventsOnDocumentOpenedAsync;
                _docEvents.DocumentClosing     += DocEventsOnDocumentClosedAsync;
                _docEvents.DocumentSaved       += DocEventsOnDocumentSaved;
                _docEvents.DocumentOpening     += DocEventsOnDocumentOpeningAsync;

                //initialize the StatusBar
                await InitializeSoftwareStatusAsync();

                if (_sessionSummary == null)
                {
                    _sessionSummary = new SessionSummary();
                }
                // initialize the menu commands
                await SoftwareLaunchCommand.InitializeAsync(this);

                await SoftwareDashboardLaunchCommand.InitializeAsync(this);

                await SoftwareTopFortyCommand.InitializeAsync(this);

                await SoftwareLoginCommand.InitializeAsync(this);

                await SoftwareToggleStatusInfoCommand.InitializeAsync(this);

                if (_softwareRepoUtil == null)
                {
                    _softwareRepoUtil = new SoftwareRepoManager();
                }



                // Create an AutoResetEvent to signal the timeout threshold in the
                // timer callback has been reached.
                var autoEvent = new AutoResetEvent(false);

                // setup timer to process events every 1 minute
                timer = new System.Threading.Timer(
                    ProcessSoftwareDataTimerCallbackAsync,
                    autoEvent,
                    ONE_MINUTE,
                    ONE_MINUTE);

                offlineDataTimer = new System.Threading.Timer(
                    SendOfflineData,
                    null,
                    THIRTY_MINUTES,
                    THIRTY_MINUTES);

                // this.SendOfflineData();

                // start in 5 seconds every 5 min
                //int delay = 1000 * 5;
                //kpmTimer = new System.Threading.Timer(
                //    ProcessFetchDailyKpmTimerCallbackAsync,
                //    autoEvent,
                //    delay,
                //    ONE_MINUTE * 5);

                int delay = 1000 * 45;

                delay            = ONE_MINUTE + (1000 * 10);
                repoCommitsTimer = new System.Threading.Timer(
                    ProcessHourlyJobs,
                    autoEvent,
                    delay,
                    ONE_HOUR);

                musicTimer = new System.Threading.Timer(
                    ProcessMusicTracksAsync,
                    autoEvent,
                    1000 * 5,
                    1000 * 30);

                statusMsgTimer = new System.Threading.Timer(
                    UpdateStatusMsg,
                    autoEvent,
                    1000 * 30,
                    1000 * 10);

                userStatusTimer = new System.Threading.Timer(
                    UpdateUserStatus,
                    autoEvent,
                    ONE_MINUTE,
                    1000 * 120);

                this.InitializeUserInfo();
            }
            catch (Exception ex)
            {
                Logger.Error("Error Initializing SoftwareCo", ex);
            }
        }