Esempio n. 1
0
 public void Constructor_CreateNewProjectFromBundle_BundleHasNoLdmlFile_WsIsoIsSet_ProjectIsCreatedSuccessfully()
 {
     Sldr.Initialize();
     try
     {
         var bundle = GetGlyssenBundleToBeUsedForProject(false);
         bundle.Metadata.Language.Ldml = "";
         bundle.Metadata.Language.Iso  = "ach";
         bundle.Metadata.Language.Name = "Acholi";                 // see messages in Assert.AreEqual lines below
         var project = new Project(bundle);
         m_tempProjectFolders.Add(Path.GetDirectoryName(Path.GetDirectoryName(project.ProjectFilePath)));
         WaitForProjectInitializationToFinish(project, ProjectState.ReadyForUserInteraction);
         Assert.IsNotNull(project);
         Assert.IsNotEmpty(project.QuoteSystem.AllLevels);
         Assert.AreEqual("ach", project.WritingSystem.Id);
         Assert.AreEqual("Acoli", project.WritingSystem.Language.Name,
                         "This name should be coming from the \"global\" cache, not from the metadata above - note spelling difference.");
         Assert.AreEqual("ach", project.WritingSystem.Language.Iso3Code,
                         "If \"ach\" is not found in the global cache, the lnaguage subtag will be considered \"private-use\" and the " +
                         "ISO code will be null");
         Assert.AreEqual("ach", project.WritingSystem.Language.Code);
     }
     finally
     {
         Sldr.Cleanup();
     }
 }
        public void LoadProject(string projectName)
        {
            LCModel.Core.Text.CustomIcu.InitIcuDataDir();
            if (!Sldr.IsInitialized)
            {
                Sldr.Initialize(true);
            }
            var dirs        = new PaFieldWorksHelper();
            var projectPath = string.Empty;

            if (File.Exists(projectName))
            {
                projectPath = projectName;
            }
            else
            {
                projectPath = Path.Combine(dirs.ProjectsDirectory, projectName, projectName + LcmFileHelper.ksFwDataXmlFileExtension);
            }

            var ui       = new SilentLcmUI(SynchronizeInvoke);
            var settings = new LcmSettings {
                DisableDataMigration = false, UpdateGlobalWSStore = false
            };

            SilTools.Utils.WaitCursors(true);
            using (var progressDlg = new PAProgress())
            {
                m_cache = LcmCache.CreateCacheFromExistingData(new FWProjectId(BackendProviderType.kSharedXML, projectPath), Thread.CurrentThread.CurrentUICulture.Name, ui, dirs, settings, progressDlg);
            }
            SilTools.Utils.WaitCursors(false);
        }
 public void FixtureSetup()
 {
     if (!Sldr.IsInitialized)
     {
         Sldr.Initialize();
     }
 }
Esempio n. 4
0
        public CallerSetting()
        {
            _xDoc.RemoveAll();
            if (!Sldr.IsInitialized)
            {
                Sldr.Initialize(true);
            }
            WritingSystem = new WritingSystemDefinition();
            Caller        = DataCreator.Creator;
            switch (Caller)
            {
            case DataCreator.CreatorProgram.Paratext8:
                _dataFolder = RegistryHelperLite.FallbackStringValue("Paratext/8", "Settings_Directory");
                break;

            case DataCreator.CreatorProgram.Paratext7:
                _dataFolder = RegistryHelperLite.FallbackStringValue("ScrChecks/1.0/Settings_Directory");
                break;

            case DataCreator.CreatorProgram.FieldWorks8:
                _dataFolder = RegistryHelperLite.FallbackStringValue("SIL/FieldWorks/8", "ProjectsDir");
                SetupLdmlFolder();
                break;

            case DataCreator.CreatorProgram.FieldWorks9:
                _dataFolder = RegistryHelperLite.FallbackStringValue("SIL/FieldWorks/9", "ProjectsDir");
                SetupLdmlFolder();
                break;
            }
            if (Caller != DataCreator.CreatorProgram.Unknown)
            {
                return;
            }
            FindDataFolder();
        }
Esempio n. 5
0
        public void SetUp()
        {
            // Force initialization in ILRepacked SIL.WritingSystems assembly,
            // even if a referenced SIl.WritingSystems assembly somewhere down
            // the dependency chain, that we won't be using, was initialized.
            if (!Sldr.IsInitialized)
            {
                Sldr.Initialize();
            }

            FwRegistryHelper.Initialize();
            m_threadHelper = new ThreadHelper();
            var ui        = new DummyLcmUI(m_threadHelper);
            var projectId = new ParatextLexiconPluginProjectId(BackendProviderType.kMemoryOnly, "Test.fwdata");

            m_cache = LcmCache.CreateCacheWithNewBlankLangProj(projectId, "en", "fr", "en", ui,
                                                               ParatextLexiconPluginDirectoryFinder.LcmDirectories, new LcmSettings());
            NonUndoableUnitOfWorkHelper.Do(m_cache.ActionHandlerAccessor, () =>
            {
                m_cache.ServiceLocator.WritingSystems.AddToCurrentAnalysisWritingSystems(m_cache.ServiceLocator.WritingSystemManager.Get("fr"));
                m_cache.ServiceLocator.WritingSystems.AddToCurrentVernacularWritingSystems(m_cache.ServiceLocator.WritingSystemManager.Get("en"));
                m_cache.LangProject.MorphologicalDataOA.ParserParameters = "<ParserParameters><XAmple><MaxNulls>1</MaxNulls><MaxPrefixes>5</MaxPrefixes><MaxInfixes>1</MaxInfixes><MaxSuffixes>5</MaxSuffixes><MaxInterfixes>0</MaxInterfixes><MaxAnalysesToReturn>10</MaxAnalysesToReturn></XAmple><ActiveParser>XAmple</ActiveParser></ParserParameters>";
            });
            m_lexicon = new FdoLexicon("Test", "FieldWorks:Test", m_cache, m_cache.DefaultVernWs);
        }
