//---------------------------------------------- public override CResultAErreur GetDatas(CEasyQuerySource source, params string[] strIdsColonnesSource) { CResultAErreur result = CResultAErreur.True; CDataHotelConnexion filler = source.Connexion as CDataHotelConnexion; if (filler != null) { List <string> strColsHotel = new List <string>(); foreach (IColumnDefinition col in Columns) { if (strIdsColonnesSource.Contains(col.Id)) { CColonneDefinitionDataHotel colHotel = col as CColonneDefinitionDataHotel; if (colHotel != null) { strColsHotel.Add(colHotel.Id); } } } } return(result); }
//------------------------------------------------------- protected override CResultAErreur GetDatasHorsCalculees(CListeQuerySource sources) { CEasyQuery query = Query; CResultAErreur result = CResultAErreur.True; if (query == null || sources == null) { result.EmpileErreur(I.T("Table @1 needs a source to provide datas|20001", NomFinal)); return(result); } CEasyQuerySource source = sources.GetSourceFromId(TableDefinition.SourceId); CDataHotelConnexion hotelConnexion = source != null ? source.Connexion as CDataHotelConnexion : null; if (hotelConnexion == null) { result.EmpileErreur(I.T("No connection for table @1|20006", NomFinal)); return(result); } CTableDefinitionDataHotel tableHotel = m_definitionTable as CTableDefinitionDataHotel; if (tableHotel == null) { result.EmpileErreur(I.T("Table @1 can not be calculated. A DataHotel table should be used as source|20002", NomFinal)); return(result); } DateTime?dateDebut = null; DateTime?dateFin = null; CContexteEvaluationExpression ctxEval = new CContexteEvaluationExpression(Query); if (m_formuleDateDebut != null) { result = m_formuleDateDebut.Eval(ctxEval); if (!result) { result.EmpileErreur(I.T("Error on start date formula in table @1|20003", NomFinal)); } else { dateDebut = result.Data as DateTime?; } } if (m_formuleDateFin != null) { result = m_formuleDateFin.Eval(ctxEval); if (!result) { result.EmpileErreur(I.T("Error on end date formula in table @1|20004", NomFinal)); } else { dateFin = result.Data as DateTime?; } } if (dateDebut == null || dateFin == null) { result.EmpileErreur(I.T("Both start date and end date must be set for table @1|20005", NomFinal)); } if (!result) { return(result); } List <string> lstIdsEntites = new List <string>(); if (SourceEntites != null) { lstIdsEntites.AddRange(SourceEntites.GetListeIdsEntites(Query)); } ITestDataHotel test = null; //Calcule le filtre if (m_filtre != null) { test = m_filtre.GetTestFinal(Query); } CDataHotelQuery hotelQuery = new CDataHotelQuery(); hotelQuery.TableId = tableHotel.Id; hotelQuery.DateDebut = dateDebut.Value; hotelQuery.DateFin = dateFin.Value; hotelQuery.EntitiesId.AddRange(lstIdsEntites); hotelQuery.Filtre = test; List <string> lstIdsColonnes = new List <string>(); List <IChampHotelCalcule> lstCalcs = new List <IChampHotelCalcule>(); foreach (IColumnDeEasyQuery col in m_listeColonnes) { CColumnEQFromSource colFromSource = col as CColumnEQFromSource; if (colFromSource != null) { lstIdsColonnes.Add(colFromSource.IdColumnSource); } CColonneCalculeeDataHotel colCalc = col as CColonneCalculeeDataHotel; if (colCalc != null) { if (colCalc.Calcul != null) { IChampHotelCalcule champHotelCalc = colCalc.Calcul.GetChampHotel(Query); if (champHotelCalc != null) { champHotelCalc.NomChampFinal = colCalc.ColumnName; lstCalcs.Add(champHotelCalc); } } } } hotelQuery.ChampsId = lstIdsColonnes; hotelQuery.ChampsCalcules = lstCalcs; DataTable tableResult = hotelConnexion.GetData(tableHotel, hotelQuery); if (tableResult != null) { Dictionary <string, IColumnDeEasyQuery> colNameSourceToDestCol = new Dictionary <string, IColumnDeEasyQuery>(); foreach (IColumnDeEasyQuery col in m_listeColonnes) { CColumnEQFromSource cs = col as CColumnEQFromSource; if (cs != null) { IColumnDefinition def = tableHotel.GetColumn(cs.IdColumnSource); if (def != null) { colNameSourceToDestCol[def.ColumnName] = col; } } } foreach (DataColumn col in tableResult.Columns) { IColumnDeEasyQuery colThis = null; if (colNameSourceToDestCol.TryGetValue(col.ColumnName, out colThis)) { col.ColumnName = colThis.ColumnName; } } } result.Data = tableResult; return(result); }
//------------------------------------------------------- protected override CResultAErreur GetDatasHorsCalculees(CListeQuerySource sources) { CResultAErreur result = CResultAErreur.True; if (sources == null) { result.EmpileErreur(I.T("Table @1 needs a source to provide datas|20001", NomFinal)); return(result); } CEasyQuerySource source = sources.GetSourceFromId(TableDefinition.SourceId); CDataHotelConnexion hotelConnexion = source != null ? source.Connexion as CDataHotelConnexion : null; if (hotelConnexion == null) { result.EmpileErreur(I.T("No connection for table @1|20006", NomFinal)); return(result); } CTableDefinitionEntitiesDataHotel tableHotel = m_definitionTable as CTableDefinitionEntitiesDataHotel; if (tableHotel == null) { result.EmpileErreur(I.T("Table @1 can not be calculated. A DataHotel table should be used as source|20002", NomFinal)); return(result); } DateTime?dateDebut = null; DateTime?dateFin = null; CContexteEvaluationExpression ctxEval = new CContexteEvaluationExpression(Query); if (m_formuleDateDebut != null) { result = m_formuleDateDebut.Eval(ctxEval); if (!result) { result.EmpileErreur(I.T("Error on start date formula in table @1|20003", NomFinal)); } else { dateDebut = result.Data as DateTime?; } } if (m_formuleDateFin != null) { result = m_formuleDateFin.Eval(ctxEval); if (!result) { result.EmpileErreur(I.T("Error on end date formula in table @1|20004", NomFinal)); } else { dateFin = result.Data as DateTime?; } } if (dateDebut == null || dateFin == null) { result.EmpileErreur(I.T("Both start date and end date must be set for table @1|20005", NomFinal)); } if (!result) { return(result); } DataTable tableResult = hotelConnexion.GetData(tableHotel, dateDebut.Value, dateFin.Value); if (tableResult != null) { Dictionary <string, IColumnDeEasyQuery> colNameSourceToDestCol = new Dictionary <string, IColumnDeEasyQuery>(); foreach (IColumnDeEasyQuery col in m_listeColonnes) { CColumnEQFromSource cs = col as CColumnEQFromSource; if (cs != null) { IColumnDefinition def = tableHotel.GetColumn(cs.IdColumnSource); if (def != null) { colNameSourceToDestCol[def.ColumnName] = col; } } } foreach (DataColumn col in tableResult.Columns) { IColumnDeEasyQuery colThis = null; if (colNameSourceToDestCol.TryGetValue(col.ColumnName, out colThis)) { col.ColumnName = colThis.ColumnName; } } } result.Data = tableResult; return(result); }