Example #1
0
        public static CommitInfo GetLastCommitInfo(string projectDir, string email)
        {
            if (!SoftwareCoUtil.IsGitProject(projectDir))
            {
                return(new CommitInfo());
            }
            CommitInfo commitInfo = new CommitInfo();

            string authorArg = (email != null) ? " --author=" + email + " " : " ";
            string cmd       = "git log --pretty=%H,%s" + authorArg + "--max-count=1";

            List <string> results = SoftwareCoUtil.GetCommandResultList(cmd, projectDir);

            if (results != null && results.Count > 0)
            {
                string[] parts = results[0].Split(',');
                if (parts != null && parts.Length == 2)
                {
                    commitInfo.commitId = parts[0];
                    commitInfo.comment  = parts[1];
                    commitInfo.email    = email;
                }
            }

            return(commitInfo);
        }
Example #2
0
        public SessionSummary GetSessionSummaryFromDictionary(IDictionary <string, object> dict)
        {
            SessionSummary sessionSummary = new SessionSummary();

            sessionSummary.currentDayMinutes            = SoftwareCoUtil.ConvertObjectToLong(dict, "currentDayMinutes");
            sessionSummary.currentDayKeystrokes         = SoftwareCoUtil.ConvertObjectToLong(dict, "currentDayKeystrokes");
            sessionSummary.currentDayKpm                = SoftwareCoUtil.ConvertObjectToLong(dict, "currentDayKpm");
            sessionSummary.currentDayLinesAdded         = SoftwareCoUtil.ConvertObjectToLong(dict, "currentDayLinesAdded");
            sessionSummary.currentDayLinesRemoved       = SoftwareCoUtil.ConvertObjectToLong(dict, "currentDayLinesRemoved");
            sessionSummary.averageDailyKeystrokes       = SoftwareCoUtil.ConvertObjectToLong(dict, "averageDailyKeystrokes");
            sessionSummary.averageDailyKpm              = SoftwareCoUtil.ConvertObjectToLong(dict, "averageDailyKpm");
            sessionSummary.averageDailyLinesAdded       = SoftwareCoUtil.ConvertObjectToLong(dict, "averageDailyLinesAdded");
            sessionSummary.averageDailyLinesRemoved     = SoftwareCoUtil.ConvertObjectToLong(dict, "averageDailyLinesRemoved");
            sessionSummary.averageDailyMinutes          = SoftwareCoUtil.ConvertObjectToLong(dict, "averageDailyMinutes");
            sessionSummary.globalAverageDailyKeystrokes = SoftwareCoUtil.ConvertObjectToLong(dict, "globalAverageDailyKeystrokes");
            sessionSummary.globalAverageDailyMinutes    = SoftwareCoUtil.ConvertObjectToLong(dict, "globalAverageDailyMinutes");
            sessionSummary.globalAverageLinesAdded      = SoftwareCoUtil.ConvertObjectToLong(dict, "globalAverageLinesAdded");
            sessionSummary.globalAverageLinesRemoved    = SoftwareCoUtil.ConvertObjectToLong(dict, "globalAverageLinesRemoved");
            sessionSummary.globalAverageSeconds         = SoftwareCoUtil.ConvertObjectToLong(dict, "globalAverageSeconds");

            sessionSummary.latestPayloadTimestamp       = SoftwareCoUtil.ConvertObjectToLong(dict, "latestPayloadTimestamp");
            sessionSummary.latestPayloadTimestampEndUtc = SoftwareCoUtil.ConvertObjectToLong(dict, "latestPayloadTimestampEndUtc");
            sessionSummary.timePercent      = SoftwareCoUtil.ConvertObjectToDouble(dict, "timePercent");
            sessionSummary.velocityPercent  = SoftwareCoUtil.ConvertObjectToDouble(dict, "velocityPercent");
            sessionSummary.volumePercent    = SoftwareCoUtil.ConvertObjectToDouble(dict, "volumePercent");
            sessionSummary.dailyMinutesGoal = SoftwareCoUtil.ConvertObjectToInt(dict, "dailyMinutesGoal");
            sessionSummary.liveshareMinutes = SoftwareCoUtil.ConvertObjectToInt(dict, "liveshareMinutes");

            sessionSummary.inflow           = SoftwareCoUtil.ConvertObjectToBool(dict, "inflow");
            sessionSummary.lastUpdatedToday = SoftwareCoUtil.ConvertObjectToBool(dict, "lastUpdatedToday");

            return(sessionSummary);
        }
        public static TreeViewItem BuildTreeItem(string id, string text, string iconName = null)
        {
            CodeMetricsTreeItem treeItem = new CodeMetricsTreeItem(id);

            // create a stack panel
            StackPanel stack = new StackPanel();

            stack.Orientation = Orientation.Horizontal;

            if (!string.IsNullOrEmpty(iconName))
            {
                stack.Children.Add(SoftwareCoUtil.CreateImage(iconName));
            }

            Label label = new Label();

            label.Content    = text;
            label.Foreground = Brushes.DarkCyan;

            // add to the stack
            stack.Children.Add(label);

            // assign the stack to the header
            treeItem.Header = stack;
            return(treeItem);
        }
        public async Task <TimeData> GetTodayTimeDataSummary(PluginDataProject proj)
        {
            NowTime         nowTime = SoftwareCoUtil.GetNowTime();
            List <TimeData> list    = GetTimeDataList();

            if (proj == null || proj.directory == null || proj.directory.Equals(""))
            {
                proj = await PluginData.GetPluginProject();
            }

            if (proj == null || proj.directory == null || proj.directory.Equals(""))
            {
                proj = new PluginDataProject("Unnamed", "Untitled");
            }

            if (list != null && list.Count > 0)
            {
                foreach (TimeData td in list)
                {
                    if (td.day.Equals(nowTime.local_day) && td.project.directory.Equals(proj.directory))
                    {
                        return(td);
                    }
                }
            }
            return(await GetNewTimeDataSummary(proj));
        }
