Help For creating tickets from C#
This code works correctly
Can it be better than that?
private void btnSend_Click(object sender, EventArgs e)
{
try
{
if (String.IsNullOrEmpty(textSubject.Text))
{
}
else
{
string username1 = System.DirectoryServices.AccountManagement.UserPrincipal.Current.DisplayName;
string name1 = username1;
string subject1 = textSubject.Text;
string description1 = textBox1.Text;
description1 = textBox1.Text;
if (description1 == "")
{
description1 = "بدون شرح";
}
string priority1 = comboBox1.Text;
if (priority1 == "")
{
priority1 = "Low";
}
using (var wb = new WebClient())
{
var data = new NameValueCollection();
//
data["TECHNICIAN_KEY"] = "C641A2A3-4C1E-43FE-A970-DD750BEE42A3";
data["OPERATION_NAME"] = "ADD_REQUEST";
data["format"] = "json";
data["subject"] = "Specify Subject";
data["description"] = "json";
data["INPUT_DATA"] = @"{" + "operation" + ":" + "{" + "details" + ":" + " {" + "subject" + ":" + subject1 + "," + "description" + ":" + description1 + "," + "requester" + ":" + name1 + "," + "priority" + ":" + priority1 + "," + "site" + ":" + "Sample Site" + "," + "technician" + ":" + "[My Name]" + " }" + " }" + " }";
//XmlDocument doc = new XmlDocument();
// doc.LoadXml(string.Format("{ "operation": { "details": { "subject": "Cannotttt browse", "description": "Unable to connect to the internet", "requester": "[My Name]", "site": "Sample Site", "technician": "[My Name]" } } }));
string url = "
http://sdp.mamad.com/sdpapi/request?";
var response = wb.UploadValues(url, "POST", data);
string responseInString = Encoding.UTF8.GetString(response);
MessageBox.Show("پیغام شما جهت بررسی به واحد انفورماتیک ارسال شد", "", MessageBoxButtons.OK,
MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1,
MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading);
textBox1.Text = null;
textSubject.Text = null;
comboBox1.Text = null;
}
}
}
catch
{
}
}
New to ADSelfService Plus?