Example #1
0
        /// <summary>
        /// Gets a list of the files that should be available on the specified date.
        /// This will include file names for all active versions of the file, for their appropriate dates
        /// </summary>
        /// <param name="curDT">Date/Time of the search day (ie. today for real-time)</param>
        /// <returns>TRUE if some files need to be downloaded</returns>
        public List <LCAEDIFileType> queueFilesReleasedToday(List <DateTime> holidays)
        {
            int sIdx  = 0;
            int pIdx  = 0;
            int dtIdx = 0;
            int vIdx  = 0;
            List <LCAEDIFileType> dlQueue = new List <LCAEDIFileType>();

            foreach (LCAEDISettings setting in settings)
            {
                foreach (LCAEDIPoint point in setting.points)
                {
                    foreach (LCAEDIPoint.LCAEDIDataType dataType in point.dataTypes)
                    {
                        foreach (LCAEDIPoint.LCAEDIDataType.versionInfo version in dataType.versions)
                        {
                            if (version.isActive)
                            {
                                DateTime publishTime;
                                try {
                                    publishTime = DateTime.ParseExact(version.publishTime, "HH:mm:ss", null);
                                }
                                catch (Exception e) {
                                    publishTime = DateTime.Now.AddHours(-1);
                                }

                                if (publishTime.TimeOfDay <= DateTime.Now.TimeOfDay)
                                {
                                    LCAEDIFileType thisFile = new LCAEDIFileType();

                                    DateTime fileDate = DateTime.Now;

                                    fileDate = LCATimeUtils.AddBusinessDays(fileDate, version.publishBDayLag, holidays);
                                    fileDate = fileDate.AddDays(version.publishDayLag);

                                    string fName = version.makeFileName(dataType.fileNameStructure, fileDate, setting.accountName);

                                    thisFile.connection = setting.connection;
                                    thisFile.fileName   = fName;
                                    thisFile.folder     = "/private/" + setting.accountName + "/" + dataType.folderName;
                                    thisFile.fullName   = thisFile.folder + "/" + fName;

                                    if (dlQueue.FirstOrDefault(a => a.fullName == thisFile.fullName) == null)
                                    {
                                        dlQueue.Add(thisFile);
                                    }
                                }
                            }
                            vIdx++;
                        }
                        dtIdx++;
                    }
                    pIdx++;
                }
                sIdx++;
            }
            return(dlQueue);
        }
Example #2
0
        /// <summary>
        /// Get the file names for a specific day. It's historical, so we'll return the file names for any versions
        /// which should be available on the given date.
        /// </summary>
        /// <param name="histDT">Day to file historically</param>
        /// <returns>List of available file names on the IESO server</returns>
        public List <LCAEDIFileType> queueHistorical(DateTime sDT, DateTime eDT, List <DateTime> holidays)
        {
            int sIdx  = 0;
            int pIdx  = 0;
            int dtIdx = 0;
            int vIdx  = 0;
            int curBestVer;
            List <LCAEDIFileType> dlQueue = new List <LCAEDIFileType>();

            foreach (LCAEDISettings setting in settings)
            {
                foreach (LCAEDIPoint point in setting.points)
                {
                    foreach (LCAEDIPoint.LCAEDIDataType dataType in point.dataTypes)
                    {
                        int      days    = (eDT.Date - sDT.Date).Days + 1;
                        DateTime curDate = sDT;

                        for (int i = 0; i < days; i++)
                        {
                            curDate    = sDT.AddDays(i);
                            curBestVer = 0;

                            for (int j = 0; j < dataType.versions.Count(); j++)
                            {
                                if (dataType.versions[j].isActive)
                                {
                                    if (dataType.versions[j].versionNum > curBestVer)
                                    {
                                        LCAEDIFileType thisFile = new LCAEDIFileType();

                                        DateTime releaseDate = LCATimeUtils.AddBusinessDays(curDate, -1 * dataType.versions[j].publishBDayLag, holidays);
                                        releaseDate = releaseDate.AddDays(-1 * dataType.versions[j].publishDayLag);

                                        if (releaseDate.Date <= DateTime.Now.Date)
                                        {
                                            curBestVer = dataType.versions[j].versionNum;
                                            vIdx       = j;
                                        }
                                    }
                                }
                            }

                            if (curBestVer > 0)
                            {
                                string fName = dataType.versions[vIdx].makeFileName(dataType.fileNameStructure, curDate, setting.accountName);

                                LCAEDIFileType thisFile = new LCAEDIFileType();

                                thisFile.connection    = setting.connection;
                                thisFile.fileName      = fName;
                                thisFile.folder        = "/private/" + setting.accountName + "/" + dataType.folderName;
                                thisFile.fullName      = thisFile.folder + "/" + fName;
                                thisFile.localFileName = null;

                                if (dlQueue.FirstOrDefault(a => a.fullName == thisFile.fullName) == null)
                                {
                                    dlQueue.Add(thisFile);
                                }
                            }
                        }
                        dtIdx++;
                    }
                    pIdx++;
                }
                sIdx++;
            }
            return(dlQueue);
        }