public override void RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; var vAssetName = v_AssetName.ConvertUserVariableToString(engine); var vAssetActionValue = v_AssetActionValue.ConvertUserVariableToString(engine); var client = AuthMethods.GetAuthToken(); var asset = AssetMethods.GetAsset(client, vAssetName, "Number"); if (asset == null) { throw new DataException($"No Asset was found for '{vAssetName}' and type 'Number'"); } switch (v_AssetActionType) { case "Increment": AssetMethods.IncrementAsset(client, asset.Id); break; case "Decrement": AssetMethods.DecrementAsset(client, asset.Id); break; case "Add": AssetMethods.AddAsset(client, asset.Id, vAssetActionValue); break; case "Subtract": AssetMethods.SubtractAsset(client, asset.Id, vAssetActionValue); break; } }
public override async Task RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; var vHumanTaskId = (Guid)await v_TaskId.EvaluateCode(engine); var vDocId = (Guid)await v_DocumentId.EvaluateCode(engine); string vUsername; string vPassword; var environmentSettings = new EnvironmentSettings(); environmentSettings.Load(); AuthMethods authMethods = new AuthMethods(); authMethods.Initialize(environmentSettings.ServerType, environmentSettings.OrganizationName, environmentSettings.ServerUrl, environmentSettings.Username, environmentSettings.Password); if (environmentSettings.ServerType == "Local") { throw new Exception("Documents commands cannot be used with local Server"); } else { vUsername = environmentSettings.Username; vPassword = environmentSettings.Password; } var userInfo = authMethods.GetDocumentsAuthToken(vUsername, vPassword); DocumentMethods.MarkDocumentAsVerified(userInfo, vHumanTaskId, vDocId); }
public void SetFailedFatallyStatus() { _engine = new AutomationEngineInstance(null); _setQueueItem = new SetQueueItemStatusCommand(); string name = "FailedQueueItem"; AddQueueItem(name); var queueItemDict = WorkQueueItem(); var client = AuthMethods.GetAuthToken(); var transactionKey = queueItemDict["LockTransactionKey"].ToString(); var queueItem = QueueItemMethods.GetQueueItemByLockTransactionKey(client, transactionKey); VariableMethods.CreateTestVariable(null, _engine, "vQueueItem", typeof(Dictionary <,>)); _setQueueItem.v_QueueItem = "{vQueueItem}"; queueItemDict.StoreInUserVariable(_engine, _setQueueItem.v_QueueItem, typeof(Dictionary <,>)); _setQueueItem.v_QueueItemStatusType = "Failed - Fatal"; _setQueueItem.RunCommand(_engine); queueItem = QueueItemMethods.GetQueueItemById(client, queueItem.Id); Assert.Equal("Failed", queueItem.State); }
public CheckMail(Life.Activity activity, string credential = "Life.CheckMail", int seconds = 60, AuthMethods method = AuthMethods.Login) : base(activity) { _credential = credential; _seconds = seconds; _method = method; }
public ImapClient(string host, string username, string password, AuthMethods method = AuthMethods.Login, int port = 143, bool secure = false, bool skipSslValidation = false) : this() { Connect(host, port, secure, skipSslValidation); AuthMethod = method; Login(username, password); }
public override void RunCommand(object sender) { var engine = (AutomationEngineInstance)sender; var vQueueItem = (Dictionary <string, object>)v_QueueItem.ConvertUserVariableToObject(engine); var vQueueItemErrorMessage = v_QueueItemErrorMessage.ConvertUserVariableToString(engine); var vQueueItemErrorCode = v_QueueItemErrorCode.ConvertUserVariableToString(engine); var client = AuthMethods.GetAuthToken(); Guid transactionKey = (Guid)vQueueItem["LockTransactionKey"]; switch (v_QueueItemStatusType) { case "Successful": QueueItemMethods.CommitQueueItem(client, transactionKey); break; case "Failed - Should Retry": QueueItemMethods.RollbackQueueItem(client, transactionKey, vQueueItemErrorCode, vQueueItemErrorMessage, false); break; case "Failed - Fatal": QueueItemMethods.RollbackQueueItem(client, transactionKey, vQueueItemErrorCode, vQueueItemErrorMessage, true); break; } }
public override void RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; var vAccountName = v_AccountName.ConvertUserVariableToString(engine); var vToRecipients = v_ToRecipients.ConvertUserVariableToString(engine); var vCCRecipients = v_CCRecipients.ConvertUserVariableToString(engine); var vBCCRecipients = v_BCCRecipients.ConvertUserVariableToString(engine); var vSubject = v_Subject.ConvertUserVariableToString(engine); var vBody = v_Body.ConvertUserVariableToString(engine); var vAttachments = v_Attachments.ConvertUserVariableToString(engine); var toEmailList = ServerEmailMethods.GetEmailList(vToRecipients); var ccEmailList = ServerEmailMethods.GetEmailList(vCCRecipients); var bccEmailList = ServerEmailMethods.GetEmailList(vBCCRecipients); var emailMessage = new EmailMessage() { To = toEmailList, CC = ccEmailList, BCC = bccEmailList, Subject = vSubject, Body = vBody }; if (string.IsNullOrEmpty(vToRecipients)) { throw new NullReferenceException("To Recipient(s) cannot be empty"); } var client = AuthMethods.GetAuthToken(); ServerEmailMethods.SendServerEmail(client, emailMessage, vAttachments, vAccountName); }
public void WorkQueueItemNoAttachments() { _engine = new AutomationEngineInstance(null); _addQueueItem = new AddQueueItemCommand(); _workQueueItem = new WorkQueueItemCommand(); VariableMethods.CreateTestVariable(null, _engine, "output", typeof(Dictionary <,>)); _addQueueItem.v_QueueName = "UnitTestQueue"; _addQueueItem.v_QueueItemName = "WorkQueueItemNoAttachmentTest"; _addQueueItem.v_QueueItemType = "Text"; _addQueueItem.v_JsonType = "Test Type"; _addQueueItem.v_QueueItemTextValue = "Test Text"; _addQueueItem.v_Priority = "10"; _addQueueItem.RunCommand(_engine); _workQueueItem.v_QueueName = "UnitTestQueue"; _workQueueItem.v_OutputUserVariableName = "{output}"; _workQueueItem.v_SaveAttachments = "No"; _workQueueItem.v_AttachmentDirectory = ""; _workQueueItem.RunCommand(_engine); var queueItemObject = (Dictionary <string, object>) "{output}".ConvertUserVariableToObject(_engine, typeof(Dictionary <,>)); var client = AuthMethods.GetAuthToken(); var queueItem = QueueItemMethods.GetQueueItemByLockTransactionKey(client, queueItemObject["LockTransactionKey"].ToString()); Assert.Equal("InProgress", queueItem.State); }
public async Task <ServiceResponseObject <AuthResponse> > Login(LoginViewModel model) { if (ModelState.IsValid) { AuthMethods AuthData = new AuthMethods(_userManager, _signInManager, _roleManager, _boxContext); var Result = await AuthData.Login(model); return(Result); } ServiceResponseObject <AuthResponse> response = new ServiceResponseObject <AuthResponse>(); response.Status = ResponseResult.Error; List <string> errors = ModelState.Values.Aggregate( new List <string>(), (a, c) => { a.AddRange(c.Errors.Select(r => r.ErrorMessage)); return(a); }, a => a ); response.Message = errors[0]; return(response); }
public override void RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; var vQueueItem = (Dictionary <string, object>)v_QueueItem.ConvertUserVariableToObject(engine, nameof(v_QueueItem), this); var vQueueItemErrorMessage = v_QueueItemErrorMessage.ConvertUserVariableToString(engine); var vQueueItemErrorCode = v_QueueItemErrorCode.ConvertUserVariableToString(engine); var client = AuthMethods.GetAuthToken(); Guid transactionKey = (Guid)vQueueItem["LockTransactionKey"]; if (transactionKey == null || transactionKey == Guid.Empty) { throw new NullReferenceException($"Transaction key {transactionKey} is invalid or not found"); } switch (v_QueueItemStatusType) { case "Successful": QueueItemMethods.CommitQueueItem(client, transactionKey); break; case "Failed - Should Retry": QueueItemMethods.RollbackQueueItem(client, transactionKey, vQueueItemErrorCode, vQueueItemErrorMessage, false); break; case "Failed - Fatal": QueueItemMethods.RollbackQueueItem(client, transactionKey, vQueueItemErrorCode, vQueueItemErrorMessage, true); break; } }
public Color GetAuthMethodColor(AuthMethods p) => AuthMethod == p ? new Color() { A = 255, R = 119, G = 119, B = 119 } // Enable : new Color() { A = 255, R = 68, G = 68, B = 68 }; // Disable
public ImapClient(string host, int port, string username, string password, bool useSsl, bool skipSslValidation, AuthMethods authmethod) { Host = host; Port = port; Username = username; Password = password; UseSsl = useSsl; SkipSslValidation = skipSslValidation; AuthMethod = authmethod; }
public override async Task RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; string vUsername; string vPassword; var environmentSettings = new EnvironmentSettings(); environmentSettings.Load(); AuthMethods authMethods = new AuthMethods(); authMethods.Initialize(environmentSettings.ServerType, environmentSettings.OrganizationName, environmentSettings.ServerUrl, environmentSettings.Username, environmentSettings.Password); if (environmentSettings.ServerType == "Local") { throw new Exception("Documents commands cannot be used with local Server"); } else { vUsername = environmentSettings.Username; vPassword = environmentSettings.Password; } Guid vHumanTaskId = (Guid)await v_TaskId.EvaluateCode(engine); bool vSavePageText = (bool)await v_SavePageText.EvaluateCode(engine); bool vSavePageImages = (bool)await v_SavePageImages.EvaluateCode(engine); string vOutputFolder = (string)await v_OutputFolder.EvaluateCode(engine); bool vAwaitCompletion = (bool)await v_AwaitCompletion.EvaluateCode(engine); int vTimeout = (int)await v_Timeout.EvaluateCode(engine); var vData = await v_OutputUserVariableName5.EvaluateCode(engine); DataTable dataDt = vData == null ? null : (DataTable)vData; var userInfo = authMethods.GetDocumentsAuthToken(vUsername, vPassword); DocumentResult docInfo = DocumentMethods.SaveDocumentResults(userInfo, vHumanTaskId, vAwaitCompletion, vSavePageImages, vSavePageText, vTimeout, vOutputFolder, dataDt); string docInfoAsJSON = docInfo.OutputAsJSON; DataTable docInfoAsDataTable = docInfo.DataAsTable; dataDt = docInfo.OutputAsTable; docInfo.Status.SetVariableValue(engine, v_OutputUserVariableName); docInfo.IsCompleted.SetVariableValue(engine, v_OutputUserVariableName1); docInfo.HasFailedOrError.SetVariableValue(engine, v_OutputUserVariableName2); docInfoAsJSON.SetVariableValue(engine, v_OutputUserVariableName3); docInfoAsDataTable.SetVariableValue(engine, v_OutputUserVariableName4); dataDt.SetVariableValue(engine, v_OutputUserVariableName5); }
public override async Task RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; string vUsername; string vPassword; var environmentSettings = new EnvironmentSettings(); environmentSettings.Load(); AuthMethods authMethods = new AuthMethods(); authMethods.Initialize(environmentSettings.ServerType, environmentSettings.OrganizationName, environmentSettings.ServerUrl, environmentSettings.Username, environmentSettings.Password); if (environmentSettings.ServerType == "Local") { throw new Exception("Documents commands cannot be used with local Server"); } else { vUsername = environmentSettings.Username; vPassword = environmentSettings.Password; } string vFileToProcess = (string)await v_FilePath.EvaluateCode(engine); string vTaskQueueName = (string)await v_QueueName.EvaluateCode(engine); string vName = (string)await v_Name.EvaluateCode(engine); string vDescription = (string)await v_Description.EvaluateCode(engine); string vCaseNumber = (string)await v_CaseNumber.EvaluateCode(engine); string vCaseType = (string)await v_CaseType.EvaluateCode(engine); string vAssignedTo = (string)await v_AssignedTo.EvaluateCode(engine); dynamic vDueOn = v_DueDate.EvaluateCode(engine); if (!string.IsNullOrEmpty(v_DueDate)) { vDueOn = (DateTime)await v_DueDate.EvaluateCode(engine); } UserInfo userInfo = authMethods.GetDocumentsAuthToken(vUsername, vPassword); var docInfo = DocumentMethods.SubmitDocument(userInfo, vFileToProcess, vTaskQueueName, vName, vDescription, vCaseType, vCaseNumber, vAssignedTo, vDueOn); Guid taskId = Guid.Parse(docInfo["TaskID"]); string status = docInfo["Status"]; taskId.SetVariableValue(engine, v_OutputUserVariableName); status.SetVariableValue(engine, v_OutputUserVariableName2); }
public override void RunCommand(object sender) { var engine = (AutomationEngineInstance)sender; var vQueueItem = (Dictionary <string, object>)v_QueueItem.ConvertUserVariableToObject(engine); var client = AuthMethods.GetAuthToken(); Guid transactionKey = (Guid)vQueueItem["LockTransactionKey"]; QueueItemMethods.ExtendQueueItem(client, transactionKey); }
private string GetPublicIP(EnvironmentSettings environmentSettings) { try { AuthMethods authMethods = new AuthMethods(); authMethods.Initialize(environmentSettings.ServerType, environmentSettings.OrganizationName, environmentSettings.ServerUrl, environmentSettings.Username, environmentSettings.Password); return(authMethods.Ping()); } catch (Exception) { return("Server is not responding"); } }
/// <inheritdoc /> /// <summary> /// Construct a sink inserting into InfluxDB with the specified details. /// </summary> /// <param name="connectionInfo">Connection information used to construct InfluxDB client.</param> /// <param name="applicationName">Application name in the InfluxDB bucket.</param> /// <param name="instanceName">Facility name in the InfluxDB bucket.</param> /// <param name="batchSizeLimit">The maximum number of events to post in a single batch.</param> /// <param name="period">The time to wait between checking for event batches.</param> /// <param name="formatProvider"></param> public InfluxDBSink(InfluxDBSinkOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } _connectionInfo = options.ConnectionInfo ?? throw new ArgumentNullException(nameof(options.ConnectionInfo)); _applicationName = options.ApplicationName ?? throw new ArgumentNullException(nameof(options.ApplicationName)); if (_connectionInfo.Uri is null) { throw new ArgumentNullException(nameof(_connectionInfo.Uri)); } if (_connectionInfo.BucketName is null) { throw new ArgumentNullException(nameof(_connectionInfo.BucketName)); } if (_connectionInfo.OrganizationId is null) { throw new ArgumentNullException(nameof(_connectionInfo.OrganizationId)); } if (string.IsNullOrWhiteSpace(_connectionInfo.Token) && string.IsNullOrWhiteSpace(_connectionInfo.AllAccessToken) && string.IsNullOrWhiteSpace(_connectionInfo.Username)) { throw new ArgumentNullException($"At least one authentication field should be provided: {nameof(_connectionInfo.Username)}/{nameof(_connectionInfo.Password)} or {nameof(_connectionInfo.Token)}({nameof(_connectionInfo.AllAccessToken)} If Buckets has to be check and created if needed)"); } if (string.IsNullOrWhiteSpace(_connectionInfo.Username)) { _authMethod = AuthMethods.Token; } else { _authMethod = AuthMethods.Credentials; } if (_authMethod == AuthMethods.Token && string.IsNullOrWhiteSpace(_connectionInfo.Token) && string.IsNullOrWhiteSpace(_connectionInfo.AllAccessToken) && string.IsNullOrWhiteSpace(_connectionInfo.Username)) { throw new ArgumentNullException(nameof(_connectionInfo.Token), $"At least one Token should be given either {nameof(_connectionInfo.Token)} if already created with write permissions or {nameof(_connectionInfo.AllAccessToken)}"); } _instanceName = options.InstanceName ?? _applicationName; _formatProvider = options.FormatProvider; _includeFullException = options.IncludeFullException ?? false; CreateBucketIfNotExists(); _influxDbClient = CreateInfluxDbClientWithWriteAccess(); }
/// <summary> /// Create a new charging session. /// </summary> public Session(CountryCode CountryCode, Party_Id PartyId, Session_Id Id, DateTime Start, Decimal kWh, CDRToken CDRToken, AuthMethods AuthMethod, Location_Id LocationId, EVSE_UId EVSEUId, Connector_Id ConnectorId, Currency Currency, SessionStatusTypes Status, DateTime?End = null, AuthorizationReference?AuthorizationReference = null, Meter_Id?MeterId = null, EnergyMeter EnergyMeter = null, IEnumerable <TransparencySoftware> TransparencySoftwares = null, IEnumerable <ChargingPeriod> ChargingPeriods = null, Price?TotalCosts = null, DateTime?LastUpdated = null) { this.CountryCode = CountryCode; this.PartyId = PartyId; this.Id = Id; this.Start = Start; this.kWh = kWh; this.CDRToken = CDRToken; this.AuthMethod = AuthMethod; this.LocationId = LocationId; this.EVSEUId = EVSEUId; this.ConnectorId = ConnectorId; this.Currency = Currency; this.Status = Status; this.End = End; this.AuthorizationReference = AuthorizationReference; this.MeterId = MeterId; this.EnergyMeter = EnergyMeter; this.TransparencySoftwares = TransparencySoftwares; this.ChargingPeriods = ChargingPeriods; this.TotalCosts = TotalCosts; this.LastUpdated = LastUpdated ?? DateTime.Now; CalcSHA256Hash(); }
public override void RunCommand(object sender) { var engine = (AutomationEngineInstance)sender; var vQueueName = v_QueueName.ConvertUserVariableToString(engine); Dictionary <string, object> queueItemDict = new Dictionary <string, object>(); var client = AuthMethods.GetAuthToken(); var settings = EnvironmentSettings.GetAgentSettings(); string agentId = settings["AgentId"]; if (string.IsNullOrEmpty(agentId)) { throw new Exception("Agent is not connected"); } Queue queue = QueueMethods.GetQueue(client, $"name eq '{vQueueName}'"); if (queue == null) { throw new Exception($"Queue with name '{vQueueName}' not found"); } var queueItem = QueueItemMethods.DequeueQueueItem(client, Guid.Parse(agentId), queue.Id); if (queueItem == null) { queueItemDict = null; queueItemDict.StoreInUserVariable(engine, v_OutputUserVariableName); return; } queueItemDict = queueItem.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public) .ToDictionary(prop => prop.Name, prop => prop.GetValue(queueItem, null)); queueItemDict = queueItemDict.Where(kvp => kvp.Key == "LockTransactionKey" || kvp.Key == "Name" || kvp.Key == "Source" || kvp.Key == "Event" || kvp.Key == "Type" || kvp.Key == "JsonType" || kvp.Key == "DataJson" || kvp.Key == "Priority" || kvp.Key == "LockedUntilUTC") .ToDictionary(i => i.Key, i => i.Value); queueItemDict.StoreInUserVariable(engine, v_OutputUserVariableName); }
public override void RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; var vQueueName = v_QueueName.ConvertUserVariableToString(engine); var vQueueItemName = v_QueueItemName.ConvertUserVariableToString(engine); var vSource = v_Source.ConvertUserVariableToString(engine); var vEvent = v_Event.ConvertUserVariableToString(engine); var vJsonType = v_JsonType.ConvertUserVariableToString(engine); var vPriority = v_Priority.ConvertUserVariableToString(engine); var vQueueItemTextValue = v_QueueItemTextValue.ConvertUserVariableToString(engine); var vAttachments = v_Attachments.ConvertUserVariableToString(engine); var client = AuthMethods.GetAuthToken(); Queue queue = QueueMethods.GetQueue(client, $"name eq '{vQueueName}'"); if (queue == null) { throw new DataException($"Queue with name '{vQueueName}' not found"); } int priority = 0; if (!string.IsNullOrEmpty(v_Priority)) { priority = int.Parse(vPriority); } QueueItemModel queueItem = new QueueItemModel() { IsLocked = false, QueueId = queue.Id, Type = v_QueueItemType, JsonType = vJsonType, DataJson = vQueueItemTextValue, Name = vQueueItemName, IsDeleted = false, Priority = priority, Source = vSource, Event = vEvent }; QueueItemMethods.EnqueueQueueItem(client, queueItem); if (!string.IsNullOrEmpty(vAttachments)) { QueueItemMethods.AttachFiles(client, queueItem.Id, vAttachments); } }
public override void RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; var vAssetName = v_AssetName.ConvertUserVariableToString(engine); var vAppendText = v_AppendText.ConvertUserVariableToString(engine); var client = AuthMethods.GetAuthToken(); var asset = AssetMethods.GetAsset(client, vAssetName, "Text"); if (asset == null) { throw new DataException($"No Asset was found for '{vAssetName}' with type 'Text'"); } AssetMethods.AppendAsset(client, asset.Id, vAppendText); }
public override void RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; var vQueueItem = (Dictionary <string, object>)v_QueueItem.ConvertUserVariableToObject(engine, nameof(v_QueueItem), this); var client = AuthMethods.GetAuthToken(); Guid transactionKey = (Guid)vQueueItem["LockTransactionKey"]; if (transactionKey == null || transactionKey == Guid.Empty) { throw new NullReferenceException($"Transaction key {transactionKey} is invalid or not found"); } QueueItemMethods.ExtendQueueItem(client, transactionKey); }
public override void RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; var vAssetName = v_AssetName.ConvertUserVariableToString(engine); var vOutputDirectoryPath = v_OutputDirectoryPath.ConvertUserVariableToString(engine); var client = AuthMethods.GetAuthToken(); var asset = AssetMethods.GetAsset(client, vAssetName, v_AssetType); if (asset == null) { throw new DataException($"No Asset was found for '{vAssetName}' with type '{v_AssetType}'"); } dynamic assetValue; switch (v_AssetType) { case "Text": assetValue = asset.TextValue; break; case "Number": assetValue = asset.NumberValue; break; case "Json": assetValue = asset.JsonValue; break; case "File": var fileID = asset.FileID; File file = FileMethods.GetFile(client, fileID); AssetMethods.DownloadFileAsset(client, asset.Id, vOutputDirectoryPath, file.Name); assetValue = string.Empty; break; default: assetValue = string.Empty; break; } if (v_AssetType != "File") { ((object)assetValue).StoreInUserVariable(engine, v_OutputUserVariableName, nameof(v_OutputUserVariableName), this); } }
public void WorkQueueItemMultipleAttachments() { _engine = new AutomationEngineInstance(null); _addQueueItem = new AddQueueItemCommand(); _workQueueItem = new WorkQueueItemCommand(); string projectDirectory = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName; string filePath = Path.Combine(projectDirectory, @"Resources\"); string fileName1 = "testFile.txt"; string fileName2 = "testFile2.txt"; string attachment1 = Path.Combine(filePath, @"Download\", fileName1); string attachment2 = Path.Combine(filePath, @"Download\", fileName2); VariableMethods.CreateTestVariable(null, _engine, "output", typeof(Dictionary <,>)); _addQueueItem.v_QueueName = "UnitTestQueue"; _addQueueItem.v_QueueItemName = "WorkQueueItemAttachmentsTest"; _addQueueItem.v_QueueItemType = "Text"; _addQueueItem.v_JsonType = "Test Type"; _addQueueItem.v_QueueItemTextValue = "Test Text"; _addQueueItem.v_Priority = "10"; _addQueueItem.v_Attachments = filePath + @"Upload\" + fileName1 + ";" + filePath + @"Upload\" + fileName2; _addQueueItem.RunCommand(_engine); _workQueueItem.v_QueueName = "UnitTestQueue"; _workQueueItem.v_OutputUserVariableName = "{output}"; _workQueueItem.v_SaveAttachments = "Yes"; _workQueueItem.v_AttachmentDirectory = filePath + @"Download\"; _workQueueItem.RunCommand(_engine); var queueItemObject = "{output}".ConvertUserVariableToObject(_engine, typeof(Dictionary <,>)); string queueItemString = JsonConvert.SerializeObject(queueItemObject); var vQueueItem = JsonConvert.DeserializeObject <QueueItemModel>(queueItemString); var client = AuthMethods.GetAuthToken(); var queueItem = QueueItemMethods.GetQueueItemByLockTransactionKey(client, vQueueItem.LockTransactionKey.ToString()); Assert.Equal("InProgress", queueItem.State); Assert.True(File.Exists(attachment1)); Assert.True(File.Exists(attachment2)); File.Delete(attachment1); File.Delete(attachment2); }
public override void RunCommand(object sender) { var engine = (AutomationEngineInstance)sender; var vAssetName = v_AssetName.ConvertUserVariableToString(engine); var vOutputDirectoryPath = v_OutputDirectoryPath.ConvertUserVariableToString(engine); var client = AuthMethods.GetAuthToken(); var asset = AssetMethods.GetAsset(client, $"name eq '{vAssetName}' and type eq '{v_AssetType}'"); if (asset == null) { throw new Exception($"No Asset was found for '{vAssetName}' with type '{v_AssetType}'"); } string assetValue = string.Empty; switch (v_AssetType) { case "Text": assetValue = asset.TextValue; break; case "Number": assetValue = asset.NumberValue.ToString(); break; case "JSON": assetValue = asset.JsonValue; break; case "File": var binaryObjectID = asset.BinaryObjectID; BinaryObject binaryObject = BinaryObjectMethods.GetBinaryObject(client, binaryObjectID); AssetMethods.DownloadFileAsset(client, asset.Id, vOutputDirectoryPath, binaryObject.Name); break; default: assetValue = string.Empty; break; } if (v_AssetType != "File") { assetValue.StoreInUserVariable(engine, v_OutputUserVariableName); } }
public override async Task RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; var vTaskId = (Guid)await v_TaskId.EvaluateCode(engine); var vAwaitCompletion = (bool)await v_AwaitCompletion.EvaluateCode(engine); string vUsername; string vPassword; var environmentSettings = new EnvironmentSettings(); environmentSettings.Load(); AuthMethods authMethods = new AuthMethods(); authMethods.Initialize(environmentSettings.ServerType, environmentSettings.OrganizationName, environmentSettings.ServerUrl, environmentSettings.Username, environmentSettings.Password); if (environmentSettings.ServerType == "Local") { throw new Exception("Documents commands cannot be used with local Server"); } else { vUsername = environmentSettings.Username; vPassword = environmentSettings.Password; } var userInfo = authMethods.GetDocumentsAuthToken(vUsername, vPassword); DocumentStatus docStatus = DocumentMethods.GetDocumentStatus(userInfo, vTaskId); if (vAwaitCompletion) { int vTimeout = (int)await v_Timeout.EvaluateCode(engine); docStatus = DocumentMethods.AwaitProcessing(userInfo, vTaskId, vTimeout); } docStatus.Status.SetVariableValue(engine, v_OutputUserVariableName); docStatus.IsDocumentCompleted.SetVariableValue(engine, v_OutputUserVariableName1); docStatus.HasError.SetVariableValue(engine, v_OutputUserVariableName2); docStatus.IsCurrentlyProcessing.SetVariableValue(engine, v_OutputUserVariableName3); docStatus.IsSuccessful.SetVariableValue(engine, v_OutputUserVariableName4); }
public override void RunCommand(object sender) { var engine = (AutomationEngineInstance)sender; var vCredentialName = v_CredentialName.ConvertUserVariableToString(engine); var client = AuthMethods.GetAuthToken(); var credential = CredentialMethods.GetCredential(client, $"name eq '{vCredentialName}'"); if (credential == null) { throw new Exception($"No Credential was found for '{vCredentialName}'"); } string username = credential.UserName; SecureString password = credential.PasswordSecret.GetSecureString(); username.StoreInUserVariable(engine, v_OutputUserVariableName); password.StoreInUserVariable(engine, v_OutputUserVariableName2); }
public override void RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; var vCredentialName = v_CredentialName.ConvertUserVariableToString(engine); var vCredentialUsername = v_CredentialUsername.ConvertUserVariableToString(engine); var vCredentialPassword = v_CredentialPassword.ConvertUserVariableToString(engine); var client = AuthMethods.GetAuthToken(); var credential = CredentialMethods.GetCredential(client, $"name eq '{vCredentialName}'"); if (credential == null) { throw new Exception($"No Credential was found for '{vCredentialName}'"); } credential.UserName = vCredentialUsername; credential.PasswordSecret = vCredentialPassword; CredentialMethods.PutCredential(client, credential); }
public static UserInfo RefreshToken(IAutomationEngineInstance engine) { var sessionVariablesDict = engine.EngineContext.SessionVariables; UserInfo userInfo = (UserInfo)sessionVariablesDict["UserInfo"]; sessionVariablesDict.Remove("UserInfo"); //use refresh token and get new auth/refresh tokens var environmentSettings = new EnvironmentSettings(); environmentSettings.Load(); AuthMethods authMethods = new AuthMethods(); authMethods.Initialize(environmentSettings.ServerType, environmentSettings.OrganizationName, environmentSettings.ServerUrl, environmentSettings.Username, environmentSettings.Password, environmentSettings.AgentId); authMethods.RefreshToken(userInfo); return(userInfo); }
public void ExtendQueueItem() { _engine = new AutomationEngineInstance(null); _addQueueItem = new AddQueueItemCommand(); _workQueueItem = new WorkQueueItemCommand(); _extendQueueItem = new ExtendQueueItemCommand(); VariableMethods.CreateTestVariable(null, _engine, "output", typeof(Dictionary <,>)); VariableMethods.CreateTestVariable(null, _engine, "vQueueItem", typeof(Dictionary <,>)); _addQueueItem.v_QueueName = "UnitTestQueue"; _addQueueItem.v_QueueItemName = "ExtendQueueItemTest"; _addQueueItem.v_QueueItemType = "Text"; _addQueueItem.v_JsonType = "Test Type"; _addQueueItem.v_QueueItemTextValue = "Test Text"; _addQueueItem.v_Priority = "10"; _addQueueItem.RunCommand(_engine); _workQueueItem.v_QueueName = "UnitTestQueue"; _workQueueItem.v_OutputUserVariableName = "{output}"; _workQueueItem.v_SaveAttachments = "No"; _workQueueItem.v_AttachmentDirectory = ""; _workQueueItem.RunCommand(_engine); var queueItemDict = (Dictionary <string, object>) "{output}".ConvertUserVariableToObject(_engine, typeof(Dictionary <,>)); var transactionKey = queueItemDict["LockTransactionKey"].ToString(); var client = AuthMethods.GetAuthToken(); var queueItem = QueueItemMethods.GetQueueItemByLockTransactionKey(client, transactionKey); _extendQueueItem.v_QueueItem = "{vQueueItem}"; queueItemDict.StoreInUserVariable(_engine, _extendQueueItem.v_QueueItem, typeof(Dictionary <,>)); _extendQueueItem.RunCommand(_engine); var extendedQueueItem = QueueItemMethods.GetQueueItemByLockTransactionKey(client, transactionKey); Assert.True(queueItem.LockedUntilUTC < extendedQueueItem.LockedUntilUTC); }
public override void RunCommand(object sender) { var engine = (AutomationEngineInstance)sender; var vAssetName = v_AssetName.ConvertUserVariableToString(engine); var vAssetFilePath = v_AssetFilePath.ConvertUserVariableToString(engine); var vAssetValue = v_AssetValue.ConvertUserVariableToString(engine); var client = AuthMethods.GetAuthToken(); var asset = AssetMethods.GetAsset(client, $"name eq '{vAssetName}' and type eq '{v_AssetType}'"); if (asset == null) { throw new Exception($"No Asset was found for '{vAssetName}' with type '{v_AssetType}'"); } switch (v_AssetType) { case "Text": asset.TextValue = vAssetValue; break; case "Number": asset.NumberValue = double.Parse(vAssetValue); break; case "JSON": asset.JsonValue = vAssetValue; break; case "File": AssetMethods.UpdateFileAsset(client, asset, vAssetFilePath); break; } if (v_AssetType != "File") { AssetMethods.PutAsset(client, asset); } }
public ImapClient(AuthMethods method = AuthMethods.Login) { AuthMethod = method; }
public ImapClient(string host, string username, string password, AuthMethods method = AuthMethods.Login, int port = 143, bool secure = false) { Connect(host, port, secure); AuthMethod = method; Login(username, password); }