Ejemplo n.º 1
0
 public static StatisticsByFuzzyViewModel ToStatisticsByFuzzy(StatisticsByFuzzy elem)
 {
     return(new StatisticsByFuzzyViewModel
     {
         Id = elem.Id,
         SeriesDiscriptionId = elem.SeriesDiscriptionId,
         NumberSituation = elem.NumberSituation,
         Description = elem.Description,
         StartStateFuzzyLabelId = elem.StartStateFuzzyLabelId,
         StartStateFuzzyTrendId = elem.StartStateFuzzyTrendId,
         EndStateFuzzyLabelId = elem.EndStateFuzzyLabelId,
         EndStateFuzzyTrendId = elem.EndStateFuzzyTrendId,
         CountMeet = elem.CountMeet
     });
 }
Ejemplo n.º 2
0
 public static StatisticsByFuzzy ToStatisticsByFuzzy(StatisticsByFuzzyBindingModel model, StatisticsByFuzzy elem = null)
 {
     if (elem == null)
     {
         elem = new StatisticsByFuzzy();
     }
     elem.SeriesDiscriptionId    = model.SeriesDiscriptionId;
     elem.NumberSituation        = model.NumberSituation;
     elem.Description            = model.Description;
     elem.StartStateFuzzyLabelId = model.StartStateFuzzyLabelId;
     elem.StartStateFuzzyTrendId = model.StartStateFuzzyTrendId;
     elem.EndStateFuzzyLabelId   = model.EndStateFuzzyLabelId;
     elem.EndStateFuzzyTrendId   = model.EndStateFuzzyTrendId;
     return(elem);
 }
 /// <summary>
 /// Определение ситуации по нечеткости, увеличение статистики по этой ситуации
 /// </summary>
 /// <param name="point"></param>
 /// <returns></returns>
 private StatisticsByFuzzy GetStateFuzzy(PointInfo point)
 {
     using (var _context = new DissertationDbContext())
     {
         var startLabelId = _points[_points.Count - 1].FuzzyLabelId;
         var startTrendId = _points[_points.Count - 1].FuzzyTrendId;
         var stateFuzzy   = _context.StatisticsByFuzzys.SingleOrDefault(r =>
                                                                        r.StartStateFuzzyLabelId == startLabelId &&
                                                                        r.StartStateFuzzyTrendId == startTrendId &&
                                                                        r.EndStateFuzzyLabelId == point.FuzzyLabelId &&
                                                                        r.EndStateFuzzyTrendId == point.FuzzyTrendId &&
                                                                        r.SeriesDiscriptionId == point.SeriesDiscriptionId);
         if (stateFuzzy == null)
         {
             var number = _context.StatisticsByFuzzys
                          .Where(sbf => sbf.SeriesDiscriptionId == point.SeriesDiscriptionId)
                          .Select(sbf => sbf.NumberSituation)
                          .DefaultIfEmpty()
                          .Max() + 1;
             stateFuzzy = new StatisticsByFuzzy
             {
                 SeriesDiscriptionId    = point.SeriesDiscriptionId,
                 StartStateFuzzyLabelId = startLabelId.Value,
                 StartStateFuzzyTrendId = startTrendId.Value,
                 EndStateFuzzyLabelId   = point.FuzzyLabelId.Value,
                 EndStateFuzzyTrendId   = point.FuzzyTrendId.Value,
                 NumberSituation        = number,
                 CountMeet = 1
             };
             _context.StatisticsByFuzzys.Add(stateFuzzy);
         }
         else
         {
             stateFuzzy.CountMeet++;
         }
         _context.SaveChanges();
         return(stateFuzzy);
     }
 }