Exemplo n.º 1
0
        public static IDisposable SubscribeProcessing(HttpServer server, WorkflowServer workflowserver)
        {
            return(server.Subscribe(async ctx =>
            {
                var path = ctx.Request.LocalPath.ToLower();

                Response response = null;
                if (path == "/workflowapi")
                {
                    if (!string.IsNullOrWhiteSpace(workflowserver.Parameters.ApiKey) &&
                        ctx.Request.HttpParams.QueryString["apikey"] != workflowserver.Parameters.ApiKey)
                    {
                        ctx.Respond(new StringResponse("APIKEY is not valid!"));
                        return;
                    }

                    workflowserver.Parameters?.Log?.Invoke(string.Format("Workflow API {0} ({2}): {1}",
                                                                         ctx.Request.HttpMethod, ctx.Request.RawUrl, ctx.Request.ClientAddress));
                    response = await workflowserver.WorkflowApiProcessing(ctx);
                }
                else if (path == "/designerapi")
                {
                    workflowserver.Parameters?.Log?.Invoke(string.Format("Designer API {0} ({2}): {1}",
                                                                         ctx.Request.HttpMethod, ctx.Request.RawUrl, ctx.Request.ClientAddress));
                    response = await workflowserver.DesignerApiProcessing(ctx);
                }
                else
                {
                    workflowserver.Parameters?.Log?.Invoke(string.Format("Get file ({1}): {0}", ctx.Request.RawUrl, ctx.Request.ClientAddress));
                    response = await BackEndProcessing(ctx, workflowserver.Parameters);
                }

                ctx.Respond(response);
            }));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            RegisterWorkflowEngine();

            // for tests(MS SQL)
            //args = new string[]{
            //    "-url=http://*:8077/",
            //    //"-callbackurl=http://localhost:8078/",
            //    //"-callbackgenscheme",
            //    "-dbprovider=mssql",
            //   // "-log",
            //    "-dbcs=Data Source=(local)\\SQL2012;Initial Catalog=WFTemp;Integrated Security=True;User ID=sa;Password=1;",
            //    "-befolder=../backend"
            //};

            var wsparams = ParseWorkflowServerParameter(args);

            if (wsparams == null)
            {
                ShowAllParameters();
                return;
            }

            Console.WriteLine("WorkflowServer by OptimaJet");
            Console.WriteLine("WorkflowEngine.NET: Init...");
            var workflowserver = new OptimaJet.WorkflowServer(wsparams);

            if (!wsparams.NoStartWorkflow)
            {
                Console.WriteLine("WorkflowEngine.NET: Starting...");
                workflowserver.Start();
            }

            Console.WriteLine("WorkflowServer: Starting...");
            var subject = new Subject <string>();

            using (var server = new HttpServer(wsparams.Url))
            {
                Console.WriteLine(string.Format("Waiting for a connection on {0}...", wsparams.Url));
                var listeners = OptimaJet.ServerHelper.SubscribeProcessing(server, workflowserver);

                while (true)
                {
                    Console.WriteLine("For exit please enter 'Q'.");
                    var command = Console.ReadLine();
                    if (!string.IsNullOrEmpty(command) && command.ToUpper() == "Q")
                    {
                        break;
                    }
                }

                listeners.Dispose();
            }
        }
Exemplo n.º 3
0
        protected override void OnStart(string[] args)
        {
            WorkflowServerParameter wsparams = GetParams();

            RegisterWorkflowEngine();

            Log("WorkflowEngine.NET: Init...");
            _workflowserver = new OptimaJet.WorkflowServer(wsparams);

            if (!wsparams.NoStartWorkflow)
            {
                Log("WorkflowEngine.NET: Starting...");
                _workflowserver.Start();
            }

            Log("HttpServer: Starting...");
            _server = new HttpServer(wsparams.Url);
            Log($"Waiting for a connection on {wsparams.Url}...");

            _listeners = ServerHelper.SubscribeProcessing(_server, _workflowserver);
        }
Exemplo n.º 4
0
        public static IDisposable SubscribeProcessing(HttpServer server, WorkflowServer workflowserver)
        {
            return server.Subscribe(ctx =>
            {
                var path = ctx.Request.LocalPath.ToLower();

                Response response = null;
                if (path == "/workflowapi")
                {
                    if (!string.IsNullOrWhiteSpace(workflowserver.Parameters.ApiKey) &&
                    ctx.Request.HttpParams.QueryString["apikey"] != workflowserver.Parameters.ApiKey)
                    {
                        ctx.Respond(new StringResponse("APIKEY is not valid!"));
                        return;
                    }

                    if (workflowserver.Parameters.Log != null)
                        workflowserver.Parameters.Log(string.Format("Workflow API {0} ({2}): {1}",
                        ctx.Request.HttpMethod, ctx.Request.RawUrl, ctx.Request.ClientAddress));
                    response = workflowserver.WorkflowApiProcessing(ref ctx);
                }
                else if (path == "/designerapi")
                {
                   if (workflowserver.Parameters.Log != null)
                        workflowserver.Parameters.Log(string.Format("Designer API {0} ({2}): {1}",
                        ctx.Request.HttpMethod, ctx.Request.RawUrl, ctx.Request.ClientAddress));
                    response = workflowserver.DesignerApiProcessing(ref ctx);
                }
                else
                {
                    if (workflowserver.Parameters.Log != null)
                        workflowserver.Parameters.Log(string.Format("Get file ({1}): {0}", ctx.Request.RawUrl, ctx.Request.ClientAddress));
                    response = BackEndProcessing(ref ctx, workflowserver.Parameters);
                }

                ctx.Respond(response);
            });
        }