public static IEnumerator Start(Func <IEnumerator, Coroutine> startCoroutine) { Time.timeScale = Constants.TimeScale; Debugger.Config = Settings.Current.Debugging; Debugger.Logger += str => { Debug.Log(str); File.AppendAllText("log.txt", str + "\n"); }; Debugger.AddException("************** UNITY STARTED " + DateTime.Now); Application.logMessageReceived += Application_logMessageReceived; if (!Directory.Exists(Constants.LogFolderRoot)) { Directory.CreateDirectory(Constants.LogFolderRoot); } Loader = new Loader(); Debugger.Log("Loader ready. Starting: adding levels"); Debugger.Log("======================= Tutorial competition:" + Settings.Current.TutorialCompetitions); GameManager = new GameManager(); serviceServer = new ServiceServer(Constants.ServicePort); new Thread(serviceServer.Work).Start(); yield return(startCoroutine(new DlcLoader(startCoroutine).LoadAllDlc())); isStarted = true; }
void OnRosInit() { nh = ROS.GlobalNodeHandle; // nh = new NodeHandle ( "~" ); pathSrv = nh.advertiseService <GetPath.Request, GetPath.Response> ("quad_rotor/get_path", GetPathService); // setOrientSrv = nh.advertiseService<Messages.std_srvs.Empty.Request> ("quad_rotor/reset_orientation", TriggerReset) // enableMotorSrv = nh.advertiseService<EnableMotors.Request, EnableMotors.Response> ( "enable_motors", OnEnableMotors ); nh.setParam("control_mode", "wrench"); // for now force twist mode twistSub = nh.subscribe <Twist> ("quad_rotor/cmd_vel", 10, TwistCallback); wrenchSub = nh.subscribe <Wrench> ("quad_rotor/cmd_force", 10, WrenchCallback); posePub = nh.advertise <PoseStamped> ("quad_rotor/pose", 10, false); imuPub = nh.advertise <Imu> ("quad_rotor/imu", 10, false); // imgPub = nh.advertise<Image> ( "quad_rotor/image", 10, false ); pubThread = new Thread(PublishAll); pubThread.Start(); gravitySrv = nh.advertiseService <SetBool.Request, SetBool.Response> ("quad_rotor/gravity", GravityService); constrainForceXSrv = nh.advertiseService <SetBool.Request, SetBool.Response> ("quad_rotor/x_force_constrained", ConstrainForceX); constrainForceYSrv = nh.advertiseService <SetBool.Request, SetBool.Response> ("quad_rotor/y_force_constrained", ConstrainForceY); constrainForceZSrv = nh.advertiseService <SetBool.Request, SetBool.Response> ("quad_rotor/z_force_constrained", ConstrainForceZ); constrainTorqueXSrv = nh.advertiseService <SetBool.Request, SetBool.Response> ("quad_rotor/x_torque_constrained", ConstrainTorqueX); constrainTorqueYSrv = nh.advertiseService <SetBool.Request, SetBool.Response> ("quad_rotor/y_torque_constrained", ConstrainTorqueY); constrainTorqueZSrv = nh.advertiseService <SetBool.Request, SetBool.Response> ("quad_rotor/z_torque_constrained", ConstrainTorqueZ); triggerResetSrv = nh.advertiseService <SetBool.Request, SetBool.Response> ("quad_rotor/reset_orientation", TriggerReset); // triggerResetSrv = nh.advertiseService<Empty.Request, Empty.Response> ( "quad_rotor/reset_orientation", TriggerReset ); setPoseSrv = nh.advertiseService <SetPose.Request, SetPose.Response> ("quad_rotor/set_pose", SetPoseService); clearPathSrv = nh.advertiseService <SetBool.Request, SetBool.Response> ("quad_rotor/clear_path", ClearPathService); setPathSrv = nh.advertiseService <SetPath.Request, SetPath.Response> ("quad_rotor/set_path", SetPathService); }
public void Run() { metadata_pub = rosNodeHandle.advertise <nm.MapMetaData>("map_metadata", 1, true); if (metadata_pub != null) { metadata_pub.publish(mete_data_message_); } else { throw new Exception("map_metadata话题发布失败!"); } map_pub = rosNodeHandle.advertise <nm.OccupancyGrid>("map", 1, true); if (map_pub != null) { map_pub.publish(map_resp_.map); } else { throw new Exception("map话题发布失败!"); } server = rosNodeHandle.advertiseService <TwoInts.Request, TwoInts.Response>("/add_two_ints", addition); //可能rosnet 框架问题,服务不能够发布,后面解决 service = rosNodeHandle.advertiseService <nm.GetMap.Request, nm.GetMap.Response>("/static_map", mapCallback); }
public void Stop() { try { LogOut(); } catch { } if (serviceServer != null) { serviceServer.Stop(); serviceServer.Dispose(); serviceServer = null; } if (textServer != null) { textServer.Stop(); textServer.Dispose(); textServer = null; } if (fileServer != null) { fileServer.Stop(); fileServer.Dispose(); fileServer = null; } }
public void AdvertiseReconfigureService() { string sn = names.resolve(name, "set_parameters"); if (timeout == 0) { try { Service.waitForService(sn, 1); } catch { Service.waitForService(sn, timeout); } } else { Service.waitForService(sn, timeout); } setServer = nh.advertiseService(sn, (Reconfigure.Request req, ref Reconfigure.Request res) => { res.config = req.config; return(true); }); }
private void Window_Loaded(object sender, RoutedEventArgs e) { ROS.Init(new string[0], NODE_NAME); nodeHandle = new NodeHandle(); server = nodeHandle.advertiseService <TwoInts.Request, TwoInts.Response>("/add_two_ints", addition); }
public CalculatorServer() { _server = new ServiceServer(new Generated.CalculatorDispatcher(this), 27500); _server.OnClientConnection += info => { Console.WriteLine($"Client '{info}' has connected."); }; _server.OnClientDisconnection += info => { Console.WriteLine($"Client '{info}' has diconnected."); }; }
public void Stop() { if (!IsRunning) { return; } MonitorPool.Singleton.Exit(); IsRunning = false; ListenServer.Stop(); ServiceServer.Stop(); Client.Disconnect(); }
public void Dispose() { if (_cli != null) { _cli.shutdown(); _cli = null; } if (setServer != null) { setServer.shutdown(); setServer = null; } }
public async Task <int> Run() { if (_quitToken.IsCancellationRequested) { return(0); } await Kademlia.Start(); TransactionManager.Start(); await CouncilManager.Start(); await NodeServer.Start(); await ClientServer.Start(); if (ServiceServer != null) { await ServiceServer.Start(); } await _quitToken.WaitAsync(); await PubSub.PublishAsync(new QuitEvent()); await NodeServer.Stop(); await ClientServer.Stop(); await CouncilManager.Stop(); TransactionManager.Stop(); await Kademlia.Stop(); await ChainManager.Stop(); if (ServiceServer != null) { await ServiceServer.Stop(); } await(Host as Host).Stop(); return(0); }
/// <summary> /// Register a ROS Service /// </summary> /// <typeparam name="TService"> Service Type </typeparam> /// <param name="serviceName"> Service Name </param> /// <param name="service"> Service Instance </param> /// <returns> object that dispose a service </returns> public Task <IServiceServer> AdvertiseServiceAsync <TService>(string serviceName, TService service) where TService : IService, new() { if (_disposed) { throw new ObjectDisposedException("Node"); } if (_serviceServers.ContainsKey(serviceName)) { throw new InvalidOperationException(serviceName + " is already registered."); } _logger.InfoFormat("Create ServiceServer: {0}", serviceName); var serviceServer = new ServiceServer <TService>(NodeId); serviceServer.StartService(serviceName, service); serviceServer.Disposing += DisposeServiceAsync; _serviceServers.Add(serviceName, service); var serviceUri = new Uri("rosrpc://" + Ros.HostName + ":" + serviceServer.EndPoint.Port); var tcs = new TaskCompletionSource <IServiceServer>(); _masterClient .RegisterServiceAsync(NodeId, serviceName, serviceUri, _slaveServer.SlaveUri) .ContinueWith(registerTask => { if (registerTask.Status == TaskStatus.RanToCompletion) { tcs.SetResult(serviceServer); } else if (registerTask.Status == TaskStatus.Faulted) { tcs.SetException(registerTask.Exception.InnerException); } }); return(tcs.Task); }
public void AdvertiseReconfigureService() { if (timeout == 0) { try { Service.waitForService(set_service_name, 1); } catch { Service.waitForService(set_service_name, timeout); } } else { Service.waitForService(set_service_name, timeout); } setServer = nh.advertiseService(set_service_name, (Reconfigure.Request req, ref Reconfigure.Request res) => { res.config = req.config; return(true); }); }
void OnRosInit() { nh = ROS.GlobalNodeHandle; poseTypeSrv = nh.advertiseService <SetInt.Request, SetInt.Response> ("/quad_rotor/camera_pose_type", SetCameraPoseType); distanceSrv = nh.advertiseService <SetFloat.Request, SetFloat.Response> ("/quad_rotor/camera_distance", SetFollowDistance); }
protected override void ExecuteTool(IDSFDataObject dataObject) { ErrorResultTO allErrors = new ErrorResultTO(); dataObject.EnvironmentID = (EnvironmentID == null || EnvironmentID.Expression == null) ? Guid.Empty : Guid.Parse(EnvironmentID.Expression.ToString()); dataObject.RemoteServiceType = Type.Expression == null ? "" : Type.Expression.ToString(); ParentServiceName = dataObject.ServiceName; string parentServiceName = string.Empty; string serviceName = string.Empty; // BUG 9634 - 2013.07.17 - TWR - changed isRemoteExecution to check EnvironmentID instead // This is now the wrong behavior - We need to keep the original EnvironmentID when not a remote workflow // This is because we put and empty GUID in when designing against a remote server that uses it's resources // The first time through this value is set correctly when executing those designed resource from our localhost // If we change it as per what was here, we always get a localhost tag instead of the remote host we are design against var isRemote = dataObject.IsRemoteWorkflow(); if ((isRemote || dataObject.IsRemoteInvokeOverridden) && dataObject.EnvironmentID == Guid.Empty) { dataObject.IsRemoteInvokeOverridden = true; } var oldResourceId = dataObject.ResourceID; InitializeDebug(dataObject); try { //compiler.ClearErrors(dataObject.DataListID); if (ServiceServer != Guid.Empty) { // we need to adjust the originating server id so debug reflect remote server instead of localhost ;) dataObject.RemoteInvokerID = ServiceServer.ToString(); } dataObject.RunWorkflowAsync = RunWorkflowAsync; if (dataObject.IsDebugMode() || (dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer)) { DispatchDebugState(dataObject, StateType.Before); } Guid resourceId = dataObject.ResourceID; if (resourceId != Guid.Empty) { dataObject.ResourceID = resourceId; } // scrub it clean ;) // set the parent service parentServiceName = dataObject.ParentServiceName; serviceName = dataObject.ServiceName; dataObject.ParentServiceName = serviceName; _previousInstanceId = dataObject.ParentInstanceID; dataObject.ParentID = oldResourceId; dataObject.ParentInstanceID = UniqueID; dataObject.ParentWorkflowInstanceId = ParentWorkflowInstanceId; if (!DeferExecution) { // In all cases the ShapeOutput will have merged the execution data up into the current ErrorResultTO tmpErrors = new ErrorResultTO(); IEsbChannel esbChannel = dataObject.EsbChannel; if (esbChannel == null) { throw new Exception("FATAL ERROR : Null ESB channel!!"); } else { // NEW EXECUTION MODEL ;) // PBI 7913 dataObject.ServiceName = ServiceName; // set up for sub-exection ;) dataObject.ResourceID = ResourceID.Expression == null ? Guid.Empty : Guid.Parse(ResourceID.Expression.ToString()); BeforeExecutionStart(dataObject, allErrors); allErrors.MergeErrors(tmpErrors); // Execute Request ExecutionImpl(esbChannel, dataObject, InputMapping, OutputMapping, out tmpErrors); allErrors.MergeErrors(tmpErrors); AfterExecutionCompleted(tmpErrors); allErrors.MergeErrors(tmpErrors); dataObject.ServiceName = ServiceName; } } } catch (Exception err) { dataObject.Environment.Errors.Add(err.Message); } finally { if (!dataObject.WorkflowResumeable || !dataObject.IsDataListScoped) { // Handle Errors if (allErrors.HasErrors()) { DisplayAndWriteError("DsfActivity", allErrors); dataObject.Environment.AddError(allErrors.MakeDataListReady()); // add to datalist in variable specified if (!String.IsNullOrEmpty(OnErrorVariable)) { var upsertVariable = DataListUtil.AddBracketsToValueIfNotExist(OnErrorVariable); dataObject.Environment.Assign(upsertVariable, allErrors.MakeDataListReady()); } } } if (dataObject.IsDebugMode() || (dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer)) { DispatchDebugState(dataObject, StateType.After); } dataObject.ParentInstanceID = _previousInstanceId; dataObject.ParentServiceName = parentServiceName; dataObject.ServiceName = serviceName; dataObject.RemoteInvokeResultShape = new StringBuilder(); // reset targnet shape ;) dataObject.RunWorkflowAsync = false; dataObject.RemoteInvokerID = Guid.Empty.ToString(); dataObject.EnvironmentID = Guid.Empty; dataObject.ResourceID = oldResourceId; } }
public async Task <bool> Start(string[] args, CancellationTokenSource quiteToken) { _quitToken = quiteToken; if (_quitToken.IsCancellationRequested) { return(false); } var dataPath = "heleusdata"; var genesis = false; var sync = false; var run = false; var init = false; var newChainConfig = false; if (args.Length == 1) { dataPath = args[0]; run = true; } else if (args.Length == 2) { dataPath = args[0]; var cmd = args[1]; if (cmd == "init") { init = true; } else if (cmd == "run") { run = true; } else if (cmd == "sync") { sync = true; } else if (cmd == "chainconfig") { newChainConfig = true; } else if (cmd == "genesis") { genesis = true; } else { Usage(); return(false); } } else { Usage(); return(false); } if ((run || sync) && !File.Exists(Path.Combine(dataPath, $"{nameof(NodeConfig).ToLower()}.txt"))) { Usage(); var dp = new DirectoryInfo(dataPath); Log.Error($"Data path {dp.FullName} not initalized.", this); return(false); } Storage = new Storage(dataPath); if (!Storage.IsWriteable) { Log.Fatal($"Data path {Storage.Root} is not writeable!", this); return(false); } if (genesis) { Storage.DeleteDirectory("cache"); Storage.DeleteDirectory("chains"); } PubSub = Log.PubSub = new PubSub(); Log.Write($"Starting Heleus Node (Version {Program.Version})."); Log.Trace($"PID {System.Diagnostics.Process.GetCurrentProcess().Id}"); Log.Write($"Data path is '{Storage.Root.FullName}'."); var config = Config.Load <NodeConfig>(Storage); Log.AddIgnoreList(config.LogIgnore); Log.LogLevel = config.LogLevel; if (Program.IsDebugging) { Log.LogLevel = LogLevels.Trace; } if (newChainConfig) { var chainConfig = Config.Load <ChainConfig>(Storage, true); //if (chainConfig.Chains.Count == 0) { Log.Write("Chain config generated."); chainConfig.Chains.Add(new ChainConfig.ChainInfo { ChainKeys = new List <ChainConfig.ChainKeyInfo> { new ChainConfig.ChainKeyInfo { ChainKey = string.Empty, ChainKeyPassword = string.Empty, AttachementKey = -1 } } }); Config.Save(chainConfig); } return(false); } if (init) { Log.Write("Config file generated."); return(false); } if (!genesis) { if (config.NetworkPublicKey.IsNullOrEmpty()) { Log.Write("Network key not set. Querying beacon nodes."); var beacons = config.BeaconNodes; foreach (var beacon in beacons) { Log.Write($"Querying beacon node {beacon}."); var client = new NodeClient(new Uri(beacon)); var nodeInfo = (await client.DownloadNodeInfo()).Data; if (nodeInfo != null) { config.NetworkPublicKey = nodeInfo.NetworkKey.HexString; Config.Save(config); Log.Write($"Network key set to {config.NetworkPublicKey}."); break; } } } if (config.NetworkPublicKey.IsNullOrEmpty()) { Log.Write("No valid network key found or set.", this); return(false); } } NodeConfiguration = new NodeConfiguration(config, Config.Load <CoreKeyConfig>(Storage, false), Config.Load <ChainConfig>(Storage, false)); Host = new Host(config); AttachementManager = new AttachementManager(this); ChainManager = new ChainManager(this); if (!await ChainManager.Initalize()) { return(false); } if (genesis) { var result = GenesisBlock.Generate(Storage); var blockData = new BlockData <CoreBlock>(result.Block, result.Signature); await ChainManager.Start(false); await ChainManager.CoreChain.BlockStorage.StoreBlock(blockData); ChainManager.ConsumeBlockData(blockData); Log.Write($"Genesis block and keys generated. Network public key: {result.NetworkPublicKey.HexString}."); var coreKeyConfig = Config.Load <CoreKeyConfig>(Storage); coreKeyConfig.Key = result.NetworkVoteKey.HexString; coreKeyConfig.Password = result.NetworkVotePassword; config.NetworkPublicKey = result.NetworkPublicKey.HexString; Config.Save(config); Config.Save(coreKeyConfig); await ChainManager.Stop(); await ChainManager.Start(true); if (result.ServiceTransactions.Count > 0) { foreach (var serviceTransactions in result.ServiceTransactions) { var chainId = serviceTransactions.Key; var transactions = serviceTransactions.Value; var serviceChain = ChainManager.GetServiceChain(chainId); var maintainChain = ChainManager.GetMaintainChain(chainId); if (serviceChain != null) { var generator = new ServiceBlockGenerator(ChainManager.CoreChain, serviceChain, maintainChain, null); foreach (var transaction in transactions) { generator.ConsumeTransaction(transaction); } var serviceBlock = generator.GenerateBlock(0, 0); var serviceBlockData = new BlockData <ServiceBlock>(serviceBlock, new BlockSignatures(serviceBlock)); await serviceChain.BlockStorage.StoreBlock(serviceBlockData); serviceChain.ConsumeBlockData(serviceBlockData); } } } await ChainManager.Stop(); return(false); } SyncManager = new SyncManager(this); await SyncManager.Start(); //if (!await SyncManager.Start()) // return false; if (sync) { Log.Write("Sync done."); return(false); } AttachementManager.Start(); Kademlia = new Kademlia(Storage, this); TransactionManager = new TransactionManager(this); CouncilManager = new CouncilManager(this); NodeServer = new NodeServer(this, config.MaxIncomingConnections, config.MaxOutgoingConnectoins); ClientServer = new ClientServer(this); if (Host.EnableRemoteServices) { ServiceServer = new ServiceServer(); } await(Host as Host).Start(this); return(true); }
[ExcludeFromCodeCoverage] //This execution is no longer used protected override void OnExecute(NativeActivityContext context) { // ???? Why is this here.... context.Properties.ToObservableCollection(); IEsbChannel esbChannel = DataObject.EsbChannel; IDSFDataObject dataObject = context.GetExtension <IDSFDataObject>(); dataObject.EnvironmentID = context.GetValue(EnvironmentID); Guid datalistId = DataListExecutionID.Get(context); ParentWorkflowInstanceId = context.WorkflowInstanceId.ToString(); dataObject.RemoteServiceType = context.GetValue(Type); var resourceId = context.GetValue(ResourceID); ErrorResultTO allErrors = new ErrorResultTO(); ParentServiceName = dataObject.ServiceName; string parentServiceName = string.Empty; string serviceName = string.Empty; var isRemote = dataObject.IsRemoteWorkflow(); if ((isRemote || dataObject.IsRemoteInvokeOverridden) && dataObject.EnvironmentID == Guid.Empty) { dataObject.IsRemoteInvokeOverridden = true; } var oldResourceId = dataObject.ResourceID; InitializeDebug(dataObject); try { if (ServiceServer != Guid.Empty) { dataObject.RemoteInvokerID = ServiceServer.ToString(); } dataObject.RunWorkflowAsync = RunWorkflowAsync; if (resourceId != Guid.Empty) { dataObject.ResourceID = resourceId; } if (dataObject.IsDebugMode() || dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer) { DispatchDebugState(dataObject, StateType.Before, 0); } // scrub it clean ;) // set the parent service parentServiceName = dataObject.ParentServiceName; serviceName = dataObject.ServiceName; dataObject.ParentServiceName = serviceName; _previousInstanceId = dataObject.ParentInstanceID; dataObject.ParentID = oldResourceId; dataObject.ParentInstanceID = UniqueID; dataObject.ParentWorkflowInstanceId = ParentWorkflowInstanceId; if (!DeferExecution) { // In all cases the ShapeOutput will have merged the execution data up into the current ErrorResultTO tmpErrors = new ErrorResultTO(); if (esbChannel == null) { throw new Exception(ErrorResource.NullESBChannel); } else { // NEW EXECUTION MODEL ;) // PBI 7913 if (datalistId != GlobalConstants.NullDataListID) { BeforeExecutionStart(dataObject, allErrors); allErrors.MergeErrors(tmpErrors); dataObject.ServiceName = ServiceName; // set up for sub-exection ;) dataObject.ResourceID = ResourceID.Expression == null ? Guid.Empty : Guid.Parse(ResourceID.Expression.ToString()); // Execute Request ExecutionImpl(esbChannel, dataObject, InputMapping, OutputMapping, out tmpErrors, 0); // careful of zero if wf comes back allErrors.MergeErrors(tmpErrors); AfterExecutionCompleted(tmpErrors); allErrors.MergeErrors(tmpErrors); dataObject.DataListID = datalistId; // re-set DL ID dataObject.ServiceName = ServiceName; } } } } finally { // Handle Errors if (allErrors.HasErrors()) { DisplayAndWriteError("DsfActivity", allErrors); dataObject.Environment.AddError(allErrors.MakeDataListReady()); // add to datalist in variable specified if (!String.IsNullOrEmpty(OnErrorVariable)) { var upsertVariable = DataListUtil.AddBracketsToValueIfNotExist(OnErrorVariable); dataObject.Environment.Assign(upsertVariable, allErrors.MakeDataListReady(), 0); } } if (dataObject.IsDebugMode() || dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer) { DispatchDebugState(dataObject, StateType.After, 0); } dataObject.ParentInstanceID = _previousInstanceId; dataObject.ParentServiceName = parentServiceName; dataObject.ServiceName = serviceName; dataObject.RemoteInvokeResultShape = new StringBuilder(); // reset targnet shape ;) dataObject.RunWorkflowAsync = false; dataObject.RemoteInvokerID = Guid.Empty.ToString(); dataObject.EnvironmentID = Guid.Empty; dataObject.ResourceID = oldResourceId; } }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { ErrorResultTO allErrors = new ErrorResultTO(); dataObject.EnvironmentID = EnvironmentID?.Expression == null ? Guid.Empty : Guid.Parse(EnvironmentID.Expression.ToString()); dataObject.RemoteServiceType = Type?.Expression?.ToString() ?? ""; ParentServiceName = dataObject.ServiceName; string parentServiceName = string.Empty; string serviceName = string.Empty; var isRemote = dataObject.IsRemoteWorkflow(); if ((isRemote || dataObject.IsRemoteInvokeOverridden) && dataObject.EnvironmentID == Guid.Empty) { dataObject.IsRemoteInvokeOverridden = true; } var oldResourceId = dataObject.ResourceID; var wasTestExecution = dataObject.IsServiceTestExecution; InitializeDebug(dataObject); try { if (ServiceServer != Guid.Empty) { dataObject.RemoteInvokerID = ServiceServer.ToString(); } dataObject.RunWorkflowAsync = RunWorkflowAsync; Guid resourceId = dataObject.ResourceID; if (resourceId != Guid.Empty) { dataObject.ResourceID = resourceId; } parentServiceName = dataObject.ParentServiceName; serviceName = dataObject.ServiceName; dataObject.ParentServiceName = serviceName; _previousInstanceId = dataObject.ParentInstanceID; dataObject.ParentID = oldResourceId; dataObject.ParentInstanceID = UniqueID; dataObject.ParentWorkflowInstanceId = ParentWorkflowInstanceId; if (!DeferExecution) { ErrorResultTO tmpErrors = new ErrorResultTO(); IEsbChannel esbChannel = dataObject.EsbChannel; if (esbChannel == null) { throw new Exception(ErrorResource.NullESBChannel); } dataObject.ServiceName = ServiceName; // set up for sub-exection ;) dataObject.ResourceID = ResourceID.Expression == null ? Guid.Empty : Guid.Parse(ResourceID.Expression.ToString()); BeforeExecutionStart(dataObject, allErrors); if (dataObject.IsDebugMode() || dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer) { DispatchDebugStateAndUpdateRemoteServer(dataObject, StateType.Before, update); } allErrors.MergeErrors(tmpErrors); ExecutionImpl(esbChannel, dataObject, InputMapping, OutputMapping, out tmpErrors, update); allErrors.MergeErrors(tmpErrors); AfterExecutionCompleted(tmpErrors); allErrors.MergeErrors(tmpErrors); dataObject.ServiceName = ServiceName; } } catch (Exception err) { dataObject.Environment.Errors.Add(err.Message); } finally { if (!dataObject.WorkflowResumeable || !dataObject.IsDataListScoped) { // Handle Errors if (allErrors.HasErrors()) { DisplayAndWriteError("DsfActivity", allErrors); foreach (var allError in allErrors.FetchErrors()) { dataObject.Environment.Errors.Add(allError); } // add to datalist in variable specified if (!String.IsNullOrEmpty(OnErrorVariable)) { var upsertVariable = DataListUtil.AddBracketsToValueIfNotExist(OnErrorVariable); dataObject.Environment.Assign(upsertVariable, allErrors.MakeDataListReady(), update); } } } if (dataObject.IsDebugMode() || dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer) { var dt = DateTime.Now; DispatchDebugState(dataObject, StateType.After, update, dt); ChildDebugStateDispatch(dataObject); _debugOutputs = new List <DebugItem>(); DispatchDebugState(dataObject, StateType.Duration, update, dt); } dataObject.ParentInstanceID = _previousInstanceId; dataObject.ParentServiceName = parentServiceName; dataObject.ServiceName = serviceName; dataObject.RemoteInvokeResultShape = new StringBuilder(); // reset targnet shape ;) dataObject.RunWorkflowAsync = false; dataObject.RemoteInvokerID = Guid.Empty.ToString(); dataObject.EnvironmentID = Guid.Empty; dataObject.ResourceID = oldResourceId; } }
public override IEnumerable <StateVariable> GetState() { var serializer = new Dev2JsonSerializer(); var inputs = serializer.Serialize(Inputs); var outputs = serializer.Serialize(Outputs); return(new[] { new StateVariable { Name = "Inputs", Type = StateVariable.StateType.Input, Value = inputs }, new StateVariable { Name = "Outputs", Type = StateVariable.StateType.Output, Value = outputs }, new StateVariable { Name = "ServiceServer", Type = StateVariable.StateType.Input, Value = ServiceServer.ToString() }, new StateVariable { Name = "EnvironmentID", Type = StateVariable.StateType.Input, Value = EnvironmentID.Expression.ToString() }, new StateVariable { Name = "IsWorkflow", Type = StateVariable.StateType.Input, Value = IsWorkflow.ToString() }, new StateVariable { Name = "ServiceUri", Type = StateVariable.StateType.Input, Value = ServiceUri }, new StateVariable { Name = "ResourceID", Type = StateVariable.StateType.Input, Value = ResourceID.Expression.ToString() }, new StateVariable { Name = "ServiceName", Type = StateVariable.StateType.Input, Value = ServiceName }, new StateVariable { Name = "ParentServiceName", Type = StateVariable.StateType.Input, Value = ParentServiceName } }); }
#pragma warning disable S1541 // Methods and properties should not be too complex protected override void ExecuteTool(IDSFDataObject dataObject, int update) #pragma warning restore S1541 // Methods and properties should not be too complex { var allErrors = new ErrorResultTO(); dataObject.EnvironmentID = EnvironmentID?.Expression == null ? Guid.Empty : Guid.Parse(EnvironmentID.Expression.ToString()); dataObject.RemoteServiceType = Type?.Expression?.ToString() ?? ""; ParentServiceName = dataObject.ServiceName; var parentServiceName = string.Empty; var serviceName = string.Empty; var isRemote = dataObject.IsRemoteWorkflow(); if ((isRemote || dataObject.IsRemoteInvokeOverridden) && dataObject.EnvironmentID == Guid.Empty) { dataObject.IsRemoteInvokeOverridden = true; } var oldResourceId = dataObject.ResourceID; InitializeDebug(dataObject); try { if (ServiceServer != Guid.Empty) { dataObject.RemoteInvokerID = ServiceServer.ToString(); } dataObject.RunWorkflowAsync = RunWorkflowAsync; parentServiceName = dataObject.ParentServiceName; serviceName = dataObject.ServiceName; dataObject.ParentServiceName = serviceName; _previousInstanceId = dataObject.ParentInstanceID; dataObject.ParentID = oldResourceId; dataObject.ParentInstanceID = UniqueID; dataObject.ParentWorkflowInstanceId = ParentWorkflowInstanceId; if (!DeferExecution) { var tmpErrors = new ErrorResultTO(); var esbChannel = dataObject.EsbChannel; if (esbChannel == null) { throw new Exception(ErrorResource.NullESBChannel); } dataObject.ServiceName = ServiceName; // set up for sub-exection ;) dataObject.ResourceID = ResourceID.Expression == null ? Guid.Empty : Guid.Parse(ResourceID.Expression.ToString()); BeforeExecutionStart(dataObject, allErrors); if (dataObject.IsDebugMode() || dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer) { DispatchDebugStateAndUpdateRemoteServer(dataObject, StateType.Before, update); } allErrors.MergeErrors(tmpErrors); ExecutionImpl(esbChannel, dataObject, InputMapping, OutputMapping, out tmpErrors, update); allErrors.MergeErrors(tmpErrors); AfterExecutionCompleted(tmpErrors); allErrors.MergeErrors(tmpErrors); dataObject.ServiceName = ServiceName; } } catch (Exception err) { dataObject.Environment.AddError(err.Message); } finally { DebugOutput(dataObject, update, allErrors, parentServiceName, serviceName, oldResourceId); } }
protected override void OnExecute(NativeActivityContext context) { // ???? Why is this here.... context.Properties.ToObservableCollection(); IEsbChannel esbChannel = context.GetExtension <IEsbChannel>(); IDSFDataObject dataObject = context.GetExtension <IDSFDataObject>(); IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); ErrorResultTO errors; ErrorResultTO allErrors = new ErrorResultTO(); Guid datalistId = DataListExecutionID.Get(context); ParentServiceName = dataObject.ServiceName; ParentWorkflowInstanceId = context.WorkflowInstanceId.ToString(); string parentServiceName = string.Empty; string serviceName = string.Empty; // BUG 9634 - 2013.07.17 - TWR - changed isRemoteExecution to check EnvironmentID instead // This is now the wrong behavior - We need to keep the original EnvironmentID when not a remote workflow // This is because we put and empty GUID in when designing against a remote server that uses it's resources // The first time through this value is set correctly when executing those designed resource from our localhost // If we change it as per what was here, we always get a localhost tag instead of the remote host we are design against var isRemote = dataObject.IsRemoteWorkflow(); dataObject.EnvironmentID = context.GetValue(EnvironmentID); if ((isRemote || dataObject.IsRemoteInvokeOverridden) && dataObject.EnvironmentID == Guid.Empty) { dataObject.IsRemoteInvokeOverridden = true; } var oldResourceId = dataObject.ResourceID; InitializeDebug(dataObject); try { compiler.ClearErrors(dataObject.DataListID); if (ServiceServer != Guid.Empty) { // we need to adjust the originating server id so debug reflect remote server instead of localhost ;) dataObject.RemoteInvokerID = ServiceServer.ToString(); } dataObject.RemoteServiceType = context.GetValue(Type); dataObject.RunWorkflowAsync = RunWorkflowAsync; if (dataObject.IsDebugMode() || (dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer)) { DispatchDebugState(context, StateType.Before); } var resourceId = context.GetValue(ResourceID); if (resourceId != Guid.Empty) { dataObject.ResourceID = resourceId; } // scrub it clean ;) ScrubDataList(compiler, datalistId, context.WorkflowInstanceId.ToString(), out errors); allErrors.MergeErrors(errors); // set the parent service parentServiceName = dataObject.ParentServiceName; serviceName = dataObject.ServiceName; dataObject.ParentServiceName = serviceName; _previousInstanceId = dataObject.ParentInstanceID; dataObject.ParentID = oldResourceId; dataObject.ParentInstanceID = UniqueID; dataObject.ParentWorkflowInstanceId = ParentWorkflowInstanceId; if (!DeferExecution) { // In all cases the ShapeOutput will have merged the execution data up into the current ErrorResultTO tmpErrors = new ErrorResultTO(); if (esbChannel == null) { throw new Exception("FATAL ERROR : Null ESB channel!!"); } else { // NEW EXECUTION MODEL ;) // PBI 7913 if (datalistId != GlobalConstants.NullDataListID) { BeforeExecutionStart(dataObject, allErrors); allErrors.MergeErrors(tmpErrors); dataObject.ServiceName = ServiceName; // set up for sub-exection ;) dataObject.ResourceID = ResourceID.Expression == null ? Guid.Empty : Guid.Parse(ResourceID.Expression.ToString()); // Execute Request ExecutionImpl(esbChannel, dataObject, InputMapping, OutputMapping, out tmpErrors); allErrors.MergeErrors(tmpErrors); AfterExecutionCompleted(tmpErrors); allErrors.MergeErrors(tmpErrors); dataObject.DataListID = datalistId; // re-set DL ID dataObject.ServiceName = ServiceName; } // ** THIS IS A HACK OF NOTE, WE NEED TO ADDRESS THIS! if (dataObject.IsDebugMode()) { //Dont remove this it is here to fix the data not being returned correctly string testData = compiler.ConvertFrom(dataObject.DataListID, DataListFormat.CreateFormat(GlobalConstants._Studio_Debug_XML), enTranslationDepth.Data, out errors).ToString(); if (string.IsNullOrEmpty(testData)) { } } } bool whereErrors = compiler.HasErrors(datalistId); Result.Set(context, whereErrors); HasError.Set(context, whereErrors); IsValid.Set(context, whereErrors); } } finally { if (!dataObject.WorkflowResumeable || !dataObject.IsDataListScoped) { // Handle Errors if (allErrors.HasErrors()) { DisplayAndWriteError("DsfActivity", allErrors); compiler.UpsertSystemTag(dataObject.DataListID, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errors); // add to datalist in variable specified if (!String.IsNullOrEmpty(OnErrorVariable)) { var upsertVariable = DataListUtil.AddBracketsToValueIfNotExist(OnErrorVariable); compiler.Upsert(dataObject.DataListID, upsertVariable, allErrors.MakeDataListReady(), out errors); } } } if (dataObject.IsDebugMode() || (dataObject.RunWorkflowAsync && !dataObject.IsFromWebServer)) { DispatchDebugState(context, StateType.After); } dataObject.ParentInstanceID = _previousInstanceId; dataObject.ParentServiceName = parentServiceName; dataObject.ServiceName = serviceName; dataObject.RemoteInvokeResultShape = new StringBuilder(); // reset targnet shape ;) dataObject.RunWorkflowAsync = false; dataObject.RemoteInvokerID = Guid.Empty.ToString(); dataObject.EnvironmentID = Guid.Empty; dataObject.ResourceID = oldResourceId; } }