Пример #1
0
        private string SubmitJiraSupportRequest(SupportRequestModel model)
        {
            var    currentUser = CheckPoint.Instance.IsAuthenticated ? CheckPoint.Instance.GetUser(this.tdb) : null;
            string reporter    = string.Empty;

            if (currentUser != null)
            {
                reporter = currentUser.Email;
            }
            else if (!string.IsNullOrEmpty(model.Email))
            {
                reporter = model.Email;
            }

            try
            {
                var priorityConfig = JiraSection.GetSection().Priorities[model.Priority];
                var typeConfig     = JiraSection.GetSection().Types[model.Type];

                if (priorityConfig == null)
                {
                    throw new Exception("Cannot find a configured JIRA priority mapping for " + model.Priority);
                }

                if (typeConfig == null)
                {
                    throw new Exception("Cannot find a configured JIRA type mapping for " + model.Type);
                }

                string issueTypeId = typeConfig.Id;

                if (string.IsNullOrEmpty(issueTypeId))
                {
                    issueTypeId = AppSettings.DefaultJiraTaskType;
                }

                JIRAIssueData issueData = new JIRAIssueData();
                issueData.project     = AppSettings.JiraProject;
                issueData.type        = issueTypeId;
                issueData.summary     = model.Summary;
                issueData.description = model.Details;
                issueData.reporter    = reporter;
                issueData.priority    = priorityConfig.Id;

                return(this.SubmitJIRAIssue(issueData, TRIFOLIA_SUPPORT_LABEL));
            }
            catch (Exception submitException)
            {
                Log.For(this).Error("Failed to submit JIRA support request", submitException);
                throw new Exception("Could not submit JIRA support request. Please notify the administrator.");
            }
        }
Пример #2
0
        public string SubmitSupportRequest(SupportRequestModel model)
        {
            if (!AppSettings.EnableJiraSupport)
            {
                if (string.IsNullOrEmpty(AppSettings.MailFromAddress))
                {
                    throw new Exception("MailFromAddress is not configured.");
                }

                if (string.IsNullOrEmpty(AppSettings.SupportEmailTo))
                {
                    throw new Exception("SupportEmailTo is not configured");
                }

                var client = new SmtpClient(AppSettings.MailHost, AppSettings.MailPort)
                {
                    Credentials = new NetworkCredential(AppSettings.MailUser, AppSettings.MailPassword),
                    Port        = AppSettings.MailPort,
                    EnableSsl   = AppSettings.MailEnableSSL
                };

                string lBody = string.Format("Issue Type: {0}\nIssue Priority: {1}\nDetails: {2}\nSubmitted By: {3} ({4})",
                                             model.Type,
                                             model.Priority,
                                             model.Details,
                                             CheckPoint.Instance.UserFullName,
                                             CheckPoint.Instance.UserName);

                string lSubject = string.Format("Trifolia Support: {0}", model.Summary);

                try
                {
                    client.Send(
                        AppSettings.MailFromAddress,
                        AppSettings.SupportEmailTo,
                        lSubject,
                        lBody);

                    return("Email sent");
                }
                catch (Exception ex)
                {
                    Log.For(this).Error("Error sending support request email", ex);
                    throw ex;
                }
            }
            //Send a JIRA ticket
            else
            {
                JIRAProxy lProxy    = new JIRAProxy();
                string    lUserName = string.Empty;

                if (this.User.Identity.IsAuthenticated)
                {
                    lUserName = this.User.Identity.Name;
                }
                else
                {
                    lUserName = model.Name + "; " + model.Email;
                }

                try
                {
                    var priorityConfig = JiraSection.GetSection().Priorities[model.Priority];
                    var typeConfig     = JiraSection.GetSection().Types[model.Type];

                    if (priorityConfig == null)
                    {
                        throw new Exception("Cannot find a configured JIRA priority mapping for " + model.Priority);
                    }

                    if (typeConfig == null)
                    {
                        throw new Exception("Cannot find a configured JIRA type mapping for " + model.Type);
                    }

                    return(lProxy.SubmitSupportTicket(lUserName, model.Summary, model.Details, priorityConfig.Id, typeConfig.Id));
                }
                catch (Exception submitException)
                {
                    Log.For(this).Error("Failed to submit JIRA beta user application", submitException);
                    throw new Exception("Could not submit beta user application.  Please notify the administrator");
                }
            }
        }