Contains a DIS Macro to generate a class for a selected table in a Connector. It will generate a class representing a row, and one representing the table.
Note
This generated class can be used as a start. For example if your column is a discreet you might want to have a property of type enum instead of a double. You can just edit this generated class and change the properties. Don't forget to update the constructor and the ToProtocolRow method too.
You can do a manual install by downloading the .xml file from the releases.
- Go to releases
- Download the .xml file from the latest version
- Go to Visual Studio -> Extension -> DIS -> Tool Windows -> DIS Macros
- In the DIS Macros windows right click "My Macros"
- Click on "Import macros...", this will open a windows explorer dialog
- Go to the file you just downloaded.
- Open a Connector in visual studio.
- Open the Connector's .xml file.
- Open the DIS Macros tool window.
- Select the table and all of it's columns.
- Select the "Create Class from Table" macro.
- Press run at the top of the DIS Macros window.
- The generated code will be copied to your Clipboard.
- Create a new file in your pre compiled QAction, for example: "MyTable.cs".
- Paste the generated code.
// <auto-generated>This is auto-generated code by a DIS Macro. Do not modify.</auto-generated>
namespace Skyline.Protocol.Tables
{
using System;
using System.Collections.Generic;
using System.Linq;
using Skyline.DataMiner.Net.Helper;
using Skyline.DataMiner.Scripting;
using SLNetMessages = Skyline.DataMiner.Net.Messages;
public class RepositoryTagsRecord
{
private static readonly double DateTimeNotAvailable = -2;
public RepositoryTagsRecord() { }
public RepositoryTagsRecord(params object[] row)
{
ID = Convert.ToString(row[0]);
Name = Convert.ToString(row[1]);
RepositoryID = Convert.ToString(row[2]);
CommitSHA = Convert.ToString(row[3]);
}
public string ID { get; set; }
public string Name { get; set; }
public string RepositoryID { get; set; }
public string CommitSHA { get; set; }
public static RepositoryTagsRecord FromPK(SLProtocol protocol, string pk)
{
var row = (object[])protocol.GetRow(Parameter.Repositorytags.tablePid, pk);
if(row[0] == null)
{
return default;
}
return new RepositoryTagsRecord(row);
}
public object[] ToProtocolRow()
{
return new RepositorytagsQActionRow
{
Repositorytagsid_1201 = ID,
Repositorytagsname_1202 = Name,
Repositorytagsrepositoryid_1203 = RepositoryID,
Repositorytagscommitsha_1204 = CommitSHA,
};
}
public void SaveToProtocol(SLProtocol protocol)
{
if(!protocol.Exists(Parameter.Repositorytags.tablePid, ID))
{
protocol.AddRow(Parameter.Repositorytags.tablePid, ToProtocolRow());
}
else
{
protocol.SetRow(Parameter.Repositorytags.tablePid, ID, ToProtocolRow());
}
}
}
public class RepositoryTagsRecords
{
public RepositoryTagsRecords() { }
public RepositoryTagsRecords(SLProtocol protocol)
{
uint[] repositoryTagsIdx = new uint[]
{
Parameter.Repositorytags.Idx.repositorytagsid_1201,
Parameter.Repositorytags.Idx.repositorytagsname_1202,
Parameter.Repositorytags.Idx.repositorytagsrepositoryid_1203,
Parameter.Repositorytags.Idx.repositorytagscommitsha_1204,
};
object[] repositorytags = (object[])protocol.NotifyProtocol((int)SLNetMessages.NotifyType.NT_GET_TABLE_COLUMNS, Parameter.Repositorytags.tablePid, repositoryTagsIdx);
object[] iD = (object[])repositorytags[0];
object[] name = (object[])repositorytags[1];
object[] repositoryID = (object[])repositorytags[2];
object[] commitSHA = (object[])repositorytags[3];
for (int i = 0; i < iD.Length; i++)
{
Rows.Add( new RepositoryTagsRecord(
iD[i],
name[i],
repositoryID[i],
commitSHA[i]));
}
}
public List<RepositoryTagsRecord> Rows { get; set; } = new List<RepositoryTagsRecord>();
public void SaveToProtocol(SLProtocol protocol, bool partial = false)
{
// Calculate the batch size, recommended 25000 cells max per fill array, divided by the number of columns.
var batchSize = 25000 / 4;
// If full then the first batch needs to be a SaveOption.Full.
var first = !partial;
if (!Rows.Any() && !partial)
{
protocol.ClearAllKeys(Parameter.Repositorytags.tablePid);
return;
}
foreach (var batch in Rows.Select(x => x.ToProtocolRow()).Batch(batchSize))
{
if (first)
{
protocol.FillArray(Parameter.Repositorytags.tablePid, batch.ToList(), NotifyProtocol.SaveOption.Full);
}
else
{
protocol.FillArray(Parameter.Repositorytags.tablePid, batch.ToList(), NotifyProtocol.SaveOption.Partial);
}
}
}
}
}
DataMiner is a transformational platform that provides vendor-independent control and monitoring of devices and services. Out of the box and by design, it addresses key challenges such as security, complexity, multi-cloud, and much more. It has a pronounced open architecture and powerful capabilities enabling users to evolve easily and continuously.
The foundation of DataMiner is its powerful and versatile data acquisition and control layer. With DataMiner, there are no restrictions to what data users can access. Data sources may reside on premises, in the cloud, or in a hybrid setup.
A unique catalog of 7000+ connectors already exist. In addition, you can leverage DataMiner Development Packages to build you own connectors (also known as "protocols" or "drivers").
Note See also: About DataMiner.
At Skyline Communications, we deal in world-class solutions that are deployed by leading companies around the globe. Check out our proven track record and see how we make our customers' lives easier by empowering them to take their operations to the next level.