/**********************************************************************************/ private void LoadAndRunPlan(Guid planId) { var plan = ObjectFactory.GetInstance <IPlan>(); var planDO = _uow.PlanRepository.GetById <PlanDO>(planId); if (planDO == null) { throw new InvalidOperationException($"Plan {planId} was not found"); } var crateStorage = _crate.GetStorage(_container.CrateStorage); var operationStateCrate = crateStorage.CrateContentsOfType <OperationalStateCM>().Single(); operationStateCrate.CurrentActivityResponse = ActivityResponseDTO.Create(ActivityResponse.Null); operationStateCrate.History.Add(new OperationalStateCM.HistoryElement { Description = "Launch Triggered by Container ID " + _container.Id }); crateStorage.Remove <OperationalStateCM>(); var payloadCrates = crateStorage.AsEnumerable().ToArray(); plan.Enqueue(planDO.Id, payloadCrates); }
protected override async Task RunCurrentActivity() { var crate = FindCrateToProcess(CurrentPayloadStorage); var payloadObjects = new List <PayloadObjectDTO>(); if (crate.IsOfType <StandardTableDataCM>()) { var table = crate.Get <StandardTableDataCM>(); if (table.FirstRowHeaders) { payloadObjects.AddRange( table.DataRows.Select(x => new PayloadObjectDTO(x.Row.Select(y => y.Cell))) ); } } CurrentPayloadStorage.Add( Fr8Data.Crates.Crate.FromContent( "Sql Query Result", new StandardPayloadDataCM { PayloadObjects = payloadObjects } ) ); OperationalState.CurrentActivityResponse = ActivityResponseDTO.Create(ActivityResponse.ExecuteClientActivity); OperationalState.CurrentClientActivityName = "ShowTableReport"; await Task.Yield(); }
/**********************************************************************************/ protected void SetResponse(ActivityResponse response, string message = null, object details = null) { OperationalState.CurrentActivityResponse = ActivityResponseDTO.Create(response); if (!string.IsNullOrWhiteSpace(message) || details != null) { OperationalState.CurrentActivityResponse.AddResponseMessageDTO(new ResponseMessageDTO() { Message = message, Details = details }); } }
private void UpdateOperationCrate(string errorMessage = null) { Storage.RemoveByManifestId((int)MT.OperationalStatus); var operationalStatus = new OperationalStateCM { CurrentActivityResponse = ActivityResponseDTO.Create(ActivityResponse.ExecuteClientActivity), }; operationalStatus.CurrentActivityResponse.Body = "RunImmediately"; var operationsCrate = Crate.FromContent("Operational Status", operationalStatus); Storage.Add(operationsCrate); }
public override async Task FollowUp() { var activityTemplates = (await HubCommunicator.GetActivityTemplates(null, true)) .Select(Mapper.Map <ActivityTemplateDO>) .ToList(); try { var continueClicked = false; Storage.Remove <StandardQueryCM>(); await UpdatePlanName(); var queryCrate = ExtractQueryCrate(Storage); Storage.Add(queryCrate); var continueButton = GetControl <Button>("Continue"); if (continueButton != null) { continueClicked = continueButton.Clicked; if (continueButton.Clicked) { continueButton.Clicked = false; } } if (continueClicked) { ActivityPayload.ChildrenActivities.Clear(); var queryFr8WarehouseActivityTemplate = activityTemplates .FirstOrDefault(x => x.Name == "Query_Fr8_Warehouse"); if (queryFr8WarehouseActivityTemplate == null) { return; } var queryFr8WarehouseTemplate = await HubCommunicator.GetActivityTemplate("terminalFr8Core", "Query_Fr8_Warehouse"); var queryFr8WarehouseAction = await HubCommunicator.AddAndConfigureChildActivity(ActivityPayload, queryFr8WarehouseTemplate); var crateStorage = queryFr8WarehouseAction.CrateStorage; var upstreamManifestTypes = crateStorage .CrateContentsOfType <KeyValueListCM>(x => x.Label == "Upstream Crate ManifestType List") .FirstOrDefault(); var controls = crateStorage .CrateContentsOfType <StandardConfigurationControlsCM>() .FirstOrDefault(); var radioButtonGroup = controls .FindByName <RadioButtonGroup>("QueryPicker"); UpstreamCrateChooser upstreamCrateChooser = null; if (radioButtonGroup != null && radioButtonGroup.Radios.Count > 0 && radioButtonGroup.Radios[0].Controls.Count > 0) { upstreamCrateChooser = radioButtonGroup.Radios[0].Controls[0] as UpstreamCrateChooser; } if (upstreamCrateChooser != null) { if (upstreamManifestTypes != null) { upstreamCrateChooser.SelectedCrates[0].ManifestType.selectedKey = upstreamManifestTypes.Values[0].Key; upstreamCrateChooser.SelectedCrates[0].ManifestType.Value = upstreamManifestTypes.Values[0].Value; } upstreamCrateChooser.SelectedCrates[0].Label.selectedKey = QueryCrateLabel; upstreamCrateChooser.SelectedCrates[0].Label.Value = QueryCrateLabel; } queryFr8WarehouseAction = await HubCommunicator.ConfigureChildActivity( ActivityPayload, queryFr8WarehouseAction ); Storage.RemoveByManifestId((int)MT.OperationalStatus); var operationalStatus = new OperationalStateCM(); operationalStatus.CurrentActivityResponse = ActivityResponseDTO.Create(ActivityResponse.ExecuteClientActivity); operationalStatus.CurrentActivityResponse.Body = "RunImmediately"; var operationsCrate = Crate.FromContent("Operational Status", operationalStatus); Storage.Add(operationsCrate); } } catch (Exception) { } }
/**********************************************************************************/ /// <summary> /// returns error to hub /// </summary> /// <param name="errorCode"></param> /// <param name="currentActivity">Activity where the error occured</param> /// <param name="currentTerminal">Terminal where the error occured</param> /// <param name="errorMessage"></param> /// <param name="errorType"></param> /// <returns></returns> protected void RaiseError(string errorMessage, ErrorType errorType, ActivityErrorCode?errorCode = null, string currentActivity = null, string currentTerminal = null) { OperationalState.CurrentActivityErrorCode = errorCode; OperationalState.CurrentActivityResponse = ActivityResponseDTO.Create(ActivityResponse.Error); OperationalState.CurrentActivityResponse.AddErrorDTO(ErrorDTO.Create(errorMessage, errorType, errorCode.ToString(), null, currentActivity, currentTerminal)); }