Ejemplo n.º 1
0
 //--------------------------------------------------------------------
 public static void Read(this CDataRoomEntry entry, BinaryReader reader, DateTime dt)
 {
     byte[] bts = new byte[3];
     reader.Read(bts, 0, 3);
     entry.Date  = new DateTime(dt.Year, dt.Month, dt.Day, (int)bts[0], (int)bts[1], (int)bts[2]);
     entry.Value = reader.ReadDouble();
 }
Ejemplo n.º 2
0
        //--------------------------------------------------------------------
        public static void Write(this CDataRoomEntry entry, BinaryWriter writer)
        {
            DateTime dt = entry.Date;

            byte[] bts = new byte[] {
                (byte)dt.Hour,
                (byte)dt.Minute,
                (byte)dt.Second
            };
            writer.Write(bts, 0, 3);
            writer.Write(entry.Value);
        }
Ejemplo n.º 3
0
        //-------------------------------------------------------------------------------------------------------------------
        private List <CDataRoomEntry> ReadFile(DateTime dt, string strFichier)
        {
            List <CDataRoomEntry> lstRecs = new List <CDataRoomEntry>();
            FileStream            fs      = new FileStream(strFichier, FileMode.Open, FileAccess.Read);
            BinaryReader          reader  = new BinaryReader(fs);
            long nLength = fs.Length;

            while (fs.Position < nLength)
            {
                CDataRoomEntry rec = new CDataRoomEntry();
                rec.Read(reader, dt);
                lstRecs.Add(rec);
            }
            reader.Close();
            fs.Close();
            reader.Dispose();
            fs.Dispose();
            return(lstRecs);
        }
Ejemplo 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);
        }
Ejemplo n.º 5
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;
                    }
                }
            }
        }