public List <TableProps> GetDimensions() { List <TableProps> retList = new List <TableProps>(); using (SqlCommand command = new SqlCommand(@"dbo.GetTableProps", connection)) { command.Parameters.AddWithValue("@TableName", "DimHierarchy"); command.CommandType = CommandType.StoredProcedure; using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { TableProps tableProps = new TableProps() { ColumnName = reader["ColumnName"].ToString(), Datatype = reader["Datatype"].ToString(), /* Remove unnecessary props * MaxLength = Convert.ToUInt16(reader["MaxLength"]), * Precision = Convert.ToUInt16(reader["Precision"]), * Scale = Convert.ToUInt16(reader["Scale"]), * Nullable = Convert.ToBoolean(reader["Nullable"]), * PrimaryKey = Convert.ToBoolean(reader["PrimaryKey"]), */ }; retList.Add(tableProps); } } } return(retList); }
public override void PropsToCsv() { TableProps.Clear(); TableProps.Add(nameof(_model.SegmentSize), _model.SegmentSize.ToString()); TableProps.Add(nameof(_model.CompareSegmentSize), _model.CompareSegmentSize.ToString()); TableProps.Add(nameof(_model.SimilarityLimit), _model.SimilarityLimit.ToString()); TableProps.Add(nameof(_model.SimilarityLimitMin), _model.SimilarityLimitMin.ToString()); TableProps.Add(nameof(_model.SegmentsDrawer), string.Join(",", _model.SegmentsDrawer.Select(x => x.Id))); }
public override void LinkReferences() { var withoutMediaItem = new List <SegmentM>(); foreach (var segment in _model.All) { if (_mediaItemsM.AllDic.TryGetValue(int.Parse(segment.Csv[1]), out var mi)) { segment.MediaItem = mi; mi.Segments ??= new(); mi.Segments.Add(segment); if (segment.PersonId > 0 && _peopleM.AllDic.TryGetValue(segment.PersonId, out var person)) { segment.Person = person; person.Segment ??= segment; } } else { withoutMediaItem.Add(segment); } // reference to Keywords if (!string.IsNullOrEmpty(segment.Csv[4])) { var ids = segment.Csv[4].Split(','); segment.Keywords = new(ids.Length); foreach (var keywordId in ids) { var k = _keywordsM.AllDic[int.Parse(keywordId)]; segment.Keywords.Add(k); } } // CSV array is not needed any more segment.Csv = null; } // in case MediaItem was deleted foreach (var segment in withoutMediaItem) { _ = _model.All.Remove(segment); } // Table Properties if (TableProps == null) { return; } if (TableProps.TryGetValue(nameof(_model.SegmentSize), out var segmentSize)) { _model.SegmentSize = int.Parse(segmentSize); } if (TableProps.TryGetValue(nameof(_model.CompareSegmentSize), out var compareSegmentSize)) { _model.CompareSegmentSize = int.Parse(compareSegmentSize); } if (TableProps.TryGetValue(nameof(_model.SimilarityLimit), out var similarityLimit)) { _model.SimilarityLimit = int.Parse(similarityLimit); } if (TableProps.TryGetValue(nameof(_model.SimilarityLimitMin), out var similarityLimitMin)) { _model.SimilarityLimitMin = int.Parse(similarityLimitMin); } if (TableProps.TryGetValue(nameof(_model.SegmentsDrawer), out var segmentsDrawer) && !string.IsNullOrEmpty(segmentsDrawer)) { foreach (var segmentId in segmentsDrawer.Split(',')) { _model.SegmentsDrawer.Add(_model.AllDic[int.Parse(segmentId)]); } } // table props are not needed any more TableProps.Clear(); }