Example #5
0
        public static bool IsNewDay()
        {
            NowTime nowTime    = SoftwareCoUtil.GetNowTime();
            string  currentDay = FileManager.getItemAsString("currentDay");

            return((!nowTime.day.Equals(currentDay)) ? true : false);
        }
Example #6
0
        public IDictionary <string, string> GetResourceInfo(string projectDir)
        {
            IDictionary <string, string> dict = new Dictionary <string, string>();
            string identifier = SoftwareCoUtil.RunCommand("git config remote.origin.url", projectDir);

            if (identifier != null && !identifier.Equals(""))
            {
                dict.Add("identifier", identifier);

                // only get these since identifier is available
                string email = SoftwareCoUtil.RunCommand("git config user.email", projectDir);
                if (email != null && !email.Equals(""))
                {
                    dict.Add("email", email);
                }
                string branch = SoftwareCoUtil.RunCommand("git symbolic-ref --short HEAD", projectDir);
                if (branch != null && !branch.Equals(""))
                {
                    dict.Add("branch", branch);
                }
                string tag = SoftwareCoUtil.RunCommand("git describe --all", projectDir);

                if (tag != null && !tag.Equals(""))
                {
                    dict.Add("tag", tag);
                }
            }

            return(dict);
        }
        private async void InitializeUserInfo()
        {
            bool online = await SoftwareUserSession.IsOnlineAsync();

            bool softwareSessionFileExists = SoftwareCoUtil.softwareSessionFileExists();
            bool jwtExists       = SoftwareCoUtil.jwtExists();
            bool initializedUser = false;

            if (!softwareSessionFileExists || !jwtExists)
            {
                string result = await SoftwareUserSession.CreateAnonymousUserAsync(online);

                if (result != null)
                {
                    initializedUser = true;
                }
            }

            SoftwareUserSession.UserStatus status = await SoftwareUserSession.GetUserStatusAsync(true);

            SoftwareLoginCommand.UpdateEnabledState(status);

            if (initializedUser)
            {
                LaunchLoginPrompt();
            }

            if (online)
            {
                fetchSessionSummaryInfoAsync();

                // send heartbeat
                SoftwareUserSession.SendHeartbeat("INITIALIZED");
            }
        }
        private async Task _IntialisefileMap(string fileName)
        {
            foreach (KeyValuePair <string, object> sourceFiles in _softwareData.source)
            {
                long   end       = 0;
                long   local_end = 0;
                double offset    = 0;
                if (fileName != sourceFiles.Key)
                {
                    object     outend       = null;
                    JsonObject fileInfoData = null;
                    fileInfoData = (JsonObject)sourceFiles.Value;
                    fileInfoData.TryGetValue("end", out outend);

                    if (long.Parse(outend.ToString()) == 0)
                    {
                        end       = SoftwareCoUtil.getNowInSeconds();
                        offset    = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalMinutes;
                        local_end = end + ((int)offset * 60);

                        _softwareData.addOrUpdateFileInfo(fileName, "end", end);
                        _softwareData.addOrUpdateFileInfo(fileName, "local_end", local_end);
                    }
                }
                else
                {
                    _softwareData.addOrUpdateFileInfo(fileName, "end", 0);
                    _softwareData.addOrUpdateFileInfo(fileName, "local_end", 0);
                }
            }
        }
