Ejemplo n.º 1
0
        public ResourceSyncStatistics SyncBundleDeletions(ResourceAssembly ra, List<string> existingBundleNames)
        {
            var context = new TinyTranslatorDbContext();

            var task = new SyncResourcesTask(
                new ResourceAssemblyRepository(context),
                new ResourceBundleRepository(context),
                new ResourceRepository(context),
                new ResourceTranslationRepository(context)
                );

            var assembly = task.SyncResourceAssembly(ra);
            task.DeleteNonExistingBundles(assembly, existingBundleNames);
            context.SaveChanges();

            task.CalculateAssemblyStatusFromBundles(assembly);
            context.SaveChanges();

            return task.Statistics;
        }
        public TranslationSyncStatistics SyncTranslations(ResourceAssembly assembly, ResourceBundle bundle, List<ResourceTranslation> translations)
        {
            var context = new TinyTranslatorDbContext();

            var task = new SyncTranslationsTask(
                new ProjectRepository(context),
                new ResourceAssemblyRepository(context),
                new ResourceBundleRepository(context),
                new ResourceRepository(context),
                new ResourceTranslationRepository(context)
                );

            var existingAssembly = task.SyncTranslations(assembly, bundle, translations);
            context.SaveChanges();

            if (existingAssembly != null)
            {
                task.CalculateAssemblyStatusFromBundles(existingAssembly);
                context.SaveChanges();
            }

            return task.Statistics;
        }
Ejemplo n.º 3
0
        private ResourceSyncStatistics InnerSyncResourceAssembly(ResourceAssembly ra, ICollection<ResourceBundle> bundles, bool deleteBundles)
        {
            var context = new TinyTranslatorDbContext();

            var task = new SyncResourcesTask(
                new ResourceAssemblyRepository(context),
                new ResourceBundleRepository(context),
                new ResourceRepository(context),
                new ResourceTranslationRepository(context)
                );

            var assembly = task.SyncResourceAssembly(ra);
            if (deleteBundles)
                task.SyncAllBundlesWithDeletions(assembly, bundles);
            else
                task.SyncSomeBundles(assembly, bundles);
            context.SaveChanges();

            task.CalculateAssemblyStatusFromBundles(assembly);
            context.SaveChanges();

            return task.Statistics;
        }