public object Post(WpsJobSendSupportEmailRequestTep request) { var context = TepWebContext.GetWebContext(PagePrivileges.UserView); try { context.Open(); context.LogInfo(this, string.Format("/job/wps/{{identifier}}/support POST identifier='{0}', subject='{1}', body='{2}'", request.JobId, request.Subject, request.Body)); WpsJob job = WpsJob.FromIdentifier(context, request.JobId); //user must be the owner of the job if (context.UserId != job.OwnerId) { throw new Exception("Sorry, you must be the owner of the job to contact the support for job analysis."); } var supportModes = context.GetConfigValue("wpsjob-support-mode").Split(','); if (supportModes.Contains("mail")) { //send email from job's owner to mailto context.SendMail(job.Owner.Email ?? context.GetConfigValue("MailSenderAddress"), context.GetConfigValue("MailSenderAddress"), request.Subject, request.Body); } if (supportModes.Contains("jira")) { //create JIRA ticket var components = new List <JiraNameProperty>(); var configComponents = context.GetConfigValue("jira-helpdesk-components"); if (!string.IsNullOrEmpty(configComponents)) { var componentsList = configComponents.Split(','); foreach (var component in componentsList) { components.Add(new JiraNameProperty { name = component }); } } var labels = new List <string>(); var configLabels = context.GetConfigValue("jira-helpdesk-labels"); if (!string.IsNullOrEmpty(configLabels)) { labels = configLabels.Split(',').ToList(); } var owner = job.Owner; if (string.IsNullOrEmpty(owner.TerradueCloudUsername)) { owner.LoadCloudUsername(); } var raiseOnBehalfOf = owner.TerradueCloudUsername; var issue = new JiraServiceDeskIssueRequest { serviceDeskId = context.GetConfigValue("jira-helpdesk-serviceDeskId"), requestTypeId = context.GetConfigValue("jira-helpdesk-requestTypeId"), raiseOnBehalfOf = raiseOnBehalfOf, requestFieldValues = new JiraServiceDeskIssueFields { summary = request.Subject, description = request.Body, components = components, labels = labels } }; if (!string.IsNullOrEmpty(context.GetConfigValue("jira-helpdesk-customfield-ThematicAppLabel"))) { issue.requestFieldValues.thematicAppLabels = new List <string> { request.AppId }; } if (!string.IsNullOrEmpty(context.GetConfigValue("jira-helpdesk-customfield-ProcessingServiceLabel"))) { if (job.Process != null && !string.IsNullOrEmpty(job.Process.Name)) { var process = job.Process.Name.Replace(' ', '-'); issue.requestFieldValues.processingServicesLabels = new List <string> { process }; } } var jira = new JiraClient(context); try { jira.CreateServiceDeskIssue(issue); }catch (Exception) { issue.raiseOnBehalfOf = job.Owner.Email; jira.CreateServiceDeskIssue(issue); } } context.Close(); } catch (Exception e) { context.LogError(this, e.Message, e); context.Close(); throw e; } return(new WebResponseBool(true)); }