Example #9
0
        private static CommitChangeStats GetChangeStats(string cmd, string projectDir)
        {
            if (!SoftwareCoUtil.IsGitProject(projectDir))
            {
                return(new CommitChangeStats());
            }
            CommitChangeStats stats = new CommitChangeStats();

            /**
             * example:
             * -mbp-2:swdc-vscode xavierluiz$ git diff --stat
             *  lib/KpmProviderManager.ts | 22 ++++++++++++++++++++--
             *  1 file changed, 20 insertions(+), 2 deletions(-)
             *
             *  for multiple files it will look like this...
             *  7 files changed, 137 insertions(+), 55 deletions(-)
             */
            List <string> results = SoftwareCoUtil.GetCommandResultList(cmd, projectDir);

            if (results == null || results.Count == 0)
            {
                // something went wrong, but don't try to parse a null or undefined str
                return(stats);
            }

            // just look for the line with "insertions" and "deletions"
            return(AccumulateChangeStats(results));
        }
        public static async Task <string> GetAppJwtAsync(bool online)
        {
            try
            {
                if (online)
                {
                    long seconds = SoftwareCoUtil.GetNowInSeconds();
                    HttpResponseMessage response = await SoftwareHttpManager.SendRequestAsync(
                        HttpMethod.Get, "/data/apptoken?token=" + seconds, null);

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

                        IDictionary <string, object> jsonObj = (IDictionary <string, object>)SimpleJson.DeserializeObject(responseBody, new Dictionary <string, object>());
                        jsonObj.TryGetValue("jwt", out object jwtObj);
                        string app_jwt = (jwtObj == null) ? null : Convert.ToString(jwtObj);
                        return(app_jwt);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("GetAppJwtAsync, error: " + ex.Message, ex);
            }

            return(null);
        }
Example #11
0
        public static CommitChangeStats GetCommitsForRange(string rangeType, string projectDir, string email)
        {
            if (!SoftwareCoUtil.IsGitProject(projectDir))
            {
                return(new CommitChangeStats());
            }
            NowTime nowTime   = SoftwareCoUtil.GetNowTime();
            string  sinceTime = nowTime.start_of_today.ToString("yyyy-MM-ddTHH:mm:sszzz");
            string  untilTime = null;

            if (rangeType == "yesterday")
            {
                sinceTime = nowTime.start_of_yesterday_dt.ToString("yyyy-MM-ddTHH:mm:sszzz");
                untilTime = nowTime.start_of_today.ToString("yyyy-MM-ddTHH:mm:sszzz");
            }
            else if (rangeType == "thisWeek")
            {
                sinceTime = nowTime.start_of_week_dt.ToString("yyyy-MM-ddTHH:mm:sszzz");
            }

            string cmd = "git log --stat --pretty=\"COMMIT:% H,% ct,% cI,% s\" --since=\"" + sinceTime + "\"";

            if (untilTime != null)
            {
                cmd += " --until=\"" + untilTime + "\"";
            }
            if (email != null && !email.Equals(""))
            {
                cmd += " --author=" + email;
            }
            return(GetChangeStats(cmd, projectDir));
        }
Example #12
0
 public SoftwareData(ProjectInfo projectInfo)
 {
     start   = SoftwareCoUtil.getNowInSeconds();
     project = projectInfo;
     version = SoftwareCoPackage.GetVersion();
     os      = SoftwareCoPackage.GetOs();
 }
        private static void updateStatusBarWithSummaryData()
        {
            _sessionSummary = getSessionSummayData();

            long currentDayMinutesVal   = _sessionSummary.currentDayMinutes;
            long averageDailyMinutesVal = _sessionSummary.averageDailyMinutes;

            string currentDayMinutesTime   = SoftwareCoUtil.HumanizeMinutes(currentDayMinutesVal);
            string averageDailyMinutesTime = SoftwareCoUtil.HumanizeMinutes(averageDailyMinutesVal);

            // Code time today:  4 hrs | Avg: 3 hrs 28 min
            string inFlowIcon = currentDayMinutesVal > averageDailyMinutesVal ? "🚀" : "";
            string msg        = string.Format("{0}{1}", inFlowIcon, currentDayMinutesTime);

            if (averageDailyMinutesVal > 0)
            {
                msg += string.Format(" | {0}", averageDailyMinutesTime);
                _softwareStatus.SetStatus(msg);
            }
            else if (currentDayMinutesVal > 0)
            {
                _softwareStatus.SetStatus(msg);
            }
            else
            {
                _softwareStatus.SetStatus("Code Time");
            }
        }
Example #14
0
        public void EnsureFileInfoDataIsPresent(string fileName)
        {
            JsonObject fileInfoData = new JsonObject();
            long       start        = SoftwareCoUtil.getNowInSeconds();
            double     offset       = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalMinutes;
            long       local_start  = start + ((int)offset * 60);

            if (!source.ContainsKey(fileName))
            {
                fileInfoData.Add("paste", 0);
                fileInfoData.Add("open", 0);
                fileInfoData.Add("close", 0);
                fileInfoData.Add("delete", 0);
                fileInfoData.Add("add", 0);
                fileInfoData.Add("netkeys", 0);
                fileInfoData.Add("length", 0);
                fileInfoData.Add("lines", 0);
                fileInfoData.Add("linesAdded", 0);
                fileInfoData.Add("linesRemoved", 0);
                fileInfoData.Add("syntax", "");
                fileInfoData.Add("start", start);
                fileInfoData.Add("local_start", local_start);
                fileInfoData.Add("end", 0);
                fileInfoData.Add("local_end", 0);
                source.Add(fileName, fileInfoData);
            }
        }
        public static async void SendHeartbeat(string reason)
        {
            string jwt    = GetJwt();
            bool   online = await IsOnlineAsync();

            if (online && jwt != null)
            {
                string version = Constants.EditorVersion;

                JsonObject jsonObj = new JsonObject();
                jsonObj.Add("version", SoftwareCoPackage.GetVersion());
                jsonObj.Add("os", SoftwareCoPackage.GetOs());
                jsonObj.Add("pluginId", Constants.PluginId);
                jsonObj.Add("start", SoftwareCoUtil.getNowInSeconds());
                jsonObj.Add("trigger_annotation", reason);
                jsonObj.Add("hostname", SoftwareCoUtil.getHostname());

                string api      = "/data/heartbeat";
                string jsonData = jsonObj.ToString();
                HttpResponseMessage response = await SoftwareHttpManager.SendRequestAsync(HttpMethod.Post, api, jsonData, jwt);

                if (!SoftwareHttpManager.IsOk(response))
                {
                    Logger.Warning("Code Time: Unable to send heartbeat");
                }
            }
        }
        private StackPanel BuildClickLabel(string panelName, string iconName, string content, MouseButtonEventHandler handler)
        {
            StackPanel panel = new StackPanel();

            panel.Name        = panelName;
            panel.Orientation = Orientation.Horizontal;
            panel.Margin      = new Thickness(5, 0, 0, 0);

            Image img = new Image();

            img.Width  = 15;
            img.Height = 15;
            img.Source = SoftwareCoUtil.CreateImage(iconName).Source;
            panel.Children.Add(img);

            Label label = new Label();

            label.Content         = content;
            label.MouseDown      += handler;
            label.Foreground      = Brushes.DarkCyan;
            label.Background      = Brushes.Transparent;
            label.BorderThickness = new Thickness(0d);
            panel.Children.Add(label);
            return(panel);
        }
        public static async Task <bool> IsLoggedOn(bool online)
        {
            try
            {
                string jwt = FileManager.getItemAsString("jwt");
                if (online && jwt != null)
                {
                    User user = await GetUserAsync(online);

                    if (user != null && SoftwareCoUtil.IsValidEmail(user.email))
                    {
                        FileManager.setItem("name", user.email);
                        FileManager.setItem("jwt", user.plugin_jwt);
                        lastJwt = user.plugin_jwt;
                        return(true);
                    }

                    string api = "/users/plugin/state";
                    HttpResponseMessage response = await SoftwareHttpManager.SendRequestAsync(HttpMethod.Get, api, jwt);

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

                        IDictionary <string, object> jsonObj = (IDictionary <string, object>)SimpleJson.DeserializeObject(responseBody, new Dictionary <string, object>());
                        if (jsonObj != null)
                        {
                            jsonObj.TryGetValue("state", out object stateObj);
                            string state = (stateObj == null) ? "NONE" : Convert.ToString(stateObj);
                            jsonObj.TryGetValue("jwt", out object pluginJwtObj);
                            string pluginJwt = (pluginJwtObj == null) ? null : Convert.ToString(pluginJwtObj);
                            if (state.Equals("OK") && pluginJwt != null)
                            {
                                jsonObj.TryGetValue("email", out object nameObj);
                                string name = (nameObj == null) ? null : Convert.ToString(nameObj);
                                if (name != null)
                                {
                                    FileManager.setItem("name", name);
                                }
                                FileManager.setItem("jwt", pluginJwt);
                                lastJwt = pluginJwt;
                            }
                            else if (state.Equals("NOT_FOUND"))
                            {
                                FileManager.setItem("jwt", null);
                                lastJwt = null;
                            }
                        }
                    }
                }
                FileManager.setItem("name", null);
            }
            catch (Exception ex)
            {
                //
            }

            return(false);
        }
