Beispiel #1
0
        private IEnumerable <ParameterDefinitionWithValue> GetPersistedProcessParameters(Guid processId, ProcessDefinition processDefinition)
        {
            var persistenceParameters = processDefinition.PersistenceParameters.ToList();
            var parameters            = new List <ParameterDefinitionWithValue>(persistenceParameters.Count());

            List <WorkflowProcessInstancePersistence> persistedParameters;

            using (PredefinedTransactionScopes.ReadUncommittedSupressedScope)
            {
                using (var context = CreateContext())
                {
                    persistedParameters =
                        context.WorkflowProcessInstancePersistences.Where(
                            wpip =>
                            wpip.ProcessId == processId).ToList();
                }
            }

            foreach (var persistedParameter in persistedParameters)
            {
                var parameterDefinition = persistenceParameters.FirstOrDefault(p => p.Name == persistedParameter.ParameterName);
                if (parameterDefinition == null)
                {
                    parameterDefinition = ParameterDefinition.Create(persistedParameter.ParameterName, "System.String", ParameterPurpose.Persistence.ToString(), null);
                }

                parameters.Add(ParameterDefinition.Create(parameterDefinition, _runtime.DeserializeParameter(persistedParameter.Value, parameterDefinition.Type)));
            }

            return(parameters);
        }
Beispiel #2
0
        private async Task <RawDataInformation[]> ListRawDataByUuidList(RawDataEntity entity, string[] uuids, FilterCondition filter, CancellationToken cancellationToken = default(CancellationToken))
        {
            StringUuidTools.CheckUuids(entity, uuids);

            var requestPath          = $"rawData/{entity}";
            var parameterDefinitions = new List <ParameterDefinition>();

            if (filter != null)
            {
                var filterTree      = filter.BuildFilterTree();
                var filterString    = new FilterTreeFormatter().FormatString(filterTree);
                var filterParameter = ParameterDefinition.Create("filter", filterString);
                parameterDefinitions.Add(filterParameter);
            }

            //Split into multiple parameter sets to limit uuid parameter lenght
            var splitter            = new ParameterSplitter(this, requestPath);
            var collectionParameter = CollectionParameterFactory.Create("uuids", uuids);
            var parameterSets       = splitter.SplitAndMerge(collectionParameter, parameterDefinitions);

            //Execute requests in parallel
            var requests = parameterSets
                           .Select(set => RequestBuilder.CreateGet(requestPath, set.ToArray()))
                           .Select(request => _RestClient.Request <RawDataInformation[]>(request, cancellationToken));
            var result = await Task.WhenAll(requests).ConfigureAwait(false);

            return(result.SelectMany(r => r).ToArray());
        }
Beispiel #3
0
        /// <inheritdoc/>
        public async Task ClearPart(Guid partUuid, IEnumerable <ClearPartKeepEntitiesDto> clearPartKeepEntities = null, CancellationToken cancellationToken = default)
        {
            var featureMatrix = await GetFeatureMatrixInternal(FetchBehavior.FetchIfNotCached, cancellationToken).ConfigureAwait(false);

            if (!featureMatrix.SupportClearPart)
            {
                throw new OperationNotSupportedOnServerException(
                          "Clearing a part is not supported by this server.",
                          DataServiceFeatureMatrix.ClearPartMinVersion,
                          featureMatrix.CurrentInterfaceVersion);
            }

            if (clearPartKeepEntities != null)
            {
                var clearPartListString = clearPartKeepEntities.Select(p => p.ToString());
                var keepRestriction     = RestClientHelper.ToListString(clearPartListString);
                var keepListParameter   = ParameterDefinition.Create("keep", keepRestriction);

                await _RestClient.Request(RequestBuilder.CreatePost($"parts/{partUuid}/clear", Payload.Empty, keepListParameter), cancellationToken).ConfigureAwait(false);
            }
            else
            {
                await _RestClient.Request(RequestBuilder.CreatePost($"parts/{partUuid}/clear", Payload.Empty), cancellationToken).ConfigureAwait(false);
            }
        }
        /// <summary>
        /// Fills persisted <see cref="ParameterPurpose.Persistence"/> parameters of the process
        /// </summary>
        /// <param name="processInstance">Instance of the process</param>
        public void FillPersistedProcessParameters(ProcessInstance processInstance)
        {
            var persistenceParameters = processInstance.ProcessScheme.PersistenceParameters.ToList();
            var parameters            = new List <ParameterDefinitionWithValue>(persistenceParameters.Count());

            var db = _connector.GetDatabase();
            var persistedParametersValue = db.StringGet(GetKeyForProcessPersistence(processInstance.ProcessId));

            if (!persistedParametersValue.HasValue)
            {
                return;
            }

            var persistedParameters = JsonConvert.DeserializeObject <Dictionary <string, string> >(persistedParametersValue);

            foreach (var persistedParameter in persistedParameters)
            {
                var parameterDefinition = persistenceParameters.FirstOrDefault(p => p.Name == persistedParameter.Key);
                if (parameterDefinition == null)
                {
                    parameterDefinition = ParameterDefinition.Create(persistedParameter.Key, "System.String", ParameterPurpose.Persistence.ToString(), null);
                }

                parameters.Add(ParameterDefinition.Create(parameterDefinition, _runtime.DeserializeParameter(persistedParameter.Value, parameterDefinition.Type)));
            }

            processInstance.AddParameters(parameters);
        }
