Пример #1
0
        /// <summary>
        /// System ring init method - ran once at boot
        /// </summary>
        public static void Init()
        {
            HW.Init();
            //Thread.Sleep(500);
            Console.WriteLine("FileSystem service...");
            FSService.Init();
            Console.WriteLine("Filesystem: " + FSService.Active);
            if (FSService.Active == true)
            {
                for (int i = 1; i < SystemFunctions.IDEs.Length; i++)
                {
                    new DiskListing(i, SystemFunctions.IDEs[i]);
                }
                InstallService.Init();
            }

            SystemCalls MEFAPI = new SystemCalls();

            for (int i = 0; i < Kernel.Drivers.Count; i++)
            {
                if (Kernel.Drivers[i].Init())
                {
                    Console.WriteLine(Kernel.Drivers[i].Name + "' loaded sucessfully");
                }
                else
                {
                    Console.WriteLine("Failure loading module '" + Kernel.Drivers[i].Name + "'");
                    Console.ReadKey();
                }
            }
        }
        private async Task CheckNewVersion()
        {
            string         scripts = Path.Combine(Environment.CurrentDirectory, "Scripts");
            InstallService service = new InstallService(scripts);

            _vm.CurrentVersion = service.GetInstalledVersion(PackageName);
            _client            = new HmacAuthWebApiClient(Url, CdmId, ApiKey);

            try
            {
                UpdateInformation apiVersion = await _client.ReadAsync <UpdateInformation>(!string.IsNullOrWhiteSpace(_vm.CurrentVersion)?ConfigurationManager.AppSettings["api:downloadUrl"] + _vm.CurrentVersion + ConfigurationManager.AppSettings["api:downloadUrlMethod"] : ConfigurationManager.AppSettings["api:downloadUrlLatestUpdate"]);

                if (apiVersion == null || (!string.IsNullOrWhiteSpace(_vm.CurrentVersion) && new Version(apiVersion.Version) < new Version(_vm.CurrentVersion))) // when current version is disabled or unknown => the provided new version is lower than current one ...
                {
                    _vm.ApiVersion = new UpdateInformation {
                        Version = _vm.CurrentVersion
                    }
                }
                ;                                                                            // ... do like there is no new version => avoid impossible downgrade
                else
                {
                    _vm.ApiVersion = apiVersion;
                }
            }
            catch (Exception ex)
            {
                _logger.Error("CheckNewVersion() failed on ", ex);
            }
        }
Пример #3
0
 static void Main(string[] args)
 {
     try {
         if (args != null && args.Any(x => x == "/i"))
         {
             InstallService.Install(App.Config.AppName);
             return;
         }
         if (args != null && args.Any(x => x == "/s"))
         {
             InstallService.TryStopService(App.Config.AppName);
             return;
         }
         if (Environment.UserInteractive)
         {
             var app = new App();
             app.Run().Wait();
         }
         else
         {
             ServiceBase.Run(new Program());
         }
     }
     catch (Exception ex) {
         File.AppendAllText(Path.Combine("C:\\", "failedToStart.txt"), ex.ToString());
     }
 }
        public void DownloadAndInstall()
        {
            var manager  = DownloadManager.FromContext(this); //(DownloadManager)this.GetSystemService(Android.Content.Context.DownloadService);
            var iservice = new InstallService();

            Task.Run(async() => await iservice.DownloadAndInstall(manager));
        }
Пример #5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory,
                              InstallService installService)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            //动态压缩内容
            app.UseResponseCompression();

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();
            app.UseMvc();

            //NLog
            env.ConfigureNLog("nlog.config");
            LogManager.Configuration.Variables["connectionString"] = Configuration.GetConnectionString("DefaultConnection");

            //初始化系统菜单,及参数
            installService.Install();
        }
