Exemple #1
0
        public AppExportInfoDto GetAppInfo(int appId, int zoneId)
        {
            Log.Add($"get app info for app:{appId} and zone:{zoneId}");
            var contextZoneId = _zoneMapper.GetZoneId(_tenantId);
            var currentApp    = ImpExpHelpers.GetAppAndCheckZoneSwitchPermissions(zoneId, appId, _user, contextZoneId, Log);

            var zipExport = Factory.Resolve <ZipExport>().Init(zoneId, appId, currentApp.Folder, currentApp.PhysicalPath, Log);
            var cultCount = _zoneMapper
                            .CulturesWithState(currentApp.Tenant.Id, currentApp.ZoneId)
                            .Count(c => c.Active);

            var cms = new CmsRuntime(currentApp, Log, true, false);

            return(new AppExportInfoDto
            {
                Name = currentApp.Name,
                Guid = currentApp.AppGuid,
                Version = currentApp.VersionSafe(),
                EntitiesCount = cms.Entities.All.Count(),
                LanguagesCount = cultCount,
                TemplatesCount = cms.Views.GetAll().Count(),
                HasRazorTemplates = cms.Views.GetRazor().Any(),
                HasTokenTemplates = cms.Views.GetToken().Any(),
                FilesCount = zipExport.FileManager.AllFiles.Count(),
                TransferableFilesCount = zipExport.FileManager.AllTransferableFiles.Count()
            });
        }
Exemple #2
0
 public ResetApp(IZoneMapper zoneMapper,
                 Lazy <XmlImportWithFiles> xmlImportWithFilesLazy,
                 ImpExpHelpers impExpHelpers,
                 CmsZones cmsZones) : base("Bck.Export")
 {
     _zoneMapper             = zoneMapper;
     _xmlImportWithFilesLazy = xmlImportWithFilesLazy;
     _impExpHelpers          = impExpHelpers;
     _cmsZones = cmsZones;
 }
Exemple #3
0
        public bool SaveDataForVersionControl(int appId, int zoneId, bool includeContentGroups, bool resetAppGuid)
        {
            Log.Add($"export for version control z#{zoneId}, a#{appId}, include:{includeContentGroups}, reset:{resetAppGuid}");
            SecurityHelpers.ThrowIfNotAdmin(_user); // must happen inside here, as it's opened as a new browser window, so not all headers exist

            var contextZoneId = _zoneMapper.GetZoneId(_tenantId);
            var currentApp    = ImpExpHelpers.GetAppAndCheckZoneSwitchPermissions(zoneId, appId, _user, contextZoneId, Log);

            var zipExport = _zipExport.Init(zoneId, appId, currentApp.Folder, currentApp.PhysicalPath, Log);

            zipExport.ExportForSourceControl(includeContentGroups, resetAppGuid);

            return(true);
        }
Exemple #4
0
        public HttpResponseMessage Export(int appId, int zoneId, string contentTypeIdsString, string entityIdsString, string templateIdsString)
        {
            Log.Add($"export content z#{zoneId}, a#{appId}, ids:{entityIdsString}, templId:{templateIdsString}");
            SecurityHelpers.ThrowIfNotAdmin(_user); // must happen inside here, as it's opened as a new browser window, so not all headers exist

            var contextZoneId = _zoneMapper.GetZoneId(_tenantId);
            var currentApp    = ImpExpHelpers.GetAppAndCheckZoneSwitchPermissions(zoneId, appId, _user, contextZoneId, Log);
            var appRuntime    = new AppRuntime(currentApp, true, Log);

            var fileName = $"2sxcContentExport_{currentApp.NameWithoutSpecialChars()}_{currentApp.VersionSafe()}.xml";
            var fileXml  = _xmlExporter.Init(zoneId, appId, appRuntime, false,
                                             contentTypeIdsString?.Split(';') ?? new string[0],
                                             entityIdsString?.Split(';') ?? new string[0],
                                             Log
                                             ).GenerateNiceXml();

            return(HttpFileHelper.GetAttachmentHttpResponseMessage(fileName, "text/xml", fileXml));
        }
Exemple #5
0
        public ExportPartsOverviewDto PreExportSummary(int appId, int zoneId, string scope)
        {
            Log.Add($"get content info for z#{zoneId}, a#{appId}, scope:{scope} super?:{_user.IsSuperUser}");
            var contextZoneId = _zoneMapper.GetZoneId(_tenantId);
            var currentApp    = ImpExpHelpers.GetAppAndCheckZoneSwitchPermissions(zoneId, appId, _user, contextZoneId, Log);

            var cms          = new CmsRuntime(currentApp, Log, true, false);
            var contentTypes = cms.ContentTypes.FromScope(scope);
            var entities     = cms.Entities.All;
            var templates    = cms.Views.GetAll();

            return(new ExportPartsOverviewDto
            {
                ContentTypes = contentTypes.Select(c => new ExportPartsContentTypesDto
                {
                    Id = c.ContentTypeId,
                    Name = c.Name,
                    StaticName = c.StaticName,
                    Templates = templates.Where(t => t.ContentType == c.StaticName)
                                .Select(t => new IdNameDto
                    {
                        Id = t.Id,
                        Name = t.Name
                    }),
                    Entities = entities
                               .Where(e => e.Type.ContentTypeId == c.ContentTypeId)
                               .Select(e => new ExportPartsEntitiesDto
                    {
                        Title = e.GetBestTitle(),
                        Id = e.EntityId
                    })
                }),
                TemplatesWithoutContentTypes = templates
                                               .Where(t => !string.IsNullOrEmpty(t.ContentType))
                                               .Select(t => new IdNameDto
                {
                    Id = t.Id,
                    Name = t.Name
                })
            });
        }
Exemple #6
0
        public HttpResponseMessage Export(int appId, int zoneId, bool includeContentGroups, bool resetAppGuid)
        {
            Log.Add($"export app z#{zoneId}, a#{appId}, incl:{includeContentGroups}, reset:{resetAppGuid}");
            SecurityHelpers.ThrowIfNotAdmin(_user); // must happen inside here, as it's opened as a new browser window, so not all headers exist

            var contextZoneId = _zoneMapper.GetZoneId(_tenantId);
            var currentApp    = ImpExpHelpers.GetAppAndCheckZoneSwitchPermissions(zoneId, appId, _user, contextZoneId, Log);

            var zipExport = Factory.Resolve <ZipExport>().Init(zoneId, appId, currentApp.Folder, currentApp.PhysicalPath, Log);
            var addOnWhenContainingContent = includeContentGroups ? "_withPageContent_" + DateTime.Now.ToString("yyyy-MM-ddTHHmm") : "";

            var fileName =
                $"2sxcApp_{currentApp.NameWithoutSpecialChars()}_{currentApp.VersionSafe()}{addOnWhenContainingContent}.zip";

            Log.Add($"file name:{fileName}");
            using (var fileStream = zipExport.ExportApp(includeContentGroups, resetAppGuid))
            {
                var fileBytes = fileStream.ToArray();
                Log.Add("will stream so many bytes:" + fileBytes.Length);
                return(HttpFileHelper.GetAttachmentHttpResponseMessage(fileName, "application/octet-stream", new MemoryStream(fileBytes)));
            }
        }