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 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);
        }
Exemple #3
0
        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);
        }
        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, "上传附件设置修改失败!");
                }
            }
        }
Exemple #5
0
        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, "上传视频设置修改失败!");
                }
            }
        }