Esempio n. 1
0
        protected override object DeleteAttachment(IDbDataSource host, IFieldUpload upload,
                                                   IFieldValueAccessor accessor, string path)
        {
            AttachmentResolver resolver = new AttachmentResolver(host);

            resolver.SetCommands(AdapterCommand.Delete);
            resolver.Delete(accessor[upload.ContentField].Value <int>(), false);
            return(resolver);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        protected override object UpdateAttachment(IDbDataSource host, IFieldUpload upload,
                                                   IFieldValueAccessor accessor, string oldPath, string newPath)
        {
            AttachmentResolver resolver = new AttachmentResolver(host);

            resolver.SetCommands(AdapterCommand.Update);
            resolver.Update(accessor[upload.ContentField].Value <int>(),
                            accessor[upload.FileNameField].ToString(), newPath,
                            accessor[upload.MimeTypeField].ToString(),
                            File.ReadAllBytes(newPath), false);

            fDelFile = newPath;
            return(resolver);
        }
Esempio n. 6
0
        protected override object InsertAttachment(IDbDataSource host, IFieldUpload upload,
                                                   IFieldValueAccessor accessor, string path)
        {
            AttachmentResolver resolver = new AttachmentResolver(host);

            resolver.SetCommands(AdapterCommand.Insert);
            byte[] fileData = File.ReadAllBytes(path);
            accessor.SetValue(upload.ContentField, resolver.Insert(
                                  accessor[upload.FileNameField].ToString(), path,
                                  accessor[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);
 }
Esempio n. 8
0
        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 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 InsertAttachment(IDbDataSource host, IFieldUpload upload,
                                                   IFieldValueAccessor accessor, string path)
        {
            if (UseAliyunUploadMode)
            {
                FileConfig temp   = FileConfig.ReadFromJson(path);
                FileConfig config = new FileConfig(BucketName, temp.ObjectName);
                accessor.SetValue(upload.ServerPathField, config.AccessUrl);
                accessor.SetValue(upload.ContentField, config.ToString());

                temp.RemoveTo(config);
            }
            else
            {
                string     fileName = Path.GetFileNameWithoutExtension(path);
                FileConfig config   = new FileConfig(BucketName, fileName);
                accessor.SetValue(upload.ServerPathField, config.AccessUrl);
                accessor.SetValue(upload.ContentField, config.ToString());
                string originFileName = accessor.GetValue(upload.FileNameField);

                config.UploadFile(path, originFileName);
            }
            return(null);
        }
 public virtual IComparer <int> NewComparer(IFieldValueAccessor fieldValueAccessor, BigSegmentedArray counts)
 {
     return(new FacetValueComparerFactoryComparer());
 }
Esempio n. 12
0
 public virtual IComparer <int> NewComparator(IFieldValueAccessor valueList, BigSegmentedArray counts)
 {
     return(new FacetHitComparer {
         counts = counts
     });
 }
Esempio n. 13
0
 protected abstract object DeleteAttachment(IDbDataSource host, IFieldUpload upload,
                                            IFieldValueAccessor accessor, string path);
Esempio n. 14
0
 protected abstract object UpdateAttachment(IDbDataSource host, IFieldUpload upload,
                                            IFieldValueAccessor accessor, string oldPath, string newPath);