Archive Management API

Overview

To utilize the data within the Archive Management screen, access to the AutoSol.ACM.ArchiveManagement.ClientLibrary and AutoSol.ACM.ArchiveManagement.UI classes is required

ArchiveManagement.ClientLibrary

Classes

ClassDescription
_ArchiveDetailCollectionA collection of _ArchiveDetailRecord objects.
_ArchiveDetailRecord

Represents a data row of an archive record.

ArchiveManagementClientRepresents a connection to the archive management application.
_ArchiveRecordCollectionA collection of _ArchiveStatusRecord objects.
_ArchiveStatusRecordRepresents a data row in a recordset of missing archive records.
_ArchiveSummaryProcessRepresents a data row of the current status of the archive process.
_FieldDataCollectionA collection of _FieldDataDetail, the raw archive data, which is part of the _ArchiveDetailRecord set.
_FieldDataDetailRepresents a data row of the parsed XML field and data portion of an Archive or Meter record.
_GapDetailsDeprecated.
_MeterRecordCollectionA collection of _MeterRecordDetail objects.
_MeterRecordDetailRepresents a data row of a meter record.
RangeDetailsDeprecated.

Methods

NameSummaryParameter
GetArchiveDetailRecords (int MeterId, string sStartDt, string sEndDt, string sArchiveType)Return hourly or daily records in the format of an _ArchvieDetailRecords  for the requested meter in the specified date range.  

MeterId = ACM ObjectId for Meter

sStartDt = yyyy-MM-dd HH:mm:ss formatted Start Date

sEndDt = yyyy-MM-dd HH:mm:ss formatted End Date

sArchiveType = "Hourly" ,  "Daily"

GetArchiveDetailForMeter( int MeterId)Deprecated. Use GetMeterConfigRecords
GetArchiveEventRecords (int MeterId, string sStartDt, string sEndDt, string sMeterName)Return event records in the format of an _ArchvieDetailRecords for the requested meter in the specified date range.  

MeterId = ACM ObjectId for Meter

sStartDt = yyyy-MM-dd HH:mm:ss formatted Start Date

sEndDt = yyyy-MM-dd HH:mm:ss formatted End Date

sMeterName = Meter Name

GetArchiveStatusRecords(int iUseContractHour, bool bOnlyMissing, bool bOnlyEnabled, string sArchiveType)Return _ArchvieDetailRecords or _MeterRecordCollection for the requested meter in the specified date range.  

iUseContractHour = deprecated

bOnlyMissing = retrieve only missing records

bOnlyEnabled = show only devices that are enabled

sArchiveType =  "Hourly" ,  "Daily"

GetMeterConfigRecords(int MeterId)Return the current meter record in the format of a _MeterRecordCollection for the requested meter.MeterId = ACM ObjectId for Meter
GetSummaryStatusReturn the current status of the Archive process in the format of a _ArchvieSummaryProcess.
HelloWorldReturns HelloWorld. Use for testing successful connection.
InvokeArchiveSnapshotStarts the archive missing report process.
KeepAliveStandard KeepAlive to prevent Garbage Collection

ArchiveManagement.UI

Classes

ClassDescription
ArchiveDetailsUser Control of the Archive Management Screen.
ArchiveManagementControl

User Control that controls the preset data for the ArchiveDetail screen.

FormDetailsUser Control for the Archive Management Detail Screen.
ServerConnsA collection of _ArchiveStatusRecord objects.

Methods

NameSummaryParameter
ConnectToConfigServerConnects the Archive Management User forms to the running Configuration Server.


ConnectToServerConnects to the Archive Management on the local host.
ConnectToServer (string strHost)Connects to the Archive Management on the specified host.

strHost = Server Name to connect to

DisconnectFromConfigServer()Disconnect from the connected Configuration Server.


DisconnectFromServer()Disconnect from the connected Reporting Services for Archive Management client.

Example Using C#

using AutoSol.ACM.ArchiveManagement.ClientLibrary.ArchiveManagementSvc;
using System;
using System.Windows.Forms;

/* make sure you do these three things...
 add reference for AutoSol.ACM.ArchiveManagement.ClientLibrary
 add reference for AutoSol.ACM.ArchiveManagement.UI
 set project properites to use .net4.7.2
*/

namespace WindowsFormsApp1
{
	public partial class Form1 : Form
	{
		//The archive management service connection
		AutoSol.ACM.ArchiveManagement.UI.ServerConns _archiveConn = new AutoSol.ACM.ArchiveManagement.UI.ServerConns();

		public Form1()
		{
			InitializeComponent();

			// Set the host address we want to connect to
			_archiveConn.ConnectToServer("localhost");
		}

