protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { //validate user SSPUser user = new SSPUser(); user.LogIn(Login1.UserName, Login1.Password); if (!user.Role.Contains("-1")) { e.Authenticated = true; Session["user"] = user; Session.Add("userckey", user.CKey); HttpCookie myCookie = new HttpCookie("UserSettings"); myCookie["UserName"] = user.FirstName + " " + user.LastName; myCookie["UserCKey"] = user.CKey.ToString(); myCookie.Expires = DateTime.Now.AddDays(365d); Response.Cookies.Add(myCookie); //moved from global SSPWebUI.Data.Dashboard.LoadDashboardData(); Login1.DestinationPageUrl = "ProtocolEditor.aspx"; } }
public string GetRole(string UserCKey, string ProtocolCKey) { try { SSPUser user = SSPUser.GetUserByCKey(decimal.Parse(UserCKey)); if (user.UserType == "6.100004300") { return("99"); } if (ProtocolCKey == null) { return("0"); } user.CKey = decimal.Parse(UserCKey); return(user.GetProtocolRole(decimal.Parse(ProtocolCKey))); } catch (Exception ex) { //throw exception var response = new HttpResponseMessage(HttpStatusCode.BadRequest); response.Content = new StringContent("GetRole: " + ex.Message); throw new HttpResponseException(response); } }
public void LoadAuthors() { lstAddAuthors.DataSource = SSPUser.getAllAuthors(); lstAddAuthors.DataTextField = "Name"; lstAddAuthors.DataValueField = "CKey"; lstAddAuthors.DataBind(); lstAddAuthors.Items.Insert(0, new ListItem("Please select")); }
[ActionName("SetPassword")] //PUT public void SetPassword(UserPassword Pwd) { try { SSPUser.UpdatePassword(Pwd.UserID, Pwd.Password); } catch (Exception ex) { var resp = new HttpResponseMessage(HttpStatusCode.ExpectationFailed) { ReasonPhrase = ex.Message }; throw new HttpResponseException(resp); } }
protected void Page_Init(object sender, EventArgs e) { Protocols.DataSource = SSPWebUI.Data.ProtocolsData.GetProtocols(); Protocols.DataTextField = "ProtocolName"; Protocols.DataValueField = "ProtocolCKey"; Protocols.DataBind(); Protocols.SelectedIndex = 1; Session["CurrentProtocol"] = Protocols.SelectedValue; SSPUser user = (SSPUser)Session["user"]; //set protocol role //user.Role = user.GetProtocolRole(decimal.Parse(Protocols.SelectedValue)); //hidden field hdnUserCKey.Value = user.CKey.ToString(); }
public List <SSPUser> GetAllAuthors() //for dropdown { try { return(SSPUser.getAllAuthors()); } catch (Exception ex) { var resp = new HttpResponseMessage(HttpStatusCode.ExpectationFailed) { ReasonPhrase = ex.Message }; throw new HttpResponseException(resp); } }
[ActionName("Create")] //POST public HttpResponseMessage Post(SSPUser user) { //check if user exists if (SSPUser.GetUserById(user.UserID).UserID != null) { var message = string.Format("User with UserID = {0} already exists", user.UserID); HttpError err = new HttpError(message); return(Request.CreateResponse(HttpStatusCode.NotFound, err)); } else { SSPUser.CreateUser(user); var message = string.Format("User with UserID = {0} already exists", user.UserID); //HttpError err = new HttpError(message); return(Request.CreateResponse(HttpStatusCode.OK, "User created")); } }
public List <Comment> GetComment(decimal ProtocolVersion, string DraftVersion) { try { List <Comment> comments = new List <Comment>(); Comment comment = new Comment(); DataTable dt = comment.GetComments(ProtocolVersion, DraftVersion); foreach (DataRow dr in dt.Rows) { int commentid = int.Parse(dr["Id"].ToString()); decimal userckey = decimal.Parse(dr["UserCKey"].ToString()); string usercomment = dr["Comment"].ToString(); string section = dr["ReviewItem"].ToString(); DateTime dtAdded = DateTime.Parse(dr["DateAdded"].ToString()); string userid = SSPUser.GetUserByCKey(userckey).UserID; string reviewitemckey = dr["ReviewItemCKey"].ToString(); comment = new Comment { Id = commentid, UserCKey = userckey, UserId = userid, DateAdded = dtAdded.ToShortDateString() + " " + dtAdded.ToShortTimeString(), ReviewItem = section, ReviewItemCKey = reviewitemckey, ProtocolVersionCKey = ProtocolVersion, UserComment = usercomment }; comments.Add(comment); } return(comments); } catch (Exception ex) { var resp = new HttpResponseMessage(HttpStatusCode.ExpectationFailed) { ReasonPhrase = ex.Message }; throw new HttpResponseException(resp); } }
protected void grdAuthors_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Footer) { ////Find the DropDownList in the Row //DropDownList lstAuthors = (e.Row.FindControl("lstAuthors") as DropDownList); //lstAuthors.DataSource = SSPUser.getAll(); //new Author().getAuthors(decimal.Parse(hdnProtocolVersionCKey.Value)); //lstAuthors.DataTextField = "Name"; //lstAuthors.DataValueField = "CKey"; //lstAuthors.DataBind(); //lstAuthors.Items.Insert(0, new ListItem("Please select")); ////lstAuthors.Attributes.Add("onchange", "setAuthor('" + lstAuthors.SelectedValue + "')"); //DropDownList lstRoles = (e.Row.FindControl("lstRoles") as DropDownList); //lstRoles.DataSource = Role.getRoles(); //new Author().getAuthors(decimal.Parse(hdnProtocolVersionCKey.Value)); //lstRoles.DataTextField = "RoleName"; //lstRoles.DataValueField = "RoleCKey"; //lstRoles.DataBind(); //lstRoles.Items.Insert(0, new ListItem("Please select")); //lstRoles.Attributes.Add("onchange", "setRole('" + lstRoles.SelectedValue +"')"); //lstAuthors.Items.FindByValue(country).Selected = true; } else if (e.Row.RowType == DataControlRowType.EmptyDataRow) { DropDownList lstAuthors = (e.Row.FindControl("lstAuthors") as DropDownList); lstAuthors.DataSource = SSPUser.getAllAuthors(); //new Author().getAuthors(decimal.Parse(hdnProtocolVersionCKey.Value)); lstAuthors.DataTextField = "Name"; lstAuthors.DataValueField = "CKey"; lstAuthors.DataBind(); lstAuthors.Items.Insert(0, new ListItem("Please select")); DropDownList lstRoles = (e.Row.FindControl("lstRoles") as DropDownList); lstRoles.DataSource = Role.getRoles(); lstRoles.DataTextField = "RoleName"; lstRoles.DataValueField = "RoleCKey"; lstRoles.DataBind(); lstRoles.Items.Insert(0, new ListItem("Please select")); } else if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton EditButton = (LinkButton)e.Row.FindControl("lnkEdit"); LinkButton RemoveButton = (LinkButton)e.Row.FindControl("lnkRemove"); Author dataRecord = (Author)e.Row.DataItem; if (EditButton != null && dataRecord != null) { if (!Request.IsAuthenticated) { EditButton.Visible = false; RemoveButton.Visible = false; } } if ((e.Row.RowState & DataControlRowState.Edit) > 0) { DropDownList lstAuthors = (e.Row.FindControl("lstAuthors") as DropDownList); lstAuthors.DataSource = SSPUser.getAllAuthors(); lstAuthors.DataTextField = "Name"; lstAuthors.DataValueField = "CKey"; lstAuthors.DataBind(); DropDownList lstRoles = (e.Row.FindControl("lstRoles") as DropDownList); lstRoles.DataSource = Role.getRoles(); lstRoles.DataTextField = "RoleName"; lstRoles.DataValueField = "RoleCKey"; lstRoles.DataBind(); Author author = e.Row.DataItem as Author; lstAuthors.SelectedValue = author.AuthorCKey.ToString(); lstRoles.SelectedValue = author.RoleCKey.ToString(); } } }
public List <Comment> GetComments(string protocolckey, string draftversion, string reviewitem, string reviewitemckey, string reviewerckey) { try { List <Comment> comments = new List <Comment>(); Comment comment = new Comment(); DataTable dt = new DataTable(); if (reviewerckey == null) { if (reviewitem != null) { dt = comment.GetComments(decimal.Parse(protocolckey), reviewitem); } else { dt = comment.GetComments(decimal.Parse(protocolckey), draftversion); } } else { if (reviewitemckey != null) { dt = comment.GetCommentsByReviewer(decimal.Parse(protocolckey), draftversion, reviewitem, reviewitemckey, reviewerckey); } else if (reviewitem != null) { dt = comment.GetCommentsByReviewer(decimal.Parse(protocolckey), draftversion, reviewitem, reviewerckey); } else { dt = comment.GetCommentsByReviewer(decimal.Parse(protocolckey), draftversion, decimal.Parse(reviewerckey)); } } foreach (DataRow dr in dt.Rows) { int commentid = int.Parse(dr["Id"].ToString()); decimal userckey = decimal.Parse(dr["UserCKey"].ToString()); string usercomment = dr["Comment"].ToString(); string reviewitm = dr["ReviewItem"].ToString(); DateTime dtAdded = DateTime.Parse(dr["DateAdded"].ToString()); string userid = SSPUser.GetUserByCKey(userckey).UserID; string reviewitmckey = dr["ReviewItemCKey"].ToString(); comment = new Comment { Id = commentid, UserCKey = userckey, UserId = userid, DateAdded = dtAdded.ToShortDateString() + " " + dtAdded.ToShortTimeString(), ReviewItem = reviewitm, ReviewItemCKey = reviewitmckey, ProtocolVersionCKey = decimal.Parse(protocolckey), UserComment = usercomment }; comments.Add(comment); } return(comments); } catch (Exception ex) { var resp = new HttpResponseMessage(HttpStatusCode.ExpectationFailed) { ReasonPhrase = ex.Message }; throw new HttpResponseException(resp); } }
// DELETE api/<controller>/5 public int Delete(string UserID) { SSPUser.DeleteUser(UserID); //must return a value, otherwise ajax DELETE does not work return(200); }
[ActionName("Update")] //PUT public void Put(SSPUser user) { SSPUser.UpdateUser(user); }
// GET api/<controller>/5 public SSPUser GetUserById(string UserID) { return(SSPUser.GetUserById(UserID)); }
// GET api/<controller> public List <SSPUser> GetUsers() { return(SSPUser.getAll()); }