Ejemplo n.º 1
0
        //----------------------------------------------------------
        public DataTable GetTableEntitiesVide(ITableDefinition tableDefinition, params string[] strIdColonnesSource)
        {
            CTableDefinitionEntitiesDataHotel tableEntites = tableDefinition as CTableDefinitionEntitiesDataHotel;

            if (tableEntites == null)
            {
                return(null);
            }
            DataTable  table = new DataTable(tableDefinition.TableName);
            DataColumn col   = new DataColumn(CTableDefinitionEntitiesDataHotel.c_strNomEntityId, typeof(string));

            col.ExtendedProperties[CODEQBase.c_extPropColonneId] = CTableDefinitionEntitiesDataHotel.c_strIdColEntityId;
            table.Columns.Add(col);
            return(table);
        }
Ejemplo n.º 2
0
        //----------------------------------------------------------
        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)
                {
                }
            }
        }
Ejemplo n.º 3
0
        //----------------------------------------------------------
        public DataTable GetData(CTableDefinitionEntitiesDataHotel table, DateTime dataStart, DateTime dataEnd)
        {
            CDataHotelClient client = new CDataHotelClient(m_strIp, m_nPort);

            try
            {
                IEnumerable <string> lstIds      = client.GetRoomServer().GetEntities(table.Id, dataStart, dataEnd);
                DataTable            tableRetour = GetTableEntitiesVide(table);
                tableRetour.BeginLoadData();
                foreach (string strId in lstIds)
                {
                    DataRow row = tableRetour.NewRow();
                    row[CTableDefinitionEntitiesDataHotel.c_strNomEntityId] = strId;
                    tableRetour.Rows.Add(row);
                }
                return(tableRetour);
            }
            catch
            {
            }
            return(null);
        }
Ejemplo n.º 4
0
        //-------------------------------------------------------
        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);
        }