コード例 #1
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (myFile.PostedFile != null && "" != myFile.PostedFile.FileName)
            {
                var filePath = myFile.PostedFile.FileName;
                if (!EFileSystemTypeUtils.IsCompressionFile(PathUtils.GetExtension(filePath)))
                {
                    FailMessage("必须上传压缩文件");
                    return;
                }

                try
                {
                    var localFilePath = PathUtils.GetTemporaryFilesPath(PathUtils.GetFileName(filePath));

                    myFile.PostedFile.SaveAs(localFilePath);

                    var importObject = new ImportObject(PublishmentSystemId);
                    importObject.ImportChannelsAndContentsByZipFile(TranslateUtils.ToInt(ParentNodeID.SelectedValue), localFilePath, TranslateUtils.ToBool(IsOverride.SelectedValue));

                    Body.AddSiteLog(PublishmentSystemId, "导入栏目");

                    PageUtils.CloseModalPage(Page);
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "导入栏目失败!");
                }
            }
        }
コード例 #2
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (myFile.PostedFile != null && "" != myFile.PostedFile.FileName)
            {
                var filePath = myFile.PostedFile.FileName;
                if (!EFileSystemTypeUtils.IsCompressionFile(PathUtils.GetExtension(filePath)))
                {
                    FailMessage("必须上传压缩文件");
                    return;
                }

                try
                {
                    var localFilePath = PathUtils.GetTemporaryFilesPath(PathUtils.GetFileName(filePath));

                    myFile.PostedFile.SaveAs(localFilePath);

                    ImportObject.ImportTableStyleByZipFile(_tableStyle, _tableName, 0, localFilePath);

                    Body.AddAdminLog("导入表单显示样式", $"类型:{ETableStyleUtils.GetText(_tableStyle)}");

                    PageUtils.CloseModalPage(Page);
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "导入表样式失败!");
                }
            }
        }
コード例 #3
0
        public void RecoveryButton_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                if (TranslateUtils.ToBool(IsRecoveryByUpload.SelectedValue))
                {
                    if (myFile.PostedFile != null && "" != myFile.PostedFile.FileName)
                    {
                        var filePath = myFile.PostedFile.FileName;
                        if (EBackupTypeUtils.Equals(EBackupType.Templates, BackupType.SelectedValue))
                        {
                            if (EFileSystemTypeUtils.GetEnumType(PathUtils.GetExtension(filePath)) != EFileSystemType.Xml)
                            {
                                FailMessage("必须上传Xml文件");
                                return;
                            }
                        }
                        else
                        {
                            if (!EFileSystemTypeUtils.IsCompressionFile(PathUtils.GetExtension(filePath)))
                            {
                                FailMessage("必须上传压缩文件");
                                return;
                            }
                        }

                        try
                        {
                            var localFilePath = PathUtils.GetTemporaryFilesPath(PathUtils.GetFileName(filePath));

                            myFile.PostedFile.SaveAs(localFilePath);

                            var importObject = new ImportObject(PublishmentSystemId);

                            if (EBackupTypeUtils.Equals(EBackupType.Templates, BackupType.SelectedValue))
                            {
                                importObject.ImportTemplates(localFilePath, TranslateUtils.ToBool(IsOverride.SelectedValue), Body.AdministratorName);
                                SuccessMessage("恢复模板成功!");
                            }
                            else if (EBackupTypeUtils.Equals(EBackupType.ChannelsAndContents, BackupType.SelectedValue))
                            {
                                importObject.ImportChannelsAndContentsByZipFile(0, localFilePath, TranslateUtils.ToBool(IsOverride.SelectedValue));
                                SuccessMessage("恢复栏目及内容成功!");
                            }
                            else if (EBackupTypeUtils.Equals(EBackupType.Files, BackupType.SelectedValue))
                            {
                                var filesDirectoryPath = PathUtils.GetTemporaryFilesPath(EBackupTypeUtils.GetValue(EBackupType.Files));
                                DirectoryUtils.DeleteDirectoryIfExists(filesDirectoryPath);
                                DirectoryUtils.CreateDirectoryIfNotExists(filesDirectoryPath);

                                ZipUtils.UnpackFiles(localFilePath, filesDirectoryPath);

                                importObject.ImportFiles(filesDirectoryPath, TranslateUtils.ToBool(IsOverride.SelectedValue));
                                SuccessMessage("恢复文件成功!");
                            }
                            else if (EBackupTypeUtils.Equals(EBackupType.Site, BackupType.SelectedValue))
                            {
                                var userKeyPrefix = StringUtils.Guid();
                                PageUtils.Redirect(PageProgressBar.GetRecoveryUrl(PublishmentSystemId, IsDeleteChannels.SelectedValue, IsDeleteTemplates.SelectedValue, IsDeleteFiles.SelectedValue, true, localFilePath, IsOverride.SelectedValue, IsOverride.SelectedValue, userKeyPrefix));
                            }
                        }
                        catch (Exception ex)
                        {
                            FailMessage(ex, "数据恢复失败!");
                        }
                    }
                }
            }
        }