public override OutputData DoAction(IInputData input)
        {
            string context = input.QueryString["Context"];

            if (!string.IsNullOrEmpty(context))
            {
                Context = DbContextUtil.CreateDbContext(context);
            }
            AttachmentResolver resolver = new AttachmentResolver(this);

            using (resolver)
            {
                DataRow     row        = resolver.Query(input.QueryString);
                bool        noFileName = input.QueryString["NoFileName"].Value <bool>();
                FileContent content;

                if (noFileName)
                {
                    content = new FileContent(row["ContentType"].ToString(), (byte[])row["Content"]);
                }
                else
                {
                    content = new FileContent(row["ContentType"].ToString(),
                                              row["OriginalName"].ToString(), (byte[])row["Content"]);
                }
                return(OutputData.Create(content));
            }
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }