public void PortAllBEPsTestsUsingAnAlreadyOpenedSource() { var path = Path.Combine(Path.GetTempPath(), "FieldWorksTest"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } foreach (var sourceBackendStartupParameters in m_sourceInfo) { if (sourceBackendStartupParameters == null) { continue; } DeleteDatabase(sourceBackendStartupParameters); // Set up data source, but only do it once. var sourceGuids = new List <Guid>(); using (var threadHelper = new ThreadHelper()) using (var sourceCache = FdoCache.CreateCacheWithNewBlankLangProj( new TestProjectId(sourceBackendStartupParameters.ProjectId.Type, sourceBackendStartupParameters.ProjectId.Path), "en", "fr", "en", threadHelper)) { // BEP is a singleton, so we shouldn't call Dispose on it. This will be done // by service locator. var sourceDataSetup = GetMainBEPInterface(sourceCache); // The source is created ex nihilo. sourceDataSetup.LoadDomain(sourceBackendStartupParameters.BulkLoadDomain); foreach (var obj in GetAllCmObjects(sourceCache)) { sourceGuids.Add(obj.Guid); // Collect up all source Guids. } foreach (var targetBackendStartupParameters in m_targetInfo) { if (targetBackendStartupParameters == null) { continue; } DeleteDatabase(targetBackendStartupParameters); // Migrate source data to new BEP. using (var otherThreadHelper = new ThreadHelper()) using (var targetCache = FdoCache.CreateCacheCopy( new TestProjectId(targetBackendStartupParameters.ProjectId.Type, targetBackendStartupParameters.ProjectId.Path), "en", sourceCache, otherThreadHelper)) { // BEP is a singleton, so we shouldn't call Dispose on it. This will be done // by service locator. var targetDataSetup = GetMainBEPInterface(targetCache); targetDataSetup.LoadDomain(BackendBulkLoadDomain.All); CompareResults(sourceGuids, targetCache); } } } } }
private void ConvertToTargetBEP(FdoCache originalCache, FDOBackendProviderType bepType, string targetPathname, string msg) { // Convert to test target BEP. TimeSpan elapsedTime; DeleteBEP(bepType, targetPathname); var start = DateTime.Now; using (var targetCache = FdoCache.CreateCacheCopy(bepType, new object[] { targetPathname }, "en", originalCache)) { //var dataSetup = targetCache.ServiceLocator.GetInstance<IDataSetup>(); //dataSetup.CreateNewLanguageProject(new object[] { targetPathname }, originalCache); elapsedTime = DateTime.Now - start; } MessageBox.Show(this, msg + elapsedTime.TotalMilliseconds); }
public void PortAllBEPsTestsUsingAnAlreadyOpenedSource( [Values(FDOBackendProviderType.kXML, FDOBackendProviderType.kDb4oClientServer, FDOBackendProviderType.kMemoryOnly)] FDOBackendProviderType sourceType, [Values(FDOBackendProviderType.kXML, FDOBackendProviderType.kDb4oClientServer, FDOBackendProviderType.kMemoryOnly)] FDOBackendProviderType targetType) { var sourceBackendStartupParameters = GenerateBackendStartupParameters(false, sourceType); var targetBackendStartupParameters = GenerateBackendStartupParameters(true, targetType); // Make sure we start from a clean slate DeleteDatabase(sourceBackendStartupParameters); // Set up data source, but only do it once. var sourceGuids = new List <Guid>(); using (var sourceCache = FdoCache.CreateCacheWithNewBlankLangProj( new TestProjectId(sourceBackendStartupParameters.ProjectId.Type, sourceBackendStartupParameters.ProjectId.Path), "en", "fr", "en", new DummyFdoUI(), FwDirectoryFinder.FdoDirectories, new FdoSettings())) { // BEP is a singleton, so we shouldn't call Dispose on it. This will be done // by service locator. var sourceDataSetup = GetMainBEPInterface(sourceCache); // The source is created ex nihilo. sourceDataSetup.LoadDomain(sourceBackendStartupParameters.BulkLoadDomain); sourceGuids.AddRange(GetAllCmObjects(sourceCache).Select(obj => obj.Guid)); // Collect all source Guids DeleteDatabase(targetBackendStartupParameters); // Migrate source data to new BEP. using (var targetCache = FdoCache.CreateCacheCopy( new TestProjectId(targetBackendStartupParameters.ProjectId.Type, targetBackendStartupParameters.ProjectId.Path), "en", new DummyFdoUI(), FwDirectoryFinder.FdoDirectories, new FdoSettings(), sourceCache)) { // BEP is a singleton, so we shouldn't call Dispose on it. This will be done // by service locator. var targetDataSetup = GetMainBEPInterface(targetCache); targetDataSetup.LoadDomain(BackendBulkLoadDomain.All); CompareResults(sourceGuids, targetCache); } } // Try to clean up after ourselves DeleteDatabase(sourceBackendStartupParameters, false); DeleteDatabase(targetBackendStartupParameters, false); }
private void Import(FdoCache originalCache, FDOBackendProviderType bepType, string msg, string exportedPathname) { DeleteBEP(bepType, exportedPathname); if (m_timingRun) { // Do a dry run, to get it precomplied. using (var cache = FdoCache.CreateCacheCopy(bepType, new object[] { exportedPathname }, "en", originalCache)) { //var dataSetup = cache.ServiceLocator.GetInstance<IDataSetup>(); //dataSetup.CreateNewLanguageProject(new object[] {exportedPathname}, originalCache); } } // Do an export for each count. var elapsedTime = new TimeSpan(0); int runCount = m_timingRun ? (int)numericUpDown1.Value : 1; for (var i = 0; i < runCount; ++i) { DeleteBEP(bepType, exportedPathname); var start = DateTime.Now; using (var cache = FdoCache.CreateCacheCopy(bepType, new object[] { exportedPathname }, "en", originalCache)) { //var dataSetup = cache.ServiceLocator.GetInstance<IDataSetup>(); //dataSetup.CreateNewLanguageProject(new object[] { exportedPathname }, originalCache); elapsedTime += DateTime.Now - start; } } if (m_timingRun) { DeleteBEP(bepType, exportedPathname); } MessageBox.Show(this, string.Format("Average time to import from XML to {0}: {1}", msg, elapsedTime.TotalMilliseconds / runCount)); }