internal SharedXMLBackendProvider(FdoCache cache, IdentityMap identityMap, ICmObjectSurrogateFactory surrogateFactory, IFwMetaDataCacheManagedInternal mdc,
			IDataMigrationManager dataMigrationManager, IFdoUI ui, IFdoDirectories dirs, FdoSettings settings)
			: base(cache, identityMap, surrogateFactory, mdc, dataMigrationManager, ui, dirs, settings)
		{
			m_peerProcesses = new Dictionary<int, Process>();
			m_peerID = Guid.NewGuid();
		}
Esempio n. 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="backendProviderType">Type of backend provider to create.</param>
 /// <param name="ui">The UI service.</param>
 /// <param name="dirs">The directories service.</param>
 /// <param name="settings">The FDO settings.</param>
 internal FdoServiceLocatorFactory(FDOBackendProviderType backendProviderType, IFdoUI ui, IFdoDirectories dirs, FdoSettings settings)
 {
     m_backendProviderType = backendProviderType;
     m_ui       = ui;
     m_dirs     = dirs;
     m_settings = settings;
 }
 protected ClientServerBackendProvider(FdoCache cache,
                                       IdentityMap identityMap,
                                       ICmObjectSurrogateFactory surrogateFactory,
                                       IFwMetaDataCacheManagedInternal mdc,
                                       IDataMigrationManager dataMigrationManager,
                                       IFdoUI ui, IFdoDirectories dirs, FdoSettings settings) : base(cache, identityMap, surrogateFactory, mdc, dataMigrationManager, ui, dirs, settings)
 {
 }
		protected ClientServerBackendProvider(FdoCache cache,
			IdentityMap identityMap,
			ICmObjectSurrogateFactory surrogateFactory,
			IFwMetaDataCacheManagedInternal mdc,
			IDataMigrationManager dataMigrationManager,
			IFdoUI ui, IFdoDirectories dirs, FdoSettings settings) : base(cache, identityMap, surrogateFactory, mdc, dataMigrationManager, ui, dirs, settings)
		{
		}
Esempio n. 5
0
        static int Main(string[] args)
        {
            if (args.Length < 2)
            {
                WriteHelp();
                return(0);
            }

            if (!File.Exists(args[0]))
            {
                Console.WriteLine("The FieldWorks project file could not be found.");
                return(1);
            }

            RegistryHelper.CompanyName = DirectoryFinder.CompanyName;
            Icu.InitIcuDataDir();
            var synchronizeInvoke = new SingleThreadedSynchronizeInvoke();
            var spanFactory       = new ShapeSpanFactory();

            var projectId = new ProjectIdentifier(args[0]);
            var logger    = new ConsoleLogger(synchronizeInvoke);
            var dirs      = new NullFdoDirectories();
            var settings  = new FdoSettings {
                DisableDataMigration = true
            };
            var progress = new NullThreadedProgress(synchronizeInvoke);

            Console.WriteLine("Loading FieldWorks project...");
            try
            {
                using (FdoCache cache = FdoCache.CreateCacheFromExistingData(projectId, "en", logger, dirs, settings, progress))
                {
                    Language language = HCLoader.Load(spanFactory, cache, logger);
                    Console.WriteLine("Loading completed.");
                    Console.WriteLine("Writing HC configuration file...");
                    XmlLanguageWriter.Save(language, args[1]);
                    Console.WriteLine("Writing completed.");
                }
                return(0);
            }
            catch (FdoFileLockedException)
            {
                Console.WriteLine("Loading failed.");
                Console.WriteLine("The FieldWorks project is currently open in another application.");
                Console.WriteLine("Close the application and try to run this command again.");
                return(1);
            }
            catch (FdoDataMigrationForbiddenException)
            {
                Console.WriteLine("Loading failed.");
                Console.WriteLine("The FieldWorks project was created with an older version of FLEx.");
                Console.WriteLine("Migrate the project to the latest version by opening it in FLEx.");
                return(1);
            }
        }
		internal SharedXMLBackendProvider(FdoCache cache, IdentityMap identityMap, ICmObjectSurrogateFactory surrogateFactory, IFwMetaDataCacheManagedInternal mdc,
			IDataMigrationManager dataMigrationManager, IFdoUI ui, IFdoDirectories dirs, FdoSettings settings)
			: base(cache, identityMap, surrogateFactory, mdc, dataMigrationManager, ui, dirs, settings)
		{
			m_peerProcesses = new Dictionary<int, Process>();
			m_peerID = Guid.NewGuid();
#if __MonoCS__
			// /dev/shm is not guaranteed to be available on all systems, so fall back to temp
			m_commitLogDir = Directory.Exists("/dev/shm") ? "/dev/shm" : Path.GetTempPath();
#endif
		}