Beispiel #5
0
        private IEnumerable <ParameterDefinitionWithValue> GetPersistedProcessParameters(Guid processId, ProcessDefinition processDefinition)
        {
            var persistenceParameters = processDefinition.PersistenceParameters.ToList();
            var parameters            = new List <ParameterDefinitionWithValue>(persistenceParameters.Count());

            List <WorkflowProcessInstancePersistence> persistedParameters;

            using (PredefinedTransactionScopes.ReadUncommittedSupressedScope)
            {
                using (var context = CreateContext())
                {
                    persistedParameters =
                        context.WorkflowProcessInstancePersistences.Where(
                            wpip =>
                            wpip.ProcessId == processId &&
                            persistenceParameters.Select(pp => pp.Name).Contains(wpip.ParameterName)).ToList();
                }
            }

            foreach (var persistedParameter in persistedParameters)
            {
                var parameterDefinition = persistenceParameters.Single(p => p.Name == persistedParameter.ParameterName);
                parameters.Add(ParameterDefinition.Create(parameterDefinition, _runtime.DeserializeParameter(persistedParameter.Value, parameterDefinition.Type)));
            }

            return(parameters);
        }
Beispiel #6
0
        /// <summary>
        /// Creates a <see cref="ParameterDefinition"/> list that represents this filter.
        /// </summary>
        public IEnumerable <ParameterDefinition> ToParameterDefinition()
        {
            var result = new List <ParameterDefinition>();

            if (Depth.HasValue)
            {
                result.Add(ParameterDefinition.Create(DepthParamName, Depth.ToString()));
            }

            if (WithHistory)
            {
                result.Add(ParameterDefinition.Create(WithHistoryParamName, WithHistory.ToString()));
            }

            if (PartUuids != null && PartUuids.Length > 0)
            {
                result.Add(ParameterDefinition.Create(PartUuidsParamName, RestClientHelper.ConvertGuidListToString(PartUuids)));
            }

            if (RequestedPartAttributes != null && RequestedPartAttributes.AllAttributes != AllAttributeSelection.True && RequestedPartAttributes.Attributes != null)
            {
                result.Add(ParameterDefinition.Create(RequestedPartAttributesParamName, RestClientHelper.ConvertUInt16ListToString(RequestedPartAttributes.Attributes)));
            }

            if (RequestedCharacteristicAttributes != null && RequestedCharacteristicAttributes.AllAttributes != AllAttributeSelection.True && RequestedCharacteristicAttributes.Attributes != null)
            {
                result.Add(ParameterDefinition.Create(RequestedCharacteristicsAttributesParamName, RestClientHelper.ConvertUInt16ListToString(RequestedCharacteristicAttributes.Attributes)));
            }

            return(result);
        }
        private IEnumerable <ParameterDefinitionWithValue> GetPersistedProcessParameters(Guid processId, ProcessDefinition processDefinition)
        {
            var persistenceParameters = processDefinition.PersistenceParameters.ToList();
            var parameters            = new List <ParameterDefinitionWithValue>(persistenceParameters.Count());

            List <WorkflowProcessInstancePersistence> persistedParameters;

            using (var session = Store.OpenSession())
            {
                var process = session.Load <WorkflowProcessInstance>(processId);
                if (process != null && process.Persistence != null)
                {
                    persistedParameters = process.Persistence;
                }
                else
                {
                    return(parameters);
                    //persistedParameters = new List<WorkflowProcessInstancePersistence>();
                }
            }

            foreach (var persistedParameter in persistedParameters)
            {
                var parameterDefinition = persistenceParameters.FirstOrDefault(p => p.Name == persistedParameter.ParameterName);
                if (parameterDefinition == null)
                {
                    parameterDefinition = ParameterDefinition.Create(persistedParameter.ParameterName, "System.String", ParameterPurpose.Persistence.ToString(), null);
                }

                parameters.Add(ParameterDefinition.Create(parameterDefinition, _runtime.DeserializeParameter(persistedParameter.Value, parameterDefinition.Type)));
            }

            return(parameters);
        }
Beispiel #8
0
        private List <ExecutionRequestParameters> FillExecutionRequestParameters(Guid processId, ProcessInstance processInstance, IEnumerable <TransitionDefinition> transitions)
        {
            var newExecutionParameters = new List <ExecutionRequestParameters>();

            foreach (var transition in transitions)
            {
                var parametersLocal = ExecutionRequestParameters.Create(processInstance.ProcessId,
                                                                        processInstance.ProcessParameters,
                                                                        transition, true);

                if (transition.Trigger.Type != TriggerType.Auto || transition.Restrictions.Count() > 0)
                {
                    var actors = GetActors(processId, transition);

                    parametersLocal.AddParameterInContainer(
                        ParameterDefinition.Create(DefaultDefinitions.ParameterIdentityIds,
                                                   actors));
                }

                if (transition.Trigger.Type == TriggerType.Command)
                {
                    parametersLocal.AddParameterInContainer(ParameterDefinition.Create(DefaultDefinitions.ParameterCurrentCommand, (object)transition.Trigger.Command.Name));
                }


                newExecutionParameters.Add(parametersLocal);
            }
            return(newExecutionParameters);
        }
