Esempio n. 1
0
        /// <summary>
        /// Processes data not yet processed
        /// by this SandBox instance.
        /// </summary>
        private void ProcessLatestDataOperation()
        {
            string latestDataFile = FilePath.GetAbsolutePath(@"LatestData.bin");
            int    latestFileGroupID;
            FileInfoDataContext fileInfo;
            List <int>          newFileGroups;

            if ((object)m_systemSettings == null)
            {
                ReloadSystemSettings();
            }

            using (FileBackedDictionary <string, int> dictionary = new FileBackedDictionary <string, int>(latestDataFile))
                using (DbAdapterContainer dbAdapterContainer = new DbAdapterContainer(m_systemSettings.DbConnectionString, m_systemSettings.DbTimeout))
                {
                    fileInfo = dbAdapterContainer.GetAdapter <FileInfoDataContext>();

                    do
                    {
                        dictionary.Compact();

                        if (!dictionary.TryGetValue("latestFileGroupID", out latestFileGroupID))
                        {
                            latestFileGroupID = 0;
                        }

                        newFileGroups = fileInfo.FileGroups
                                        .Select(fileGroup => fileGroup.ID)
                                        .Where(id => id > latestFileGroupID)
                                        .Take(100)
                                        .OrderBy(id => id)
                                        .ToList();

                        foreach (int fileGroupID in newFileGroups)
                        {
                            MeterDataProcessor processor = new MeterDataProcessor(LoadSystemSettings());
                            processor.ProcessFileGroup(fileGroupID);
                            dictionary["latestFileGroupID"] = fileGroupID;
                        }
                    }while (newFileGroups.Count > 0);
                }
        }
Esempio n. 2
0
        /// <summary>
        /// Processes data not yet processed
        /// by this SandBox instance.
        /// </summary>
        private void ProcessLatestDataOperation()
        {
            string     latestDataFile = FilePath.GetAbsolutePath(@"LatestData.bin");
            List <int> newFileGroups;

            if ((object)m_systemSettings == null)
            {
                ReloadSystemSettings();
            }

            using (FileBackedDictionary <string, int> dictionary = new FileBackedDictionary <string, int>(latestDataFile))
                using (AdoDataConnection connection = new AdoDataConnection("systemSettings"))
                {
                    do
                    {
                        dictionary.Compact();

                        if (!dictionary.TryGetValue("latestFileGroupID", out m_latestFileGroupID))
                        {
                            m_latestFileGroupID = 0;
                        }

                        newFileGroups = (new TableOperations <FileGroup>(connection)).QueryRecordsWhere("ID > {0}", m_latestFileGroupID)
                                        .Select(fileGroup => fileGroup.ID)
                                        .Take(100)
                                        .OrderBy(id => id)
                                        .ToList();

                        foreach (int fileGroupID in newFileGroups)
                        {
                            MeterDataProcessor processor = new MeterDataProcessor(s_connectionString);
                            processor.ProcessFileGroup(fileGroupID);
                            dictionary["latestFileGroupID"] = fileGroupID;
                        }
                    }while (newFileGroups.Count > 0);
                }
        }
        /// <summary>
        /// Processes data not yet processed
        /// by this SandBox instance.
        /// </summary>
        private void ProcessLatestDataOperation()
        {
            string latestDataFile = FilePath.GetAbsolutePath(@"LatestData.bin");
            int latestFileGroupID;
            FileInfoDataContext fileInfo;
            List<int> newFileGroups;

            if ((object)m_systemSettings == null)
                ReloadSystemSettings();

            using (FileBackedDictionary<string, int> dictionary = new FileBackedDictionary<string, int>(latestDataFile))
            using (DbAdapterContainer dbAdapterContainer = new DbAdapterContainer(m_systemSettings.DbConnectionString, m_systemSettings.DbTimeout))
            {
                fileInfo = dbAdapterContainer.GetAdapter<FileInfoDataContext>();

                do
                {
                    dictionary.Compact();

                    if (!dictionary.TryGetValue("latestFileGroupID", out latestFileGroupID))
                        latestFileGroupID = 0;

                    newFileGroups = fileInfo.FileGroups
                        .Select(fileGroup => fileGroup.ID)
                        .Where(id => id > latestFileGroupID)
                        .Take(100)
                        .OrderBy(id => id)
                        .ToList();

                    foreach (int fileGroupID in newFileGroups)
                    {
                        MeterDataProcessor processor = new MeterDataProcessor(LoadSystemSettings());
                        processor.ProcessFileGroup(fileGroupID);
                        dictionary["latestFileGroupID"] = fileGroupID;
                    }
                }
                while (newFileGroups.Count > 0);
            }
        }