Beispiel #1
0
        public List <DFDataColumn> GenerateColumnDataForCache(DataTable dt, List <DFDataColumn> columns)
        {
            var result = new List <DFDataColumn>();

            try
            {
                var dataCount = dt.Rows.Count;
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    var name = dt.Columns[i].ColumnName;
                    var col  = new RdDataColumn();
                    col.GroupingTags = new List <RdGroupingTag>();
                    col.Name         = name;
                    col.Rem          = name;
                    var kindCount = 0;
                    var nullCount = 0;
                    var colStat   = GenerateColumnStatistics(dt, col, dataCount, out kindCount, out nullCount);

                    col.StatisticsInfo = JsonConvert.SerializeObject(colStat);
                    col.IsContinuous   = (kindCount == 0);
                    col.KindCount      = kindCount;
                    col.NullPercent    = ((double)nullCount / dataCount).ToString("P");

                    var dataColumnTags = new List <DFGroupingTag>();
                    foreach (var r in col.GroupingTags)
                    {
                        dataColumnTags.Add(new DFGroupingTag
                        {
                            Id    = r.Id,
                            Name  = r.Name,
                            Index = r.Index
                        });
                    }
                    var column = columns.FirstOrDefault(x => x.Name == name);
                    result.Add(new DFDataColumn {
                        Id             = column.Id,
                        Name           = column.Name,
                        Rem            = column.Rem,
                        IsContinuous   = col.IsContinuous,
                        KindCount      = col.KindCount,
                        NullPercent    = col.NullPercent,
                        StatisticsInfo = col.StatisticsInfo,
                        GroupingTags   = dataColumnTags
                    });;
                }
            }
            catch (Exception ex)
            {
                _logger.LogInformation("更新分析数据失败:" + ex.ToString());
                throw ex;
            }
            return(result);
        }
Beispiel #2
0
 public JsonResult UpdateRdColumnName(RdDataColumn rdData)
 {
     try
     {
         _logRepository.Add("数据检查-修改字段名", $"column Id:{rdData.Id},rem:{rdData.Rem}");
         var result = false;
         result = _dataManageRepository.UpdateRdColumnName(rdData);
         var msg = "操作成功";
         if (!result)
         {
             msg = "操作失败";
         }
         return(Json(new { success = result, msg }));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, msg = ex.ToString() }));
     }
 }
        public bool UpdateRdColumnName(RdDataColumn rdData)
        {
            var result = false;

            try
            {
                result = _dbKyStatic.Updateable <RdDataColumn>()
                         .SetColumns(x => new RdDataColumn()
                {
                    Rem = rdData.Rem
                })
                         .Where(x => x.Id == rdData.Id).ExecuteCommandHasChange();
            }
            catch (Exception ex)
            {
                _logger.LogError("编辑数据rdColumn失败:" + ex.ToString());
            }
            return(result);
        }
Beispiel #4
0
        public void GenerateColumnDataForSingleColumn(DataTable dt, string columnName, int rdDataColumnId)
        {
            try
            {
                var dataCount = dt.Rows.Count;
                List <RdGroupingTag> removedTags = new List <RdGroupingTag>();

                var col = new RdDataColumn();
                col.GroupingTags = new List <RdGroupingTag>();
                col.Name         = columnName;
                col.Rem          = columnName;
                var kindCount = 0;
                var nullCount = 0;
                var colStat   = GenerateColumnStatistics(dt, col, dataCount, out kindCount, out nullCount);
                col.StatisticsInfo = JsonConvert.SerializeObject(colStat);
                col.IsContinuous   = (kindCount == 0);
                col.KindCount      = kindCount;
                col.NullPercent    = ((double)nullCount / dataCount).ToString("P");
                _dbKyStatic.Deleteable <RdGroupingTag>().Where(x => x.DataColumnId == rdDataColumnId).ExecuteCommand();
                if (col.GroupingTags.Any())
                {
                    col.GroupingTags.ForEach(x => { x.DataColumnId = rdDataColumnId; });
                    _dbKyStatic.Insertable <RdGroupingTag>(col.GroupingTags).ExecuteCommand();
                }
                _dbKyStatic.Updateable <RdDataColumn>()
                .SetColumns(x => new RdDataColumn()
                {
                    IsContinuous = col.IsContinuous, StatisticsInfo = col.StatisticsInfo, KindCount = col.KindCount, NullPercent = col.NullPercent
                })
                .Where(x => x.Id == rdDataColumnId).ExecuteCommandHasChange();
            }
            catch (Exception ex)
            {
                _logger.LogInformation("GenerateColumnDataForSingleColumn更新分析数据失败:" + ex.ToString());
                throw ex;
            }
        }
Beispiel #5
0
 public void GenerateColumnData(DataTable dt, int resultDataId)
 {
     try
     {
         var rdDataColumns = new List <RdDataColumn>();
         var dataCount     = dt.Rows.Count;
         for (int i = 0; i < dt.Columns.Count; i++)
         {
             var name = dt.Columns[i].ColumnName;
             var col  = new RdDataColumn();
             col.ResultDataId = resultDataId;
             col.GroupingTags = new List <RdGroupingTag>();
             col.Name         = name;
             col.Rem          = name;
             var kindCount = 0;
             var nullCount = 0;
             var colStat   = GenerateColumnStatistics(dt, col, dataCount, out kindCount, out nullCount);
             col.StatisticsInfo = JsonConvert.SerializeObject(colStat);
             col.IsContinuous   = (kindCount == 0);
             col.KindCount      = kindCount;
             col.NullPercent    = ((double)nullCount / dataCount).ToString("P");
             if (!col.GroupingTags.Any())
             {
                 col.GroupingTags = null;
             }
             rdDataColumns.Add(col);
         }
         _dbKyStatic.Insertable(rdDataColumns).AddSubList(x => x.GroupingTags.First().DataColumnId)
         .ExecuteReturnPrimaryKey();
     }
     catch (Exception ex)
     {
         _logger.LogInformation("更新分析数据失败:" + ex.ToString());
         throw ex;
     }
 }