protected override void Execute(NativeActivityContext context) { if (!NMHook.connected) { Result.Set(context, null); return; } var browser = Browser.Get(context); if (browser != "chrome" && browser != "ff" && browser != "edge") { browser = "chrome"; } if (browser == "edge") { Result.Set(context, NMHook.CurrentEdgeTab); } else if (browser == "ff") { Result.Set(context, NMHook.CurrentFFTab); } else { Result.Set(context, NMHook.CurrentChromeTab); } }
// Copies the specified attribute boolean value to the specified argument if present. private void ReadBoolAttribute(string attributeName, OutArgument argument) { var value = this.file[attributeName]; if (value == null) { argument.Set(this.ActivityContext, null); return; } argument.Set(this.ActivityContext, Convert.ToBoolean(value)); }
// Copies the specified attribute GUID value to the specified argument if present. private void ReadGuidAttribute(string attributeName, OutArgument argument) { var value = this.file[attributeName]; if (value == null) { argument.Set(this.ActivityContext, null); return; } argument.Set(this.ActivityContext, new System.Guid(value)); }
protected override void Execute(NativeActivityContext context) { var script = Script.Get(context); var frameid = FrameId.Get(context); var browser = Browser.Get(context); var timeout = TimeSpan.FromSeconds(3); script = Interfaces.Selector.Selector.ReplaceVariables(script, context.DataContext); if (browser != "chrome" && browser != "ff" && browser != "edge") { browser = "chrome"; } var result = NMHook.ExecuteScript(browser, frameid, -1, script, timeout); if (result == null) { result = "[]"; } var results = JsonConvert.DeserializeObject <object[]>(result.ToString()); if (results != null && results.Length > 0) { Result.Set(context, results[0]); } else { Result.Set(context, null); } Results.Set(context, results); }
void OnBookmarkCallback(NativeActivityContext context, Bookmark bookmark, object obj) { // keep bookmark, we want to support being triggerede multiple times, so bookmark needs to be keep incase workflow is restarted // context.RemoveBookmark(bookmark.Name); // var result = obj as IDetectorEvent; Event.Set(context, obj); }
protected override void Execute(NativeActivityContext context) { var script = Script.Get(context); var frameid = FrameId.Get(context); var browser = Browser.Get(context); var timeout = TimeSpan.FromSeconds(3); script = Interfaces.Selector.Selector.ReplaceVariables(script, context.DataContext); if (browser != "chrome" && browser != "ff" && browser != "edge") { browser = "chrome"; } if (!script.Contains(Environment.NewLine) && !script.Contains(";") && !script.Contains("return")) { script = "return " + script; } var result = NMHook.ExecuteScript(browser, frameid, -1, script, timeout); if (result == null) { result = "[]"; } var results = JsonConvert.DeserializeObject <object[]>(result.ToString()); Result.Set(context, results[0]); Results.Set(context, results); }
protected override void Execute(NativeActivityContext context) { base.Execute(context); var cell = Cell.Get(context); Microsoft.Office.Interop.Excel.Range range = worksheet.get_Range(cell); Formula.Set(context, range.Formula); Range.Set(context, range); if (this.ResultType == typeof(string)) { if (range.Value2 == null) { context.SetValue(Result, null); } try { if (range.Value2 != null) { context.SetValue(Result, range.Value2.ToString()); } else { context.SetValue(Result, null); } } catch (Exception) { context.SetValue(Result, null); } } else { context.SetValue(Result, (TResult)range.Value2); } }
protected override void Execute(NativeActivityContext context) { if (!NMHook.connected) { Result.Set(context, null); return; } var browser = Browser.Get(context); if (browser != "chrome" && browser != "ff" && browser != "edge") { browser = "chrome"; } if (browser == "edge") { if (Result != null && !Result.GetIsEmpty()) { Result.Set(context, NMHook.CurrentEdgeTab); } else { Results.Set(context, NMHook.tabs.Where(x => x.browser == browser).ToArray()); } } else if (browser == "ff") { if (Result != null && !Result.GetIsEmpty()) { Result.Set(context, NMHook.CurrentFFTab); } else { Results.Set(context, NMHook.tabs.Where(x => x.browser == browser).ToArray()); } } else { if (Result != null && !Result.GetIsEmpty()) { Result.Set(context, NMHook.CurrentChromeTab); } else { Results.Set(context, NMHook.tabs.Where(x => x.browser == browser).ToArray()); } } }
protected override void Execute(CodeActivityContext context) { base.Execute(context); Microsoft.Office.Interop.Excel.Range range = officewrap.application.Selection as Microsoft.Office.Interop.Excel.Range; var rowabsolute = RowAbsolute.Get(context); var columnabsolute = ColumnAbsolute.Get(context); var external = External.Get(context); if (range != null) { Range.Set(context, range.Address[rowabsolute, columnabsolute, Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1, external, null]); } else { Range.Set(context, ""); } }
// Updates and returns the version of the specified attribute. private string UpdateVersion(string attributeName, string format, OutArgument <Version> maxVersion) { var oldValue = this.file[attributeName]; if (oldValue == null || string.IsNullOrWhiteSpace(format)) { // do nothing return(oldValue); } // parse old version (handle * character) bool containsWildcard = oldValue.Contains('*'); string versionPattern = "{0}.{1}.{2}.{3}"; if (containsWildcard) { if (oldValue.Split('.').Length == 3) { oldValue = oldValue.Replace("*", "0.0"); versionPattern = "{0}.{1}.*"; } else { oldValue = oldValue.Replace("*", "0"); versionPattern = "{0}.{1}.{2}.*"; } } if (!versionParser.IsMatch(oldValue)) { throw new FormatException("Current value for attribute '" + attributeName + "' is not in a correct version format."); } var version = new Version(oldValue); // update version var tokens = format.Split('.'); if (tokens.Length != 4) { throw new FormatException("Specified value for attribute '" + attributeName + "' is not a correct version format."); } version = new Version( Convert.ToInt32(this.ReplaceTokens(tokens[0], version.Major)), Convert.ToInt32(this.ReplaceTokens(tokens[1], version.Minor)), Convert.ToInt32(this.ReplaceTokens(tokens[2], version.Build)), Convert.ToInt32(this.ReplaceTokens(tokens[3], version.Revision))); this.file[attributeName] = string.Format(versionPattern, version.Major, version.Minor, version.Build, version.Revision); if (version > maxVersion.Get(this.ActivityContext)) { maxVersion.Set(this.ActivityContext, version); } return(version.ToString()); }
protected override void AfterExecute(AsyncCodeActivityContext context, object result) { JObject res = result as JObject; Username.Set(context, res["username"].ToString()); var pass = new System.Net.NetworkCredential("", res["password"].ToString()).SecurePassword; Password.Set(context, pass); UnsecurePassword.Set(context, res["password"].ToString()); }
protected override JObject[] PostExecute(AsyncCodeActivityContext context, JObject[] result) { if (DataTable != null && DataTable.Expression != null) { var jarray = new JArray(result); DataTable dt = jarray.ToDataTable(); DataTable.Set(context, dt); } return(result); }
protected override void Execute(CodeActivityContext context) { Microsoft.Office.Interop.Outlook.Application outlookApplication = new Microsoft.Office.Interop.Outlook.Application(); Microsoft.Office.Interop.Outlook.MailItem email = (Microsoft.Office.Interop.Outlook.MailItem)outlookApplication.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); var to = To.Get(context); var cc = CC.Get(context); var bcc = BCC.Get(context); var subject = Subject.Get(context); string body = (Body != null ?Body.Get(context) : null); string htmlbody = (HTMLBody != null ? HTMLBody.Get(context) : null); if (!string.IsNullOrEmpty(htmlbody)) { body = htmlbody; } var attachments = Attachments.Get(context); var uiaction = UIAction.Get(context); email.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatRichText; email.To = to; email.Subject = subject; email.HTMLBody = body; email.CC = cc; email.BCC = bcc; if (attachments != null && attachments.Count() > 0) { foreach (var attachment in attachments) { if (!string.IsNullOrEmpty(attachment)) { email.Attachments.Add(attachment, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, 100000, Type.Missing); } } } if (uiaction == "Show") { email.Display(true); } //else if(uiaction == "SendVisable") //{ // email.Display(true); // email.Send(); //} else { email.Send(); } if (EMail != null) { EMail.Set(context, new email(email)); } }
// Copies the specified attribute string value to the specified argument if present. private void ReadStringAttribute(string attributeName, OutArgument argument) { var value = this.file[attributeName]; if (value == null) { // do nothing return; } argument.Set(this.ActivityContext, value); }
private void OnUpdateOrderTotal(NativeActivityContext context, Bookmark bookmark, object value) { if (value is Decimal) { OrderTotal.Set(context, OrderTotal.Get(context) + (Decimal)value); Console.WriteLine( "OrderScope.OnUpdateOrderTotal Value: {0}, Total: {1}", (Decimal)value, OrderTotal.Get(context)); } }
protected override void Execute(CodeActivityContext context) { Message inMessage = this.Message.Get(context); if (inMessage == null) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR.NullReplyMessageContractMismatch)); } if (inMessage.IsFault) { FaultConverter faultConverter = FaultConverter.GetDefaultFaultConverter(inMessage.Version); Exception exception = DeserializeFault(inMessage, faultConverter); // We simply throw the exception throw FxTrace.Exception.AsError(exception); } else { object[] outObjects; if (this.parameters != null) { outObjects = new object[this.parameters.Count]; } else { outObjects = Constants.EmptyArray; } object returnValue = this.Formatter.DeserializeReply(inMessage, outObjects); if (this.Result != null) { this.Result.Set(context, returnValue); } if (parameters != null) { for (int i = 0; i < this.parameters.Count; i++) { OutArgument outArgument = this.parameters[i]; Fx.Assert(outArgument != null, "Parameter cannot be null"); object obj = outObjects[i]; if (obj == null) { obj = ProxyOperationRuntime.GetDefaultParameterValue(outArgument.ArgumentType); } outArgument.Set(context, obj); } } } }
protected override void Execute(CodeActivityContext context) { var el = Element.Get(context); // if (el == null) throw new ArgumentException("element cannot be null"); var x = OffsetX; var y = OffsetY; if (el != null) { x += el.Rectangle.X; y += el.Rectangle.Y; } Result.Set(context, GetPixelColor(x, y)); }
protected override void Execute(NativeActivityContext context) { bool killall = KillAll.Get(context); bool killself = KillSelf.Get(context); string WorkflowInstanceId = context.WorkflowInstanceId.ToString(); string workflowid = workflow.Get(context); if (killall) { workflowid = ""; } if (string.IsNullOrEmpty(workflowid) && !killall) { throw new Exception("Kill all not enabled and no workflow selected"); } int result = 0; try { var Instance = WorkflowInstance.Instances.Where(x => x.InstanceId == context.WorkflowInstanceId.ToString()).FirstOrDefault(); foreach (var i in global.OpenRPAClient.WorkflowInstances.ToList()) { if (!killself && i.InstanceId == WorkflowInstanceId) { continue; } if (!i.isCompleted) { if (!string.IsNullOrEmpty(workflowid)) { if (i.Workflow != null && i.Workflow._id == workflowid || i.Workflow.RelativeFilename == workflowid || i.Workflow.ProjectAndName == workflowid) { i.Abort("Killed by StopOpenRPA command from " + Instance.Workflow.name); result++; } } else { i.Abort("Killed StopOpenRPA command from " + Instance.Workflow.name); result++; } } } Result.Set(context, result); } catch (Exception ex) { Log.Error(ex.ToString()); throw; } }
protected override void Execute(CodeActivityContext context) { string systemname = SystemName.Get(context); string path = Path.Get(context); string actionname = ActionName.Get(context); var parameters = Parameters.Get(context); object[] _parameters = null; if (!string.IsNullOrEmpty(parameters)) { _parameters = JsonConvert.DeserializeObject <object[]>(parameters); } var result = SAPhook.Instance.InvokeMethod(systemname, path, actionname, _parameters, TimeSpan.FromSeconds(PluginConfig.bridge_timeout_seconds)); try { if (result == null) { Result.Set(context, null); } else { var res = result as string; if (res != null) { Result.Set(context, result); } else { Result.Set(context, result.ToString()); } } } catch (Exception) { Result.Set(context, result.ToString()); } }
protected override void Execute(NativeActivityContext context) { string WorkflowInstanceId = context.WorkflowInstanceId.ToString(); if (Result != null && !Result.GetIsEmpty()) { var i = WorkflowInstance.Instances.Where(x => x.InstanceId == WorkflowInstanceId).FirstOrDefault(); Result.Set(context, i); } else { Results.Set(context, WorkflowInstance.Instances.ToArray()); } }
protected override void Execute(NativeActivityContext context) { var script = Script.Get(context); var frameid = FrameId.Get(context); var browser = Browser.Get(context); var timeout = TimeSpan.FromSeconds(3); script = Interfaces.Selector.Selector.ReplaceVariables(script, context.DataContext); if (browser != "chrome" && browser != "ff" && browser != "edge") { browser = "chrome"; } var result = NMHook.ExecuteScript(browser, frameid, -1, script, timeout); Result.Set(context, result); }
protected override void Execute(CodeActivityContext context) { string systemname = SystemName.Get(context); string path = Path.Get(context); string actionname = ActionName.Get(context); object[] _parameters = null; var data = new SAPInvokeMethod(systemname, path, actionname, _parameters); var message = new SAPEvent("getproperty"); message.Set(data); var reply = SAPhook.Instance.SendMessage(message, TimeSpan.FromSeconds(PluginConfig.bridge_timeout_seconds)); data = reply.Get <SAPInvokeMethod>(); Result.Set(context, data.Result); }
protected override void Execute(NativeActivityContext context) { System.ServiceModel.Channels.Message message = null; try { object[] emptyArray; message = this.Message.Get(context); if ((this.parameters == null) || (this.parameters.Count == 0)) { emptyArray = System.ServiceModel.Activities.Constants.EmptyArray; } else { emptyArray = new object[this.parameters.Count]; } this.Formatter.DeserializeRequest(message, emptyArray); if (this.parameters != null) { for (int i = 0; i < this.parameters.Count; i++) { OutArgument argument = this.parameters[i]; object defaultParameterValue = emptyArray[i]; if (defaultParameterValue == null) { defaultParameterValue = ProxyOperationRuntime.GetDefaultParameterValue(argument.ArgumentType); } argument.Set(context, defaultParameterValue); } } } finally { if (this.CloseMessage && (message != null)) { message.Close(); } this.Message.Set(context, null); System.Activities.NoPersistHandle handle = (this.NoPersistHandle == null) ? null : this.NoPersistHandle.Get(context); if (handle != null) { handle.Exit(context); } } }
protected void SetValue(Context context, OutArgument <EntityReference> outArgument, string entityName) { var guidString = GuidString.Get(context); Guid guid; try { guid = Guid.Parse(guidString); } catch (Exception ex) { throw new InvalidWorkflowExecutionException($"Значение \"{guidString}\" не может быть приведено к типу GUID. ", ex); } if (guid == Guid.Empty) { throw new InvalidWorkflowExecutionException($"Значение \"{guidString}\" не может быть пустым GUID."); } outArgument.Set(context, new EntityReference(entityName, guid)); }
protected override void Execute(CodeActivityContext context) { var vars = context.DataContext.GetProperties(); Connection connection = null; foreach (dynamic v in vars) { if (v.DisplayName == "conn") { connection = v.GetValue(context.DataContext); } } var tablename = TableName.Get(context); var datatable = DataTable.Get(context); var result = connection.UpdateDataTable(tablename, datatable); Result.Set(context, result); }
protected override void Execute(CodeActivityContext context) { object[] emptyArray; System.ServiceModel.Channels.Message inMessage = this.Message.Get(context); if (inMessage == null) { throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activities.SR.NullReplyMessageContractMismatch)); } if (inMessage.IsFault) { FaultConverter defaultFaultConverter = FaultConverter.GetDefaultFaultConverter(inMessage.Version); Exception exception = this.DeserializeFault(inMessage, defaultFaultConverter); throw System.ServiceModel.Activities.FxTrace.Exception.AsError(exception); } if (this.parameters != null) { emptyArray = new object[this.parameters.Count]; } else { emptyArray = System.ServiceModel.Activities.Constants.EmptyArray; } object obj2 = this.Formatter.DeserializeReply(inMessage, emptyArray); if (this.Result != null) { this.Result.Set(context, obj2); } if (this.parameters != null) { for (int i = 0; i < this.parameters.Count; i++) { OutArgument argument = this.parameters[i]; object defaultParameterValue = emptyArray[i]; if (defaultParameterValue == null) { defaultParameterValue = ProxyOperationRuntime.GetDefaultParameterValue(argument.ArgumentType); } argument.Set(context, defaultParameterValue); } } }
protected override void Execute(CodeActivityContext context) { int row = Row.Get(context); int column = Column.Get(context); int length = Length.Get(context); var timeout = Timeout.Get(context); if (Timeout == null || Timeout.Expression == null) { timeout = TimeSpan.FromSeconds(3); } var vars = context.DataContext.GetProperties(); Interfaces.VT.ITerminalSession session = null; foreach (dynamic v in vars) { var val = v.GetValue(context.DataContext); if (val is Interfaces.VT.ITerminalSession _session) { session = val; } } if (session == null) { throw new ArgumentException("Failed locating terminal session"); } if (session.Terminal == null) { throw new ArgumentException("Terminal Sessoin not initialized"); } if (!session.Terminal.IsConnected) { throw new ArgumentException("Terminal Sessoin not connected"); } if (WaitForKeyboard.Get(context)) { session.Terminal.WaitForKeyboardUnlocked(timeout); } var result = session.Terminal.GetTextAt(column, row, length); Result.Set(context, result); }
protected override void Execute(NativeActivityContext context) { //if (Record.Instance.IsRecording) Record.Instance.StopRecording(); //Filename.Set(context, Record.Instance.lastFileName); var p = Plugins.runPlugins.Where(x => x.Name == RunPlugin.PluginName).FirstOrDefault() as RunPlugin; if (p == null) { return; } var instance = p.client.GetWorkflowInstanceByInstanceId(context.WorkflowInstanceId.ToString()); if (instance == null) { return; } var r = p.stopRecording(instance); Filename.Set(context, r.lastFileName); }
// Updates and returns the version of the specified attribute. private string UpdateVersion(string attributeName, string format, OutArgument <Version> maxVersion) { var oldValue = this.file[attributeName]; if (oldValue == null || string.IsNullOrWhiteSpace(format)) { // do nothing return(string.Empty); } // parse old version if (!versionParser.IsMatch(oldValue)) { throw new FormatException("Current value for attribute '" + attributeName + "' is not in a correct version format."); } var version = new Version(oldValue); // update version var tokens = format.Split('.'); if (tokens.Length != 4) { throw new FormatException("Specified value for attribute '" + attributeName + "' is not a correct version format."); } version = new Version( Convert.ToInt32(this.ReplaceTokens(tokens[0], version.Major)), Convert.ToInt32(this.ReplaceTokens(tokens[1], version.Minor)), Convert.ToInt32(this.ReplaceTokens(tokens[2], version.Build)), Convert.ToInt32(this.ReplaceTokens(tokens[3], version.Revision))); this.file[attributeName] = version.ToString(); if (version > maxVersion.Get(this.ActivityContext)) { maxVersion.Set(this.ActivityContext, version); } return(version.ToString()); }
void BookmarkCallback(NativeActivityContext context, Bookmark bookmark, object bookmarkData) { int localGuess = (int)bookmarkData, localTarget = Target.Get(context); Guess.Set(context, localGuess); Turns.Set(context, Turns.Get(context) + 1); if (localGuess != localTarget) { if (localGuess < localTarget) { Console.WriteLine("Your guess is too low."); } else { Console.WriteLine("Your guess is too high."); } } else { context.RemoveBookmark(bookmark.Name); } }