Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        protected static SQLiteADOPersistenceHelper CreatePersistenceHelper(PlatformSettings settings)
        {
            SQLiteADOPersistenceHelper helper = new SQLiteADOPersistenceHelper();

            if (helper.Initialize(settings.GetMappedPath("DataStoreDBPath"), true) == false)
            {
                return(null);
            }

            if (helper.ContainsTable("DataStoreEntries") == false)
            {// Create the table structure.
                helper.ExecuteCommand(ForexPlatformPersistence.Properties.Settings.Default.DataStoreDBSchema);
            }

            helper.SetupTypeMapping(typeof(DataStoreEntry), "DataStoreEntries");

            return(helper);
        }
Esempio n. 2
0
        /// <summary>
        /// Helper, creates the correspoding persistence helper.
        /// </summary>
        protected static SQLiteADOPersistenceHelper CreatePersistenceHelper(PlatformSettings settings)
        {
            SQLiteADOPersistenceHelper helper = new SQLiteADOPersistenceHelper();

            if (helper.Initialize(settings.GetMappedPath("EventsDBPath"), true) == false)
            {
                return(null);
            }

            if (helper.ContainsTable("Events") == false)
            {// Create the table structure.
                object result = helper.ExecuteCommand(ForexPlatformPersistence.Properties.Settings.Default.EventsDBSchema);
            }

            helper.SetupTypeMapping(typeof(EventSource), "EventSources");
            helper.SetupTypeMapping(typeof(EventBase), "Events");

            return(helper);
        }
Esempio n. 3
0
        /// <summary>
        /// Helper, creates the persistence helper for the platform.
        /// </summary>
        protected static SQLiteADOPersistenceHelper CreatePlatformPersistenceHelper(PlatformSettings settings)
        {
            SQLiteADOPersistenceHelper helper = new SQLiteADOPersistenceHelper();
            if (helper.Initialize(settings.GetMappedPath("PlatformDBPath"), true) == false)
            {
                return null;
            }

            if (helper.ContainsTable("Platforms") == false)
            {// Create the table structure.
                helper.ExecuteCommand(ForexPlatformPersistence.Properties.Settings.Default.PlatformDBSchema);
            }

            helper.SetupTypeMapping(typeof(Platform), "Platforms");
            helper.SetupTypeMapping(typeof(PlatformComponent), "PlatformComponents");

            return helper;
        }
        /// <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;
        }
Esempio n. 5
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);
        }