Exemplo n.º 1
0
        //----------------------------------------------------------------
        public IEnumerable <string> GetEntities(string strIdTable, DateTime dataStart, DateTime dataEnd)
        {
            HashSet <string>        setIds = new HashSet <string>();
            COptimizedDataRoomTable table  = m_optimizedDb.GetTable(strIdTable);

            if (table != null)
            {
                strIdTable = table.TableId;
            }
            CListeEntitesDeMemoryDb <CDataRoom> lstRooms = new CListeEntitesDeMemoryDb <CDataRoom>(m_database);

            foreach (CDataRoom room in lstRooms)
            {
                try
                {
                    IDataRoomServer srv = GetRoomServer(room);
                    if (srv != null)
                    {
                        IEnumerable <string> lst = srv.GetEntitiesDirect(strIdTable, dataStart, dataEnd);
                        if (lst != null)
                        {
                            foreach (string strId in lst)
                            {
                                setIds.Add(strId);
                            }
                        }
                    }
                }
                catch { }
            }
            return(setIds);
        }
Exemplo n.º 2
0
        //-----------------------------------------------------
        public static IEnumerable <DataTable> GetDefinitionsTablesFromHotel( )
        {
            List <DataTable> lstTables = new List <DataTable>();

            try
            {
                IDataRoomServer srv = GetServer();
                DataSet         ds  = srv.GetDataSetModele();
                if (ds != null)
                {
                    foreach (DataTable table in ds.Tables)
                    {
                        lstTables.Add(table);
                    }
                }
            }
            catch { }
            return(lstTables);
        }
