public MultistepActionStepResult Step(int step) { var result = new MultistepActionStepResult(); SiteService.CopySiteSettings(SiteId, NewSiteId.Value); return(result); }
public MultistepActionStepResult Step(int step) { var result = new MultistepActionStepResult(); var templateNumber = step * ItemsPerStep + 1; result.ProcessedItemsCount = PageTemplateService.CopySiteTemplates(SiteId, NewSiteId.Value, templateNumber); return(result); }
public MultistepActionStepResult Step(int step) { var result = new MultistepActionStepResult(); ContentService.CopyContentLinks(SiteId, NewSiteId.Value); result.ProcessedItemsCount = Count; return(result); }
public MultistepActionStepResult Step(int step) { var settings = HttpContext.Session.GetValue <ImportSettings>(HttpContextSession.ImportSettingsSessionKey); Ensure.NotNull(settings); var reader = new CsvReader(SiteId, ContentId, settings); var result = new MultistepActionStepResult(); using (var ts = QPConfiguration.CreateTransactionScope(IsolationLevel.ReadCommitted)) { using (new QPConnectionScope()) { try { reader.Process(step, ItemsPerStep, out var processedItemsCount); var lastStep = step * ItemsPerStep >= reader.ArticleCount - ItemsPerStep; if (lastStep) { ContentRepository.UpdateContentModification(ContentId); reader.PostUpdateM2MRelationAndO2MRelationFields(); } settings = HttpContext.Session.GetValue <ImportSettings>(HttpContextSession.ImportSettingsSessionKey); var logData = new ImportArticlesLogData() { Id = settings.Id, InsertedArticleIds = settings.InsertedArticleIds.ToArray(), UpdatedArticleIds = settings.UpdatedArticleIds.ToArray(), ImportAction = (CsvImportMode)settings.ImportAction }; ImportLogger.Trace() .Message("Import articles step: {step}.", step) .Property("result", logData) .Property("customerCode", QPContext.CurrentCustomerCode) .Write(); result.ProcessedItemsCount = processedItemsCount; result.TraceResult = reader.GetTraceResult(); result.AdditionalInfo = $"{MultistepActionStrings.InsertedArticles}: {settings.InsertedArticleIds.Count}; {MultistepActionStrings.UpdatedArticles}: {settings.UpdatedArticleIds.Count}."; } catch (Exception ex) { throw new ImportException(string.Format(ImportStrings.ImportInterrupted, ex.Message, reader.LastProcessed), ex, settings); } } ts.Complete(); } return(result); }
public MultistepActionStepResult Step(int step) { var result = new MultistepActionStepResult(); var startFrom = step * ItemsPerStep + 1; var endOn = startFrom - 1 + ItemsPerStep; var articlesLinks = ContentService.CopyContentsData(CopyFromSiteId, NewSiteId.Value, ContentsToCopy, startFrom, endOn); WriteToTempFile(articlesLinks); result.ProcessedItemsCount = articlesLinks.Count(); return(result); }
public MultistepActionStepResult Step(int step) { var result = new MultistepActionStepResult(); var sourceSite = SiteRepository.GetById(SiteId); var destinationSite = SiteRepository.GetById(NewSiteId.Value); var helper = new CopySiteFilesHelper(sourceSite, destinationSite); helper.CopyDirectories(); result.ProcessedItemsCount = helper.CopyFiles(step); return(result); }
public MultistepActionStepResult Step(int step) { var result = new MultistepActionStepResult(); var contentsToInsert = VirtualContentService.CopyVirtualContents(SiteId, NewSiteId.Value); var errors = VirtualContentService.UpdateVirtualContents(SiteId, NewSiteId.Value, contentsToInsert); if (!string.IsNullOrEmpty(errors)) { result.AdditionalInfo = $"{ContentStrings.ErrorsOnCopyingVirtualContents}{errors}"; } return(result); }
public MultistepActionStepResult Step(int step) { var prms = HttpContext.Session.GetValue <CopySiteSettings>(HttpContextSession.CopySiteServiceSettings); var result = new MultistepActionStepResult(); var skip = step * ItemsPerStep; var xDocument = XDocument.Load(prms.PathForFileWithLinks); var items = xDocument.Elements().Elements().Skip(skip).Take(ItemsPerStep).ToArray(); ContentService.CopyArticlesLinks(SourceSiteId, DestinationSiteId, string.Concat(items.AsEnumerable())); result.ProcessedItemsCount = items.Count(); return(result); }
public MultistepActionStepResult Step(int step) { var result = new MultistepActionStepResult(); var startFrom = step * ItemsPerStep + 1; var endOn = startFrom - 1 + ItemsPerStep; result.ProcessedItemsCount = ContentService.CopyContents(SiteId, NewSiteId.Value, startFrom, endOn); ContentsCount = SiteRepository.GetSiteRealContentCount(SiteId); if (endOn >= ContentsCount) { ContentService.UpdateContents(SiteId, NewSiteId.Value); } return(result); }
public MultistepActionStepResult Step(int step) { var settings = HttpContext.Current.Session[HttpContextSession.ImportSettingsSessionKey] as ImportSettings; Ensure.NotNull(settings); var reader = new CsvReader(SiteId, ContentId, settings); var result = new MultistepActionStepResult(); using (var ts = new TransactionScope()) { using (new QPConnectionScope()) { try { reader.Process(step, ItemsPerStep, out var processedItemsCount); if (step * ItemsPerStep >= reader.ArticleCount - ItemsPerStep) { reader.PostUpdateM2MRelationAndO2MRelationFields(); } var logData = new { settings.Id, ImportAction = (CsvImportMode)settings.ImportAction, Inserted = settings.InsertedArticleIds.Count, Updated = settings.UpdatedArticleIds.Count }; _importLogger.Trace($"Import articles step: {step}. Settings: {logData.ToJsonLog()}"); result.ProcessedItemsCount = processedItemsCount; result.AdditionalInfo = $"{MultistepActionStrings.InsertedArticles}: {settings.InsertedArticleIds.Count}; {MultistepActionStrings.UpdatedArticles}: {settings.UpdatedArticleIds.Count}."; } catch (Exception ex) { throw new ImportException(string.Format(ImportStrings.ImportInterrupted, ex.Message, reader.LastProcessed), ex, settings); } } ts.Complete(); } return(result); }
public MultistepActionStepResult Step(int step) { var content = ContentRepository.GetById(ContentId); var settings = HttpContext.Current.Session[HttpContextSession.ExportSettingsSessionKey] as ExportSettings; Ensure.NotNull(content, string.Format(ContentStrings.ContentNotFound, ContentId)); Ensure.NotNull(settings); var csv = new CsvWriter(SiteId, ContentId, Ids, ExtensionContents, settings); var result = new MultistepActionStepResult { ProcessedItemsCount = csv.Write(step, ItemsPerStep) }; if (csv.CsvReady) { result.AdditionalInfo = csv.CopyFileToTempSiteLiveDirectory(); } return(result); }
public MultistepActionStepResult Step(int step) { var prms = (CopySiteSettings)HttpContext.Current.Session[HttpContextSession.CopySiteServiceSettings]; var result = new MultistepActionStepResult(); var startFrom = step * ItemsPerStep + 1; var xDocument = XDocument.Load(prms.PathForFileWithLinks); var elements = string.Concat(xDocument.Elements().Elements().Skip(startFrom).Take(ItemsPerStep)); ContentService.UpdateArticlesLinks(SourceSiteId, DestinationSiteId, elements); result.ProcessedItemsCount = xDocument.Elements().Elements().Skip(startFrom).Take(ItemsPerStep).Count(); var siteArticlesCount = xDocument.Elements().Elements().Count(); if (startFrom >= siteArticlesCount - ItemsPerStep) { ContentService.FillLinkTables(SourceSiteId, DestinationSiteId); File.Delete(prms.PathForFileWithLinks); } return(result); }
public MultistepActionStepResult Step(int step) { var content = ContentRepository.GetById(ContentId); var settings = HttpContext.Session.GetValue <ExportSettings>(HttpContextSession.ExportSettingsSessionKey); Ensure.NotNull(content, string.Format(ContentStrings.ContentNotFound, ContentId)); Ensure.NotNull(settings); var extContents = ExtensionContentIds != null && ExtensionContentIds.Any() ? ContentRepository.GetList(ExtensionContentIds) : new Content[] { }; var csv = new CsvWriter(SiteId, ContentId, Ids, extContents, settings); var result = new MultistepActionStepResult { ProcessedItemsCount = csv.Write(step, ItemsPerStep) }; HttpContext.Session.SetValue(HttpContextSession.ExportSettingsSessionKey, settings); if (csv.CsvReady) { result.AdditionalInfo = csv.CopyFileToTempUploadDirectory(); } return(result); }