protected HttpResponseMessage GetUserIds(params object[] errors) { Dictionary <string, string[]> userids = UserIDMapper.GetAllUserIds().GroupBy(kvp => kvp.Value).ToDictionary(g => g.Key, g => g.Select(kvp => kvp.Key).ToArray()); return(Html( Head("Xerox Username to Printer Code mapping"), Body( new XElement("p", new XElement("a", new XAttribute("href", Url.Route("default", new { controller = "Home" })), "Back to Cloud Print Server")), new XElement("dl", userids.SelectMany(uid => new object[] { new XElement("dt", "UserID: ", new XElement("a", new XAttribute("href", Url.Route("default", new { controller = "Auditron", userid = uid.Key })), uid.Key)), new XElement("dd", "Username(s): ", String.Join(", ", uid.Value)) }) ), new XElement("form", new XAttribute("action", Url.Route("default", new { controller = "Auditron" })), new XAttribute("method", "post"), new XElement("fieldset", new XElement("legend", "Map UserId"), new XElement("input", new XAttribute("type", "hidden"), new XAttribute("name", "Action"), new XAttribute("value", "AddUserId")), new XElement("p", new XElement("label", new XAttribute("for", "UserId"), "Printer Code:"), new XElement("input", new XAttribute("type", "text"), new XAttribute("name", "UserId")) ), new XElement("p", new XElement("label", new XAttribute("for", "Usernames"), "Username(s):"), new XElement("input", new XAttribute("type", "text"), new XAttribute("name", "Usernames")) ), new XElement("input", new XAttribute("type", "submit"), new XAttribute("value", "Add Printer Code")) ) ) ) )); }
protected HttpResponseMessage Delete(FormDataCollection form) { foreach (string username in form.Where(kvp => kvp.Key.StartsWith("user_")).Select(kvp => kvp.Key.Substring(5))) { UserIDMapper.DeleteUser(username); } return(GetUserId(form.Get("UserId"))); }
protected HttpResponseMessage AddUsers(string userid, string[] usernames) { foreach (string username in usernames) { UserIDMapper.CreateUser(username, userid); } return(GetUserId(userid)); }
public override void Print(CloudPrintJob job) { Dictionary <string, string> pjlattribs = new Dictionary <string, string> { { "LUNA", job.Username }, { "ACNA", job.JobTitle }, { "JOAU", UserIDMapper.GetUserId(job.Username) } }; base.Print(job, false, true, pjlattribs, null); }
protected HttpResponseMessage AddUserId(string userid, string[] usernames) { if (usernames.Length != 0) { foreach (string username in usernames) { UserIDMapper.CreateUser(username, userid); } return(GetUserIds()); } else { return(GetUserId(userid)); } }
protected HttpResponseMessage GetUserId(string userid, params object[] errors) { string[] usernames = UserIDMapper.GetAllUserIds().Where(kvp => kvp.Value == userid).Select(kvp => kvp.Key).ToArray(); return(Html( Head("Xerox Usernames mapped to Printer Code " + userid), Body( new XElement("p", new XElement("a", new XAttribute("href", Url.Route("default", new { controller = "Auditron" })), "Back to Printer Code list")), new XElement("p", new XElement("a", new XAttribute("href", Url.Route("default", new { controller = "Home" })), "Back to Cloud Print Server")), errors, new XElement("form", new XAttribute("action", Url.Route("default", new { controller = "Auditron" })), new XAttribute("method", "post"), new XElement("input", new XAttribute("type", "hidden"), new XAttribute("name", "Action"), new XAttribute("value", "Delete")), new XElement("input", new XAttribute("type", "hidden"), new XAttribute("name", "UserId"), new XAttribute("value", userid)), new XElement("ul", usernames.Select(u => new XElement("li", new XElement("input", new XAttribute("type", "checkbox"), new XAttribute("name", "user_" + u)), new XElement("label", new XAttribute("for", "user_" + u), u) )) ), new XElement("input", new XAttribute("type", "submit"), new XAttribute("value", "Delete")) ), new XElement("form", new XAttribute("action", Url.Route("default", new { controller = "Auditron" })), new XAttribute("method", "post"), new XElement("fieldset", new XElement("legend", "Add Users to Printer Code"), new XElement("input", new XAttribute("type", "hidden"), new XAttribute("name", "Action"), new XAttribute("value", "AddUser")), new XElement("input", new XAttribute("type", "hidden"), new XAttribute("name", "UserId"), new XAttribute("value", userid)), new XElement("label", new XAttribute("for", "Usernames"), "Username(s):"), new XElement("input", new XAttribute("type", "text"), new XAttribute("name", "Usernames")), new XElement("input", new XAttribute("type", "submit"), new XAttribute("value", "Add Username(s)")) ) ) ) )); }
public override bool UserCanPrint(string username) { return(UserIDMapper.GetUserId(username) != null); }