private void btnJIRA_ItemClick(object sender, ItemClickEventArgs e)
        {
            JiraHelper.TakeScreenshot(this);
            // Show the Isssue Dialog Box.
            JiraIssue issue = new JiraIssue();

            issue.ShowDialog(this);
        }
Example #2
0
 public WorkItem(string releaseNum, JiraStory story, JiraStory epic)
 {
     this.StoryNumber         = story.Id;
     this.ReleaseNumber       = releaseNum;
     this.Status              = JiraHelper.GetWorkItemStatus(story);
     this.EpicWorkItemId      = story.EpicStoryId;
     this.EpicName            = (epic != null) ? epic.Title : null;
     this.Title               = story.Title;
     this.Type                = JiraHelper.GetWorkItemType(story);
     this.StoryPointsOriginal = story.StoryPoints.HasValue ? (int)story.StoryPoints.Value : (int?)null;
     this.StoryPoints         = story.StoryPoints.HasValue ? (int)story.StoryPoints.Value : 0;
     this.BillToClient        = GetBillToClient(story);
 }
        public async Task <ContentResult> DialogActionAsync()
        {
            // Parse the body of the request using the Protobuf JSON parser,
            // *not* Json.NET.
            string textToReturn = "";
            string requestJson;

            using (TextReader reader = new StreamReader(Request.Body))
            {
                requestJson = await reader.ReadToEndAsync();
            }

            WebhookRequest request;

            request = jsonParser.Parse <WebhookRequest>(requestJson);


            // Add a comment
            if (request.QueryResult.Action == "addIssueComment")
            {
                textToReturn = await JiraService.AddComment(request);
            }

            // Change issue status
            else if (request.QueryResult.Action == "changeIssueStatus")
            {
                textToReturn = await JiraService.ChangeStatusOfIssue(request);
            }
            // Get issue details
            else if (request.QueryResult.Action == "getIssueDetails")
            {
                textToReturn = await JiraService.GetIssueDetails(request);
            }

            // Get all the issues asssigned to the user
            else if (request.QueryResult.Action == "getAllAssignedIssues")
            {
                textToReturn = JiraHelper.CreateAssignedIssueTable(await JiraAPIContext.GetAssignedIssues());
            }


            else
            {
                textToReturn = "Your action could not be resolved!";
            }

            string responseJson = DialogService.populateResponse(textToReturn);
            var    content      = Content(responseJson, "application/json");

            return(content);
        }