Пример #6
0
 protected virtual void CreateSite(Stream stream, SiteDefinition siteDefinition, ContentReference startPage)
 {
     EPiServer.Find.Cms.EventedIndexingSettings.Instance.EventedIndexingEnabled    = false;
     EPiServer.Find.Cms.EventedIndexingSettings.Instance.ScheduledPageQueueEnabled = false;
     InstallService.ImportEpiserverContent(stream, startPage, siteDefinition);
     EPiServer.Find.Cms.EventedIndexingSettings.Instance.EventedIndexingEnabled    = true;
     EPiServer.Find.Cms.EventedIndexingSettings.Instance.ScheduledPageQueueEnabled = true;
 }
Пример #7
0
 public InstallController(
     InstallService installService,
     IOptions <RequestLocalizationOptions> requestLocalizationOptions,
     IStringLocalizer <InstallController> l)
 {
     InstallService             = installService;
     RequestLocalizationOptions = requestLocalizationOptions;
     L = l;
 }
Пример #8
0
        private void InstallServiceCommandExecuted(object obj)
        {
            var w = new InstallService
            {
                ProjectConnectionString = ConnectionParameters == null ? null : ConnectionParameters.ConnectionString,
                Owner = View as Window
            };

            w.ShowDialog();
        }
Пример #9
0
 public override void OnActionExecuting(ActionExecutingContext context)
 {
     if (!InstallService.NeedToInstall())
     {
         context.Result = this.RedirectToAction("Index", "Home");
     }
     else
     {
         base.OnActionExecuting(context);
     }
 }
Пример #10
0
        protected virtual void CreateCatalog(CloudBlockBlob file)
        {
            var name         = file.Name.Substring(file.Name.LastIndexOf('/') == 0 ? 0 : file.Name.LastIndexOf('/') + 1);
            var path         = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"..\appData\Imports\Catalog");
            var zipFile      = Path.Combine(path, name);
            var zipDirectory = new DirectoryInfo(Path.Combine(path, name.Replace(".zip", "")));

            if (zipDirectory.Exists)
            {
                zipDirectory.Delete(true);
            }

            zipDirectory.Create();

            file.DownloadToFile(zipFile, FileMode.Create);
            System.IO.Compression.ZipFile.ExtractToDirectory(zipFile, zipDirectory.FullName);

            var assests = zipDirectory.GetFiles("ProductAssets*")
                          .FirstOrDefault();

            var catalogXml = zipDirectory.GetFiles("*.xml")
                             .FirstOrDefault();

            if (catalogXml == null || assests == null)
            {
                throw new Exception("Zip does not contain catalog.xml or ProductAssets.episerverdata");
            }

            var catalogFolder = ContentRepository.GetChildren <ContentFolder>(ContentReference.GlobalBlockFolder)
                                .FirstOrDefault(_ => _.Name.Equals("Catalogs"));

            if (catalogFolder == null)
            {
                catalogFolder      = ContentRepository.GetDefault <ContentFolder>(ContentReference.GlobalBlockFolder);
                catalogFolder.Name = "Catalogs";
                ContentRepository.Save(catalogFolder, EPiServer.DataAccess.SaveAction.Publish, EPiServer.Security.AccessLevel.NoAccess);
            }

            using (var assetStream = assests.OpenRead())
            {
                EPiServer.Find.Cms.EventedIndexingSettings.Instance.EventedIndexingEnabled    = false;
                EPiServer.Find.Cms.EventedIndexingSettings.Instance.ScheduledPageQueueEnabled = false;
                InstallService.ImportEpiserverContent(assetStream, catalogFolder.ContentLink);
                EPiServer.Find.Cms.EventedIndexingSettings.Instance.EventedIndexingEnabled    = true;
                EPiServer.Find.Cms.EventedIndexingSettings.Instance.ScheduledPageQueueEnabled = true;
            }

            using (var catalogStream = catalogXml.OpenRead())
            {
                InstallService.ImportCatalog(catalogStream);
            }
        }
