Exemple #1
0
 /// <summary>
 /// Returns a list of jpeg files which meet the search criteria. Returns complete file path. Specify the source drive , e.g. 'D:\\'
 /// </summary>
 /// <param name="PSSName"></param>
 /// <param name="sourceName"></param>
 /// <param name="start"></param>
 /// <param name="stop"></param>
 /// <returns></returns>
 /// 
 public string[] GetAllJpegsInRange(string sourceDrive, DateTime start, DateTime stop)
 {
     m_GetAllJpegsProcessCallback = null;
     bool stopSearch = false;
     return (_GetAllJpegsInRange(sourceDrive + StorageDir, start, stop, null, null, (object) stopSearch, m_AppData.MAX_SEARCH_RESULTS_TO_DISPLAY));
 }
Exemple #2
0
 /// <summary>
 /// Returns a list of jpeg files which meet the search criteria. Returns complete file path. Uses the default primary drive storage path.
 /// </summary>
 /// <param name="PSSName"></param>
 /// <param name="sourceName"></param>
 /// <param name="start"></param>
 /// <param name="stop"></param>
 /// <returns></returns>
 public string[] GetAllJpegsInRange(DateTime start, DateTime stop, string PSS, string channelSource)
 {
     m_GetAllJpegsProcessCallback = null;
     bool stopSearch = false;
     return (_GetAllJpegsInRange(StoragePath, start, stop, PSS, channelSource, (object) stopSearch, m_AppData.MAX_SEARCH_RESULTS_TO_DISPLAY));
 }
Exemple #3
0
 public string[] GetAllJpegsInRange(GET_ALL_JPEGS_IN_RANGE_PARAMS parameters)
 {
     m_GetAllJpegsProcessCallback = parameters.callBack;
     m_ProgressUpdateFrequency = parameters.updateFreq;
     return ( _GetAllJpegsInRange(StoragePath, parameters.start, parameters.stop, null, null,  parameters.stopSearch, parameters.maxResultsCount));
 }
