Esempio n. 1
0
        /// <summary>
        /// Determine and create the directory where the raw data is saved in 1-hour chunks.
        /// </summary>
        private void DetermineFilePath()
        {
            if (isActive)
            {
                if (presentHour != DateTime.Now.Hour)
                {
                    if (bwPLFormat != null)
                    {
                        bwPLFormat.CloseFile();
                    }
                    presentHour = DateTime.Now.Hour;
                    // Need to create a new directory and switch the file name
                    dayPath = DirectoryStructure.DayDirectoryToUse(aRootPathName);

                    // Make sure hour directory exists
                    currentDataFile = dayPath + "\\" + presentHour + "\\";
                    if (!System.IO.Directory.Exists(currentDataFile))
                    {
                        System.IO.Directory.CreateDirectory(currentDataFile);
                    }

                    currentDataFile = currentDataFile + FILE_TYPE_MONIKER + "." +
                                      DirectoryStructure.GetDate() + "." + COMP_ID + "." + FILE_EXT;

                    bwPLFormat = new ByteWriter(currentDataFile, true);
                    bwPLFormat.OpenFile();

                    // Ensure that the first data point in the new file will start
                    // with the full, rather than differential, timecode info.
                    isForceTimestampSave = true;
                }
            }
        }
Esempio n. 2
0
        private static DayFolderNode[] GetDayFolderInformation(FileSystemInfo[] fia)
        {
            if (fia == null || fia.Length < 1)
            {
                return(null);
            }

            System.Collections.ArrayList ret = new System.Collections.ArrayList();

            DayFolderNode dfn;

            HourFolderNode[] hours = null;

            DateTime dt;

            foreach (FileSystemInfo fsi in fia)
            {
                //fill the info
                dfn = new DayFolderNode();

                dfn.folderName  = fsi.FullName;
                dfn.dayAsString = fsi.Name;


                if (!DirectoryStructure.TimeFromDayFolderName(fsi.Name, out dt))
                {
                    return(null);
                }

                dfn.startUnixTime = UnixTime.GetUnixTime(dt);
                dfn.endUnixTime   = dfn.startUnixTime + UnixTime.MilliInDay - 1;

                //Get the hour information
                hours = DirectoryStructure.GetHourFolderInformation(fsi.FullName, dfn.startUnixTime);
                if (hours == null || hours.Length < 1)
                {
                    continue;
                }

                dfn.hours = hours;

                //add to the list
                ret.Add(dfn);

                hours = null;
                dfn   = null;
            }

            if (ret.Count > 0)
            {
                //Create the array to return
                return((DayFolderNode[])ret.ToArray(typeof(DayFolderNode)));
            }
            else
            {
                return(null);
            }
        }