Esempio n. 6
0
 protected static void IcuInit()
 {
     Icu.InitIcuDataDir();
     if (!Sldr.IsInitialized)
     {
         Sldr.Initialize();
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParatextMigrationOperations"/> class.
 /// </summary>
 public ParatextMigrationOperations()
 {
     if (!Sldr.IsInitialized)
     {
         // Always use offline mode in tests
         Sldr.Initialize(true);
     }
 }
Esempio n. 8
0
        public LiftService()
        {
            if (!Sldr.IsInitialized)
            {
                Sldr.Initialize(true);
            }

            _liftExports = new Dictionary <string, string>();
        }
Esempio n. 9
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);
            }

            FwRegistryHelper.Initialize();
            FwUtils.InitializeIcu();
            Sldr.Initialize();
            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 LcmSettings {
                DisableDataMigration = true
            };
            var progress = new NullThreadedProgress(synchronizeInvoke);

            Console.WriteLine("Loading FieldWorks project...");
            try
            {
                using (LcmCache cache = LcmCache.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 (LcmFileLockedException)
            {
                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 (LcmDataMigrationForbiddenException)
            {
                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);
            }
        }
        public void TestFixtureSetUp()
        {
            // Use the real version of the file because we want the results to be based on the production control file.
            ControlCharacterVerseData.TabDelimitedCharacterVerseData = null;
            CharacterDetailData.TabDelimitedCharacterDetailData      = null;

            Sldr.Initialize();
            m_project = Project.Load(@"C:\ProgramData\FCBH-SIL\Glyssen\ach\3b9fdc679b9319c3\Acholi New Test 1985 Audio\ach.glyssen");
            TestProject.SimulateDisambiguationForAllBooks(m_project);
            m_project.CharacterGroupGenerationPreferences.NarratorsOption = NarratorsOption.SingleNarrator;
        }
Esempio n. 11
0
        public static void Main(string[] args)
        {
            ExceptionLogging.Initialize("17a42e4a67dd2e42d4aa40d8bf2d23ee", Assembly.GetExecutingAssembly().GetName().Name);
            var options = AuxToolOptions.ParseCommandLineArgs(args);

            if (options == null)
            {
                return;
            }

            if (!File.Exists(options.Project))
            {
                Console.WriteLine("Can't find project file '{0}'", options.Project);
                return;
            }

            Icu.Wrapper.Init();

            // initialize the SLDR
            Sldr.Initialize();

            try
            {
                var projectFileInfo = new FileInfo(options.Project);
                options.Project = projectFileInfo.FullName;

                if (options.InfoOnly)
                {
                    DisplayInfo(options);
                }

                ExceptionLogging.Client.AddInfo(options.Project,
                                                FwProject.GetModelVersion(options.Project));

                if (options.Migrate)
                {
                    MigrateData(options);
                }

                if (options.Commit)
                {
                    CommitData(options);
                }
            }
            finally
            {
                if (Sldr.IsInitialized)
                {
                    Sldr.Cleanup();
                }

                Icu.Wrapper.Cleanup();
            }
        }
        public void TestFixtureSetUp()
        {
            // Use the real version of the file because we want the results to be based on the production control file.
            ControlCharacterVerseData.TabDelimitedCharacterVerseData = null;
            CharacterDetailData.TabDelimitedCharacterDetailData      = null;

            Sldr.Initialize();
            //Change this to Kuna and finish tests for OT books
            m_project = Project.Load(@"C:\ProgramData\FCBH-SIL\Glyssen\cuk\5a6b88fafe1c8f2b\The Bible in Kuna, San Blas Audio (1)\cuk.glyssen");
            TestProject.SimulateDisambiguationForAllBooks(m_project);
            m_project.CharacterGroupGenerationPreferences.NarratorsOption = NarratorsOption.SingleNarrator;
        }
Esempio n. 13
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            FwRegistryHelper.Initialize();
            FwUtils.InitializeIcu();
            Sldr.Initialize();
            using (var form = new LCMBrowserForm())
            {
                Application.Run(form);
            }

            Sldr.Cleanup();
        }
