public async Task <GitHubIssueModel> SettIssue(GitHubIssueModel issue, string Provider) { try { this.Credentials = new Credentials(Configuration.GetSection("GitHubRepo").GetSection(Provider)["Token"]); System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; client.Credentials = Credentials; //create issue var createIssue = new NewIssue(issue.Title); createIssue.Body = issue.Body; if (issue.Assignees != null) { createIssue.Assignees.Add(issue.Assignee); } if (issue.Label != null) { string[] labels = issue.Label.Split(";"); for (int i = 0; i < labels.Length - 1; i++) { createIssue.Labels.Add(labels[i]); } } string[] Repo = Configuration.GetSection("GitHubRepo").GetSection(Provider)["Reponame"].Split("/"); var result = await client.Issue.Create(Repo[0], Repo[1], createIssue); issue.HtmlUrl = result.HtmlUrl; issue.IssueID = result.Number; return(issue); } catch (Exception ex) { issue.Exception = ex.Message; return(issue); } }
public async Task<IActionResult> Submit(BackupNodeModel BCKNode) { GitHubIssueModel issue = new GitHubIssueModel(); GitHubService gitHubService = new GitHubService(Configuration); await gitHubService.SettIssue(issue, "BaaS"); return RedirectToAction(nameof(Index)); }
public IActionResult Index(string Provider) { try { GitHubIssue = new GitHubIssueModel(); GitHubIssue.Provider = Configuration.GetSection("GitHubRepo").GetSection(Provider)["RepoName"]; GitHubIssue.HtmlUrl = "draft"; } catch { } return(View(GitHubIssue)); }
public async Task <IActionResult> Bluecare(string userAction, string serverName) { JsonService = new JsonFileServices(); foreach (var s in JsonService.GetServer(HttpContext.Session.GetString("Customer"), "CurrentConfig", serverName)) { Server = s; setServerToSession(Server); } JsonService = new JsonFileServices(); Server = getServerFromSession(); GitHubIssueModel issue = new GitHubIssueModel(); GitHubService gitHubService = new GitHubService(Configuration); if (userAction == "ServiceResponsability") { issue.Title = Server.Customer + " - Configure new service responsability for server " + Server.ServerName; string _Body = "Configure new service responsability for server " + Server.ServerName; _Body += "\n\nCustomer: " + Server.Customer; _Body += "\nOperating System: " + Server.OperatingSystem; _Body += "\nEnvironment: " + Server.Environment; _Body += "\nSeverity value: "; _Body += "\nChange record: "; issue.Body = _Body; issue.Provider = Provider; issue.Label = "enhancement;"; setIssueToSession(issue); TempData["issue"] = JsonConvert.SerializeObject(issue); return(RedirectToAction("Edit", "SubmitGitHubIssue")); } if (userAction == "NewNode") { issue.Title = Server.Customer + " - Create new bluecare node for server " + Server.ServerName; string _Body = "Create new bluecare node for server " + Server.ServerName; _Body += "\n\nCustomer: " + Server.Customer; _Body += "\nOperating System: " + Server.OperatingSystem; _Body += "\nEnvironment: " + Server.Environment; _Body += "\nIP: "; _Body += "\nAlert source: "; _Body += "\nChange record:"; issue.Body = _Body; issue.Provider = Provider; issue.Label = "enhancement;"; setIssueToSession(issue); TempData["issue"] = JsonConvert.SerializeObject(issue); return(RedirectToAction("Edit", "SubmitGitHubIssue")); } else { return(RedirectToAction(nameof(Index))); } }
public IActionResult RobotInventory() { string Customer = HttpContext.Session.GetString("Customer"); GitHubIssueModel issue = new GitHubIssueModel(); issue.Title = Customer + " - Get Robot inventory for RobotSN: "; string _Body = "Get Robot inventory for RobotSN: <write the Robot serial number>"; _Body += "\n\nCustomer: " + Customer; issue.Body = _Body; issue.Provider = Provider; issue.Label = "enhancement;"; setIssueToSession(issue); TempData["issue"] = JsonConvert.SerializeObject(issue); return RedirectToAction("Edit", "SubmitGitHubIssue"); }
public async Task <IActionResult> Submit(GitHubIssueModel newIssue) { gitHubService = new GitHubService(Configuration); var result = await gitHubService.SettIssue(newIssue, newIssue.Provider); if (result.HtmlUrl != null) { ModelState.Clear(); newIssue.Title = ""; newIssue.Body = ""; if (newIssue.Labels != null) { newIssue.Labels.Clear(); } TempData["Success"] = "Issue created with success"; } else { ModelState.AddModelError(string.Empty, newIssue.Exception); } return(View(nameof(Index), newIssue)); }
public async Task<IActionResult> Create(string userAction, string serverName) { JsonService = new JsonFileServices(); foreach (var s in JsonService.GetServer(HttpContext.Session.GetString("Customer"), "CurrentConfig", serverName)) { Server = s; setServerToSession(Server); } JsonService = new JsonFileServices(); if (userAction == "NewNode") { Server = getServerFromSession(); GitHubIssueModel issue = new GitHubIssueModel(); issue.Title = Server.Customer + " - Create new backup node for server " + Server.ServerName; string _Body = "Create new backup node for server " + Server.ServerName; _Body += "\n\nCustomer: " + Server.Customer; _Body += "\nOperating System: " + Server.OperatingSystem; _Body += "\nEnvironment: " + Server.Environment; _Body += "\nChange record:"; issue.Body = _Body; issue.Provider = Provider; issue.Label = "enhancement;"; GitHubService gitHubService = new GitHubService(Configuration); issue = await gitHubService.SettIssue(issue, Provider); if (issue.HtmlUrl != null) { ModelState.Clear(); TempData["Success"] = "Service request for server "+Server.ServerName +" created with success.Request id: " + issue.IssueID + " . Link para o issue: " + issue.HtmlUrl; } else { ModelState.Clear(); TempData["Error"] = "Error while creating the request " + issue.Exception; } return RedirectToAction(nameof(Index)); } if (userAction == "BlockNode") { Server = getServerFromSession(); GitHubIssueModel issue = new GitHubIssueModel(); issue.Title = Server.Customer + " - Lock backup node for server " + Server.ServerName; string _Body = "Lock backup node for server " + Server.ServerName; _Body += "\n\nCustomer: " + Server.Customer; _Body += "\nOperating System: " + Server.OperatingSystem; _Body += "\nEnvironment: " + Server.Environment; _Body += "\nChange record:"; issue.Body = _Body; issue.Provider = Provider; issue.Label = "enhancement;"; setIssueToSession(issue); TempData["issue"] = JsonConvert.SerializeObject(issue); return RedirectToAction("Edit", "SubmitGitHubIssue"); } if (userAction == "StandByNode") { Server = getServerFromSession(); GitHubIssueModel issue = new GitHubIssueModel(); issue.Title = Server.Customer + " - Standby node for server " + Server.ServerName; string _Body = "Standby node for server " + Server.ServerName; _Body += "\n\nCustomer: " + Server.Customer; _Body += "\nOperating System: " + Server.OperatingSystem; _Body += "\nEnvironment: " + Server.Environment; _Body += "\nChange record:"; issue.Body = _Body; issue.Provider = Provider; issue.Label = "enhancement;"; setIssueToSession(issue); TempData["issue"] = JsonConvert.SerializeObject(issue); return RedirectToAction("Edit", "SubmitGitHubIssue"); } if (userAction == "Activate") { Server = getServerFromSession(); GitHubIssueModel issue = new GitHubIssueModel(); issue.Title = Server.Customer + " - Activate backup node for server " + Server.ServerName; string _Body = "Activate backup node for server " + Server.ServerName; _Body += "\n\nCustomer: " + Server.Customer; _Body += "\nOperating System: " + Server.OperatingSystem; _Body += "\nEnvironment: " + Server.Environment; _Body += "\nChange record:"; issue.Body = _Body; issue.Provider = Provider; issue.Label = "enhancement;"; setIssueToSession(issue); TempData["issue"] = JsonConvert.SerializeObject(issue); return RedirectToAction("Edit", "SubmitGitHubIssue"); } if (userAction == "RobotInventory") { Server = getServerFromSession(); GitHubIssueModel issue = new GitHubIssueModel(); issue.Title = Server.Customer + " - Get Robot inventory for RobotSN: "; string _Body = "Get Robot inventory for RobotSN: <write the Robot serial number>"; _Body += "\n\nCustomer: " + Server.Customer; issue.Body = _Body; issue.Provider = Provider; issue.Label = "enhancement;"; setIssueToSession(issue); TempData["issue"] = JsonConvert.SerializeObject(issue); return RedirectToAction("Edit", "SubmitGitHubIssue"); } else { return RedirectToAction(nameof(Index)); } }
public void setIssueToSession(GitHubIssueModel issue) { var issueToSession = JsonConvert.SerializeObject(issue); HttpContext.Session.SetString("ServiceRequest", issueToSession); }
public async Task <IActionResult> ITM(string userAction, string serverName) { JsonService = new JsonFileServices(); foreach (var s in JsonService.GetServer(HttpContext.Session.GetString("Customer"), "CurrentConfig", serverName)) { Server = s; setServerToSession(Server); } JsonService = new JsonFileServices(); Server = getServerFromSession(); GitHubIssueModel issue = new GitHubIssueModel(); GitHubService gitHubService = new GitHubService(Configuration); if (userAction == "SOAgentInstall") { issue.Title = Server.Customer + " - Install new ITM agent for server " + Server.ServerName; string _Body = "Install new ITM agent for server " + Server.ServerName; _Body += "\n\nCustomer: " + Server.Customer; _Body += "\nOperating System: " + Server.OperatingSystem; _Body += "\nEnvironment: " + Server.Environment; _Body += "\nInstallation path (if diferent from standard): "; _Body += "\nChange record:"; issue.Body = _Body; issue.Provider = Provider; issue.Label = "enhancement;"; setIssueToSession(issue); TempData["issue"] = JsonConvert.SerializeObject(issue); return(RedirectToAction("Edit", "SubmitGitHubIssue")); } if (userAction == "SubsysAgentInstall") { issue.Title = Server.Customer + " - Install new ITM subsystem agent for server " + Server.ServerName; string _Body = "Install new ITM subsystem agent for server " + Server.ServerName; _Body += "\n\nCustomer: " + Server.Customer; _Body += "\nOperating System: " + Server.OperatingSystem; _Body += "\nEnvironment: " + Server.Environment; _Body += "\nSubsystem name: "; _Body += "\nSubsystem version: "; _Body += "\nInstallation path (if diferent from standard): "; _Body += "\nService account: "; _Body += "\nChange record:"; issue.Body = _Body; issue.Provider = Provider; issue.Label = "enhancement;"; setIssueToSession(issue); TempData["issue"] = JsonConvert.SerializeObject(issue); return(RedirectToAction("Edit", "SubmitGitHubIssue")); } if (userAction == "NewSituation") { issue.Title = Server.Customer + " - Create new situation for server " + Server.ServerName; string _Body = "Create new situation for server " + Server.ServerName; _Body += "\n\nCustomer: " + Server.Customer; _Body += "\nOperating System: " + Server.OperatingSystem; _Body += "\nEnvironment: " + Server.Environment; _Body += "\nSituation name: "; _Body += "\nThreshold: "; _Body += "\nChange record: "; issue.Body = _Body; issue.Provider = Provider; issue.Label = "enhancement;"; setIssueToSession(issue); TempData["issue"] = JsonConvert.SerializeObject(issue); return(RedirectToAction("Edit", "SubmitGitHubIssue")); } if (userAction == "ModifyThreshold") { issue.Title = Server.Customer + " - Modify threshold on situation for server " + Server.ServerName; string _Body = "Modify threshold on situation for server " + Server.ServerName; _Body += "\n\nCustomer: " + Server.Customer; _Body += "\nOperating System: " + Server.OperatingSystem; _Body += "\nEnvironment: " + Server.Environment; _Body += "\nSituation name: "; _Body += "\nNew threshold: "; _Body += "\nChange record: "; issue.Body = _Body; issue.Provider = Provider; issue.Label = "enhancement;"; setIssueToSession(issue); TempData["issue"] = JsonConvert.SerializeObject(issue); return(RedirectToAction("Edit", "SubmitGitHubIssue")); } else { return(RedirectToAction(nameof(Index))); } }
public IActionResult Edit() { GitHubIssue = JsonConvert.DeserializeObject <GitHubIssueModel>(TempData["issue"].ToString()); GitHubIssue.HtmlUrl = "draft"; return(View(nameof(Index), GitHubIssue)); }