Example #18
0
 public static CommitChangeStats GetThisWeeksCommits(string projectDir, string email)
 {
     if (!SoftwareCoUtil.IsGitProject(projectDir))
     {
         return(new CommitChangeStats());
     }
     return(GetCommitsForRange("thisWeek", projectDir, email));
 }
Example #19
0
 public static string GetUsersEmail(string projectDir)
 {
     if (!SoftwareCoUtil.IsGitProject(projectDir))
     {
         return("");
     }
     return(SoftwareCoUtil.RunCommand("git config user.email", projectDir));
 }
Example #20
0
 public static CommitChangeStats GetYesterdayCommits(string projectDir, string email)
 {
     if (!SoftwareCoUtil.IsGitProject(projectDir))
     {
         return(new CommitChangeStats());
     }
     return(GetCommitsForRange("yesterday", projectDir, email));
 }
 public static string GetJwt()
 {
     if (lastJwt == null)
     {
         object jwt = SoftwareCoUtil.getItem("jwt");
         lastJwt = (jwt != null && !((string)jwt).Equals("")) ? (string)jwt : null;
     }
     return(lastJwt);
 }
Example #22
0
        public static CommitChangeStats GetUncommitedChanges(string projectDir)
        {
            if (!SoftwareCoUtil.IsGitProject(projectDir))
            {
                return(new CommitChangeStats());
            }
            string cmd = "git diff --stat";

            return(GetChangeStats(cmd, projectDir));;
        }
