/// <summary> /// Initializes a new instance of the <see cref="TraceLinkBuilder{TLinkData}"/> class. /// </summary> /// <param name="cfg"> the config to instantiate the builder </param> public TraceLinkBuilder(TraceLinkBuilderConfig <TLinkData> cfg) : base( cfg.WorkflowId, (cfg.ParentLink != null ? cfg.ParentLink.TraceId() : Guid.NewGuid().ToString())) { // trace id is either retrieved from parent link when it is provided // or set to a new uuid. // set the parent link this.parentLink = (TraceLink <TLinkData>)cfg.ParentLink; // degree is always 1 base.WithDegree(1); // set priority to 1 by default // may be overriden if parent link was provided base.WithPriority(1); // set the created at timestamp this.metadata = new TraceLinkMetaData(); this.metadata.CreatedAt = DateTime.Now; // if parent link was provided set the parent hash and priority if (this.parentLink != null) { base.WithPriority(this.parentLink.Priority() + 1).WithParent(this.parentLink.Hash()); } }
public async Task <TraceState <TState, TLinkData> > CancelTransferAsync <TLinkData>(TransferResponseInput <TLinkData> input) { // retrieve parent link TransferResponseInput <TLinkData> headLinkInput = new TransferResponseInput <TLinkData>(input.TraceId, null); TraceLink <TLinkData> parentLink = await this.GetHeadLinkAsync <TLinkData>(headLinkInput); TLinkData data = input.Data; SdkConfig sdkConfig = await this.GetConfigAsync(); String workflowId = sdkConfig.WorkflowId; String configId = sdkConfig.ConfigId; String accountId = sdkConfig.AccountId; 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); linkBuilder // this is to cancel the transfer .ForCancelTransfer(data) // add creator info .WithCreatedBy(accountId); // call createLink helper return(await this.CreateLinkAsync(linkBuilder)); }
/// <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)); }
/// <summary> /// The PullTrace /// </summary> /// <typeparam name="TLinkData"></typeparam> /// <param name="input">The input<see cref="PullTransferInput{TLinkData}"/></param> /// <returns>The <see cref="Task{TraceState{TState, TLinkData}}"/></returns> public async Task <TraceState <TState, TLinkData> > PullTraceAsync <TLinkData>(PullTransferInput <TLinkData> input) { // retrieve parent link TransferResponseInput <TLinkData> headLinkInput = new TransferResponseInput <TLinkData>(input.TraceId, null); TraceLink <TLinkData> parentLink = await this.GetHeadLinkAsync <TLinkData>(headLinkInput); TLinkData data = input.Data; SdkConfig sdkConfig = await this.GetConfigAsync(); string workflowId = sdkConfig.WorkflowId; string userId = sdkConfig.UserId; string groupId = sdkConfig.GroupId; 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 a push transfer linkBuilder.ForPullTransfer(groupId, data).WithCreatedBy(userId); // call createLink helper return(await this.CreateLinkAsync(linkBuilder)); }
/// <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)); }
/// <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)); }
/// <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)); }
public async Task <TraceState <TState, TLinkData> > AcceptTransferAsync <TLinkData>(TransferResponseInput <TLinkData> input) { // retrieve parent link TraceLink <TLinkData> parentLink = await this.GetHeadLinkAsync(input); //extract info from input 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); 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.ForAcceptTransfer(data) // add group info .WithGroup(groupId) // add creator info .WithCreatedBy(accountId); // call createLink helper return(await CreateLinkAsync(linkBuilder)); }