Esempio n. 14
0
            public TestEnvironment(bool sldrOffline = true, DateTime?embeddedAllTagsTime = null)
            {
                string sldrCachePath = Sldr.SldrCachePath;

                Sldr.Cleanup();
                if (embeddedAllTagsTime == null)
                {
                    Sldr.Initialize(sldrOffline, sldrCachePath);
                }
                else
                {
                    Sldr.Initialize(sldrOffline, sldrCachePath, embeddedAllTagsTime.Value);
                }
                FolderContainingLdml = new TemporaryFolder("SldrTests");
                NamespaceManager     = new XmlNamespaceManager(new NameTable());
                NamespaceManager.AddNamespace("sil", "urn://www.sil.org/ldml/0.1");
            }
Esempio n. 15
0
            public void Dispose()
            {
                FolderContainingLdml.Dispose();
                string sldrCachePath = Sldr.SldrCachePath;

                Sldr.Cleanup();
                // clear out SLDR cache
                DirectoryInfo di = new DirectoryInfo(sldrCachePath);

                foreach (FileInfo fi in di.GetFiles())
                {
                    fi.Delete();
                }
                // The OfflineSldrAttribute has been assigned to the entire test assembly, so we reinitialize
                // the SLDR back to what it was
                Sldr.Initialize(true, sldrCachePath);
            }
Esempio n. 16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FwLexiconPlugin"/> class.
        /// </summary>
        public FwLexiconPlugin()
        {
            FwRegistryHelper.Initialize();

            // setup necessary environment variables on Linux
            if (MiscUtils.IsUnix)
            {
                // update ICU_DATA to location of ICU data files
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ICU_DATA")))
                {
                    string codeIcuDataPath = Path.Combine(ParatextLexiconPluginDirectoryFinder.CodeDirectory, "Icu" + CustomIcu.Version);
#if DEBUG
                    string icuDataPath = codeIcuDataPath;
#else
                    string icuDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), ".config/fieldworks/Icu" + CustomIcu.Version);
                    if (!Directory.Exists(icuDataPath))
                    {
                        icuDataPath = codeIcuDataPath;
                    }
#endif
                    Environment.SetEnvironmentVariable("ICU_DATA", icuDataPath);
                }
                // update COMPONENTS_MAP_PATH to point to code directory so that COM objects can be loaded properly
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("COMPONENTS_MAP_PATH")))
                {
                    string compMapPath = Path.GetDirectoryName(FileUtils.StripFilePrefix(Assembly.GetExecutingAssembly().CodeBase));
                    Environment.SetEnvironmentVariable("COMPONENTS_MAP_PATH", compMapPath);
                }
                // update FW_ROOTCODE so that strings-en.txt file can be found
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("FW_ROOTCODE")))
                {
                    Environment.SetEnvironmentVariable("FW_ROOTCODE", ParatextLexiconPluginDirectoryFinder.CodeDirectory);
                }
            }
            FwUtils.InitializeIcu();
            if (!Sldr.IsInitialized)
            {
                Sldr.Initialize();
            }

            m_syncRoot     = new object();
            m_lexiconCache = new FdoLexiconCollection();
            m_cacheCache   = new LcmCacheCollection();
            m_ui           = new ParatextLexiconPluginLcmUI();
        }
Esempio n. 17
0
 public void Constructor_CreateNewProjectFromBundle_BundleHasNoLdmlFile_WsLdmlIsSet_ProjectIsCreatedSuccessfully()
 {
     Sldr.Initialize();
     try
     {
         var bundle = GetGlyssenBundleToBeUsedForProject(false);
         bundle.Metadata.Language.Ldml = "ach";
         var project = new Project(bundle);
         WaitForProjectInitializationToFinish(project, ProjectState.ReadyForUserInteraction);
         Assert.IsNotNull(project);
         Assert.IsNotEmpty(project.QuoteSystem.AllLevels);
         Assert.AreEqual("ach", project.WritingSystem.Id);
     }
     finally
     {
         Sldr.Cleanup();
     }
 }
Esempio n. 18
0
 public void Constructor_CreateNewProjectFromBundle_BundleHasNoLdmlFile_WsIsoCodeNotInLanguageRepo_ProjectIsCreatedUsingPrivateUseWritingSystem()
 {
     Sldr.Initialize();
     try
     {
         var bundle = GetGlyssenBundleToBeUsedForProject(false);
         bundle.Metadata.Language.Iso  = "zyt";
         bundle.Metadata.Language.Ldml = "";
         var project = new Project(bundle);
         WaitForProjectInitializationToFinish(project, ProjectState.ReadyForUserInteraction);
         Assert.IsNotNull(project);
         Assert.IsNotEmpty(project.QuoteSystem.AllLevels);
         Assert.AreEqual("zyt", project.WritingSystem.Id);
         Assert.IsTrue(project.WritingSystem.Language.IsPrivateUse);
     }
     finally
     {
         Sldr.Cleanup();
     }
 }