Example #23
0
        public static PluginDataProject GetPluginDataFromDictionary(IDictionary <string, object> dict)
        {
            string            projName      = SoftwareCoUtil.ConvertObjectToString(dict, "name");
            string            projDir       = SoftwareCoUtil.ConvertObjectToString(dict, "directory");
            string            identifierVal = SoftwareCoUtil.ConvertObjectToString(dict, "identifier");
            PluginDataProject project       = new PluginDataProject(projName, projDir);

            project.identifier = identifierVal;
            return(project);
        }
        public static async void LaunchCodeTimeDashboardAsync()
        {
            fetchSessionSummaryInfoAsync();
            string dashboardFile = SoftwareCoUtil.getDashboardFile();

            if (File.Exists(dashboardFile))
            {
                ObjDte.ItemOperations.OpenFile(dashboardFile);
            }
        }
        public static async Task <string> CreateAnonymousUserAsync(bool online)
        {
            // get the app jwt
            try
            {
                string app_jwt = await GetAppJwtAsync(online);

                if (app_jwt != null && online)
                {
                    string creation_annotation = "NO_SESSION_FILE";
                    string osUsername          = Environment.UserName;
                    string timezone            = "";
                    if (TimeZone.CurrentTimeZone.DaylightName != null &&
                        TimeZone.CurrentTimeZone.DaylightName != TimeZone.CurrentTimeZone.StandardName)
                    {
                        timezone = TimeZone.CurrentTimeZone.DaylightName;
                    }
                    else
                    {
                        timezone = TimeZone.CurrentTimeZone.StandardName;
                    }

                    JsonObject jsonObj = new JsonObject();
                    jsonObj.Add("timezone", timezone);
                    jsonObj.Add("username", osUsername);
                    jsonObj.Add("hostname", SoftwareCoUtil.getHostname());
                    jsonObj.Add("creation_annotation", creation_annotation);

                    string api      = "/data/onboard";
                    string jsonData = jsonObj.ToString();
                    HttpResponseMessage response = await SoftwareHttpManager.SendRequestAsync(HttpMethod.Post, api, jsonData, app_jwt);

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

                        IDictionary <string, object> respObj = (IDictionary <string, object>)SimpleJson.DeserializeObject(responseBody, new Dictionary <string, object>());
                        respObj.TryGetValue("jwt", out object jwtObj);
                        string jwt = (jwtObj == null) ? null : Convert.ToString(jwtObj);
                        if (jwt != null)
                        {
                            FileManager.setItem("jwt", jwt);
                            return(jwt);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("CreateAnonymousUserAsync, error: " + ex.Message, ex);
            }


            return(null);
        }
Example #26
0
        private static string getRowNumberData(string title, long userStat, long contribStat)
        {
            string userStatStr    = SoftwareCoUtil.FormatNumber(userStat);
            string contribStatStr = SoftwareCoUtil.FormatNumber(contribStat);

            List <string> labels = new List <string>();

            labels.Add(title);
            labels.Add(userStatStr);
            labels.Add(contribStatStr);
            return(getRowLabels(labels));
        }
        public async Task <TimeData> GetNewTimeDataSummary(PluginDataProject project)
        {
            NowTime  nowTime = SoftwareCoUtil.GetNowTime();
            TimeData td      = new TimeData();

            td.day             = nowTime.local_day;
            td.timestamp       = nowTime.utc_end_of_day;
            td.timestamp_local = nowTime.local_end_of_day;
            td.project         = project;

            return(td);
        }
Example #28
0
        /**
         * Get the latest repo commit
         **/
        public async Task <RepoCommit> GetLatestCommitAsync(string projectDir)
        {
            try
            {
                if (!SoftwareCoUtil.IsGitProject(projectDir))
                {
                    return(null);
                }
                RepoResourceInfo info = GitUtilManager.GetResourceInfo(projectDir, false);

                if (info != null && info.identifier != null)
                {
                    string identifier = info.identifier;
                    if (identifier != null && !identifier.Equals(""))
                    {
                        string tag    = info.tag;
                        string branch = info.branch;

                        string qryString = "?identifier=" + identifier;
                        qryString += "&tag=" + tag;
                        qryString += "&branch=" + branch;

                        HttpResponseMessage response = await SoftwareHttpManager.SendRequestAsync(
                            HttpMethod.Get, "/commits/latest?" + qryString, null);

                        if (SoftwareHttpManager.IsOk(response))
                        {
                            // get the json data
                            string responseBody = await response.Content.ReadAsStringAsync();

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

                            jsonObj.TryGetValue("commitId", out object commitIdObj);
                            string commitId = (commitIdObj == null) ? "" : Convert.ToString(commitIdObj);

                            jsonObj.TryGetValue("message", out object messageObj);
                            string message = (messageObj == null) ? "" : Convert.ToString(messageObj);

                            jsonObj.TryGetValue("message", out object timestampObj);
                            long timestamp = (timestampObj == null) ? 0L : Convert.ToInt64(timestampObj);

                            RepoCommit repoCommit = new RepoCommit(commitId, message, timestamp);
                            return(repoCommit);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("GetLatestCommitAsync ,error: " + ex.Message, ex);
            }
            return(null);
        }
Example #29
0
 public void ResetData()
 {
     keystrokes = 0;
     source     = new JsonObject();
     if (project != null)
     {
         project.ResetData();
     }
     start       = SoftwareCoUtil.getNowInSeconds();
     local_start = 0L;
     initialized = false;
 }
Example #30
0
 public void CloneFromDictionary(IDictionary <string, object> dict)
 {
     this.timestamp       = SoftwareCoUtil.ConvertObjectToLong(dict, "timestamp");
     this.timestamp_local = SoftwareCoUtil.ConvertObjectToLong(dict, "timestamp_local");
     this.type            = SoftwareCoUtil.ConvertObjectToString(dict, "type");
     this.name            = SoftwareCoUtil.ConvertObjectToString(dict, "name");
     this.description     = SoftwareCoUtil.ConvertObjectToString(dict, "description");
     this.os       = SoftwareCoUtil.ConvertObjectToString(dict, "os");
     this.version  = SoftwareCoUtil.ConvertObjectToString(dict, "version");
     this.timezone = SoftwareCoUtil.ConvertObjectToString(dict, "timezone");
     this.hostname = SoftwareCoUtil.ConvertObjectToString(dict, "hostname");
     this.pluginId = SoftwareCoUtil.ConvertObjectToInt(dict, "pluginId");
 }