private static void MigrateData(AuxToolOptions options) { var oldVersion = FwProject.GetModelVersion(options.Project); try { var project = Path.Combine(Path.GetDirectoryName(options.Project), Path.GetFileNameWithoutExtension(options.Project)); FwProject.AllowDataMigration = true; using (new FwProject(new LfMergeSettings(), project)) { Console.WriteLine("Migrated {0} from {1} to {2}", Path.GetFileName(options.Project), oldVersion, FwProject.GetModelVersion(options.Project)); } } catch (LcmDataMigrationForbiddenException) { Console.WriteLine("LCM: Incompatible version (can't migrate data)"); } catch (LcmNewerVersionException) { Console.WriteLine( "LCM: Incompatible version (version number newer than expected)"); } catch (LcmFileLockedException) { Console.WriteLine("LCM: Access denied"); } catch (Exception e) { Console.WriteLine("LCM: Unknown error: {0} exception: {1}", e.GetType(), e.Message); } }
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(); } }
protected override void DoRun(ILfProject project) { // TODO: These checks might be overkill; consider removing some of them if (project == null) { Logger.Error("Project was null in TransferFdoToMongoAction.DoRun"); return; } Logger.Debug("TransferFdoToMongoAction: locating FieldWorks project"); FwProject fwProject = project.FieldWorksProject; if (fwProject == null) { Logger.Error("Can't find FieldWorks project {0}", project.ProjectCode); return; } Logger.Debug("TransferFdoToMongoAction: locating FieldWorks project cache"); _cache = fwProject.Cache; if (_cache == null) { Logger.Error("Can't find cache for FieldWorks project {0}", project.ProjectCode); return; } Logger.Debug("TransferFdoToMongoAction: connecting to FieldWorks service locator"); _servLoc = _cache.ServiceLocator; if (_servLoc == null) { Logger.Error("Can't find service locator for FieldWorks project {0}", project.ProjectCode); return; } Logger.Debug("TransferFdoToMongoAction: setting up lexicon converter"); _lexiconConverter = new ConvertFdoToMongoLexicon(project, Logger, _connection, Progress, _projectRecordFactory); Logger.Debug("TransferFdoToMongoAction: about to run lexicon conversion"); _lexiconConverter.RunConversion(); Logger.Debug("TransferFdoToMongoAction: successful transfer; setting last-synced date"); _connection.SetLastSyncedDate(project, DateTime.UtcNow); }
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"); }
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; } if (options.InfoOnly) { Console.WriteLine("{0} has model version {1}", Path.GetFileName(options.Project), FwProject.GetModelVersion(options.Project)); } ExceptionLogging.Client.AddInfo(options.Project, FwProject.GetModelVersion(options.Project)); if (options.Migrate) { var oldVersion = FwProject.GetModelVersion(options.Project); try { var project = Path.Combine(Path.GetDirectoryName(options.Project), Path.GetFileNameWithoutExtension(options.Project)); FwProject.AllowDataMigration = true; using (new FwProject(new LfMergeSettings(), project)) { Console.WriteLine("Migrated {0} from {1} to {2}", Path.GetFileName(options.Project), oldVersion, FwProject.GetModelVersion(options.Project)); } } catch (FdoDataMigrationForbiddenException) { Console.WriteLine("FDO: Incompatible version (can't migrate data)"); } catch (FdoNewerVersionException) { Console.WriteLine("FDO: Incompatible version (version number newer than expected)"); } catch (FdoFileLockedException) { Console.WriteLine("FDO: Access denied"); } catch { Console.WriteLine("FDO: Unknown error"); } } if (options.Commit) { var hgDir = Path.Combine(Path.GetDirectoryName(options.Project), ".hg"); if (!Directory.Exists(hgDir)) { Console.WriteLine("It looks the project isn't setup for S/R - can't find '{0}'", hgDir); return; } // Call into LF Bridge to do the work. string syncResult; var mergeBridgeOptions = new Dictionary <string, string> { { "fullPathToProject", Path.GetDirectoryName(options.Project) }, { "fwdataFilename", options.Project }, { "fdoDataModelVersion", FdoCache.ModelVersion }, }; var result = LfMergeBridge.LfMergeBridge.Execute("Language_Forge_Auxiliary_Commit", new NullProgress(), mergeBridgeOptions, out syncResult); Console.WriteLine(syncResult); if (result) { Console.WriteLine("Successfully updated .hg files"); } } }
private static void DisplayInfo(AuxToolOptions options) { Console.WriteLine("{0} has model version {1}", Path.GetFileName(options.Project), FwProject.GetModelVersion(options.Project)); }