Esempio n. 19
0
        public void TestFixtureSetUp()
        {
            // Use the real version of the file because we want the results to be based on the production control file.
            ControlCharacterVerseData.TabDelimitedCharacterVerseData = null;
            CharacterDetailData.TabDelimitedCharacterDetailData      = null;

            Sldr.Initialize();
            try
            {
                m_project =
                    Project.Load(@"C:\ProgramData\FCBH-SIL\Glyssen\ach\3b9fdc679b9319c3\Acholi New Test 1985 Audio\ach.glyssen");
                TestProject.SimulateDisambiguationForAllBooks(m_project);
                m_project.CharacterGroupGenerationPreferences.NarratorsOption = NarratorsOption.SingleNarrator;
            }
            catch
            {
                // If we have an exception here, TestFixtureTearDown doesn't get called which means we need to call Sldr.Cleanup() now
                Sldr.Cleanup();
                throw;
            }
        }
Esempio n. 20
0
        /// <summary> Exports main character set from a project to an ldml file </summary>
        private void LdmlExport(string filePath, string langTag)
        {
            // SLDR is the SIL Locale Data repository, it is necessary for reading/writing ldml
            // It is being initialized in offline mode here to only pull local data
            Sldr.Initialize(true);
            try
            {
                var wsr = LdmlInFolderWritingSystemRepository.Initialize(filePath);
                var wsf = new LdmlInFolderWritingSystemFactory(wsr);
                wsf.Create(langTag, out var wsDef);

                var proj = _projService.GetProject(_projectId).Result;

                // If there isn't already a main character set defined, make one and add it to the writing system
                // definition
                if (!wsDef.CharacterSets.TryGet("main", out var chars))
                {
                    chars = new CharacterSetDefinition("main");
                    wsDef.CharacterSets.Add(chars);
                }

                // Replace all the characters found with our copy of the character set
                chars.Characters.Clear();
                foreach (var character in proj.ValidCharacters)
                {
                    chars.Characters.Add(character);
                }

                // Write out the new definition
                wsr.Set(wsDef);
                wsr.Save();
            }
            finally
            {
                // If there was somehow an error above, we still want to cleanup to prevent unhelpful errors later
                Sldr.Cleanup();
            }
        }
Esempio n. 21
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Sldr.Initialize();
            var localizationFolder = Path.GetDirectoryName(FileLocationUtilities.GetFileDistributedWithApplication("Palaso.en.tmx"));

            LocalizationManager.Create("fr", "Palaso", "Palaso", "1.0.0", localizationFolder, "SIL/Palaso",
                                       null, "");
            if (args.Length > 0)          //for testing commandlinerunner
            {
                for (int i = 0; i < 10; i++)
                {
                    Console.WriteLine(i);
                    Thread.Sleep(1000);
                }
                return;
            }

            Application.Run(new TestAppForm());

            Sldr.Cleanup();
        }
Esempio n. 22
0
        public void TestFixtureSetUp()
        {
            // Use the real version of the file because we want the results to be based on the production control file.
            ControlCharacterVerseData.TabDelimitedCharacterVerseData = null;
            CharacterDetailData.TabDelimitedCharacterDetailData      = null;

            Sldr.Initialize();
            try
            {
                //Change this to Kuna and finish tests for OT books
                m_project =
                    Project.Load(
                        @"C:\ProgramData\FCBH-SIL\Glyssen\cuk\5a6b88fafe1c8f2b\The Bible in Kuna, San Blas Audio\cuk.glyssen");
                TestProject.SimulateDisambiguationForAllBooks(m_project);
                m_project.CharacterGroupGenerationPreferences.NarratorsOption = NarratorsOption.SingleNarrator;
            }
            catch
            {
                // If we have an exception here, TestFixtureTearDown doesn't get called which means we need to call Sldr.Cleanup() now.
                // This can affect other tests, otherwise.
                Sldr.Cleanup();
                throw;
            }
        }
Esempio n. 23
0
        /// <summary> Imports main character set for a project from an ldml file </summary>
        public void LdmlImport(string filePath, string langTag)
        {
            // SLDR is the SIL locale data repository, it is necessary for reading/writing ldml
            // It is being initialized in offline mode here to only pull local data
            Sldr.Initialize(true);
            try
            {
                var wsr = LdmlInFolderWritingSystemRepository.Initialize(filePath);
                var wsf = new LdmlInFolderWritingSystemFactory(wsr);
                wsf.Create(langTag, out var wsDef);

                //if there is a main character set, import it to the project
                if (wsDef.CharacterSets.Contains("main"))
                {
                    var newProj = _projService.GetProject(_projectId).Result;
                    newProj.ValidCharacters = wsDef.CharacterSets["main"].Characters.ToList();
                    _projService.Update(_projectId, newProj);
                }
            }
            finally //if there was somehow an error above, we still want to cleanup to prevent unhelpful errors later
            {
                Sldr.Cleanup();
            }
        }
Esempio n. 24
0
 public CallerSetting(string database)
 {
     _xDoc.RemoveAll();
     if (!Sldr.IsInitialized)
     {
         Sldr.Initialize(true);
     }
     WritingSystem = new WritingSystemDefinition();
     DatabaseName  = database;
     if (database != "DatabaseName")
     {
         FindDataFolder();
     }
     if (Caller == DataCreator.CreatorProgram.FieldWorks8 ||
         Caller == DataCreator.CreatorProgram.FieldWorks9)
     {
         SetupLdmlFolder();
     }
     if (Caller != null)
     {
         return;
     }
     Caller = DataCreator.Creator;
 }
