Skip to content

Commit

Permalink
remove nodered commands
Browse files Browse the repository at this point in the history
  • Loading branch information
skadefro committed Mar 1, 2023
1 parent b5e6f92 commit cf32bf7
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 110 deletions.
60 changes: 30 additions & 30 deletions OpenRPA.PS/NodeRED/AddNoderedInstance.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenRPA.Interfaces;
using System.Management.Automation;
using Newtonsoft.Json.Linq;
using System.Collections.ObjectModel;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//using OpenRPA.Interfaces;
//using System.Management.Automation;
//using Newtonsoft.Json.Linq;
//using System.Collections.ObjectModel;

namespace OpenRPA.PS
{
[Cmdlet(VerbsCommon.Add, "NoderedInstance")]
public class AddNoderedInstance : OpenRPACmdlet
{
[Parameter(Position = 0, ValueFromPipeline = true)] public string _id { get; set; }
protected override async Task ProcessRecordAsync()
{
try
{
string traceId = ""; string spanId = "";
if (string.IsNullOrEmpty(_id)) { _id = global.webSocketClient.user._id; }
await global.webSocketClient.EnsureNoderedInstance(_id, traceId, spanId);
}
catch (Exception ex)
{
WriteError(new ErrorRecord(ex, "", ErrorCategory.NotSpecified, null));
}
//namespace OpenRPA.PS
//{
// [Cmdlet(VerbsCommon.Add, "NoderedInstance")]
// public class AddNoderedInstance : OpenRPACmdlet
// {
// [Parameter(Position = 0, ValueFromPipeline = true)] public string _id { get; set; }
// protected override async Task ProcessRecordAsync()
// {
// try
// {
// string traceId = ""; string spanId = "";
// if (string.IsNullOrEmpty(_id)) { _id = global.webSocketClient.user._id; }
// await global.webSocketClient.EnsureNoderedInstance(_id, traceId, spanId);
// }
// catch (Exception ex)
// {
// WriteError(new ErrorRecord(ex, "", ErrorCategory.NotSpecified, null));
// }


}
}
}
// }
// }
//}
100 changes: 50 additions & 50 deletions OpenRPA.PS/NodeRED/GetNoderedInstance.cs
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenRPA.Interfaces;
using System.Management.Automation;
using Newtonsoft.Json.Linq;
using System.Collections.ObjectModel;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//using OpenRPA.Interfaces;
//using System.Management.Automation;
//using Newtonsoft.Json.Linq;
//using System.Collections.ObjectModel;

