//---------------------------------------------------------- private void AssureListeTables() { if (m_listeTables == null) { CDataHotelClient client = new CDataHotelClient(m_strIp, m_nPort); try { DataSet ds = client.GetRoomServer().GetDataSetModele(); if (ds != null) { m_listeTables = new List <ITableDefinition>(); foreach (DataTable table in ds.Tables) { string strTableId = table.ExtendedProperties[CDataHotelTable.c_extPropTableId] as string; if (strTableId != null) { CTableDefinitionDataHotel tableDef = new CTableDefinitionDataHotel(strTableId, table.TableName); tableDef.AddColumn(new CColonneDefinitionHotelEntiteId("Data entity id")); tableDef.AddColumn(new CColonneDefinitionHotelDate("Data date")); foreach (DataColumn col in table.Columns) { string strColId = col.ExtendedProperties[CDataHotelField.c_extPropColumnId] as string; if (strColId != null) { CColonneDefinitionDataHotel colHotel = new CColonneDefinitionDataHotel(strColId, col.ColumnName); tableDef.AddColumn(colHotel); } } m_listeTables.Add(tableDef); CTableDefinitionEntitiesDataHotel tableE = new CTableDefinitionEntitiesDataHotel(strTableId, table.TableName); m_listeTables.Add(tableE); } } } } catch (Exception e) { } } }
//---------------------------------------------- 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); }
//---------------------------------------------------------- public DataTable GetData(CTableDefinitionDataHotel tableHotel, CDataHotelQuery query) { DataTable tableResult = null; try { CDataHotelClient client = new CDataHotelClient(m_strIp, m_nPort); //Convertit les ids de colonne en id de colonne DataHotel; List <string> lstIds = new List <string>(); Dictionary <string, IColumnDefinition> dicIdToColDef = new Dictionary <string, IColumnDefinition>(); //remarque sur le code : //au début, les CColonneDefinitionDataHotel avaient un id qui leur était propre //au lieu de prendre l'id de la colonne de DataHotel, du coup, //il fallait faire une conversion des IdCol -> IdHotel. //Cette notion a été corrigée, mais pour compatiblité, on continue à //convertir. foreach (string strIdCol in query.ChampsId) { IColumnDefinition col = tableHotel.GetColumn(strIdCol); CColonneDefinitionDataHotel colHot = col as CColonneDefinitionDataHotel; if (colHot != null) { lstIds.Add(colHot.HotelColumnId); dicIdToColDef[colHot.HotelColumnId] = col; if (query.Filtre != null) { query.Filtre.ReplaceColumnId(strIdCol, colHot.HotelColumnId); } } if (col is CColonneDefinitionHotelDate) { dicIdToColDef[CDataHotelTable.c_nomChampTableDate] = col; } if (col is CColonneDefinitionHotelEntiteId) { dicIdToColDef[CDataHotelTable.c_nomChampTableEntiteId] = col; } } query.ChampsId = lstIds; CResultAErreurType <CDataTableFastSerialize> res = client.GetRoomServer().GetData(query); if (res && res.Data != null) { tableResult = res.DataType; foreach (DataColumn col in tableResult.Columns) { IColumnDefinition colDef = null; if (dicIdToColDef.TryGetValue(col.ColumnName, out colDef)) { col.ExtendedProperties[CODEQBase.c_extPropColonneId] = col.ColumnName; col.ColumnName = colDef.ColumnName; } } } return(tableResult); } catch (Exception ex) { } return(null); }