Ejemplo n.º 1
0
 /// <summary>
 /// 页面加载
 /// </summary>
 public override void RenderPage()
 {
     if (FileRestrictID.IsNoNull())
     {
         objresource_filerestrict = objFileResourceRule.resource_filerestrict.FirstOrDefault(s => s.FileRestrictID == FileRestrictID);
         if (CheckEditObjectIsNull(objresource_filerestrict))
         {
             return;
         }
         ///文件访问方式
         radAccessModeCodeType.SelectedValue = objresource_filerestrict.AccessModeCodeType.ToString();
         ///目录存储格式
         radPathFormatCodeType.SelectedValue = objresource_filerestrict.PathFormatCodeType.ToString();
         ///1文件2图片3flash4mid
         radFileType.SelectedValue          = objresource_filerestrict.FileType.ToString();
         radFileStoragePathID.SelectedValue = objresource_filerestrict.FileStoragePathID;
         chkIsReturnSize.Checked            = objresource_filerestrict.IsReturnSize == 1;
         chkIsHistory.Checked = objresource_filerestrict.IsHistory == 1;
         chkIsMd5.Checked     = objresource_filerestrict.IsMd5 == 1;
         Page.DataBind();
     }
     else
     {
         radAccessModeCodeType.SelectedIndex = 0;
         radPathFormatCodeType.SelectedIndex = 0;
     }
 }
Ejemplo n.º 2
0
    /// <summary>
    /// 保存信息
    /// </summary>
    public void SaveInfo()
    {
        if (FileRestrictID.IsNull())
        {
            objresource_filerestrict.FileRestrictID = Guid.NewGuid().ToString();
            objresource_filerestrict.FileResourceID = FileResourceID;
            ///存储路经标识
            objresource_filerestrict.FileStoragePathID = radFileStoragePathID.SelectedValue;
            ///文件访问方式
            objresource_filerestrict.AccessModeCodeType = radAccessModeCodeType.SelectValueInt;
            ///目录存储格式
            objresource_filerestrict.PathFormatCodeType = radPathFormatCodeType.SelectValueInt;
            ///限制名称
            objresource_filerestrict.RestrictName = txtRestrictName.TextCutWord(100);
            ///限制码
            objresource_filerestrict.RestrictCode = txtRestrictCode.TextCutWord(1000);
            ///1文件2图片3flash4mid
            objresource_filerestrict.FileType = radFileType.SelectValueInt;
            ///文件扩展名
            objresource_filerestrict.FileExtension = txtFileExtension.TextCutWord(256);
            ///大小限制单位(K)0不限制
            objresource_filerestrict.FileMaxSize = txtFileMaxSize.TextInt;

            objresource_filerestrict.IsReturnSize = chkIsReturnSize.Checked ? 1 : 0;
            objresource_filerestrict.IsHistory    = chkIsHistory.Checked ? 1 : 0;
            objresource_filerestrict.IsMd5        = chkIsMd5.Checked ? 1 : 0;
            objFileResourceRule.Insertfilerestrict(objresource_filerestrict);
            MessageDialog("新增成功", "FileRestrictList.aspx?FileResourceID=" + FileResourceID);
        }
        else
        {
            objresource_filerestrict = objFileResourceRule.resource_filerestrict.FirstOrDefault(p => p.FileRestrictID == FileRestrictID);
            if (CheckEditObjectIsNull(objresource_filerestrict))
            {
                return;
            }
            ///存储路经标识
            objresource_filerestrict.FileStoragePathID = radFileStoragePathID.SelectedValue;
            ///文件访问方式
            objresource_filerestrict.AccessModeCodeType = radAccessModeCodeType.SelectValueInt;
            ///目录存储格式
            objresource_filerestrict.PathFormatCodeType = radPathFormatCodeType.SelectValueInt;
            ///限制名称
            objresource_filerestrict.RestrictName = txtRestrictName.TextCutWord(100);
            ///限制码
            objresource_filerestrict.RestrictCode = txtRestrictCode.TextCutWord(1000);
            ///1文件2图片3flash4mid
            objresource_filerestrict.FileType = radFileType.SelectValueInt;
            ///文件扩展名
            objresource_filerestrict.FileExtension = txtFileExtension.TextCutWord(256);
            ///大小限制单位(K)0不限制
            objresource_filerestrict.FileMaxSize  = txtFileMaxSize.TextInt;
            objresource_filerestrict.IsReturnSize = chkIsReturnSize.Checked ? 1 : 0;
            objresource_filerestrict.IsHistory    = chkIsHistory.Checked ? 1 : 0;
            objresource_filerestrict.IsMd5        = chkIsMd5.Checked ? 1 : 0;
            objFileResourceRule.Updatefilerestrict(objresource_filerestrict);
            MessageDialog("修改成功", "FileRestrictList.aspx?FileResourceID=" + FileResourceID);
        }
    }
