コード例 #1
0
ファイル: QueryViewModel.cs プロジェクト: jume2003/SK800
 private void ShowRight(T_Result result)
 {
     if (result.Gel == null)
     {
         result.Gel = GelList.Where(g => g.ID == result.GelID).FirstOrDefault();
     }
     if (result.Picture == null)
     {
     }
     this.SelectedResult = null;
     SK_ABO.UserCtrls.TubeResult_Control[] tubes =
     {
         (this.View as QueryView).Img_Tube1, (this.View as QueryView).Img_Tube2, (this.View as QueryView).Img_Tube3, (this.View as QueryView).Img_Tube4,
         (this.View as QueryView).Img_Tube5, (this.View as QueryView).Img_Tube6, (this.View as QueryView).Img_Tube7, (this.View as QueryView).Img_Tube8
     };
     for (int i = 0; i < 8; i++)
     {
         tubes[i].TestResult = null;
     }
     for (int i = result.TubeStartNo; i < result.TubeStartNo + result.TubeCount; i++)
     {
         tubes[i].TestResult = result;
     }
     this.SelectedResult = result;
     this.ResultStr      = result.Result;
     this.CanSaveChange  = true;
 }
コード例 #2
0
        public bool SaveT_Result(T_Result result)
        {
            bool res = false;

            if (result.ID == 0)
            {
                Mapper.BeginTransaction();
                try
                {
                    if (result.Picture != null)
                    {
                        Mapper.Insert("InsertT_Picture", result.Picture);
                        result.PictureID = result.Picture.ID;
                    }
                    Mapper.Insert("InsertT_Result", result);
                    Mapper.CommitTransaction();
                    res = true;
                }
                catch (Exception ex)
                {
                    Tool.AppLogError(ex);
                    Mapper.RollBackTransaction();
                }
            }
            return(res);
        }
コード例 #3
0
ファイル: ResultController.cs プロジェクト: Shrey22/P_Backend
        // DELETE: api/Result/5
        public Response Delete(int id)
        {
            try
            {
                T_Result resultToBedeleted = dalobj.T_Result.Find(id);
                if (resultToBedeleted != null)
                {
                    dalobj.T_Result.Remove(resultToBedeleted);
                    dalobj.SaveChanges();

                    response.Data   = null;
                    response.Status = "success";
                    response.Err    = null;
                    logger.Log("Specific REsult deleted using Id");
                    return(response);
                }
                else
                {
                    response.Data   = null;
                    response.Status = "failed";
                    response.Err    = null;
                    logger.Log("Something wentr wrong!");
                    return(response);
                }
            }
            catch (Exception cause)
            {
                response.Data   = cause.Message;
                response.Status = "Failed";
                response.Err    = cause;
                logger.Log("Exception occured returned Error msg");
                return(response);
            }
        }
コード例 #4
0
        internal void Add(String SampleBarcode, byte RackIndex, byte Index)
        {
            T_Result result = new T_Result();

            result.GelID      = GelType.ID;
            result.SmpBarcode = SampleBarcode;
            result.TestUser   = Constants.Login.LoginName;
            var vt = ValueTuple.Create <String, byte, byte, T_Result>(SampleBarcode, RackIndex, Index, result);

            this.SamplesInfo.Add(vt);
        }
