예제 #1
0
 public static void TestProcessScriptGenerator(IServiceResolver sr)
 {
     var pr = sr.GetInstance<IProcessPackageRepo>();
     var pdef = pr.GetProcessDef("Test2.Compensation.1");
     var sw = new StringWriter();
     NGinnBPM.Runtime.ProcessDSL.BooProcessScriptGenerator gen = new NGinnBPM.Runtime.ProcessDSL.BooProcessScriptGenerator(sw);
     gen.GenerateScript(pdef);
     Console.WriteLine(sw.ToString());
 }
예제 #2
0
        public static void TestProcessScriptGenerator(IServiceResolver sr)
        {
            var pr   = sr.GetInstance <IProcessPackageRepo>();
            var pdef = pr.GetProcessDef("Test2.Compensation.1");
            var sw   = new StringWriter();

            NGinnBPM.Runtime.ProcessDSL.BooProcessScriptGenerator gen = new NGinnBPM.Runtime.ProcessDSL.BooProcessScriptGenerator(sw);
            gen.GenerateScript(pdef);
            Console.WriteLine(sw.ToString());
        }
예제 #3
0
        /// <summary>
        /// Registers some default values with the specified HTTP configuration.
        /// </summary>
        /// <param name="httpConfiguration">The HTTP configuration.</param>
        /// <param name="resolver">The resolver.</param>
        /// <exception cref="ArgumentNullException">If any arguments are null.</exception>
        public void Register(HttpConfiguration httpConfiguration, IServiceResolver resolver)
        {
            if (httpConfiguration == null)
            {
                throw new ArgumentNullException(nameof(httpConfiguration));
            }

            if (resolver == null)
            {
                throw new ArgumentNullException(nameof(resolver));
            }

            var jsonFormatter = httpConfiguration.Formatters.JsonFormatter;

            jsonFormatter.MediaTypeMappings.Add(new RequestHeaderMapping("Accept", "text/html", StringComparison.OrdinalIgnoreCase, true, "application/json"));

            // jsonFormatter.SerializerSettings = JsonConfiguration.CompactSerializerSettings;
            httpConfiguration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "{controller}/{id}",
                defaults: new { id = RouteParameter.Optional });

            httpConfiguration.Services.Replace(typeof(IHttpControllerSelector), new ApiControllerSelector(httpConfiguration));

            if (this.ExceptionLogger != null)
            {
                httpConfiguration.Services.Add(typeof(IExceptionLogger), this.ExceptionLogger);
            }

            var hostingSettings = resolver.GetInstance <HostingSettings>();

            if (hostingSettings?.Cors != null && hostingSettings.Cors.Origins.Any())
            {
                var cors = hostingSettings.Cors;

                var corsPolicyProvider = new EnableCorsAttribute(
                    string.Join(",", cors.Origins),
                    string.Join(",", cors.Headers),
                    string.Join(",", cors.Methods),
                    string.Join(",", cors.ExposedHeaders))
                {
                    SupportsCredentials = cors.SupportsCredentials,
                };

                if (cors.PreflightMaxAge.HasValue)
                {
                    corsPolicyProvider.PreflightMaxAge = cors.PreflightMaxAge.Value;
                }

                httpConfiguration.EnableCors(corsPolicyProvider);
            }
        }
예제 #4
0
        void _transport_OnMessageToUnknownDestination(MessageContainer message, IMessageTransport transport)
        {
            string dest = message.To;

            log.Debug("Message to remote destination {0}", dest);
            Uri               uri = new Uri(dest);
            string            sn  = string.Format("MessageTransport_{0}", uri.Scheme);
            IMessageTransport mt  = ServiceLocator.GetInstance <IMessageTransport>(sn);

            if (mt == null)
            {
                throw new Exception("No message transport configured for destination " + dest);
            }
            mt.Send(message);
        }
예제 #5
0
 public static void TestProcess(string definitionId, IServiceResolver container, Action<CompositeTaskInstanceInfo, Dictionary<string, object>> validate)
 {
     using (var ts = new TransactionScope())
     {
         var pr = container.GetInstance<ProcessEngine>();
         var proc = pr.StartProcess(definitionId, new Dictionary<string, object> { });
         log.Info("Started process {0}: {1}", definitionId, proc);
         var ti = pr.GetTaskInstanceInfo(proc);
         var data = pr.GetTaskData(proc);
         validate?.Invoke(ti, data);
         /*
         if (ti.Status != NGinnBPM.Runtime.TaskStatus.Completed)
         {
             throw new Exception("Process did not complete");
         }*/
         ts.Complete();
     }
 }
예제 #6
0
 public static void TestProcess(string definitionId, IServiceResolver container, Action<CompositeTaskInstanceInfo, Dictionary<string, object>> validate)
 {
     using (var ts = new TransactionScope())
     {
         var pr = container.GetInstance<ProcessEngine>();
         var proc = pr.StartProcess(definitionId, new Dictionary<string, object> { });
         log.Info("Started process {0}: {1}", definitionId, proc);
         var ti = pr.GetTaskInstanceInfo(proc);
         var data = pr.GetTaskData(proc);
         if (validate != null)
         {
             validate(ti, data);
         }
         /*
         if (ti.Status != NGinnBPM.Runtime.TaskStatus.Completed)
         {
             throw new Exception("Process did not complete");
         }*/
         ts.Complete();
     }
 }
        public virtual object CallService(string name, object inputMessage)
        {
            if (ServiceCallContext.Current == null)
            {
                throw new Exception("Service call context has not been set up!");
            }
            ServiceHandlerInfo shi = null;
            var tp = inputMessage.GetType();

            if (!string.IsNullOrEmpty(name))
            {
                shi = GetServiceHandler(name);
            }
            else
            {
                shi = GetServices().Find(x => x.RequestType == tp);
            }

            if (shi == null)
            {
                throw new Exception("Service not found");
            }
            var h = shi.HandlerName == null?ServiceLocator.GetInstance(shi.MessageHandlerGenericType) : ServiceLocator.GetInstance(shi.MessageHandlerGenericType, shi.HandlerName);

            if (h == null)
            {
                throw new Exception("Service not found: " + name);
            }

            try
            {
                if (h is SagaBase)
                {
                    object ret    = null;
                    var    helper = ServiceLocator.GetInstance <Sagas.SagaStateHelper>();
                    var    b      = helper.DispatchToSaga(null, inputMessage, true, true, (SagaBase)h, delegate(SagaBase saga)
                    {
                        ret = shi.HandleMethod(saga, inputMessage);
                    });
                    ServiceLocator.ReleaseInstance(helper);
                    if (b != Sagas.SagaStateHelper.SagaDispatchResult.MessageHandled)
                    {
                        throw new Exception();
                    }
                    return(ret);
                }
                else
                {
                    return(shi.HandleMethod(h, inputMessage));
                }
            }
            catch (TargetInvocationException ex)
            {
                if (ex.InnerException != null)
                {
                    throw ex.InnerException;
                }
                throw;
            }
            finally
            {
                if (h != null)
                {
                    ServiceLocator.ReleaseInstance(h);
                }
            }
        }