Ejemplo n.º 3
0
        public static string GetFtpFullFileNamePath(resource_filerestrict objresource_filerestrict, string resourceFileName)
        {
            DateTime now = DateTime.Now;
            string   fileResourceCode = objresource_filerestrict.resource_fileresource.FileResourceCode;
            string   resourceVerID    = Guid.NewGuid().ToString();
            resource_filestoragepath _filestoragepath = objresource_filerestrict.resource_filestoragepath;
            string resourceGUIDFileName = resourceVerID + Path.GetExtension(resourceFileName);
            string pathFormatValue      = GetResourcePathFormatValue(now, resourceVerID, objresource_filerestrict.PathFormatCodeType);

            return(GetresourceFullFileNamePath(_filestoragepath.StoragePath, (AccessModeCodeType)objresource_filerestrict.AccessModeCodeType, fileResourceCode, pathFormatValue, resourceGUIDFileName, resourceFileName, false).Replace('\\', '/'));
        }
Ejemplo n.º 4
0
 private void ValidationInit()
 {
     if ((this.ValidationGroup.IsNoNull() && this.ResourceCode.IsNoNull()) && this.RestrictCode.IsNoNull())
     {
         FileResourceRule      rule          = new FileResourceRule();
         resource_filerestrict _filerestrict = rule.resource_filerestrict.Where("it.RestrictCode='" + this.RestrictCode + "' and it.resource_fileresource.FileResourceCode='" + this.ResourceCode + "'", new ObjectParameter[0]).Include("resource_filestoragepath").Include("resource_filerestrictpic").FirstOrDefault <resource_filerestrict>();
         if (_filerestrict == null)
         {
             SysAssert.InfoHintAssert("找不到此文件配置");
         }
         if (_filerestrict.FileExtension.IsNoNull())
         {
             this.ValidationExpression = "(" + _filerestrict.FileExtension.Replace(',', '|') + ")$";
         }
         if (this.HintMessage.IsNull())
         {
             object hintMessage;
             if ((_filerestrict.FileMaxSize > 0) || _filerestrict.FileExtension.IsNoNull())
             {
                 this.HintMessage  = (_filerestrict.FileExtension.IsNoNull() ? ("文件类型:" + _filerestrict.FileExtension) : "") + ((_filerestrict.FileMaxSize > 0) ? ((_filerestrict.FileExtension.IsNoNull() ? "," : "") + "文件必须小于" + ((int)(_filerestrict.FileMaxSize * 0x400)).RenderFileSize()) : "");
                 this.ErrorMessage = "请上传:" + (_filerestrict.FileExtension.IsNoNull() ? ("文件类型:" + _filerestrict.FileExtension) : "") + ((_filerestrict.FileMaxSize > 0) ? ((_filerestrict.FileExtension.IsNoNull() ? "," : "") + "文件必须小于" + ((int)(_filerestrict.FileMaxSize * 0x400)).RenderFileSize()) : "");
             }
             resource_filerestrictpic _filerestrictpic = (from s in _filerestrict.resource_filerestrictpic
                                                          orderby s.ImageWidth descending
                                                          select s).FirstOrDefault <resource_filerestrictpic>();
             if (_filerestrictpic != null)
             {
                 if (_filerestrictpic.ImageWidth > 0)
                 {
                     hintMessage       = this.HintMessage;
                     this.HintMessage  = string.Concat(new object[] { hintMessage, ",尺寸:", _filerestrictpic.ImageWidth, "x", _filerestrictpic.ImageHeight });
                     hintMessage       = this.ErrorMessage;
                     this.ErrorMessage = string.Concat(new object[] { hintMessage, ",尺寸:", _filerestrictpic.ImageWidth, "x", _filerestrictpic.ImageHeight });
                 }
             }
             else if ((this.ImageWidth > 0) || (this.ImageHeight > 0))
             {
                 hintMessage       = this.HintMessage;
                 this.HintMessage  = string.Concat(new object[] { hintMessage, ",尺寸:", this.ImageWidth, "x", this.ImageHeight, (this.ImageRange > 0) ? (",误差:" + this.ImageRange) : "" });
                 hintMessage       = this.ErrorMessage;
                 this.ErrorMessage = string.Concat(new object[] { hintMessage, ",尺寸:", this.ImageWidth, "x", this.ImageHeight, (this.ImageRange > 0) ? (",误差:" + this.ImageRange) : "" });
             }
         }
         if (!string.IsNullOrEmpty(this.ValidationGroup))
         {
             base.Attributes.Add("ValidationGroup", this.ValidationGroup);
         }
         else
         {
             base.Attributes.Remove("ValidationGroup");
         }
         if (!string.IsNullOrEmpty(this.ValidationExpression))
         {
             base.Attributes.Add("ValidationExpression", this.ValidationExpression);
         }
         else
         {
             base.Attributes.Remove("ValidationExpression");
         }
         if (!string.IsNullOrEmpty(this.ErrorMessage))
         {
             base.Attributes.Add("ErrorMessage", this.ErrorMessage);
             base.Attributes.Add("onblur", "$(this).BlurValidationError(" + (this.BlurSucessCall.IsNull() ? "" : this.BlurSucessCall) + ");");
         }
         else
         {
             base.Attributes.Remove("ErrorMessage");
             base.Attributes.Remove("onblur");
         }
         if (!string.IsNullOrEmpty(this.HintMessage))
         {
             base.Attributes.Add("HintMessage", this.HintMessage);
             base.Attributes.Add("onfocus", "$(this).FocusValidationHint();");
         }
         else
         {
             base.Attributes.Remove("HintMessage");
             base.Attributes.Remove("onfocus");
         }
         if (this.MessageWidth != 0)
         {
             base.Attributes.Add("MessageWidth", this.MessageWidth.ToString());
         }
         else
         {
             base.Attributes.Remove("MessageWidth");
         }
         if (this.CheckValueEmpty)
         {
             base.Attributes.Add("CheckValueEmpty", this.CheckValueEmpty.ToString());
         }
         else
         {
             base.Attributes.Remove("CheckValueEmpty");
         }
     }
 }
