public static void GetParatextProjects() { var apiFolder = Util.ApiFolder(); if (!ParatextInfo.IsParatextInstalled) { return; } try { ParatextData.Initialize(); var paratextProjects = ScrTextCollection.ScrTexts(IncludeProjects.ScriptureOnly); if (paratextProjects == null) { return; } var jsonList = ParatextProjectsJsonList(paratextProjects); using (var sw = new StreamWriter(Path.Combine(apiFolder, "GetParatextProjects"))) { sw.Write($"[{string.Join(",", jsonList)}]"); } } catch (Exception ex) { string error = ex.Message; Debug.Print(error); Logger.WriteEvent(error); } }
/// <summary> /// The Transcribed Data is moved to Paratext SFM /// </summary> /// <param name="taskId">Task Id</param> /// <param name="heading">Heading for scripture</param> /// <returns>true if upload successful</returns> public static bool Upload(string taskId, string heading) { if (!ParatextInfo.IsParatextInstalled) { return(false); } try { // Get Task Details var currentTask = new Task(); currentTask = currentTask.GetTask(taskId); // Get the Task Transcription Text from EAF var folder = Util.FileFolder(taskId); string eafFilePath = Path.Combine(folder, Path.GetFileNameWithoutExtension(taskId) + ".eaf"); var transcriptionArray = GetTranscriptionTextFromEaf(eafFilePath); if (transcriptionArray[0].Trim().ToUpper().StartsWith("File Error:")) { return(false); } ParatextData.Initialize(); var paratextProject = ScrTextCollection.Find(currentTask.Project); if (paratextProject == null) { return(false); } var bookNum = paratextProject.BookNames.ScrText.BookNames.GetBookNumFromName(currentTask.BookName, true, BookNameSource.Abbreviation); if (bookNum == 0) { bookNum = (from i in paratextProject.BookNames.GetBookNames() where i.BookCode == currentTask.BookName select i.BookNum).FirstOrDefault(); } var vRef = new VerseRef(bookNum, currentTask.ChapterNumber, Convert.ToInt32(currentTask.VerseStart), paratextProject.Settings.Versification); var chapterContent = paratextProject.GetText(vRef, true, true); var sb = GenerateParatextData(currentTask, chapterContent, transcriptionArray[1], heading); paratextProject.PutText(bookNum, currentTask.ChapterNumber, true, sb.ToString(), null); return(true); } catch (Exception ex) { var error = ex.Message; Debug.Print(error); Logger.WriteEvent(error); } return(false); }
public void Initialize() { Alert.Implementation = new ParatextAlert(); ParatextData.Initialize(); }
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(); UserInfo userInfo = new UserInfo { UILanguageCode = Settings.Default.UserInterfaceLanguage }; bool sldrIsInitialized = false; Logger.Init(); Trace.Listeners.Add(new LogFileTraceListener()); Alert.Implementation = new AlertImpl(); // Do this before calling Initialize, just in case Initialize tries to display an alert. if (ParatextInfo.IsParatextInstalled) { string userName = null; try { ParatextData.Initialize(); sldrIsInitialized = true; userName = RegistrationInfo.UserName; userInfo.Email = RegistrationInfo.EmailAddress; foreach (var errMsgInfo in CompatibleParatextProjectLoadErrors.Where(e => e.Reason == UnsupportedReason.Unspecified)) { _pendingExceptionsToReportToAnalytics.Add(errMsgInfo.Exception); } } catch (Exception fatalEx) when(fatalEx is FileLoadException || fatalEx is TypeInitializationException) { ErrorReport.ReportFatalException(fatalEx); } catch (Exception ex) { _pendingExceptionsToReportToAnalytics.Add(ex); } if (userName != null) { var split = userName.LastIndexOf(" ", StringComparison.Ordinal); if (split > 0) { userInfo.FirstName = userName.Substring(0, split); userInfo.LastName = userName.Substring(split + 1); } else { userInfo.LastName = userName; } } } // ENHANCE (PG-63): Implement something like this if we decide to give the user the option of manually // specifying the location of Paratext data files if the program isn’t actually installed. //else //{ // RegistrationInfo.Implementation = new GlyssenAnonymousRegistrationInfo(); // if (!String.IsNullOrWhiteSpace(Settings.Default.UserSpecifiedParatext8ProjectsDir) && // Directory.Exists(Settings.Default.UserSpecifiedParatext8ProjectsDir)) // { // try // { // ParatextData.Initialize(Settings.Default.UserSpecifiedParatext8ProjectsDir); // sldrIsInitialized = true; // } // catch (Exception ex) // { // _pendingExceptionsToReportToAnalytics.Add(ex); // Settings.Default.UserSpecifiedParatext8ProjectsDir = null; // } // } //} #if DEBUG using (new Analytics("jBh7Qg4jw2nRFE8j8EY1FDipzin3RFIP", userInfo)) #else //default is to allow tracking if this isn't set string feedbackSetting = Environment.GetEnvironmentVariable("FEEDBACK")?.ToLower(); var allowTracking = string.IsNullOrEmpty(feedbackSetting) || feedbackSetting == "yes" || feedbackSetting == "true"; using (new Analytics("WEyYj2BOnZAP9kplKmo2BDPvfyofbMZy", userInfo, allowTracking)) #endif { foreach (var exception in _pendingExceptionsToReportToAnalytics) { Analytics.ReportException(exception); } _pendingExceptionsToReportToAnalytics.Clear(); 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); SetUpLocalization(); DataMigrator.UpgradeToCurrentDataFormatVersion(); SampleProject.CreateSampleProjectIfNeeded(); // 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); } // This might also be needed if Glyssen and ParatextData use different versions of SIL.WritingSystems.dll if (!sldrIsInitialized) { Sldr.Initialize(); } try { Application.Run(new MainForm(args)); } finally { Sldr.Cleanup(); } } }
public void Initialize() { ParatextData.Initialize(); }