public override void ValidateParameters(IProcessExecutionContext executionContext, ISerializedParameters parameters) { if (!parameters.ContainsKey("ContactActionName") || string.IsNullOrEmpty(parameters["ContactActionName"])) { throw new Exception("CustomerRecordActionEvaluator requires a parameter for ContactActionName."); } if (!parameters.ContainsKey("AccountActionName") || string.IsNullOrEmpty(parameters["AccountActionName"])) { throw new Exception("CustomerRecordActionEvaluator requires a parameter for AccountActionName."); } }
public override void ValidateParameters(IProcessExecutionContext executionContext, ISerializedParameters parameters) { if (!parameters.ContainsKey("FetchXml") || string.IsNullOrEmpty(parameters["FetchXml"])) { throw new Exception("DataRecordQueryMatchEvalautor requires a parameter for FetchXml."); } }
public override void ValidateStepParameters(IProcessExecutionContext executionContext, ISerializedParameters parameters) { if (!parameters.ContainsKey(feeParameter) || string.IsNullOrEmpty(parameters[feeParameter])) { throw new Exception(string.Format("AddFee required parameter '{0}'.", feeParameter)); } }
public void ValidateParameters(IProcessExecutionContext executionContext, ISerializedParameters parameters) { if (!parameters.ContainsKey("EvaluateAs")) { throw new Exception("FakeLogicEvaluatorType requires a parameter named 'EvaluateAs' that contains a boolean value."); } }
public override void ValidateStepParameters(IProcessExecutionContext executionContext, ISerializedParameters parameters) { if (!parameters.ContainsKey("ActionName") || string.IsNullOrEmpty(parameters["ActionName"])) { throw new Exception("DataRecordAction requires a parameter for ActionName."); } }
public override void Execute(IProcessExecutionContext executionContext, IWorkSession session, ITransaction transaction, ISerializedParameters parameters) { try { if (!parameters.ContainsKey("ActionName")) { throw new Exception("DataRecordAction requires a parameter for ActionName"); } var dataRecord = transaction.DataRecord; var req = new OrganizationRequest(parameters["ActionName"]); req["Target"] = new EntityReference(dataRecord.RecordType, dataRecord.Id); req["Transaction"] = transaction.ToEntityReference(); //process any additional parameter data passed in from the configuration. if (parameters.Count > 1) { foreach (var key in parameters.Keys) { if (key != "ActionName" && !string.IsNullOrEmpty(parameters[key])) { req[key] = parameters[key]; } } } executionContext.DataService.ToOrgService().Execute(req); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public override void ValidateStepParameters(IProcessExecutionContext executionContext, ISerializedParameters parameters) { if (!parameters.ContainsKey("FormId") || string.IsNullOrEmpty(parameters["FormId"])) { throw new Exception("Entity Data Capture step requires parameter 'FormId'"); } }
public override void Execute(IProcessExecutionContext executionContext, IWorkSession session, ITransaction transaction, ISerializedParameters parameters) { var feeNumber = parameters[feeParameter]; var quantity = int.Parse(parameters.ContainsKey(feeQuantity) ? parameters[feeQuantity] : "1"); var feeList = executionContext.Container.Resolve <IFeeList>(); var fee = feeList.GetFee(executionContext, feeNumber) ?? throw new Exception("Fee not found."); transaction.Fees.AddFee(executionContext, session, fee, quantity); }
/// <summary> /// Builds a new Transaction Service preloaded with all available Transaction Type configurations. /// </summary> /// <param name="executionContext"></param> /// <param name="cacheTimeOut">Sets amount of time to cache the transaction service to service future build requests. When null, caching is not used.</param> /// <returns></returns> public ITransactionService CreateTransactionService(IProcessExecutionContext executionContext, bool useCache = true) { try { useCache = useCache && executionContext.Cache != null; if (useCache) { if (executionContext.Cache.Exists(CACHE_KEY)) { executionContext.Trace("Returning Transaction Service from cache."); return(executionContext.Cache.Get <ITransactionService>(CACHE_KEY)); } } IList <ITransactionType> registeredTransactions = new List <ITransactionType>(); var transactionTypeRecords = DataConnector.GetAllTransactionTypeRecords(executionContext.DataService); executionContext.Trace("Retrieved {0} Transaction Type records.", transactionTypeRecords.Count); // get all active records that are needed to fully define a transaction type. This includes complex objects for ITransactionProcess // and ITransactionRequirements as well as simpler objects for transaction groups, authorized channels, authorized roles, // initial fees, and eligible record contexts. var processes = getProcesses(executionContext, useCache); var requirements = getRequirements(executionContext, useCache); var transactionGroups = DataConnector.GetAllTransactionGroups(executionContext.DataService); executionContext.Trace("Retrieved {0} Transaction Group records.", transactionGroups.Count); var authorizedChannels = DataConnector.GetAllTransactionAuthorizedChannels(executionContext.DataService); executionContext.Trace("Retrieved {0} Transaction Authorized Channel records.", authorizedChannels.Count); var authorizedRoles = DataConnector.GetAllAuthorizedRoles(executionContext.DataService); executionContext.Trace("Retrieved {0} Transaction Authorized Role records.", authorizedRoles.Count); var initialFees = DataConnector.GetAllInitialFees(executionContext.DataService); executionContext.Trace("Retrieved {0} Transaction Initial Fee records.", initialFees.Count); var contexts = DataConnector.GetAllTransactionContextTypes(executionContext.DataService); executionContext.Trace("Retrieved {0} Transaction Type Context records.", contexts.Count); // Create a new TransactionType object for each transaction type retrieved. foreach (ITransactionTypeRecord t in transactionTypeRecords) { executionContext.Trace("Processing transaction type '{0}'", t.Name); ISerializedParameters dataRecordConfig = null; try { executionContext.Trace("Parsing Data Record Configuration."); dataRecordConfig = this.ParameterSerializer.CreateParamters(t.DataRecordConfiguration); if (!dataRecordConfig.ContainsKey("RecordType")) { throw new Exception("Missing RecordType."); } if (!dataRecordConfig.ContainsKey("CustomerField")) { throw new Exception("Missing Customer Field"); } if (!dataRecordConfig.ContainsKey("TransactionField")) { throw new Exception("Missing Transaction Field"); } if (!dataRecordConfig.ContainsKey("NameField")) { throw new Exception("Missing Name Field"); } } catch (Exception ex) { throw TransactionException.BuildException(TransactionException.ErrorCode.ProcessStepTypeInvalid, ex); } registeredTransactions.Add(new TransactionType( t, t.Name, t.DisplayRank, transactionGroups.Where(r => t.TransactionGroupId != null && r.Id == t.TransactionGroupId.Id).FirstOrDefault(), t.StartupProcessId ?? throw new Exception("Transaction type is missing a startup process id."), dataRecordConfig, authorizedChannels.Where(r => r.ParentId.Id == t.Id).Select(r => r.ChannelId), authorizedRoles.Where(r => r.ParentId.Id == t.Id).Select(r => r.RoleId), processes.Where(r => r.TransactionTypeId.Id == t.Id), requirements.Where(r => r.TransactionTypeId.Id == t.Id), initialFees.Where(r => r.TransactionTypeId.Id == t.Id).Select(r => r.FeeId), contexts.Where(r => r.TransactionTypeId.Id == t.Id))); } executionContext.Trace("Creating Transaction Service loaded with {0} Transaction Types.", registeredTransactions.Count); // Create a new transaction service and pass in required factory and record services. var transactionService = new TransactionService(this.DataConnector, this.AgentFactory, this.TransactionFeeListFactory, this.TransactionContextFactory, this.CustomerFactory, this.TransactionDeficienciesFactory, this.DocumentService, this.EvidenceService, this.LocationFactory, RequirementEvaluator, this.TransactionHistoryFactory, this.FeeList, registeredTransactions); if (useCache) { var settings = SettingsFactory.CreateSettings(executionContext.Settings); var cacheTimeout = settings.PlatformServiceCacheTimeout; executionContext.Cache.Add <ITransactionService>(CACHE_KEY, transactionService, cacheTimeout.Value); executionContext.Trace("Cached Transaction Service for {0}.", cacheTimeout.Value); } executionContext.TrackEvent("TransactionServiceFactory.BuildTransactionService"); return(transactionService); } catch (Exception) { throw; } }