Esempio n. 1
0
        /// <summary>
        /// Returns the event log file path for a new destination drive given a source in IMAGE_FILE_DATA format
        /// </summary>
        /// <param name="fd"></param>
        /// <param name="destDrive"></param>
        /// <returns></returns>
        public string GetEventLogFilePath(IMAGE_FILE_DATA fd, string destDrive)
        {
            lock (singleton)
            {

                int year = fd.timeStamp.ToUniversalTime().Year;
                int month = fd.timeStamp.ToUniversalTime().Month;
                int day = fd.timeStamp.ToUniversalTime().Day;
                int hour = fd.timeStamp.ToUniversalTime().Hour;

                string path = destDrive + StorageDir + "\\" +
                                year.ToString("####") + "\\" +
                                month.ToString("####") + "\\" +
                                day.ToString("####") + "\\" +
                                hour.ToString("####") + "\\" +
                                fd.PSSName + "\\" +
                                "EVENTLOG.TXT";

                return (path);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// supply the complete path, and get back the parsed info from the path structure
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public IMAGE_FILE_DATA ParseFileCompleteLogfilePath(string path)
        {
            //D:\DVRSTORAGE\2009\8\22\20\David-PC17\EVENTLOG.TXT

            try
            {
                string[] pathSegments = path.Split('\\');

                int startingIndex = 0;

                // find the DVRSTORAGE segment
                for (int i = 0; i < pathSegments.Count(); i++)
                {
                    if (pathSegments[i].Contains(StorageDir))
                    {
                        startingIndex = i;
                        break;
                    }
                }
                IMAGE_FILE_DATA data = new IMAGE_FILE_DATA();
                data.completePath = path;
                data.PSSName = pathSegments[startingIndex + 5];

                data.fileNameOnly = pathSegments[startingIndex + 6];
                data.dirOnly = path.Replace(pathSegments[startingIndex + 6], "");

                int year = Convert.ToInt32(pathSegments[startingIndex + 1]);
                int month = Convert.ToInt32(pathSegments[startingIndex + 2]);
                int day = Convert.ToInt32(pathSegments[startingIndex + 3]);
                int hour = Convert.ToInt32(pathSegments[startingIndex + 4]);

                data.timeStamp = new DateTime(year, month, day, hour, 0, 0);

                char[] trimLeadingChar = { '\\' };

                string removeDriveColon = path.Replace(pathSegments[0], "").TrimStart(trimLeadingChar);
                data.relativePath = removeDriveColon.Replace(StorageDir + "\\", "");

                return (data);
            }
            catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.INFORMATIONAL); return (null); }
        }
Esempio n. 3
0
        /// <summary>
        /// Creats a complete destination path for a new destination drive.
        /// </summary>
        /// <param name="fd"></param>
        /// <param name="destinationDrive"></param>
        /// <returns></returns>
        public IMAGE_FILE_DATA GetCompleteFilePath(IMAGE_FILE_DATA srcFd, string destinationDrive)
        {
            lock (singleton)
            {
                int year;
                int month;
                int day;
                int hour;

                // STORAGE_DIR/Year/Month/Day/Hour/PSS_Name/Source_Name/YYYY_MM_DD_HH_MM_SS_mmm.jpg
                IMAGE_FILE_DATA newFd = new IMAGE_FILE_DATA();

                string[] sp = srcFd.fileNameOnly.Split('_');
                newFd.fileNameOnly = srcFd.fileNameOnly;
                newFd.timeStamp = srcFd.timeStamp;

                newFd.PSSName = srcFd.PSSName;
                newFd.SourceName = srcFd.SourceName;

                year =  srcFd.timeStamp.Year;
                month = srcFd.timeStamp.Month;
                day = srcFd.timeStamp.Day;
                hour = srcFd.timeStamp.Hour;

                if (srcFd.SourceName != null) // jpeg file case
                {
                    newFd.relativePath = StorageDir + "\\" +
                                    year.ToString() + "\\" +
                                    month.ToString() + "\\" +
                                    day.ToString() + "\\" +
                                    hour.ToString() + "\\" +
                                    srcFd.PSSName + "\\" +
                                    srcFd.SourceName + "\\";
                }
                else
                {  // eventlog.txt file case
                    newFd.relativePath = StorageDir + "\\" +
                                   year.ToString() + "\\" +
                                   month.ToString() + "\\" +
                                   day.ToString() + "\\" +
                                   hour.ToString() + "\\" +
                                   srcFd.PSSName + "\\";
                }

                string destDir = null;

                if (srcFd.SourceName != null) // jpeg file case
                {
                    destDir = destinationDrive + StorageDir + "\\" +
                                   year.ToString() + "\\" +
                                   month.ToString() + "\\" +
                                   day.ToString() + "\\" +
                                   hour.ToString() + "\\" +
                                   srcFd.PSSName + "\\" +
                                   srcFd.SourceName + "\\";
                }
                else
                {           // eventlog.txt file case
                    destDir = destinationDrive + StorageDir + "\\" +
                                 year.ToString() + "\\" +
                                 month.ToString() + "\\" +
                                 day.ToString() + "\\" +
                                 hour.ToString() + "\\" +
                                 srcFd.PSSName + "\\";
                }

                newFd.dirOnly = destDir;

                newFd.completePath  = destDir + srcFd.fileNameOnly;

                return (newFd);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// supply the complete path, and get back the parsed info from the path structure
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public IMAGE_FILE_DATA ParseFileCompleteJpegPath(string path)
        {
            //F:\DVRSTORAGE\2009\8\19\17\k000a9df304bf\1\2009_08_19_17_03_46_4062690.jpg

            try
            {
                string[] pathSegments = path.Split('\\');

                int startingIndex = 0;

                // find the DVRSTORAGE segment
                for (int i = 0; i < pathSegments.Count(); i++)
                {
                    if (pathSegments[i].Contains(StorageDir))
                    {
                        startingIndex = i;
                        break;
                    }
                }
                IMAGE_FILE_DATA data = new IMAGE_FILE_DATA();
                data.completePath = path;
                data.PSSName = pathSegments[startingIndex + 5];
                data.SourceName = pathSegments[startingIndex + 6];
                data.fileNameOnly = pathSegments[startingIndex + 7];
                data.dirOnly = path.Replace(pathSegments[startingIndex + 7], "");
                data.timeStamp = GetTimeFromFile(pathSegments[startingIndex + 7]);

                char[] trimLeadingChar  = {'\\'};

                string removeDriveColon = path.Replace(pathSegments[0], "").TrimStart(trimLeadingChar);

                int offset = path.IndexOf(StorageDir);
                data.relativePath = path.Substring(offset+StorageDir.Length); // get the string after the "DVRSTORAGE"
                data.relativePath = data.relativePath.Remove(0, 1);// remove the leading '\' character

                return (data);
            }
            catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.INFORMATIONAL); return (null); }
        }