protected override void Execute(CodeActivityContext context) { SshClient sshClient = null; if (SSHClient.Expression == null) { var sshClientArgument = context.DataContext.GetProperties()["SSHClient"]; sshClient = sshClientArgument.GetValue(context.DataContext) as SshClient; if (sshClient == null) { throw (new ArgumentException("SSHClient was not provided and cannot be retrieved from the container.")); } } else { sshClient = SSHClient.Get(context); } var sshCommand = sshClient.CreateCommand(Command.Get(context)); sshCommand.CommandTimeout = Timeout.Get(context); sshCommand.Execute(); ExitStatus.Set(context, sshCommand.ExitStatus); Result.Set(context, sshCommand.Result); Error.Set(context, sshCommand.Error); }
protected override void Execute(NativeActivityContext context) { var twilio = context.GetExtension <ITwilioContext>(); var timeout = Timeout.Get(context); var finishOnKey = FinishOnKey.Get(context); var numDigits = NumDigits.Get(context); var finishUrl = twilio.ResolveBookmarkUrl(context.CreateTwilioBookmark(OnFinish)); // append gather element var element = new XElement("Gather", new XAttribute("action", finishUrl), timeout != null ? new XAttribute("timeout", ((TimeSpan)timeout).TotalSeconds) : null, finishOnKey != null ? new XAttribute("finishOnKey", finishOnKey) : null, numDigits != null ? new XAttribute("numDigits", numDigits) : null); // write gather element GetElement(context).Add( element, new XElement("Redirect", finishUrl)); if (Body != null) { SetElement(context, element); context.ScheduleActivity(Body); } }
protected override void SafeExecute(CodeActivityContext context) { // Create URL string bearer = Bearer.Get(context); var queryText = GetQuery(context); var query = new PipefyQuery(queryText, bearer); int timeout = Timeout.Get(context); query.SetTimeout(timeout); string result = query.Execute(); CheckStatusCode(query.StatusCode); JObject json = PipefyQuery.ParseJson(result); ParseResult(context, json["data"] as JObject); // Upload File UploadFile(fileInfo); var resultUrl = new Uri(amazonUrl); FileUrl.Set(context, resultUrl.LocalPath.TrimStart('\\', '/')); }
protected override void Execute(CodeActivityContext context) { var timeout = Timeout.Get(context); if (Timeout == null || Timeout.Expression == null) { timeout = TimeSpan.FromSeconds(10); } var key = Key.Get(context); var fileurl = Fileurl.Get(context); var desiredstatus = Status.Get(context).ToLower(); string status = ""; var sw = new Stopwatch(); sw.Start(); do { var res = SimpleRequests.GET(fileurl, key); var o = JObject.Parse(res); status = o["status"].ToString(); if (status != desiredstatus) { System.Threading.Thread.Sleep(1000); } } while (status != desiredstatus && sw.Elapsed < timeout); context.SetValue(Result, status); }
protected override void Execute(NativeActivityContext context) { var twilio = context.GetExtension <ITwilioContext>(); var timeout = Timeout.Get(context); var finishOnKey = FinishOnKey.Get(context); var maxLength = MaxLength.Get(context); var transcribe = Transcribe.Get(context); var playBeep = PlayBeep.Get(context); var actionUrl = twilio.ResolveBookmarkUrl(context.CreateTwilioBookmark(OnAction)); // append record element var element = new XElement("Record", new XAttribute("action", actionUrl), timeout != null ? new XAttribute("timeout", ((TimeSpan)timeout).TotalSeconds) : null, finishOnKey != null ? new XAttribute("finishOnKey", finishOnKey) : null, maxLength != null ? new XAttribute("maxLength", ((TimeSpan)maxLength).TotalSeconds) : null, transcribe != null ? new XAttribute("transcribe", (bool)transcribe ? "true" : "false") : null, playBeep != null ? new XAttribute("playBeep", (bool)playBeep ? "true" : "false") : null); // write dial element and catch redirect GetElement(context).Add( element, new XElement("Redirect", actionUrl)); }
protected override void Execute(CodeActivityContext context) { try { Int32 _timeout = Timeout.Get(context); string data = ""; Thread.Sleep(_timeout); latch = new CountdownEvent(1); Thread td = new Thread(() => { System.Windows.Forms.IDataObject clipBoardBefore = System.Windows.Forms.Clipboard.GetDataObject(); if (clipBoardBefore.GetDataPresent(System.Windows.DataFormats.Text)) { data = (string)clipBoardBefore.GetData(System.Windows.DataFormats.Text); } refreshData(latch); }); td.TrySetApartmentState(ApartmentState.STA); td.IsBackground = true; td.Start(); latch.Wait(); Result.Set(context, data); } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "有一个错误产生", e.Message); if (ContinueOnError.Get(context)) { } else { throw; } } }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (ProcessId.Expression != null) { targetCommand.AddParameter("Id", ProcessId.Get(context)); } if (Name.Expression != null) { targetCommand.AddParameter("Name", Name.Get(context)); } if (Timeout.Expression != null) { targetCommand.AddParameter("Timeout", Timeout.Get(context)); } if (InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
protected override void Execute(NativeActivityContext context) { try { string _arguments = Arguments.Get(context); string _fileName = ProcessPath.Get(context); string _workingDirectory = WorkingDirectory.Get(context); Int32 _timeout = Timeout.Get(context); Process p = new System.Diagnostics.Process(); if (_arguments != null) { p.StartInfo.Arguments = _arguments; } if (_workingDirectory != null) { p.StartInfo.WorkingDirectory = _workingDirectory; } p.StartInfo.UseShellExecute = false; p.StartInfo.FileName = _fileName; p.Start(); Thread.Sleep(_timeout); context.ScheduleAction(Body, "", OnCompleted, OnFaulted); } catch (Exception e) { if (ContinueOnError.Get(context)) { } else { throw new NotImplementedException(e.Message); } } }
protected override void StartLoop(NativeActivityContext context) { if (Image == null) { new ArgumentException("Image is null"); } //var timeout = TimeSpan.FromSeconds(3); var timeout = Timeout.Get(context); if (Timeout == null || Timeout.Expression == null) { timeout = TimeSpan.FromSeconds(3); } var maxresults = MaxResults.Get(context); var processname = Processname.Get(context); var comparegray = CompareGray.Get(context); var threshold = Threshold.Get(context); var minresults = MinResults.Get(context); var from = From.Get(context); var limit = Limit.Get(context); if (maxresults < 1) { maxresults = 1; } if (threshold < 0.1) { threshold = 0.1; } if (threshold > 1) { threshold = 1; } ImageElement[] elements = { }; var sw = new Stopwatch(); sw.Start(); do { elements = getBatch(minresults, maxresults, threshold, processname, timeout, comparegray, limit).ToArray(); } while (elements.Count() == 0 && sw.Elapsed < timeout); // Log.Debug(string.Format("OpenRPA.Image::GetElement::found {1} elements in {0:mm\\:ss\\.fff}", sw.Elapsed, elements.Count())); context.SetValue(Elements, elements); IEnumerator <ImageElement> _enum = elements.ToList().GetEnumerator(); context.SetValue(_elements, _enum); bool more = _enum.MoveNext(); if (more) { IncIndex(context); SetTotal(context, elements.Length); context.ScheduleAction(Body, _enum.Current, OnBodyComplete); } else if (elements.Count() < minresults) { throw new Interfaces.ElementNotFoundException("Failed locating item"); } }
protected override void Execute(NativeActivityContext context) { UIElement[] elements = null; var selector = Selector.Get(context); var sel = new WindowsSelector(selector); var timeout = Timeout.Get(context); var maxresults = MaxResults.Get(context); var minresults = MinResults.Get(context); if (maxresults < 1) { maxresults = 1; } var sw = new Stopwatch(); var from = From.Get(context); sw.Start(); do { elements = OpenRPA.AutomationHelper.RunSTAThread <UIElement[]>(() => { try { return(WindowsSelector.GetElementsWithuiSelector(sel, from, maxresults)); } catch (System.Threading.ThreadAbortException) { } catch (Exception ex) { Log.Error(ex, ""); } return(new UIElement[] { }); }, TimeSpan.FromMilliseconds(250)).Result; if (elements == null) { elements = new UIElement[] { }; } } while (elements != null && elements.Length == 0 && sw.Elapsed < timeout); if (elements.Length > 0) { // Get them again, we need the COM objects to be loaded in the UI thread elements = WindowsSelector.GetElementsWithuiSelector(sel, from, maxresults); } context.SetValue(Elements, elements); if (elements.Count() < minresults) { throw new ElementNotFoundException("Failed locating " + minresults + " item(s)"); } IEnumerator <UIElement> _enum = elements.ToList().GetEnumerator(); context.SetValue(_elements, _enum); bool more = _enum.MoveNext(); if (more) { context.ScheduleAction <UIElement>(Body, _enum.Current, OnBodyComplete); } }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (Job.Expression != null) { targetCommand.AddParameter("Job", Job.Get(context)); } if (Any.Expression != null) { targetCommand.AddParameter("Any", Any.Get(context)); } if (Timeout.Expression != null) { targetCommand.AddParameter("Timeout", Timeout.Get(context)); } if (Force.Expression != null) { targetCommand.AddParameter("Force", Force.Get(context)); } if (Name.Expression != null) { targetCommand.AddParameter("Name", Name.Get(context)); } if (InstanceId.Expression != null) { targetCommand.AddParameter("InstanceId", InstanceId.Get(context)); } if (JobId.Expression != null) { targetCommand.AddParameter("Id", JobId.Get(context)); } if (State.Expression != null) { targetCommand.AddParameter("State", State.Get(context)); } if (Filter.Expression != null) { targetCommand.AddParameter("Filter", Filter.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
protected override async void Execute(NativeActivityContext context) { bool in_continueonerror = ContinueOnError.Get(context); try { CancellationToken cancellationToken = default; var timeout = Timeout.Get(context); int tableNumber = TableNumber.Get(context); var task = GetHtmlMailBody(context); string htmlstring = task.Result; var out_NumberOfTables = NumberOfMailTables(htmlstring); int NumberOfTables = out_NumberOfTables.Result; if (NumberOfTables == 0) { throw new NullReferenceException("No table in mail Body"); } ; if (tableNumber - 1 > NumberOfTables) { throw new Exception("Total Number of tables in mail body is " + NumberOfTables.ToString() + " please enter the TableNumber equal or less then " + NumberOfTables.ToString()); } else { var result_datatables = GetDatatable(htmlstring); DataTable[] out_dataTables = result_datatables.Result; if (await Task.WhenAny(task, Task.Delay(timeout, cancellationToken)) != task) { throw new TimeoutException(); } ; if (tableNumber == 0) { Datatable.Set(context, out_dataTables[tableNumber]); } else { Datatable.Set(context, out_dataTables[tableNumber - 1]); } } } catch { if (in_continueonerror == false) { } } }
protected override void Execute(NativeActivityContext context) { var connectionstring = ConnectionString.Get(context); var timeout = Timeout.Get(context); Connection connection = new Connection(connectionstring); connection.Open(); context.SetValue(Connection, connection); context.ScheduleAction(Body, connection, OnBodyComplete); }
protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken token) { var dir = DirectoryPath.Get(context); var time = Timeout.Get(context); var searchPattern = SearchPattern.Get(context) ?? "*.*"; var afterDate = CalculateDate(dir); var filePath = await ExecuteWithTimeoutAsync(context, token, ExecuteMainAsync(dir, searchPattern, afterDate, token), time).ConfigureAwait(false); return(ctx => Result.Set(ctx, filePath != null ? new FileInfo(filePath) : null)); }
protected override void Execute(NativeActivityContext context) { var selector = Selector.Get(context); selector = OpenRPA.Interfaces.Selector.Selector.ReplaceVariables(selector, context.DataContext); var sel = new IESelector(selector); var timeout = Timeout.Get(context); var from = From.Get(context); var maxresults = MaxResults.Get(context); if (maxresults < 1) { maxresults = 1; } IEElement[] elements = { }; if (WaitForReady.Get(context)) { var browser = Browser.GetBrowser(); MSHTML.HTMLDocument doc = browser.Document; var sw2 = new Stopwatch(); sw2.Start(); while (sw2.Elapsed < timeout && doc.readyState != "complete" && doc.readyState != "interactive") { // Log.Debug("pending complete, readyState: " + doc.readyState); System.Threading.Thread.Sleep(100); } } var sw = new Stopwatch(); sw.Start(); do { elements = IESelector.GetElementsWithuiSelector(sel, from); } while (elements.Count() == 0 && sw.Elapsed < timeout); if (elements.Count() > maxresults) { elements = elements.Take(maxresults).ToArray(); } context.SetValue(Elements, elements); IEnumerator <IEElement> _enum = elements.ToList().GetEnumerator(); context.SetValue(_elements, _enum); bool more = _enum.MoveNext(); if (more) { context.ScheduleAction(Body, _enum.Current, OnBodyComplete); } else { throw new Interfaces.ElementNotFoundException("Failed locating item"); } }
protected override void Execute(CodeActivityContext context) { var selectorstring = Selector.Get(context); var selector = new Interfaces.Selector.Selector(selectorstring); var pluginname = selector.First().Selector; var Plugin = Plugins.recordPlugins.Where(x => x.Name == pluginname).First(); var timeout = Timeout.Get(context); var force = Force.Get(context); Plugin.CloseBySelector(selector, timeout, force); }
protected override void StartLoop(NativeActivityContext context) { var dataprovider = DataProvider.Get(context); var datasource = DataSource.Get(context); var connectionstring = ConnectionString.Get(context); var timeout = Timeout.Get(context); Connection connection = new Connection(dataprovider, datasource, connectionstring); connection.Open(); context.SetValue(Connection, connection); context.ScheduleAction(Body, connection, OnBodyComplete); }
protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken token) { var path = FilePath.Get(context); var time = Timeout.Get(context); await ExecuteWithTimeoutAsync(context, token, ExecuteMainAsync(token, path), time, defaultHandler => { throw new TimeoutException("The operation has timed-out.", _fileException); }).ConfigureAwait(false); return(ctx => Result.Set(ctx, new FileInfo(path))); }
protected override void StartLoop(NativeActivityContext context) { var SelectorString = Selector.Get(context); SelectorString = OpenRPA.Interfaces.Selector.Selector.ReplaceVariables(SelectorString, context.DataContext); var sel = new SAPSelector(SelectorString); var timeout = Timeout.Get(context); var maxresults = MaxResults.Get(context); var minresults = MinResults.Get(context); var flatternguitree = FlatternGuiTree.Get(context); //var from = From.Get(context); SAPElement from = null; if (maxresults < 1) { maxresults = 1; } SAPElement[] elements = { }; var sw = new Stopwatch(); sw.Start(); do { var selector = new SAPSelector(SelectorString); elements = SAPSelector.GetElementsWithuiSelector(selector, from, 0, maxresults, flatternguitree); } while (elements.Count() == 0 && sw.Elapsed < timeout); Log.Debug(string.Format("OpenRPA.SAP::GetElement::found {1} elements in {0:mm\\:ss\\.fff}", sw.Elapsed, elements.Count())); if (elements.Count() > maxresults) { elements = elements.Take(maxresults).ToArray(); } if (elements.Count() < minresults) { Log.Selector(string.Format("Windows.GetElement::Failed locating " + minresults + " item(s) {0:mm\\:ss\\.fff}", sw.Elapsed)); throw new ElementNotFoundException("Failed locating " + minresults + " item(s)"); } context.SetValue(Elements, elements); IEnumerator <SAPElement> _enum = elements.ToList().GetEnumerator(); context.SetValue(_elements, _enum); bool more = _enum.MoveNext(); if (more) { IncIndex(context); SetTotal(context, elements.Length); context.ScheduleAction(Body, _enum.Current, OnBodyComplete); } }
protected override void StartLoop(NativeActivityContext context) { Interfaces.VT.ITerminalSession session = null; var timeout = Timeout.Get(context); if (Timeout == null || Timeout.Expression == null) { timeout = TimeSpan.FromSeconds(3); } string WorkflowInstanceId = context.WorkflowInstanceId.ToString(); GenericTools.RunUI(() => { // termOpen3270Config Config = new termOpen3270Config(); Config.Hostname = Hostname.Get(context); Config.TermType = TermType.Get(context); Config.Port = Port.Get(context); session = RunPlugin.GetRecorderWindow(Config); if (string.IsNullOrEmpty(session.WorkflowInstanceId)) { session.WorkflowInstanceId = WorkflowInstanceId; } context.SetValue(_elements, session); if (!HideUI.Get(context)) { session.Show(); } if (session.Terminal == null || !session.Terminal.IsConnected) { session.Connect(); } }); var sw = new Stopwatch(); sw.Start(); while (!session.Terminal.IsConnected && sw.Elapsed < timeout) { System.Threading.Thread.Sleep(50); } Log.Output(string.Format("Connected to {0} in {1:mm\\:ss\\.fff}", session.Config.Hostname, sw.Elapsed)); if (!session.Terminal.IsConnected) { throw new Exception("Timeout connecting to " + Hostname.Get(context) + ":" + Port.Get(context)); } session.Refresh(); context.ScheduleAction(Body, session, OnBodyComplete); }
protected override void StartLoop(NativeActivityContext context) { string text = Text.Get(context); var timeout = Timeout.Get(context); var _throw = Throw.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"); } var sw = new Stopwatch(); sw.Start(); var result = session.Terminal.WaitForText(text, timeout); if (result && Body != null) { context.ScheduleAction(Body, result, OnBodyComplete); } else if (_throw) { throw new ArgumentException("Timeout waiting for text"); } }
protected override void Execute(CodeActivityContext context) { string key = Key.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"); } session.Refresh(); if (WaitForKeyboard.Get(context)) { session.Terminal.WaitForKeyboardUnlocked(timeout); } System.Windows.Input.Key _key; if (Enum.TryParse(key, true, out _key)) { session.Terminal.SendKey(_key); if (WaitForKeyboard.Get(context)) { session.Terminal.WaitForKeyboardUnlocked(timeout); } } }
protected override void StartLoop(NativeActivityContext context) { var selectorstring = Selector.Get(context); selectorstring = OpenRPA.Interfaces.Selector.Selector.ReplaceVariables(selectorstring, context.DataContext); var selector = new Interfaces.Selector.Selector(selectorstring); var checkrunning = CheckRunning.Get(context); checkrunning = true; var pluginname = selector.First().Selector; var Plugin = Plugins.recordPlugins.Where(x => x.Name == pluginname).First(); var timeout = Timeout.Get(context); var element = Plugin.LaunchBySelector(selector, checkrunning, timeout); Result.Set(context, element); _element.Set(context, element); if (element != null && element is UIElement ui && Body == null) { //var window = ((UIElement)element).GetWindow(); var x = X.Get(context); var y = Y.Get(context); var width = Width.Get(context); var height = Height.Get(context); var animatemove = AnimateMove.Get(context); if ((width == 0 && height == 0) || (x == 0 && y == 0)) { } else { if (animatemove) { ui.MoveWindowTo(x, y, width, height); } if (!animatemove) { ui.SetWindowSize(width, height); ui.SetWindowPosition(x, y); } } } if (element != null && Body != null) { IncIndex(context); SetTotal(context, 1); context.ScheduleAction(Body, element, OnBodyComplete); } }
protected override void Execute(CodeActivityContext context) { var selectorstring = Selector.Get(context); selectorstring = OpenRPA.Interfaces.Selector.Selector.ReplaceVariables(selectorstring, context.DataContext); var selector = new Interfaces.Selector.Selector(selectorstring); var pluginname = selector.First().Selector; var Plugin = Plugins.recordPlugins.Where(x => x.Name == pluginname).First(); var timeout = Timeout.Get(context); if (Timeout == null || Timeout.Expression == null) { timeout = TimeSpan.FromSeconds(3); } var force = Force.Get(context); Plugin.CloseBySelector(selector, timeout, force); }
protected override void Execute(CodeActivityContext context) { AndroidDriver <AndroidElement> driver; // Inherit driver from scope activity OR from input (if out of context) try { driver = context.DataContext.GetProperties()["Driver"].GetValue(context.DataContext) as AndroidDriver <AndroidElement>; } catch { driver = Driver.Get(context); } int timeout = Timeout.Get(context); driver.BackgroundApp(timeout); }
protected override void Execute(NativeActivityContext context) { var selector = Selector.Get(context); selector = OpenRPA.Interfaces.Selector.Selector.ReplaceVariables(selector, context.DataContext); var sel = new NMSelector(selector); var timeout = Timeout.Get(context); var from = From.Get(context); var maxresults = MaxResults.Get(context); var minresults = MinResults.Get(context); if (maxresults < 1) { maxresults = 1; } NMElement[] elements = { }; var sw = new Stopwatch(); sw.Start(); do { elements = NMSelector.GetElementsWithuiSelector(sel, from, maxresults); } while (elements.Count() == 0 && sw.Elapsed < timeout); if (elements.Count() > maxresults) { elements = elements.Take(maxresults).ToArray(); } context.SetValue(Elements, elements); IEnumerator <NMElement> _enum = elements.ToList().GetEnumerator(); bool more = _enum.MoveNext(); if (more) { if (elements.Count() > 1) { context.SetValue(_elements, _enum); } context.ScheduleAction(Body, _enum.Current, OnBodyComplete); } else if (elements.Length < minresults) { throw new Interfaces.ElementNotFoundException("Failed locating " + minresults + " item"); } }
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); }
/// <summary> /// Only the main part of the execution. Will be run inside of a try / catch statement /// </summary> protected virtual void SafeExecute(CodeActivityContext context) { string bearer = Bearer.Get(context); var queryText = GetQuery(context); var query = new PipefyQuery(queryText, bearer); int timeout = Timeout.Get(context); if (timeout > 100) { query.SetTimeout(timeout); } string result = query.Execute(); CheckStatusCode(query.StatusCode); JObject json = PipefyQuery.ParseJson(result); ParseResult(context, json["data"] as JObject); }
/// <summary> /// Runs the main logic of the activity. Has access to the context, /// which holds the values of properties for this activity and those from the parent scope. /// </summary> /// <param name="context"></param> /// <param name="cancellationToken"></param> /// <returns></returns> protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken) { //var property = context.DataContext.GetProperties()[ParentScope.ApplicationTag]; //var app = property.GetValue(context.DataContext) as Application; if (ShowBalloonMessage.Get(context) == true) { System.Windows.Forms.NotifyIcon notifyIcon1 = new System.Windows.Forms.NotifyIcon(); notifyIcon1.Icon = SystemIcons.Exclamation; notifyIcon1.BalloonTipTitle = Title.Get(context); notifyIcon1.BalloonTipText = Message.Get(context); notifyIcon1.BalloonTipIcon = IconType.Get(context); notifyIcon1.Visible = true; notifyIcon1.ShowBalloonTip(Timeout.Get(context)); } return(ctx => { Success.Set(ctx, true); }); }
protected override void Execute(NativeActivityContext context) { var twilio = context.GetExtension <ITwilioContext>(); var timeout = Timeout.Get(context); var hangupOnStar = HangupOnStar.Get(context); var timeLimit = TimeLimit.Get(context); var callerId = CallerId.Get(context); var record = Record.Get(context); // dial completion var finishUrl = twilio.ResolveBookmarkUrl(context.CreateTwilioBookmark(OnFinish)); // dial element var element = new XElement("Dial", new XAttribute("action", finishUrl), timeout != null ? new XAttribute("timeout", ((TimeSpan)timeout).TotalSeconds) : null, hangupOnStar != null ? new XAttribute("hangupOnStar", (bool)hangupOnStar ? "true" : "false") : null, timeLimit != null ? new XAttribute("timeLimit", ((TimeSpan)timeLimit).TotalSeconds) : null, callerId != null ? new XAttribute("callerId", callerId) : null, record != null ? new XAttribute("record", (bool)record ? "true" : "false") : null); // write Dial element GetElement(context).Add( element, new XElement("Redirect", finishUrl)); // execute nouns if (Activities.Count > 0) { // schedule nouns with reference to Dial element twilio.SetElement(context, element); foreach (var noun in Activities) { context.ScheduleActivity(noun); } } }