Esempio n. 1
0
        /// <summary>
        /// The NewTrace
        /// </summary>
        /// <typeparam name="TLinkData"></typeparam>
        /// <param name="input">The input<see cref="NewTraceInput{TLinkData}"/></param>
        /// <returns>The <see cref="Task{TraceState{TState, TLinkData}}"/></returns>
        public async Task <TraceState <TState, TLinkData> > NewTraceAsync <TLinkData>(NewTraceInput <TLinkData> input)
        {
            //extract info from input
            string    actionKey  = input.ActionKey;
            TLinkData data       = input.Data;
            string    groupLabel = input.GroupLabel;

            SdkConfig sdkConfig = await this.GetConfigAsync();

            string workflowId = sdkConfig.WorkflowId;
            string configId   = sdkConfig.ConfigId;
            string accountId  = sdkConfig.AccountId;
            string groupId    = sdkConfig.GetGroupId(groupLabel);

            // upload files and transform data
            await this.UploadFilesInLinkData(data);

            TraceLinkBuilderConfig <TLinkData> cfg = new TraceLinkBuilderConfig <TLinkData>()
            {
                WorkflowId = workflowId,
                // and workflow config id
                ConfigId = configId,
            };
            // use a TraceLinkBuilder to create the first link
            // only provide workflowId to initiate a new trace
            TraceLinkBuilder <TLinkData> linkBuilder = new TraceLinkBuilder <TLinkData>(cfg);

            // this is an attestation
            linkBuilder.ForAttestation(actionKey, data).WithGroup(groupId).WithCreatedBy(accountId);
            // call createLink helper
            return(await this.CreateLinkAsync(linkBuilder));
        }
Esempio n. 2
0
        /// <summary>
        /// The NewTrace
        /// </summary>
        /// <typeparam name="TLinkData"></typeparam>
        /// <param name="input">The input<see cref="NewTraceInput{TLinkData}"/></param>
        /// <returns>The <see cref="Task{TraceState{TState, TLinkData}}"/></returns>
        public async Task <TraceState <TState, TLinkData> > NewTraceAsync <TLinkData>(NewTraceInput <TLinkData> input)
        {
            //extract info from input
            string    formId = input.FormId;
            TLinkData data   = input.Data;

            SdkConfig sdkConfig = await this.GetConfigAsync();

            string workflowId = sdkConfig.WorkflowId;
            string userId     = sdkConfig.UserId;
            string ownerId    = sdkConfig.OwnerId;
            string groupId    = sdkConfig.GroupId;
            IDictionary <string, string> actionNames = sdkConfig.ActionNames;

            // upload files and transform data
            await this.UploadFilesInLinkData(data);

            TraceLinkBuilderConfig <TLinkData> cfg = new TraceLinkBuilderConfig <TLinkData>()
            {
                WorkflowId = workflowId
            };
            // use a TraceLinkBuilder to create the first link
            // only provide workflowId to initiate a new trace
            TraceLinkBuilder <TLinkData> linkBuilder = new TraceLinkBuilder <TLinkData>(cfg);

            var action = actionNames.ContainsKey(formId) ? actionNames[formId] : null;

            // this is an attestation
            linkBuilder.ForAttestation(formId, action, data).WithOwner(ownerId).WithGroup(groupId).WithCreatedBy(userId);
            // call createLink helper
            return(await this.CreateLinkAsync(linkBuilder));
        }
Esempio n. 3
0
        /// <summary>
        /// The AppendLink
        /// </summary>
        /// <typeparam name="TLinkData"></typeparam>
        /// <param name="input">The input<see cref="AppendLinkInput{TLinkData}"/></param>
        /// <returns>The <see cref="Task{TraceState{TState, TLinkData}}"/></returns>
        public async Task <TraceState <TState, TLinkData> > AppendLinkAsync <TLinkData>(AppendLinkInput <TLinkData> input)
        {
            // retrieve parent link
            TransferResponseInput <TLinkData> headLinkInput = new TransferResponseInput <TLinkData>(input.TraceId, null);
            TraceLink <TLinkData>             parentLink    = await this.GetHeadLinkAsync <TLinkData>(headLinkInput);

            //extract info from input
            string    actionKey  = input.ActionKey;
            TLinkData data       = input.Data;
            string    groupLabel = input.GroupLabel;

            SdkConfig sdkConfig = await this.GetConfigAsync();

            string workflowId = sdkConfig.WorkflowId;
            string configId   = sdkConfig.ConfigId;
            string accountId  = sdkConfig.AccountId;
            string groupId    = sdkConfig.GetGroupId(groupLabel);

            // upload files and transform data
            await this.UploadFilesInLinkData(data);

            TraceLinkBuilderConfig <TLinkData> cfg = new TraceLinkBuilderConfig <TLinkData>()
            {
                // provide workflow id
                WorkflowId = workflowId,
                // and workflow config id
                ConfigId = configId,
                // and parent link to append to the existing trace
                ParentLink = parentLink
            };
            // use a TraceLinkBuilder to create the first link
            // only provide workflowId to initiate a new trace
            TraceLinkBuilder <TLinkData> linkBuilder = new TraceLinkBuilder <TLinkData>(cfg);

            // this is an attestation
            linkBuilder.ForAttestation(actionKey, data)
            .WithGroup(groupId)
            .WithCreatedBy(accountId);
            // call createLink helper
            return(await this.CreateLinkAsync(linkBuilder));
        }
Esempio n. 4
0
        /// <summary>
        /// The AppendLink
        /// </summary>
        /// <typeparam name="TLinkData"></typeparam>
        /// <param name="input">The input<see cref="AppendLinkInput{TLinkData}"/></param>
        /// <returns>The <see cref="Task{TraceState{TState, TLinkData}}"/></returns>
        public async Task <TraceState <TState, TLinkData> > AppendLinkAsync <TLinkData>(AppendLinkInput <TLinkData> input)
        {
            // retrieve parent link
            TransferResponseInput <TLinkData> headLinkInput = new TransferResponseInput <TLinkData>(input.TraceId, null);
            TraceLink <TLinkData>             parentLink    = await this.GetHeadLinkAsync <TLinkData>(headLinkInput);

            //extract info from input
            string    formId = input.FormId;
            TLinkData data   = input.Data;

            SdkConfig sdkConfig = await this.GetConfigAsync();

            string workflowId = sdkConfig.WorkflowId;
            string userId     = sdkConfig.UserId;
            string ownerId    = sdkConfig.OwnerId;
            string groupId    = sdkConfig.GroupId;
            IDictionary <string, string> actionNames = sdkConfig.ActionNames;

            // upload files and transform data
            await this.UploadFilesInLinkData(data);

            TraceLinkBuilderConfig <TLinkData> cfg = new TraceLinkBuilderConfig <TLinkData>()
            {
                // provide workflow id
                WorkflowId = workflowId,
                // and parent link to append to the existing trace
                ParentLink = parentLink
            };
            // use a TraceLinkBuilder to create the first link
            // only provide workflowId to initiate a new trace
            TraceLinkBuilder <TLinkData> linkBuilder = new TraceLinkBuilder <TLinkData>(cfg);

            // this is an attestation
            linkBuilder.ForAttestation(formId, actionNames.ContainsKey(formId)?actionNames[formId]:null, data)
            .WithOwner(ownerId)
            .WithGroup(groupId)
            .WithCreatedBy(userId);
            // call createLink helper
            return(await this.CreateLinkAsync(linkBuilder));
        }