Esempio n. 25
0
 public OfflineSldr()
 {
     _sldrCacheFolder = new TemporaryFolder("SldrCacheTest");
     Sldr.Initialize(true, _sldrCacheFolder.Path);
 }
Esempio n. 26
0
        public static int Main(string[] args)
        {
            ExceptionLogging.Initialize("17a42e4a67dd2e42d4aa40d8bf2d23ee", Assembly.GetExecutingAssembly().GetName().Name);
            int result  = (int)ErrorCode.NoError;
            var options = Options.ParseCommandLineArgs(args);

            if (options == null)
            {
                return((int)ErrorCode.InvalidOptions);
            }

            // initialize the SLDR
            Sldr.Initialize();

            // Username and Password will usually be "x" because it's dealt with on Language Forge site.
            // However, when debugging LfMerge we want to be able to set it to a real name
            ChorusHelper.Username = options.User;
            ChorusHelper.Password = System.Environment.GetEnvironmentVariable("LANGUAGE_DEPOT_TRUST_TOKEN") ?? options.Password;

            ExceptionLogging.Client.AddInfo(options.ProjectCode, MainClass.ModelVersion);

            MainClass.Logger.Notice("LfMerge {2} (database {0}) starting with args: {1}",
                                    MainClass.ModelVersion, string.Join(" ", args), MainClass.GetVersionInfo("SemVer"));

            if (string.IsNullOrEmpty(options.ProjectCode))
            {
                MainClass.Logger.Error("Command line doesn't contain project code - exiting.");
                return(-1);
            }

            FwProject.AllowDataMigration = options.AllowDataMigration;

            string differentModelVersion = null;

            try
            {
                if (!MainClass.CheckSetup())
                {
                    return((int)ErrorCode.GeneralError);
                }

                MongoConnection.Initialize();

                differentModelVersion = RunAction(options.ProjectCode, options.CurrentAction);
            }
            catch (Exception e)
            {
                MainClass.Logger.Error("Unhandled Exception: \n{0}", e);
                throw;
            }
            finally
            {
                if (Sldr.IsInitialized)
                {
                    Sldr.Cleanup();
                }

                MainClass.Container.Dispose();
                Cleanup();
            }

            if (!string.IsNullOrEmpty(differentModelVersion))
            {
                result = MainClass.StartLfMerge(options.ProjectCode, options.CurrentAction,
                                                differentModelVersion, false);
            }

            MainClass.Logger.Notice("LfMerge-{0} finished", MainClass.ModelVersion);
            return(result);
        }
Esempio n. 27
0
        static void Main(string[] args)
        {
            IsRunning = true;

            if (GetRunningGlyssenProcessCount() > 1)
            {
                ErrorReport.NotifyUserOfProblem("There is another copy of Glyssen already running. This instance of Glyssen will now shut down.");
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //bring in settings from any previous version
            if (Settings.Default.NeedUpgrade)
            {
                //see http://stackoverflow.com/questions/3498561/net-applicationsettingsbase-should-i-call-upgrade-every-time-i-load
                Settings.Default.Upgrade();
                Settings.Default.Reload();
                Settings.Default.NeedUpgrade = false;
                Settings.Default.Save();
            }

            SetUpErrorHandling();

#if DEBUG
            using (new Analytics("jBh7Qg4jw2nRFE8j8EY1FDipzin3RFIP", new UserInfo {
                UILanguageCode = Settings.Default.UserInterfaceLanguage
            }))
#else
            string feedbackSetting = Environment.GetEnvironmentVariable("FEEDBACK");

            //default is to allow tracking
            var allowTracking = string.IsNullOrEmpty(feedbackSetting) || feedbackSetting.ToLower() == "yes" || feedbackSetting.ToLower() == "true";

            using (new Analytics("WEyYj2BOnZAP9kplKmo2BDPvfyofbMZy", new UserInfo {
                UILanguageCode = Settings.Default.UserInterfaceLanguage
            }, allowTracking))
#endif
            {
                Logger.Init();

                var oldPgBaseFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
                                                   GlyssenInfo.kCompany, kOldProductName);
                var baseDataFolder = GlyssenInfo.BaseDataFolder;
                if (Directory.Exists(oldPgBaseFolder) && !Directory.Exists(baseDataFolder))
                {
                    Directory.Move(oldPgBaseFolder, baseDataFolder);
                }

                if (!Directory.Exists(baseDataFolder))
                {
                    // create the directory
                    Directory.CreateDirectory(baseDataFolder);
                }

                // PG-433, 07 JAN 2016, PH: Set the permissions so everyone can read and write to this directory
                DirectoryUtilities.SetFullControl(baseDataFolder, false);

                DataMigrator.UpgradeToCurrentDataFormatVersion();

                SampleProject.CreateSampleProjectIfNeeded();

                SetUpLocalization();

                // The following not only gets the location of the settings file;
                // it also detects corruption and deletes it if needed so we don't crash.
                string userConfigSettingsPath = GetUserConfigFilePath();

                if ((Control.ModifierKeys & Keys.Shift) > 0 && !string.IsNullOrEmpty(userConfigSettingsPath))
                {
                    HandleDeleteUserSettings(userConfigSettingsPath);
                }

                Sldr.Initialize();

                try
                {
                    Application.Run(new MainForm(args));
                }
                finally
                {
                    Sldr.Cleanup();
                }
            }
        }