Пример #11
0
        public ActionResult ExportSite(ConfigurationViewModel model)
        {
            if (model.LocalSelectedSiteName.IsNullOrEmpty())
            {
                model = GetConfigurationViewModel();
                ModelState.AddModelError(nameof(model.LocalSelectedSiteName), "Site is required.");
                return(View("Index", model));
            }

            var site = SiteDefinitionRepository.List()
                       .FirstOrDefault(_ => _.Name.Equals(model.LocalSelectedSiteName));

            if (site == null)
            {
                model = GetConfigurationViewModel();
                ModelState.AddModelError(nameof(model.LocalSelectedSiteName), "Site is required.");
                return(View("Index", model));
            }

            if (model.SiteExportLocation.Equals("Remote", StringComparison.InvariantCultureIgnoreCase) && model.LocalSiteName.IsNullOrEmpty())
            {
                model = GetConfigurationViewModel();
                ModelState.AddModelError(nameof(model.LocalSiteName), "Blob Storage Site name is required.");
                return(View("Index", model));
            }

            var fileName = model.LocalSiteName;

            if (fileName.IsNullOrEmpty())
            {
                fileName = $"{site.Name}.episerverdata";
            }

            if (!fileName.EndsWith(".episerverdata", StringComparison.InvariantCultureIgnoreCase))
            {
                fileName += ".episerverdata";
            }

            if (model.SiteExportLocation.Equals("Remote", StringComparison.InvariantCultureIgnoreCase))
            {
                using (var exportStream = InstallService.ExportEpiserverContent(site.StartPage, ContentExport.ExportPages | ContentExport.ExportVisitorGroups))
                {
                    StorageService.Add($"Sites/{fileName}", exportStream, exportStream.Length);
                    return(RedirectToAction("Index"));
                }
            }

            var stream = InstallService.ExportEpiserverContent(site.StartPage, ContentExport.ExportPages | ContentExport.ExportVisitorGroups);

            return(File(stream, "application/octet-stream", fileName));
        }
Пример #12
0
        public MainViewModel()
        {
            _discoveryService        = new DiscoveryService();
            _discoveryService.Error += OnServiceError;

            _downloadService        = new DownloadService();
            _downloadService.Error += OnServiceError;

            _installService        = new InstallService();
            _installService.Error += OnServiceError;

            InitLog();
            InitPorts();
            InitVersions();
        }
Пример #13
0
 public InstallerForm(PluginPackageInfo pluginPackageInfo, Logger logger)
     : this()
 {
     _logger = logger;
     try
     {
         _pluginPackageInfo    = pluginPackageInfo;
         _studioVersionService = new StudioVersionService();
         _installService       = new InstallService(_pluginPackageInfo);
     }
     catch (Exception exception)
     {
         _logger.Error(exception, "Error constructing installer window", null);
         throw;
     }
 }
Пример #14
0
        public MainViewModel()
        {
            _logLock = new object();

            _discoveryService        = new DiscoveryService();
            _discoveryService.Error += OnServiceError;

            _downloadService        = new DownloadService();
            _downloadService.Error += OnServiceError;

            _installService        = new InstallService();
            _installService.Error += OnServiceError;

            IsBusy = true;
            InitLog();
            InitPorts();
            InitVersions();
            IsBusy = false;
        }
Пример #15
0
        private void CheckForProcess(PluginPackageInfo pluginToUninstall, int rowIndex)
        {
            _installService = new InstallService(pluginToUninstall);

            var processes = _installService.GetStudioProcesses();

            if (processes.Count <= 0)
            {
                _uninstallService.UninstallPlugin(pluginToUninstall);
                installedPluginListView.RemoveObject(pluginToUninstall);
                _installedPlugins.RemoveRange(rowIndex, 1);
            }
            else
            {
                using (var processesForm = new Processes(processes))
                {
                    processesForm.ShowDialog();
                }
            }
        }
