public WorkflowInstance CreateNewWorkflow(Type workflowType, Dictionary <string, object> arguments)
        {
            GlobalInitializerFacade.EnsureSystemIsInitialized();
            DoInitialize(0);

            try
            {
                WorkflowInstance workflowInstance = _workflowRuntime.CreateWorkflow(workflowType, arguments);

                SetWorkflowPersistingType(workflowType, workflowInstance.InstanceId);

                if (arguments.TryGetValue("SerializedEntityToken", out var serializedEntityToken) &&
                    arguments.TryGetValue("SerializedActionToken", out var serializedActionToken))
                {
                    ActionToken actionToken = ActionTokenSerializer.Deserialize((string)serializedActionToken);

                    if (!actionToken.IgnoreEntityTokenLocking)
                    {
                        AcquireLockIfNeeded(workflowType, workflowInstance.InstanceId, (string)serializedEntityToken);
                    }
                }

                return(workflowInstance);
            }
            catch (WorkflowValidationFailedException exp)
            {
                var errors = new StringBuilder();
                foreach (ValidationError error in exp.Errors)
                {
                    errors.AppendLine(error.ToString());
                }

                Log.LogError(LogTitle, errors.ToString());
                throw;
            }
        }
        public WorkflowInstance CreateNewWorkflow(Type workflowType)
        {
            GlobalInitializerFacade.EnsureSystemIsInitialized();
            DoInitialize(0);

            try
            {
                WorkflowInstance workflowInstance = _workflowRuntime.CreateWorkflow(workflowType);

                SetWorkflowPersistingType(workflowType, workflowInstance.InstanceId);

                return(workflowInstance);
            }
            catch (WorkflowValidationFailedException exp)
            {
                StringBuilder errors = new StringBuilder();
                foreach (ValidationError error in exp.Errors)
                {
                    errors.AppendLine(error.ToString());
                }
                Log.LogError(LogTitle, errors.ToString());
                throw;
            }
        }