コード例 #1
0
ファイル: CDataRoomManager.cs プロジェクト: ykebaili/sc2idlls
        //-------------------------------------------------------------------------------------------------------------------
        public IDataRoomEntry GetFirstNotInSerie(
            string strIdTable,
            string strIdEntite,
            string strIdChamp,
            DateTime dateRecherche,
            ITestDataHotel test
            )
        {
            if (test == null)
            {
                return(null);
            }
            List <CDataRoomEntry> lstData = GetData(strIdTable, strIdEntite, strIdChamp, dateRecherche.Date, dateRecherche);

            lstData.Sort((x, y) => x.Date.CompareTo(y.Date));
            for (int n = lstData.Count - 1; n >= 0; n--)
            {
                if (!test.IsInFilter(strIdChamp, lstData[n]))
                {
                    return(lstData[n]);
                }
            }
            CPlageDates plage = GetPlageDates(strIdTable);

            if (dateRecherche > plage.DateMin)
            {
                return(GetFirstNotInSerie(strIdTable, strIdEntite, strIdChamp, dateRecherche.Date.AddSeconds(-0.1), test));
            }
            return(null);
        }
コード例 #2
0
      //--------------------------------------------------
      public virtual ITestDataHotel GetTestFinal(object objetPourSousProprietes)
      {
          CTestDataHotelASousElements testFinal = AlloueTestFinal();

          if (testFinal == null)
          {
              return(null);
          }
          List <ITestDataHotel> lstSousTests = new List <ITestDataHotel>();

          foreach (IDHFiltre dg in SousElements)
          {
              ITestDataHotel test = dg.GetTestFinal(objetPourSousProprietes);
              if (test != null)
              {
                  lstSousTests.Add(test);
              }
          }
          if (lstSousTests.Count == 0)
          {
              return(null);
          }
          testFinal.SousTests = lstSousTests;
          return(testFinal);
      }
コード例 #3
0
 //-------------------------------------------------
 public CChampHotelCalculeDuree(
     string strNomChampFinal,
     string strIdChampSource,
     ITestDataHotel filtre)
 {
     m_strNomChampFinal = strNomChampFinal;
     m_strIdChampSource = strIdChampSource;
     m_filtre           = filtre;
 }
コード例 #4
0
ファイル: CDataRoomServer.cs プロジェクト: ykebaili/sc2idlls
 //-------------------------------------------------------------------------------------
 public double GetDepuisCombienDeTempsEnSDirect(
     string strTableId,
     string strEntityId,
     string strFieldId,
     DateTime dateRecherche,
     ITestDataHotel filtre)
 {
     return(CDataRoomManager.Instance.GetDepuisCombienDeTempsEnS(
                strTableId,
                strEntityId,
                strFieldId,
                dateRecherche,
                filtre));
 }
コード例 #5
0
ファイル: CDataRoomServer.cs プロジェクト: ykebaili/sc2idlls
 //-------------------------------------------------------------------------------------
 public IDataRoomEntry GetFirstNotInSerieDirect(
     string strTableId,
     string strEntityId,
     string strFieldId,
     DateTime dateRecherche,
     ITestDataHotel filtre)
 {
     return(CDataRoomManager.Instance.GetFirstNotInSerie(
                strTableId,
                strEntityId,
                strFieldId,
                dateRecherche,
                filtre));
 }
コード例 #6
0
ファイル: CDataRoomManager.cs プロジェクト: ykebaili/sc2idlls
        //-------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Dit depuis combien de temps le champ demandé correspond
        /// au filtre à la date donnée
        /// </summary>
        /// <param name="strTableId"></param>
        /// <param name="strEntityId"></param>
        /// <param name="strFieldId"></param>
        /// <param name="dt"></param>
        /// <param name="filtre"></param>
        /// <returns></returns>
        public double GetDepuisCombienDeTempsEnS(
            string strTableId,
            string strEntityId,
            string strFieldId,
            DateTime dt,
            ITestDataHotel filtre)
        {
            IDataRoomEntry entry = GetKnownDataAt(strTableId, strEntityId, strFieldId, dt);

            if (entry == null)
            {
                return(0);
            }
            if (!filtre.IsInFilter(strFieldId, entry))
            {
                return(0);
            }
            entry = GetFirstNotInSerie(strTableId, strEntityId, strFieldId, dt, filtre);
            if (entry != null)
            {
                return((dt - entry.Date).TotalSeconds);
            }
            return(0);
        }
コード例 #7
0
ファイル: CDataRoomServer.cs プロジェクト: ykebaili/sc2idlls
        //-------------------------------------------------------------------------------------
        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);
        }
コード例 #8
0
        //-------------------------------------------------------
        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);
        }
コード例 #9
0
ファイル: CDataRoomProxy.cs プロジェクト: ykebaili/sc2idlls
 //-----------------------------------------------------------
 public double GetDepuisCombienDeTempsEnSDirect(string strTableId, string strEntityId, string strFieldId, DateTime dateRecherche, ITestDataHotel filtre)
 {
     return(m_server.GetDepuisCombienDeTempsEnSDirect(strTableId, strEntityId, strFieldId, dateRecherche, filtre));
 }
コード例 #10
0
ファイル: CDataRoomProxy.cs プロジェクト: ykebaili/sc2idlls
 //-----------------------------------------------------------
 public IDataRoomEntry GetFirstNotInSerie(string strTableId, string strEntityId, string strFieldId, DateTime dateRecherche, ITestDataHotel filtre)
 {
     return(m_server.GetFirstNotInSerie(strTableId, strEntityId, strFieldId, dateRecherche, filtre));
 }