public override void Submit_OnClick(object sender, EventArgs e) { if (myFile.PostedFile != null && "" != myFile.PostedFile.FileName) { var filePath = myFile.PostedFile.FileName; if (!EFileSystemTypeUtils.IsZip(PathUtils.GetExtension(filePath))) { FailMessage("必须上传Zip压缩文件"); 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, "导入栏目失败!"); } } }
public override void Submit_OnClick(object sender, EventArgs e) { if (HifFile.PostedFile != null && "" != HifFile.PostedFile.FileName) { var filePath = HifFile.PostedFile.FileName; if (!EFileSystemTypeUtils.IsZip(PathUtils.GetExtension(filePath))) { FailMessage("必须上传Zip压缩文件"); return; } try { var localFilePath = PathUtils.GetTemporaryFilesPath(PathUtils.GetFileName(filePath)); HifFile.PostedFile.SaveAs(localFilePath); var importObject = new ImportObject(SiteId, AuthRequest.AdminName); importObject.ImportChannelsAndContentsByZipFile(TranslateUtils.ToInt(DdlParentChannelId.SelectedValue), localFilePath, TranslateUtils.ToBool(DdlIsOverride.SelectedValue)); AuthRequest.AddSiteLog(SiteId, "导入栏目"); LayerUtils.Close(Page); } catch (Exception ex) { FailMessage(ex, "导入栏目失败!"); } } }
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, "数据恢复失败!"); } } } } }