protected override object DeleteAttachment(IDbDataSource host, IFieldUpload upload, DataRow row, string path) { AttachmentResolver resolver = new AttachmentResolver(host); resolver.SetCommands(AdapterCommand.Delete); resolver.Delete(row[upload.ContentField].Value <int>(), false); return(resolver); }
public string Display(IFieldUpload upload, DataRow row) { TkDebug.AssertArgumentNull(upload, "upload", this); TkDebug.AssertArgumentNull(row, "row", this); return(string.Format(ObjectUtil.SysCulture, "<a href=\"{2}\" target=\"_blank\">{0}{1}</a>", row.GetString(upload.FileNameField), BaseUploadProcessor.FormatSize(row.GetValue <int>(upload.SizeField)), row.GetString(upload.ContentField))); }
public Tk5UploadConfig(IFieldUpload fieldUpload) { TkDebug.AssertArgumentNull(fieldUpload, "fieldUpload", null); FileNameField = fieldUpload.FileNameField; ServerPathField = fieldUpload.ServerPathField; ContentField = fieldUpload.ContentField; MimeTypeField = fieldUpload.MimeTypeField; SizeField = fieldUpload.SizeField; }
public override string Display(IFieldUpload upload, DataRow row) { TkDebug.AssertArgumentNull(upload, "upload", this); TkDebug.AssertArgumentNull(row, "row", this); return(string.Format(ObjectUtil.SysCulture, "<a href=\"{2}\" target=\"_blank\">{0}{1}</a>", StringUtil.EscapeHtml(row.GetString(upload.FileNameField)), FormatSize(row.GetValue <int>(upload.SizeField)), StringUtil.EscapeHtmlAttribute(row.GetString(upload.ContentField)))); }
protected override object InsertAttachment(IDbDataSource host, IFieldUpload upload, DataRow row, string path) { string fileName = Path.GetFileName(path); string newPath = Path.Combine(fUploadPath, fileName); row[upload.ServerPathField] = newPath; row[upload.ContentField] = fVirtualPath + fileName; CopyFile(path, newPath); return(null); }
protected override object InsertAttachment(IDbDataSource host, IFieldUpload upload, IFieldValueAccessor accessor, string path) { string fileName = Path.GetFileName(path); string newPath = Path.Combine(fUploadPath, fileName); accessor.SetValue(upload.ServerPathField, newPath); accessor.SetValue(upload.ContentField, fVirtualPath + fileName); CopyFile(path, newPath); return(null); }
protected override object DeleteAttachment(IDbDataSource host, IFieldUpload upload, DataRow row, string path) { try { File.Delete(path); } catch { } return(null); }
protected override object DeleteAttachment(IDbDataSource host, IFieldUpload upload, IFieldValueAccessor accessor, string path) { try { accessor.SetValue(upload.ContentField, DBNull.Value); File.Delete(path); } catch { } return(null); }
protected override object UpdateAttachment(IDbDataSource host, IFieldUpload upload, DataRow row, string oldPath, string newPath) { AttachmentResolver resolver = new AttachmentResolver(host); resolver.SetCommands(AdapterCommand.Update); resolver.Update(row[upload.ContentField].Value <int>(), row[upload.FileNameField].ToString(), newPath, row[upload.MimeTypeField].ToString(), File.ReadAllBytes(newPath), false); fDelFile = newPath; return(resolver); }
protected override object UpdateAttachment(IDbDataSource host, IFieldUpload upload, DataRow row, string oldPath, string newPath) { string fileName = Path.GetFileName(newPath); row[upload.ContentField] = fVirtualPath + fileName; //Add By Gaolq 2018/8/15 string toPath = Path.Combine(fUploadPath, fileName); row[upload.ServerPathField] = toPath; CopyFile(newPath, toPath); return(null); }
protected override object UpdateAttachment(IDbDataSource host, IFieldUpload upload, IFieldValueAccessor accessor, string oldPath, string newPath) { string fileName = Path.GetFileName(newPath); accessor.SetValue(upload.ContentField, fVirtualPath + fileName); //Add By Gaolq 2018/8/15 string toPath = Path.Combine(fUploadPath, fileName); accessor.SetValue(upload.ServerPathField, toPath); CopyFile(newPath, toPath); return(null); }
protected override object InsertAttachment(IDbDataSource host, IFieldUpload upload, DataRow row, string path) { AttachmentResolver resolver = new AttachmentResolver(host); resolver.SetCommands(AdapterCommand.Insert); byte[] fileData = File.ReadAllBytes(path); row[upload.ContentField] = resolver.Insert( row[upload.FileNameField].ToString(), path, row[upload.MimeTypeField].ToString(), fileData, false); fDelFile = path; return(resolver); }
protected override object DeleteAttachment(IDbDataSource host, IFieldUpload upload, IFieldValueAccessor accessor, string path) { try { var json = accessor.GetValue(upload.ContentField); accessor.SetValue(upload.ContentField, DBNull.Value); FileConfig config = FileConfig.ReadFromJson(json); config.Delete(); } catch { } return(null); }
protected override object DeleteAttachment(IDbDataSource host, IFieldUpload upload, DataRow row, string path) { try { var json = row[upload.ContentField].ToString(); row[upload.ContentField] = DBNull.Value; FileConfig config = FileConfig.ReadFromJson(json); config.Delete(); } catch { } return(null); }
public object Process(IDbDataSource host, IFieldUpload upload, DataRow row, UpdateKind kind) { switch (kind) { case UpdateKind.Insert: string path = row[upload.ServerPathField].ToString(); if (!string.IsNullOrEmpty(path)) { return(InsertAttachment(host, upload, row, path)); } break; case UpdateKind.Update: string originalPath = row[upload.ServerPathField, DataRowVersion.Original].ToString(); string newPath = row[upload.ServerPathField].ToString(); if (originalPath != newPath) { if (string.IsNullOrEmpty(originalPath)) { // 原先没有,当前实际是新建 return(InsertAttachment(host, upload, row, newPath)); } else if (string.IsNullOrEmpty(newPath)) { // 现在没有,当前实际是删除 var result = DeleteAttachment(host, upload, row, originalPath); row[upload.FileNameField] = DBNull.Value; return(result); } else { // 原先和现在都有,当前实际是覆盖 return(UpdateAttachment(host, upload, row, originalPath, newPath)); } } break; case UpdateKind.Delete: if (row[upload.ContentField] != DBNull.Value) { return(DeleteAttachment(host, upload, row, row[upload.ServerPathField].ToString())); } break; } return(null); }
public object Process(IDbDataSource host, IFieldUpload upload, IFieldValueAccessor provider, UpdateKind kind) { switch (kind) { case UpdateKind.Insert: string path = provider[upload.ServerPathField].ToString(); if (!string.IsNullOrEmpty(path)) { return(InsertAttachment(host, upload, provider, path)); } break; case UpdateKind.Update: string originalPath = provider.GetOriginValue(upload.ServerPathField).ToString(); string newPath = provider[upload.ServerPathField].ToString(); if (originalPath != newPath) { if (string.IsNullOrEmpty(originalPath)) { // 原先没有,当前实际是新建 return(InsertAttachment(host, upload, provider, newPath)); } else if (string.IsNullOrEmpty(newPath)) { // 现在没有,当前实际是删除 var result = DeleteAttachment(host, upload, provider, originalPath); provider.SetValue(upload.FileNameField, DBNull.Value); return(result); } else { // 原先和现在都有,当前实际是覆盖 return(UpdateAttachment(host, upload, provider, originalPath, newPath)); } } break; case UpdateKind.Delete: if (provider[upload.ContentField] != DBNull.Value) { return(DeleteAttachment(host, upload, provider, provider[upload.ServerPathField].ToString())); } break; } return(null); }
protected IEnumerable <string> GetListSelectFields(TkDbContext context, IFieldUpload upload, IFieldInfoIndexer indexer, bool showSize, bool showContent, bool showMimeType, bool showServerPath) { TkDebug.AssertArgumentNull(upload, "upload", this); TkDebug.AssertArgumentNull(indexer, "indexer", this); string result; if (showSize) { result = GetUploadItemField(context, indexer, upload.SizeField); if (result != null) { yield return(result); } } if (showContent) { result = GetUploadItemField(context, indexer, upload.ContentField); if (result != null) { yield return(result); } } if (showMimeType) { result = GetUploadItemField(context, indexer, upload.MimeTypeField); if (result != null) { yield return(result); } } if (showServerPath) { result = GetUploadItemField(context, indexer, upload.ServerPathField); if (result != null) { yield return(result); } } }
public UploadInfo CreateValue(IFieldUpload upload, DataRow row) { TkDebug.AssertArgumentNull(upload, "upload", this); TkDebug.AssertArgumentNull(row, "row", this); string fileName = row.GetString(upload.FileNameField); if (string.IsNullOrEmpty(fileName)) { return(null); } UploadInfo info = new UploadInfo { FileName = fileName, ContentType = row.GetString(upload.MimeTypeField), ServerPath = row.GetString(upload.ServerPathField), FileSize = row.GetValue <int>(upload.SizeField), WebPath = row.GetString(upload.ContentField) }; return(info); }
protected override object UpdateAttachment(IDbDataSource host, IFieldUpload upload, IFieldValueAccessor accessor, string oldPath, string newPath) { if (UseAliyunUploadMode) { FileConfig temp = FileConfig.ReadFromJson(newPath); string json = accessor.GetValue(upload.ContentField); FileConfig config = FileConfig.ReadFromJson(json); accessor.SetValue(upload.ServerPathField, config.AccessUrl); temp.RemoveTo(config); } else { string json = accessor.GetValue(upload.ContentField); FileConfig config = FileConfig.ReadFromJson(json); accessor.SetValue(upload.ServerPathField, config.AccessUrl); string originFileName = accessor.GetValue(upload.FileNameField); config.UploadFile(newPath, originFileName); } return(null); }
protected override object UpdateAttachment(IDbDataSource host, IFieldUpload upload, DataRow row, string oldPath, string newPath) { if (UseAliyunUploadMode) { FileConfig temp = FileConfig.ReadFromJson(newPath); string json = row[upload.ContentField].ToString(); FileConfig config = FileConfig.ReadFromJson(json); row[upload.ServerPathField] = config.AccessUrl; temp.RemoveTo(config); } else { string json = row[upload.ContentField].ToString(); FileConfig config = FileConfig.ReadFromJson(json); row[upload.ServerPathField] = config.AccessUrl; string originFileName = row[upload.FileNameField].ToString(); config.UploadFile(newPath, originFileName); } return(null); }
public override UploadInfo CreateValue(IFieldUpload upload, IFieldValueProvider provider) { TkDebug.AssertArgumentNull(upload, "upload", this); TkDebug.AssertArgumentNull(provider, "provider", this); string fileName = provider.GetValue(upload.FileNameField); if (string.IsNullOrEmpty(fileName)) { return(null); } UploadInfo info = new UploadInfo { FileName = fileName, ContentType = provider.GetValue(upload.MimeTypeField), ServerPath = provider.GetValue(upload.ServerPathField), FileSize = provider.GetValue <int>(upload.SizeField), WebPath = provider.GetValue(upload.ContentField) }; return(info); }
protected override object InsertAttachment(IDbDataSource host, IFieldUpload upload, DataRow row, string path) { if (UseAliyunUploadMode) { FileConfig temp = FileConfig.ReadFromJson(path); FileConfig config = new FileConfig(BucketName, temp.ObjectName); row[upload.ServerPathField] = config.AccessUrl; row[upload.ContentField] = config.ToString(); temp.RemoveTo(config); } else { string fileName = Path.GetFileNameWithoutExtension(path); FileConfig config = new FileConfig(BucketName, fileName); row[upload.ServerPathField] = config.AccessUrl; row[upload.ContentField] = config.ToString(); string originFileName = row[upload.FileNameField].ToString(); config.UploadFile(path, originFileName); } return(null); }
public IEnumerable <string> GetListSelectFields(TkDbContext context, IFieldUpload upload, IFieldInfoIndexer indexer) { return(null); }
public virtual object Process(IDbDataSource host, IFieldUpload upload, DataRow row, UpdateKind kind) { return(null); }
protected abstract object DeleteAttachment(IDbDataSource host, IFieldUpload upload, DataRow row, string path);
protected abstract object UpdateAttachment(IDbDataSource host, IFieldUpload upload, DataRow row, string oldPath, string newPath);
public abstract IEnumerable <string> GetListSelectFields(TkDbContext context, IFieldUpload upload, IFieldInfoIndexer indexer);
public abstract UploadInfo CreateValue(IFieldUpload upload, DataRow row);
public abstract string Display(IFieldUpload upload, DataRow row);
protected abstract object DeleteAttachment(IDbDataSource host, IFieldUpload upload, IFieldValueAccessor accessor, string path);