public void WriteRowHtml(JiraTimeEntry jiraTimeEntry, JiraConnector.HtmlWriter htmlWriter)
        {
            const string dateFormat = "hh:mm tt";

            htmlWriter.WriteBeginTag("tr");
            htmlWriter.BeginStyleTag(htmlWriter);
            htmlWriter.WriteStyleAttribute("border-bottom", "1px solid #222222");
            htmlWriter.EndStyleTag(htmlWriter);

            htmlWriter.WriteBeginTag("td");
            htmlWriter.WriteAttribute("width", "300");
            WriteTextStyle(htmlWriter, "#222222", "14px");
            htmlWriter.Write(jiraTimeEntry.KeyWithDescription);
            htmlWriter.WriteEndTag("td");

            htmlWriter.WriteBeginTag("td");
            htmlWriter.WriteAttribute("width", "100");
            WriteTextStyle(htmlWriter, "#222222", "14px");
            htmlWriter.Write(jiraTimeEntry.TimeSpentDisplay);
            htmlWriter.WriteEndTag("td");

            htmlWriter.WriteBeginTag("td");
            WriteTextStyle(htmlWriter, "#888888", "11px");
            htmlWriter.Write(jiraTimeEntry.StartedLocal.ToString(dateFormat) + " - " + jiraTimeEntry.EndedLocal.ToString(dateFormat));
            htmlWriter.WriteEndTag("td");

            htmlWriter.WriteEndTag("tr");
        }
Exemplo n.º 2
0
        public void InsertWorkLogEntry(JiraTimeEntry timeEntry)
        {
            RestClient client = new RestClient(_AuthUser.Username, _AuthUser.Password);

            client.EndPoint = $"{_AuthUser.JiraUrl}/rest/api/2/issue/{timeEntry.IssueKey}/worklog";

            string timeEntryDisplay = timeEntry.IssueKey + ": " + timeEntry.StartedLocal + " (" + timeEntry.TimeSpentDisplay + ")";

            if (IsSaved(client, timeEntry))
            {
                MessageBox.Show(timeEntryDisplay, "Already Saved");
            }
            else
            {
                client.Method   = HttpVerb.POST;
                client.PostData = JsonConvert.SerializeObject(
                    new WorkLogEntry {
                    timeSpent = timeEntry.TimeSpentDisplay, started = GetStartedDateTime(timeEntry.StartedLocal)
                });

                client.MakeRequest();

                MessageBox.Show(timeEntryDisplay, "Saved");
            }
        }
Exemplo n.º 3
0
        private string GetWorkLogTotal()
        {
            TimeSpan totalTimeSpan = new TimeSpan();

            //Loop through time entries and recalculate duration
            foreach (TimeEntry timeEntry in TimeEntries)
            {
                totalTimeSpan = totalTimeSpan.Add(timeEntry.Duration);
            }
            return(JiraTimeEntry.GetTimeSpentDisplay(totalTimeSpan));
        }
Exemplo n.º 4
0
        private bool IsSaved(RestClient client, JiraTimeEntry timeEntry)
        {
            client.Method = HttpVerb.GET;
            string response = client.MakeRequest();

            JObject deserializeObject = (JObject)JsonConvert.DeserializeObject(response);

            foreach (JToken worklog in deserializeObject["worklogs"])
            {
                JToken started   = worklog["started"];
                JToken timeSpent = worklog["timeSpent"];

                if (started.ToObject <DateTime>().ToString("s") == timeEntry.StartedLocal.ToString("s") && timeEntry.TimeSpentDisplay == timeSpent.ToObject <string>())
                {
                    return(true);
                }
            }
            return(false);
        }