protected override void Execute(CodeActivityContext context) { var hostName = HostName.Get(context); bool success; Ping ping = null; try { ping = new Ping(); PingReply reply; reply = ping.Send(hostName); success = reply.Status == IPStatus.Success; if (success) { DelayMS.Set(context, (int)reply.RoundtripTime); } Success.Set(context, success); } catch (System.Exception) { Success.Set(context, false); } finally { if (ping != null) { ping.Dispose(); } } }
protected override async Task <Action <NativeActivityContext> > ExecuteAsync(NativeActivityContext context, CancellationToken cancellationToken) { // Inputs var hostName = HostName.Get(context); var portNumber = PortNumber.Get(context); var userName = UserName.Get(context); var password = Password.Get(context); var sftp_session = new SftpClient(hostName, portNumber, userName, password); sftp_session.Connect(); sftp_Session_Var = sftp_session; _objectContainer.Add <SftpClient>(sftp_session); return((ctx) => { // Schedule child activities if (Body != null) { ctx.ScheduleAction <IObjectContainer>(Body, _objectContainer, OnCompleted, OnFaulted); } // Outputs }); }