Beispiel #9
0
        private IEnumerable <ParameterDefinitionWithValue> GetPersistedProcessParameters(Guid processId, ProcessDefinition processDefinition)
        {
            List <ParameterDefinition>                persistenceParameters = processDefinition.PersistenceParameters.ToList <ParameterDefinition>();
            List <ParameterDefinitionWithValue>       list = new List <ParameterDefinitionWithValue>(persistenceParameters.Count <ParameterDefinition>());
            List <WorkflowProcessInstancePersistence> list2;

            using (PredefinedTransactionScopes.ReadUncommittedSupressedScope)
            {
                using (WorkflowPersistenceModelDataContext workflowPersistenceModelDataContext = base.CreateContext())
                {
                    list2 = (
                        from wpip in workflowPersistenceModelDataContext.WorkflowProcessInstancePersistences
                        where wpip.ProcessId == processId && (
                            from pp in persistenceParameters
                            select pp.Name).Contains(wpip.ParameterName)
                        select wpip).ToList <WorkflowProcessInstancePersistence>();
                }
            }
            foreach (WorkflowProcessInstancePersistence persistedParameter in list2)
            {
                ParameterDefinition parameterDefinition = persistenceParameters.Single((ParameterDefinition p) => p.Name == persistedParameter.ParameterName);
                list.Add(ParameterDefinition.Create(parameterDefinition, this.DeserializeParameter(persistedParameter.Value, parameterDefinition.Type)));
            }
            return(list);
        }
Beispiel #10
0
        private IEnumerable <ParameterDefinitionWithValue> GetPersistedProcessParameters(Guid processId, ProcessDefinition processDefinition)
        {
            var persistenceParameters = processDefinition.PersistenceParameters.ToList();
            var parameters            = new List <ParameterDefinitionWithValue>(persistenceParameters.Count());

            List <WorkflowProcessInstancePersistence> persistedParameters;
            var dbcoll  = Store.GetCollection <WorkflowProcessInstance>(MongoDBConstants.WorkflowProcessInstanceCollectionName);
            var process = dbcoll.Find(x => x.Id == processId).FirstOrDefault();

            if (process != null && process.Persistence != null)
            {
                persistedParameters = process.Persistence.ToList();
            }
            else
            {
                return(parameters);
                //persistedParameters = new List<WorkflowProcessInstancePersistence>();
            }

            foreach (var persistedParameter in persistedParameters)
            {
                var parameterDefinition = persistenceParameters.FirstOrDefault(p => p.Name == persistedParameter.ParameterName);
                if (parameterDefinition == null)
                {
                    parameterDefinition = ParameterDefinition.Create(persistedParameter.ParameterName, typeof(UnknownParameterType), ParameterPurpose.Persistence);
                    parameters.Add(ParameterDefinition.Create(parameterDefinition, persistedParameter.Value));
                }
                else
                {
                    parameters.Add(ParameterDefinition.Create(parameterDefinition, ParametersSerializer.Deserialize(persistedParameter.Value, parameterDefinition.Type)));
                }
            }

            return(parameters);
        }
Beispiel #11
0
        private IEnumerable <ParameterDefinitionWithValue> GetPersistedProcessParameters(Guid processId, ProcessDefinition processDefinition)
        {
            var persistenceParameters = processDefinition.PersistenceParameters.ToList();
            var parameters            = new List <ParameterDefinitionWithValue>(persistenceParameters.Count());

            List <WorkflowProcessInstancePersistence> persistedParameters;

            using (var session = Store.OpenSession())
            {
                var process = session.Load <WorkflowProcessInstance>(processId);
                if (process != null && process.Persistence != null)
                {
                    persistedParameters = process.Persistence.Where(WorkflowProcessInstancep => persistenceParameters.Select(pp => pp.Name).Contains(WorkflowProcessInstancep.ParameterName)).ToList();
                }
                else
                {
                    persistedParameters = new List <WorkflowProcessInstancePersistence>();
                }
            }

            foreach (var persistedParameter in persistedParameters)
            {
                var parameterDefinition = persistenceParameters.Single(p => p.Name == persistedParameter.ParameterName);
                parameters.Add(ParameterDefinition.Create(parameterDefinition, _runtime.DeserializeParameter(persistedParameter.Value, parameterDefinition.Type)));
            }

            return(parameters);
        }