		private void btnRetrieveData_Click(object sender, EventArgs e)
		{
			GetHourlySummary();
			GetDailySummary();
		}

		private void GetHourlySummary()
		{
			//Gets the summary hourly archive data for only missing and enabled objects
			AutoSol.ACM.ArchiveManagement.ClientLibrary.ArchiveManagementSvc._ArchiveRecordCollection hourlyRecs;
			hourlyRecs = _myConns._archiveClient.GetArchiveStatusRecords(0, true, true, "Hourly");

			//The data can be easily used as a datasource
			if (hourlyRecs != null)
			{
				DataGridView dgv = new DataGridView();
				dgv.DataSource = hourlyRecs.archiveRecords;
			}
		}

		private void GetDailySummary()
		{
			AutoSol.ACM.ArchiveManagement.ClientLibrary.ArchiveManagementSvc._ArchiveRecordCollection dailyRecs;

			//Gets the summary daily archive data for all enabled objects
			dailyRecs= _myConns._archiveClient.GetArchiveStatusRecords(0, false, true, "Daily");

			//You can drill into the individual records verses as well as using them as a single object
			if (dailyRecs != null)
			{
				//Gets the meter details of the first meter record to find more information about that meter
				int meterId = dailyRecs.archiveRecords[0].MeterId;
				string meterName = GetMeterInfo(meterId);
				GetEventsForMeter(meterId, meterName);
			}
		}

		private string GetMeterInfo( int meterId )
		{
			//Gets the meter details of the first meter record
			_MeterRecordCollection meterRec = _archiveConn._archiveClient.GetMeterConfigRecords(meterId);

			//The meter record will only ever return 1 meter record
			if (meterRec != null)
			{
				string meterName = meterRec.meterConfigColl[0].MeterName;
				return meterName;
			}

			return String.Empty;
		}

		private string GetEventsForMeter( int meterId, string meterName )
		{
			//Gets the meter last 30 days of event records
			string startDate = DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd HH:mm:ss");
			string endDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
			_ArchiveDetailCollection eventRecs = _archiveConn._archiveClient.GetArchiveEventRecords(meterId, startDate, endDate, meterName);

			//The meter record will only ever return 1 meter record
			if (eventRecs != null)
			{
				MessageBox.Show("Found " + eventRecs.archiveDetailRecords.Length.ToString()+" events");
			}
		}

		private void Form1_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (_myConns != null)
			{
				//Disconnect
				_myConns.DisconnectFromServer();
			}
		}
	}
}


Example Using VB .Net

Module Module1

	Sub Main()
		'The archive management service connection
		Dim _archiveConn As New AutoSol.ACM.ArchiveManagement.UI.ServerConns()

		'Set the host address we want to connect to
		_archiveConn.ConnectToServer("localhost")

		'Invoke the service process
		_archiveConn._archiveClient.InvokeArchiveSnapshot()

		Dim isProcessRunning As Boolean
		isProcessRunning = ProcessRunning(_archiveConn)

		While (isProcessRunning = True)
			isProcessRunning = ProcessRunning(_archiveConn)
			Threading.Thread.CurrentThread.Sleep(1000)
		End While

		_archiveConn.DisconnectFromServer()

	End Sub

	Private Function ProcessRunning(_archiveConn As AutoSol.ACM.ArchiveManagement.UI.ServerConns) As Boolean
		'Check the summary status
		Dim _archiveSummary As New AutoSol.ACM.ArchiveManagement.ClientLibrary.ArchiveManagementSvc._ArchiveSummaryProcess
		_archiveSummary = _archiveConn._archiveClient.GetSummaryStatus()

		If (_archiveSummary IsNot Nothing) Then
			Dim finishTime As String
			Dim errorMsg As String

			finishTime = _archiveSummary.FinishTime
			errorMsg = _archiveSummary.ErrorMessage

			If (finishTime.Equals("Pending", StringComparison.InvariantCultureIgnoreCase)) Then
				Console.WriteLine("Process is still running")
				Return True

			ElseIf (errorMsg.Equals("No error", StringComparison.InvariantCultureIgnoreCase)) Then
				Console.WriteLine("Process finished at: " + finishTime)
				Return False

			ElseIf (errorMsg IsNot Nothing) Then
				Console.WriteLine("Error invoking process: " + errorMsg)
				Return False
			End If
		Else
			Console.WriteLine("Process did not return anything")
			Return False
		End If

	End Function


End Module


For assistance, please submit a ticket via our Support Portal, email autosol.support@autosoln.com or call 281.286.6017 to speak to a support team member.