コード例 #5
0
        /// <summary>
        /// Handles the Click event of the CmdImport control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void CmdImport_Click(object sender, RoutedEventArgs e)
        {
            if (ViewModel.SelectedStationValue == null)
            {
                // kein "StationValue" ausgewählt!
                MessageBox.Show("Kein Stations-Wert gewählt!");
                return;
            }

            var stationValueId = ViewModel.SelectedStationValue.Id;

            try
            {
                using (var db = new WintertalentiadeDataContext2(Properties.Settings.Default.WintertalentiadeConnectionString, _user, _pwd))
                {
                    var results = db.T_Results.Where(r => r.StationValueId == stationValueId).ToList();

                    foreach (var dataRow in ViewModel.DataRows)
                    {
                        var newResult = results.SingleOrDefault(r => r.AthletId == dataRow.Id);

                        if (newResult == null)
                        {
                            // es gibt das Ergebnis noch nicht
                            newResult = new T_Result()
                            {
                                AthletId       = dataRow.Id,
                                StationValueId = stationValueId
                            };

                            db.T_Results.InsertOnSubmit(newResult);
                        }

                        // Wert zuweisen
                        newResult.ResultValue = dataRow.Value;
                    }

                    db.SubmitChanges();
                }

                MessageBox.Show("OK");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #6
0
        /// <summary>
        /// 保存到本地数据库
        /// </summary>
        /// <param name="car"></param>
        public async static Task <int> SaveLocalResult(string element, bool state, string vin, string driver, string write, string cal)
        {
            try
            {
                var configs = await _sqlSugar.Queryable <T_VCUConfig, T_MTOC>((v, m) => new JoinQueryInfos(JoinType.Inner, v.mtoc == m.mtoc))
                              .Where((v, m) => m.vin == vin).Select((v, m) => new T_Result
                {
                    vin             = vin,
                    mtoc            = v.mtoc,
                    flashBin        = v.drivername,
                    writeBin        = v.binname,
                    calBin          = v.calname,
                    softwareversion = v.softwareversion,
                    testtime        = SqlFunc.GetDate(),
                    teststate       = SqlFunc.IIF(state == true, 2, 1),
                    isprint         = SqlFunc.IIF(state == true, 1, 0),
                    tracyCode       = element,
                    sign            = v.sign
                }).FirstAsync();

                if (configs == null)
                {
                    configs = new T_Result
                    {
                        flashBin  = driver,
                        writeBin  = write,
                        calBin    = cal,
                        teststate = SqlFunc.IIF(state == true, 2, 1),
                        isprint   = SqlFunc.IIF(state == true, 1, 0),
                    };
                }

                var tmpK = await _sqlSugar.Insertable(configs).ExecuteCommandAsync();

                if (tmpK > 0)
                {
                    Log.Info("保持到本地数据库成功!");
                }
                return(tmpK);
            }
            catch (Exception ex)
            {
                Log.Error($"修改记录失败!\r\n element={element},state={state},vin={vin},driver={driver},write={write},cal={cal}", ex);
            }
            return(0);
        }
コード例 #7
0
ファイル: ResultController.cs プロジェクト: Shrey22/P_Backend
        // GET: api/Result/5
        //public Response Get(int id)
        //{
        //    try
        //    {
        //        T_Result resultToBeFind = dalobj.T_Result.Find(id);
        //        if (resultToBeFind != null)
        //        {
        //            response.Data = resultToBeFind;
        //            response.Status = "success";
        //            response.Err = null;
        //            logger.Log("Specific Result displayed using Id");
        //            return response;
        //        }
        //        else
        //        {
        //            response.Data = null;
        //            response.Status = "Failed";
        //            response.Err = null;
        //            logger.Log("Specific Result not found using Id");
        //            return response;
        //        }

        //    }
        //    catch (Exception cause)
        //    {
        //        response.Data = cause.Message;
        //        response.Status = "Failed";
        //        response.Err = cause;
        //        logger.Log("Exception occured returned Error msg");
        //        return response;
        //    }
        //}



        // POST: api/Result
        public Response Post([FromBody] UserScore tally)
        {
            try
            {
                if (tally != null)                    // afterwards check valid subject or not so if/else loop ...
                {
                    T_Result list = new T_Result();



                    list.UserId        = tally.UserId;
                    list.SubId         = tally.SubId;
                    list.CntCorrectAns = tally.CntCorrectAns;

                    dalobj.T_Result.Add(list);
                    dalobj.SaveChanges();
                    response.Data   = null;
                    response.Status = "success";
                    response.Err    = null;
                    logger.Log("Result added in db");
                    return(response);
                }
                else
                {
                    response.Data   = null;
                    response.Status = "Failed";
                    response.Err    = null;
                    logger.Log("Result insertion failed");
                    return(response);
                }
            }

            catch (Exception cause)
            {
                response.Data   = cause.Message;
                response.Status = "Failed";
                response.Err    = cause;
                logger.Log("Exception occured returned Error msg");
                return(response);
            }
        }
コード例 #8
0
        public bool UpdateT_Result(T_Result result)
        {
            bool res = false;

            Mapper.BeginTransaction();
            try
            {
                if (result.Picture != null)
                {
                    Mapper.Update("UpdateT_Picture", result.Picture);
                }
                Mapper.Update("UpdateT_Result", result);
                Mapper.CommitTransaction();
                res = true;
            }
            catch (Exception ex)
            {
                Tool.AppLogError(ex);
                Mapper.RollBackTransaction();
            }
            return(res);
        }
コード例 #9
0
ファイル: ResultController.cs プロジェクト: Shrey22/P_Backend
        //// POST: api/Result
        //public Response Post([FromBody]T_Result result)
        //{
        //    try
        //    {
        //        if (result != null)                    // afterwards check valid subject or not so if/else loop ...
        //        {
        //            dalobj.T_Result.Add(result);
        //            dalobj.SaveChanges();
        //            response.Data = null;
        //            response.Status = "success";
        //            response.Err = null;
        //            logger.Log("Result added in db");
        //            return response;
        //        }
        //        else
        //        {
        //            response.Data = null;
        //            response.Status = "Failed";
        //            response.Err = null;
        //            logger.Log("Result insertion failed");
        //            return response;
        //        }
        //    }

        //    catch (Exception cause)
        //    {
        //        response.Data = cause.Message;
        //        response.Status = "Failed";
        //        response.Err = cause;
        //        logger.Log("Exception occured returned Error msg");
        //        return response;
        //    }
        //}

        // PUT: api/Result/5
        public Response Put(int id, [FromBody] T_Result result)
        {
            try
            {
                T_Result resultToBeFind = dalobj.T_Result.Find(id);
                if (resultToBeFind != null)
                {
                    resultToBeFind.UserId        = result.UserId;
                    resultToBeFind.SubId         = result.SubId;
                    resultToBeFind.CntCorrectAns = result.CntCorrectAns;
                    dalobj.SaveChanges();

                    response.Data   = resultToBeFind;
                    response.Status = "success";
                    response.Err    = null;
                    logger.Log("Specific Result updated using Id");
                    return(response);
                }
                else
                {
                    response.Data   = null;
                    response.Status = "failed";
                    response.Err    = null;
                    logger.Log("Something wentr wrong!");
                    return(response);
                }
            }
            catch (Exception cause)
            {
                response.Data   = cause.Message;
                response.Status = "Failed";
                response.Err    = cause;
                logger.Log("Exception occured returned Error msg");
                return(response);
            }
        }
コード例 #10
0
 public bool UpdateT_Result(T_Result result)
 {
     return(ResultDAO.UpdateT_Result(result));
 }
コード例 #11
0
 public bool SaveT_Result(T_Result result)
 {
     return(ResultDAO.SaveT_Result(result));
 }
コード例 #12
0
        /// <summary>
        /// Handles the Click event of the CmdCreateRandomResults control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void CmdCreateRandomResults_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Wirklich?", "Zufallsergebnisse einfügen", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                var rnd = new Random();

                using (var db = new WintertalentiadeDataContext2(Properties.Settings.Default.WintertalentiadeConnectionString, txtUser.Text, txtPwd.Text))
                {
                    var allAthlets       = db.T_Athlets.ToList();
                    var allStations      = db.T_Stations.ToList();
                    var allStationValues = db.T_StationValues.ToList();
                    var allResults       = db.T_Results.ToList();

                    foreach (var station in allStations)
                    {
                        if (station.StationNumber < 90)
                        {
                            var stationValues = allStationValues.Where(asv => asv.StationId == station.StationId).OrderBy(asv => asv.StationValueIndex).ToList();

                            foreach (var athlet in allAthlets)
                            {
                                var randomValues = new List <float>();

                                switch (station.StationNumber)
                                {
                                case 2:
                                    randomValues.Add(GetRandomFloat(rnd, 1.5, 2.1));
                                    randomValues.Add(GetRandomFloat(rnd, 2, 3.1));
                                    break;

                                case 3:
                                    randomValues.Add(GetRandomFloat(rnd, 4.1, 6.2));
                                    randomValues.Add(GetRandomFloat(rnd, 5.2, 7.1));
                                    break;

                                case 4:
                                    randomValues.Add(rnd.Next(17, 27));
                                    break;

                                case 5:
                                    randomValues.Add(GetRandomFloat(rnd, 2, 7));
                                    randomValues.Add(GetRandomFloat(rnd, 3, 8));
                                    randomValues.Add(GetRandomFloat(rnd, 2, 6));
                                    break;

                                case 7:
                                    randomValues.Add(GetRandomFloat(rnd, 15, 25));
                                    break;

                                case 8:
                                    randomValues.Add(rnd.Next(17, 27));
                                    break;

                                case 9:
                                    randomValues.Add(rnd.Next(11, 24));
                                    break;

                                case 11:
                                    randomValues.Add(GetRandomFloat(rnd, 15, 19));
                                    break;

                                case 13:
                                    randomValues.Add(GetRandomFloat(rnd, 13, 22));
                                    break;

                                case 14:
                                    randomValues.Add(rnd.Next(80, 400));
                                    break;
                                }

                                var index = 0;
                                foreach (var stationValue in stationValues)
                                {
                                    var existingResult = allResults.SingleOrDefault(r => r.AthletId == athlet.AthletId && r.StationValueId == stationValue.StationValueId);
                                    if (existingResult != null)
                                    {
                                        // es gibt das Ergebnis schon
                                        // => nichts machen
                                    }
                                    else
                                    {
                                        // neues Ergebnis
                                        var newResult = new T_Result()
                                        {
                                            AthletId       = athlet.AthletId,
                                            StationValueId = stationValue.StationValueId,
                                            ResultValue    = randomValues[index]
                                        };
                                        db.T_Results.InsertOnSubmit(newResult);
                                    }

                                    index++;
                                }
                            }
                        }
                    }

                    db.SubmitChanges();
                }

                MessageBox.Show("Fertig");
            }
        }
