Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public static Tk5UploadConfig AssertUpload(this IFieldInfoEx field)
        {
            TkDebug.AssertArgumentNull(field, "field", null);

            Tk5UploadConfig upload = field.Upload.Convert <Tk5UploadConfig>();

            TkDebug.AssertNotNull(upload, "非法调用,Field没有配置Upload单元", field);

            return(upload);
        }
Ejemplo n.º 3
0
        public static IUploadProcessor2 CreateUploadProcessor2(this Tk5UploadConfig config)
        {
            TkDebug.AssertArgumentNull(config, "config", null);

            if (config.Processor != null)
            {
                return(config.Processor.CreateObject());
            }
            return(new DbUploadProcessor());
        }
Ejemplo n.º 4
0
        public static IUploadProcessor CreateUploadProcessor(this Tk5UploadConfig config)
        {
            TkDebug.AssertArgumentNull(config, "config", null);

            if (config.Processor != null)
            {
                var creator = config.Processor as IConfigCreator <IUploadProcessor>;
                if (creator != null)
                {
                    return(creator.CreateObject());
                }
            }
            return(new DbUploadProcessor());
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        protected override IUploadProcessor2 CreateUploadProcessor(IFieldInfoEx info, UpdateKind status)
        {
            Tk5UploadConfig upload = info.AssertUpload();

            return(upload.CreateUploadProcessor2());
        }