public ActionResult InsertData(string response, string sq, int langlryExpTableId) { LangleyExperimentTable langlryExpTable = dbDrive.GetLangleyExperimentTable(langlryExpTableId); List <LangleyDataTable> langleyDataTables = dbDrive.GetAllLangleyDataTable(langlryExpTable.let_Id); var xOrVArray = LangleyPublic.XAndVArrays(langleyDataTables); if (sq != null && sq != "") { xOrVArray.xArray[langleyDataTables.Count - 1] = double.Parse(sq); } if (response != null && response != "") { xOrVArray.vArray[langleyDataTables.Count - 1] = int.Parse(response); } else { xOrVArray.vArray[langleyDataTables.Count - 1] = 0; } var lr = LangleyPublic.SelectState(langlryExpTable); dbDrive.Update(LangleyPublic.UpdateLangleyDataTable(langlryExpTable, lr, xOrVArray.xArray, xOrVArray.vArray, langleyDataTables[langleyDataTables.Count - 1])); //增加一条新数据 double StimulusQuantity = lr.CalculateStimulusQuantity(xOrVArray.xArray, xOrVArray.vArray, langlryExpTable.let_StimulusQuantityCeiling, langlryExpTable.let_StimulusQuantityFloor, langlryExpTable.let_PrecisionInstruments); var isTrue = dbDrive.Insert(LangleyPublic.LangleyDataTables(langlryExpTableId, dbDrive, double.Parse(StimulusQuantity.ToString("f6")))); var xOrVArray2 = LangleyPublic.XAndVArrays(dbDrive.GetAllLangleyDataTable(langlryExpTable.let_Id)); xOrVArray2.vArray = LangleyPublic.IsFlipTheResponse(langlryExpTable, xOrVArray2.vArray); if (langlryExpTable.let_FlipTheResponse == 1) { for (int i = 0; i < xOrVArray2.vArray.Length - 1; i++) { if (xOrVArray2.vArray[i] == 0) { xOrVArray2.vArray[i] = 1; } else { xOrVArray2.vArray[i] = 0; } } } string[] value = { isTrue.ToString(), (xOrVArray2.xArray.Length - 1).ToString(), lr.GetNM(xOrVArray2.xArray, xOrVArray2.vArray), StimulusQuantity.ToString() }; return(Json(value)); }
public static List <Langley_list> Langley_lists(IDbDrive dbDrive, List <LangleyExperimentTable> lets, int first) { List <Langley_list> langletlists = new List <Langley_list>(); for (int i = lets.Count - 1; i >= 0; i--) { var langley_List = GetLangley_lists(lets[i]); langley_List.number = i + 1 + first; langley_List.count = dbDrive.GetAllLangleyDataTable(lets[i].let_Id).Count - 1; langletlists.Add(langley_List); } return(langletlists); }
public static List <Langley_list> Langley_lists(IDbDrive dbDrive, List <LangleyExperimentTable> lets) { List <Langley_list> langletlists = new List <Langley_list>(); for (int i = 0; i < lets.Count; i++) { var langley_List = GetLangley_lists(lets[i]); langley_List.number = i + 1; langley_List.count = dbDrive.GetAllLangleyDataTable(lets[i].let_Id).Count - 1; langletlists.Add(langley_List); } langletlists.Reverse(); return(langletlists); }
public static LangleyDataTable LangleyDataTables(int langlryExpTableId, IDbDrive dbDrive, double sq = 0, int resp = 0, double mean = 0, double sd = 0, double mv = 0, double sdv = 0, double covmusigma = 0, string note = null) { LangleyDataTable ldt = new LangleyDataTable(); ldt.ldt_ExperimentTableId = langlryExpTableId; ldt.ldt_StimulusQuantity = double.Parse(sq.ToString("f6")); ldt.ldt_Number = dbDrive.GetAllLangleyDataTable(langlryExpTableId).Count + 1; ldt.ldt_Response = resp; ldt.ldt_Mean = mean; ldt.ldt_StandardDeviation = sd; ldt.ldt_MeanVariance = mv; ldt.ldt_StandardDeviationVariance = sdv; ldt.ldt_Covmusigma = covmusigma; ldt.ldt_Note1 = note; return(ldt); }
//修改分析参数 public JsonResult UpdateParameter() { var str = new StreamReader(Request.InputStream); var stream = str.ReadToEnd(); JavaScriptSerializer js = new JavaScriptSerializer(); LangleyExperimentTable let = dbDrive.GetLangleyExperimentTable(js.Deserialize <LangleyExperimentTable>(stream).let_Id); let.let_DistributionState = js.Deserialize <LangleyExperimentTable>(stream).let_DistributionState; let.let_Correction = js.Deserialize <LangleyExperimentTable>(stream).let_Correction; dbDrive.Update(let); List <LangleyDataTable> ldts = dbDrive.GetAllLangleyDataTable(let.let_Id); ldts.RemoveRange(ldts.Count - 1, 1); var xOrVArray = LangleyPublic.XAndVArrays(ldts); var lr = LangleyPublic.SelectState(let); LangleyDataTable langleyDataTable = new LangleyDataTable(); bool isTure = false; for (int i = 1; i <= ldts.Count; i++) { double[] xArray = new double[i]; int[] vArray = new int[i]; for (int j = 0; j < i; j++) { xArray[j] = xOrVArray.xArray[j]; vArray[j] = xOrVArray.vArray[j]; } langleyDataTable = LangleyPublic.UpdateLangleyDataTable(let, lr, xArray, vArray, ldts[i - 1]); isTure = dbDrive.Update(langleyDataTable); if (isTure == false) { break; } } string[] value = { isTure.ToString(), lr.Precs(langleyDataTable.ldt_Mean, langleyDataTable.ldt_StandardDeviation)[0].ToString("f6"), lr.Precs(langleyDataTable.ldt_Mean, langleyDataTable.ldt_StandardDeviation)[1].ToString("f6"), langleyDataTable.ldt_Mean.ToString("f6"), langleyDataTable.ldt_StandardDeviation.ToString("f6") }; return(Json(value)); }