Beispiel #12
0
        private IEnumerable <ParameterDefinitionWithValue> GetPersistedProcessParameters(Guid processId, ProcessDefinition processDefinition)
        {
            var persistenceParameters = processDefinition.PersistenceParameters.ToList();
            var parameters            = new List <ParameterDefinitionWithValue>(persistenceParameters.Count());

            List <WorkflowProcessInstancePersistence> persistedParameters;

            var dbcoll = Store.GetCollection <WorkflowProcessInstance>(MongoDBConstants.WorkflowProcessInstanceCollectionName);

            {
                var process = dbcoll.FindOneById(processId);
                if (process != null && process.Persistence != null)
                {
                    persistedParameters = process.Persistence.Where(WorkflowProcessInstancep => persistenceParameters.Select(pp => pp.Name).Contains(WorkflowProcessInstancep.ParameterName)).ToList();
                }
                else
                {
                    persistedParameters = new List <WorkflowProcessInstancePersistence>();
                }
            }

            foreach (var persistedParameter in persistedParameters)
            {
                var parameterDefinition = persistenceParameters.Single(p => p.Name == persistedParameter.ParameterName);
                parameters.Add(ParameterDefinition.Create(parameterDefinition, _runtime.DeserializeParameter(persistedParameter.Value, parameterDefinition.Type)));
            }

            return(parameters);
        }
        private IEnumerable <ParameterDefinitionWithValue> GetPersistedProcessParameters(Guid processId, ProcessDefinition processDefinition)
        {
            var persistenceParameters = processDefinition.PersistenceParameters.ToList();
            var parameters            = new List <ParameterDefinitionWithValue>(persistenceParameters.Count());

            List <WorkflowProcessInstancePersistence> persistedParameters;
            var dbcoll  = Store.GetCollection <WorkflowProcessInstance>(MongoDBConstants.WorkflowProcessInstanceCollectionName);
            var process = dbcoll.FindOneById(processId);

            if (process != null && process.Persistence != null)
            {
                persistedParameters = process.Persistence.ToList();
            }
            else
            {
                persistedParameters = new List <WorkflowProcessInstancePersistence>();
            }

            foreach (var persistedParameter in persistedParameters)
            {
                var parameterDefinition = persistenceParameters.FirstOrDefault(p => p.Name == persistedParameter.ParameterName);
                if (parameterDefinition == null)
                {
                    parameterDefinition = ParameterDefinition.Create(persistedParameter.ParameterName, "System.String", ParameterPurpose.Persistence.ToString(), null);
                }
                parameters.Add(ParameterDefinition.Create(parameterDefinition, _runtime.DeserializeParameter(persistedParameter.Value, parameterDefinition.Type)));
            }

            return(parameters);
        }
Beispiel #14
0
        private IEnumerable <ParameterDefinitionWithValue> GetPersistedProcessParameters(Guid processId, ProcessDefinition processDefinition)
        {
            var persistenceParameters = processDefinition.PersistenceParameters.ToList();
            var parameters            = new List <ParameterDefinitionWithValue>(persistenceParameters.Count());

            List <WorkflowProcessInstancePersistence> persistedParameters;

            using (var connection = new NpgsqlConnection(ConnectionString))
            {
                persistedParameters = WorkflowProcessInstancePersistence.SelectByProcessId(connection, processId).ToList();
            }

            foreach (var persistedParameter in persistedParameters)
            {
                var parameterDefinition = persistenceParameters.FirstOrDefault(p => p.Name == persistedParameter.ParameterName);
                if (parameterDefinition == null)
                {
                    parameterDefinition = ParameterDefinition.Create(persistedParameter.ParameterName, typeof(UnknownParameterType), ParameterPurpose.Persistence);
                    parameters.Add(ParameterDefinition.Create(parameterDefinition, persistedParameter.Value));
                }
                else
                {
                    parameters.Add(ParameterDefinition.Create(parameterDefinition, ParametersSerializer.Deserialize(persistedParameter.Value, parameterDefinition.Type)));
                }
            }

            return(parameters);
        }
Beispiel #15
0
        private async Task <DataMeasurementDto[]> GetMeasurementValuesSplitByMeasurement(PathInformationDto partPath, MeasurementValueFilterAttributesDto filter, CancellationToken cancellationToken)
        {
            var newFilter = filter.Clone();

            newFilter.MeasurementUuids = null;

            var parameter = CreateParameterDefinitions(partPath, newFilter);

            parameter.Add(ParameterDefinition.Create(AbstractMeasurementFilterAttributesDto.MeasurementUuidsParamName, ""));

            var requestRestriction = RequestBuilder.AppendParameters("values", parameter);
            var targetSize         = RestClientHelper.GetUriTargetSize(ServiceLocation, requestRestriction, MaxUriLength);

            var result = new List <DataMeasurementDto>(filter.MeasurementUuids.Length);

            foreach (var uuids in ArrayHelper.Split(filter.MeasurementUuids, targetSize, RestClientHelper.LengthOfListElementInUri))
            {
                newFilter.MeasurementUuids = uuids;
                if (newFilter.CharacteristicsUuidList?.Length > 0)
                {
                    result.AddRange(await GetMeasurementValuesSplitByCharacteristics(partPath, newFilter, cancellationToken).ConfigureAwait(false));
                }
                else
                {
                    result.AddRange(await _RestClient.Request <DataMeasurementDto[]>(RequestBuilder.CreateGet("values", CreateParameterDefinitions(partPath, newFilter).ToArray()), cancellationToken).ConfigureAwait(false));
                }
            }

            return(result.ToArray());
        }
        private IEnumerable <ParameterDefinitionWithValue> GetPersistedProcessParameters(Guid processId,
                                                                                         ProcessDefinition processDefinition)
        {
            var persistenceParameters = processDefinition.PersistenceParameters.ToList();
            var parameters            = new List <ParameterDefinitionWithValue>(persistenceParameters.Count());

            List <WorkflowProcessInstancePersistence> persistedParameters;
            var cache =
                Store.GetOrCreateCache <Guid, WorkflowProcessInstance>(IgniteConstants.WorkflowProcessInstanceCacheName);
            var process = cache.Get(processId);

            if (process != null && process.Persistence != null)
            {
                persistedParameters = process.Persistence.ToList();
            }
            else
            {
                return(parameters);
                //persistedParameters = new List<WorkflowProcessInstancePersistence>();
            }

            foreach (var persistedParameter in persistedParameters)
            {
                var parameterDefinition =
                    persistenceParameters.FirstOrDefault(p => p.Name == persistedParameter.ParameterName) ??
                    ParameterDefinition.Create(persistedParameter.ParameterName, "System.String",
                                               ParameterPurpose.Persistence.ToString(), null);
                parameters.Add(ParameterDefinition.Create(parameterDefinition,
                                                          _runtime.DeserializeParameter(persistedParameter.Value, parameterDefinition.Type)));
            }

            return(parameters);
        }