Esempio n. 7
0
        private FdoCache TryGetFdoCache()
        {
            FdoCache fdoCache = null;
            var      path     = _project.Path;

            if (!File.Exists(path))
            {
                return(null);
            }

            var settings = new FdoSettings {
                DisableDataMigration = !AllowDataMigration
            };

            try
            {
                fdoCache = FdoCache.CreateCacheFromExistingData(
                    _project, Thread.CurrentThread.CurrentUICulture.Name, _fdoUi,
                    _project.FdoDirectories, settings, _progress);
            }
            catch (FdoDataMigrationForbiddenException)
            {
                MainClass.Logger.Error("FDO: Incompatible version (can't migrate data)");
                return(null);
            }
            catch (FdoNewerVersionException)
            {
                MainClass.Logger.Error("FDO: Incompatible version (version number newer than expected)");
                return(null);
            }
            catch (FdoFileLockedException)
            {
                MainClass.Logger.Error("FDO: Access denied");
                return(null);
            }
            catch (StartupException)
            {
                MainClass.Logger.Error("FDO: Unknown error");
                return(null);
            }

            return(fdoCache);
        }
        internal SharedXMLBackendProvider(FdoCache cache, IdentityMap identityMap, ICmObjectSurrogateFactory surrogateFactory, IFwMetaDataCacheManagedInternal mdc,
                                          IDataMigrationManager dataMigrationManager, IFdoUI ui, IFdoDirectories dirs, FdoSettings settings)
            : base(cache, identityMap, surrogateFactory, mdc, dataMigrationManager, ui, dirs, settings)
        {
            m_peerProcesses = new Dictionary <int, Process>();
            m_peerID        = Guid.NewGuid();
#if __MonoCS__
            // /dev/shm is not guaranteed to be available on all systems, so fall back to temp
            m_commitLogDir = Directory.Exists("/dev/shm") ? "/dev/shm" : Path.GetTempPath();
#endif
        }
Esempio n. 9
0
        protected FdoCache BootstrapSystem(IProjectIdentifier projectId, BackendBulkLoadDomain loadType, FdoSettings settings)
        {
            var retval = m_internalRestart ? FdoCache.CreateCacheFromExistingData(projectId, "en", new DummyFdoUI(), FwDirectoryFinder.FdoDirectories, settings, new DummyProgressDlg()) :
                         FdoCache.CreateCacheWithNewBlankLangProj(projectId, "en", "fr", "en", new DummyFdoUI(), FwDirectoryFinder.FdoDirectories, settings);
            var dataSetup = retval.ServiceLocator.GetInstance <IDataSetup>();

            dataSetup.LoadDomain(loadType);
            return(retval);
        }
