Exemple #1
0
        public dynamic GetAppInfo(int appId, int zoneId)
        {
            Log.Add($"get app info for app:{appId} and zone:{zoneId}");
            var currentApp = SxcAppForWebApi.AppBasedOnUserPermissions(zoneId, appId, UserInfo, Log);

            var zipExport = new ZipExport(zoneId, appId, currentApp.Folder, currentApp.PhysicalPath, Log);
            var cultCount = Env.ZoneMapper
                            .CulturesWithState(currentApp.Tenant.Id, currentApp.ZoneId)
                            .Count(c => c.Active);

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

            return(new
            {
                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 bool ExportForVersionControl(int appId, int zoneId, bool includeContentGroups, bool resetAppGuid)
        {
            Log.Add($"export for version control z#{zoneId}, a#{appId}, include:{includeContentGroups}, reset:{resetAppGuid}");
            EnsureUserIsAdmin();

            var currentApp = SxcAppForWebApi.AppBasedOnUserPermissions(zoneId, appId, UserInfo, Log);// AppWithRestrictedZoneChange(appId, zoneId);

            var zipExport = new ZipExport(zoneId, appId, currentApp.Folder, currentApp.PhysicalPath, Log);

            zipExport.ExportForSourceControl(includeContentGroups, resetAppGuid);

            return(true);
        }
        public bool ExportForVersionControl(int appId, int zoneId, bool includeContentGroups, bool resetAppGuid)
        {
            Log.Add($"export for version control z#{zoneId}, a#{appId}, include:{includeContentGroups}, reset:{resetAppGuid}");
            EnsureUserIsAdmin();

            // ReSharper disable once UnusedVariable
            var appWrapper = AppBasedOnUserPermissions(appId, zoneId);

            var zipExport = new ZipExport(zoneId, appId, appWrapper.App.Folder, appWrapper.App.PhysicalPath, Log);

            zipExport.ExportForSourceControl(includeContentGroups, resetAppGuid);

            return(true);
        }
        public HttpResponseMessage ExportApp(int appId, int zoneId, bool includeContentGroups, bool resetAppGuid)
        {
            EnsureUserIsAdmin();

            var appWrapper = new SxcAppWrapper(appId);
            var zipExport  = new ZipExport(zoneId, appId);

            var fileName = string.Format("2sxcApp_{0}_{1}.zip", appWrapper.GetNameWithoutSpecialChars(), appWrapper.GetVersion());

            using (var fileStream = zipExport.ExportApp(includeContentGroups, resetAppGuid))
            {
                var fileBytes = fileStream.ToArray();
                return(HttpResponseMessageHelper.GetAttachmentHttpResponseMessage(fileName, "application/octet-stream", new MemoryStream(fileBytes)));
            }
        }
        public bool ExportForVersionControl(int appId, int zoneId, bool includeContentGroups, bool resetAppGuid)
        {
            EnsureUserIsAdmin();

            // ReSharper disable once UnusedVariable
            var appWrapper = (UserInfo.IsSuperUser)
                ? new SxcAppWrapper(zoneId, appId)  // only super-user may switch to another zone for export
                : new SxcAppWrapper(appId);

            var zipExport = new ZipExport(zoneId, appId);

            zipExport.ExportForSourceControl(includeContentGroups, resetAppGuid);

            return(true);
        }
        public dynamic GetAppInfo(int appId, int zoneId)
        {
            var appWrapper = new SxcAppWrapper(appId);
            var zipExport  = new ZipExport(zoneId, appId);

            return(new
            {
                Name = appWrapper.App.Name,
                Guid = appWrapper.App.AppGuid,
                Version = appWrapper.GetVersion(),
                EntitiesCount = appWrapper.GetEntities().Count(),
                LanguagesCount = appWrapper.GetActiveLanguages().Count(),
                TemplatesCount = appWrapper.GetTemplates().Count(),
                HasRazorTemplates = appWrapper.GetRazorTemplates().Count() > 0,
                HasTokenTemplates = appWrapper.GetTokenTemplates().Count() > 0,
                FilesCount = zipExport.FileManager.AllFiles.Count(),
                TransferableFilesCount = zipExport.FileManager.AllTransferableFiles.Count()
            });
        }
        public HttpResponseMessage ExportApp(int appId, int zoneId, bool includeContentGroups, bool resetAppGuid)
        {
            EnsureUserIsAdmin();

            var appWrapper = (UserInfo.IsSuperUser)
                ? new SxcAppWrapper(zoneId, appId)  // only super-user may switch to another zone for export
                : new SxcAppWrapper(appId);

            var zipExport = new ZipExport(zoneId, appId);
            var addOnWhenContainingContent = includeContentGroups ? "_withPageContent_" + DateTime.Now.ToString("yyyy-MM-ddTHHmm") : "";

            var fileName =
                $"2sxcApp_{appWrapper.GetNameWithoutSpecialChars()}_{appWrapper.GetVersion()}{addOnWhenContainingContent}.zip";

            using (var fileStream = zipExport.ExportApp(includeContentGroups, resetAppGuid))
            {
                var fileBytes = fileStream.ToArray();
                return(HttpResponseMessageHelper.GetAttachmentHttpResponseMessage(fileName, "application/octet-stream", new MemoryStream(fileBytes)));
            }
        }
        public HttpResponseMessage ExportApp(int appId, int zoneId, bool includeContentGroups, bool resetAppGuid)
        {
            Log.Add($"export app z#{zoneId}, a#{appId}, incl:{includeContentGroups}, reset:{resetAppGuid}");
            EnsureUserIsAdmin(); // must happen inside here, as it's opened as a new browser window, so not all headers exist

            var appWrapper = AppBasedOnUserPermissions(appId, zoneId);

            var zipExport = new ZipExport(zoneId, appId, appWrapper.App.Folder, appWrapper.App.PhysicalPath, Log);
            var addOnWhenContainingContent = includeContentGroups ? "_withPageContent_" + DateTime.Now.ToString("yyyy-MM-ddTHHmm") : "";

            var fileName =
                $"2sxcApp_{appWrapper.GetNameWithoutSpecialChars()}_{appWrapper.GetVersion()}{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(HttpResponseMessageHelper.GetAttachmentHttpResponseMessage(fileName, "application/octet-stream", new MemoryStream(fileBytes)));
            }
        }
        public dynamic GetAppInfo(int appId, int zoneId)
        {
            var appWrapper = (UserInfo.IsSuperUser)
                ? new SxcAppWrapper(zoneId, appId)  // only super-user may switch to another zone for export
                : new SxcAppWrapper(appId);

            var zipExport = new ZipExport(zoneId, appId);

            return(new
            {
                appWrapper.App.Name,
                Guid = appWrapper.App.AppGuid,
                Version = appWrapper.GetVersion(),
                EntitiesCount = appWrapper.GetEntities().Count,
                LanguagesCount = appWrapper.GetActiveLanguages().Count(),
                TemplatesCount = appWrapper.GetTemplates().Count(),
                HasRazorTemplates = appWrapper.GetRazorTemplates().Any(),
                HasTokenTemplates = appWrapper.GetTokenTemplates().Any(),
                FilesCount = zipExport.FileManager.AllFiles.Count(),
                TransferableFilesCount = zipExport.FileManager.AllTransferableFiles.Count()
            });
        }
        public dynamic GetAppInfo(int appId, int zoneId)
        {
            Log.Add($"get app info for app:{appId} and zone:{zoneId}");
            var appWrapper = AppBasedOnUserPermissions(appId, zoneId);

            var zipExport = new ZipExport(zoneId, appId, appWrapper.App.Folder, appWrapper.App.PhysicalPath, Log);
            var cultCount = Env.ZoneMapper
                            .CulturesWithState(appWrapper.App.OwnerPortalSettings.PortalId, appWrapper.App.ZoneId)
                            .Count(c => c.Active);

            return(new
            {
                appWrapper.App.Name,
                Guid = appWrapper.App.AppGuid,
                Version = appWrapper.GetVersion(),
                EntitiesCount = appWrapper.GetEntities().Count,
                LanguagesCount = cultCount,
                TemplatesCount = appWrapper.GetTemplates().Count(),
                HasRazorTemplates = appWrapper.GetRazorTemplates().Any(),
                HasTokenTemplates = appWrapper.GetTokenTemplates().Any(),
                FilesCount = zipExport.FileManager.AllFiles.Count(),
                TransferableFilesCount = zipExport.FileManager.AllTransferableFiles.Count()
            });
        }
Exemple #11
0
 public ExportApp(IZoneMapper zoneMapper, ZipExport zipExport) : base("Bck.Export")
 {
     _zoneMapper = zoneMapper;
     _zipExport  = zipExport;
 }
Exemple #12
0
 public ExportApp(IZoneMapper zoneMapper, ZipExport zipExport, CmsRuntime cmsRuntime) : base("Bck.Export")
 {
     _zoneMapper = zoneMapper;
     _zipExport  = zipExport;
     _cmsRuntime = cmsRuntime;
 }