Пример #16
0
        static async Task Main(string[] args)
        {
            UpdateService  updateService  = new UpdateService();
            InstallService installService = new InstallService();
            //ProcessService processService = new ProcessService(Path.Combine(Environment.CurrentDirectory, ""));

            GithubReleaseRes info = await updateService.GetLatestVerInfo("https://api.github.com/repos/soyCracker/DelegationExporter/releases/latest");

            LogUtil.Debug("tag_name:" + info.TagName);
            LogUtil.Debug("download url:" + info.Assets[0].AssetBrowserDownloadUrl);
            LogUtil.Debug("file name:" + info.Assets[0].AssetName);

            //LogUtil.Debug(Environment.CurrentDirectory);
            //LogUtil.Debug(Path.GetFullPath(BaseConstant.VERSION_FILE_NAME));

            if (updateService.IsHasNewVer(info, BaseConstant.VERSION_FILE_NAME))
            {
                LogUtil.Debug("Has new ver, download start");
                if (await updateService.DownloadNewVer(info, BaseConstant.DOWNLOAD_TEMP_FOLDER, info.Assets[0].AssetName))
                {
                    updateService.SaveVerInfo(info, BaseConstant.DOWNLOAD_TEMP_FOLDER, BaseConstant.VERSION_FILE_NAME);
                    LogUtil.Debug("Download Finish");

                    /*while(processService.IsProcessRun())
                     * {
                     *  processService.StopProcess();
                     *  Thread.Sleep(1000);
                     * }*/

                    string zipPath = Path.Combine(BaseConstant.DOWNLOAD_TEMP_FOLDER, info.Assets[0].AssetName);
                    installService.DeleteCurrent(installService.GetZipEntries(zipPath));
                    installService.Inastall(zipPath, Environment.CurrentDirectory);
                }
            }

            /*if(!processService.IsProcessRun())
             * {
             *  processService.StartProcess();
             * }*/
        }
Пример #17
0
        public async Task <IActionResult> Index([FromForm] InstallModel model)
        {
            if (!ModelState.IsValid)
            {
                var vm = this.CreateViewModel(model);
                vm.ErrorMessage = L["Invalid request"];
                return(this.View(vm));
            }

            var result = await InstallService.TryInstallAsync(model);

            if (result.Success)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                var vm = this.CreateViewModel(model);
                vm.ErrorMessage = result.ErrorMessage;
                return(this.View(vm));
            }
        }
Пример #18
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env,
                              InstallService installService)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            //NLog 数据库连接
            LogManager.Configuration.FindTargetByName <DatabaseTarget>("db").ConnectionString
                = Configuration.GetConnectionString("DefaultConnection");

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");

                endpoints.MapControllerRoute(
                    name: "areas",
                    pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
            });

            //初始化系统菜单,及参数
            installService.Install();
        }
Пример #19
0
        public async Task <IActionResult> Index([FromServices] InstallService installService, int page = 1)
        {
            if (installService.NeedToInstall())
            {
                return(RedirectToAction("Index", "Install"));
            }

            var pageSize  = SettingModel.TopicsPerPage;
            var topicList = await TopicService.QueryNotTrash(page, pageSize, Core.Enums.TopicStatus.Published, null);

            var vm = new IndexPageViewModel
            {
                TopicList = new TopicListModel
                {
                    Data      = topicList.Data,
                    PageIndex = page,
                    PageSize  = pageSize,
                    Total     = topicList.Total
                }
            };

            return(View(vm));
        }
