コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public static DataFileSeriserbase GetFileSeriser(this HisDataFileInfo4 file)
        {
            //判断是否为压缩文件
            if (file.IsZipFile && (System.IO.Path.GetExtension(file.FileName) == DataFileManager.ZipHisDataFileExtends || !System.IO.File.Exists(file.FileName)))
            {
                if (!System.IO.File.Exists(file.FileName) && !string.IsNullOrEmpty(file.BackFileName))
                {
                    file.FileName = file.BackFileName;
                }

                string spath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(file.FileName), "tmp");
                if (!System.IO.Directory.Exists(spath))
                {
                    System.IO.Directory.CreateDirectory(spath);
                }
                spath = System.IO.Path.Combine(spath, System.IO.Path.GetFileName(file.FileName).Replace(DataFileManager.ZipHisDataFileExtends, DataFileManager.HisDataFileExtends));
                UnZipFile(file.FileName, spath);
                file.BackFileName = file.FileName;
                file.FileName     = spath;
            }
            var re = DataFileSeriserManager.manager.GetDefaultFileSersie();

            re.FileName = file.FileName;
            re.OpenForReadOnly(file.FileName);
            return(re);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="file"></param>
        /// <param name="tid"></param>
        /// <param name="times"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static HisQueryResult <T> Read <T>(this HisDataFileInfo4 file, int tid, List <DateTime> times, QueryValueMatchType type)
        {
            HisQueryResult <T> re = new HisQueryResult <T>(times.Count);

            Read <T>(file, tid, times, type, re);
            return(re);
        }
コード例 #3
0
        /// <summary>
        /// 读取某时间段内的所有bool值
        /// </summary>
        /// <param name="file"></param>
        /// <param name="tid"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="result"></param>
        public static void ReadAllValue <T>(this HisDataFileInfo4 file, int tid, DateTime startTime, DateTime endTime, HisQueryResult <T> result)
        {
            //long ltmp = 0, ltmp1 = 0;
            //Stopwatch sw = new Stopwatch();
            //sw.Start();

            var vff = file.GetFileSeriser();

            var offset = file.GetFileOffsets(startTime, endTime);

            //var vff = file.GetFileSeriser();
            //ltmp = sw.ElapsedMilliseconds;

            foreach (var vv in offset)
            {
                DateTime stime = vv.Key > startTime ? vv.Key : startTime;
                DateTime etime = vv.Key + vv.Value.Item1 > endTime ? endTime : vv.Key + vv.Value.Item1;
                ReadAllValue(vff, vv.Value.Item2, tid, stime, etime, result);
            }

            //ltmp1 = sw.ElapsedMilliseconds;
            //vff.Close();
            Task.Run(() => { vff.Dispose(); });

            //sw.Stop();
            //Debug.WriteLine("ReadAllValue:" + ltmp + " ," + (ltmp1 - ltmp) + "," + (sw.ElapsedMilliseconds - ltmp1));
        }
コード例 #4
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="file"></param>
 /// <param name="tid"></param>
 /// <param name="time"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public static object Read <T>(this HisDataFileInfo4 file, int tid, DateTime time, QueryValueMatchType type)
 {
     using (var vff = file.GetFileSeriser())
     {
         var offset = file.GetFileOffsets(time);
         return(Read <T>(vff, offset, tid, time, type));
     }
 }
コード例 #5
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="file"></param>
 /// <param name="tid"></param>
 /// <param name="times"></param>
 /// <param name="type"></param>
 /// <param name="result"></param>
 public static void Read <T>(this HisDataFileInfo4 file, int tid, List <DateTime> times, QueryValueMatchType type, HisQueryResult <T> result)
 {
     using (var vff = file.GetFileSeriser())
     {
         Dictionary <long, List <DateTime> > moffs = new Dictionary <long, List <DateTime> >();
         foreach (var vv in times)
         {
             var ff = file.GetFileOffsets(vv);
             if (moffs.ContainsKey(ff))
             {
                 moffs[ff].Add(vv);
             }
             else
             {
                 moffs.Add(ff, new List <DateTime>()
                 {
                     vv
                 });
             }
         }
         foreach (var vf in moffs)
         {
             if (vf.Key > -1)
             {
                 Read <T>(vff, vf.Key, tid, vf.Value, type, result);
             }
             else
             {
                 foreach (var vv in vf.Value)
                 {
                     result.Add(default(T), vv, (byte)QualityConst.Null);
                 }
             }
         }
     }
 }