Skip to content

Commit

Permalink
Small code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
barnstee committed Jan 19, 2024
1 parent 965df70 commit 0f883b1
Showing 1 changed file with 54 additions and 54 deletions.
108 changes: 54 additions & 54 deletions Applications/ADXClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,54 +31,11 @@ public ADXClient(ILogger<ADTClient> logger)

public void AddAsset(string assetName, string uaApplicationURI, string uaNamespaceURI, string publisherName)
{
ClientRequestProperties clientRequestProperties = new ClientRequestProperties()
{
ClientRequestId = Guid.NewGuid().ToString()
};

string query = "TODO!";
Dictionary<string, object> values = new();

try
{
using (IDataReader reader = _queryProvider?.ExecuteQuery(query, clientRequestProperties))
{
while ((reader != null) && reader.Read())
{
for (int i = 0; i < reader.FieldCount; i++)
{
try
{
if (reader.GetValue(i) != null)
{
string value = reader.GetValue(i).ToString();
if (value != null)
{
if (values.ContainsKey(value))
{
values[value] = reader.GetValue(i);
}
else
{
values.TryAdd(value, reader.GetValue(i));
}
}
}
}
catch (Exception ex)
{
_logger.LogError(ex.Message);

// ignore this field and move on
}
}
}
}
}
catch (Exception ex)
{
_logger.LogError(ex.Message);
}
// nothing to do - this is handled via ADX data ingest directly!
}
public void UpdateAssetTelemetry(string assetName, string telemetryName, BuiltInType telemetryType, DataValue telemetryValue)
{
// nothing to do - this is handled via ADX data ingest directly!
}

public void Login(string instanceUrl)
Expand Down Expand Up @@ -120,11 +77,6 @@ public void Login(string instanceUrl)
}
}

public void UpdateAssetTelemetry(string assetName, string telemetryName, BuiltInType telemetryType, DataValue telemetryValue)
{
// nothing to do - this is handled via ADX data ingest directly!
}

public void UploadTwinModels()
{
Login(Environment.GetEnvironmentVariable("ADX_INSTANCE_URL"));
Expand Down Expand Up @@ -157,7 +109,6 @@ public void UploadTwinModels()
{
DTDL deserializedModel = JsonConvert.DeserializeObject<DTDL>(model);

// TODO
Debug.WriteLine("DTDL ID:" + deserializedModel.id);

if (deserializedModel.contents != null)
Expand All @@ -170,6 +121,55 @@ public void UploadTwinModels()
}
}
}

ClientRequestProperties clientRequestProperties = new ClientRequestProperties()
{
ClientRequestId = Guid.NewGuid().ToString()
};

string query = "TODO!";
Dictionary<string, object> values = new();

try
{
using (IDataReader reader = _queryProvider?.ExecuteQuery(query, clientRequestProperties))
{
while ((reader != null) && reader.Read())
{
for (int i = 0; i < reader.FieldCount; i++)
{
try
{
if (reader.GetValue(i) != null)
{
string value = reader.GetValue(i).ToString();
if (value != null)
{
if (values.ContainsKey(value))
{
values[value] = reader.GetValue(i);
}
else
{
values.TryAdd(value, reader.GetValue(i));
}
}
}
}
catch (Exception ex)
{
_logger.LogError(ex.Message);

// ignore this field and move on
}
}
}
}
}
catch (Exception ex)
{
_logger.LogError(ex.Message);
}
}
}

Expand Down

0 comments on commit 0f883b1

Please sign in to comment.