//Returns a html table displaying loginscript data and raw data parition public string parseAndDisplayLoginScript(string loginscript) { var sb = new StringBuilder(); var lines = loginscript.Split('\n'); //Remote comment var linesNetUse = lines.Where<string>(s => s.StartsWith("net use", StringComparison.CurrentCultureIgnoreCase)).ToArray<string>(); var linesNetUseNotDelete = linesNetUse.Where<string>(s => !s.ToLower().Contains(" /d")).ToArray<string>(); var table = new HTMLTableHelper(2); sb.Append("<h3>Networkdrives</h3>"); sb.Append(table.printStart()); sb.Append(table.printRow(new string[] { "Drive Letter", "share" }, true)); foreach (string line in linesNetUseNotDelete) { //net use S: \\adm.aau.dk\Fileshares\DRIFTSDB Regex pattern = new Regex(@"net use (?<drive>.): (?<share>.*)"); Match match = pattern.Match(line.ToLower()); string drive = match.Groups["drive"].Value; string share = match.Groups["share"].Value; sb.Append(table.printRow(new string[] { drive, share }, true)); } sb.Append(table.printEnd()); sb.Append("<h3>Raw<h3>"); foreach (string line in lines) { sb.Append(String.Format("<code>{0}</code><br/>", line.Replace("\r", ""))); } return sb.ToString(); }
protected string doAction(string userjson) { //Print the user info! var sb = new StringBuilder(); if (userjson == null) { sb.Append("User not found i SCSM"); return sb.ToString(); } JavaScriptSerializer js = new JavaScriptSerializer(); js.MaxJsonLength = Int32.MaxValue; dynamic json = js.Deserialize<dynamic>(userjson); sb.Append("<br /><br />" + string.Format("<a href=\"{0}{1}\">Servie Portal User Info</a>", "https://service.aau.dk/user/UserRelatedInfoById/", userID) + "<br/>"); sb.Append("<h1>Open Requests</h1><br />"); var helper = new HTMLTableHelper(4); sb.Append(helper.printStart()); sb.Append(helper.printRow(new string[] { "ID", "Title", "Status", "Last Change" }, true)); for (int i = 0; i < json["MyRequest"].Length; i++) { if (!"Closed".Equals(json["MyRequest"][i]["Status"]["Name"])) { string id = json["MyRequest"][i]["Id"]; string link; if (id.StartsWith("IR")) { link = "https://service.aau.dk/Incident/Edit/" + id; } else //if (id.StartsWith("SR")) { link = "https://service.aau.dk/ServiceRequest/Edit/" + id; } string sID = "<a href=\"" + link + "\" target=\"_blank\">" + json["MyRequest"][i]["Id"] + "</a><br/>"; string sTitle = json["MyRequest"][i]["Title"]; string sStatus = json["MyRequest"][i]["Status"]["Name"]; string tmp = json["MyRequest"][i]["LastModified"]; string sLastChange = Convert.ToDateTime(tmp).ToString(); sb.Append(helper.printRow(new String[] { sID, sTitle, sStatus, sLastChange })); //sb.Append("<a href=\"" + link + "\" target=\"_blank\">" + json["MyRequest"][i]["Id"] + " - " + json["MyRequest"][i]["Title"] + " - " + json["MyRequest"][i]["Status"]["Name"] + "</a><br/>"); } } sb.Append(helper.printEnd()); sb.Append("<br /><br /><h3>Closed Requests</h3>"); sb.Append(helper.printStart()); sb.Append(helper.printRow(new string[] { "ID", "Title", "Status", "Last Change" }, true)); for (int i = 0; i < json["MyRequest"].Length; i++) { if ("Closed".Equals(json["MyRequest"][i]["Status"]["Name"])) { string id = json["MyRequest"][i]["Id"]; string link; if (id.StartsWith("IR")) { link = "https://service.aau.dk/Incident/Edit/" + id; } else //if (id.StartsWith("SR")) { link = "https://service.aau.dk/ServiceRequest/Edit/" + id; } string sID = "<a href=\"" + link + "\" target=\"_blank\">" + json["MyRequest"][i]["Id"] + "</a><br/>"; string sTitle = json["MyRequest"][i]["Title"]; string sStatus = json["MyRequest"][i]["Status"]["Name"]; string tmp = json["MyRequest"][i]["LastModified"]; string sLastChange = Convert.ToDateTime(tmp).ToString(); sb.Append(helper.printRow(new String[] { sID, sTitle, sStatus, sLastChange })); } } sb.Append(helper.printEnd()); //sb.Append("<br /><br/>IsAssignedToUser<br />"); //foreach (dynamic s in json["IsAssignedToUser"]) //for (int i = 0; i < json["IsAssignedToUser"].Length; i++) //{ // sb.Append(json["IsAssignedToUser"][i]["Id"] + " -" + json["IsAssignedToUser"][i]["DisplayName"] + " - " + json["IsAssignedToUser"][i]["Status"]["Name"] + "<br/>"); //} return sb.ToString(); }