Exemplo n.º 3
0
        //-----------------------------------------------
        public IDataRoomServer GetRoomServer()
        {
            if (m_strProxyURL != null && m_strProxyURL.Length > 0)
            {
                try
                {
                    IDataHotelClientAllocator al     = Activator.GetObject(typeof(IDataHotelClientAllocator), m_strProxyURL + "/" + c_HotelAllocatorTypeName) as IDataHotelClientAllocator;
                    IDataHotelClient          client = al.GetNewClient();
                    client.Init(m_strHotelURL);
                    return(client.GetRoomServerProxy());
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            IDataRoomServer srv = Activator.GetObject(typeof(IDataRoomServer), m_strHotelURL + "/" + c_RoomTypeName) as IDataRoomServer;

            return(srv);
        }
Exemplo n.º 4
0
        //----------------------------------------------------------------
        public CResultAErreur SendData(string strIdTable, string strIdChamp, string strIdEntite, DateTime dataDate, double fValue)
        {
            CResultAErreur result = CResultAErreur.True;
            CDataRoom      room   = CDataDispatch.GetRoomFor(strIdEntite, m_database);

            try
            {
                IDataRoomServer srv = GetRoomServer(room);
                if (srv != null)
                {
                    result = srv.SendDataDirect(strIdTable, strIdChamp, strIdEntite, dataDate, fValue);
                }
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
            }


            return(result);
        }
Exemplo n.º 5
0
        //-------------------------------------------------------------------------------------
        public IDataRoomEntry GetFirstNotInSerie(
            string strTableId,
            string strEntityId,
            string strFieldId,
            DateTime dateRecherche,
            ITestDataHotel filtre)
        {
            CListeEntitesDeMemoryDb <CDataRoom> lstRooms = new CListeEntitesDeMemoryDb <CDataRoom>(m_database);
            IDataRoomEntry minEntry = null;

            foreach (CDataRoom room in lstRooms)
            {
                try
                {
                    IDataRoomServer srv = GetRoomServer(room);
                    if (srv != null)
                    {
                        IDataRoomEntry entry = srv.GetFirstNotInSerieDirect(
                            strTableId,
                            strEntityId,
                            strFieldId,
                            dateRecherche,
                            filtre);
                        if (entry != null)
                        {
                            if (minEntry == null || minEntry.Date > entry.Date)
                            {
                                minEntry = entry;
                            }
                        }
                    }
                }
                catch { }
            }
            return(minEntry);
        }
Exemplo n.º 6
0
 //-----------------------------------------------------------
 public CDataRoomProxy(IDataRoomServer serveur)
 {
     m_server = serveur;
 }
Exemplo n.º 7
0
        //----------------------------------------------------------------
        public CResultAErreurType <CDataTableFastSerialize> GetData(CDataHotelQuery query)
        {
            //Explose la requête pour chaque serveur de destination
            Dictionary <CDataRoom, CDataHotelQuery> dicRoomToQuery = new Dictionary <CDataRoom, CDataHotelQuery>();
            CListeEntitesDeMemoryDb <CDataRoom>     allRooms       = new CListeEntitesDeMemoryDb <CDataRoom>(m_database);

            foreach (string strIdEntite in query.EntitiesId)
            {
                //Si le dispatch ne sait pas qui interroger, on interroge tout le monde !
                CDataRoom        room     = CDataDispatch.GetRoomFor(strIdEntite, m_database);
                List <CDataRoom> lstToAsk = new List <CDataRoom>();
                if (room != null)
                {
                    lstToAsk.Add(room);
                }
                else
                {
                    lstToAsk.AddRange(allRooms);
                }
                foreach (CDataRoom roomToAsk in lstToAsk)
                {
                    CDataHotelQuery specQuery = null;
                    if (!dicRoomToQuery.TryGetValue(roomToAsk, out specQuery))
                    {
                        specQuery = query.Clone(false);
                        dicRoomToQuery[roomToAsk] = specQuery;
                    }
                    specQuery.EntitiesId.Add(strIdEntite);
                }
            }
            CResultAErreurType <CDataTableFastSerialize> myResult = new CResultAErreurType <CDataTableFastSerialize>();
            DataTable tableResult = new DataTable();

            foreach (KeyValuePair <CDataRoom, CDataHotelQuery> kv in dicRoomToQuery)
            {
                CDataRoom room = kv.Key;
                CResultAErreurType <CDataTableFastSerialize> res = new CResultAErreurType <CDataTableFastSerialize>();
                IDataRoomServer srv = GetRoomServer(room);
                if (srv != null)
                {
                    res = srv.GetDataDirect(kv.Value);
                    if (res && res.DataType != null)
                    {
                        DataTable tableTmp = res.DataType;
                        tableResult.Merge(tableTmp);
                    }
                }
            }
            //S'assure que la table résultat contient bien toutes les colonnes demandées
            foreach (string strIdCol in query.ChampsId)
            {
                if (tableResult.Columns[strIdCol] == null)
                {
                    tableResult.Columns.Add(strIdCol, typeof(double));
                }
            }
            tableResult.DefaultView.Sort = CDataHotelTable.c_nomChampTableDate + "," + CDataHotelTable.c_nomChampTableEntiteId;
            DataTable tableFinale = tableResult.Clone();

            tableFinale.BeginLoadData();
            foreach (DataRowView rv in tableResult.DefaultView)
            {
                DataRow row = tableFinale.NewRow();

                foreach (DataColumn col in tableFinale.Columns)
                {
                    row[col.ColumnName] = rv[col.ColumnName];
                }
                tableFinale.Rows.Add(row);
            }
            tableFinale.EndLoadData();
            tableResult = tableFinale;
            foreach (IChampHotelCalcule champCalcule in query.ChampsCalcules)
            {
                champCalcule.FinaliseCalcul(
                    query.TableId,
                    tableResult,
                    this,
                    query.DateDebut,
                    query.DateFin);
            }

            myResult.DataType = tableResult;
            return(myResult);
        }
Exemplo n.º 8
0
        //-------------------------------------------------
        public void FinaliseCalcul(
            string strIdTable,
            DataTable tableRemplieEtTriee,
            IDataRoomServer server,
            DateTime?dateDebut,
            DateTime?dateFin)
        {
            if (dateDebut == null)
            {
                return;
            }
            if (!tableRemplieEtTriee.Columns.Contains(NomChampFinal))
            {
                DataColumn col = new DataColumn(NomChampFinal, typeof(double));
                col.AllowDBNull = true;
                tableRemplieEtTriee.Columns.Add(col);
            }
            Dictionary <string, double?>  dicDureesParEntite = new Dictionary <string, double?>();
            Dictionary <string, DateTime> dicLastDates       = new Dictionary <string, DateTime>();

            //Identifie toutes les entités
            foreach (DataRow row in tableRemplieEtTriee.Rows)
            {
                string strEttId = (string)row[CDataHotelTable.c_nomChampTableEntiteId];
                double?fVal     = null;
                if (!dicDureesParEntite.TryGetValue(strEttId, out fVal))
                {
                    IDataRoomEntry entry = server.GetFirstNotInSerie(
                        strIdTable,
                        strEttId,
                        IdChampSource,
                        dateDebut.Value,
                        m_filtre);

                    if (entry == null)
                    {
                        fVal = 0;
                    }
                    else
                    {
                        fVal = ((DateTime)row[CDataHotelTable.c_nomChampTableDate] - entry.Date).TotalSeconds;
                    }
                    dicDureesParEntite[strEttId] = fVal;
                    dicLastDates[strEttId]       = (DateTime)row[CDataHotelTable.c_nomChampTableDate];
                    row[NomChampFinal]           = fVal.Value;
                }
                else
                {
                    if (row[IdChampSource] != DBNull.Value)
                    {
                        CDataRoomEntry entry = new CDataRoomEntry(
                            (DateTime)row[CDataHotelTable.c_nomChampTableDate],
                            (double)row[IdChampSource]);
                        if (Filtre.IsInFilter(IdChampSource, entry))
                        {
                            DateTime dt = dicLastDates[strEttId];
                            fVal  = dicDureesParEntite[strEttId];
                            fVal += ((DateTime)row[CDataHotelTable.c_nomChampTableDate] - dt).TotalSeconds;
                        }
                        else
                        {
                            fVal = 0;
                        }
                        dicDureesParEntite[strEttId] = fVal;
                        dicLastDates[strEttId]       = (DateTime)row[CDataHotelTable.c_nomChampTableDate];
                        row[NomChampFinal]           = fVal.Value;
                    }
                }
            }
        }
Exemplo n.º 9
0
        //-----------------------------------------------
        public IDataRoomServer GetRoomServerProxy()
        {
            IDataRoomServer srv = GetRoomServer();

            return(new CDataRoomProxy(srv));
        }