public string DisplayValue(object value, Tk5FieldInfoEx field, IFieldValueProvider rowValue) { TkDebug.AssertArgumentNull(field, "field", this); if (DisplayUtil.IsNull(value)) { return(string.Empty); } if (field.Upload != null) { Tk5UploadConfig upload = field.AssertUpload(); IUploadProcessor2 processor = upload.CreateUploadProcessor2(); //IFieldValueProvider provider = new DataRowFieldValueProvider(row, row.Table.DataSet); string url = processor.Display(upload, rowValue); HtmlAttribute cssAttr = string.IsNullOrEmpty(CssClass) ? null : new HtmlAttribute("class", CssClass); HtmlAttributeBuilder builder = new HtmlAttributeBuilder(); builder.Add("src", url); builder.Add(cssAttr); return(string.Format(ObjectUtil.SysCulture, "<img {0} />", builder.CreateAttribute())); } return(string.Empty); }
public static string DisplayUpload(this Tk5FieldInfoEx field, IFieldValueProvider row) { TkDebug.AssertArgumentNull(field, "field", null); Tk5UploadConfig upload = field.AssertUpload(); IUploadProcessor2 processor = upload.CreateUploadProcessor2(); return(processor.Display(upload, row)); }
public static string Upload(this Tk5FieldInfoEx field, IFieldValueProvider provider, bool needId) { TkDebug.AssertArgumentNull(field, "field", null); var upload = field.AssertUpload(); HtmlAttributeBuilder builder = new HtmlAttributeBuilder(); builder.Add("data-control", "Upload"); builder.Add("data-fileSize", upload.SizeField); builder.Add("data-serverPath", upload.ServerPathField); builder.Add("data-contentType", upload.MimeTypeField); AddNormalAttribute(field, builder, field.NickName, needId, true); int maxSize = upload.MaxSize; if (maxSize == 0) { maxSize = BaseGlobalVariable.Current.DefaultValue .GetSimpleDefaultValue("DefaultMaxUploadSize").Value <int>(DEFAULT_UPLOAD_SIZE); } builder.Add("data-maxSize", maxSize); IUploadProcessor2 processor = upload.CreateUploadProcessor2(); UploadInfo info = provider == null ? null : processor.CreateValue(upload, provider); if (info != null) { builder.Add("data-value", info.ToJson()); } IUploadExtension extension = processor as IUploadExtension; if (extension != null) { string uploadUrl = extension.UploadUrl; if (!string.IsNullOrEmpty(uploadUrl)) { builder.Add("data-url", uploadUrl); } } return(string.Format(ObjectUtil.SysCulture, Html.Upload, builder.CreateAttribute(), ERROR_LABEL)); }
public string DisplayValue(object value, Tk5FieldInfoEx field, IFieldValueProvider rowValue) { TkDebug.AssertArgumentNull(field, "field", this); if (DisplayUtil.IsNull(value)) { return(string.Empty); } if (field.Upload != null) { Tk5UploadConfig upload = field.AssertUpload(); IUploadProcessor2 processor = upload.CreateUploadProcessor2(); //IFieldValueProvider provider = new DataRowFieldValueProvider(row, row.Table.DataSet); string url = processor.Display(upload, rowValue); return(string.Format(ObjectUtil.SysCulture, "<a href=\"{2}\" target=\"_blank\">{0}{1}</a>", StringUtil.EscapeHtml(rowValue.GetValue(upload.FileNameField)), BaseUploadProcessor.FormatSize(rowValue.GetValue <int>(upload.SizeField)), StringUtil.EscapeHtmlAttribute(url))); } return(string.Empty); }