Пример #20
0
        protected virtual void CreateCatalog(HttpPostedFileBase file)
        {
            if (file == null || file.InputStream == null)
            {
                throw new Exception("File is required");
            }
            var name         = file.FileName.Substring(file.FileName.LastIndexOf("\\") == 0 ? 0 : file.FileName.LastIndexOf("\\") + 1);
            var path         = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"..\appData\Imports\Catalog");
            var zipFile      = Path.Combine(path, name);
            var zipDirectory = new DirectoryInfo(Path.Combine(path, name.Replace(".zip", "")));

            if (zipDirectory.Exists)
            {
                zipDirectory.Delete(true);
            }

            zipDirectory.Create();

            var zipInputStream = new ZipFile(file.InputStream);

            zipInputStream.IsStreamOwner = false;
            foreach (ZipEntry zipEntry in zipInputStream)
            {
                if (!zipEntry.IsFile)
                {
                    continue;
                }

                var entryFileName = zipEntry.Name;
                var zipStream     = zipInputStream.GetInputStream(zipEntry);
                using (var fs = new FileStream(Path.Combine(zipDirectory.FullName, entryFileName), FileMode.Create, FileAccess.ReadWrite))
                {
                    zipStream.CopyTo(fs);
                }
            }


            var assests = zipDirectory.GetFiles("ProductAssets*")
                          .FirstOrDefault();

            var catalogXml = zipDirectory.GetFiles("*.xml")
                             .FirstOrDefault();

            if (catalogXml == null || assests == null)
            {
                throw new Exception("Zip does not contain catalog.xml or ProductAssets.episerverdata");
            }

            var catalogFolder = ContentRepository.GetChildren <ContentFolder>(ContentReference.GlobalBlockFolder)
                                .FirstOrDefault(_ => _.Name.Equals("Catalogs"));

            if (catalogFolder == null)
            {
                catalogFolder      = ContentRepository.GetDefault <ContentFolder>(ContentReference.GlobalBlockFolder);
                catalogFolder.Name = "Catalogs";
                ContentRepository.Save(catalogFolder, EPiServer.DataAccess.SaveAction.Publish, EPiServer.Security.AccessLevel.NoAccess);
            }

            EPiServer.Find.Cms.EventedIndexingSettings.Instance.EventedIndexingEnabled    = false;
            EPiServer.Find.Cms.EventedIndexingSettings.Instance.ScheduledPageQueueEnabled = false;
            InstallService.ImportEpiserverContent(assests.OpenRead(), catalogFolder.ContentLink);
            InstallService.ImportCatalog(catalogXml.OpenRead());
            EPiServer.Find.Cms.EventedIndexingSettings.Instance.EventedIndexingEnabled    = true;
            EPiServer.Find.Cms.EventedIndexingSettings.Instance.ScheduledPageQueueEnabled = true;
        }
Пример #21
0
 private void CopyAllFiles()
 {
     InstallService.CopyAllFiles();
 }
Пример #22
0
 private bool CopyPrimaryFiles()
 {
     return(InstallService.CopyPrimaryFiles());
 }
Пример #23
0
 private bool CopySecondaryFiles()
 {
     return(InstallService.CopySecondaryFiles());
 }
