hytos / ID2.Manager / ID2.Manager.Dapper / Repository / ExcelDataRepository.cs @ f37c5383
이력 | 보기 | 이력해설 | 다운로드 (2.27 KB)
1 | 8eca8767 | taeseongkim | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using System.Threading.Tasks; |
||
6 | using Dapper; |
||
7 | using ID2.Manager.Data.Models; |
||
8 | |||
9 | namespace ID2.Manager.Dapper.Repository |
||
10 | { |
||
11 | public class ExcelDataRepository : BaseRepository |
||
12 | { |
||
13 | public ExcelDataRepository(string connectionStr) : base(connectionStr) { } |
||
14 | |||
15 | public IEnumerable<ExcelData> GetExcelData(string FileName,string WorksheetName) |
||
16 | { |
||
17 | try |
||
18 | { |
||
19 | 57ea162e | yoush97 | string query = $@"select * from dbo.ImportExcel where [FILE_NAME] = @FileName and WORKSHEET_NAME = @WorksheetName order by ROW_INDEX, COUMMN_INDEX"; |
20 | 8eca8767 | taeseongkim | var dynamicParameters = new DynamicParameters(); |
21 | dynamicParameters.Add("@FileName", FileName); |
||
22 | dynamicParameters.Add("@WorksheetName", WorksheetName); |
||
23 | |||
24 | return Query<ExcelData>(query, dynamicParameters); |
||
25 | } |
||
26 | catch (Exception ex) |
||
27 | { |
||
28 | throw ex; |
||
29 | } |
||
30 | } |
||
31 | |||
32 | public IEnumerable<ExcelDataInfo> GetExcelDataInfo() |
||
33 | { |
||
34 | try |
||
35 | { |
||
36 | string query = $@"select [FILE_NAME],WORKSHEET_NAME from dbo.ImportExcel group by [FILE_NAME],WORKSHEET_NAME"; |
||
37 | |||
38 | return Query<ExcelDataInfo>(query); |
||
39 | } |
||
40 | catch (Exception ex) |
||
41 | { |
||
42 | throw ex; |
||
43 | } |
||
44 | } |
||
45 | 2201f8c4 | yoush97 | |
46 | public bool DeleteExcelData(string FileName, string WorksheetName) |
||
47 | { |
||
48 | bool isSuccess = false; |
||
49 | |||
50 | try |
||
51 | { |
||
52 | using (var transaction = base.BeginTransaction()) |
||
53 | { |
||
54 | string query = $@"delete from dbo.ImportExcel where [FILE_NAME] = @FileName and WORKSHEET_NAME = @WorksheetName"; |
||
55 | var dynamicParameters = new DynamicParameters(); |
||
56 | dynamicParameters.Add("@FileName", FileName); |
||
57 | dynamicParameters.Add("@WorksheetName", WorksheetName); |
||
58 | |||
59 | Execute(query, dynamicParameters, transaction); |
||
60 | |||
61 | transaction.Commit(); |
||
62 | isSuccess = true; |
||
63 | } |
||
64 | } |
||
65 | catch (Exception ex) |
||
66 | { |
||
67 | throw ex; |
||
68 | } |
||
69 | |||
70 | return isSuccess; |
||
71 | } |
||
72 | 8eca8767 | taeseongkim | } |
73 | } |