Example #1
0
        //撤销
        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));
        }
Example #2
0
 public override bool Insert(LangleyDataTable ldt)
 {
     try
     {
         db.LangleyDataTable.Add(ldt);
         db.SaveChanges();
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Example #3
0
        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 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);
        }
Example #5
0
        public override bool Delete(LangleyDataTable ldt)
        {
            LangleyDataTable modle = db.LangleyDataTable.FirstOrDefault(m => m.ldt_Id == ldt.ldt_Id);

            if (modle == null)
            {
                return(false);
            }
            try
            {
                db.LangleyDataTable.Remove(modle);
                db.SaveChanges();
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Example #6
0
 public override bool Update(LangleyDataTable ldt)
 {
     try
     {
         var entry = db.Set <LangleyDataTable>().Find(ldt.ldt_Id);
         if (entry != null)
         {
             db.Entry <LangleyDataTable>(entry).State = EntityState.Detached; //这个是在同一个上下文能修改的关键
         }
         db.LangleyDataTable.Attach(ldt);
         db.Entry(ldt).State = EntityState.Modified;
         db.SaveChanges();
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Example #7
0
        //修改分析参数
        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 LangleyDataTable UpdateLangleyDataTable(LangleyExperimentTable langlryExpTable, LangleyAlgorithm langleyAlgorithm, double[] xArray, int[] vArray, LangleyDataTable ldt)
        {
            ldt.ldt_Response         = vArray[vArray.Length - 1];
            ldt.ldt_StimulusQuantity = xArray[xArray.Length - 1];
            vArray = IsFlipTheResponse(langlryExpTable, vArray);
            var pointCalculateValue = langleyAlgorithm.GetResult(xArray, vArray);

            ldt.ldt_Mean = double.Parse(pointCalculateValue.μ0_final.ToString("f13"));
            if (langlryExpTable.let_Correction == 0)
            {
                pointCalculateValue.σ0_final = langleyAlgorithm.CorrectionAlgorithm(pointCalculateValue.σ0_final, xArray.Length);
            }
            ldt.ldt_StandardDeviation = pointCalculateValue.σ0_final;
            if (double.IsNaN(pointCalculateValue.varmu))
            {
                ldt.ldt_MeanVariance = 0;
            }
            else
            {
                ldt.ldt_MeanVariance = pointCalculateValue.varmu;
            }
            if (double.IsNaN(pointCalculateValue.varsigma))
            {
                ldt.ldt_StandardDeviationVariance = 0;
            }
            else
            {
                ldt.ldt_StandardDeviationVariance = pointCalculateValue.varsigma;
            }
            if (double.IsNaN(pointCalculateValue.covmusigma))
            {
                ldt.ldt_Covmusigma = 0;
            }
            else
            {
                ldt.ldt_Covmusigma = pointCalculateValue.covmusigma;
            }
            return(ldt);
        }
Example #9
0
 public abstract bool Delete(LangleyDataTable ldt);
Example #10
0
 public abstract bool Update(LangleyDataTable ldt);
Example #11
0
 public abstract bool Insert(LangleyDataTable ldt);