Esempio n. 28
0
        LanguageLookup _languageLookup;         // throws FileNotFound / invalid image exception

        public LanguageData()
        {
            if (!Sldr.IsInitialized)
            {
                Sldr.Initialize();
            }
            _languageLookup = new LanguageLookup();
            // These are from the GDL catalog of January 2020.
            _nameToCode.Add("አማርኛ", "am");
            _nameToCode.Add("Arabic", "ar");
            _nameToCode.Add("Awadhi", "awa");
            _nameToCode.Add("Bhojpuri", "bho");
            _nameToCode.Add("বাঙালি", "bn");
            _nameToCode.Add("Bukusu", "luy");                   // bxk in GDL
            _nameToCode.Add("Cebuano", "ceb");
            _nameToCode.Add("Dotyali", "dty");
            _nameToCode.Add("English", "en");
            _nameToCode.Add("Spanish (Spain)", "es-ES");
            _nameToCode.Add("French", "fr");
            _nameToCode.Add("Gusii", "guz");
            _nameToCode.Add("Hausa (Nigeria)", "ha-NG");
            _nameToCode.Add("Hadiyya", "hdy");
            _nameToCode.Add("हिंदी", "hi");
            _nameToCode.Add("bahasa Indonesia", "id");
            _nameToCode.Add("Kalanguya", "kak");
            _nameToCode.Add("Kamba (Kenya)", "kam");
            _nameToCode.Add("ភាសាខ្មែរ", "km");
            _nameToCode.Add("Lingala", "ln");
            _nameToCode.Add("Wanga", "lwg");
            _nameToCode.Add("Maithili", "mai");
            _nameToCode.Add("मराठी", "mr");
            _nameToCode.Add("नेपाली (Nepal)", "ne-NP");
            _nameToCode.Add("Newari", "new");
            _nameToCode.Add("isiNdebele seSewula", "nr");
            _nameToCode.Add("Pedi", "nso");
            _nameToCode.Add("Afaan Oromoo", "om");
            _nameToCode.Add("Portuguese (Brazil)", "pt-BR");
            _nameToCode.Add("Kinyarwanda", "rw");
            _nameToCode.Add("Sidamo", "sid");
            _nameToCode.Add("Shona", "sn");
            _nameToCode.Add("Somali (Ethiopia)", "so-ET");
            _nameToCode.Add("siSwati", "ss");
            _nameToCode.Add("Sesotho", "st");
            _nameToCode.Add("Kiswahili (Kenya)", "sw-KE");
            _nameToCode.Add("Dangaura Tharu", "thl");
            _nameToCode.Add("Tigrinya (Ethiopia)", "ti-ET");
            _nameToCode.Add("Setswana", "tn");
            _nameToCode.Add("Tshivenḓa", "ve");
            _nameToCode.Add("Wolaytta", "wal");
            _nameToCode.Add("isiZulu", "zu");
            // These are the best I could figure out from the StoryWeaver catalog of January 2020.
            _nameToCode.Add("Acholi", "ach");
            _nameToCode.Add("Afaan Oromo", "om");               // gax hae
            _nameToCode.Add("Afrikaans", "af");
            _nameToCode.Add("Akuapem Twi", "ak-x-Akuapem");
            _nameToCode.Add("Amharic", "am");
            _nameToCode.Add("Aringati", "luc");
            _nameToCode.Add("Asante Twi", "ak-x-Asante");
            _nameToCode.Add("Assamese", "as");
            _nameToCode.Add("Ateso", "teo");
            _nameToCode.Add("Bahasa Indonesia", "id");
            _nameToCode.Add("Balinese", "ban");
            _nameToCode.Add("Bangla (Bangladesh)", "bn-BD");
            _nameToCode.Add("Basa Jawa", "jv");
            _nameToCode.Add("Bengali", "bn");
            _nameToCode.Add("Bengali-Santali (Bengali Script)", "sat-Beng");
            _nameToCode.Add("Bhoti", "sbu");                // ??
            _nameToCode.Add("Chinese (Simplified)", "zh-CN");
            _nameToCode.Add("Chinese (Traditional)", "zh-TW");
            _nameToCode.Add("Chinyanja", "ny");
            _nameToCode.Add("ChiShona", "sn");
            _nameToCode.Add("Chitonga", "tog");
            _nameToCode.Add("Dagaare", "dga");              // dgi
            _nameToCode.Add("Dagbani", "dag");
            _nameToCode.Add("Dangme", "ada");
            _nameToCode.Add("Dhopadhola", "adh");
            _nameToCode.Add("Ekegusii", "guz");
            //_nameToCode.Add("English", "en"); - already have
            _nameToCode.Add("Ewe", "ee");
            _nameToCode.Add("Fante", "ak-x-Fante");
            _nameToCode.Add("Farsi (Samim)", "prs-x-Samim");
            _nameToCode.Add("Filipino", "fil");
            //_nameToCode.Add("French", "fr"); - already have
            _nameToCode.Add("Fulfulde Mbororoore", "fuv");
            _nameToCode.Add("Ga", "gaa");
            _nameToCode.Add("Gondi", "gon");
            _nameToCode.Add("Gonja", "gjn");
            _nameToCode.Add("Gujarati", "gu");
            _nameToCode.Add("Gurene", "gur");
            _nameToCode.Add("Hausa", "ha");
            _nameToCode.Add("Hindi", "hi");
            _nameToCode.Add("IciBemba", "bem");
            _nameToCode.Add("Igbo", "ig");
            _nameToCode.Add("isiNdebele", "nd");                // nr
            _nameToCode.Add("isiXhosa", "xh");
            //_nameToCode.Add("isiZulu", "zu"); - already have
            _nameToCode.Add("Kakwa", "keo");
            _nameToCode.Add("Kannada", "kn");
            _nameToCode.Add("Kasem", "xsm");
            _nameToCode.Add("Khmer", "km");
            _nameToCode.Add("Khoekhoegowab", "naq");
            _nameToCode.Add("K'iche", "quc");
            _nameToCode.Add("Kidawida", "dav");
            _nameToCode.Add("Kikamba", "kam");
            _nameToCode.Add("Kikuyu", "ki");
            //_nameToCode.Add("Kinyarwanda", "rw"); - already have
            _nameToCode.Add("Kiswahili", "sw");
            _nameToCode.Add("Konkani", "knn");
            _nameToCode.Add("Kora (Bengali Script)", "cdz-Beng");
            _nameToCode.Add("Korku", "kfq");
            _nameToCode.Add("Kumam", "kdi");
            _nameToCode.Add("Kurmali", "kyw");
            _nameToCode.Add("Kurukh", "kru");
            _nameToCode.Add("Lámnsoʼ", "lns");
            _nameToCode.Add("Lao", "lo");
            _nameToCode.Add("Likpakpaanl", "xon");
            //_nameToCode.Add("Lingala", "ln"); - already have
            _nameToCode.Add("Lubukusu", "luy");
            _nameToCode.Add("Luganda", "lg");
            _nameToCode.Add("Lugbarati", "lgg");
            _nameToCode.Add("Lugwere", "gwr");
            _nameToCode.Add("Lumasaaba", "myx");
            _nameToCode.Add("Lunyole", "nuj");          // nyd
            _nameToCode.Add("Lusoga", "xog");
            _nameToCode.Add("Maa", "cma");              // mas mev
            _nameToCode.Add("Malayalam", "ml");
            _nameToCode.Add("Mampruli", "maw");
            _nameToCode.Add("Marathi", "mr");
            _nameToCode.Add("Marwari", "mwr");              // mve rwr
            _nameToCode.Add("Minangkabau", "min");
            _nameToCode.Add("Mundari", "unr");              // mqu
            _nameToCode.Add("Nepali", "ne");
            _nameToCode.Add("Ng’aturkana", "tuv");
            _nameToCode.Add("Nzema", "nzi");
            _nameToCode.Add("Odia", "or");              // (macrolanguage)
            _nameToCode.Add("Olukhayo", "lko");
            _nameToCode.Add("Oluwanga", "lwg");
            _nameToCode.Add("Oshikwanyama", "kj");
            _nameToCode.Add("Oshindonga", "ng");
            _nameToCode.Add("Otjiherero", "hz");
            _nameToCode.Add("Pashto", "ps");                // pst pbu
            _nameToCode.Add("Portuguese", "pt");
            _nameToCode.Add("Punjabi", "pa");
            _nameToCode.Add("Rufumbira", "rw");
            _nameToCode.Add("Rukwangali", "kwn");
            _nameToCode.Add("Runyankore", "nyn");
            _nameToCode.Add("Rutooro", "ttj");
            _nameToCode.Add("Sadri", "sck");
            _nameToCode.Add("Santali (Bengali Script)", "sat-Beng");
            _nameToCode.Add("Sepedi", "nso");
            //_nameToCode.Add("Sesotho", "st"); - already have
            //_nameToCode.Add("Setswana", "tn"); - already have
            _nameToCode.Add("S'gaw Karen (Latin Script)", "ksw-Latn");
            _nameToCode.Add("SiLozi", "loz");
            _nameToCode.Add("Sinhala", "si");
            _nameToCode.Add("Sisali", "sld");               // ?? Sisaali / Sissala
            _nameToCode.Add("Siswati", "ss");
            _nameToCode.Add("Surjapuri", "sjp");
            _nameToCode.Add("Swedish", "sv");
            _nameToCode.Add("Tamil", "ta");
            _nameToCode.Add("Telugu", "te");
            _nameToCode.Add("Thai", "th");
            _nameToCode.Add("Tibetan", "bo");
            _nameToCode.Add("Tigrigna", "ti");
            _nameToCode.Add("Tiv", "tiv");
            //_nameToCode.Add("Tshivenḓa", "ve"); - already have
            _nameToCode.Add("Urdu", "ur");
            _nameToCode.Add("Vietnamese", "vi");
            _nameToCode.Add("Xitsonga", "ts");
            _nameToCode.Add("Yoruba", "yo");
            // These appear to be diglots: from what I've seen, the internal HTML doesn't distinguish language so these aren't useful.
            //_nameToCode.Add("English-Afrikaans", "xxx");
            //_nameToCode.Add("English-Bengali", "xxx");
            //_nameToCode.Add("English-Farsi (Samim)", "xxx");
            //_nameToCode.Add("English-Gujarati", "xxx");
            //_nameToCode.Add("English-Hindi", "xxx");
            //_nameToCode.Add("English-Kannada", "xxx");
            //_nameToCode.Add("English-Kutchi (Gujarati Script)", "xxx");
            //_nameToCode.Add("English-Marathi", "xxx");
            //_nameToCode.Add("English-Odia", "xxx");
            //_nameToCode.Add("English-Sepedi", "xxx");
            //_nameToCode.Add("English-Sesotho", "xxx");
            //_nameToCode.Add("English-Setswana", "xxx");
            //_nameToCode.Add("English-Siswati", "xxx");
            //_nameToCode.Add("English-Tamil", "xxx");
            //_nameToCode.Add("English-Telugu", "xxx");
            //_nameToCode.Add("English-Tshivenḓa", "xxx");
            //_nameToCode.Add("English-Tulu", "xxx");
            //_nameToCode.Add("English-Urdu", "xxx");
            //_nameToCode.Add("English-Xitsonga", "xxx");
            //_nameToCode.Add("English-isiNdebele", "xxx");
            //_nameToCode.Add("English-isiXhosa", "xxx");
            //_nameToCode.Add("English-isiZulu", "xxx");
            //_nameToCode.Add("Hindi-Kurmali", "xxx");
            //_nameToCode.Add("Hindi-Kurukh", "xxx");
            //_nameToCode.Add("Hindi-Mundari", "xxx");
            //_nameToCode.Add("Hindi-Sadri", "xxx");
            //_nameToCode.Add("Hindi-Surjapuri", "xxx");
            //_nameToCode.Add("Juanga-Odia", "jun-Orya");
            //_nameToCode.Add("Kora (Bengali Script)-Bengali", "xxx");
            //_nameToCode.Add("Kui-Odia", "kxu-Orya");
            //_nameToCode.Add("Munda-Odia", "unr-Orya");
            //_nameToCode.Add("Runyoro / Runyakitara", "xxx");
            //_nameToCode.Add("Santali-Bengali (Bengali Script)", "xxx");
            //_nameToCode.Add("Saura-Odia", "srb-Orya");
        }
