/** * @param uuid String with the uuid of a person * @return Result containing the response from the cprBroker */ public ActionResult showPerson(String uuid) { String ipAddress = LoggingTools.GetVisitorIPAddress(); String hostName = LoggingTools.GetHostName(ipAddress); // Logging the show request cpreader.Logger.info(String.Format("At <{0}> user <{1}> requested to see uuid <{2}>. Host name: <{3}> at local IP address <{4}>.", DateTime.Now, User.Identity.Name, uuid, hostName, ipAddress )); IPerson person = null; try { person = cprBroker.read(uuid); // Logging the show request cpreader.Logger.info(String.Format("{0}'s request to CPRBroker responded, {1} - {2}.", User.Identity.Name, person.code(), person.message() )); } catch (Exception ex) { cpreader.Logger.error(ex); } SearchInput searchInput = new SearchInput(); searchInput.saveToSession(this); //searchInput.fillFromSession(this); // access level - add to person model if (person == null) { return(View("show_error", new Tuple <int, SearchInput>(503, searchInput))); } if (person.code() == 200) { List <IPerson> persons = new List <IPerson>(); persons.Add(person); String path = Request.Path; int page = 1; int accessLevel = AccessLevelManager.getCurrentAccessLevel(); return(View("list", new list_viewModel( persons, 1, page, path, searchInput, accessLevel))); } else { //TODO - A person wasn't found return(View("show_error", new Tuple <int, SearchInput>(person.code(), searchInput))); } }
protected void btnSearch_Click(object sender, EventArgs e) { UsersManager businesslayer = new UsersManager(); User user = businesslayer.getUserData(txtSearchUser.Text); hidUserID.Value = user.getId().ToString(); txtUsername.Text = user.getUsername(); txtFirstName.Text = user.getFirstName(); txtLastName.Text = user.getLastName(); txtAddress.Text = user.getAddress(); txtCity.Text = user.getCity(); txtAccountCreationDate.Text = user.getAccountCreationDate().ToShortDateString(); txtState.Text = user.getState(); txtZipCode.Text = user.getZipCode(); txtEmail.Text = user.getEamil(); List <AccessLevel> allAccessLevels = AccessLevelManager.getAllLevels(); ddlAccessLevel.DataSource = allAccessLevels; ddlAccessLevel.DataTextField = "level"; ddlAccessLevel.DataValueField = "ID"; ddlAccessLevel.DataBind(); int accessLevel = businesslayer.getUserAccessLevel(user.getId()); ddlAccessLevel.SelectedValue = accessLevel.ToString(); }
public ActionResult updateFullpage(String uuid) { cpreader.Logger.info(String.Format("{0} is accessing overview of person: {1}", User.Identity.Name, uuid )); IPerson person = null; try { person = cprBroker.read(uuid); // Logging the show request cpreader.Logger.info(User.Identity.Name + "'s request to CPRBroker responded, " + person.code() + " - " + person.message()); } catch (Exception ex) { cpreader.Logger.error(ex); } SearchInput searchInput = new SearchInput(); searchInput.fillFromSession(this); // access level - add to person model int accessLevel = AccessLevelManager.getCurrentAccessLevel(); if (accessLevel < 1) { return(PartialView("access_denied", new Tuple <int, SearchInput, string>(401, searchInput, "Access denied."))); } if (person == null) { return(PartialView("show_error", new Tuple <int, SearchInput>(503, searchInput))); } if (person.code() == 200) { ActionResult ret = PartialView("fullpagemodalcontent", new Tuple <IPerson, int>(person, accessLevel)); return(ret); } else { //TODO - A person wasn't found return(PartialView("show_error", new Tuple <int, SearchInput>(person.code(), searchInput))); } }
public ActionResult searchNameAndAddress(String name, String address, bool online, int page) { List <IPerson> persons = null; try { String ipAddress = LoggingTools.GetVisitorIPAddress(); String hostName = LoggingTools.GetHostName(ipAddress); // log what page the user requested cpreader.Logger.info(String.Format("At <{0}> user <{1}> searched for name<{2}>, address<{3}>; online <{4}>, page <{5}>. Host name: <{6}> at local IP address <{7}>.", DateTime.Now, User.Identity.Name, name, address, online, page, hostName, ipAddress )); String key = String.Format("session={0};name={1};address={2}", getSessionId(), name, address); // TODO: See if there is a cahce equivalent in ASP.NET /*if (online && onlineCacheEnabled) * { * Object o = Cache.get(key); * if (o != null) * persons = (List<IPerson>)o; * }*/ if (persons == null) { persons = cprBroker.searchList( name, address, online ? ESourceUsageOrder.ExternalOnly : ESourceUsageOrder.LocalOnly, -1, -1); } // TODO: See if there is a cahce equivalent in ASP.NET /* * if (online && onlineCacheEnabled) * { * // Temporarily store the results for a while * Cache.set(key, persons, onlineCacheTimeout); * }*/ } catch (Exception ex) { cpreader.Logger.error(ex); } String path = Request.Path; path = path.Substring(0, path.IndexOf("page") + 5); SearchInput searchInput = new SearchInput(name, address, online); searchInput.saveToSession(this); int accessLevel = AccessLevelManager.getCurrentAccessLevel(); if (persons != null) { // calculate the searchIndex, which is the starting point of the search int fromIndex = ((page - 1) * 10); int toIndex = ((page) * 10); if (persons.Count < fromIndex) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (persons.Count < toIndex) { toIndex = persons.Count; } List <IPerson> subPersons = persons.Take(toIndex).Skip(fromIndex).ToList(); return(View("list", new list_viewModel(subPersons, persons.Count, page, path, searchInput, accessLevel))); } else { return(View("list", new list_viewModel(persons, 1, page, path, searchInput, accessLevel))); } }