Пример #24
0
 private bool ShowFormatWarning()
 {
     return(InstallService.ShowFormatWarning());
 }
        private async Task DoInstall(IProgress <int> progress)
        {
            _logger.Info("Lancement de l'installation");

            string saveFolder        = ConfigurationManager.AppSettings["windowsApp:downloadFolder"];
            string myDocuments       = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string savePath          = Path.Combine(myDocuments, saveFolder);
            string userProfileFolder = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);

            try
            {
                progress.Report(0);
                string applicationDataFolder = Path.Combine(userProfileFolder,
                                                            ConfigurationManager.AppSettings["windowsApp:pathToBackup"]);
                string applicationDataZip = Path.Combine(myDocuments,
                                                         ConfigurationManager.AppSettings["windowsApp:backupDestination"]);

                progress.Report(10);

                string folder = Path.GetDirectoryName(applicationDataZip);
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }

                if (Directory.Exists(savePath))
                {
                    Directory.Delete(savePath, true);
                }

                Directory.CreateDirectory(savePath);

                string         scripts = Path.Combine(Environment.CurrentDirectory, "Scripts");
                InstallService service = new InstallService(scripts);

                progress.Report(20);

                if (service.IsLaunched())
                {
                    MessageBoxResult result = MessageBox.Show(
                        string.Format(
                            @"L'application {0} est en cours d'exécution. Voulez-vous continuer ?
En cliquant sur Oui, {0} sera fermé automatiquement, assurez-vous préalablement que votre travail ait été sauvegardé.",
                            service.PackageName),
                        "Exécution en cours", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);

                    if (result == MessageBoxResult.No)
                    {
                        progress.Report(-1);
                        return;
                    }

                    service.StopApplicationProcesses();
                }

                progress.Report(30);

                if (Directory.Exists(applicationDataFolder))
                {
                    service.BackupData(applicationDataFolder, applicationDataZip);
                }

                bool hasValidLicence = false;

                progress.Report(40);

                try
                {
                    hasValidLicence = service.HasLicence();
                }
                catch (Exception ex)
                {
                    _logger.Warn("HasLicence() failed on next error", ex);
                }

                progress.Report(50);
                if (!hasValidLicence)
                {
                    service.RegisterLicense();
                }

                progress.Report(60);

                string downloadedFile = await service.DownloadASync(_client, _vm.ApiVersion.Version, savePath);

                progress.Report(70);

                service.Configure();

                progress.Report(80);

                if (downloadedFile != null)
                {
                    UnzipAndSetFilesPath(downloadedFile);
                }

                progress.Report(85);

                service.RegisterCertificate(_certifPath);

                progress.Report(90);

                service.InstallPackage(_appxPath);

                progress.Report(100);

                MessageBox.Show("Installation Terminée", "Installation", MessageBoxButton.OK,
                                MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                _exception = ex;
                _logger.Error(ex);

                MessageBox.Show(@"Une erreur s'est produite lors de l'installation." +
                                "Consultez le log d'erreurs pour plus d'informations. " + _exception.Message + "",
                                _exception.Message, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                //Directory.Delete(savePath, true);

                if (_exception != null)
                {
                    StatusTextBlock.Text    = "Problème ...";
                    Bar.Value               = 0;
                    InstallButton.IsEnabled = true;

                    _logger.Error("Erreur lors de l'installation", _exception);

                    MessageBox.Show(
                        @"Une erreur s'est produite lors de l'installation.
Consultez le log d'erreurs pour plus d'informations. " + _exception.Message + "", _exception.Message, MessageBoxButton.OK, MessageBoxImage.Error);
                }

                _logger.Info("Fin de l'installation");
            }
        }
Пример #26
0
        public ActionResult ExportCatalog(ConfigurationViewModel model)
        {
            if (model.LocalSelectedCatalogName.IsNullOrEmpty())
            {
                model = GetConfigurationViewModel();
                ModelState.AddModelError(nameof(model.LocalSelectedCatalogName), "Catalog is required.");
                return(View("Index", model));
            }

            if (model.MediaFolder.IsNullOrEmpty())
            {
                model = GetConfigurationViewModel();
                ModelState.AddModelError(nameof(model.MediaFolder), "Media folder is required.");
                return(View("Index", model));
            }

            var catalog = ContentRepository.GetChildren <CatalogContent>(ReferenceConverter.GetRootLink())
                          .FirstOrDefault(_ => _.Name.Equals(model.LocalSelectedCatalogName));

            if (catalog == null)
            {
                model = GetConfigurationViewModel();
                ModelState.AddModelError(nameof(model.LocalSelectedCatalogName), "Catalog is required.");
                return(View("Index", model));
            }

            var mediaFolder = ContentRepository.Get <ContentFolder>(ContentReference.Parse(model.MediaFolder));

            if (mediaFolder == null)
            {
                model = GetConfigurationViewModel();
                ModelState.AddModelError(nameof(model.MediaFolder), "Media folder is required.");
                return(View("Index", model));
            }

            if (model.CatalogExportLocation.Equals("Remote", StringComparison.InvariantCultureIgnoreCase) && model.LocalCatalogName.IsNullOrEmpty())
            {
                model = GetConfigurationViewModel();
                ModelState.AddModelError(nameof(model.LocalCatalogName), "Blob Storage Catalog name is required.");
                return(View("Index", model));
            }

            using (var stream = new MemoryStream())
            {
                _catalogImportExport.Export(model.LocalSelectedCatalogName, stream, "");
                stream.Position = 0;

                var document = XDocument.Load(stream);
                document.Element("Catalogs").Element("MetaDataScheme").ReplaceWith(GetMetaDataScheme());
                document.Element("Catalogs").Element("Dictionaries").ReplaceWith(GetDictionaries());


                var newStream = new MemoryStream();
                var writer    = XmlWriter.Create(newStream);
                document.Save(writer);
                writer.Close();
                newStream.Position = 0;
                var media = InstallService.ExportEpiserverContent(mediaFolder.ContentLink, ContentExport.ExportPages);

                var zip = CreateArchiveStream(new Dictionary <string, Stream>()
                {
                    { "Catalog.xml", newStream },
                    { "ProductAssets.episerverdata", media }
                });

                var zipName = model.LocalCatalogName.IsNullOrEmpty() ? model.LocalSelectedCatalogName : model.LocalCatalogName;
                if (!zipName.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase))
                {
                    zipName += ".zip";
                }

                if (model.CatalogExportLocation.Equals("Remote", StringComparison.InvariantCultureIgnoreCase))
                {
                    StorageService.Add($"Catalogs/{zipName}", zip, zip.Length);
                    return(RedirectToAction("Index"));
                }

                return(File(zip, "application/octet-stream", zipName));
            }
        }