Beispiel #17
0
        private IEnumerable <ParameterDefinitionWithValue> GetPersistedProcessParameters(Guid processId, ProcessDefinition processDefinition)
        {
            var persistenceParameters = processDefinition.PersistenceParameters.ToList();
            var parameters            = new List <ParameterDefinitionWithValue>(persistenceParameters.Count());

            List <WorkflowProcessInstancePersistence> persistedParameters;

            using (MySqlConnection connection = new MySqlConnection(ConnectionString))
            {
                persistedParameters = WorkflowProcessInstancePersistence.SelectByProcessId(connection, processId).ToList();
            }

            foreach (var persistedParameter in persistedParameters)
            {
                var parameterDefinition = persistenceParameters.FirstOrDefault(p => p.Name == persistedParameter.ParameterName);
                if (parameterDefinition == null)
                {
                    parameterDefinition = ParameterDefinition.Create(persistedParameter.ParameterName, "System.String", ParameterPurpose.Persistence.ToString(), null);
                }

                parameters.Add(ParameterDefinition.Create(parameterDefinition, _runtime.DeserializeParameter(persistedParameter.Value, parameterDefinition.Type)));
            }

            return(parameters);
        }
        private IEnumerable <ParameterDefinitionWithValue> GetSystemProcessParameters(Guid processId,
                                                                                      ProcessDefinition processDefinition)
        {
            var processInstance = GetProcessInstance(processId);

            var systemParameters =
                processDefinition.Parameters.Where(p => p.Purpose == ParameterPurpose.System).ToList();

            var parameters = new List <ParameterDefinitionWithValue>(systemParameters.Count)
            {
                ParameterDefinition.Create(
                    systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterProcessId.Name),
                    processId),
                ParameterDefinition.Create(
                    systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterPreviousState.Name),
                    processInstance.PreviousState),
                ParameterDefinition.Create(
                    systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterCurrentState.Name),
                    processInstance.StateName),
                ParameterDefinition.Create(
                    systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterPreviousStateForDirect.Name),
                    processInstance.PreviousStateForDirect),
                ParameterDefinition.Create(
                    systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterPreviousStateForReverse.Name),
                    processInstance.PreviousStateForReverse),
                ParameterDefinition.Create(
                    systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterPreviousActivity.Name),
                    processInstance.PreviousActivity),
                ParameterDefinition.Create(
                    systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterCurrentActivity.Name),
                    processInstance.ActivityName),
                ParameterDefinition.Create(
                    systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterPreviousActivityForDirect.Name),
                    processInstance.PreviousActivityForDirect),
                ParameterDefinition.Create(
                    systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterPreviousActivityForReverse.Name),
                    processInstance.PreviousActivityForReverse),
                ParameterDefinition.Create(
                    systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterSchemeCode.Name),
                    processDefinition.Name),
                ParameterDefinition.Create(
                    systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterSchemeId.Name),
                    processInstance.SchemeId),
                ParameterDefinition.Create(
                    systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterIsPreExecution.Name),
                    false),
                ParameterDefinition.Create(
                    systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterParentProcessId.Name),
                    processInstance.ParentProcessId),
                ParameterDefinition.Create(
                    systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterRootProcessId.Name),
                    processInstance.RootProcessId),
                ParameterDefinition.Create(
                    systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterTenantId.Name),
                    processInstance.TenantId)
            };

            return(parameters);
        }
        /// <summary>
        /// Creates a CollectionParameter that can be split.
        /// </summary>
        /// <param name="name">Name of the collection parameter, e.g. 'uuids'</param>
        /// <param name="values">The separate values as string.</param>
        /// <param name="toStringConverter">A function to convert the parameter list to a string</param>
        internal CollectionParameterDefinition(string name, IEnumerable <T> values, Func <IEnumerable <T>, string> toStringConverter)
        {
            Name               = name;
            Values             = values;
            _ToStringConverter = toStringConverter;

            Empty = ParameterDefinition.Create(Name, EmptyCollectionString);
        }
