Exemplo n.º 1
0
        public TResponse ContinueWorkflow <TRequest, TResponse>(WorkflowDefinition definition, TRequest request, string OperationName)
        {
            TResponse response = default(TResponse);

            WorkflowInstanceManager workflowManager = new WorkflowInstanceManager(definition.Workflow);

            //workflowManager.instanceStore = InstanceStore;

            workflowManager.instanceStore = WorkflowActivator.GetScope().ServiceProvider.GetService <System.Activities.Runtime.DurableInstancing.InstanceStore>();
            if (workflowManager.instanceStore is IStoreCorrelation)
            {
                (workflowManager.instanceStore as IStoreCorrelation).Correlation = new WorkflowCorrelation()
                {
                    //CorrelationId = definition.InstanceCorrelation,
                    CorrelationId = definition.Correlation.CorrelationId,
                    //WorkflowId = wfApp.Id,
                };
            }

            try
            {
                response = workflowManager.ContinueWorkflow <TRequest, TResponse>(request, OperationName);
                definition.Correlation.WorkflowId = workflowManager.WorkflowId;
            }
            catch (Exception exc)
            {
                throw exc;
            }
            return(response);
        }
Exemplo n.º 2
0
        internal static void initializeKnownTypes(IEnumerable <Type> knownTypesForDataContractSerializer)
        {
            //https://github.com/UiPath/corewf/blob/master/src/Test/TestFileInstanceStore/TestFileInstanceStore.cs
            _knownTypes = new List <Type>();

            System.Reflection.Assembly sysActivitiesAssembly = typeof(Activity).GetTypeInfo().Assembly;
            Type[] typesArray = sysActivitiesAssembly.GetTypes();

            // Remove types that are not decorated with a DataContract attribute
            foreach (Type t in typesArray)
            {
                TypeInfo typeInfo = t.GetTypeInfo();
                if (typeInfo.GetCustomAttribute <System.Runtime.Serialization.DataContractAttribute>() != null)
                {
                    _knownTypes.Add(t);
                }
            }

            if (knownTypesForDataContractSerializer != null)
            {
                foreach (Type knownType in knownTypesForDataContractSerializer)
                {
                    _knownTypes.Add(knownType);
                }
            }

            var conf = WorkflowActivator.GetScope().ServiceProvider.GetService <IConfiguration>();

            if (conf != null &&
                conf.GetSection("WorkflowSerialization:KnownTypes") != null &&
                conf.GetSection("WorkflowSerialization:KnownTypes").Exists() &&
                conf.GetSection("WorkflowSerialization:KnownTypes").Get <string[]>() != null)
            {
                var knownTypesConf = conf.GetSection("WorkflowSerialization:KnownTypes").Get <string[]>();

                foreach (string knownTypeConf in knownTypesConf)
                {
                    var t = sysActivitiesAssembly.GetType(knownTypeConf);
                    if (t != null)
                    {
                        _knownTypes.Add(t);
                    }
                }
            }

            //var t1 = sysActivitiesAssembly.GetType("System.Activities.Variable`1+VariableLocation[[System.Int32, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]");
            //_knownTypes.Add(t1);

            //_knownTypes.Add(typeof(WorkflowCorrelation));
        }