示例#1
0
        public AttachmentInfoCollection GetAttachmentsInfo(HttpContext context)
        {
            YZRequest request = new YZRequest(context);

            string[] ids = request.GetString("fileids").Split(',', ';');

            AttachmentInfoCollection attachments = new AttachmentInfoCollection();

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    attachments = AttachmentManager.GetAttachmentsInfo(provider, cn, ids);
                }
            }

            AttachmentInfoCollection rv = new AttachmentInfoCollection();

            foreach (string id in ids)
            {
                AttachmentInfo attachmentInfo = attachments.TryGetItem(id);
                if (attachmentInfo != null)
                {
                    rv.Add(attachmentInfo);
                }
            }
            return(rv);
        }
示例#2
0
    public static AttachmentInfoCollection GetAttachmentsInfo(IYZDbProvider provider, IDbConnection cn, string[] fileIds)
    {
        AttachmentInfoCollection rv = new AttachmentInfoCollection();

        using (IDataReader reader = provider.GetAttachmentsInfo(cn, fileIds))
        {
            while (reader.Read())
            {
                rv.Add(new AttachmentInfo(reader, AttachmentManager.AttachmentRootPath));
            }
        }

        return(rv);
    }
示例#3
0
        public AttachmentInfoCollection GetAllAttachmentInfo(IYZDbProvider provider, IDbConnection cn)
        {
            AttachmentInfoCollection attachments = new AttachmentInfoCollection();

            foreach (File file in this)
            {
                AttachmentInfo attachment = AttachmentManager.TryGetAttachmentInfo(provider, cn, file.FileID);
                if (attachment != null)
                {
                    attachments.Add(attachment);
                }
            }

            return(attachments);
        }
示例#4
0
    public static AttachmentInfo TryGetAttachmentInfo(IYZDbProvider provider, IDbConnection cn, string fileId)
    {
        if (String.IsNullOrEmpty(fileId))
        {
            throw new Exception(Resources.YZStrings.Aspx_Upload_EmptyFileID);
        }

        AttachmentInfoCollection attachments = AttachmentManager.GetAttachmentsInfo(provider, cn, new string[] { fileId });

        if (attachments.Count == 0)
        {
            return(null);
        }

        return(attachments[0]);
    }
示例#5
0
        public static AttachmentInfo GetAttachmentInfo(IDbConnection cn, string fileId)
        {
            if (String.IsNullOrEmpty(fileId))
            {
                throw new Exception(null);
            }

            AttachmentInfoCollection attachments = YZAttachmentHelper.GetAttachmentsInfo(cn, new string[] { fileId });

            if (attachments.Count == 0)
            {
                throw new Exception(null);
            }

            return(attachments[0]);
        }
示例#6
0
        public static string GetNewFileName(IYZDbProvider provider, IDbConnection cn, int folderid, string oldName)
        {
            string                   perfix      = Path.GetFileNameWithoutExtension(oldName);
            string                   ext         = Path.GetExtension(oldName);
            FileCollection           files       = DirectoryManager.GetFiles(provider, cn, folderid, null, null, -1);
            AttachmentInfoCollection attachments = files.GetAllAttachmentInfo(provider, cn);
            BPMObjectNameCollection  fileNames   = attachments.Names;

            for (int i = 1; true; i++)
            {
                string newFileName = perfix + "(" + i.ToString() + ")" + ext;

                if (fileNames.Contains(newFileName))
                {
                    continue;
                }

                return(newFileName);
            }
        }