Beispiel #20
0
        public override IEnumerable <ActionDefinition> ParseActions(XElement schemeMedium, IEnumerable <ParameterDefinition> parameterDefinitions)
        {
            if (schemeMedium == null)
            {
                throw new ArgumentNullException("schemeMedium");
            }
            if (parameterDefinitions == null)
            {
                throw new ArgumentNullException("parameterDefinitions");
            }
            var actionElements = schemeMedium.SingleOrDefault("Actions");

            if (actionElements == null)
            {
                throw new ArgumentNullException("");
            }

            var parameterDefinitionsList = parameterDefinitions.ToList();

            var actions = new List <ActionDefinition>();

            foreach (var element in actionElements.Elements().ToList())
            {
                var executeMethodElement = element.Elements("ExecuteMethod").Single();

                var action = ActionDefinition.Create(GetName(element), GetType(executeMethodElement), GetMethodName(executeMethodElement));


                var inputParameters = executeMethodElement.Elements("InputParameters").SingleOrDefault();

                if (inputParameters != null)
                {
                    foreach (var xmlInputParameter in inputParameters.Elements())
                    {
                        var parameterRef       = parameterDefinitionsList.Single(pd => pd.Name == GetNameRef(xmlInputParameter));
                        var parameterForAction = ParameterDefinition.Create(parameterRef, GetOrder(xmlInputParameter));
                        action.AddInputParameterRef(parameterForAction);
                    }
                }

                var outputParameters = executeMethodElement.Elements("OutputParameters").SingleOrDefault();

                if (outputParameters != null)
                {
                    foreach (var xmlOutputParameter in outputParameters.Elements())
                    {
                        var parameterRef =
                            parameterDefinitionsList.Single(pd => pd.Name == GetNameRef(xmlOutputParameter));
                        var parameterForAction = ParameterDefinition.Create(parameterRef, GetOrder(xmlOutputParameter));
                        action.AddOutputParameterRef(parameterForAction);
                    }
                }

                actions.Add(action);
            }

            return(actions);
        }
Beispiel #21
0
        private void SetStateWithExecution(Guid identityId,
                                           Guid impersonatedIdentityId,
                                           IDictionary <string, object> parameters,
                                           ActivityDefinition activityToSet,
                                           ProcessInstance processInstance)
        {
            SetProcessNewStatus(processInstance, ProcessStatus.Running);

            IEnumerable <TransitionDefinition> transitions;


            try
            {
                PersistenceProvider.FillSystemProcessParameters(processInstance);
                PersistenceProvider.FillPersistedProcessParameters(processInstance);

                var parametersLocal = new List <ParameterDefinitionWithValue>();
                foreach (var commandParameter in parameters)
                {
                    var parameterDefinition = processInstance.ProcessScheme.GetParameterDefinition(commandParameter.Key);

                    if (parameterDefinition != null)
                    {
                        parametersLocal.Add(ParameterDefinition.Create(parameterDefinition, commandParameter.Value));
                    }
                }
                parametersLocal.Add(ParameterDefinition.Create(DefaultDefinitions.ParameterCurrentCommand,
                                                               (object)DefaultDefinitions.CommandSetState.Name));
                parametersLocal.Add(ParameterDefinition.Create(DefaultDefinitions.ParameterIdentityId, identityId));
                parametersLocal.Add(ParameterDefinition.Create(DefaultDefinitions.ParameterImpersonatedIdentityId,
                                                               impersonatedIdentityId));
                parametersLocal.Add(ParameterDefinition.Create(DefaultDefinitions.ParameterSchemeId, processInstance.SchemeId));

                parametersLocal.ForEach(processInstance.AddParameter);
            }
            catch (Exception)
            {
                SetProcessNewStatus(processInstance, ProcessStatus.Idled);
                throw;
            }

            //TODO Убрать после обработки команд
            try
            {
                Bus.QueueExecution(ExecutionRequestParameters.Create(processInstance.ProcessId,
                                                                     processInstance.ProcessParameters,
                                                                     activityToSet,
                                                                     ConditionDefinition.Always));
            }
            catch (Exception ex)
            {
                Logger.Log.Error(string.Format("Workflow Id={0}", processInstance.ProcessId), ex);
                SetProcessNewStatus(processInstance, ProcessStatus.Idled);
                throw;
            }
        }
Beispiel #22
0
        /// <summary>
        /// Creates a <see cref="ParameterDefinition"/> list that represents this filter.
        /// </summary>
        public ParameterDefinition[] ToParameterDefinition()
        {
            var result = new List <ParameterDefinition>();

            if (Deep)
            {
                result.Add(ParameterDefinition.Create(DeepParamName, Deep.ToString()));
            }

            if (LimitResult >= 0)
            {
                result.Add(ParameterDefinition.Create(LimitResultParamName, LimitResult.ToString()));
            }

            if (MeasurementUuids != null && MeasurementUuids.Length > 0)
            {
                result.Add(ParameterDefinition.Create(MeasurementUuidsParamName, RestClientHelper.ConvertGuidListToString(MeasurementUuids)));
            }

            if (RequestedMeasurementAttributes != null && RequestedMeasurementAttributes.AllAttributes != AllAttributeSelection.True && RequestedMeasurementAttributes.Attributes != null)
            {
                result.Add(ParameterDefinition.Create(RequestedMeasurementAttributesParamName, RestClientHelper.ConvertUInt16ListToString(RequestedMeasurementAttributes.Attributes)));
            }

            if (OrderBy != null && OrderBy.Length > 0)
            {
                result.Add(ParameterDefinition.Create(OrderByParamName, OrderByToString(OrderBy)));
            }

            if (SearchCondition != null)
            {
                result.Add(ParameterDefinition.Create(SearchConditionParamName, SearchConditionParser.GenericConditionToString(SearchCondition)));
            }

            if (Statistics != MeasurementStatistics.None)
            {
                result.Add(ParameterDefinition.Create(StatisticsParamName, Statistics.ToString()));
            }

            if (AggregationMeasurements != AggregationMeasurementSelection.Default)
            {
                result.Add(ParameterDefinition.Create(AggregationParamName, AggregationMeasurements.ToString()));
            }

            if (FromModificationDate.HasValue)
            {
                result.Add(ParameterDefinition.Create(FromModificationDateParamName, XmlConvert.ToString(FromModificationDate.Value, XmlDateTimeSerializationMode.RoundtripKind)));
            }

            if (ToModificationDate.HasValue)
            {
                result.Add(ParameterDefinition.Create(ToModificationDateParamName, XmlConvert.ToString(ToModificationDate.Value, XmlDateTimeSerializationMode.RoundtripKind)));
            }

            return(result.ToArray());
        }
