Hi All
Does anyone know if this is an internal Skyline nuget package?
Skyline.DataMiner.CommunityLibrary.Utility.Protocol
Regards
Ryan
Hi Ryan
Yes, the Skyline.DataMiner.CommunityLibrary.Utility.Protocol is an internal NuGet package. Depending on what you need from it, some parts (like the GetColumns) is already part of the Skyline.DataMiner.Core.DataMinerSystem.Protocol NuGet package (protocol.GetLocalElement().GetTable().GetColumns).

Hi Ryan
That library isn't maintained anymore. I had a look and the ClearTables method is just doing a protocol.DeleteRows with the primaryKeys (via GetColumn). The GetColumnsAsDictionary is a regular GetColumns which is looped over and put in a dictionary. You could easily recreate these methods in your precompile QAction and remove the reference to UtilityLibrary (as that will be kept internal).
Hi Michiel,
Ok thanks for this, when you say DeletRows, is that with an s or just protocol.DeleteRow?
Do you have these methods you could share?

Hi Ryan
I meant the protocol.DeleteRow. Instead of the 'raw' calls, I'll do you one better. Recently a new NuGet was made that contains some extension methods which are a clearer than the old NotifyProtocol calls.
You need to install the Skyline.DataMiner.Utils.Protocol.Extensions NuGet in your QAction. Then add the using 'using Skyline.DataMiner.Utils.Protocol.Extensions' at the top. Then in your code you can add these methods:
public static void ClearTable(SLProtocol protocol, int tablePid)
{
object[] keys = protocol.GetColumn(tablePid, 0);
protocol.DeleteRows(tablePid, keys);
}
public static IDictionary<string, object> GetColumnAsDictionary<T>(SLProtocol protocol, int tablePid, uint columnIdx)
where T : IConvertible
{
IDictionary<string, object> result = new Dictionary<string, object>();
object[] columns = protocol.GetColumns(tablePid, new uint[] { 0, columnIdx });
object[] keys = (object[])columns[0];
object[] values = (object[])columns[1];
for (int i = 0; i < keys.Length; i++)
{
result.Add(Convert.ToString(keys[i]), values[i].ChangeType<T>());
}
return result;
}
private static T ChangeType<T>(this object obj)
where T : IConvertible
{
if (obj == null)
{
return default(T);
}
var type = typeof(T);
if (type.IsEnum)
{
return (T)Enum.ToObject(type, obj.ChangeType<int>());
}
if (type != typeof(DateTime))
{
return (T)Convert.ChangeType(obj, type);
}
var oadate = Convert.ToDouble(obj);
if (oadate.CompareTo(-657435.0) >= 0 && oadate.CompareTo(2958465.99999999) <= 0)
{
object date = DateTime.FromOADate(oadate);
return (T)date;
}
throw new OverflowException($"{obj} is not a valid OA Date, supported range -657435.0 to 2958465.99999999");
}
Hi Michiel,
Thanks for that, I am wanting to use the ClearTables and GetColumnAsDictionary method.
Its a protocol from SkyLine that I am trying to slightly modify to test something out and in VS those are the only errors I am getting relating to that nuget package