/// <summary> /// Executes the node. /// </summary> /// <param name="runtime"></param> /// <param name="scope"></param> /// <returns></returns> public override bool Execute(IFlowRuntimeService runtime, DataPinScope scope) { if (ftpServerService == null) { ftpServerService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IFtpServerConfigurationService>(); } var servername = scope.GetValue <string>(InPinServer); var server = ftpServerService.GetByName(servername); if (serviceCache.Keys.Contains(server.Type.ToString())) { ftpService = serviceCache[server.Type.ToString()]; } else { ftpService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IFtpService>(server.Type.ToString()); serviceCache.Add(server.Type.ToString(), ftpService); } var directory = scope.GetValue <string>(InPinDirectory); var dir = ftpService.GetDirectoryContent(server, directory); scope.SetValue(OutPinDirectory, dir); runtime.EnqueueNode(OutNodeSuccess, scope); return(true); }
/// <summary> /// Executes the node. /// </summary> /// <param name="runtime"></param> /// <param name="scope"></param> /// <returns></returns> public override bool Execute(IFlowRuntimeService runtime, DataPinScope scope) { if (ftpServerService == null) { ftpServerService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IFtpServerConfigurationService>(); } var servername = scope.GetValue <string>(InPinServer); var server = ftpServerService.GetByName(servername); if (serviceCache.Keys.Contains(server.Type.ToString())) { ftpService = serviceCache[server.Type.ToString()]; } else { ftpService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IFtpService>(server.Type.ToString()); serviceCache.Add(server.Type.ToString(), ftpService); } var filename = scope.GetValue <string>(InPinFileName); var newFilename = scope.GetValue <string>(InPinNewFileName); var path = scope.GetValue <string>(InPinPath); ftpService.RenameFile(server, path + filename, newFilename); runtime.EnqueueNode(OutNodeSuccess, scope); return(true); }
/// <summary> /// Executes the node. /// </summary> /// <param name="runtime"></param> /// <param name="scope"></param> /// <returns></returns> public override bool Execute(IFlowRuntimeService runtime, DataPinScope scope) { if (ftpServerService == null) { ftpServerService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IFtpServerConfigurationService>(); } var servername = scope.GetValue <string>(InPinServer); var server = ftpServerService.GetByName(servername); if (serviceCache.Keys.Contains(server.Type.ToString())) { ftpService = serviceCache[server.Type.ToString()]; } else { ftpService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IFtpService>(server.Type.ToString()); serviceCache.Add(server.Type.ToString(), ftpService); } var file = scope.GetValue <byte[]>(InPinFile); var path = scope.GetValue <string>(InPinPath); var fileName = scope.GetValue <string>(InPinFileName); try { ftpService.UploadFile(server, file, path, fileName); runtime.EnqueueNode(OutNodeSuccess, scope); } catch (Exception ex) { runtime.EnqueueNode(OutNodeFaield, scope); Console.WriteLine(ex); } return(true); }