프로젝트

일반

사용자정보

통계
| 개정판:

hytos / ID2.Manager / ID2.Manager.Dapper / Repository / FileRepository.cs @ 4142eefa

이력 | 보기 | 이력해설 | 다운로드 (1.54 KB)

1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

    
7
using ID2.Manager.Data.Models;
8

    
9
namespace ID2.Manager.Dapper.Repository
10
{
11
    public class FileRepository : BaseRepository
12
    {
13
        public FileRepository(string connectionStr) : base(connectionStr) { }
14

    
15
        public IEnumerable<FileInfo> GetFileList(string documentID)
16
        {
17
            try
18
            {
19
                string query = $@"
20
select * from dbo.Files where RefDocID=@documentID order by CreatedDate";
21
                return Query<FileInfo>(query, new { documentID });
22
            }
23
            catch (Exception ex)
24
            {
25
                throw ex;
26
            }
27
        }
28

    
29
        public bool SetFileInfo(List<FileInfo> fileList)
30
        {
31
            bool isSuccess = false;
32

    
33
            try
34
            {
35
                using (var transaction = base.BeginTransaction())
36
                {
37
                    foreach (FileInfo file in fileList)
38
                    {
39
                        string query = $@"
40
insert into dbo.Files (FileID, RefDocID, FileType, FileName, FilePath, FileData)
41
values
42
(
43
    lower(newid())
44
   ,@RefDocID
45
   ,@FileType
46
   ,@FileName
47
   ,@FilePath
48
   ,@FileData
49
)";
50
                        base.Execute(query, file, transaction);
51
                    }
52

    
53
                    transaction.Commit();
54
                    isSuccess = true;
55
                }
56
            }
57
            catch (Exception ex)
58
            {
59
                throw ex;
60
            }
61

    
62
            return isSuccess;
63
        }
64
    }
65
}
클립보드 이미지 추가 (최대 크기: 500 MB)