Esempio n. 10
0
		/// <summary>
		/// Actually create the system.
		/// Called by subclass overrides of CreateCache(), with parameters that suit
		/// the subclass.
		/// </summary>
		/// <param name="projectId"></param>
		/// <param name="loadType"></param>
		/// <param name="settings"></param>
		/// <returns>a working FdoCache</returns>
		protected FdoCache BootstrapSystem(IProjectIdentifier projectId, BackendBulkLoadDomain loadType, FdoSettings settings)
		{
			var retval = m_internalRestart ? FdoCache.CreateCacheFromExistingData(projectId, "en", new DummyFdoUI(), FwDirectoryFinder.FdoDirectories, settings, new DummyProgressDlg()) :
				FdoCache.CreateCacheWithNewBlankLangProj(projectId, "en", "fr", "en", new DummyFdoUI(), FwDirectoryFinder.FdoDirectories, settings);
			var dataSetup = retval.ServiceLocator.GetInstance<IDataSetup>();
			dataSetup.LoadDomain(loadType);
			return retval;
		}
Esempio n. 11
0
        private LexicalProjectValidationResult TryGetFdoCache(string projectId, string langId, out FdoCache fdoCache)
        {
            fdoCache = null;
            if (string.IsNullOrEmpty(langId))
            {
                return(LexicalProjectValidationResult.InvalidLanguage);
            }

            if (m_fdoCacheCache.Contains(projectId))
            {
                fdoCache = m_fdoCacheCache[projectId];
            }
            else
            {
                var    backendProviderType = FDOBackendProviderType.kSharedXML;
                string path = Path.Combine(ParatextLexiconPluginDirectoryFinder.ProjectsDirectory, projectId, projectId + FdoFileHelper.ksFwDataXmlFileExtension);
                if (!File.Exists(path))
                {
                    backendProviderType = FDOBackendProviderType.kDb4oClientServer;
                    path = Path.Combine(ParatextLexiconPluginDirectoryFinder.ProjectsDirectory, projectId, projectId + FdoFileHelper.ksFwDataDb4oFileExtension);
                    if (!File.Exists(path))
                    {
                        return(LexicalProjectValidationResult.ProjectDoesNotExist);
                    }
                }

                var settings = new FdoSettings {
                    DisableDataMigration = true
                };
                using (RegistryKey fwKey = ParatextLexiconPluginRegistryHelper.FieldWorksRegistryKeyLocalMachine)
                {
                    if (fwKey != null)
                    {
                        var sharedXMLBackendCommitLogSize = (int)fwKey.GetValue("SharedXMLBackendCommitLogSize", 0);
                        if (sharedXMLBackendCommitLogSize > 0)
                        {
                            settings.SharedXMLBackendCommitLogSize = sharedXMLBackendCommitLogSize;
                        }
                    }
                }

                try
                {
                    var progress = new ParatextLexiconPluginThreadedProgress(m_ui.SynchronizeInvoke)
                    {
                        IsIndeterminate = true, Title = string.Format("Opening {0}", projectId)
                    };
                    fdoCache = FdoCache.CreateCacheFromExistingData(new ParatextLexiconPluginProjectID(backendProviderType, path), Thread.CurrentThread.CurrentUICulture.Name, m_ui,
                                                                    ParatextLexiconPluginDirectoryFinder.FdoDirectories, settings, progress);
                }
                catch (FdoDataMigrationForbiddenException)
                {
                    return(LexicalProjectValidationResult.IncompatibleVersion);
                }
                catch (FdoNewerVersionException)
                {
                    return(LexicalProjectValidationResult.IncompatibleVersion);
                }
                catch (FdoFileLockedException)
                {
                    return(LexicalProjectValidationResult.AccessDenied);
                }
                catch (StartupException)
                {
                    return(LexicalProjectValidationResult.UnknownError);
                }

                m_fdoCacheCache.Add(fdoCache);
            }

            if (fdoCache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems.All(ws => ws.Id != langId))
            {
                DisposeFdoCacheIfUnused(fdoCache);
                fdoCache = null;
                return(LexicalProjectValidationResult.InvalidLanguage);
            }

            return(LexicalProjectValidationResult.Success);
        }