private void Form1_Load(object sender, EventArgs e) { generalComboBox.DropDownStyle = ComboBoxStyle.DropDownList; specificComboBox.DropDownStyle = ComboBoxStyle.DropDownList; generalComboBox.DataSource = ComboItem.GeneralIssues(); generalComboBox.DisplayMember = Text; specificComboBox.DisplayMember = Text; string app = "Bayonet IT Tickets Program"; string version = File.ReadAllText(Application.StartupPath + "\\Version.txt"); this.Text = app + " " + version; Task.Run(() => Imgur.ConfigImgur()); Task.Run(() => API.ConfigureAPI()); }
private async void submitButton_Click(object sender, EventArgs e) { try { string general = ""; string specific = ""; if (generalComboBox.SelectedIndex != -1) { general = generalComboBox.Text; } if (specificComboBox.SelectedIndex != -1) { specific = specificComboBox.Text; } bool ComboBoxesCheck = DetermineComboBoxes(); if (!ComboBoxesCheck) { return; } string issue = "\n"; if (general.Length > 0) { issue += "(General Issue) " + general + "\n"; } if (specific.Length > 0) { issue += "(Specific Issue) " + specific + "\n"; } if (issueTextBox.Text.Length > 0) { issue += issueTextBox.Text; } //grab some user info (AD email, user name, host name, ip addr) string email = UserPrincipal.Current.EmailAddress; string user_name = Environment.UserName; string host_name = Dns.GetHostName(); string ip_address = ""; //grab local ip address var host = Dns.GetHostEntry(host_name); foreach (var ip in host.AddressList) { if (ip.AddressFamily == AddressFamily.InterNetwork) { ip_address = ip.ToString(); break; } } //if we couldnt find ip addr if (ip_address.Length == 0) { ip_address = "UNKNOWN"; } //check for file uploading string image_path = Imgur.IMGUR_SCREENSHOT_PATH; if (image_path != null) { await Imgur.postImageToImgur(image_path); } else { Imgur.IMAGE_URL = "None uploaded"; } //begin formulation of ticket string string ticket = "User_Name: " + user_name + "\n"; ticket += "User_Email: " + email + "\n"; ticket += "Host_Name: " + host_name + "\n"; ticket += "IP_Address: " + ip_address + "\n"; ticket += "Image_URL: " + Imgur.IMAGE_URL + "\n"; ticket += "Status: *Active*" + "\n"; ticket += "Issue: " + issue + "\n"; API.submitTicket(ticket, host_name); ClearIssue(); MessageBox.Show("Ticket submitted to IT Department! A member of the team will be with you shortly."); } catch (Exception ex) { MessageBox.Show("Error occured: please contact IT staff directly. \n\nERROR:" + ex.Message); } }