Example #4
0
        // Executes the expression tree that is passed to it.
        internal static object Execute(Expression expression, bool isEnumerable)
        {
            while (expression.CanReduce)
            {
                expression = expression.Reduce();
            }

            var    expressionString = expression.ToString();
            string jql;

            if (expressionString.Contains("WorklogQuery"))
            {
                var query     = ParseNode(expression, string.Empty);
                var wkl       = query.Split('\"').Skip(1).Take(1).First();
                var @params   = wkl.Split(';').ToList();
                var dateStart = @params[0];
                var dateEnd   = @params[1];
                var userName  = @params[2];
                jql = string.Format("key in workedIssues(\"{0}\",\"{1}\",\"{2}\")", dateStart, dateEnd, userName);
                return(JiraHelper.GetIssues(
                           jql,
                           new List <string>
                {
                    "worklog",
                    "issuetype",
                    "parent",
                    "assignee",
                    "labels",
                    "issuelinks",
                    "summary",
                }));
            }

            jql = ParseNode(expression);
            return(ParseAndExecute(jql));
        }
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (dxValidationProvider1.Validate())
            {
                try
                {
                    if (!string.IsNullOrEmpty(txtPassword.Text))
                    {
                        if (!JiraHelper.Login(txtReportedBy.Text, txtPassword.Text))
                        {
                            if (
                                XtraMessageBox.Show(
                                    "The username/password you entered is not applicable.  Would you like to continue submit?",
                                    "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                            {
                                return;
                            }
                        }
                        JiraHelper.UserName = txtReportedBy.Text;
                        JiraHelper.Password = txtPassword.Text;
                    }

                    var issue = JiraHelper.CreateIssue("HW", txtSummary.Text, txtDescription.Text, lkPriority.Text,
                                                       lkType.Text);
                    //issue.AddComment("My Comment is that this is a good test");
                    issue.CustomFields.Add("Site Name",
                                           new string[]
                    {
                        GeneralInfo.Current.HospitalName
                    }
                                           );
                    issue.CustomFields.Add("Current User", new string[]
                    {
                        string.Format("{0}, {1}, {2}",
                                      CurrentContext.LoggedInUserName,
                                      CurrentContext.LoggedInUser.FullName,
                                      txtReportedBy.Text
                                      )
                    }
                                           );
                    issue.CustomFields.Add("Current Version", new string[]
                    {
                        cboCurrentVersion.Text
                    });

                    if (MainWindow.Instance != null)
                    {
                        if (!string.IsNullOrEmpty(MainWindow.Instance.CurrentFormIdentifier))
                        {
                            // now let's send the page identifier
                            // try to find the component if possible.
                            //issue.CustomFields.Add("Form ID", new string[]
                            //                                      {
                            //                                          MainWindow.Instance.CurrentFormIdentifier
                            //                                      });
                        }
                    }

                    issue.CustomFields.Add("Version", new string[]
                    {
                        Program.HCMISVersionString
                    });

                    issue.Reporter = txtReportedBy.Text;



                    issue.SaveChanges();

                    JiraHelper.AttachScreenShot(issue, screenShot.Image);
                    XtraMessageBox.Show("The issue has been successfully reported.", "Confirmation",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                catch
                {
                    XtraMessageBox.Show("Please check if you have internet connection and try again.", "No Connection", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #6
0
        public void FormatMail(DataTable dt1, string mailFormat, string toEmailAddress, string ccEmailAddress, string fromEmailAddress,
                               bool isPreview, RequestProfile requestProfile)
        {
            var mailTemplate = mailFormat;

            decimal totalhrs = 0;

            var stringBuilder = new StringBuilder();
            var strSubject    = new StringBuilder();

            var scheduleDetailData = (from m in dt1.AsEnumerable()
                                      select new
            {
                InTime = m["InTime"],
                OutTime = m["OutTime"],
                Message = m["Message"].ToString(),
                ScheduleDetailActivityCategory = m["ScheduleDetailActivityCategory"].ToString(),
                ScheduleDetailActivityCategoryId = m["ScheduleDetailActivityCategoryId"],
                WorkDate = m["WorkDate"],
                DateDiffHrs = m["DateDiffHrs"],
                Person = m["Person"],
                PersonId = m["PersonId"],
                EmailAddress = m["EmailAddress"],
                ScheduleId = m["ScheduleId"],
                WorkTicket = m["WorkTicket"]
            }).OrderBy(m => m.InTime).ToList();


            var workDate_distinct = (from c in dt1.AsEnumerable()
                                     select new
            {
                WorkDate = c["WorkDate"].ToString(),
                Person = c["Person"],
                ScheduleId = c["ScheduleId"]
            }).Distinct();

            if (!string.IsNullOrEmpty(mailTemplate))
            {
                foreach (var c in workDate_distinct)
                {
                    mailTemplate = mailTemplate.Replace("##PersonName##", c.Person.ToString());
                    mailTemplate = mailTemplate.Replace("##WorkDate##", Convert.ToDateTime(c.WorkDate).ToString("MMMM dd, yyyy"));
                }

                foreach (var item in scheduleDetailData)
                {
                    if (item.DateDiffHrs != null)
                    {
                        totalhrs = totalhrs + Convert.ToDecimal(item.DateDiffHrs);
                    }
                }
                mailTemplate = mailTemplate.Replace("##StartTime##", Convert.ToDateTime(scheduleDetailData.Select(grp => grp.InTime).First()).ToShortTimeString());
                mailTemplate = mailTemplate.Replace("##EndTime##", Convert.ToDateTime(scheduleDetailData.Select(grp => grp.OutTime).Last()).ToShortTimeString());
                mailTemplate = mailTemplate.Replace("##TotalHrs##", totalhrs.ToString("0.00"));

                var bColor = "#d9edf7";
                var i      = 0;

                foreach (var item in scheduleDetailData)
                {
                    var jiraIssue       = JiraDataManager.GetDetails(item.WorkTicket.ToString());
                    var jiraDescription = "N/A";
                    var jiraPriority    = "N/A";
                    var jiraWorkHours   = GetJiraWorkHours(item.WorkTicket.ToString(), Convert.ToDateTime(item.WorkDate), Convert.ToInt32(item.PersonId));
                    personId = Convert.ToInt32(item.PersonId);
                    var minsDuration = ScheduleDataManager.GetMinutes(Convert.ToDouble(item.DateDiffHrs));
                    var jiraURL      = "http://*****:*****@indusvalleyresearch.com";
                }

                var nMail = new MailMessage(fromEmailAddress, strToEmail);
                //string strFromEmail = "*****@*****.**";
                if (ccEmailAddress != string.Empty)
                {
                    MailAddress copy = new MailAddress(ccEmailAddress);
                    nMail.CC.Add(copy);
                }

                foreach (var item in scheduleDetailData)
                {
                    string bccMail = item.EmailAddress.ToString();
                    if (bccMail != string.Empty)
                    {
                        nMail.Bcc.Add(new MailAddress(bccMail));
                    }
                }

                foreach (var c in workDate_distinct)
                {
                    strSubject.Append("EOD Daily Summary Email for " + Convert.ToDateTime(c.WorkDate).ToString("MMMM dd, yyyy") + "(" + totalhrs.ToString("0.00") + " hrs" + ")");
                    strSubject.Append(" - Sent on behalf of " + c.Person);
                }

                nMail.Subject    = strSubject.ToString();
                nMail.Body       = mailTemplate;
                nMail.IsBodyHtml = true;

                var a = new SmtpClient();
                a.Send(nMail);
            }
        }
Example #7
0
 private static object ParseAndExecute(string query)
 {
     return(JiraHelper.GetIssues(query));
 }
Example #8
0
        public async Task <List <TimeEntryValidationResult> > Validate(Release release, List <TimeEntry> timeEntries)
        {
            var jiraStoriesInRelease = (await JiraApi.GetStoriesInReleaseAsync(release.ReleaseNumber));

            var results = new List <TimeEntryValidationResult>();

            foreach (var timeEntry in timeEntries)
            {
                var errors   = new List <string>();
                var warnings = new List <string>();

                var isPlanned          = (MavenlinkHelper.GetBillingClassification(timeEntry.TaskTitleOverride) == BillingClassificationEnum.Planned);
                var referencedStoryIds = MavenlinkHelper.GetJiraStoryIds(timeEntry.NotesOverride);

                if (referencedStoryIds.Count <= 1 && timeEntry.DurationMinutesOverride < 15)
                {
                    warnings.Add($"Minimum billing increment is 15 minutes");
                }
                else if (referencedStoryIds.Count > 1)
                {
                    var timePerStory = (timeEntry.DurationMinutesOverride / referencedStoryIds.Count);

                    if (timePerStory < 15m)
                    {
                        warnings.Add($"Each Jira story would receive {timePerStory} minutes of elapsed time, less than the 15-min minimum billing increment.");
                    }
                }

                foreach (var jiraStoryId in referencedStoryIds)
                {
                    var jiraStory = jiraStoriesInRelease
                                    .Where(x => x.Id == jiraStoryId)
                                    .FirstOrDefault();

                    // we're loading all of the stories in the release in a single load for performance, but if time is
                    // billed to a story NOT in the release we still need to load it as a 1-off.
                    if (jiraStory == null)
                    {
                        try {
                            jiraStory = await JiraApi.GetStoryAsync(jiraStoryId);
                        }
                        catch (NotFoundException) {
                            errors.Add($"Jira ID '{jiraStoryId}' was not found in Jira");
                            continue;
                        }
                    }

                    // Billing time to a story not associated with the release is a warning; the time will be counted towards
                    // the "undelivered" category and will not affect the metrics
                    if (!jiraStory.FixVersions.Contains(release.ReleaseNumber))
                    {
                        warnings.Add($"Jira {jiraStory.IssueType} '{jiraStoryId}' is not tagged to release {release.ReleaseNumber} and has status '{jiraStory.Status}'. Time will be counted towards 'undelivered'.");
                    }

                    var workItemType     = JiraHelper.GetWorkItemType(jiraStory);
                    var isEpic           = (workItemType == WorkItemTypeEnum.Epic);
                    var isDeclined       = jiraStory.Status.EqualsIgnoringCase("Declined");
                    var isContingency    = (workItemType == WorkItemTypeEnum.Contingency);
                    var isFeatureRequest = (workItemType == WorkItemTypeEnum.FeatureRequest);

                    if (isFeatureRequest)
                    {
                        warnings.Add($"'{jiraStoryId}' is a Feature Request; Feature Requests should not be billed as development, they should either be billed to a specific analysis ticket or to Unplanned Analysis.");
                    }

                    if (isDeclined)
                    {
                        warnings.Add($"Jira {jiraStory.IssueType} '{jiraStoryId}' is marked as 'DECLINED'. Time will be tracked towards 'undelivered'.");
                    }

                    if (isEpic && isPlanned)
                    {
                        warnings.Add($"'{jiraStoryId}' is an Epic; epics should generally have Overhead or Unplanned time instead of Planned.");
                    }

                    if (isContingency)
                    {
                        errors.Add($"'{jiraStoryId}' is a Contingency; Contingency cases should not have time billed to them. The time (and contingency points) should be moved to an actual feature.");
                    }
                }

                if (errors.Any() || warnings.Any())
                {
                    results.Add(
                        new TimeEntryValidationResult(timeEntry.Id, errors, warnings)
                        );
                }
            }

            return(results);
        }
Example #9
0
        private void BtnLoginClick(object sender, EventArgs e)
        {
            UserInformation userInfo = null;

            try
            {
                if (BLL.Settings.UseNewUserManagement)
                {
                    userInfo = Auth.Authenticate(txtUsername.Text, txtPassword.Text);
                    if (userInfo == null)
                    {
                        //errorLogger.SaveError(0, 1, 1, 2, "Login Attempt", "Warehouse", new InvalidCredentialException("Invalid credentials, Username = "******"", "", true, txtUsername.Text, Program.HCMISVersionString);
                    if (XtraMessageBox.Show(@"Invalid Username or Password!", @"Login Failed", MessageBoxButtons.OKCancel, MessageBoxIcon.Stop) == DialogResult.Cancel)
                    {
                        Application.Exit();
                    }
                    else
                    {
                    }
                }
            }
            catch
            {
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    //ConnectionStringManager.ConnectionStringManager connMgr =
                    //    new ConnectionStringManager.ConnectionStringManager(Program.RegKey,
                    //                                                        Program.PrevConnectionStringKey);
                    //connMgr.ShowDialog();
                }
                else
                {
                    XtraMessageBox.Show("Network error.  Please make sure your network connection is working.", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            // Clear the login form
            txtPassword.Text = "";
            txtUsername.Text = "";
            txtUsername.Focus();
        }