示例#1
0
        protected override void OnLoad(EventArgs e)
        {
            string proxy_location = (Request.Url.Host == "localhost" ? "http://localhost:64657/cec_inputform.ashx?proxy" : "{0}://{1}/cec_inputform.ashx?proxy");

            Page.ClientScript.RegisterClientScriptInclude("webproxy", String.Format(proxy_location, Request.Url.Scheme, Request.Url.Host));

            TabName = status_tabs[0];
            if (Request.QueryString["tab"] != null)
            {
                TabName = Request.QueryString["tab"].ToLower();
            }

            if (UserToken.TokenSet && UserToken.access_level == 200)
            {
                edit_intro.Controls.Clear();
                edit_intro.Controls.Add(new LiteralControl("<div class='row col-sm-12'><h2>Welcome NCI Reviewer,</h2></div>"));
            }
            else if (UserToken.TokenSet && UserToken.access_level == 300)
            {
                if (TabName != "users")
                {
                    addUserBtn.Visible = false;
                }
            }

            if (Array.IndexOf(status_tabs, TabName) > -1)
            {
                if (TabName == "pending")
                {
                    dt_cohorts = CECWebSrv.GetCohortsWithStatusesWithColumns(UserToken, new string[] { "pending" }, "id, cohort_acronym, cohort_name, status_timestamp, [status]");
                    using (DataTable tmp_dt = CECWebSrv.GetCohortsWithStatusesWithColumns(UserToken, new string[] { "inprogress", "rejected" }, "id, cohort_acronym, cohort_name, status_timestamp, [status]"))
                    {
                        foreach (DataRow tmp_dr in tmp_dt.Rows)
                        {
                            dt_cohorts.ImportRow(tmp_dr);
                        }
                    }
                }
                else
                {
                    dt_cohorts = CECWebSrv.GetCohortsByStatusWithColumns(UserToken, TabName, "id, cohort_acronym, cohort_name, [status]");
                }

                cohortList.Sorting +=
                    new GridViewSortEventHandler(cohortList_Sorting);
                cohortList.RowDataBound +=
                    new GridViewRowEventHandler(cohortList_RowDataBound);
            }
            else if (TabName == "users")
            {
                // need to add display name to list of columns
                dt_users = CECWebSrv.GetUsers(UserToken, "uid, username, display_name, email, access_level, cohort_id, account_lockout");

                cohortList.Sorting +=
                    new GridViewSortEventHandler(cohortList_Sorting);
                cohortList.RowDataBound +=
                    new GridViewRowEventHandler(userList_RowDataBound);
            }
            else
            {
                section.Controls.Clear();

                System.Web.UI.HtmlControls.HtmlGenericControl rl =
                    new HtmlGenericControl("div");
                rl.Attributes["class"] = "list-group";
                rl.ID = "reports";
                section.Controls.Add(rl);
                for (int i = 0; i < reports.Length; i++)
                {
                    System.Web.UI.WebControls.HyperLink btn =
                        new HyperLink();
                    btn.CssClass    = "list-group-item";
                    btn.NavigateUrl = String.Format("/input/list.aspx?tab=reports&name={0}", i);
                    btn.Controls.Add(new LiteralControl("<span class=\"glyphicon glyphicon-save-file\"></span> "));
                    btn.Controls.Add(new LiteralControl(reports[i]));
                    rl.Controls.Add(btn);

                    if (Request.QueryString["name"] != null && Request.QueryString["name"] == i.ToString())
                    {
                        string filepath = String.Format("/user_files/{0}/report_{1}.xlsx", UserToken.userid, DateTime.Now.ToString("yyyyMMMddmm"));

                        GenerateExcelReport(i, Server.MapPath(filepath));

                        Page.ClientScript.RegisterStartupScript(GetType(), "downloadExport",
                                                                String.Format("<script>window.open('{0}');</script>", filepath));
                    }
                }
            }

            base.OnLoad(e);
        }
示例#2
0
        protected void forgotPassword_SendBtnClicked(object sender, EventArgs e)
        {
            if (helper.IsStringEmptyWhiteSpace(fg_email.Text))
            {
                fg_errorMsg.InnerText = "Email address cannot be left blank";

                RegisterJSAlert(fg_errorMsg.InnerText);
                return;
            }
            else if (!helper.IsEmailAddress(fg_email.Text))
            {
                fg_errorMsg.InnerText = "Email address not in expected format";

                RegisterJSAlert(fg_errorMsg.InnerText);
                return;
            }

            try
            {
                UserData ud = ps.GetUserInformationByEmail(fg_email.Text);
                CECMembershipProvider prov = (Membership.Providers["CECProvider"] as CECMembershipProvider);
                string newPass             = prov.ResetPassword(ud.email, string.Empty);

                System.Collections.Specialized.NameValueCollection data =
                    new NameValueCollection();
                data.Add("password", newPass);
                data.Add("to", ud.email);

                DataRow[] dr_users;
                using (DataTable dt_users = ps.GetUsers(helper.CreateTemporaryToken(), "uid, username, email"))
                {
                    dr_users = dt_users.Select(String.Format("email='{0}'", ud.email));
                }

                if (dr_users.Length > 1)
                {
                    string additional_accounts = string.Empty;
                    foreach (DataRow dr in dr_users)
                    {
                        additional_accounts += String.Format("\t{0}\n", dr["username"]);
                    }

                    data.Add("additional_accounts", String.Format("<p>The following accounts were updated with the password above because they are associated with this email address:<pre>{0}</pre></p>", additional_accounts));
                }
                else
                {
                    data.Add("additional_accounts", string.Empty);
                }

                ps.CreateEmailAndSend(helper.CreateTemporaryToken(), "lost_password", data);

                CECWebSrv.AuditLog_AddActivity(ud.userid, "password reset; email sent");

                fg_errorMsg.Attributes["class"] = "bg-success text-sucess";
                fg_errorMsg.InnerText           = "Email successfully sent";
                //Response.Redirect("/select.aspx", false);
            }
            catch (Exception ex)
            {
                fg_errorMsg.InnerText = String.Format("Failed to email the password to {0}.", fg_email.Text);
                LogError(fg_errorMsg.InnerText, ex);
            }
        }