//撤销 public ActionResult RevocationData(int id, int langlryExpTableId) { LangleyDataTable langleyDataTable = new LangleyDataTable(); List <LangleyDataTable> langleyDataTables = dbDrive.GetAllLangleyDataTable(langlryExpTableId); langleyDataTable.ldt_Id = langleyDataTables[langleyDataTables.Count - 1].ldt_Id; bool isTure = dbDrive.Delete(langleyDataTable); var xOrVArray = LangleyPublic.XAndVArrays(langleyDataTables); string[] value = { isTure.ToString(), (xOrVArray.xArray.Length - 1).ToString(), xOrVArray.xArray[xOrVArray.xArray.Length - 2].ToString() }; return(Json(value)); }
//批量区间估计 public ActionResult BatchIntervalCalculation(double BatchConfidenceLevel, double yMin, double yMax, int Y_Axis, int intervalTypeSelection, double favg, double fsigma, int langlryExpTableId) { LangleyExperimentTable langlryExpTable = dbDrive.GetLangleyExperimentTable(langlryExpTableId); List <LangleyDataTable> ldts = dbDrive.GetAllLangleyDataTable(langlryExpTable.let_Id); ldts.RemoveRange(ldts.Count - 1, 1); var xOrVArray = LangleyPublic.XAndVArrays(ldts); xOrVArray.vArray = LangleyPublic.IsFlipTheResponse(langlryExpTable, xOrVArray.vArray); var lr = LangleyPublic.SelectState(langlryExpTable); var srd = lr.BatchIntervalCalculate(yMax, yMin, Y_Axis, BatchConfidenceLevel, favg, fsigma, xOrVArray.xArray, xOrVArray.vArray, intervalTypeSelection); LangleyPublic.sideReturnData = srd; LangleyPublic.aArray.Clear(); LangleyPublic.bArray.Clear(); LangleyPublic.cArray.Clear(); double ceiling = srd.responsePoints.Min(); double lower = srd.responsePoints.Max(); for (int i = 0; i < srd.responseProbability.Length; i++) { LangleyPublic.aArray.Add("[" + srd.responsePoints[i] + "," + srd.responseProbability[i] + "]"); if (double.IsInfinity(srd.Y_Ceilings[i])) { LangleyPublic.bArray.Add("[" + lower + "," + srd.responseProbability[i] + "]"); } else { LangleyPublic.bArray.Add("[" + srd.Y_Ceilings[i] + "," + srd.responseProbability[i] + "]"); } if (double.IsInfinity(srd.Y_LowerLimits[i])) { LangleyPublic.cArray.Add("[" + ceiling + "," + srd.responseProbability[i] + "]"); } else { LangleyPublic.cArray.Add("[" + srd.Y_LowerLimits[i] + "," + srd.responseProbability[i] + "]"); } } if (intervalTypeSelection == 0) { LangleyPublic.incredibleIntervalType = "拟然比区间计算-单侧置信区间"; } else { LangleyPublic.incredibleIntervalType = "拟然比区间计算-双侧置信区间"; } LangleyPublic.incredibleLevelName = BatchConfidenceLevel.ToString(); return(Json(true)); }
public ActionResult PointCalculate(int langlryExpTableId) { LangleyExperimentTable langlryExpTable = dbDrive.GetLangleyExperimentTable(langlryExpTableId); List <LangleyDataTable> ldts = dbDrive.GetAllLangleyDataTable(langlryExpTable.let_Id); ldts.RemoveRange(ldts.Count - 1, 1); var xOrVArray = LangleyPublic.XAndVArrays(ldts); var lr = LangleyPublic.SelectState(langlryExpTable); LangleyDataTable langleyDataTable = LangleyPublic.UpdateLangleyDataTable(langlryExpTable, lr, xOrVArray.xArray, xOrVArray.vArray, ldts[ldts.Count - 1]); langleyDataTable.ldt_Mean = double.Parse(langleyDataTable.ldt_Mean.ToString("f13")); string[] value = { 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"), lr.GetConversionNumber(xOrVArray.vArray), (xOrVArray.xArray.Length).ToString(), lr.GetNM(xOrVArray.xArray, xOrVArray.vArray) }; dbDrive.Update(langleyDataTable); return(Json(value)); }
public ActionResult ResponsePointIntervalEstimate(double reponseProbability2, double confidenceLevel2, double cjl, double favg, double fsigma, int langlryExpTableId) { LangleyExperimentTable langlryExpTable = dbDrive.GetLangleyExperimentTable(langlryExpTableId); List <LangleyDataTable> ldts = dbDrive.GetAllLangleyDataTable(langlryExpTable.let_Id); ldts.RemoveRange(ldts.Count - 1, 1); var xOrVArray = LangleyPublic.XAndVArrays(ldts); xOrVArray.vArray = LangleyPublic.IsFlipTheResponse(langlryExpTable, xOrVArray.vArray); var lr = LangleyPublic.SelectState(langlryExpTable); var ies = lr.ResponsePointIntervalEstimate(xOrVArray.xArray, xOrVArray.vArray, reponseProbability2, confidenceLevel2, cjl, favg, fsigma); string[] value = { "(" + ies[0].Confidence.Down.ToString("f6") + "," + ies[0].Confidence.Up.ToString("f6") + ")", "(" + ies[0].Mu.Down.ToString("f6") + "," + ies[0].Mu.Up.ToString("f6") + ")", "(" + ies[0].Sigma.Down.ToString("f6") + "," + ies[0].Sigma.Up.ToString("f6") + ")", "(" + ies[1].Confidence.Down.ToString("f6") + "," + ies[1].Confidence.Up.ToString("f6") + ")", "(" + ies[1].Mu.Down.ToString("f6") + "," + ies[1].Mu.Up.ToString("f6") + ")", "(" + ies[1].Sigma.Down.ToString("f6") + "," + ies[1].Sigma.Up.ToString("f6") + ")" }; return(Json(value)); }
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 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)); }
public static string LangleyFreeSpireExcel(LangleyExperimentTable langlryExpTable, List <LangleyDataTable> ldts) { var lr = LangleyPublic.SelectState(langlryExpTable); ldts.RemoveRange(ldts.Count - 1, 1); var xOrVArray = LangleyPublic.XAndVArrays(ldts); Workbook book = new Workbook(); Worksheet sheet = book.Worksheets[0]; var iCellcount = 1; //1.设置表头 sheet.Range[1, iCellcount++].Text = "兰利法感度试验数据记录及处理结果"; sheet.Range["A1:H1"].Merge(); sheet.Range["A1:H1"].Style.HorizontalAlignment = HorizontalAlignType.Center; sheet.Range["E2"].Text = "打印时间"; sheet.Range["F2:H2"].Text = DateTime.Now.ToString("yyyy-MM-dd"); sheet.Range["F2:H2"].Merge(); sheet.Range["A3"].Text = "样本名称"; sheet.Range["B3:D3"].Text = langlryExpTable.let_ProductName; sheet.Range["B3:D3"].Merge(); sheet.Range["E3"].Text = "试验时间"; sheet.Range["F3:H3"].Text = langlryExpTable.let_ExperimentalDate.ToString("yyyy-MM-dd HH:mm"); sheet.Range["F3:H3"].Merge(); sheet.Range["A4"].Text = "实验数量"; sheet.Range["B4"].Text = ldts.Count.ToString(); sheet.Range["C4"].Text = "分辨率"; sheet.Range["D4"].Text = langlryExpTable.let_PrecisionInstruments.ToString(); sheet.Range["E4"].Text = "发布选择"; sheet.Range["F4:H4"].Text = LangleyPublic.DistributionState(langlryExpTable); sheet.Range["F4:H4"].Merge(); sheet.Range["A5"].Text = "刺激量上限"; sheet.Range["B5"].Text = langlryExpTable.let_StimulusQuantityCeiling.ToString(); sheet.Range["C5"].Text = "刺激量下限"; sheet.Range["D5"].Text = langlryExpTable.let_StimulusQuantityFloor.ToString(); sheet.Range["E5"].Text = "标准差修正"; sheet.Range["F5"].Text = langlryExpTable.let_Correction == 0 ? "是" : "否"; sheet.Range["G5"].Text = "翻转响应"; sheet.Range["H5"].Text = langlryExpTable.let_FlipTheResponse == 1 ? "是" : "否"; sheet.Range["A6"].Text = "技术条件"; sheet.Range["B6:H6"].Text = langlryExpTable.let_TechnicalConditions; sheet.Range["B6:H6"].Merge(); if (langlryExpTable.let_FlipTheResponse == 0) { if (langlryExpTable.let_Correction == 1) { sheet.Range["A7:H7"].Text = "标记:发火:“1”,不发火:“0” 点估计标准差计算结果为最大拟然估计结果"; } else { sheet.Range["A7:H7"].Text = "标记:发火:“1”,不发火:“0” 点估计标准差计算结果为按照GJB377修正结果"; } } else if (langlryExpTable.let_Correction == 1) { sheet.Range["A7:H7"].Text = "标记:发火:“0”,不发火:“1” 点估计标准差计算结果为最大拟然估计结果"; } else { sheet.Range["A7:H7"].Text = "标记:发火:“0”,不发火:“1” 点估计标准差计算结果为按照GJB377修正结果"; } TableHead(sheet); int count = 9; for (int i = 0; i < ldts.Count; i++) { sheet.Range["A" + count + ""].Text = (i + 1).ToString(); sheet.Range["B" + count + ":C" + count + ""].Text = ldts[i].ldt_StimulusQuantity.ToString(); sheet.Range["B" + count + ":C" + count + ""].Merge(); sheet.Range["D" + count + ""].Text = ldts[i].ldt_Response.ToString(); sheet.Range["E" + count + ":F" + count + ""].Text = ldts[i].ldt_Mean.ToString(); sheet.Range["E" + count + ":F" + count + ""].Merge(); sheet.Range["G" + count + ":H" + count + ""].Text = ldts[i].ldt_StandardDeviation.ToString(); sheet.Range["G" + count + ":H" + count + ""].Merge(); count++; } sheet.Range["A" + count + ""].Text = "点估计:"; sheet.Range["B" + count + ":D" + count + ""].Text = "均值:" + ldts[ldts.Count - 1].ldt_Mean + ""; sheet.Range["B" + count + ":D" + count + ""].Merge(); sheet.Range["E" + count + ":H" + count + ""].Text = "标准差:" + ldts[ldts.Count - 1].ldt_StandardDeviation + ""; sheet.Range["E" + count + ":H" + count + ""].Merge(); count++; var ignition99 = LangleyIgnition(ldts, lr, 0.99); var ignition1 = LangleyIgnition(ldts, lr, 0.01); var ignition999 = LangleyIgnition(ldts, lr, 0.999); var ignition01 = LangleyIgnition(ldts, lr, 0.001); var ignition9999 = LangleyIgnition(ldts, lr, 0.9999); var ignition001 = LangleyIgnition(ldts, lr, 0.0001); count = PointCalculation(count, ignition99, ignition1, ignition999, ignition01, ignition9999, ignition001, sheet); var ie = lr.GetIntervalEstimationValue(lr.DoubleSideEstimation(xOrVArray.xArray, xOrVArray.vArray, 0.999, 0.8)); var ie01 = lr.GetIntervalEstimationValue(lr.DoubleSideEstimation(xOrVArray.xArray, xOrVArray.vArray, 0.001, 0.8)); count = IntervalEstimation(count, sheet, ie, ie01, 0.8); ie = lr.GetIntervalEstimationValue(lr.DoubleSideEstimation(xOrVArray.xArray, xOrVArray.vArray, 0.999, 0.95)); ie01 = lr.GetIntervalEstimationValue(lr.DoubleSideEstimation(xOrVArray.xArray, xOrVArray.vArray, 0.001, 0.95)); count = IntervalEstimation(count, sheet, ie, ie01, 0.95); ie = lr.GetIntervalEstimationValue(lr.DoubleSideEstimation(xOrVArray.xArray, xOrVArray.vArray, 0.999, 0.99)); ie01 = lr.GetIntervalEstimationValue(lr.DoubleSideEstimation(xOrVArray.xArray, xOrVArray.vArray, 0.001, 0.99)); count = IntervalEstimation(count, sheet, ie, ie01, 0.99); sheet.Range["A3:H" + count + ""].BorderInside(LineStyleType.Thin, Color.Black); sheet.Range["A3:H" + count + ""].BorderAround(LineStyleType.Medium, Color.Black); count++; sheet.Range["B" + count + ""].Text = "复查人"; sheet.Range["F" + count + ""].Text = "试验人"; //设置行宽 sheet.Range["A1:H1"].RowHeight = 20; var strFullName = @"C:\兰利法\" + "兰利法" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".xlsx"; book.SaveToFile(strFullName, ExcelVersion.Version2010); return(strFullName); }