Beispiel #23
0
        public override void RegisterFinal(ProcessDefinition pd, List <WorkflowBlock> blocks)
        {
            base.RegisterFinal(pd, blocks);

            //transitions
            var commands = this["Commands"] as List <SimpleCommand>;

            if (commands != null)
            {
                var restrictions = new List <RestrictionDefinition>();
                if (this["_actorRestrictions"] is ActorDefinition)
                {
                    restrictions.Add(RestrictionDefinition.Create(RestrictionType.Allow, (ActorDefinition)this["_actorRestrictions"]));
                }

                foreach (var c in commands)
                {
                    var pdCommand = pd.Commands.Where(pdc => pdc.Name == c.Name).FirstOrDefault();
                    if (pdCommand == null)
                    {
                        pdCommand = CommandDefinition.Create(c.Name);

                        ParameterDefinition pdParameterComment = pd.Parameters.Where(p => p.Name == "Comment").FirstOrDefault();
                        if (pdParameterComment == null)
                        {
                            pdParameterComment = ParameterDefinition.Create("Comment", typeof(string), ParameterPurpose.Temporary, null);
                            pd.Parameters.Add(pdParameterComment);
                        }

                        pdCommand.InputParameters.Add(new ParameterDefinitionReference()
                        {
                            Name      = "Comment",
                            Parameter = pdParameterComment
                        });
                        pd.Commands.Add(pdCommand);
                    }

                    pd.Transitions.Add(new TransitionDefinition()
                    {
                        Name       = string.Format("{0}_{1}_{2}", Name, c.ToBlock.Name, c.Name),
                        Classifier = c.Classifier,
                        From       = (ActivityDefinition)this["_currentActivity"],
                        To         = (ActivityDefinition)c.ToBlock["_currentActivity"],
                        Trigger    = new TriggerDefinition(TriggerType.Command)
                        {
                            Command = pdCommand
                        },
                        Conditions = new List <ConditionDefinition>()
                        {
                            ConditionDefinition.Always
                        },
                        Restrictions = restrictions
                    });
                }
            }
        }
Beispiel #24
0
        /// <inheritdoc />
        /// <exception cref="ArgumentNullException"><paramref name="characteristics"/> is <see langword="null"/>.</exception>
        public Task UpdateCharacteristics(InspectionPlanCharacteristicDto[] characteristics, bool versioningEnabled = false, CancellationToken cancellationToken = default)
        {
            if (characteristics == null)
            {
                throw new ArgumentNullException(nameof(characteristics));
            }
            var parameter = ParameterDefinition.Create("versioningEnabled", versioningEnabled.ToString());

            return(_RestClient.Request(RequestBuilder.CreatePut("characteristics", Payload.Create(characteristics), parameter), cancellationToken));
        }
Beispiel #25
0
        /// <inheritdoc />
        /// <exception cref="ArgumentNullException"><paramref name="charPath"/> is <see langword="null"/>.</exception>
        public Task DeleteCharacteristics(PathInformationDto charPath, CancellationToken cancellationToken = default)
        {
            if (charPath == null)
            {
                throw new ArgumentNullException(nameof(charPath));
            }
            var parameter = ParameterDefinition.Create("charPath", PathHelper.PathInformation2DatabaseString(charPath));

            return(_RestClient.Request(RequestBuilder.CreateDelete("characteristics", parameter), cancellationToken));
        }
