public void UpdateDeficiencyRecordStatus(IDataService dataService, IRecordPointer <Guid> deficiencyId, eDeficiencyStatusEnum status) { ccllc_transactiondeficiency_statuscode statusCode = ccllc_transactiondeficiency_statuscode.Active; ccllc_transactiondeficiencyState stateCode = ccllc_transactiondeficiencyState.Active; switch (status) { case eDeficiencyStatusEnum.Cleared: stateCode = ccllc_transactiondeficiencyState.Inactive; statusCode = ccllc_transactiondeficiency_statuscode.Cleared; break; case eDeficiencyStatusEnum.Waived: stateCode = ccllc_transactiondeficiencyState.Active; statusCode = ccllc_transactiondeficiency_statuscode.Waived; break; } var record = new ccllc_transactiondeficiency { Id = deficiencyId.Id, statecode = stateCode, statuscode = statusCode }; dataService.ToOrgService().Update(record); }
public IAgent BuildAgent(IProcessExecutionContext executionContext, IRecordPointer <Guid> agentId, bool useCache = true) { var service = executionContext.DataService as IOrganizationService; var record = service.Retrieve(agentId.RecordType, agentId.Id, new Microsoft.Xrm.Sdk.Query.ColumnSet(true)).ToEntity <TestProxy.ccllc_agent>(); return(new FakeAgent(record)); }
public IStepHistory UpdateStepHistoryStatus(IDataService dataService, IRecordPointer <Guid> stepHistoryId, eProcessStepHistoryStatusEnum status) { ccllc_stephistory_statuscode?statuscode = null; switch (status) { case eProcessStepHistoryStatusEnum.RolledBack: statuscode = ccllc_stephistory_statuscode.RolledBack; break; case eProcessStepHistoryStatusEnum.Current: statuscode = ccllc_stephistory_statuscode.Current; break; default: statuscode = ccllc_stephistory_statuscode.Archived; break; } var stepHistory = new ccllc_stephistory { Id = stepHistoryId.Id, statuscode = statuscode }; dataService.ToOrgService().Update(stepHistory); return(dataService.ToOrgService().Retrieve(ccllc_stephistory.EntityLogicalName, stepHistoryId.Id, new ColumnSet(true)).ToEntity <ccllc_stephistory>()); }
public ILocation CreateLocation(IProcessExecutionContext executionContext, IRecordPointer <Guid> locationId, bool useCache = true) { var service = executionContext.DataService as IOrganizationService; var record = service.Retrieve(locationId.RecordType, locationId.Id, new Microsoft.Xrm.Sdk.Query.ColumnSet(true)).ToEntity <TestProxy.ccllc_location>(); return(new FakeLocation(record)); }
public void UpdateTransactionRecord(IDataService dataService, IRecordPointer <Guid> transactionId, IRecordPointer <Guid> currentStepId) { try { if (dataService is null) { throw new ArgumentNullException("dataService"); } if (transactionId is null) { throw new ArgumentNullException("transactionId"); } if (currentStepId is null) { throw new ArgumentNullException("currentStepId"); } var entity = new ccllc_transaction { Id = transactionId.Id, ccllc_CurrentStepId = new EntityReference(ccllc_processstep.EntityLogicalName, currentStepId.Id) }; dataService.ToOrgService().Update(entity); } catch (Exception ex) { throw ex; } }
public IFee GetFeeById(IDataService dataService, IRecordPointer <Guid> feeId) { return(dataService.ToOrgService().Retrieve( feeId.RecordType, feeId.Id, new ColumnSet("ccllc_feeid", "ccllc_name")) .ToEntity <ccllc_fee>()); }
public TransactionContextRecord(string recordType, Guid id, string name, IRecordPointer <Guid> customerId, int status) : base(recordType, id) { Name = name; CustomerId = customerId; Status = status; }
public IEvaluatorTypeRecord GetEvaluatorTypeRecord(IDataService dataService, IRecordPointer <Guid> evaluatorTypeId) { return(dataService.ToOrgService().Retrieve( evaluatorTypeId.RecordType, evaluatorTypeId.Id, new ColumnSet("ccllc_evaluatortypeid", "ccllc_name", "ccllc_assemblyname", "ccllc_classname")) .ToEntity <ccllc_evaluatortype>()); }
public IAgentRecord GetUserAgentRecord(IDataService dataService, IRecordPointer <Guid> userId) { return(dataService.ToOrgService().Query <ccllc_agent>() .Select("ccllc_agentid") .WhereAll(e => e .IsActive() .Attribute("ccllc_userid").IsEqualTo(userId.Id)) .FirstOrDefault()); }
internal TransactionFee(ITransactionFeeRecord transactionFeeRecord, IFee fee) : base(transactionFeeRecord.RecordType, transactionFeeRecord.Id) { TransactionId = transactionFeeRecord.TransactionId; Quantity = transactionFeeRecord.Quantity; UnitPrice = transactionFeeRecord.UnitPrice; TotalPrice = transactionFeeRecord.TotalPrice; Fee = fee; }
/// <summary> /// Returns the <see cref="IProcessStep"/> associated with the specified id value. /// </summary> /// <param name="processStepId"></param> /// <returns></returns> private IProcessStep GetProcessStepById(IRecordPointer <Guid> processStepId) { var step = this.CurrentProcess.ProcessSteps.Where(s => s.Id == processStepId.Id).FirstOrDefault(); if (step is null) { throw TransactionException.BuildException(TransactionException.ErrorCode.ProcessStepNotFound); } return(step); }
public IList <IRole> GetAgentRoles(IDataService dataService, IRecordPointer <Guid> agentId) { return(dataService.ToOrgService().Query <ccllc_role>() .Select("ccllc_roleid", "ccllc_name") .WhereAll(e => e .IsActive()) .InnerJoin <ccllc_agentrole>("ccllc_roleid", "ccllc_roleid", r => r .WhereAll(ar => ar .Attribute("ccllc_agentid").IsEqualTo(agentId.Id))) .RetrieveAll().ToList <IRole>()); }
protected internal ProcessStep(IRecordPointer <Guid> stepId, string stepName, IRecordPointer <Guid> transactionProcessPointer, IProcessStepType stepType, ISerializedParameters parameters, IRecordPointer <Guid> subsequentStepPointer, IEnumerable <IAlternateBranch> alternateBranches, IEnumerable <IChannel> authorizedChannels, IEnumerable <IStepRequirement> validationRequirements) : base(stepId) { this.Name = stepName; this.TransactionProcessPointer = transactionProcessPointer; this.Type = stepType; this.Parameters = parameters; this.AlternateBranches = alternateBranches.ToList(); this.AuthorizedChannels = authorizedChannels.ToList(); this.ValidationRequirements = validationRequirements.ToList(); this.SubsequentStepPointer = subsequentStepPointer; }
protected internal StepHistory(IStepHistory copyFrom) : base(copyFrom.RecordType, copyFrom.Id) { ProcessStepId = copyFrom.ProcessStepId; StepStatus = copyFrom.StepStatus; TransactionId = copyFrom.TransactionId; PreviousStepId = copyFrom.PreviousStepId; NextStepId = copyFrom.NextStepId; CompletedOn = copyFrom.CompletedOn; CompletedById = copyFrom.CompletedById; CompletedAtId = copyFrom.CompletedAtId; }
public IAgent BuildAgent(IProcessExecutionContext executionContext, ISystemUser userId, bool useCache = true) { try { if (executionContext is null) { throw new ArgumentNullException("executionContext"); } if (userId is null) { throw new ArgumentNullException("userId"); } var cacheTimeout = useCache ? getCacheTimeout(executionContext) : null; useCache = useCache && executionContext.Cache != null && cacheTimeout != null; string cacheKey = null; IRecordPointer <Guid> agentId = null; if (useCache) { cacheKey = CACHE_KEY + ".AgentUserMap." + userId.Id.ToString(); if (executionContext.Cache.Exists(cacheKey)) { agentId = executionContext.Cache.Get <IRecordPointer <Guid> >(cacheKey); } } if (agentId is null) { agentId = DataConnector.GetUserAgentRecord(executionContext.DataService, userId); if (agentId is null) { throw new Exception("The user does not have an assigned Agent record."); } if (useCache) { executionContext.Cache.Add <IRecordPointer <Guid> >(cacheKey, agentId, cacheTimeout.Value); executionContext.Trace("Cached User Agent Map for {0}", cacheTimeout.Value); } } return(BuildAgent(executionContext, agentId, useCache)); } catch (Exception) { throw; } }
public ITransactionFeeRecord CreateTransactionFee(IDataService dataService, IRecordPointer <Guid> transactionId, IRecordPointer <Guid> feeId, string name, decimal quantity, decimal?unitPrice = null, decimal?totalPrice = null) { var record = new ccllc_transactionfee { ccllc_TransactionId = transactionId.ToEntityReference(), ccllc_FeeId = feeId.ToEntityReference(), ccllc_name = name, }; record.Id = dataService.ToOrgService().Create(record); return(record); }
protected internal TransactionProcess(IRecordPointer <Guid> processId, string name, IRecordPointer <Guid> transactionTypeId, Guid initialStepId, IEnumerable <IProcessStep> processSteps) : base(processId) { if (processSteps == null) { throw new ArgumentNullException("processSteps is null."); } this.Name = name; this.TransactionTypeId = transactionTypeId ?? throw new ArgumentNullException("transactionTypeId is null."); this.InitialStepId = initialStepId; this.processSteps = processSteps.ToList(); }
public IAgent BuildAgent(IProcessExecutionContext executionContext, IRecordPointer <Guid> agentId, bool useCache = true) { try { if (executionContext is null) { throw new ArgumentNullException("executionContext"); } if (agentId is null) { throw new ArgumentNullException("agentId"); } var cacheTimeout = useCache ? getCacheTimeout(executionContext) : null; useCache = useCache && executionContext.Cache != null && cacheTimeout != null; string cacheKey = null; if (useCache) { cacheKey = CACHE_KEY + ".Agent." + agentId.Id.ToString(); if (executionContext.Cache.Exists(cacheKey)) { executionContext.Trace("Returning Agent from Cache."); return(executionContext.Cache.Get <IAgent>(cacheKey)); } } var agentRecord = DataConnector.GetAgentRecord(executionContext.DataService, agentId); var roles = DataConnector.GetAgentRoles(executionContext.DataService, agentId); var authorizedCustomers = DataConnector.GetAgentRoles(executionContext.DataService, agentId); var prohibitedCustomers = DataConnector.GetAgentProhibitedCustomers(executionContext.DataService, agentId); var agent = new Agent(agentRecord, roles, authorizedCustomers, prohibitedCustomers); if (cacheKey != null) { executionContext.Trace("Caching Agent for {0}", cacheTimeout.Value); executionContext.Cache.Add <IAgent>(cacheKey, agent, cacheTimeout.Value); } return(agent); } catch (Exception) { throw; } }
public FakeCustomer(IRecordPointer <Guid> pointer) { RecordType = pointer.RecordType; Id = pointer.Id; if (RecordType == "contact") { Type = eCustomerTypeEnum.Contact; } else { Type = eCustomerTypeEnum.Account; } }
public IStepHistory CreateStepHistoryRecord(IDataService dataService, IRecordPointer <Guid> transactionId, IRecordPointer <Guid> processStepId, IRecordPointer <Guid> previousStepHistoryId) { var stepHistory = new ccllc_stephistory { ccllc_TransactionId = transactionId?.ToEntityReference(), ccllc_ProcessStepId = processStepId?.ToEntityReference(), ccllc_PreviousRecordId = previousStepHistoryId?.ToEntityReference(), statuscode = ccllc_stephistory_statuscode.Current }; stepHistory.Id = dataService.ToOrgService().Create(stepHistory); return(stepHistory); }
public ICustomerRecord GetCustomerRecord(IDataService dataService, IRecordPointer <Guid> customerId) { var orgService = dataService.ToOrgService(); if (customerId.RecordType == "contact") { return(dataService.ToOrgService().Retrieve("contact", customerId.Id, new ColumnSet("contactid", "fullname")).ToEntity <Contact>()); } if (customerId.RecordType == "account") { return(dataService.ToOrgService().Retrieve("account", customerId.Id, new ColumnSet("accountid", "name")).ToEntity <Account>()); } throw new Exception(string.Format("Customer type '{0}' is not supported.", customerId.RecordType)); }
public IStepHistory UpdateStepHistoryRecord(IDataService dataService, IRecordPointer <Guid> stepHistoryId, IRecordPointer <Guid> nextStepId, IRecordPointer <Guid> agentId, IRecordPointer <Guid> locationId, DateTime?completionDate) { var stepHistory = new ccllc_stephistory { Id = stepHistoryId.Id, ccllc_NextRecordId = nextStepId?.ToEntityReference(), ccllc_CompletedByAgentId = agentId?.ToEntityReference(), ccllc_CompletedAtLocationId = locationId?.ToEntityReference(), ccllc_CompletedOn = completionDate }; dataService.ToOrgService().Update(stepHistory); return(dataService.ToOrgService().Retrieve(ccllc_stephistory.EntityLogicalName, stepHistoryId.Id, new ColumnSet(true)).ToEntity <ccllc_stephistory>()); }
internal protected AlternateBranch(string recordType, Guid id, string name, int evaluationOrder, IRecordPointer <Guid> parentStepPointer, IRecordPointer <Guid> subsequentStepPointer, ILogicEvaluator logicEvaluator) : base(recordType, id) { try { Name = name ?? throw new ArgumentNullException("name"); EvaluationOrder = evaluationOrder; ParentStepPointer = parentStepPointer ?? throw new ArgumentNullException("parentStepPointer"); SubsequentStepPointer = subsequentStepPointer; LogicEvaluator = logicEvaluator ?? throw new ArgumentNullException("logicEvaluator"); } catch (Exception) { throw; } }
public ICustomer CreateCustomer(IProcessExecutionContext executionContext, IRecordPointer <Guid> customerId, bool useCache = true) { try { if (executionContext is null) { throw new ArgumentNullException("executionContext"); } if (customerId is null) { throw new ArgumentNullException("customerId"); } var cacheTimeout = useCache ? getCacheTimeout(executionContext) : null; useCache = useCache && executionContext.Cache != null && cacheTimeout != null; string cacheKey = null; if (useCache) { cacheKey = CACHE_KEY + customerId.RecordType + customerId.Id.ToString(); if (executionContext.Cache.Exists(cacheKey)) { executionContext.Trace("Returning Customer from Cache."); return(executionContext.Cache.Get <ICustomer>(cacheKey)); } } var customerRecord = DataConnector.GetCustomerRecord(executionContext.DataService, customerId); var customerClasses = DataConnector.GetCustomerClasses(executionContext.DataService, customerId); var customer = new Customer(customerRecord, customerClasses); if (cacheKey != null) { executionContext.Cache.Add <ICustomer>(cacheKey, customer, cacheTimeout.Value); } return(customer); } catch (Exception) { throw; } }
public IFee GetFee(IProcessExecutionContext executionContext, IRecordPointer <Guid> feeId, bool useCache = true) { var feeList = getFeeList(executionContext, useCache); var fee = feeList.Where(r => r.Id == feeId.Id).FirstOrDefault(); if (fee is null) { fee = DataConnector.GetFeeById(executionContext.DataService, feeId) ?? throw new Exception("Requested Fee does not exist.");; if (useCache) { feeList.Add(fee); cacheFeeList(executionContext, feeList); } } return(fee); }
protected internal TransactionType(IRecordPointer <Guid> transactionTypeId, string name, int displayRank, ITransactionGroup group, IRecordPointer <Guid> startupProcessId, ISerializedParameters dataRecordType, IEnumerable <IRecordPointer <Guid> > authorizedChannels, IEnumerable <IRecordPointer <Guid> > authorizedRoles, IEnumerable <ITransactionProcess> processes, IEnumerable <IRequirement> requirements, IEnumerable <IRecordPointer <Guid> > initialFees, IEnumerable <ITransactionContextType> contexts) : base(transactionTypeId) { this.Name = name; this.DisplayRank = displayRank; this.Group = group; this.StartUpProcessId = startupProcessId; this.TransactionDataRecordType = dataRecordType ?? throw new ArgumentNullException("dataRecordType");; _authorizedChannels = authorizedChannels != null?authorizedChannels.ToList() : throw new ArgumentNullException("authorizedChannel"); _authorizedRoles = authorizedRoles != null?authorizedRoles.ToList() : throw new ArgumentNullException("authorizedRoles"); _availableProcesses = processes != null?processes.ToList() : throw new ArgumentNullException("processes"); _requirements = requirements != null?requirements.ToList() : throw new ArgumentNullException("requirements"); _initialFeeSchedule = initialFees != null?initialFees.ToList() : throw new ArgumentNullException("initialFees"); _eligibleContexts = contexts != null?contexts.ToList() : throw new ArgumentNullException("contexts"); }
public ITransactionRecord NewTransactionRecord(IDataService dataService, IRecordPointer <Guid> initiatingAgentId, IRecordPointer <Guid> initiatingLocaitonId, IRecordPointer <Guid> customerId, IRecordPointer <Guid> contextRecordId, IRecordPointer <Guid> transactionTypeId, IRecordPointer <Guid> initiatingProcessId, IRecordPointer <Guid> currentProcessId, IRecordPointer <Guid> currentStepId, string name) { ccllc_transaction transaction = new ccllc_transaction { ccllc_InitiatingAgentId = initiatingAgentId?.ToEntityReference(), ccllc_InitiatingLocationId = initiatingLocaitonId?.ToEntityReference(), ccllc_CustomerId = customerId?.ToEntityReference(), ccllc_ContextRecordType = contextRecordId?.RecordType, ccllc_ContextRecordGUID = contextRecordId?.Id.ToString(), ccllc_TransactionTypeId = transactionTypeId?.ToEntityReference(), ccllc_InitiatingProcessId = initiatingProcessId?.ToEntityReference(), ccllc_CurrentProcessId = currentProcessId?.ToEntityReference(), ccllc_CurrentStepId = currentStepId?.ToEntityReference(), ccllc_name = name }; transaction.Id = dataService.ToOrgService().Create(transaction); return(transaction); }
public bool HasRole(IRecordPointer <Guid> role) { if (this.Agent == null) { return(false); } if (role != null) { foreach (var r in Agent.Roles) { if (r.Id == role.Id) { return(true); } } } return(false); }
public RecordPointer(IRecordPointer <T> source) { this.RecordType = source.RecordType; this.Id = source.Id; }
public ILocation CreateLocation(IProcessExecutionContext executionContext, IRecordPointer <Guid> locationId, bool useCache = true) { throw new NotImplementedException(); }