コード例 #1
0
ファイル: DataFileManager.cs プロジェクト: cdy816/mars
        /// <summary>
        ///
        /// </summary>
        /// <param name="filename"></param>
        private void CheckRemoveOldFile(string filename)
        {
            string sname = filename.Replace(DataFileExtends, "").Replace(HisDataFileExtends, "");
            string stime = sname.Substring(sname.Length - 12, 12);
            int    yy = 0, mm = 0, dd = 0;

            int id = -1;

            int.TryParse(sname.Substring(sname.Length - 15, 3), out id);

            if (id == -1)
            {
                return;
            }

            if (!int.TryParse(stime.Substring(0, 4), out yy))
            {
                return;
            }

            if (!int.TryParse(stime.Substring(4, 2), out mm))
            {
                return;
            }

            if (!int.TryParse(stime.Substring(6, 2), out dd))
            {
                return;
            }
            int hhspan = int.Parse(stime.Substring(8, 2));

            int hhind = int.Parse(stime.Substring(10, 2));

            int hh = hhspan * hhind;


            DateTime startTime = new DateTime(yy, mm, dd, hh, 0, 0);

            YearTimeFile yt = null;

            if (mTimeFileMaps.ContainsKey(id))
            {
                if (mTimeFileMaps[id].ContainsKey(yy))
                {
                    yt = mTimeFileMaps[id][yy];
                }
            }

            if (yt != null)
            {
                yt.CheckFileExist(filename, startTime);
            }
        }
コード例 #2
0
ファイル: DataFileManager.cs プロジェクト: cdy816/mars
        /// <summary>
        ///
        /// </summary>
        /// <param name="fileName"></param>
        private void ParseFileName(System.IO.FileInfo file)
        {
            string sname = file.Name.Replace(DataFileExtends, "").Replace(HisDataFileExtends, "").Replace(ZipHisDataFileExtends, "");
            string stime = sname.Substring(sname.Length - 12, 12);
            int    yy = 0, mm = 0, dd = 0;

            int id = -1;

            try
            {
                id = int.Parse(sname.Substring(sname.Length - 15, 3), System.Globalization.NumberStyles.HexNumber);

                if (id < 0)
                {
                    return;
                }
            }
            catch
            {
                return;
            }

            if (!int.TryParse(stime.Substring(0, 4), out yy))
            {
                return;
            }

            if (!int.TryParse(stime.Substring(4, 2), out mm))
            {
                return;
            }

            if (!int.TryParse(stime.Substring(6, 2), out dd))
            {
                return;
            }
            int hhspan = int.Parse(stime.Substring(8, 2));

            int hhind = int.Parse(stime.Substring(10, 2));

            int hh = hhspan * hhind;


            DateTime startTime = new DateTime(yy, mm, dd, hh, 0, 0);

            YearTimeFile yt = new YearTimeFile()
            {
                TimeKey = yy
            };

            if (mTimeFileMaps.ContainsKey(id))
            {
                if (mTimeFileMaps[id].ContainsKey(yy))
                {
                    yt = mTimeFileMaps[id][yy];
                }
                else
                {
                    mTimeFileMaps[id].Add(yy, yt);
                }
            }
            else
            {
                mTimeFileMaps.Add(id, new Dictionary <int, YearTimeFile>());
                mTimeFileMaps[id].Add(yy, yt);
            }

            if (file.Extension == DataFileExtends)
            {
                yt.AddFile(startTime, new TimeSpan(hhspan, 0, 0), new DataFileInfo4()
                {
                    Duration = new TimeSpan(hhspan, 0, 0), StartTime = startTime, FileName = file.FullName, FId = mDatabaseName + id
                });
            }
            else if (file.Extension == HisDataFileExtends || file.Extension == ZipHisDataFileExtends)
            {
                yt.AddFile(startTime, new TimeSpan(hhspan, 0, 0), new HisDataFileInfo4()
                {
                    Duration = new TimeSpan(hhspan, 0, 0), StartTime = startTime, FileName = file.FullName, FId = mDatabaseName + id, IsZipFile = file.Extension == ZipHisDataFileExtends
                });
            }
        }