/// <summary> /// Démarre et initialise les SelectorConfig associés au WorkflowConfig original. /// </summary> /// <param name="wfInstance">WorkflowInstance nouvellement démarré</param> /// <returns>Message en cas de warning</returns> public async Task <HttpResponseMessageResult> StartSelectorsIntances(WorkflowInstance wfInstance) { if ((wfInstance == null) || (wfInstance.WorkflowConfig == null)) { throw new InitialiseWorkflowException("Process: can't find an instance of WorkflowInstance or WorkflowConfig!"); } if (wfInstance.DataSetId == 0) { throw new InitialiseWorkflowException("Process: no DataSet in Workflow!"); } if (wfInstance.UserSetId == 0) { throw new InitialiseWorkflowException("Process: no UserSet in Workflow!"); } ICollection <SelectorConfig> lstSelectConf = wfInstance.WorkflowConfig.SelectorConfig; HttpResponseMessageResult res = new HttpResponseMessageResult() { IsSuccess = true }; foreach (SelectorConfig selector in lstSelectConf) { HttpResponseMessageResult resLocal = await SelectorEngine.GenerateSelectorsInstances(selector, wfInstance); res.Append(resLocal); } return(res); }
/// <summary> /// Modifie les données d'un SelectorInstance. Les données sont d'abord sauvées, puis le SelectorInstance passe en Act et en Constraints. /// </summary> /// <param name="selectorInstanceId">Id du SelectorInstance</param> /// <param name="values">Valeurs à modifier</param> /// <remarks>Les valeurs à modifier sont au format suivant : {id de la cellule}:{nouvelle valeur}</remarks> /// <returns>Message à modifier</returns> public async Task <HttpResponseMessageResult> SaveData(long selectorInstanceId, IEnumerable <KeyValuePair <long, double> > values) { // Création de la transaction using (IDbContextTransaction transaction = UnitOfWork.GetDbContext().Database.BeginTransaction()) { SessionStatsHelper.HttpHitSaveDBTransaction(transaction, _serviceProvider); // Recherche du selectorInstance List <SelectorInstance> lstSelectInst = await UnitOfWork.GetDbContext().SelectorInstance .Where(si => si.Id == selectorInstanceId) .Include(si => si.SelectorConfig) .Include(si => si.WorkflowInstance) .ThenInclude(wfi => wfi.WorkflowConfig) .ToAsyncEnumerable() .ToList(); SelectorInstance selectorInstance = lstSelectInst.FirstOrDefault(); if (selectorInstance == null) { throw new WrongParameterException($"SelectorEngine.SaveData: bad SelectorInstance Id ({selectorInstanceId})."); } // On pousse les valeurs volatiles vers les futures valeurs. HttpResponseMessageResult res = await SelectorInstanceDomain.PushVolatileToFuture(selectorInstance); // Passage aux étapes suivantes UnitOfWork.SelectorInstanceRepository.PrepareUpdateForObject(selectorInstance); res.Append(await NextStep(selectorInstance, selectorInstance.WorkflowInstance, SelectorStateEnum.Init, values)); transaction.Commit(); return(res); } }
/// <summary> /// Génére tous les SelectorInstance depuis les criteria donnés. /// </summary> /// <param name="selectConf">SelectorConfig cible</param> /// <param name="wfInstance">WorkflowInstance nouvellement démarré</param> /// <param name="parent">Eventuel SelectorInstance pouvant être à l'origine de la création de nouvelles instances</param> /// <returns>Message de résultat</returns> public async Task <HttpResponseMessageResult> GenerateSelectorsInstances(SelectorConfig selectConf, WorkflowInstance wfInstance, SelectorInstance parent = null) { if (selectConf == null) { throw new SequenceException("Process.SelectorConfig.Init: SelectorConfig are null."); } if (selectConf.Criterias == null) { throw new DataLoadingException("SelectorConfig : Criterias not loaded!"); } // WOR-174 - Créer en chaine les SelectorInstance selon la liste de Criterias... // On passe directement les criteria valorisés dans la requête de sélection... IEnumerable <IEnumerable <CriteriaValues> > lstCV = await CriteriaDomain.ExtractAllCriteriaValues(selectConf.Criterias, wfInstance); IEnumerable <IEnumerable <CriteriaValues> > lstCrit = await GetValueObjectsFromCriteria(lstCV, wfInstance.DataSetId); HttpResponseMessageResult res = new HttpResponseMessageResult() { IsSuccess = true }; foreach (IEnumerable <CriteriaValues> cvs in lstCrit) { SelectorInstance si = await SelectorInstanceDomain.Create(selectConf, cvs, parent, wfInstance); UnitOfWork.SelectorInstanceRepository.PrepareUpdateForObject(si); res.Append(await NextStep(si, wfInstance)); } return(res); }
/// <summary> /// Etabli l'étape Constraint. /// </summary> /// <param name="selectorInstance">SelectorInstance</param> /// <param name="wfInstance">Workflow Instance</param> /// <param name="values">Valeurs à modifier</param> /// <returns>Message de retour</returns> public async Task <HttpResponseMessageResult> Constraint(SelectorInstance selectorInstance, WorkflowInstance wfInstance, IEnumerable <KeyValuePair <long, double> > values) { HttpResponseMessageResult res = new HttpResponseMessageResult() { IsSuccess = true }; if (selectorInstance == null) { throw new WrongParameterException("SelectorEngine.Constraint : SelectorInstance is null."); } if (selectorInstance.SelectorConfig == null) { throw new DataLoadingException($"SelectorEngine.Constraint : SelectorConfig of SelectorInstance (Id = {selectorInstance.Id}) is null."); } if (wfInstance == null) { throw new WrongParameterException("SelectorEngine.Constraint : WorkflowInstance is null."); } if (wfInstance.WorkflowConfig == null) { throw new DataLoadingException($"SelectorEngine.Constraint : WorkflowConfig of WorkflowInstance (Id = {wfInstance.Id}) is null."); } long refSeq = -1; if (selectorInstance.SelectorConfig.ConstraintSequenceRef >= 0) { refSeq = selectorInstance.SelectorConfig.ConstraintSequenceRef; } else if (wfInstance.WorkflowConfig.ConstraintSequenceRef >= 0) { refSeq = wfInstance.WorkflowConfig.ConstraintSequenceRef; } if (refSeq >= 0) { List <ConstraintSequence> lstSeqConstraints = await UnitOfWork.GetDbContext().ConstraintSequence .Where(a => a.Reference == refSeq) .OrderBy(a => a.Order) .Include(a => a.Constraint) .AsNoTracking() .ToAsyncEnumerable() .ToList(); res.Append(await ConstraintSequenceDomain.CheckConstraintSequence(lstSeqConstraints, selectorInstance, wfInstance, values)); } return(res); }
/// <summary> /// Sélectionne les données modifiables du SelectorInstance. /// </summary> /// <param name="selectorInstance">SelectorInstance</param> /// <param name="wfInstance">WorkflowInstance</param> /// <param name="idsDimensionDS">Dictionnaire de DimensionDataSet par Id</param> /// <returns>Message de retour</returns> public async Task <HttpResponseMessageResult> SetModifyData(SelectorInstance selectorInstance, WorkflowInstance wfInstance, Dictionary <long, DataSetDimension> idsDimensionDS) { if (selectorInstance == null) { throw new WrongParameterException($"SelectorInstanceDomain.SetModifyData: SelectorInstance is null."); } if (selectorInstance.SelectorConfig == null) { throw new WrongParameterException($"SelectorInstanceDomain.SetModifyData: SelectorConfig is null (Id SelectorInstance : {selectorInstance.Id})."); } if (selectorInstance.SelectorConfig.ModifyCriterias == null) { throw new SequenceException($"SelectorInstance.SetModifyData : no ModifyCriterias for values found, error in SelectorConfig. Id SelectorConfig : {selectorInstance.SelectorConfig.Id}"); } HttpResponseMessageResult res = new HttpResponseMessageResult() { IsSuccess = true }; IEnumerable <IEnumerable <CriteriaValues> > lstCv = await CriteriaDomain.ExtractAllCriteriaValues(selectorInstance.SelectorConfig.ModifyCriterias, wfInstance); List <Expression <Func <ValueObject, bool> > > where = new List <Expression <Func <ValueObject, bool> > >(); res.Append(ValueObjectDomain.BuildFilterRequest(where, lstCv, idsDimensionDS, false)); if (where.Count > 0) { IQueryable <ValueObject> dbQuery = UnitOfWork.GetDbContext().Set <ValueObject>(); IEnumerable <long> lstIdsValueObject = await where .Aggregate(dbQuery, (current, predicate) => current.Where(predicate)) .Include(vo => vo.SelectorInstanceValueObject) .Where(vo => vo.SelectorInstanceValueObject.Any(sivo => sivo.SelectorInstanceId == selectorInstance.Id)) .Select(vo => vo.Id) .ToAsyncEnumerable() .ToList(); foreach (SelectorInstanceValueObject subSivo in selectorInstance.SelectorInstanceValueObject.Where(sivo => lstIdsValueObject.Contains(sivo.ValueObjectId))) { subSivo.IsEditable = true; } int nbr = await UnitOfWork.GetDbContext().SaveChangesAsync(); } return(res); }
/// <summary> /// Méthode de split hardcodé /// </summary> /// <param name="referenceSequence">Référence de la séquence d'action</param> /// <param name="OrderSequence">Numéro d'ordre de l'action dans la séquence</param> /// <param name="selectorInstance">SelectorInstance</param> /// <param name="wfInstance">WorkflowInstance</param> /// <returns>Message de retour</returns> private async Task <HttpResponseMessageResult> ExecuteSplitPrimeum(long referenceSequence, int OrderSequence, SelectorInstance selectorInstance, WorkflowInstance wfInstance) { HttpResponseMessageResult res = new HttpResponseMessageResult() { IsSuccess = true }; // Récupération du nom de la dimension de la secto et du dictionnaire des objects. string nomDimension = await Split_GetDimensionName(referenceSequence, OrderSequence, wfInstance); Dictionary <long, Tuple <ValueObject, int, string, bool> > dicAllVo = await ValueObjectDomain.CreateDictionaryVO(nomDimension, selectorInstance); HashSet <KeyValuePair <long, double> > modifiedValues = new HashSet <KeyValuePair <long, double> >(); // On créé la queue pour parcourir l'arbre procéduralement. Queue <ValueObject> voToSplit = new Queue <ValueObject>(); foreach (ValueObject vo in dicAllVo.Values.Where(val => val.Item4).OrderBy(val => val.Item2).Select(val => val.Item1).ToList()) { voToSplit.Enqueue(vo); } // Parcours des noeuds while (voToSplit.Count > 0) { ValueObject node = voToSplit.Dequeue(); IEnumerable <ValueObject> children = GetChildren(node, nomDimension, dicAllVo); string format = await ValueObjectDomain.GetNumericalFormat(node.TypeValue, wfInstance.DataSetId); if ((children != null) && (children.Count() > 0)) { Split_ApplyDivisionOnChildren(node, children, voToSplit, dicAllVo, modifiedValues, format); } } // On sauve les modifications int nbr = await UnitOfWork.GetDbContext().SaveChangesAsync(); // Mise à jour de la table temporaire res.Append(await GridConfigurationDomain.SaveDataInTemporyTable(selectorInstance, wfInstance, modifiedValues)); return(res); }
/// <summary> /// Vérifie une contrainte sur un SelectorInstance. /// </summary> /// <param name="contrainte">Contrainte</param> /// <param name="referenceSequence">Reference de la sequence de contrainte</param> /// <param name="ordreSequence">Ordre de la contrainte dans la sequence</param> /// <param name="level">Niveau d'alerte si la vérification échoue</param> /// <param name="selectorInstance">SelectorInstance</param> /// <param name="workflowInstance">WorkflowInstance</param> /// <param name="values">Valeurs à modifier</param> /// <returns>Message de retour</returns> public async Task <HttpResponseMessageResult> CheckConstraintSequence(IEnumerable <ConstraintSequence> sequences, SelectorInstance selectorInstance, WorkflowInstance workflowInstance, IEnumerable <KeyValuePair <long, double> > values) { HttpResponseMessageResult res = new HttpResponseMessageResult() { IsSuccess = true }; foreach (ConstraintSequence seq in sequences.OrderBy(s => s.Order)) { if (seq.Constraint == null) { res.IsSuccess = false; res.Message = $"ConstraintSequenceDomaine.CheckConstraintSequence : Constraint is null for sequence {seq.SequenceName} of SelectorInstance {selectorInstance.Id}"; continue; } Logger.LogInformation($"Starting action {seq.Constraint.Name} of sequence {seq.SequenceName}."); res.Append(await CheckConstraint(seq.Constraint, seq.Reference, seq.Order, seq.Level, selectorInstance, workflowInstance, values)); } return(res); }
/// <summary> /// Permet d'exécuter toutes les actions, dans l'ordre, d'une séquence sur un SelectorInstance. /// </summary> /// <param name="selectorInstance">SelectorInstance</param> /// <param name="wfInstance">WorkflowInstance</param> /// <param name="sequences">Sequence d'actions</param> /// <param name="values">Valeurs à modifier</param> /// <returns>Message de retour</returns> public async Task <HttpResponseMessageResult> ExecuteActionSequence(IEnumerable <ActionSequence> sequences, SelectorInstance selectorInstance, WorkflowInstance wfInstance, IEnumerable <KeyValuePair <long, double> > values) { HttpResponseMessageResult res = new HttpResponseMessageResult() { IsSuccess = true }; foreach (ActionSequence seq in sequences.OrderBy(s => s.Order)) { if (seq.Action == null) { res.IsSuccess = false; res.Message = $"ActionSequenceDomaine.ExecuteActionSequence : Action is null for sequence {seq.SequenceName} of SelectorInstance {selectorInstance.Id}"; continue; } Logger.LogInformation($"Starting action {seq.Action.Name} of sequence {seq.SequenceName}."); res.Append(await ExecuteAction(seq.Action, seq.Reference, seq.Order, selectorInstance, wfInstance, values)); } return(res); }
private async Task <HttpResponseMessageResult> ExecuteAggregatePrimeum(long referenceSequence, int OrderSequence, SelectorInstance selectorInstance, WorkflowInstance wfInstance) { HttpResponseMessageResult res = new HttpResponseMessageResult() { IsSuccess = true }; await ConfigVariableDomain.LoadVariables(); string nomDimension = await GetActionParameter(referenceSequence, OrderSequence, Constant.PARAMETER_ACTION_AGGREGATE_PRIMEUM_ALIGNMENTNAME); long idDimension = await GetIdDimensionTree(nomDimension, Constant.PARAMETER_ACTION_AGGREGATE_PRIMEUM_ALIGNMENTNAME, wfInstance); // niveau utiisateur CriteriaValues cvTree = await UnitOfWork.GetDbContext().CriteriaValues .Include(cv => cv.Criteria) .ThenInclude(c => c.Dimension) .Where(cv => cv.SelectorInstanceModifier != null && cv.SelectorInstanceModifier.Id == selectorInstance.Id && cv.Criteria.Dimension.Id == idDimension) .AsNoTracking() .FirstOrDefaultAsync(); string valueTopUser = cvTree?.Value; int levelTopUser = 0; if (!string.IsNullOrWhiteSpace(valueTopUser)) { levelTopUser = valueTopUser.Split(ConfigVariableDomain.AlignmentChar).Length; } Dictionary <long, Tuple <ValueObject, int, string, bool> > dicVo = await ValueObjectDomain.CreateDictionaryVO(nomDimension, selectorInstance); // Construction des arbres int topLvl = dicVo.Values.Select(t => t.Item2).Min(); int bottomLvl = dicVo.Values.Select(t => t.Item2).Max(); IEnumerable <TreeValueObject> lstTree = ValueObjectDomain.BuildTreeVO(dicVo, nomDimension, topLvl, bottomLvl); // On part du dernier niveau editable pour remonter jusqu'au niveau user. int bottom = dicVo.Values.Where(t => t.Item4).Select(t => t.Item2).Max(); HashSet <long> idsAlreadyComputed = new HashSet <long>(); HashSet <KeyValuePair <long, double> > modifiedValues = new HashSet <KeyValuePair <long, double> >(); foreach (TreeValueObject tvo in lstTree) { for (int currentLvl = bottom; currentLvl > levelTopUser; currentLvl--) { IEnumerable <TreeValueObject> nodes = TreeValueObject.GetNodesFromLevel(tvo, currentLvl); foreach (TreeValueObject child in nodes) { if ((child.Parent == null) || idsAlreadyComputed.Contains(child.Parent.Node.Id) || (child.Parent.Level <= levelTopUser)) { continue; } double sum = child.Parent.Children.Select(subnode => ValueObjectDomain.GetMostCurrentValue(subnode.Node)).Sum(); child.Parent.Node.FutureValue = sum; modifiedValues.Add(new KeyValuePair <long, double>(child.Parent.Node.Id, sum)); idsAlreadyComputed.Add(child.Parent.Node.Id); } } } // On sauve les modifications int nbr = await UnitOfWork.GetDbContext().SaveChangesAsync(); // Mise à jour de la table temporaire res.Append(await GridConfigurationDomain.SaveDataInTemporyTable(selectorInstance, wfInstance, modifiedValues)); return(res); }
/// <summary> /// This function permits to do a INIT action. /// </summary> /// <param name="selectorInstance">SelectorInstance</param> /// <param name="wfInstance">Workflow instance</param> /// <returns>Message</returns> public async Task <HttpResponseMessageResult> Init(SelectorInstance selectorInstance, WorkflowInstance wfInstance) { if ((selectorInstance == null) || (wfInstance == null)) { throw new WrongParameterException("Process.SelectorInstance.Init: SelectorInstance or WorkflowInstance are null!"); } HttpResponseMessageResult res = new HttpResponseMessageResult() { IsSuccess = true }; // Sélection des données et enregistrement des liaisons (subset) ICollection <CriteriaValues> lstCv = selectorInstance.CriteriaValues; Dictionary <long, DataSetDimension> dimIds = await DataSetDimensionDomain.GetDimensionColumns(wfInstance.DataSetId); List <Expression <Func <ValueObject, bool> > > where = new List <Expression <Func <ValueObject, bool> > >(); res.Append(ValueObjectDomain.BuildFilterRequest(where, new List <IEnumerable <CriteriaValues> >() { lstCv }, dimIds, true)); IQueryable <ValueObject> dbQuery = UnitOfWork.GetDbContext().Set <ValueObject>(); // Vérification que le SelectorInstance n'utilise pas les données d'un autre SelectorInstance. int nbrLinkVoSi = await where .Aggregate(dbQuery, (current, predicate) => current.Where(predicate)) .Include(vo => vo.SelectorInstanceValueObject) .Where(vo => vo.SelectorInstanceValueObject.Count > 0) .AsNoTracking() .CountAsync(); if (nbrLinkVoSi > 0) { throw new SequenceException($"SelecotrEngine.Init: Can't allocate data for SelectorInstance (from {selectorInstance?.SelectorConfig?.Name}) because there are already SelectorInstance for data."); } IEnumerable <ValueObject> lstValueObject = await where .Aggregate(dbQuery, (current, predicate) => current.Where(predicate)) .Include(vo => vo.DataSet) .Where(vo => vo.DataSet.Id == wfInstance.DataSetId) //.AsNoTracking() .ToAsyncEnumerable() .ToList(); selectorInstance.SelectorInstanceValueObject = new List <SelectorInstanceValueObject>(); foreach (ValueObject vo in lstValueObject) { vo.FutureValue = null; SelectorInstanceValueObject sivo = new SelectorInstanceValueObject() { SelectorInstance = selectorInstance, ValueObject = vo }; sivo.InitDatesAndUser(""); selectorInstance.SelectorInstanceValueObject.Add(sivo); vo.SelectorInstanceValueObject.Add(sivo); vo.Status = ValueObjectStatusEnum.Modify; } int nbr = await UnitOfWork.GetDbContext().SaveChangesAsync(); // Création de la table temporaire de données... res.Append(await GridConfigurationDomain.CreateDataTableDB(selectorInstance, wfInstance)); // Recherche des modificateurs res.Append(await SelectorInstanceDomain.FindModificator(selectorInstance, wfInstance)); // Recherche des validateurs res.Append(await SelectorInstanceDomain.FindValidators(selectorInstance, wfInstance)); // On régle les données modifiables res.Append(await SelectorInstanceDomain.SetModifyData(selectorInstance, wfInstance, dimIds)); return(res); }
/// <summary> /// Pour un SelectorInstance donné, passe à l'étape suivant dans le flux. /// </summary> /// <param name="selectIns">SelectorInstance sujet de la transition</param> /// <param name="wfInstance">Workflow instance</param> /// <returns>Message</returns> public async Task <HttpResponseMessageResult> NextStep(SelectorInstance selectIns, WorkflowInstance wfInstance, SelectorStateEnum scope = SelectorStateEnum.Void, IEnumerable <KeyValuePair <long, double> > values = null) { if (selectIns == null) { throw new SequenceException("Process.SelectorInstance.NextStep: SelectorInstance is null."); } HttpResponseMessageResult res = new HttpResponseMessageResult() { IsSuccess = true }; switch (selectIns.PreviousStatus) { case SelectorStateEnum.Create: if (selectIns.Status == SelectorStateEnum.Create) { selectIns.Status = SelectorStateEnum.PrevPropagate; res = await PrevPropagate(selectIns, wfInstance); selectIns.PreviousStatus = selectIns.Status; } if (selectIns.Status == SelectorStateEnum.PrevPropagate) { selectIns.Status = SelectorStateEnum.Init; res = await Init(selectIns, wfInstance); selectIns.PreviousStatus = SelectorStateEnum.Init; } break; case SelectorStateEnum.PrevPropagate: selectIns.Status = SelectorStateEnum.Init; res = await Init(selectIns, wfInstance); selectIns.PreviousStatus = SelectorStateEnum.Init; break; case SelectorStateEnum.Init: case SelectorStateEnum.Constraint: selectIns.Status = SelectorStateEnum.Modify; res = await Modify(selectIns, wfInstance, values); selectIns.PreviousStatus = SelectorStateEnum.Modify; selectIns.Status = SelectorStateEnum.Act; res.Append(await Act(selectIns, wfInstance, values)); selectIns.PreviousStatus = SelectorStateEnum.Act; selectIns.Status = SelectorStateEnum.Constraint; res.Append(await Constraint(selectIns, wfInstance, values)); selectIns.PreviousStatus = SelectorStateEnum.Constraint; selectIns.Status = SelectorStateEnum.Modify; if (scope == SelectorStateEnum.Validate) { selectIns.Status = SelectorStateEnum.Validate; res.Append(await Validate(selectIns, wfInstance)); selectIns.PreviousStatus = SelectorStateEnum.Validate; } break; case SelectorStateEnum.Modify: selectIns.Status = SelectorStateEnum.Act; res.Append(await Act(selectIns, wfInstance, values)); selectIns.PreviousStatus = SelectorStateEnum.Act; selectIns.Status = SelectorStateEnum.Constraint; res.Append(await Constraint(selectIns, wfInstance, values)); selectIns.PreviousStatus = SelectorStateEnum.Constraint; selectIns.Status = SelectorStateEnum.Modify; if (scope == SelectorStateEnum.Validate) { selectIns.Status = SelectorStateEnum.Validate; res.Append(await Validate(selectIns, wfInstance)); selectIns.PreviousStatus = SelectorStateEnum.Validate; } break; case SelectorStateEnum.Act: selectIns.Status = SelectorStateEnum.Constraint; res.Append(await Constraint(selectIns, wfInstance, values)); selectIns.PreviousStatus = SelectorStateEnum.Constraint; selectIns.Status = SelectorStateEnum.Modify; if (scope == SelectorStateEnum.Validate) { selectIns.Status = SelectorStateEnum.Validate; res.Append(await Validate(selectIns, wfInstance)); selectIns.PreviousStatus = SelectorStateEnum.Validate; } break; //... case SelectorStateEnum.Finish: selectIns.Status = SelectorStateEnum.Finish; res = await Finish(selectIns, wfInstance); selectIns.PreviousStatus = SelectorStateEnum.Finish; break; } // Afin de sauver les modifications d'états int nbr = await UnitOfWork.GetDbContext().SaveChangesAsync(); return(res); }
/// <summary> /// Effectue l'injection des services demandés. /// </summary> /// <param name="factory">Factory pour la communication avec le BusinessCore.</param> /// <returns>Message de retour</returns> public async Task <HttpResponseMessageResult> InjectConfig(ServiceFacade factory) { int cpt = 1; HttpResponseMessageResult res = new HttpResponseMessageResult() { IsSuccess = true }; foreach (Tuple <string, string, string, IEnumerable <KeyValuePair <string, string> >, KeyValuePair <string, string>, string> elt in _jsonServiceObjects) { try { string serviceName = elt.Item1; string httpVerb = elt.Item2; string subServiceName = elt.Item3; List <KeyValuePair <string, string> > qryStr = null; KeyValuePair <string, string> pairedReturn = elt.Item5; string body = elt.Item6; AbstractServiceFactory service = factory[serviceName]; if (service == null) { res.IsSuccess = false; res.Message += $"Service n° {cpt} - Le nom de service [{serviceName}] n'est pas connu."; return(res); } if (!string.IsNullOrWhiteSpace(pairedReturn.Value) && _references.ContainsKey(pairedReturn.Value)) { res.IsSuccess = false; res.Message += $"Service n° {cpt} - Une référence ({pairedReturn.Value}) existe déjà."; return(res); } // Transforme le body body = ReplaceGoodIds(body); // Transforme les querystring if (elt.Item4 != null) { qryStr = new List <KeyValuePair <string, string> >(); foreach (KeyValuePair <string, string> kvp in elt.Item4) { qryStr.Add(new KeyValuePair <string, string>(kvp.Key, ReplaceGoodIds(kvp.Value))); } } res.Message += $"Appel au service : [{serviceName}]/{subServiceName} ({httpVerb})"; // Globalisation HttpResponseMessageResult call = new HttpResponseMessageResult() { IsSuccess = true }; if (httpVerb == HTTP_VERB_POST) { call = await service.Post(subServiceName, qryStr, body); } if (httpVerb == HTTP_VERB_PUT) { call = await service.Put(subServiceName, qryStr, body); } if (httpVerb == HTTP_VERB_GET) { call = await service.Get(subServiceName, qryStr); } if ((call != null) && !call.IsSuccess) { res.IsSuccess = false; res.Message += $"Service n° {cpt} - Retour en erreur : {call.Message}"; res.Append(call); return(res); } JToken returnObj = null; if ((call != null) && !string.IsNullOrWhiteSpace(call.Json)) { returnObj = JsonConvert.DeserializeObject(call.Json, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }) as JToken; } if (!string.IsNullOrWhiteSpace(pairedReturn.Key) && !string.IsNullOrWhiteSpace(pairedReturn.Value) && (returnObj != null) && (returnObj[pairedReturn.Key] != null)) { long id = JsonConvert.DeserializeObject <long>(returnObj[pairedReturn.Key].ToString()); _references.Add(pairedReturn.Value, id); } res.Append(call); } catch (Exception ex) { res.IsSuccess = false; res.Message += $"Service n° {cpt} - Exception : {ex.Message}"; } cpt++; } return(res); }