コード例 #13
0
        /// <summary>
        /// Handles the Click event of the CmdImport2018TestData control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void CmdImport2018TestData_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (MessageBox.Show("Wirklich?", "Testdaten von 2018 importieren", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    var rnd = new Random();

                    using (var db = new WintertalentiadeDataContext2(Properties.Settings.Default.WintertalentiadeConnectionString, txtUser.Text, txtPwd.Text))
                    {
                        var allAthlets       = db.T_Athlets.ToList();
                        var allStations      = db.T_Stations.ToList();
                        var allStationValues = db.T_StationValues.ToList();

                        foreach (var station in allStations)
                        {
                            if (station.StationNumber < 90)
                            {
                                var stationValues = allStationValues.Where(asv => asv.StationId == station.StationId).OrderBy(asv => asv.StationValueIndex).ToList();

                                #region Testdaten lesen

                                var allLines = File.ReadAllLines($@"D:\DATEN\Dokumente\MRV\Wintertalentiade\Testdaten2018\{station.StationNumber}.txt").ToList();
                                allLines = allLines.Where(l => !string.IsNullOrEmpty(l)).ToList();

                                var testDataAthlets = new List <TestDataAthlet>();
                                foreach (var line in allLines)
                                {
                                    Debug.WriteLine($"{station.StationNumber} - {line}");
                                    var columns      = line.Split('\t').ToList();
                                    var id           = int.Parse(columns[0]);
                                    var valueStrings = columns.Skip(7).ToList();
                                    valueStrings = valueStrings.Select(vs => "0" + vs).ToList();
                                    var values = valueStrings.Select(vs => float.Parse(vs.Replace(".", ","))).ToList();

                                    testDataAthlets.Add(new TestDataAthlet()
                                    {
                                        Id = id, Values = values
                                    });
                                }

                                #endregion

                                foreach (var athlet in allAthlets)
                                {
                                    var testData = testDataAthlets.SingleOrDefault(tda => tda.Id == athlet.AthletId);
                                    if (testData != null)
                                    {
                                    }

                                    var index = 0;
                                    foreach (var stationValue in stationValues)
                                    {
                                        // neues Ergebnis
                                        var newResult = new T_Result()
                                        {
                                            AthletId       = athlet.AthletId,
                                            StationValueId = stationValue.StationValueId,
                                            ResultValue    = testData.Values[index]
                                        };

                                        db.T_Results.InsertOnSubmit(newResult);

                                        index++;
                                    }
                                }
                            }
                        }

                        db.SubmitChanges();
                    }

                    MessageBox.Show("Fertig");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Fehler: " + ex.ToString());
            }
        }