public static string GetUploadDirectoryPath(SiteInfo siteInfo, DateTime datetime, string fileExtension) { var uploadDateFormatString = siteInfo.Additional.FileUploadDateFormatString; var uploadDirectoryName = siteInfo.Additional.FileUploadDirectoryName; if (IsImageExtenstionAllowed(siteInfo, fileExtension)) { uploadDateFormatString = siteInfo.Additional.ImageUploadDateFormatString; uploadDirectoryName = siteInfo.Additional.ImageUploadDirectoryName; } else if (IsVideoExtenstionAllowed(siteInfo, fileExtension)) { uploadDateFormatString = siteInfo.Additional.VideoUploadDateFormatString; uploadDirectoryName = siteInfo.Additional.VideoUploadDirectoryName; } string directoryPath; var dateFormatType = EDateFormatTypeUtils.GetEnumType(uploadDateFormatString); var sitePath = GetSitePath(siteInfo); if (dateFormatType == EDateFormatType.Year) { directoryPath = PathUtils.Combine(sitePath, uploadDirectoryName, datetime.Year.ToString()); } else if (dateFormatType == EDateFormatType.Day) { directoryPath = PathUtils.Combine(sitePath, uploadDirectoryName, datetime.Year.ToString(), datetime.Month.ToString(), datetime.Day.ToString()); } else { directoryPath = PathUtils.Combine(sitePath, uploadDirectoryName, datetime.Year.ToString(), datetime.Month.ToString()); } DirectoryUtils.CreateDirectoryIfNotExists(directoryPath); return(directoryPath); }
public override void Submit_OnClick(object sender, EventArgs e) { if (Page.IsPostBack && Page.IsValid) { SiteInfo.Additional.FileUploadDirectoryName = TbFileUploadDirectoryName.Text; SiteInfo.Additional.FileUploadDateFormatString = EDateFormatTypeUtils.GetValue(EDateFormatTypeUtils.GetEnumType(DdlFileUploadDateFormatString.SelectedValue)); SiteInfo.Additional.IsFileUploadChangeFileName = TranslateUtils.ToBool(DdlIsFileUploadChangeFileName.SelectedValue); SiteInfo.Additional.FileUploadTypeCollection = TbFileUploadTypeCollection.Text.Replace(",", "|"); var kbSize = int.Parse(TbFileUploadTypeMaxSize.Text); SiteInfo.Additional.FileUploadTypeMaxSize = (DdlFileUploadTypeUnit.SelectedIndex == 0) ? kbSize : 1024 * kbSize; try { DataProvider.SiteDao.Update(SiteInfo); Body.AddSiteLog(SiteId, "修改附件上传设置"); SuccessMessage("上传附件设置修改成功!"); } catch (Exception ex) { FailMessage(ex, "上传附件设置修改失败!"); } } }
public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } SiteInfo.Additional.ImageUploadDirectoryName = TbImageUploadDirectoryName.Text; SiteInfo.Additional.ImageUploadDateFormatString = EDateFormatTypeUtils.GetValue(EDateFormatTypeUtils.GetEnumType(DdlImageUploadDateFormatString.SelectedValue)); SiteInfo.Additional.IsImageUploadChangeFileName = TranslateUtils.ToBool(DdlIsImageUploadChangeFileName.SelectedValue); SiteInfo.Additional.ImageUploadTypeCollection = TbImageUploadTypeCollection.Text.Replace(",", "|"); var kbSize = int.Parse(TbImageUploadTypeMaxSize.Text); SiteInfo.Additional.ImageUploadTypeMaxSize = DdlImageUploadTypeUnit.SelectedIndex == 0 ? kbSize : 1024 * kbSize; SiteInfo.Additional.PhotoSmallWidth = TranslateUtils.ToInt(TbPhotoSmallWidth.Text, SiteInfo.Additional.PhotoSmallWidth); SiteInfo.Additional.PhotoMiddleWidth = TranslateUtils.ToInt(TbPhotoMiddleWidth.Text, SiteInfo.Additional.PhotoMiddleWidth); try { DataProvider.SiteDao.Update(SiteInfo); AuthRequest.AddSiteLog(SiteId, "修改图片上传设置"); SuccessMessage("上传图片设置修改成功!"); } catch (Exception ex) { FailMessage(ex, "上传图片设置修改失败!"); } }
public override void Submit_OnClick(object sender, EventArgs e) { if (Page.IsPostBack && Page.IsValid) { PublishmentSystemInfo.Additional.VideoUploadDirectoryName = tbVideoUploadDirectoryName.Text; PublishmentSystemInfo.Additional.VideoUploadDateFormatString = EDateFormatTypeUtils.GetValue(EDateFormatTypeUtils.GetEnumType(rblVideoUploadDateFormatString.SelectedValue)); PublishmentSystemInfo.Additional.IsVideoUploadChangeFileName = TranslateUtils.ToBool(rblIsVideoUploadChangeFileName.SelectedValue); PublishmentSystemInfo.Additional.VideoUploadTypeCollection = tbVideoUploadTypeCollection.Text.Replace(",", "|"); var kbSize = int.Parse(tbVideoUploadTypeMaxSize.Text); PublishmentSystemInfo.Additional.VideoUploadTypeMaxSize = (ddlVideoUploadTypeUnit.SelectedIndex == 0) ? kbSize : 1024 * kbSize; try { DataProvider.PublishmentSystemDao.Update(PublishmentSystemInfo); Body.AddSiteLog(PublishmentSystemId, "修改视频上传设置"); SuccessMessage("上传视频设置修改成功!"); } catch (Exception ex) { FailMessage(ex, "上传视频设置修改失败!"); } } }
public static string GetUploadDirectoryPath(SiteInfo siteInfo, DateTime datetime, EUploadType uploadType) { var uploadDateFormatString = string.Empty; var uploadDirectoryName = string.Empty; if (uploadType == EUploadType.Image) { uploadDateFormatString = siteInfo.Additional.ImageUploadDateFormatString; uploadDirectoryName = siteInfo.Additional.ImageUploadDirectoryName; } else if (uploadType == EUploadType.Video) { uploadDateFormatString = siteInfo.Additional.VideoUploadDateFormatString; uploadDirectoryName = siteInfo.Additional.VideoUploadDirectoryName; } else if (uploadType == EUploadType.File) { uploadDateFormatString = siteInfo.Additional.FileUploadDateFormatString; uploadDirectoryName = siteInfo.Additional.FileUploadDirectoryName; } else if (uploadType == EUploadType.Special) { uploadDateFormatString = siteInfo.Additional.FileUploadDateFormatString; uploadDirectoryName = "/Special"; } else if (uploadType == EUploadType.AdvImage) { uploadDateFormatString = siteInfo.Additional.FileUploadDateFormatString; uploadDirectoryName = "/AdvImage"; } string directoryPath; var dateFormatType = EDateFormatTypeUtils.GetEnumType(uploadDateFormatString); var sitePath = GetSitePath(siteInfo); if (dateFormatType == EDateFormatType.Year) { directoryPath = PathUtils.Combine(sitePath, uploadDirectoryName, datetime.Year.ToString()); } else if (dateFormatType == EDateFormatType.Day) { directoryPath = PathUtils.Combine(sitePath, uploadDirectoryName, datetime.Year.ToString(), datetime.Month.ToString(), datetime.Day.ToString()); } else { directoryPath = PathUtils.Combine(sitePath, uploadDirectoryName, datetime.Year.ToString(), datetime.Month.ToString()); } DirectoryUtils.CreateDirectoryIfNotExists(directoryPath); return(directoryPath); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId"); if (IsPostBack) { return; } VerifySitePermissions(ConfigManager.WebSitePermissions.Configration); TbImageUploadDirectoryName.Text = SiteInfo.Additional.ImageUploadDirectoryName; DdlImageUploadDateFormatString.Items.Add(new ListItem("按年存入不同目录(不推荐)", EDateFormatTypeUtils.GetValue(EDateFormatType.Year))); DdlImageUploadDateFormatString.Items.Add(new ListItem("按年/月存入不同目录", EDateFormatTypeUtils.GetValue(EDateFormatType.Month))); DdlImageUploadDateFormatString.Items.Add(new ListItem("按年/月/日存入不同目录", EDateFormatTypeUtils.GetValue(EDateFormatType.Day))); ControlUtils.SelectSingleItemIgnoreCase(DdlImageUploadDateFormatString, SiteInfo.Additional.ImageUploadDateFormatString); EBooleanUtils.AddListItems(DdlIsImageUploadChangeFileName, "自动修改文件名", "保持文件名不变"); ControlUtils.SelectSingleItemIgnoreCase(DdlIsImageUploadChangeFileName, SiteInfo.Additional.IsImageUploadChangeFileName.ToString()); TbImageUploadTypeCollection.Text = SiteInfo.Additional.ImageUploadTypeCollection.Replace("|", ","); var mbSize = GetMbSize(SiteInfo.Additional.ImageUploadTypeMaxSize); if (mbSize == 0) { DdlImageUploadTypeUnit.SelectedIndex = 0; TbImageUploadTypeMaxSize.Text = SiteInfo.Additional.ImageUploadTypeMaxSize.ToString(); } else { DdlImageUploadTypeUnit.SelectedIndex = 1; TbImageUploadTypeMaxSize.Text = mbSize.ToString(); } TbPhotoSmallWidth.Text = SiteInfo.Additional.PhotoSmallWidth.ToString(); TbPhotoMiddleWidth.Text = SiteInfo.Additional.PhotoMiddleWidth.ToString(); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("PublishmentSystemID"); if (IsPostBack) { return; } BreadCrumb(AppManager.Cms.LeftMenu.IdConfigration, AppManager.Cms.LeftMenu.Configuration.IdConfigurationUpload, "图片上传设置", AppManager.Cms.Permission.WebSite.Configration); TbImageUploadDirectoryName.Text = PublishmentSystemInfo.Additional.ImageUploadDirectoryName; RblImageUploadDateFormatString.Items.Add(new ListItem("按年存入不同目录(不推荐)", EDateFormatTypeUtils.GetValue(EDateFormatType.Year))); RblImageUploadDateFormatString.Items.Add(new ListItem("按年/月存入不同目录", EDateFormatTypeUtils.GetValue(EDateFormatType.Month))); RblImageUploadDateFormatString.Items.Add(new ListItem("按年/月/日存入不同目录", EDateFormatTypeUtils.GetValue(EDateFormatType.Day))); ControlUtils.SelectListItemsIgnoreCase(RblImageUploadDateFormatString, PublishmentSystemInfo.Additional.ImageUploadDateFormatString); EBooleanUtils.AddListItems(RblIsImageUploadChangeFileName, "自动修改文件名", "保持文件名不变"); ControlUtils.SelectListItemsIgnoreCase(RblIsImageUploadChangeFileName, PublishmentSystemInfo.Additional.IsImageUploadChangeFileName.ToString()); TbImageUploadTypeCollection.Text = PublishmentSystemInfo.Additional.ImageUploadTypeCollection.Replace("|", ","); var mbSize = GetMbSize(PublishmentSystemInfo.Additional.ImageUploadTypeMaxSize); if (mbSize == 0) { DdlImageUploadTypeUnit.SelectedIndex = 0; TbImageUploadTypeMaxSize.Text = PublishmentSystemInfo.Additional.ImageUploadTypeMaxSize.ToString(); } else { DdlImageUploadTypeUnit.SelectedIndex = 1; TbImageUploadTypeMaxSize.Text = mbSize.ToString(); } TbPhotoSmallWidth.Text = PublishmentSystemInfo.Additional.PhotoSmallWidth.ToString(); TbPhotoMiddleWidth.Text = PublishmentSystemInfo.Additional.PhotoMiddleWidth.ToString(); }
public static string GetUserUploadDirectoryPath(string userName) { string directoryPath; var dateFormatType = EDateFormatTypeUtils.GetEnumType(ConfigManager.UserConfigInfo.UploadDateFormatString); var datetime = DateTime.Now; var userFilesPath = GetUserFilesPath(userName, string.Empty); if (dateFormatType == EDateFormatType.Year) { directoryPath = Combine(userFilesPath, datetime.Year.ToString()); } else if (dateFormatType == EDateFormatType.Day) { directoryPath = Combine(userFilesPath, datetime.Year.ToString(), datetime.Month.ToString(), datetime.Day.ToString()); } else { directoryPath = Combine(userFilesPath, datetime.Year.ToString(), datetime.Month.ToString()); } DirectoryUtils.CreateDirectoryIfNotExists(directoryPath); return(directoryPath); }