Exemple #4
0
        private string[] _GetAllJpegsInRange(string sourcePath, DateTime start, DateTime stop, string selectedPSS, string selectedChannelSource, object StopLoop, int maxCount)
        {
            List<string> allJpegsInRange = new List<string>();
            DateTime timeAtCurrentDirectory = default(DateTime);

            try
            {

                DateTime startYear = new DateTime(start.Year, 1, 1, 0, 0, 0);
                DateTime startMonth = new DateTime(start.Year, start.Month, 1, 0, 0, 0);
                DateTime startDay = new DateTime(start.Year, start.Month, start.Day, 0, 0, 0);
                DateTime startHour = new DateTime(start.Year, start.Month, start.Day, start.Hour, 0, 0);
                DateTime startMin = new DateTime(start.Year, start.Month, start.Day, start.Hour, start.Minute, 0);
                DateTime startSec = new DateTime(start.Year, start.Month, start.Day, start.Hour, start.Minute, start.Second);

                DateTime stopYear = new DateTime(stop.Year, 1, 1, 0, 0, 0);
                DateTime stopMonth = new DateTime(stop.Year, stop.Month, 1, 0, 0, 0);
                DateTime stopDay = new DateTime(stop.Year, stop.Month, stop.Day, 0, 0, 0);
                DateTime stopHour = new DateTime(stop.Year, stop.Month, stop.Day, stop.Hour, 0, 0);
                DateTime stopMin = new DateTime(stop.Year, stop.Month, stop.Day, stop.Hour, stop.Minute, 0);
                DateTime stopSec = new DateTime(stop.Year, stop.Month, stop.Day, stop.Hour, stop.Minute, stop.Second);

                string[] years = Directory.GetDirectories(sourcePath);
                if (years.Length == 0) return null;
                years = RemoveNonYearDirs(years);
                years = SortByNumeric(years);

                foreach (string year in years)
                {
                    int yearInt;
                    try
                    {
                        yearInt = Convert.ToInt16(GetEndofString(year));
                    }
                    catch
                    {
                        continue; // should no longer get here because I added years = RemoveNonYearDirs(years);
                    }

                    timeAtCurrentDirectory = new DateTime(yearInt, 1, 1, 0, 0, 0);
                    if (timeAtCurrentDirectory.CompareTo(startYear) >= 0 && timeAtCurrentDirectory.CompareTo(stopYear) <= 0)
                    {
                        string[] months = Directory.GetDirectories(year);
                        if (months.Length == 0) continue;
                        months = SortByNumeric(months);

                        foreach (string month in months)
                        {

                            int monthInt=0;
                            try
                            {
                                monthInt = Convert.ToInt32(GetEndofString(month));
                            }
                            catch { continue; }
                            timeAtCurrentDirectory = new DateTime(yearInt, monthInt, 1, 0, 0, 0);
                            if (timeAtCurrentDirectory.CompareTo(startMonth) >= 0 && timeAtCurrentDirectory.CompareTo(stopMonth) <= 0)
                            {
                                string[] days = Directory.GetDirectories(month);
                                if (days.Length == 0) continue;
                                days = SortByNumeric(days);

                                foreach (string day in days)
                                {
                                    int dayInt = 0;
                                    try
                                    {
                                        dayInt = Convert.ToInt32(GetEndofString(day));
                                    }
                                    catch { continue; }
                                    timeAtCurrentDirectory = new DateTime(yearInt, monthInt, dayInt, 0, 0, 0);
                                    if (timeAtCurrentDirectory.CompareTo(startDay) >= 0 && timeAtCurrentDirectory.CompareTo(stopDay) <= 0)
                                    {
                                        string[] hours = Directory.GetDirectories(day);
                                        if (hours.Length == 0) continue;
                                        hours = SortByNumeric(hours);

                                        foreach (string hour in hours)
                                        {
                                            int hourInt;
                                            try
                                            {
                                                hourInt = Convert.ToInt32(GetEndofString(hour));
                                            }
                                            catch { continue; }
                                            timeAtCurrentDirectory = new DateTime(yearInt, monthInt, dayInt, hourInt, 0, 0);
                                            if (timeAtCurrentDirectory.CompareTo(startHour) >= 0 && timeAtCurrentDirectory.CompareTo(stopHour) <= 0)
                                            {
                                                string[] PSSUnitsNode = Directory.GetDirectories(hour);
                                                if (PSSUnitsNode.Length == 0) continue;

                                                foreach (string pss in PSSUnitsNode)
                                                {
                                                    if (selectedPSS != null)
                                                    {
                                                        if (GetEndofString(pss) != selectedPSS) continue;
                                                    }
                                                    string[] sources = Directory.GetDirectories(pss);
                                                    foreach (string source in sources)
                                                    {
                                                        if (selectedChannelSource != null)
                                                        {
                                                            if (GetEndofString(source) != selectedChannelSource) continue;
                                                        }
                                                        if (m_Stop) return null;

                                                        string[] jpegs = Directory.GetFiles(source, "*.jpg");
                                                        string[] jpegsInRange = GetJpegsInMinutesRange(jpegs, start, stop);
                                                        if (jpegsInRange != null)
                                                        {
                                                            foreach (string jpeg in jpegsInRange)
                                                            {
                                                                allJpegsInRange.Add(jpeg);

                                                                if (m_GetAllJpegsProcessCallback != null)
                                                                {
                                                                    if (allJpegsInRange.Count % m_ProgressUpdateFrequency == 0)
                                                                    {
                                                                        PATHS_GET_STATUS status = new PATHS_GET_STATUS();
                                                                        status.currentTime = timeAtCurrentDirectory;
                                                                        status.currentCount = 0;
                                                                        status.totalCount = 0;
                                                                        status.errors = null;
                                                                        m_GetAllJpegsProcessCallback(status);
                                                                    }
                                                                }
                                                            }
                                                        }

                                                        if ((bool)StopLoop || allJpegsInRange.Count > maxCount) break;
                                                    }
                                                    if ((bool)StopLoop || allJpegsInRange.Count > maxCount) break;
                                                }
                                                if ((bool)StopLoop || allJpegsInRange.Count > maxCount) break;
                                            }
                                            if ((bool)StopLoop || allJpegsInRange.Count > maxCount) break;
                                        }
                                        if ((bool)StopLoop || allJpegsInRange.Count > maxCount) break;
                                    }
                                    if ((bool)StopLoop || allJpegsInRange.Count > maxCount) break;
                                }
                                if ((bool)StopLoop || allJpegsInRange.Count > maxCount) break;
                            }
                            if ((bool)StopLoop || allJpegsInRange.Count > maxCount) break;
                        }
                        if ((bool)StopLoop || allJpegsInRange.Count > maxCount) break;
                    }
                    if ((bool)StopLoop || allJpegsInRange.Count > maxCount) break;
                }
            }
            catch (Exception ex)
            {
                PATHS_GET_STATUS status = new PATHS_GET_STATUS();
                status.currentTime = timeAtCurrentDirectory;
                status.currentCount = 0;
                status.totalCount = 0;
                status.errors = ex.Message;
                m_GetAllJpegsProcessCallback(status);
                m_Log.Log("GetAllJpegsInRange ex " + ex.Message, ErrorLog.LOG_TYPE.FATAL);
            }

            string[] fileList = allJpegsInRange.ToArray();

            if (!(bool)StopLoop && allJpegsInRange.Count < maxCount) SortFilesByTimeStamp(fileList);

            if (m_GetAllJpegsProcessCallback != null)
            {
                PATHS_GET_STATUS status = new PATHS_GET_STATUS();
                status.currentTime = timeAtCurrentDirectory;
                status.currentCount = 0;
                status.totalCount = 0;
                status.errors = null;
                m_GetAllJpegsProcessCallback(status);
            }

            m_GetAllJpegsProcessCallback = null;

            return (fileList);
        }