private void VerifyIfExistsDuplicatedRequestIDs(Request[] collectRequest) { var total = collectRequest.Count(); var duplicated = (from x in collectRequest select x.RequestId).Distinct().Count(); if (total != duplicated) throw new DuplicatedRequestIDsException("There are duplicated request identifiers."); }
public void AddTargetInCollectRequest(Request collectRequestDTO, CollectRequest collectRequest) { Target target = new Target(); target.Address = collectRequestDTO.Address; collectRequest.Target = target; this.AddCredentialToTarget(collectRequestDTO, target); this.AddTargetParametersInCollectRequest(collectRequestDTO, target); }
public CollectRequest CreateCollectRequestFromDTO(Request collectRequestDTO, string definitionId) { var collectRequest = new CollectRequest(); targetAssembler.AddTargetInCollectRequest(collectRequestDTO, collectRequest); collectRequest.OvalDefinitionsId = definitionId; collectRequest.ExternalVariables = collectRequestDTO.ExternalVariables; return collectRequest; }
public static Request CreateCollectRequestDTO(string address) { Request collectRequest = new Request(); collectRequest.RequestId = "256"; collectRequest.Address = address; collectRequest.Credential = getCredential(); collectRequest.TargetParameters = getTargetParameters(); return collectRequest; }
private void AddTargetParametersInCollectRequest(Request collectRequestDTO, Modulo.Collect.Service.Entities.Target target) { if (collectRequestDTO.TargetParameters != null) { foreach (KeyValuePair<string, string> parameter in collectRequestDTO.TargetParameters) { TargetParameter targetParameter = CreateTargetParametersFromCollectRequestDTO(parameter.Key, parameter.Value); target.Parameters.Add(targetParameter); } } }
private void VerifyIfRequestIdsIsNotNull(Request[] collectRequest) { var element = collectRequest.FirstOrDefault(x => String.IsNullOrEmpty(x.RequestId)); if (element != null) throw new RequestIDNullException("There are CollectRequest with RequestId null."); }
private void VerifyIfExistsANullRequesCollectItemInCollection(Request[] collectRequest) { var hasNullItems = collectRequest.Where(x => x == null).Count() > 0; if (hasNullItems) throw new RequestItemNullException("There are null items in request collect."); }
private void VerifyIfCollectRequestParameterIsNull(Request[] collectRequest) { if (collectRequest == null) throw new ArgumentNullException("The collectRequest parameter of CollectRequest method cannot be null."); }
private Request CreateRequest(string targetAddress, Credential credentials, string externalVariables, Dictionary<string, string> targetParameters = null) { var encrytedCredentials = this.EncryptCredentials(credentials); var newRequest = new Request() { Address = targetAddress, Credential = encrytedCredentials, DefinitionId = Guid.NewGuid().ToString(), ExternalVariables = externalVariables, RequestId = Guid.NewGuid().ToString(), TargetParameters = targetParameters }; return newRequest; }
private Package CreatePackage(string ovalDefinitions, Request newRequest) { var package = new Package() { CollectRequests = new Request[] { newRequest }, Date = DateTime.UtcNow, Definitions = new DefinitionInfo[] { new DefinitionInfo() { Id = newRequest.DefinitionId, Text = ovalDefinitions } }, ScheduleInformation = new ScheduleInformation() { ScheduleDate = DateTime.UtcNow } }; return package; }
private void AddCredentialToTarget(Request collectRequestDTO, Target target) { var TargetCredential = new TargetCredential() { CredentialInfo = System.Text.Encoding.Default.GetBytes(collectRequestDTO.Credential) }; target.Credential = TargetCredential; }
private Package CreatePackage(Request request, DefinitionInfo definitionInfo, DateTime? fakeDate = null) { var date = fakeDate ?? DateTime.Now; var fakePackage = new Package() { Date = date, Definitions = new DefinitionInfo[] { definitionInfo }, CollectRequests = new Request[] { request }, ScheduleInformation = new ScheduleInformation() { ScheduleDate = date } }; return fakePackage; }