private void LoadView ()
	{
		if (!Authentication.IsLoggedIn (response)) {
			cellLogin.Text = "<li><a href='User.aspx'>Create account</a></li><li><a href='Login.aspx'>Login</a></li>";
			adminmenu.Visible = false;
		} else {
			cellLogin.Text = string.Format ("<li><a href='User.aspx?username={0}'>My Account ({0})</a></li>", Utilities.GetCookie (Request, "user"));
			cellLogout.Text = "<li><a href='Login.aspx?action=logout'>Log out</a></li>";
			adminmenu.Visible = true;
		}

		if (tree_response != null)
			return;

		try {
			tree_response = Utils.LocalWebService.GetLeftTreeData (WebServiceLogin);
		} catch(UnauthorizedException) {
			// LoadView is called on the login page, but if anonymous access is disabled,
			// the user will be 'unauthorized' to view the sidebar, and thus the entire
			// login page.
			// So catch the exception and ignore it.
		}

		if (tree_response != null) {
			CreateTree ();
			CreateHostStatus ();
		}
	}
		public GetLeftTreeDataResponse GetLeftTreeData (WebServiceLogin login)
		{
			var response = new GetLeftTreeDataResponse ();

			using (DB db = new DB ()) {
				Authenticate (db, login, response, true);
				using (var cmd = db.CreateCommand ()) {
					var sql = new StringBuilder ();
					sql.AppendLine ("SELECT * FROM Lane ORDER BY lane;");
					sql.AppendLine ("SELECT * FROM HostStatusView;");
					sql.AppendLine ("SELECT DISTINCT tag FROM LaneTag ORDER BY tag;");
					cmd.CommandText = sql.ToString ();

					using (var reader = cmd.ExecuteReader ()) {
						response.Lanes = DBRecord.LoadMany<DBLane> (reader);

						reader.NextResult ();
						response.HostStatus = DBRecord.LoadMany<DBHostStatusView> (reader);

						reader.NextResult ();
						response.Tags = new List<string> ();
						while (reader.Read ())
							response.Tags.Add (reader.GetString (0));
					}

					response.UploadStatus = Global.UploadStatus;
				}
			}

			return response;
		}
Example #3
0
	private void LoadView ()
	{
		if (!Authentication.IsLoggedIn (response)) {
			cellLogin.Text = "<li><a href='User.aspx'>Create account</a></li><li><a href='Login.aspx'>Login</a></li>";
			adminmenu.Visible = false;
		} else {
			cellLogin.Text = string.Format ("<li><a href='User.aspx?username={0}'>My Account ({0})</a></li>", Utilities.GetCookie (Request, "user"));
			cellLogout.Text = "<li><a href='Login.aspx?action=logout'>Log out</a></li>";
			adminmenu.Visible = true;
		}

		try {
			tree_response = WebService.GetLeftTreeData (WebServiceLogin);
		} catch {
			tree_response = null;
		}

		CreateTree ();
		CreateHostStatus ();
	}