/// <summary>
        /// 
        /// </summary>
        public bool Initialize(PlatformSettings settings)
        {
            lock (this)
            {
                _persistenceHelper = CreatePersistenceHelper(settings);

                _dataStoreFilesFolder = settings.GetMappedPath("DataStoreFolder");
            }

            // Loading online data sources, currently not operating.
            //GeneralHelper.FireAndForget(
            //    delegate()
            //    {
            //        try
            //        {// Download online dataDelivery source entries.
            //            WebRequest request = WebRequest.Create(settings.DataStoreOnlineSourcesXml);
            //            request.Timeout = (int)TimeSpan.FromSeconds(15).TotalMilliseconds;

            //            TextReader reader = new StreamReader(request.GetResponse().GetResponseStream());

            //            // If you get an error here in DEBUG MODE, just ignore it, it is a bug in VS 2008.
            //            XmlSerializer serializer = new XmlSerializer(typeof(OnlineEntrySource[]));

            //            OnlineEntrySource[] sources = (OnlineEntrySource[])serializer.Deserialize(reader);

            //            lock (_onlineEntrySources)
            //            {// _onlineEntrySources contains serialized existing sources.
            //                _onlineEntrySources.AddRange(sources);
            //                sources = _onlineEntrySources.ToArray();
            //            }

            //            foreach (OnlineEntrySource source in sources)
            //            {
            //                if (OnlineEntrySourceAddedEvent != null)
            //                {
            //                    OnlineEntrySourceAddedEvent(this, source);
            //                }
            //            }

            //        }
            //        catch (Exception ex)
            //        {
            //            SystemMonitor.OperationError("Failed to obtain online data souces [" + ex.Message + "].", TracerItem.PriorityEnum.Low);
            //        }
            //    }
            //);

            if (Directory.Exists(_dataStoreFilesFolder) == false)
            {
                if (Directory.CreateDirectory(_dataStoreFilesFolder) == null)
                {
                    SystemMonitor.OperationError("Failed to create Data Store folder [" + settings.GetMappedPath("DataStoreFolder") + "]");
                    return false;
                }
            }

            List<DataStoreEntry> entries = _persistenceHelper.Select<DataStoreEntry>(null, null);
            foreach (DataStoreEntry entry in entries)
            {
                DoAddEntry(entry);
            }

            ChangeOperationalState(OperationalStateEnum.Operational);

            return true;
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        public bool Initialize(PlatformSettings settings)
        {
            lock (this)
            {
                _persistenceHelper = CreatePersistenceHelper(settings);

                _dataStoreFilesFolder = settings.GetMappedPath("DataStoreFolder");
            }

            // Loading online data sources, currently not operating.
            //GeneralHelper.FireAndForget(
            //    delegate()
            //    {
            //        try
            //        {// Download online dataDelivery source entries.
            //            WebRequest request = WebRequest.Create(settings.DataStoreOnlineSourcesXml);
            //            request.Timeout = (int)TimeSpan.FromSeconds(15).TotalMilliseconds;

            //            TextReader reader = new StreamReader(request.GetResponse().GetResponseStream());

            //            // If you get an error here in DEBUG MODE, just ignore it, it is a bug in VS 2008.
            //            XmlSerializer serializer = new XmlSerializer(typeof(OnlineEntrySource[]));

            //            OnlineEntrySource[] sources = (OnlineEntrySource[])serializer.Deserialize(reader);

            //            lock (_onlineEntrySources)
            //            {// _onlineEntrySources contains serialized existing sources.
            //                _onlineEntrySources.AddRange(sources);
            //                sources = _onlineEntrySources.ToArray();
            //            }

            //            foreach (OnlineEntrySource source in sources)
            //            {
            //                if (OnlineEntrySourceAddedEvent != null)
            //                {
            //                    OnlineEntrySourceAddedEvent(this, source);
            //                }
            //            }

            //        }
            //        catch (Exception ex)
            //        {
            //            SystemMonitor.OperationError("Failed to obtain online data souces [" + ex.Message + "].", TracerItem.PriorityEnum.Low);
            //        }
            //    }
            //);

            if (Directory.Exists(_dataStoreFilesFolder) == false)
            {
                if (Directory.CreateDirectory(_dataStoreFilesFolder) == null)
                {
                    SystemMonitor.OperationError("Failed to create Data Store folder [" + settings.GetMappedPath("DataStoreFolder") + "]");
                    return(false);
                }
            }

            List <DataStoreEntry> entries = _persistenceHelper.Select <DataStoreEntry>(null, null);

            foreach (DataStoreEntry entry in entries)
            {
                DoAddEntry(entry);
            }

            ChangeOperationalState(OperationalStateEnum.Operational);

            return(true);
        }