public override void Submit_OnClick(object sender, EventArgs e) { if (HifFile.PostedFile == null || "" == HifFile.PostedFile.FileName) { return; } var isChecked = false; var checkedLevel = TranslateUtils.ToIntWithNagetive(DdlContentLevel.SelectedValue); if (checkedLevel >= SiteInfo.Additional.CheckContentLevel) { isChecked = true; } try { if (StringUtils.EqualsIgnoreCase(DdlImportType.SelectedValue, ModalExportMessage.ExportTypeContentZip)) { var filePath = HifFile.PostedFile.FileName; if (!EFileSystemTypeUtils.Equals(EFileSystemType.Zip, PathUtils.GetExtension(filePath))) { FailMessage("必须上传后缀为“.zip”的压缩文件"); return; } var localFilePath = PathUtils.GetTemporaryFilesPath(PathUtils.GetFileName(filePath)); HifFile.PostedFile.SaveAs(localFilePath); var importObject = new ImportObject(SiteId, AuthRequest.AdminName); var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); importObject.ImportContentsByZipFile(nodeInfo, localFilePath, TranslateUtils.ToBool(DdlIsOverride.SelectedValue), TranslateUtils.ToInt(TbImportStart.Text), TranslateUtils.ToInt(TbImportCount.Text), isChecked, checkedLevel); } else if (StringUtils.EqualsIgnoreCase(DdlImportType.SelectedValue, ModalExportMessage.ExportTypeContentAccess)) { var filePath = HifFile.PostedFile.FileName; if (!StringUtils.EqualsIgnoreCase(PathUtils.GetExtension(filePath), ".mdb")) { FailMessage("必须上传后缀为“.mdb”的Access文件"); return; } var localFilePath = PathUtils.GetTemporaryFilesPath(PathUtils.GetFileName(filePath)); HifFile.PostedFile.SaveAs(localFilePath); var importObject = new ImportObject(SiteId, AuthRequest.AdminName); importObject.ImportContentsByAccessFile(_channelId, localFilePath, TranslateUtils.ToBool(DdlIsOverride.SelectedValue), TranslateUtils.ToInt(TbImportStart.Text), TranslateUtils.ToInt(TbImportCount.Text), isChecked, checkedLevel); } else if (StringUtils.EqualsIgnoreCase(DdlImportType.SelectedValue, ModalExportMessage.ExportTypeContentExcel)) { var filePath = HifFile.PostedFile.FileName; if (!StringUtils.EqualsIgnoreCase(PathUtils.GetExtension(filePath), ".csv")) { FailMessage("必须上传后缀为“.csv”的Excel文件"); return; } var localFilePath = PathUtils.GetTemporaryFilesPath(PathUtils.GetFileName(filePath)); HifFile.PostedFile.SaveAs(localFilePath); var importObject = new ImportObject(SiteId, AuthRequest.AdminName); importObject.ImportContentsByCsvFile(_channelId, localFilePath, TranslateUtils.ToBool(DdlIsOverride.SelectedValue), TranslateUtils.ToInt(TbImportStart.Text), TranslateUtils.ToInt(TbImportCount.Text), isChecked, checkedLevel); } else if (StringUtils.EqualsIgnoreCase(DdlImportType.SelectedValue, ModalExportMessage.ExportTypeContentTxtZip)) { var filePath = HifFile.PostedFile.FileName; if (!EFileSystemTypeUtils.Equals(EFileSystemType.Zip, PathUtils.GetExtension(filePath))) { FailMessage("必须上传后缀为“.zip”的压缩文件"); return; } var localFilePath = PathUtils.GetTemporaryFilesPath(PathUtils.GetFileName(filePath)); HifFile.PostedFile.SaveAs(localFilePath); var importObject = new ImportObject(SiteId, AuthRequest.AdminName); importObject.ImportContentsByTxtZipFile(_channelId, localFilePath, TranslateUtils.ToBool(DdlIsOverride.SelectedValue), TranslateUtils.ToInt(TbImportStart.Text), TranslateUtils.ToInt(TbImportCount.Text), isChecked, checkedLevel); } AuthRequest.AddSiteLog(SiteId, _channelId, 0, "导入内容", string.Empty); LayerUtils.Close(Page); } catch (Exception ex) { FailMessage(ex, "导入内容失败!"); } }
public override void Submit_OnClick(object sender, EventArgs e) { if (myFile.PostedFile != null && "" != myFile.PostedFile.FileName) { var isChecked = false; var checkedLevel = TranslateUtils.ToIntWithNagetive(ContentLevel.SelectedValue); if (checkedLevel >= PublishmentSystemInfo.CheckContentLevel) { isChecked = true; } try { if (StringUtils.EqualsIgnoreCase(ImportType.SelectedValue, ModalExportMessage.ExportTypeContentZip)) { var filePath = myFile.PostedFile.FileName; if (!EFileSystemTypeUtils.Equals(EFileSystemType.Zip, PathUtils.GetExtension(filePath))) { FailMessage("必须上传后缀为“.zip”的压缩文件"); return; } var localFilePath = PathUtils.GetTemporaryFilesPath(PathUtils.GetFileName(filePath)); myFile.PostedFile.SaveAs(localFilePath); var importObject = new ImportObject(PublishmentSystemId); var nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, _nodeId); importObject.ImportContentsByZipFile(nodeInfo, localFilePath, TranslateUtils.ToBool(IsOverride.SelectedValue), TranslateUtils.ToInt(ImportStart.Text), TranslateUtils.ToInt(ImportCount.Text), isChecked, checkedLevel); } else if (StringUtils.EqualsIgnoreCase(ImportType.SelectedValue, ModalExportMessage.ExportTypeContentAccess)) { var filePath = myFile.PostedFile.FileName; if (!StringUtils.EqualsIgnoreCase(PathUtils.GetExtension(filePath), ".mdb")) { FailMessage("必须上传后缀为“.mdb”的Access文件"); return; } var localFilePath = PathUtils.GetTemporaryFilesPath(PathUtils.GetFileName(filePath)); myFile.PostedFile.SaveAs(localFilePath); var importObject = new ImportObject(PublishmentSystemId); importObject.ImportContentsByAccessFile(_nodeId, localFilePath, TranslateUtils.ToBool(IsOverride.SelectedValue), TranslateUtils.ToInt(ImportStart.Text), TranslateUtils.ToInt(ImportCount.Text), isChecked, checkedLevel); } else if (StringUtils.EqualsIgnoreCase(ImportType.SelectedValue, ModalExportMessage.ExportTypeContentExcel)) { var filePath = myFile.PostedFile.FileName; if (!StringUtils.EqualsIgnoreCase(PathUtils.GetExtension(filePath), ".csv")) { FailMessage("必须上传后缀为“.csv”的Excel文件"); return; } var localFilePath = PathUtils.GetTemporaryFilesPath(PathUtils.GetFileName(filePath)); myFile.PostedFile.SaveAs(localFilePath); var importObject = new ImportObject(PublishmentSystemId); importObject.ImportContentsByCsvFile(_nodeId, localFilePath, TranslateUtils.ToBool(IsOverride.SelectedValue), TranslateUtils.ToInt(ImportStart.Text), TranslateUtils.ToInt(ImportCount.Text), isChecked, checkedLevel); } else if (StringUtils.EqualsIgnoreCase(ImportType.SelectedValue, ModalExportMessage.ExportTypeContentTxtZip)) { var filePath = myFile.PostedFile.FileName; if (!EFileSystemTypeUtils.Equals(EFileSystemType.Zip, PathUtils.GetExtension(filePath))) { FailMessage("必须上传后缀为“.zip”的压缩文件"); return; } var localFilePath = PathUtils.GetTemporaryFilesPath(PathUtils.GetFileName(filePath)); myFile.PostedFile.SaveAs(localFilePath); var importObject = new ImportObject(PublishmentSystemId); importObject.ImportContentsByTxtZipFile(_nodeId, localFilePath, TranslateUtils.ToBool(IsOverride.SelectedValue), TranslateUtils.ToInt(ImportStart.Text), TranslateUtils.ToInt(ImportCount.Text), isChecked, checkedLevel); } Body.AddSiteLog(PublishmentSystemId, _nodeId, 0, "导入内容", string.Empty); PageUtils.CloseModalPage(Page); } catch (Exception ex) { FailMessage(ex, "导入内容失败!"); } } }