namespace OpenRPA.PS
{
[Cmdlet(VerbsCommon.Get, "NoderedInstance")]
public class GetNoderedInstance : OpenRPACmdlet
{
[Parameter(Position = 0, ValueFromPipeline = true)] public string _id { get; set; }
[Parameter(Position = 1)] public int Minutes { get; set; }
protected override async Task ProcessRecordAsync()
{
try
{
if (Minutes < 1) Minutes = 1;
// string dt = DateTime.UtcNow.AddMinutes(Minutes).ToString("o", System.Globalization.CultureInfo.InvariantCulture);
string dt = DateTime.UtcNow.AddMinutes(-Minutes).ToString("yyyy-MM-dd'T'HH:mm:ss.fffK", System.Globalization.CultureInfo.InvariantCulture);
string json = "{\"_type\":\"user\", \"_noderedheartbeat\": { \"$gte\": \"" + dt + "\" } }";
if (!string.IsNullOrEmpty(_id)) { json = "{\"_type\":\"user\", \"_id\": \"" + _id + "\"}"; }
var entities = await global.webSocketClient.Query<JObject>("users", json, top: 100);
int index = 0;
foreach (var entity in entities)
{
if (entity.ContainsKey("name"))
{
WriteVerbose("Parsing " + entity.Value<string>("_id") + " " + entity.Value<string>("name"));
}
else
{
WriteVerbose("Parsing " + entity.Value<string>("_id"));
}
// results.Add(obj);
WriteObject(entity.toPSObjectWithTypeName("users"));
index++;
if (index % 10 == 9) await Task.Delay(1);
}
//namespace OpenRPA.PS
//{
// [Cmdlet(VerbsCommon.Get, "NoderedInstance")]
// public class GetNoderedInstance : OpenRPACmdlet
// {
// [Parameter(Position = 0, ValueFromPipeline = true)] public string _id { get; set; }
// [Parameter(Position = 1)] public int Minutes { get; set; }
// protected override async Task ProcessRecordAsync()
// {
// try
// {
// if (Minutes < 1) Minutes = 1;
// // string dt = DateTime.UtcNow.AddMinutes(Minutes).ToString("o", System.Globalization.CultureInfo.InvariantCulture);
// string dt = DateTime.UtcNow.AddMinutes(-Minutes).ToString("yyyy-MM-dd'T'HH:mm:ss.fffK", System.Globalization.CultureInfo.InvariantCulture);
// string json = "{\"_type\":\"user\", \"_noderedheartbeat\": { \"$gte\": \"" + dt + "\" } }";
// if (!string.IsNullOrEmpty(_id)) { json = "{\"_type\":\"user\", \"_id\": \"" + _id + "\"}"; }
// var entities = await global.webSocketClient.Query<JObject>("users", json, top: 100);
// int index = 0;
// foreach (var entity in entities)
// {
// if (entity.ContainsKey("name"))
// {
// WriteVerbose("Parsing " + entity.Value<string>("_id") + " " + entity.Value<string>("name"));
// }
// else
// {
// WriteVerbose("Parsing " + entity.Value<string>("_id"));
// }
// // results.Add(obj);
// WriteObject(entity.toPSObjectWithTypeName("users"));
// index++;
// if (index % 10 == 9) await Task.Delay(1);
// }

}
catch (Exception ex)
{
WriteError(new ErrorRecord(ex, "", ErrorCategory.NotSpecified, null));
}
// }
// catch (Exception ex)
// {
// WriteError(new ErrorRecord(ex, "", ErrorCategory.NotSpecified, null));
// }


}
}
}
// }
// }
//}
60 changes: 30 additions & 30 deletions OpenRPA.PS/NodeRED/RemoveNoderedInstance.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenRPA.Interfaces;
using System.Management.Automation;
using Newtonsoft.Json.Linq;
using System.Collections.ObjectModel;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//using OpenRPA.Interfaces;
//using System.Management.Automation;
//using Newtonsoft.Json.Linq;
//using System.Collections.ObjectModel;

namespace OpenRPA.PS
{
[Cmdlet(VerbsCommon.Remove, "NoderedInstance")]
public class RemoveNoderedInstance : OpenRPACmdlet
{
[Parameter(Position = 0, ValueFromPipeline = true)] public string _id { get; set; }
protected override async Task ProcessRecordAsync()
{
try
{
string traceId = ""; string spanId = "";
if (string.IsNullOrEmpty(_id)) { _id = global.webSocketClient.user._id; }
await global.webSocketClient.DeleteNoderedInstance(_id, "", "");
}
catch (Exception ex)
{
WriteError(new ErrorRecord(ex, "", ErrorCategory.NotSpecified, null));
}
//namespace OpenRPA.PS
//{
// [Cmdlet(VerbsCommon.Remove, "NoderedInstance")]
// public class RemoveNoderedInstance : OpenRPACmdlet
// {
// [Parameter(Position = 0, ValueFromPipeline = true)] public string _id { get; set; }
// protected override async Task ProcessRecordAsync()
// {
// try
// {
// string traceId = ""; string spanId = "";
// if (string.IsNullOrEmpty(_id)) { _id = global.webSocketClient.user._id; }
// await global.webSocketClient.DeleteNoderedInstance(_id, "", "");
// }
// catch (Exception ex)
// {
// WriteError(new ErrorRecord(ex, "", ErrorCategory.NotSpecified, null));
// }


}
}
}
// }
// }
//}

0 comments on commit cf32bf7

Please sign in to comment.