From bd72c7efe687dfaca6d4fd3c0fc2b5a39d57df55 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Wed, 12 Aug 2020 02:12:46 +0300 Subject: More work on proc_doc. Fixed app crash on code editor selection. --- .../PPC/Tango.PPC.Shared/SQL/RemoteSqlColumn.cs | 28 +++++++++++ .../SQL/RemoteSqlColumnCollection.cs | 31 ++++++++++++ .../PPC/Tango.PPC.Shared/SQL/RemoteSqlDataSet.cs | 35 ++++++++++++++ .../PPC/Tango.PPC.Shared/SQL/RemoteSqlRow.cs | 55 ++++++++++++++++++++++ .../PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj | 4 ++ 5 files changed, 153 insertions(+) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Shared') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/SQL/RemoteSqlColumn.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/SQL/RemoteSqlColumn.cs index 328dbb492..54431bdbe 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Shared/SQL/RemoteSqlColumn.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/SQL/RemoteSqlColumn.cs @@ -6,19 +6,47 @@ using System.Threading.Tasks; namespace Tango.PPC.Shared.SQL { + /// + /// Represents a column. + /// public class RemoteSqlColumn { + /// + /// Gets or sets the column name. + /// public String Name { get; set; } + + /// + /// Gets or sets the column index. + /// public int Index { get; set; } + /// + /// Initializes a new instance of the class. + /// public RemoteSqlColumn() { } + /// + /// Initializes a new instance of the class. + /// + /// The column name. public RemoteSqlColumn(String name) { Name = name; } + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + { + return Name; + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/SQL/RemoteSqlColumnCollection.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/SQL/RemoteSqlColumnCollection.cs index 5358e047b..dfda6c3b7 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Shared/SQL/RemoteSqlColumnCollection.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/SQL/RemoteSqlColumnCollection.cs @@ -7,15 +7,27 @@ using System.Threading.Tasks; namespace Tango.PPC.Shared.SQL { + /// + /// Represents a columns collection. + /// + /// public class RemoteSqlColumnCollection : Collection { private Dictionary _dictionary; + /// + /// Initializes a new instance of the class. + /// public RemoteSqlColumnCollection() { _dictionary = new Dictionary(); } + /// + /// Inserts an element into the at the specified index. + /// + /// The zero-based index at which should be inserted. + /// The object to insert. The value can be null for reference types. protected override void InsertItem(int index, RemoteSqlColumn item) { item.Index = Count; @@ -23,22 +35,41 @@ namespace Tango.PPC.Shared.SQL base.InsertItem(index, item); } + /// + /// Removes the element at the specified index of the . + /// + /// The zero-based index of the element to remove. + /// protected override void RemoveItem(int index) { throw new NotSupportedException(); } + /// + /// Removes all elements from the . + /// protected override void ClearItems() { _dictionary.Clear(); base.ClearItems(); } + /// + /// Replaces the element at the specified index. + /// + /// The zero-based index of the element to replace. + /// The new value for the element at the specified index. The value can be null for reference types. + /// protected override void SetItem(int index, RemoteSqlColumn item) { throw new NotSupportedException(); } + /// + /// Gets the column index by column name. + /// + /// Column name. + /// public int GetIndexOf(String columnName) { return _dictionary[columnName].Index; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/SQL/RemoteSqlDataSet.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/SQL/RemoteSqlDataSet.cs index 089908e5a..72b8d2eb2 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Shared/SQL/RemoteSqlDataSet.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/SQL/RemoteSqlDataSet.cs @@ -9,17 +9,37 @@ using System.Threading.Tasks; namespace Tango.PPC.Shared.SQL { + /// + /// Represents remote database query result composed of rows and columns. + /// + /// + /// + /// + /// The following example demonstrates how to set the connected machine's demo state and query for the connected machine's jobs. + /// + /// + /// + /// public class RemoteSqlDataSet { + /// + /// Gets or sets the dataset columns. + /// public RemoteSqlColumnCollection Columns { get; set; } private ObservableCollection _rows; + /// + /// Gets or sets the dataset rows. + /// public ObservableCollection Rows { get { return _rows; } set { _rows = value; OnRowsChanged(); } } + /// + /// Initializes a new instance of the class. + /// public RemoteSqlDataSet() { Columns = new RemoteSqlColumnCollection(); @@ -61,6 +81,11 @@ namespace Tango.PPC.Shared.SQL } } + /// + /// Creates a new using the specified . + /// + /// The reader. + /// public static Task Load(SqlDataReader reader) { return Task.Factory.StartNew(() => @@ -100,11 +125,21 @@ namespace Tango.PPC.Shared.SQL }); } + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// public override string ToString() { return String.Join(", ", Columns.Select(x => x.Name)) + "\n" + String.Join(Environment.NewLine, Rows.Select(x => x.ToString())); } + /// + /// Formats this dataset as a string with columns and rows. + /// + /// public String ToTableString() { Dictionary columnsMaxLength = new Dictionary(); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/SQL/RemoteSqlRow.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/SQL/RemoteSqlRow.cs index bf6b0ba0c..dfabacfea 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Shared/SQL/RemoteSqlRow.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/SQL/RemoteSqlRow.cs @@ -10,28 +10,61 @@ using Tango.BL.Entities; namespace Tango.PPC.Shared.SQL { + /// + /// Represents a row. + /// + /// + /// + /// + /// The following example demonstrates how to set the connected machine's demo state and query for the connected machine's jobs. + /// + /// + /// + /// public class RemoteSqlRow { private Func _getFuncKey; private Func _getFuncIndex; + /// + /// Gets or sets the row values. + /// public List Values { get; set; } + /// + /// Initializes a new instance of the class. + /// public RemoteSqlRow() { Values = new List(); } + /// + /// Gets a row value by its column name. + /// + /// Name of the column. + /// The column value. public Object Get(String columnName) { return _getFuncKey.Invoke(columnName); } + /// + /// Gets a row value by its column index. + /// + /// Index of the column. + /// The column value. public Object Get(int columnIndex) { return _getFuncIndex.Invoke(columnIndex); } + /// + /// Gets a row value as type T by its column name. + /// + /// Expected column type. + /// Name of the column. + /// The column value. public T Get(String columnName) { var value = _getFuncKey.Invoke(columnName); @@ -46,6 +79,12 @@ namespace Tango.PPC.Shared.SQL } } + /// + /// Gets a row value by its column index. + /// + /// Expected column type + /// Index of the column. + /// The column value. public T Get(int columnIndex) { var value = _getFuncIndex.Invoke(columnIndex); @@ -66,11 +105,22 @@ namespace Tango.PPC.Shared.SQL _getFuncIndex = getFuncIndex; } + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// public override string ToString() { return String.Join(", ", Values); } + /// + /// Creates an object of type T and maps this row to it based on its properties decorated with . + /// + /// + /// public T Map() where T : class, new() { var obj = Activator.CreateInstance(); @@ -78,6 +128,11 @@ namespace Tango.PPC.Shared.SQL return obj; } + /// + /// Maps this row to the specified object based on its properties decorated with . + /// + /// Model type + /// The object. public void Map(T obj) where T : class { foreach (var prop in typeof(T).GetPropertiesWithAttribute()) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj index 10993399c..a0cc9b153 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj @@ -22,6 +22,8 @@ DEBUG;TRACE prompt 4 + ..\..\Build\PPC\Debug\Tango.PPC.Shared.xml + 1591 pdbonly @@ -30,6 +32,8 @@ TRACE prompt 4 + ..\..\Build\PPC\Release\Tango.PPC.Shared.xml + 1591 -- cgit v1.3.1