Esempio n. 29
0
 public void SetupFixture()
 {
     Sldr.Initialize();
 }
Esempio n. 30
0
        public static void Main(string[] args)
        {
            ExceptionLogging.Initialize("17a42e4a67dd2e42d4aa40d8bf2d23ee", Assembly.GetExecutingAssembly().GetName().Name);
            var options = QueueManagerOptions.ParseCommandLineArgs(args);

            if (options == null)
            {
                return;
            }

            MainClass.Logger.Notice("LfMergeQueueManager starting with args: {0}", string.Join(" ", args));

            // initialize the SLDR
            Sldr.Initialize();

            var settings = MainClass.Container.Resolve <LfMergeSettings>();

            settings.Initialize();
            var fileLock = SimpleFileLock.CreateFromFilePath(settings.LockFile);

            try
            {
                if (!fileLock.TryAcquireLock())
                {
                    MainClass.Logger.Error("Can't acquire file lock - is another instance running?");
                    return;
                }
                MainClass.Logger.Notice("Lock acquired");

                if (!CheckSetup(settings))
                {
                    return;
                }

                // Cleanup any hang projects
                new Janitor(settings, MainClass.Logger).CleanupAndRescheduleJobs();

                for (var queue = Queue.FirstQueueWithWork;
                     queue != null;
                     queue = queue.NextQueueWithWork)
                {
                    var clonedQueue = queue.QueuedProjects.ToList();
                    foreach (var projectCode in clonedQueue)
                    {
                        var projectPath = Path.Combine(settings.LcmDirectorySettings.ProjectsDirectory,
                                                       projectCode, $"{projectCode}{LcmFileHelper.ksFwDataXmlFileExtension}");
                        var modelVersion = FwProject.GetModelVersion(projectPath);
                        queue.DequeueProject(projectCode);
                        int retCode = MainClass.StartLfMerge(projectCode, queue.CurrentActionName,
                                                             modelVersion, true);

                        // TODO: If LfMerge fails, should we re-queue the project, or not?
                        if (retCode != 0)
                        {
                            // queue.EnqueueProject(projectCode);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MainClass.Logger.Error("Unhandled Exception:\n{0}", e);
                throw;
            }
            finally
            {
                if (fileLock != null)
                {
                    fileLock.ReleaseLock();
                }

                if (Sldr.IsInitialized)
                {
                    Sldr.Cleanup();
                }

                MainClass.Container.Dispose();
            }

            MainClass.Logger.Notice("LfMergeQueueManager finished");
        }