Ejemplo n.º 5
0
        public override void RenderEndTag(HtmlTextWriter writer)
        {
            base.RenderEndTag(writer);
            writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript");
            writer.RenderBeginTag(HtmlTextWriterTag.Script);
            StringBuilder builder = new StringBuilder();
            string        str     = SysVariable.ApplicationPath + "/" + this.ThemePath + "/uploadify.swf";

            writer.Write(builder.ToString());
            builder.AppendLine(" $(function () {");
            builder.AppendLine(" setTimeout(function(){ $(\"#" + this.ClientID + "\").uploadify({");
            builder.AppendFormat("'{0}':{1},", "auto", this.AutoPost.ToString().ToLower());
            builder.AppendFormat("'{0}':{1},", "removeTimeout", this.RemoveTimeout);
            builder.AppendFormat("'{0}':{1},", "multi", this.IsMulti.ToString().ToLower());
            builder.AppendFormat("'{0}':'{1}',", "buttonText", this.ButtonText);
            builder.AppendFormat("'{0}':'{1}',", "swf", str);
            string str2 = SysVariable.ApplicationPath + "/" + this.ThemePath + "/UploadHandler.ashx?ResourceCode=" + this.ResourceCode + "&RestrictCode=" + this.RestrictCode;

            builder.AppendFormat("'{0}':'{1}',", "uploader", str2);
            if (!string.IsNullOrWhiteSpace(this.ConfigOptions))
            {
                this.ConfigOptions = this.ConfigOptions.Trim();
                this.ConfigOptions = this.ConfigOptions + ",";
                builder.Append(this.ConfigOptions);
            }
            if (this.ResourceCode.IsNoNull() && this.RestrictCode.IsNoNull())
            {
                FileResourceRule      rule          = new FileResourceRule();
                resource_filerestrict _filerestrict = rule.resource_filerestrict.Where("it.RestrictCode='" + this.RestrictCode + "' and it.resource_fileresource.FileResourceCode='" + this.ResourceCode + "'", new ObjectParameter[0]).Include("resource_filestoragepath").Include("resource_filerestrictpic").FirstOrDefault <resource_filerestrict>();
                if (_filerestrict == null)
                {
                    SysAssert.InfoHintAssert("找不到此文件配置");
                }
                if (_filerestrict.FileExtension.IsNoNull())
                {
                    builder.AppendFormat("'{0}':'{1}',", "fileTypeExts", "*." + _filerestrict.FileExtension.Replace(",", ";*."));
                }
                if (_filerestrict.FileMaxSize > 0)
                {
                    builder.AppendFormat("'{0}':'{1}KB',", "fileSizeLimit", _filerestrict.FileMaxSize);
                }
                string str3 = "";
                if ((_filerestrict.FileMaxSize > 0) || _filerestrict.FileExtension.IsNoNull())
                {
                    str3 = "请上传:" + (_filerestrict.FileExtension.IsNoNull() ? ("文件类型:" + _filerestrict.FileExtension) : "") + ((_filerestrict.FileMaxSize > 0) ? ((_filerestrict.FileExtension.IsNoNull() ? "," : "") + "文件必须小于" + ((int)(_filerestrict.FileMaxSize * 0x400)).RenderFileSize()) : "");
                }
                resource_filerestrictpic _filerestrictpic = (from s in _filerestrict.resource_filerestrictpic
                                                             orderby s.ImageWidth descending
                                                             select s).FirstOrDefault <resource_filerestrictpic>();
                if ((_filerestrictpic != null) && (_filerestrictpic.ImageWidth > 0))
                {
                    object obj2 = str3;
                    str3 = string.Concat(new object[] { obj2, ",尺寸:", _filerestrictpic.ImageWidth, " x ", _filerestrictpic.ImageHeight });
                }
                if (!string.IsNullOrWhiteSpace(str3))
                {
                    builder.AppendFormat("'{0}':'{1}',", "fileTypeDesc", str3);
                }
            }
            builder.AppendFormat("'{0}':'{1}',", "fileObjName", this.FileObjName);
            builder.AppendFormat("'{0}':'{1}',", "width", this.Width.Value);
            builder.AppendFormat("'{0}':'{1}',", "height", this.Height.Value);
            builder.AppendFormat("'{0}':{1},", "onUploadSuccess", this.OnUploadSuccess);
            string onUploadError = " function(file, errorCode, errorMsg, errorString) { alert('文件:' + file.name + ' 上传失败: ' + errorString)}";

            if (!string.IsNullOrWhiteSpace(this.OnUploadError))
            {
                onUploadError = this.OnUploadError;
            }
            builder.AppendFormat("'{0}':{1}", "onUploadError", onUploadError);
            builder.AppendLine("});");
            builder.AppendLine("},10);");
            builder.AppendLine("});");
            writer.Write(builder.ToString());
            writer.RenderEndTag();
        }