protected void FilterEngage_Clicked(object sender, EventArgs e) { EnsureChildControls(); UsingFilterOptions = true; if (inKeyword.Text.ToLower() != "find a cohort by name" && !helper.IsStringEmptyWhiteSpace(inKeyword.Text)) { inKeyword.Text = string.Empty; } CohortIDsToCompare = new string[0]; ArrayList filters = new ArrayList(); foreach (CECFilteringOptions fo in FilterControls) { CheckBox[] cklist = fo.GetCheckedBoxes(); foreach (CheckBox ck in cklist) { filters.Add(ck.ID); } } Session_FilterTreeState = (string[])filters.ToArray(typeof(string)); CurrentFilterString = SqlizeFilterCriteria(); CECWebSrv.AuditLog_AddActivity(UserToken.userid, "select cohort page:search engaged:: " + CurrentFilterString); PopulateSummaryTable(); SetSummaryGridForDisplay(); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!IsPostBack && UserToken.TokenSet) { UserData ud = websrv.GetUserInformationByUserID(UserToken, UserToken.userid); rg_emailAddress.Text = ud.email; rg_displayName.Text = ud.display_name; } if (ForPasswordReset && !IsPostBack) { CECWebSrv.AuditLog_AddActivity(UserToken.userid, "user profile page; for password reset"); userInformation.Visible = false; fg_cancelBtn.Visible = false; rg_errorMsg.InnerText = "Account password has expired, please set a new password"; RegisterJSAlert(rg_errorMsg.InnerText); } else if (!ForPasswordReset) { CECWebSrv.AuditLog_AddActivity(UserToken.userid, "user profile page"); } }
private void PopulateCriteriaFilterTree(CECFilteringOptions tree) { //----- // filtering tree System.Data.DataSet wff = CECWebSrv.GetWebFilterFields(UserToken, tree.RootCategoryID); //TreeNode ptr = new TreeNode(); ///// add the child controls //foreach (DataRow dr in wff.Tables["tbl_web_filter_fields"].Rows) //{ // string nodePath = String.Format("{1}{0}{2}", tree.PathSeparator, dr["category_id"], dr["id"]); // if (tree.FindNode(nodePath) != null) // continue; // if (ptr.Text != (string)dr["category_name"]) // { // ptr = new TreeNode((string)dr["category_name"]); // ptr.Value = dr["category_id"].ToString(); // ptr.Expanded = ((bool)dr["default_expand"] ? true : false); // tree.Nodes.Add(ptr); // } // TreeNode child = // new TreeNode((string)dr["filter_label"], dr["id"].ToString()); // ptr.ChildNodes.Add(child); //} }
protected override bool OnBubbleEvent(object source, EventArgs args) { EnsureChildControls(); bool handled = false; if (args is CommandEventArgs) { CommandEventArgs cea = (args as CommandEventArgs); switch (cea.CommandName) { case "export": handled = true; string filepath = String.Format("./user_files/{0}/cancer_{1}.xlsx", UserToken.userid, DateTime.Now.ToString("yyyyMMMddmm")); PopulateCancerGrid(); ExportDataGridToExcel(cancerTbl, MapPath(filepath)); CECWebSrv.AuditLog_AddActivity(UserToken.userid, "cancer export created"); Page.ClientScript.RegisterStartupScript(GetType(), "downloadExport", String.Format("<script>window.open('{0}');</script>", filepath)); break; } return(handled); } else { return(base.OnBubbleEvent(source, args)); } }
private void CreateTitleListControls(HtmlControl parent, string colTitle, string colList) { if (helper.IsStringEmptyWhiteSpace(colList)) { return; } System.Web.UI.HtmlControls.HtmlGenericControl h3 = new HtmlGenericControl("h3"); h3.InnerText = CECWebSrv.GetCohortWebFieldLabelByColumnName(UserToken, colTitle); parent.Controls.Add(h3); System.Web.UI.HtmlControls.HtmlGenericControl list = new HtmlGenericControl("ul"); if (helper.IsLogicalTrue(dt_cohort.Rows[0][colList])) { list.Controls.Add((new LiteralControl(String.Format("<li>{0}</li>", CECWebSrv.GetCohortWebFieldLabelByColumnName(UserToken, colList))))); } else if (dt_cohort.Rows[0][colList] == DBNull.Value || helper.IsStringEmptyWhiteSpace(dt_cohort.Rows[0][colList].ToString())) { list.Controls.Add(new LiteralControl("<li>Not applicable</li>")); } else { list.Controls.Add((new LiteralControl(String.Format("<li>{0}</li>", dt_cohort.Rows[0][colList])))); } parent.Controls.Add(list); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!IsPostBack) { CECWebSrv.AuditLog_AddActivity(0, "[anonymous] forgot password page"); } }
protected override void CreateChildControls() { select_cancer.UserToken = UserToken; select_cohort.UserToken = UserToken; select_specimenTypes.UserToken = UserToken; bioGridView.ClientIDMode = ClientIDMode.Static; DataTable csDT = CECWebSrv.GetCancerSites(UserToken); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!IsPostBack) { CohortIDsToCompare = new string[0]; CancerTypes = new string[0]; Genders = new string[0]; CECWebSrv.AuditLog_AddActivity(UserToken.userid, "cancer page"); } }
protected override void OnInit(EventArgs e) { base.OnInit(e); shouldRefreshGrid = false; help = new helper(); compareTbl = new DataTable(); compareTbl.TableName = "compareTable"; ///--------------- ///retreive tabs /// tabsTbl = CECWebSrv.GetTabs(UserToken); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (Request.QueryString != null && Request.QueryString.AllKeys.Contains("tab")) { SelectedTabID = int.Parse(Request.QueryString["tab"]); } if (!IsPostBack) { CECWebSrv.AuditLog_AddActivity(UserToken.userid, String.Format("compare page::tab {0}", SelectedTabID)); } // populate filter selections PopulateFilterLabels(); }
protected override bool OnBubbleEvent(object source, EventArgs args) { bool handled = false; if (args is CommandEventArgs) { EnsureChildControls(); CommandEventArgs cea = (args as CommandEventArgs); switch (cea.CommandName) { case "viewDetails": handled = true; redirect = true; redirectionUrl = (String.Format("./cohortDetails.aspx?cohort_id={0}", cea.CommandArgument)); break; case "export": handled = true; string filepath = String.Format("./user_files/{0}/cohortselect_{1}.xlsx", UserToken.userid, DateTime.Now.ToString("yyyyMMMddmm")); PopulateSummaryTable(); ExportDataGridToExcel(summaryTable, MapPath(filepath)); CECWebSrv.AuditLog_AddActivity(UserToken.userid, "select cohort export created"); Page.ClientScript.RegisterStartupScript(GetType(), "downloadExport", String.Format("<script>window.open('{0}');</script>", filepath)); break; } return(handled); } else { return(base.OnBubbleEvent(source, args)); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); PopulateSummaryTable(); if (Request.Params.HasKeys() && Request.Params["__EVENTTARGET"] != null) { if (Request.Params["__EVENTTARGET"].Contains("cohortCompare")) { string id = Request.Params["__EVENTARGUMENT"]; SaveCohortIDToSession(id); /// return focus to clicked checkbox checkboxToGetFocus = "compare_" + id; } } // not sure why this does not consistently work. if ((Request.UrlReferrer != null) && !(Request.UrlReferrer.PathAndQuery.Contains("/select.aspx") || Request.UrlReferrer.PathAndQuery.EndsWith("/"))) { RestoreFilterTreeSessionStates(); } PopulateSummaryTable(); SetSummaryGridForDisplay(); //UserData ud = CECWebSrv.GetUserInformation(UserToken.email); //if (!ud.help_shown) //{ // Page.ClientScript.RegisterStartupScript(typeof(CECPage), "HelpTour", "tour.init(); tour.restart();", true); // ud.help_shown = true; // CECWebSrv.SetUserSecurityAttributes(UserToken, ud); //} if (!IsPostBack) { CECWebSrv.AuditLog_AddActivity(UserToken.userid, "select cohort page"); } }
protected override bool OnBubbleEvent(object source, EventArgs args) { bool handled = false; if (args is CommandEventArgs) { CommandEventArgs cea = (args as CommandEventArgs); switch (cea.CommandName) { //case "tabNav": //handled = true; //SelectedTabID = Convert.ToInt32(cea.CommandArgument); //PopulateCompareGrid(); //break; case "export": handled = true; //if (compareTbl == null) PopulateCompareGrid(); string filepath = String.Format("./user_files/{0}/compare{1}_{2}.xlsx", UserToken.userid, SelectedTabID, DateTime.Now.ToString("yyyyMMMddmm")); ExportDataGridToExcel(compareTbl, MapPath(filepath)); CECWebSrv.AuditLog_AddActivity(UserToken.userid, "compare export created"); Page.ClientScript.RegisterStartupScript(GetType(), "downloadExport", String.Format("<script>window.open('{0}');</script>", filepath)); break; } return(handled); } else { return(base.OnBubbleEvent(source, args)); } }
/// <summary> /// handles the check all control /// </summary> protected void OnSelectAll_Toggle(object sender, EventArgs e) { System.Collections.ArrayList arr = new ArrayList(CohortIDsToCompare); CompareAllCohortsCheckBox_Checked = select_all.Checked; if (select_all.Checked) { //----- // bind summary grid data System.Data.DataSet sg = CECWebSrv.GetCohortForSummaryGrid(UserToken, SqlizeFilterCriteria()); System.Data.DataTable t = sg.Tables["tbl_web_cohorts_v4_0"]; foreach (DataRow dr in t.Rows) { int acronymIndex = t.Columns.IndexOf("cohort_acronym"); int cId = (int)CECWebSrv.GetCohortDetails(UserToken, dr["cohort_acronym"].ToString()).Tables[0].Rows[0]["cohort_id"]; if (!arr.Contains(cId.ToString())) { arr.Add(cId.ToString()); } } } else { arr.Clear(); } CohortIDsToCompare = (string[])arr.ToArray(typeof(string)); SetSummaryGridForDisplay(); /// return focus to clicked checkbox checkboxToGetFocus = select_all.ID; }
protected override void OnLoad(EventArgs e) { if (Session["PageException"] != null) { Exception ex = (Exception)Session["PageException"]; if (!IsPostBack) { CECWebSrv.AuditLog_AddActivity((UserToken.userid == 0 ? 0 : UserToken.userid), String.Format("website error, email {0} :: {1}", GetUserEmail(), ex.Message)); } switch (ex.Message.ToLower()) { #region Session/Login Related Errors case "session is invalid": error_sessioninvalid.Visible = true; break; case "invalid session id": error_sessioninvalid.Visible = true; break; case "session not valid": error_sessioninvalid.Visible = true; break; case "accountlockedoutexception": error_accountlockout.Visible = true; break; #endregion default: // ignore bad request url errors if (ex.Message.ToLower().Contains("dangerous request.rawurl value")) { simpleError.InnerText = "bad url detected"; break; } ///----------------------------------- /// exception message to screen /// simpleError.InnerHtml = helper.HTMLEncode(ex.Message); #if (DEBUG || DEBUGDEV) simpleError.InnerHtml += "<br /><br />" + ex.StackTrace.Replace(Environment.NewLine, "<br />"); #endif LogError(simpleError.InnerText, ex); try { Session.RemoveAll(); FormsAuthentication.SignOut(); string messageContent = String.Format("Error Was Encountered On {1} {0} {2} {0}{0} Error Origin: {3}{0} User: {4}{0} {0}Stack Trace: {5}", (new object[] { Environment.NewLine, Request.Url.Authority, ex.Message, helper.HTMLEncode(GetReferrerUrl()), GetUserEmail(), ex.ToString() })); if (ex is AccountLockedOutException) { messageContent = "Login Attempted With Locked Account " + (ex as AccountLockedOutException).User; } //System.Net.Mail.MailMessage msg = // new MailMessage("*****@*****.**", Configuration["EmailRecipient"], "CEDCD Website Error Encountered", messageContent); //helper help = new helper(); //help.SendEmail(msg); //simpleError.InnerHtml += String.Format("<br/><br/>Email Sent To Web Admins"); } catch (Exception oops) { simpleError.InnerHtml += String.Format("<br/><br/>Error Sending Email: {0}", oops.Message); LogError(simpleError.InnerText, ex); } break; } } }
private void PopulateCancerGrid() { Genders = gender.GetSelectedOptions(); cancerTbl = new DataTable(); cancerTbl.TableName = "cancerTable"; if (CohortIDsToCompare.Length == 0 || CancerTypes.Length == 0 || Genders.Length == 0) //|| CancerCategory.Length == 0 { cancerGridView.DataSource = cancerTbl; cancerGridView.DataBind(); cancerGridView.Visible = false; return; } else { cancerGridView.Visible = true; cancerGridView.Attributes["has_results"] = "true"; } //----- // retreive field display settings webfieldsTbl = CECWebSrv.GetCohortWebFieldsForCancerGrid(UserToken).Tables[0]; /*ArrayList tGenders = new ArrayList(); * if (cb_gmale.Checked) * tGenders.Add("male"); * if (cb_gfemale.Checked) * tGenders.Add("female"); */ // (string[])tGenders.ToArray(typeof(string)); //----- // bind cancer grid data System.Data.DataSet sg; if (CohortIDsToCompare.Length > 0 && CancerTypes.Length > 0) { sg = CECWebSrv.GetCohortForCancerGrid(UserToken, CancerTypes, Genders, CohortIDsToCompare); } else { sg = new DataSet(); sg.Tables.Add("tbl_cancer"); } DataTable t = sg.Tables["tbl_cancer"]; // cancerTbl instantiated in OnInit() //cancerTbl = new DataTable(); //cancerTbl.TableName = "cancerTable"; // add empty column at index 0 and 1 cancerTbl.Columns.Add(new DataColumn()); cancerTbl.Columns[0].ColumnName = "Cancer"; cancerTbl.Columns.Add(new DataColumn()); cancerTbl.Columns[1].ColumnName = "Gender"; cancerTbl.PrimaryKey = new DataColumn[] { cancerTbl.Columns[0], cancerTbl.Columns[1] }; // if nothing selected to query, end routine here if (CohortIDsToCompare.Length == 0 || CancerTypes.Length == 0 || Genders.Length == 0) { cancerTbl.Rows.Add((new object[] { "Select options to continue" })); return; } // find acronym position and build the pivot table column names int acronymPosition = t.Columns.IndexOf("cohort_acronym"); for (int _p = 0; _p < t.Rows.Count; _p++) { if (acronymPosition > -1 && cancerTbl.Columns.IndexOf(t.Rows[_p][acronymPosition].ToString()) == -1) { cancerTbl.Columns.Add(new DataColumn(t.Rows[_p][acronymPosition].ToString())); } } ///--------------------------------------------- /// fill pivot table of reported cancer counts string _curCancer = string.Empty; int _curCancerIndx = 0; DataRow dr_m = null, dr_f = null; bool male = false, female = false; foreach (string s in Genders) { if (s == "male") { male = true; } else if (s == "female") { female = true; } } ///-------------------------------------------- /// any cancer sites selected if (CancerTypes.Length > 0 && CohortIDsToCompare.Length > 0) { for (int _col = 2; _col < t.Columns.Count; _col++) { if ((CancerTypes.Length > _curCancerIndx) && _curCancer != CancerTypes[_curCancerIndx]) { _curCancer = CancerTypes[_curCancerIndx]; if (!cancerTbl.Rows.Contains(new string[] { _curCancer, "Males" })) //t.Rows[_row]["cancer_type_id"].ToString()) !t.Columns[_col].ColumnName.ToLower().Contains(CancerTypes[_curCancerIndx]) { //_curCancer = CancerTypes[_curCancerIndx++]; //t.Rows[_row]["cancer_type_id"].ToString(); dr_m = cancerTbl.NewRow(); dr_m[0] = _curCancer; dr_m[1] = string.Format("{0}", "Males"); if (male) { cancerTbl.Rows.Add(dr_m); } } if (!cancerTbl.Rows.Contains(new string[] { _curCancer, "Females" })) { dr_f = cancerTbl.NewRow(); dr_f[0] = _curCancer; dr_f[1] = string.Format("{0}", "Females"); if (female) { cancerTbl.Rows.Add(dr_f); } } } for (int _row = 0; _row < t.Rows.Count; _row++) { //if ((CancerTypes.Length > _curCancerIndx) && !t.Columns[_col].ColumnName.ToLower().Contains(CancerTypes[_curCancerIndx])) // _curCancerIndx++; //if (_curCancerIndx >= CancerTypes.Length) // break; string _curCohort = (string)t.Rows[_row]["cohort_acronym"]; int aCol = cancerTbl.Columns.IndexOf(_curCohort); if (t.Columns[_col].ColumnName.ToLower().Contains("_male")) { dr_m[aCol] = t.Rows[_row][_col]; } if (t.Columns[_col].ColumnName.ToLower().Contains("_female")) { dr_f[aCol] = t.Rows[_row][_col]; } } if ((t.Columns.Count > _col + 1) && !t.Columns[_col + 1].ColumnName.ToLower().Contains(CancerTypes[_curCancerIndx])) { _curCancerIndx++; } } for (int _col = 0; _col < cancerTbl.Columns.Count; _col++) { for (int _row = 0; _row < cancerTbl.Rows.Count; _row++) { if (helper.IsNumerical(cancerTbl.Rows[_row][_col])) { cancerTbl.Rows[_row][_col] = helper.FormatCount(int.Parse(cancerTbl.Rows[_row][_col].ToString())); } } } } cancerGridView.DataSource = cancerTbl; cancerGridView.DataBind(); }
protected void cancerGridView_RowDataBound(object source, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { for (int _i = 0; _i < e.Row.Cells.Count; _i++) { System.Web.UI.WebControls.TableHeaderCell hc = new TableHeaderCell(); hc.ID = cancerTbl.Columns[_i].ColumnName.Replace(" ", string.Empty); if (CECWebSrv.IsCohort(UserToken, e.Row.Cells[_i].Text)) { DataRow dr_cohort = null; using (DataTable dt = CECWebSrv.GetFilteredCohortRecords(UserToken, "cohort_id, cohort_name, cohort_acronym", String.Format("cohort_acronym='{0}'", cancerTbl.Columns[_i].ColumnName)).Tables[0]) dr_cohort = dt.Rows[0]; System.Web.UI.HtmlControls.HtmlAnchor cohortLnk = new HtmlAnchor(); cohortLnk.HRef = String.Format("./cohortDetails.aspx?cohort_id={0}", dr_cohort["cohort_id"]); cohortLnk.Attributes["tabindex"] = "0"; cohortLnk.Attributes["role"] = "button"; cohortLnk.Attributes["data-toggle"] = "popover"; cohortLnk.Attributes["data-trigger"] = "focus"; cohortLnk.Attributes["data-placement"] = "top"; cohortLnk.Attributes["data-trigger"] = "hover"; cohortLnk.Attributes["data-content"] = String.Format("{0}", dr_cohort["cohort_name"]); cohortLnk.InnerHtml = helper.HTMLEncode(e.Row.Cells[_i].Text); hc.CssClass = "table-col-10perc sortable"; hc.Controls.Add(cohortLnk); } else { hc.CssClass = "table-col-20perc"; hc.Text = e.Row.Cells[_i].Text; } e.Row.Cells.RemoveAt(_i); e.Row.Cells.AddAt(_i, hc); } e.Row.TableSection = TableRowSection.TableHeader; } else if (e.Row.RowType == DataControlRowType.DataRow) { /// if the cell is just "Select Cancer Site..." if (e.Row.Cells[0] != null && (e.Row.Cells[0].Text == "Select Cancer Type To Continue" || e.Row.Cells[0].Text.Contains("None of the select cohorts reported any"))) { return; } ///--------------------------------------------------- /// change to tableheadercell the gender /// string orgColumnName = e.Row.Cells[1].Text; //string _curSumLbl = orgColumnName.Split('.')[1]; System.Web.UI.WebControls.TableHeaderCell nmHdr = new TableHeaderCell(); nmHdr.Attributes["headers"] = cancerTbl.Columns[0].ColumnName.Replace(" ", string.Empty); nmHdr.ID = orgColumnName; nmHdr.Text = orgColumnName; //nmHdr.Controls.Add(new LiteralControl(orgColumnName)); //CECWebSrv.GetCohortWebFieldLabelByColumnName(UserToken, orgColumnName) e.Row.Cells.RemoveAt(1); e.Row.Cells.AddAt(1, nmHdr); ///--------------------------------------------------- /// change to tableheadercell the cancer /// string _curCanLbl = e.Row.Cells[0].Text; if (Genders.Length == 2) { if (e.Row.Cells[1].Text == "Males") { System.Web.UI.WebControls.TableHeaderCell cnHdr = new TableHeaderCell(); cnHdr.CssClass = "comRowHeader"; cnHdr.ID = _curCanLbl; cnHdr.RowSpan = 2; cnHdr.Text = select_cancer.cancer_list[e.Row.Cells[0].Text]; ///cnHdr.Controls.Add(new LiteralControl()); //CECWebSrv.GetCancerLabel(UserToken, int.Parse(e.Row.Cells[0].Text) e.Row.Cells.RemoveAt(0); e.Row.Cells.AddAt(0, cnHdr); } else { e.Row.Cells.RemoveAt(0); } } else { System.Web.UI.WebControls.TableHeaderCell cnHdr = new TableHeaderCell(); cnHdr.CssClass = "comRowHeader"; cnHdr.ID = _curCanLbl; cnHdr.Text = select_cancer.cancer_list[e.Row.Cells[0].Text]; //cnHdr.Controls.Add(new LiteralControl()); //CECWebSrv.GetCancerLabel(UserToken, int.Parse(e.Row.Cells[0].Text) e.Row.Cells.RemoveAt(0); e.Row.Cells.AddAt(0, cnHdr); } ///----------------------------------------------------- /// go through the cells starting at a specific index to write /// in attributes for screen readers for (int _i = 1; _i < e.Row.Cells.Count; _i++) { string _cohort = string.Empty; if (e.Row.Cells.Count < cancerTbl.Columns.Count) { _cohort = cancerTbl.Columns[_i + 1].ColumnName; } else { _cohort = cancerTbl.Columns[_i].ColumnName; } e.Row.Cells[_i].Attributes["headers"] = String.Format("{0} {1} {2}", _curCanLbl, orgColumnName, _cohort); /// --------------------------------------- /// was N/P, per Amy 23-April, 0 is preferred /// per Amy, 4-May, 0 should appear if the cohort has incident cancers--even for prevelant; /// show N/P if incident and prevelant is not provided if (String.IsNullOrWhiteSpace(e.Row.Cells[_i].Text) || e.Row.Cells[_i].Text == "-1" || e.Row.Cells[_i].Text == " ") { e.Row.Cells[_i].Text = "N/P"; //if (CECWebSrv.CohortHasCancerIndicator(UserToken, (CancerCategory.ToLower() == "incident" ? "prevalent" : "incident"), _cohort)) //e.Row.Cells[_i].Text = "0"; //else // e.Row.Cells[_i].Text = "N/P"; } } } }
protected void compareGridView_RowDataBound(object source, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { for (int _i = 0; _i < e.Row.Cells.Count; _i++) { System.Web.UI.WebControls.TableHeaderCell hc = new TableHeaderCell(); hc.ID = compareTbl.Columns[_i].ColumnName.Replace(" ", string.Empty); if (CECWebSrv.IsCohort(UserToken, e.Row.Cells[_i].Text)) { DataRow dr_cohort = null; using (DataTable dt = CECWebSrv.GetFilteredCohortRecords(UserToken, "cohort_id, cohort_name, cohort_acronym", String.Format("cohort_acronym='{0}'", compareTbl.Columns[_i].ColumnName)).Tables[0]) dr_cohort = dt.Rows[0]; System.Web.UI.HtmlControls.HtmlAnchor cohortLnk = new HtmlAnchor(); cohortLnk.HRef = String.Format("./cohortDetails.aspx?cohort_id={0}", dr_cohort["cohort_id"]);; cohortLnk.Attributes["tabindex"] = "0"; cohortLnk.Attributes["role"] = "button"; cohortLnk.Attributes["data-toggle"] = "popover"; cohortLnk.Attributes["data-trigger"] = "focus"; cohortLnk.Attributes["data-placement"] = "top"; cohortLnk.Attributes["data-trigger"] = "hover"; cohortLnk.Attributes["data-content"] = String.Format("{0}", dr_cohort["cohort_name"]); cohortLnk.InnerHtml = helper.HTMLEncode(e.Row.Cells[_i].Text); hc.CssClass = "table-col-10perc "; hc.Controls.Add(cohortLnk); } else { hc.CssClass = "table-col-20perc"; hc.Text = e.Row.Cells[_i].Text; } e.Row.Cells.RemoveAt(_i); e.Row.Cells.AddAt(_i, hc); } e.Row.ID = "sticker"; e.Row.TableSection = TableRowSection.TableHeader; } else if (e.Row.RowType == DataControlRowType.DataRow) { DataRow[] dra = webfieldsTbl.Select(String.Format("data_field='{0}'", e.Row.Cells[0].Text)); DataRow dr = dra[0]; int wholeNumber = (int)double.Parse(dr["compare_position"].ToString()); if (_webfieldPosition != wholeNumber) { _webfieldPosition = wholeNumber; // add merged cells above this position to display as groupings System.Web.UI.WebControls.TableHeaderCell tc1 = new TableHeaderCell(); tc1.ColumnSpan = e.Row.Cells.Count; tc1.ID = webfieldsTbl.Select("compare_position=" + _webfieldPosition)[0]["field_label"].ToString().Replace(" ", String.Empty); tc1.Attributes["headers"] = compareTbl.Columns[0].ColumnName.Replace(" ", string.Empty); tc1.Attributes["tabindex"] = "0"; tc1.CssClass = "compareGroup-header"; tc1.Controls.Add(new LiteralControl(webfieldsTbl.Select("compare_position=" + _webfieldPosition)[0]["field_label"].ToString())); // expandable/collapsable sections int rows = webfieldsTbl.Select(String.Format("compare_position > {0} and compare_position < ({0} + 1) and compare_parent_id=0", wholeNumber)).Length; System.Web.UI.HtmlControls.HtmlAnchor expand = new HtmlAnchor(); expand.ID = dr["id"].ToString(); expand.Attributes["class"] = "section-expand"; expand.Attributes["target-rows"] = rows.ToString(); tc1.Controls.Add(expand); System.Web.UI.WebControls.GridViewRow gvr = new GridViewRow(e.Row.RowIndex, -1, DataControlRowType.DataRow, DataControlRowState.Normal); gvr.Cells.AddAt(0, tc1); int lastIndex = compareGridView.Controls[0].Controls.Count - 1; compareGridView.Controls[0].Controls.AddAt(lastIndex, gvr); } string columnName = e.Row.Cells[0].Text; //string _curSumLbl = orgColumnName.Split('.')[1]; // current grouping string _curGroupLbl = string.Empty; if (_webfieldPosition > 0) { _curGroupLbl = webfieldsTbl.Select("compare_position=" + _webfieldPosition)[0]["field_label"].ToString().Replace(" ", string.Empty); } ///--------------------------------------------------- /// change to tableheadercell /// System.Web.UI.WebControls.TableHeaderCell nmHdr = new TableHeaderCell(); nmHdr.ID = columnName; nmHdr.Controls.Add(new LiteralControl(CECWebSrv.GetCohortWebFieldLabelByColumnName(UserToken, columnName))); ///--------------------------------------------------- /// add control for field description /// if (IsFieldDescriptionEnabled(columnName)) { nmHdr.Controls.Add(FieldDescriptionShowButton(columnName)); Page.Controls.Add(FieldDescriptionModalDialog(columnName)); } if ((dr["compare_parent_id"] == DBNull.Value || (int)dr["compare_parent_id"] == 0) && (dr["compare_expandable"] == DBNull.Value || (bool)dr["compare_expandable"] == false)) { e.Row.CssClass = "compare-row compare-section-hidden"; } if ((int)dr["compare_parent_id"] != 0) { nmHdr.CssClass = "compareChildRecord"; e.Row.CssClass = "compare-child-row-hidden compare-child-row"; } if (dr["compare_expandable"] != DBNull.Value && Convert.ToBoolean(dr["compare_expandable"])) { int rows = webfieldsTbl.Select(String.Format("compare_parent_id={0}", dr["id"])).Length; System.Web.UI.HtmlControls.HtmlAnchor expand = new HtmlAnchor(); expand.ID = dr["id"].ToString(); expand.Attributes["class"] = "row-expand"; expand.Attributes["target-rows"] = rows.ToString(); //expand.Click += // new EventHandler(Expandable_Clicked); if (ExpandedFieldIds.IndexOf(Convert.ToInt32(dr["id"])) > -1) { //expand.CssClass += " active"; //expand.ImageUrl = "/images/minus.gif"; ///------------------------------ /// tab ids are added in a first in/last out fashion /// if (expand.ID == ExpandedFieldIds[ExpandedFieldIds.Count - 1].ToString()) { SetFocus(nmHdr); } } // else // expand.ImageUrl = "/images/plus.gif"; nmHdr.Controls.Add(expand); e.Row.CssClass = "compare-parent-row compare-section-hidden"; } e.Row.Cells.RemoveAt(0); e.Row.Cells.AddAt(0, nmHdr); ///-------------------------------------------------- /// the data cells: add header cell ids. for (int _i = 0; _i < e.Row.Cells.Count; _i++) { if (_i == 0) { e.Row.Cells[_i].Attributes["headers"] = String.Format("{0} {1}", _curGroupLbl, compareTbl.Columns[_i].ColumnName.Replace(" ", string.Empty)); } else { e.Row.Cells[_i].Attributes["headers"] = String.Format("{0} {1} {2}", _curGroupLbl, columnName, compareTbl.Columns[_i].ColumnName.Replace(" ", string.Empty)); e.Row.Cells[_i].Text = Server.HtmlDecode(e.Row.Cells[_i].Text); } } //if (dr["compare_parent_id"] != DBNull.Value) //{ //e.Row.Cells[1].CssClass = "childTextLabel"; //if (Convert.ToInt32(dr["field_order"]) % 2 == 0) // e.Row.CssClass = " childText_AltEven"; //else // e.Row.CssClass = " childText_AltOdd"; //} //else // e.Row.Cells[1].CssClass = "textLabel"; // e.Row.Cells[1].Text = CECWebSrv.GetCohortWebFieldLabelByColumnName(UserToken, colName); //for (int _i = 2; _i < e.Row.Cells.Count; _i++) // e.Row.Cells[_i].CssClass = "numberLabel"; } }
private void PopulateCompareGridWithChildren(int parentFieldId) { if (Session["CohortIDsToCompare"] == null) { throw new Exception("never would have thought you could get here without having Session.CohortIDsToCompare already defined"); } //----- // bind summary grid data System.Data.DataSet sg = CECWebSrv.GetCohortForCompareGridByParentID(UserToken, (string[])Session["CohortIDsToCompare"], parentFieldId); DataTable t = sg.Tables["tbl_web_cohorts_v4_0"]; // fill the pivot table for (int _col = 0; _col < t.Columns.Count; _col++) { /// support for virtual fields DataTable cohortFieldsTbl = CECWebSrv.GetCohortWebFieldByColumnName(UserToken, t.Columns[_col].ColumnName); //--- // columns that have a position of 0 should not be displayed if ((DBNull.Value == cohortFieldsTbl.Rows[0]["compare_position"]) || Convert.ToInt32(cohortFieldsTbl.Rows[0]["compare_position"]) == 0) { continue; } DataRow dr = compareTbl.NewRow(); dr[0] = t.Columns[_col].ColumnName; for (int _row = 0; _row < t.Rows.Count; _row++) { /// -------------------------------------------------- /// for version 3, unanswered data points will be blank (''), null or -1, transform to N/P (not provided) ///--------------------------------------------------- /// (BUGNET: CEC-5278) [SUPERSEDED] /// if (DBNull.Value == t.Rows[_row][_col] || helper.IsStringEmptyWhiteSpace(t.Rows[_row][_col].ToString()) || t.Rows[_row][_col].ToString() == "-1") { dr[_row + 1] = "N/P"; } //else if ((SelectedTabID == 6) && t.Columns[_col].ColumnName == "tech_use_of_mobile" || t.Columns[_col].ColumnName == "tech_use_of_cloud") //{ // string v = t.Rows[_row][_col].ToString(); // if (Convert.ToInt32(v) == 0) // dr[_row + 1] = "**Yes**"; // else if (Convert.ToInt32(v) == 1) // dr[_row + 1] = "**No but considering it**"; // else // dr[_row + 1] = "**No and no plans to do so**"; //} else if (helper.IsNumerical(t.Rows[_row][_col]) && !(t.Columns[_col].ColumnName.ToLower().Contains("date") || t.Columns[_col].ColumnName.ToLower().Contains("year"))) { int num = Convert.ToInt32(t.Rows[_row][_col]); dr[_row + 1] = helper.FormatCount(num); } else if (t.Columns[_col].DataType == typeof(DateTime)) { dr[_row + 1] = DateTime.Parse(t.Rows[_row][_col].ToString()).ToString("MM/dd/yyyy"); } //else if (t.Columns[_col].DataType == typeof(Boolean)) //{ // if (Convert.ToBoolean(t.Rows[_row][_col])) // dr[_row + 1] = "**Yes**"; // else // dr[_row + 1] = "**No**"; //} //else if (help.IsStringEmptyWhiteSpace(t.Rows[_row][_col].ToString())) // dr[_row + 1] = "**N/A**"; else { dr[_row + 1] = t.Rows[_row][_col]; } } compareTbl.Rows.Add(dr); } }
private DataTable PopulateSummaryTable() { //----- // bind summary grid data System.Data.DataSet sg; if (UsingFilterOptions) { sg = CECWebSrv.GetCohortForSummaryGrid(UserToken, CurrentFilterString); } else { sg = CECWebSrv.GetCohortForSummaryGrid(UserToken, String.Format(" (lower(cohort_name) like '%{0}%') OR (lower(cohort_acronym) like '%{0}%') ", helper.SterilizeDBText(inKeyword.Text.ToLower()))); } System.Data.DataTable t = sg.Tables["tbl_web_cohorts_v4_0"]; summaryTable = new DataTable(); foreach (DataColumn dc in t.Columns) { // columns that have a position of 0 should not be displayed if (Convert.ToInt32(CECWebSrv.GetCohortWebFieldByColumnName(UserToken, dc.ColumnName).Rows[0]["summary_position"]) == 0) { continue; } summaryTable.Columns.Add(dc.ColumnName); } foreach (DataRow dr in t.Rows) { DataRow ndr = summaryTable.NewRow(); for (int _col = 0; _col < t.Columns.Count; _col++) { //--- // columns that have a position of 0 should not be displayed if (Convert.ToInt32(CECWebSrv.GetCohortWebFieldByColumnName(UserToken, t.Columns[_col].ColumnName).Rows[0]["summary_position"]) == 0) { continue; } if (t.Columns[_col].DataType == typeof(DateTime)) { ndr[_col - 1] = DateTime.Parse(dr[_col].ToString()).ToString("MM/dd/yyyy"); } else if (helper.IsNumerical(dr[_col]) && !(t.Columns[_col].ColumnName.ToLower().Contains("date") || t.Columns[_col].ColumnName.ToLower().Contains("year"))) { ndr[_col - 1] = helper.FormatCount((int)dr[_col]); } else { ndr[_col - 1] = dr[_col].ToString(); } } summaryTable.Rows.Add(ndr); } summaryGridView.DataSource = summaryTable; return(summaryTable); }
private void PopulateCompareGrid() { if ((Session["CohortIDsToCompare"] == null) || ((string[])Session["CohortIDsToCompare"]).Length <= 0) { Response.Redirect("./cohortSelect.aspx"); } compareGridView.Attributes["has_results"] = "true"; //----- // reset the position integer _webfieldPosition = 0; //----- // retreive field display settings webfieldsTbl = CECWebSrv.GetCohortWebFieldsForCompareGrid(UserToken, SelectedTabID).Tables[0]; //----- // bind summary grid data System.Data.DataSet sg; if ((Session["CohortIDsToCompare"] != null) && ((string[])Session["CohortIDsToCompare"]).Length > 0) { sg = CECWebSrv.GetCohortForCompareGridByTabId(UserToken, (string[])Session["CohortIDsToCompare"], SelectedTabID); } else { sg = new DataSet(); sg.Tables.Add("tbl_web_cohorts_v4_0"); } DataTable t = sg.Tables["tbl_web_cohorts_v4_0"]; // compareTbl instantiated in OnInit() //compareTbl = new DataTable(); //compareTbl.TableName = "compareTable"; // add empty column at index 0 compareTbl.Columns.Add(new DataColumn()); if (SelectedTabID == 2) { compareTbl.Columns[0].ColumnName = "Data Collected at Baseline"; } else if (SelectedTabID == 3) { compareTbl.Columns[0].ColumnName = "Data Collected at Followup"; } else if (SelectedTabID == 4) { compareTbl.Columns[0].ColumnName = "Cancer Information"; } else if (SelectedTabID == 7) { compareTbl.Columns[0].ColumnName = "Specimens Collected"; } else { compareTbl.Columns[0].ColumnName = "Data Collected"; } // find acronym position and build the pivot table column names int acronymPosition = t.Columns.IndexOf("cohort_acronym"); for (int _p = 0; _p < t.Rows.Count; _p++) { if (acronymPosition > -1 && compareTbl.Columns.IndexOf(t.Rows[_p][acronymPosition].ToString()) == -1) { compareTbl.Columns.Add(new DataColumn(t.Rows[_p][acronymPosition].ToString())); } } // fill the pivot table for (int _col = 0; _col < t.Columns.Count; _col++) { DataTable cohortFieldsTbl = CECWebSrv.GetCohortWebFieldByColumnName(UserToken, t.Columns[_col].ColumnName); //--- // columns that have a position of 0 should not be displayed if (cohortFieldsTbl.Rows.Count == 0 || DBNull.Value == cohortFieldsTbl.Rows[0]["compare_position"] || Convert.ToInt32(cohortFieldsTbl.Rows[0]["compare_position"]) == 0) { continue; } //--- // child fields should not be displayed unless explicitly called on in the routine // further down //if (cohortFieldsTbl.Rows[0]["compare_parent_id"] != DBNull.Value && (int)cohortFieldsTbl.Rows[0]["compare_parent_id"] != 0) // continue; DataRow dr = compareTbl.NewRow(); dr[0] = t.Columns[_col].ColumnName; for (int _row = 0; _row < t.Rows.Count; _row++) { /// -------------------------------------------------- /// for version 3, unanswered data points will be blank (''), null or -1, transform to N/P (not provided) ///--------------------------------------------------- /// (BUGNET: CEC-5278) [SUPERSEDED] /// if (DBNull.Value == t.Rows[_row][_col] || helper.IsStringEmptyWhiteSpace(t.Rows[_row][_col].ToString()) || t.Rows[_row][_col].ToString() == "-1") { dr[_row + 1] = "N/P"; } //else if ((SelectedTabID == 6) && t.Columns[_col].ColumnName == "tech_use_of_mobile" || t.Columns[_col].ColumnName == "tech_use_of_cloud") //{ // string v = t.Rows[_row][_col].ToString(); // if (Convert.ToInt32(v) == 0) // dr[_row + 1] = "**Yes**"; // else if (Convert.ToInt32(v) == 1) // dr[_row + 1] = "**No but considering it**"; // else // dr[_row + 1] = "**No and no plans to do so**"; //} else if (helper.IsNumerical(t.Rows[_row][_col]) && !(t.Columns[_col].ColumnName.ToLower().Contains("date") || t.Columns[_col].ColumnName.ToLower().Contains("year"))) { /// was checking for -1s here, is this necessary? int num = Convert.ToInt32(t.Rows[_row][_col]); dr[_row + 1] = helper.FormatCount(num); } else if (t.Columns[_col].DataType == typeof(DateTime)) { dr[_row + 1] = DateTime.Parse(t.Rows[_row][_col].ToString()).ToString("MM/dd/yyyy"); } //else if (t.Columns[_col].DataType == typeof(Boolean)) //{ // if (Convert.ToBoolean(t.Rows[_row][_col])) // dr[_row + 1] = "**Yes**"; // else // dr[_row + 1] = "**No**"; //} else { dr[_row + 1] = t.Rows[_row][_col]; } } compareTbl.Rows.Add(dr); //if (ExpandedFieldIds.IndexOf(Convert.ToInt32(cohortFieldsTbl.Rows[0]["id"])) > -1) PopulateCompareGridWithChildren((int)cohortFieldsTbl.Rows[0]["id"]); } compareGridView.DataSource = compareTbl; compareGridView.DataBind(); }
private string ExportDataGridToExcel(DataTable toExport, string savePath) { /// excel writer row index int rowIndex = 0; try { CECHarmPublicService ps = new CECHarmPublicService(); NPOI.XSSF.UserModel.XSSFWorkbook wkbk = new XSSFWorkbook(); NPOI.SS.UserModel.ISheet wkst = wkbk.CreateSheet(); wkbk.SetActiveSheet(0); /// write header to excel /// NPOI.SS.UserModel.IRow dataRow = wkst.CreateRow(rowIndex++); dataRow.CreateCell(0).SetCellValue(String.Format("Cohort Data Export Generated from the CEDCD Website ({0})", Request.Url.Authority)); dataRow = wkst.CreateRow(rowIndex++); dataRow.CreateCell(0).SetCellValue("Table Name:"); dataRow.CreateCell(1).SetCellValue(String.Format("Cohort Overview Tab: {0}", CompareTabNames[SelectedTabID - 1])); dataRow = wkst.CreateRow(rowIndex++); dataRow.CreateCell(0).SetCellValue("Export Date:"); dataRow.CreateCell(1).SetCellValue(DateTime.Now.ToString("MM/dd/yyyy")); rowIndex += 2; ///-------------------------------------------------------- /// column headers /// NPOI.SS.UserModel.IRow headerRow = wkst.CreateRow(rowIndex++); for (int _c = 0; _c < toExport.Columns.Count; _c++) { ICell c = headerRow.GetCell(_c); if (c == null) { c = headerRow.CreateCell(_c); } c.SetCellValue(toExport.Columns[_c].ColumnName); } /// data rows for (int _i = 0; _i < toExport.Rows.Count; _i++) { int colPos = 0; /// create data row object then step through each cell to populate the excel row dataRow = wkst.CreateRow(rowIndex++); for (int _p = 0; _p < toExport.Columns.Count; _p++) { /// get first cell and check for null, if null create cell ICell c = dataRow.GetCell(colPos); if (c == null) { c = dataRow.CreateCell(colPos); } string cellVal = toExport.Rows[_i][_p].ToString(); if (helper.IsStringEmptyWhiteSpace(cellVal) || cellVal == " " || cellVal == "-1") { c.SetCellValue("N/P"); } else if (!helper.IsNumerical(cellVal) && CECWebSrv.GetCohortWebFieldLabelByColumnName(UserToken, cellVal) != string.Empty) { c.SetCellValue(CECWebSrv.GetCohortWebFieldLabelByColumnName(UserToken, cellVal)); } else { c.SetCellValue(cellVal); } colPos++; } } /// write output FileStream fs = new FileStream(savePath, FileMode.Create); wkbk.Write(fs); fs.Close(); return(savePath); } catch (Exception ex) { throw ex; } }
private string SqlizeFilterCriteria() { EnsureChildControls(); string filter = string.Empty; foreach (CECFilteringOptions fo in FilterControls) { string interim = string.Empty; CheckBox[] ck_list = fo.GetCheckedBoxes(); foreach (CheckBox ck in ck_list) { interim = String.Format(" {0} or", CECWebSrv.GetWebFilterByFilterId(UserToken, int.Parse(ck.ID.Split('_')[1])).Rows[0]["filter_criteria"].ToString()); if (interim.EndsWith("or")) { interim = interim.Remove(interim.Length - 2, 2); } } if (interim != string.Empty) { filter += String.Format(" ({0}) and", interim); } } ///---------------------------------------------- /// For the auto postback version of the tree control /// //foreach (CECFilteringOptions tree in FilterControls) //{ // // sidebar filtering // string interim = string.Empty; // for (int _p = 0; _p < tree.CheckedNodes.Count; _p++) // { // interim += String.Format(" {0} or", CECWebSrv.GetWebFilterByFilterId(UserToken, int.Parse(tree.CheckedNodes[_p].Value)).Rows[0]["filter_criteria"].ToString()); // if (((tree.CheckedNodes.Count == _p + 1) || tree.CheckedNodes[_p].Parent.Value != tree.CheckedNodes[_p + 1].Parent.Value) && interim != String.Empty) // { // if (interim != string.Empty) // { // if (interim.EndsWith("or")) // interim = interim.Remove(interim.Length - 2, 2); // filter += String.Format(" ({0}) and", interim); // interim = string.Empty; // } // } // } //} #region Derilict Code: Alpha Pagenation // pagination filtering --- not used anymore //if (AlphaPagenationBlock != string.Empty) //{ // string interim = string.Empty; // switch (AlphaPagenationBlock) // { // case "a-c": // interim = " (lower(a.cohort_acronym) like 'a%' or lower(a.cohort_acronym) like 'b%' or lower(a.cohort_acronym) like 'c%')"; // break; // case "d-f": // interim = " (lower(a.cohort_acronym) like 'd%' or lower(a.cohort_acronym) like 'e%' or lower(a.cohort_acronym) like 'f%')"; // break; // case "g-i": // interim = " (lower(a.cohort_acronym) like 'g%' or lower(a.cohort_acronym) like 'h%' or lower(a.cohort_acronym) like 'i%')"; // break; // case "j-l": // interim = " (lower(a.cohort_acronym) like 'j%' or lower(a.cohort_acronym) like 'k%' or lower(a.cohort_acronym) like 'l%')"; // break; // case "m-o": // interim = " (lower(a.cohort_acronym) like 'm%' or lower(a.cohort_acronym) like 'n%' or lower(a.cohort_acronym) like 'o%')"; // break; // case "p-r": // interim = " (lower(a.cohort_acronym) like 'p%' or lower(a.cohort_acronym) like 'q%' or lower(a.cohort_acronym) like 'r%')"; // break; // case "s-u": // interim = " (lower(a.cohort_acronym) like 's%' or lower(a.cohort_acronym) like 't%' or lower(a.cohort_acronym) like 'u%')"; // break; // case "w-z": // interim = " (lower(a.cohort_acronym) like 'w%' or lower(a.cohort_acronym) like 'x%' or lower(a.cohort_acronym) like 'y%' or lower(a.cohort_acronym) like 'z%')"; // break; // } // if (filter != string.Empty) // filter += " and " + interim; // else // filter = interim; //} #endregion if (filter.EndsWith("and")) { filter = filter.Remove(filter.Length - 3, 3); } return(filter); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (Page.Request.QueryString["cohort_id"] != null || Page.Request.QueryString["cohort_acronym"] != null) { System.Data.DataSet ds1, ds2; if (Page.Request.QueryString["cohort_id"] != null) { ds1 = CECWebSrv.GetCohortDetails(UserToken, int.Parse(Page.Request.QueryString["cohort_id"])); } else { ds1 = CECWebSrv.GetCohortDetails(UserToken, Page.Request.QueryString["cohort_acronym"]); } System.Data.DataTable cohort = ds1.Tables["tbl_web_cohorts_v4_0"]; if (cohort.Rows.Count == 0) { cd_errorMsg.InnerText = "cohort not found"; return; } ///---------------------------------------- /// stopped commenting, code has been hacked to handle changes from the client /// in the time provided. first casualities are comments/documentation.... o.0 /// // grab all columns from the cohort_meta table System.Data.DataTable cohort_meta = CECWebSrv.GetFilteredCohortRecords(UserToken, "*", String.Format(" (cohort_id={0})", cohort.Rows[0]["cohort_id"])).Tables["tbl_web_cohorts_v4_0"]; if (cohort_meta.Rows.Count > 0) { //if ((cohort_meta.Rows[0]["attachmentQuestionnairePending"] != DBNull.Value) && (bool)cohort_meta.Rows[0]["attachmentQuestionnairePending"]) // ChangeDefaultAttachmentEmptyText(quest_attachments.ID); //if ((cohort_meta.Rows[0]["attachmentPoliciesPending"] != DBNull.Value) && (bool)cohort_meta.Rows[0]["attachmentPoliciesPending"]) // ChangeDefaultAttachmentEmptyText(pol_attachments.ID); //if ((cohort_meta.Rows[0]["attachmentPublicationsPending"] != DBNull.Value) && (bool)cohort_meta.Rows[0]["attachmentPublicationsPending"]) // ChangeDefaultAttachmentEmptyText(pub_attachments.ID); //if ((cohort_meta.Rows[0]["attachmentGrantsPending"] != DBNull.Value) && (bool)cohort_meta.Rows[0]["attachmentGrantsPending"]) // ChangeDefaultAttachmentEmptyText(grant_attachments.ID); //if ((cohort_meta.Rows[0]["attachmentProtocolsPending"] != DBNull.Value) && (bool)cohort_meta.Rows[0]["attachmentProtocolsPending"]) // ChangeDefaultAttachmentEmptyText(prot_attachments.ID); } /// hacking ends here...spaghetti code! /// ------------------------------------------- dt_cohort = cohort; PopulateWebFieldValues(cohort); PopulateOtherSection(cohort); ds2 = CECWebSrv.GetCohortAttachmentList(UserToken, (int)cohort.Rows[0]["id"]); PopulateAttachmentSection(ds2.Tables[0]); PopulateFormURL(cohort); if (Page.Request.QueryString["tab"] != null) { string clientScr = String.Format("<script>toggleAccordion({0});</script>", helper.HTMLEncode(Page.Request.QueryString["tab"])); Page.ClientScript.RegisterStartupScript(GetType(), "tab", clientScr); } if (!IsPostBack) { CECWebSrv.AuditLog_AddActivity(UserToken.userid, String.Format("cohort {0} details page", cohort.Rows[0]["cohort_acronym"])); } } if (Page.Request.QueryString["download"] != null) { string savePath = CECWebSrv.GetCohortDocument(UserToken, Convert.ToInt32(Page.Request.QueryString["download"])); savePath = savePath.Replace("'", "\\'"); Page.ClientScript.RegisterStartupScript(GetType(), "download", String.Format("<script>window.open('{0}');</script>", savePath)); } }
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); } }
protected void registrationBtnClicked(object sender, EventArgs e) { string captcha = rg_captcha.Text; rg_captcha.Text = ""; if (captcha != CaptchaAnswer.ToString()) { rg_errorMsg.InnerText = "CAPTCHA answer is incorrect"; RegisterJSAlert(rg_errorMsg.InnerText); return; } if (!helper.IsStringEmptyWhiteSpace(rg_password1.Text) && rg_password2.Text != rg_password1.Text) { rg_errorMsg.InnerText = "Password does not match confirm password"; RegisterJSAlert(rg_errorMsg.InnerText); return; } try { UserData ud = websrv.GetUserInformationByUserID(UserToken, UserToken.userid); if (!helper.IsStringEmptyWhiteSpace(rg_password1.Text)) { CECMembershipProvider cecMp = (Membership.Providers["CECProvider"] as CECMembershipProvider); cecMp.UserToken = UserToken; if (cecMp.ValidatePasswordStrength(rg_password1.Text)) { cecMp.ChangePassword(rg_password1.Text); } ud.password_expired = false; ud.password_change_date = DateTime.Today; if (ForPasswordReset) { ud.password_reset_required = false; } websrv.SetUserSecurityAttributes(UserToken, ud); } if (!helper.IsStringEmptyWhiteSpace(rg_displayName.Text) && ud.display_name != rg_displayName.Text) { ud.display_name = rg_displayName.Text; } if (!helper.IsStringEmptyWhiteSpace(rg_emailAddress.Text) && ud.email != rg_emailAddress.Text) { ud.email = rg_emailAddress.Text; } websrv.SetUserInformation(UserToken, ud); CECWebSrv.AuditLog_AddActivity(UserToken.userid, "user profile information updated"); SendEmailConfirmation(); Response.Redirect("/input/bouncer.aspx", false); } catch (Exception ex) { if (ex is MembershipPasswordException) { rg_errorMsg.InnerText = ex.Message; } else { rg_errorMsg.InnerText = "User account was not saved"; } #if (DEBUG || DEBUGDEV) rg_errorMsg.InnerText += String.Format(" ({0})", ex.Message); #endif LogError(rg_errorMsg.InnerText, ex); RegisterJSAlert(String.Format("ERROR: {0}", rg_errorMsg.InnerText)); } }
private void CreateTitleListControls(HtmlControl parent, string colTitle, bool literalTitle, string[] colList) { if (colList.Length == 0) { return; } System.Web.UI.HtmlControls.HtmlGenericControl list = new HtmlGenericControl("ul"); System.Web.UI.HtmlControls.HtmlGenericControl li = new HtmlGenericControl("li"); li.InnerText = "Not applicable"; foreach (string s in colList) { if ((dt_cohort.Rows[0][s] == DBNull.Value || helper.IsStringEmptyWhiteSpace(dt_cohort.Rows[0][s].ToString())) && !list.Controls.Contains(li)) { list.Controls.Add(li); } else if (helper.IsLogicalBoolQuestion(dt_cohort.Rows[0][s])) { list.Controls.Add((new LiteralControl(String.Format("<li>{0}</li>", CECWebSrv.GetCohortWebFieldLabelByColumnName(UserToken, s))))); } else if (!helper.IsLogicalBoolQuestion(dt_cohort.Rows[0][s])) { if (helper.IsNumerical(dt_cohort.Rows[0][s])) { int count = int.Parse(dt_cohort.Rows[0][s].ToString()); list.Controls.Add((new LiteralControl(String.Format("<li>{0}: {1}</li>", CECWebSrv.GetCohortWebFieldLabelByColumnName(UserToken, s), helper.FormatCount(count))))); } else { list.Controls.Add((new LiteralControl(String.Format("<li>{0}: {1}</li>", CECWebSrv.GetCohortWebFieldLabelByColumnName(UserToken, s), dt_cohort.Rows[0][s])))); } } else { list.Controls.Add((new LiteralControl(String.Format("<li>{0}</li>", dt_cohort.Rows[0][s])))); } } ///---------------------------------- /// remove any n_a controls if there are more than one list item /// if (list.Controls.Contains(li) && list.Controls.Count > 1) { list.Controls.Remove(li); } ///------------------------------ /// first add parent title System.Web.UI.HtmlControls.HtmlGenericControl h3 = new HtmlGenericControl("h3"); if (literalTitle) { h3.InnerText = colTitle; } else { h3.InnerText = CECWebSrv.GetCohortWebFieldLabelByColumnName(UserToken, colTitle); } parent.Controls.Add(h3); ///------------------------------ /// then add the UL list parent.Controls.Add(list); }
private string ExportDataGridToExcel(DataTable toExport, string savePath) { /// excel writer row index int rowIndex = 0; try { CECHarmPublicService ps = new CECHarmPublicService(); NPOI.XSSF.UserModel.XSSFWorkbook wkbk = new XSSFWorkbook(); NPOI.SS.UserModel.ISheet wkst = wkbk.CreateSheet(); wkbk.SetActiveSheet(0); /// write header to excel NPOI.SS.UserModel.IRow dataRow = wkst.CreateRow(rowIndex++); dataRow.CreateCell(0).SetCellValue(String.Format("Cohort Data Export Generated from the CEDCD Website ({0})", Request.Url.Authority)); dataRow = wkst.CreateRow(rowIndex++); dataRow.CreateCell(0).SetCellValue("Table Name:"); dataRow.CreateCell(1).SetCellValue("Cohort Selection"); //string filter = String.Empty; //foreach (CECFilteringOptions tree in FilterControls) //{ // foreach (CheckBox ck in tree.GetCheckedBoxes()) // filter += String.Format("{0}; ", tree.GetCheckBoxLabel(ck.ID)); //} //filter = filter.TrimEnd(new char[] { ';', ' ' }); //dataRow = wkst.CreateRow(rowIndex++); //dataRow.CreateCell(0).SetCellValue("Web Filter Options:"); //dataRow.CreateCell(1).SetCellValue(filter); dataRow = wkst.CreateRow(rowIndex++); dataRow.CreateCell(0).SetCellValue("Export Date:"); dataRow.CreateCell(1).SetCellValue(DateTime.Now.ToString("MM/dd/yyyy")); rowIndex += 2; /// handle header row dataRow = wkst.CreateRow(rowIndex++); for (int _c = 0; _c < toExport.Columns.Count; _c++) { ICell c = dataRow.GetCell(_c); if (c == null) { c = dataRow.CreateCell(_c); } c.SetCellValue(CECWebSrv.GetCohortWebFieldLabelByColumnName(UserToken, toExport.Columns[_c].ColumnName)); } /// data rows for (int _i = 0; _i < toExport.Rows.Count; _i++) { int colPos = 0; /// create data row object then step through each cell to populate the excel row dataRow = wkst.CreateRow(rowIndex++); for (int _p = 0; _p < toExport.Columns.Count; _p++) { /// get first cell and check for null, if null create cell ICell c = dataRow.GetCell(colPos); if (c == null) { c = dataRow.CreateCell(colPos); } string cellVal = toExport.Rows[_i][_p].ToString(); if (helper.IsStringEmptyWhiteSpace(cellVal) || cellVal == " ") { c.SetCellValue(" "); } else { c.SetCellValue(cellVal); } colPos++; } } /// write output FileStream fs = new FileStream(savePath, FileMode.Create); wkbk.Write(fs); fs.Close(); return(savePath); } catch (Exception ex) { throw ex; } }
private void AssignWebFieldLabel(HtmlGenericControl label, string dataColumn) { label.InnerText = CECWebSrv.GetCohortWebFieldLabelByColumnName(UserToken, dataColumn) + ": "; }
/// <summary> /// called when the summarygridview is bound to data source /// </summary> protected void summaryGridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { e.Row.ID = "summaryHeader"; foreach (TableCell tc in e.Row.Cells) { if (tc.Controls[0] is LinkButton) { string colName = (tc.Controls[0] as LinkButton).Text; tc.ID = (tc.Controls[0] as LinkButton).Text; (tc.Controls[0] as LinkButton).Controls.Add(new LiteralControl(CECWebSrv.GetCohortWebFieldLabelByColumnName(UserToken, colName))); System.Web.UI.HtmlControls.HtmlGenericControl span = new HtmlGenericControl("span"); span.Attributes["class"] = "glyphicon glyphicon-sort"; (tc.Controls[0] as LinkButton).Controls.Add(span); } tc.CssClass = "sortable "; if (tc.ID == SummaryGridSortColumn) { tc.CssClass += String.Format("columnSorting_{0}", GetSortString(SummaryGridSortDirection)); } } //System.Web.UI.WebControls.TableHeaderCell hc = // new TableHeaderCell(); //hc.ID = "table-select-col"; //hc.ClientIDMode = ClientIDMode.Static; //hc.ToolTip = "Toggle Select All"; //hc.Controls.Add(new LiteralControl(String.Format("<label for=\"{0}\" class=\"invisibleLabel\">Toggle Select All</label>", select_all.ID))); //hc.Controls.Add(select_all); //checkbox //e.Row.Cells.AddAt(0, hc); e.Row.TableSection = TableRowSection.TableHeader; /*//contact * TableHeaderCell con = new TableHeaderCell(); * con.ID = "contactCol"; * con.ClientIDMode = ClientIDMode.Static; * con.Attributes.Add("scope", "col"); * con.Text = "Contact"; * e.Row.Cells.Add(con); * * //policies * TableHeaderCell pol = new TableHeaderCell(); * pol.ID = "policyCol"; * pol.ClientIDMode = ClientIDMode.Static; * pol.Attributes.Add("scope", "col"); * pol.Text = "Policies"; * e.Row.Cells.Add(pol); * * //more * TableHeaderCell more = new TableHeaderCell(); * more.ID = "moreCol"; * more.ClientIDMode = ClientIDMode.Static; * more.Attributes.Add("scope", "col"); * more.Text = "More"; * e.Row.Cells.Add(more);*/ } else if (e.Row.RowType == DataControlRowType.DataRow) { // get cohort id int acronymIndex = summaryTable.Columns.IndexOf("cohort_acronym"); string acronym = (e.Row.DataItem as DataRowView)[acronymIndex].ToString(); int cId = (int)CECWebSrv.GetCohortDetails(UserToken, acronym).Tables[0].Rows[0]["cohort_id"]; // get cohort name index int nameIndex = summaryTable.Columns.IndexOf("cohort_name"); /// commented out March 5 by SC. Accessibility report did not like /// multiple labels for one input control //---------------------- // create label control for each field //foreach (TableCell tc in e.Row.Cells) //{ // System.Web.UI.WebControls.Label lb = // new Label(); // lb.AssociatedControlID = "compare_" + cId.ToString(); // lb.Text = tc.Text; // tc.Controls.Add(lb); //} // get the cohort name to link System.Web.UI.WebControls.HyperLink nm = new HyperLink(); nm.Text = e.Row.Cells[nameIndex].Text; nm.NavigateUrl = String.Format("./cohortDetails.aspx?cohort_id={0}", cId); //nm.Target = "_blank"; e.Row.Cells[nameIndex].Controls.Add(nm); //------------------------------------------ System.Web.UI.WebControls.HyperLink ac = new HyperLink(); ac.Text = e.Row.Cells[acronymIndex].Text; ac.NavigateUrl = String.Format("./cohortDetails.aspx?cohort_id={0}", cId); e.Row.Cells[acronymIndex].Controls.Add(ac); //------------------------------------------ //--- // now lets add the custom columns: // checkbox control column //System.Web.UI.WebControls.CheckBox ckbx = // new CheckBox(); //ckbx.CssClass = "select-checkbox"; //ckbx.ID = "compare_" + cId.ToString(); //ckbx.ClientIDMode = ClientIDMode.Static; //if (CohortIDsToCompare.Contains(cId.ToString())) // ckbx.Checked = true; //ckbx.Attributes.Add("onclick", String.Format("javascript:__doPostBack('cohortCompare', '{0}');", cId)); //System.Web.UI.WebControls.TableCell tc1 = // new TableCell(); //tc1.Attributes["headers"] = String.Format("{0} {1}", acronym, "table-select-col"); //tc1.Controls.Add(new LiteralControl(String.Format("<label for=\"{0}\" class=\"invisibleLabel\">Select {1} Cohort</label>", ckbx.ID, acronym))); //tc1.Controls.Add(ckbx); //e.Row.Cells.AddAt(0, tc1); ////-- //// contact link column //System.Web.UI.WebControls.HyperLink con = // new HyperLink(); //con.Text = String.Format("contact {0}", acronym); ////con.Target = "_blank"; //con.CssClass = "tableIcons contact"; //con.NavigateUrl = String.Format("/cohortDetails.aspx?cohort_id={0}", cId); ////con.Controls.Add((new Image() { ImageUrl = "/images/ico_contact.png" })); //System.Web.UI.WebControls.TableCell tc2 = // new TableCell(); //tc2.Attributes["headers"] = String.Format("{0} {1}", acronym, "contactCol"); //tc2.Controls.Add(con); //e.Row.Cells.Add(tc2); ////-- //// policies //System.Web.UI.WebControls.HyperLink pro = // new HyperLink(); //pro.Text = String.Format("policies {0}", acronym); ////pro.Target = "_blank"; //pro.CssClass = "tableIcons policies"; //pro.NavigateUrl = String.Format("/cohortDetails.aspx?cohort_id={0}&tab=policies", cId); ////pro.Controls.Add((new Image() { ImageUrl="/images/ico_policies.png" })); //System.Web.UI.WebControls.TableCell tc3 = // new TableCell(); //tc3.Attributes["headers"] = String.Format("{0} {1}", acronym, "policyCol"); //tc3.Controls.Add(pro); //e.Row.Cells.Add(tc3); ////--- //// more //System.Web.UI.WebControls.HyperLink more = // new HyperLink(); //more.Text = String.Format("more {0}", acronym); ////more.Target = "_blank"; //more.CssClass = "tableIcons more"; //more.NavigateUrl = String.Format("/cohortDetails.aspx?cohort_id={0}&tab=more", cId); ////more.Controls.Add((new Image() { ImageUrl = "/images/ico_more.png" })); //System.Web.UI.WebControls.TableCell tc4 = // new TableCell(); //tc4.Attributes["headers"] = String.Format("{0} {1}", acronym, "moreCol"); //tc4.Controls.Add(more); //e.Row.Cells.Add(tc4); ///-------------------------------------------------- /// the data cells: add header cell ids. for (int _i = 0; _i < e.Row.Cells.Count; _i++) { if (e.Row.Cells[_i].Attributes["headers"] == null && _i <= summaryTable.Columns.Count) { e.Row.Cells[_i].Attributes["headers"] = String.Format("{0}", summaryTable.Columns[_i].ColumnName); } } } }