Exemplo n.º 1
0
        //-------------------------------------------------------------------------------------------------------------------
        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);
        }
Exemplo n.º 2
0
        //--------------------------------------------------------------------
        private CPlageDates ReCalcDatesMinEtMax(string strIdTable)
        {
            CPlageDates plage = new CPlageDates();

            plage.DateMin = DateTime.Now.Date;
            plage.DateMin = DateTime.Now.Date;
            StringBuilder bl = new StringBuilder();

            AddPathForTable(strIdTable, bl);
            if (Directory.Exists(bl.ToString()))
            {
                int        nYear    = 0;
                List <int> lstYears = new List <int>(from strDir in Directory.GetDirectories(bl.ToString())
                                                     where Int32.TryParse(Path.GetFileName(strDir), out nYear)
                                                     select nYear);
                lstYears.Sort();
                if (lstYears.Count > 0)
                {
                    bl = new StringBuilder();
                    AddPathForTable(strIdTable, bl);
                    bl.Append("\\");
                    bl.Append(lstYears[0].ToString());
                    int        nMonth    = 0;
                    List <int> lstMonths = new List <int>(from strDir in Directory.GetDirectories(bl.ToString())
                                                          where Int32.TryParse(Path.GetFileName(strDir), out nMonth) &&
                                                          nMonth >= 1 && nMonth <= 12
                                                          select nMonth);
                    lstMonths.Sort();
                    if (lstMonths.Count > 0)
                    {
                        plage.DateMin = new DateTime(nYear, lstMonths[0], 1);
                    }
                    if (lstYears.Count == 1)
                    {
                        //Même année
                        plage.DateMax = new DateTime(nYear, lstMonths[lstMonths.Count - 1], 1).AddMonths(1).AddSeconds(-0.1);
                    }
                    else
                    {
                        bl = new StringBuilder();
                        AddPathForTable(strIdTable, bl);
                        bl.Append("\\");
                        bl.Append(lstYears[lstYears.Count - 1].ToString());
                        nMonth    = 0;
                        lstMonths = new List <int>(from strDir in Directory.GetDirectories(bl.ToString())
                                                   where Int32.TryParse(strDir, out nMonth) &&
                                                   nMonth >= 1 && nMonth <= 12
                                                   select nMonth);
                        lstMonths.Sort();
                        if (lstMonths.Count > 0)
                        {
                            plage.DateMax = new DateTime(nYear, lstMonths[lstMonths.Count - 1], 1).AddMonths(1).AddSeconds(-0.1);
                        }
                    }
                }
            }
            return(plage);
        }
Exemplo n.º 3
0
        //--------------------------------------------------------------------
        private CPlageDates GetPlageDates(string strIdTable)
        {
            CPlageDates plage = null;

            if (!m_dicPlagesDeDates.TryGetValue(strIdTable, out plage))
            {
                plage = ReCalcDatesMinEtMax(strIdTable);
                m_dicPlagesDeDates[strIdTable] = plage;
            }
            return(plage);
        }
Exemplo n.º 4
0
        //--------------------------------------------------------------------
        public CResultAErreur SetData(string strTableId, string strIdEntite, string strIdChamp, DateTime dt, double fVal)
        {
            string   strFile  = GetPathForData(strTableId, strIdEntite, strIdChamp, dt);
            DateTime dtChrono = DateTime.Now;

            m_spAssureRep += DateTime.Now - dtChrono;
            FileStream stream = null;

            dtChrono = DateTime.Now;
            if (!File.Exists(strFile))
            {
                CUtilRepertoire.AssureRepertoirePourFichier(strFile);
                stream = new FileStream(strFile, FileMode.CreateNew, FileAccess.Write);
            }
            else
            {
                stream = new FileStream(strFile, FileMode.Append, FileAccess.Write);
            }

            BinaryWriter   writer = new BinaryWriter(stream);
            CDataRoomEntry rec    = new CDataRoomEntry(dt, fVal);

            rec.Write(writer);
            writer.Close();
            writer.Dispose();
            stream.Close();
            stream.Dispose();
            m_spWrite += DateTime.Now - dtChrono;
            CPlageDates plage = GetPlageDates(strTableId);

            if (dt > plage.DateMax)
            {
                plage.DateMax = dt;
            }
            if (dt < plage.DateMin)
            {
                plage.DateMin = dt;
            }
            return(CResultAErreur.True);
        }
Exemplo n.º 5
0
        //-------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Retourne la donnée connue à la date demandée
        /// </summary>
        /// <param name="strIdTable"></param>
        /// <param name="strIdEntite"></param>
        /// <param name="strIdChamp"></param>
        /// <param name="dateRecherche"></param>
        /// <param name="test"></param>
        /// <param name="recordSuivantQuiRépondAuTest"></param>
        /// <returns></returns>
        private IDataRoomEntry GetKnownDataAt(
            string strIdTable,
            string strIdEntite,
            string strIdChamp,
            DateTime dateRecherche
            )
        {
            List <CDataRoomEntry> lstData = GetData(strIdTable, strIdEntite, strIdChamp, dateRecherche.Date, dateRecherche);

            lstData.Sort((x, y) => x.Date.CompareTo(y.Date));
            if (lstData.Count > 0)
            {
                return(lstData[lstData.Count - 1]);
            }
            CPlageDates plage = GetPlageDates(strIdTable);

            if (dateRecherche > plage.DateMin)
            {
                return(GetKnownDataAt(strIdTable, strIdEntite, strIdChamp, dateRecherche.Date.AddSeconds(-0.1)));
            }
            return(null);
        }