Пример #27
0
        private static void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var backgroundWorker = sender as BackgroundWorker;


            foreach (var plugin in PluginPackages)
            {
                var notSupportedVersions = _studioVersionService.GetNotSupportedStudioVersions(plugin);
                var selectedVersion      = string.Empty;

                switch (Dpo.Version)
                {
                case SelectedVersion.Studio2:
                    selectedVersion = "Studio2";
                    break;

                case SelectedVersion.Studio3:
                    selectedVersion = "Studio3";
                    break;

                case SelectedVersion.Studio4:
                    selectedVersion = "Studio4";
                    break;

                case SelectedVersion.Studio5:
                    selectedVersion = "Studio5";
                    break;

                case SelectedVersion.Studio6:
                    selectedVersion = "Studio6";
                    break;
                }

                var notSupported = notSupportedVersions.FirstOrDefault(v => v.Version == selectedVersion);
                if (notSupported != null)
                {
                    Console.WriteLine(@"Selected studio version {0} is not compatible with the plugin version {1}", notSupported.PublicVersion, plugin.Version);
                }
                else
                {
                    Console.WriteLine(@"Deploy started for following plugin: {0}", plugin.PluginName);

                    _shown40 = false;
                    _shown80 = false;

                    var installService = new InstallService(plugin, _installedStudioVersions);
                    var deployLocation = new Environment.SpecialFolder();
                    switch (Dpo.DeployLocation)
                    {
                    case DeployDestination.Local:
                        deployLocation = Environment.SpecialFolder.LocalApplicationData;
                        break;

                    case DeployDestination.ProgramData:
                        deployLocation = Environment.SpecialFolder.CommonApplicationData;
                        break;

                    case DeployDestination.Roaming:

                        deployLocation = Environment.SpecialFolder.ApplicationData;
                        break;
                    }

                    if (backgroundWorker != null)
                    {
                        installService.DeployPackage(backgroundWorker.ReportProgress, deployLocation);
                    }
                }
            }
        }
Пример #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MainViewModel"/> class.
 /// </summary>
 public MainViewModel()
 {
     FilePath          = null;
     InstallAppCommand = new RelayCommand(InstallAppExecute, InstallAppCanExecute);
     installService    = new InstallService();
 }
Пример #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MainViewModel"/> class.
 /// </summary>
 /// <param name="filePath">Path to the target File for hashing</param>
 public MainViewModel(string filePath)
 {
     FilePath          = filePath;
     InstallAppCommand = new RelayCommand(InstallAppExecute, InstallAppCanExecute);
     installService    = new InstallService();
 }
Пример #30
0
 protected virtual void CreateVisitorGroup(Stream stream, ContentReference startPage) => InstallService.ImportEpiserverContent(stream, startPage);