protected void Load_Kappa_old(int measureID) { string path = Server.MapPath("/"); string html_file = path + "/research/reliability/plots/kappa_" + _content_studyID.ToString() + "_" + measureID.ToString() + ".html"; string html = Convert.ToString(ReadHtmlFile(html_file)); SqlCommand cmd_k = new SqlCommand(); cmd_k.Connection = oConnData; cmd_k.CommandType = CommandType.Text; cmd_k.CommandText = "select * from vwdatRELv2_Kappa where studyID = " + _content_studyID.ToString() + " and measureID = " + measureID.ToString(); SqlDataAdapter da_k = new SqlDataAdapter(cmd_k); DataTable dt_k = new DataTable(); da_k.Fill(dt_k); GridView_Kappa.DataSource = dt_k; GridView_Kappa.DataBind(); //if the html file with the crosstabs tables can be found display it if (html.StartsWith("Could not find")) { html = ""; } else { LiteralControl lit = new LiteralControl(); lit.Text = html; divKappa.Controls.Add(lit); } UpdatePanel_Kappa.Visible = true; UpdatePanel_Kappa.Update(); }
protected void Load_Kappa(int measureID) { SQL_utils sql = new SQL_utils("data"); DataTable dt_score_vars = sql.DataTable_from_SQLstring(" select fldname, minval, maxval from def.vwFld where measureID=" + measureID.ToString() + " and relitem in (1,3) "); List <string> vars = dt_score_vars.AsEnumerable().Select(f => f.Field <string>("fldname")).ToList(); //foreach (string v in vars) foreach (DataRow var_row in dt_score_vars.Rows) { string v = var_row["fldname"].ToString(); string x = "exec spRELv2_Get_Scores_for_var '" + v + "', " + Master.Master_studyID.ToString() + ", " + measureID.ToString() + ", 'exclude missing', 3"; DataTable dt_kappa = sql.DataTable_from_SQLstring(x); var pivotData = new PivotData( new string[] { "orig_val", "rel_val", "fldname" }, new CountAggregatorFactory(), new DataTableReader(dt_kappa)); var pivotTable = new PivotTable( new[] { "orig_val" }, // row dimension(s) new[] { "rel_val" }, // column dimension(s) pivotData); //var q = new SliceQuery(pivotData) // .Dimension("orig_val") // .Dimension("rel_val") // .Measure(0); //var q2 = q.Execute(true); utilStats.Kappa_stats k = utilStats.CalculateKappa(pivotTable); var htmlResult = new StringWriter(); var pvtHtmlWr = new PivotTableHtmlWriter(htmlResult); pvtHtmlWr.Write(pivotTable); Literal xtab = new Literal(); xtab.Text = htmlResult.ToString(); Literal kappa = new Literal(); kappa.Text += utilStats.PrintKappa_stats(k); Table tbl = new Table(); TableRow row = new TableRow(); TableCell cell1 = new TableCell(); TableCell cell2 = new TableCell(); cell1.Controls.Add(xtab); cell2.Controls.Add(kappa); row.Cells.Add(cell1); row.Cells.Add(cell2); tbl.Rows.Add(row); Label v_title = new Label(); v_title.Text = v; v_title.Font.Size = 10; v_title.Font.Bold = true; UpdatePanel_Kappa.ContentTemplateContainer.Controls.Add(v_title); UpdatePanel_Kappa.ContentTemplateContainer.Controls.Add(tbl); UpdatePanel_Kappa.Update(); UpdatePanel_Kappa.Visible = true; } sql.Close(); }