Beispiel #26
0
        /// <summary>
        /// Parses inspection plan filter criterias to a <see cref="ParameterDefinition"/> list.
        /// </summary>
        /// <param name="partPath">Path of the part the query should be restricted by.</param>
        /// <param name="partUuids">Uuids of the parts the query should be restricted by.</param>
        /// <param name="charUuids">Uuids of the parts the query should be restricted by.</param>
        /// <param name="depth">The depth determines how deep the response should be.</param>
        /// <param name="requestedPartAttributes">Restricts the part attributes that are returned.</param>
        /// <param name="requestedCharacteristicAttributes">Restricts the characteristic attributes that are returned.</param>
        /// <param name="withHistory">Determines if the history should be returned.</param>
        /// <returns></returns>
        public static List <ParameterDefinition> ParseToParameter(PathInformationDto partPath = null, Guid[] partUuids = null, Guid[] charUuids = null, ushort?depth = null, AttributeSelector requestedPartAttributes = null, AttributeSelector requestedCharacteristicAttributes = null, bool withHistory = false)
        {
            var parameter = new List <ParameterDefinition>();

            if (partPath != null)
            {
                parameter.Add(ParameterDefinition.Create("partPath", PathHelper.PathInformation2DatabaseString(partPath)));
            }

            if (depth.HasValue)
            {
                parameter.Add(ParameterDefinition.Create("depth", depth.ToString()));
            }

            if (withHistory)
            {
                parameter.Add(ParameterDefinition.Create("withHistory", true.ToString()));
            }

            if (partUuids != null && partUuids.Length > 0)
            {
                parameter.Add(ParameterDefinition.Create("partUuids", ConvertGuidListToString(partUuids)));
            }

            if (charUuids != null && charUuids.Length > 0)
            {
                parameter.Add(ParameterDefinition.Create("charUuids", ConvertGuidListToString(charUuids)));
            }

            if (requestedPartAttributes != null)
            {
                if (requestedPartAttributes.AllAttributes != AllAttributeSelectionDto.True && requestedPartAttributes.Attributes != null)
                {
                    parameter.Add(ParameterDefinition.Create("requestedPartAttributes", ConvertUshortArrayToString(requestedPartAttributes.Attributes)));
                }
                else if (requestedPartAttributes.AllAttributes == AllAttributeSelectionDto.False)
                {
                    parameter.Add(ParameterDefinition.Create("requestedPartAttributes", "None"));
                }
            }

            if (requestedCharacteristicAttributes != null)
            {
                if (requestedCharacteristicAttributes.AllAttributes != AllAttributeSelectionDto.True && requestedCharacteristicAttributes.Attributes != null)
                {
                    parameter.Add(ParameterDefinition.Create("requestedCharacteristicAttributes", ConvertUshortArrayToString(requestedCharacteristicAttributes.Attributes)));
                }
                else if (requestedCharacteristicAttributes.AllAttributes == AllAttributeSelectionDto.False)
                {
                    parameter.Add(ParameterDefinition.Create("requestedCharacteristicAttributes", "None"));
                }
            }

            return(parameter);
        }
Beispiel #27
0
        /// <inheritdoc />
        public async Task DeleteCharacteristics(Guid[] charUuid, CancellationToken cancellationToken = default)
        {
            const string requestPath = "characteristics";
            var          targetSize  = RestClientHelper.GetUriTargetSize(ServiceLocation, requestPath, MaxUriLength, ParameterDefinition.Create("charUuids", "{}"));

            foreach (var uuidList in ArrayHelper.Split(charUuid, targetSize, RestClientHelper.LengthOfListElementInUri))
            {
                var uuidListParameter = ParameterDefinition.Create("charUuids", RestClientHelper.ConvertGuidListToString(uuidList));
                await _RestClient.Request(RequestBuilder.CreateDelete(requestPath, uuidListParameter), cancellationToken).ConfigureAwait(false);
            }
        }
Beispiel #28
0
        private void FillParameters(ProcessInstance instance, ExecutionResponseParametersComplete newParameters)
        {
            foreach (var parameter in newParameters.ParameterContainer)
            {
                var parameterDefinition = instance.ProcessScheme.GetNullableParameterDefinition(parameter.Name);
                if (parameterDefinition != null)
                {
                    var parameterDefinitionWithValue = ParameterDefinition.Create(parameterDefinition, parameter.Value);

                    instance.AddParameter(parameterDefinitionWithValue);
                }
            }
        }
Beispiel #29
0
        /// <inheritdoc />
        public async Task DeleteMeasurementsByUuid(Guid[] measurementUuids, CancellationToken cancellationToken = default)
        {
            if (measurementUuids.Any())
            {
                var emptyParameter     = new[] { ParameterDefinition.Create("measurementUuids", "") };
                var requestRestriction = RequestBuilder.AppendParameters("measurements", emptyParameter);

                var targetSize = RestClientHelper.GetUriTargetSize(ServiceLocation, requestRestriction, MaxUriLength);

                foreach (var uuids in ArrayHelper.Split(measurementUuids, targetSize, RestClientHelper.LengthOfListElementInUri))
                {
                    var parameter = ParameterDefinition.Create("measurementUuids", RestClientHelper.ConvertGuidListToString(uuids));
                    await _RestClient.Request(RequestBuilder.CreateDelete("measurements", parameter), cancellationToken).ConfigureAwait(false);
                }
            }
        }
Beispiel #30
0
        private Task <RawDataInformation[]> ListRawDataForAllEntities(RawDataEntity entity, [NotNull] FilterCondition filter, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (filter == null)
            {
                throw new ArgumentNullException(nameof(filter));
            }

            var requestPath = $"rawData/{entity}";

            var parameterDefinitionList = new List <ParameterDefinition>();
            var filterTree      = filter.BuildFilterTree();
            var filterString    = new FilterTreeFormatter().FormatString(filterTree);
            var filterParameter = ParameterDefinition.Create("filter", filterString);

            parameterDefinitionList.Add(filterParameter);

            return(_RestClient.Request <RawDataInformation[]>(RequestBuilder.CreateGet(requestPath, parameterDefinitionList.ToArray()), cancellationToken));
        }