Esempio n. 1
0
            public void RunJob()
            {
                //download demo data to temporary file
                var tempFilePath = Path.Combine(tmpfolder, _fromFilePath);

                try
                {
                    if (!File.Exists(tempFilePath))
                    {
                        using (var fs = new FileStream(tempFilePath, FileMode.OpenOrCreate, FileAccess.Write))
                        {
                            var store = StorageFactory.GetStorage(currentWebConfigPath, "demodata", "demo", null, null);
                            store.GetReadStream(_fromFilePath).StreamCopyTo(fs);
                        }
                    }

                    var restoreTask = new RestorePortalTask(currentWebConfigPath, tempFilePath, ColumnMapper.ForRestoreDemoPortal(_tenantID));
                    restoreTask.IgnoreTable("tenants_tenants");
                    restoreTask.IgnoreTable("tenants_tariff");
                    restoreTask.IgnoreModule(ModuleName.Mail);
                    restoreTask.IgnoreModule(ModuleName.WebStudio);

                    restoreTask.ProgressChanged += (sender, args) => Percentage = args.Progress;
                    restoreTask.Message         += (sender, args) =>
                    {
                        if (args.Reason == MessageReason.Info)
                        {
                            log.Debug(args.Message);
                        }
                        else if (args.Reason == MessageReason.Warning)
                        {
                            log.Warn(args.Message);
                        }
                    };

                    restoreTask.Run();
                }
                catch (Exception error)
                {
                    log.Error(error);
                    Error = error;
                }
                finally
                {
                    IsCompleted = true;
                }
            }