개정판 08499f5f
issue #00000 documents에 attfile 추가
Change-Id: I1b8152672a9ead34fcb1ffea4f40e200fe42f0ab
ID2.Manager/ID2.Manager.Dapper/Repository/DocumentRepository.cs | ||
---|---|---|
9 | 9 |
using ID2.Manager.Data.Models; |
10 | 10 |
|
11 | 11 |
using Dapper; |
12 |
using System.ComponentModel; |
|
13 |
using System.Reflection; |
|
12 | 14 |
|
13 | 15 |
namespace ID2.Manager.Dapper.Repository |
14 | 16 |
{ |
... | ... | |
47 | 49 |
throw ex; |
48 | 50 |
} |
49 | 51 |
} |
52 |
static string GetDescriptionFromAttribute(MemberInfo member) |
|
53 |
{ |
|
54 |
if (member == null) return null; |
|
55 |
|
|
56 |
var attrib = (DescriptionAttribute)Attribute.GetCustomAttribute(member, typeof(DescriptionAttribute), false); |
|
57 |
return (attrib?.Description ?? member.Name).ToLower(); |
|
58 |
} |
|
59 |
|
|
50 | 60 |
|
51 | 61 |
public (IEnumerable<Documents> dwgs, int totalCnt) GetDocuments(string projectCode, string personIncharge, string jobLevel, string documentNo, string isToIsDiscussion, string isFrReviewStatus, string isID2Work, string id2Status, string avevaStatus, string prodIsResult, string clientIsResult, string isGateWay, string isRegSystem) |
52 | 62 |
{ |
63 |
var map = new CustomPropertyTypeMap(typeof(AttFileInfo), (type, columnName) |
|
64 |
=> type.GetProperties().FirstOrDefault(prop => GetDescriptionFromAttribute(prop) == columnName.ToLower())); |
|
65 |
SqlMapper.SetTypeMap(typeof(AttFileInfo), map); |
|
66 |
|
|
67 |
|
|
53 | 68 |
var dynamicParameters = new DynamicParameters(); |
54 | 69 |
dynamicParameters.Add("Total", dbType: DbType.Int32, direction: ParameterDirection.Output); |
55 | 70 |
|
... | ... | |
130 | 145 |
|
131 | 146 |
try |
132 | 147 |
{ |
133 |
string query = $@" |
|
134 |
select doc.*, datediff(SECOND, doc.ID2StartDate, doc.ID2EndDate) as ID2JobTime, |
|
135 |
markus.* |
|
148 |
|
|
149 |
using (ID2.Manager.Dapper.Repository.AttFileRepository attFileRepository = new AttFileRepository(this._DbConnection.ConnectionString)) |
|
150 |
{ |
|
151 |
var test = attFileRepository.GetAttFileList("3ef4c3cd-2204-4213-8333-5a77c2b9f8cd", "toreview"); |
|
152 |
|
|
153 |
test.ToList().ForEach( |
|
154 |
x => |
|
155 |
System.Diagnostics.Debug.WriteLine(x.FileID)); |
|
156 |
} |
|
157 |
|
|
158 |
//files.[FileID],files.[FileID] as AttFileID, files.RefID, files.Category, files.FileType, files.FileName, files.FilePath, files.FileExtension, files.FileData, files.Remark, files.CreatedDate, files.Creator, |
|
159 |
string query = $@" |
|
160 |
select doc.*, |
|
161 |
files.[FileID] as FileID, files.*, |
|
162 |
markus.MARKUP_DATA_ID as MARKUP_DATA_ID, markus.*, |
|
163 |
datediff(SECOND, doc.ID2StartDate, doc.ID2EndDate) as ID2JobTime |
|
136 | 164 |
from dbo.Documents doc |
165 |
LEFT OUTER JOIN AttachFIles files ON doc.DocID = fIles.RefID |
|
137 | 166 |
LEFT OUTER JOIN |
138 |
(SELECT [PROJECT_NO] as PROJECT_NO |
|
167 |
(SELECT [MARKUP_DATA_ID] |
|
168 |
,[PROJECT_NO] as PROJECT_NO |
|
139 | 169 |
,[DOCUMENT_ID] as DocumentNo |
140 |
,[MARKUP_DATA_ID] |
|
170 |
|
|
141 | 171 |
,[PAGENUMBER] |
142 | 172 |
,[Text] as TEXT |
143 | 173 |
,[CREATE_DATE] as CREATE_DATE |
144 | 174 |
,[NAME] as CREATE_USER |
145 |
FROM [markus_SEC].dbo.[ViewMarkupData]) markus
|
|
175 |
FROM ViewMarkupData) markus
|
|
146 | 176 |
ON doc.DocumentNo = markus.DocumentNo |
147 | 177 |
where doc.IsDeleted=0 {sbWhere} |
148 | 178 |
order by doc.Seq |
... | ... | |
157 | 187 |
|
158 | 188 |
var docDictionary = new Dictionary<string, Documents>(); |
159 | 189 |
|
160 |
var ret = MultiQuery<Documents, MarkupText, Documents>(query, |
|
161 |
(document, markusText) => |
|
190 |
var ret = MultiQuery<Documents, AttFileInfo, MarkupText, Documents>(query,
|
|
191 |
(document, attfile, markusText) =>
|
|
162 | 192 |
{ |
163 | 193 |
Documents doc; |
164 | 194 |
|
165 |
if (!docDictionary.TryGetValue(document.DocumentNo, out doc))
|
|
195 |
if (!docDictionary.TryGetValue(document.DocID, out doc))
|
|
166 | 196 |
{ |
167 | 197 |
doc = document; |
198 |
docDictionary.Add(doc.DocID, doc); |
|
199 |
} |
|
200 |
|
|
201 |
if (markusText != null) |
|
202 |
{ |
|
168 | 203 |
doc.Markups = doc.Markups ?? new List<MarkupText>(); |
169 |
docDictionary.Add(doc.DocumentNo, doc); |
|
204 |
|
|
205 |
if (!doc.Markups.Any(x => x.MARKUP_DATA_ID == markusText.MARKUP_DATA_ID)) |
|
206 |
{ |
|
207 |
doc.Markups.Add(markusText); |
|
208 |
} |
|
209 |
} |
|
210 |
|
|
211 |
if (attfile != null) |
|
212 |
{ |
|
213 |
doc.AttFiles = doc.AttFiles ?? new List<AttFileInfo>(); |
|
214 |
System.Diagnostics.Debug.WriteLine(attfile.FileName); |
|
215 |
if (!doc.AttFiles.Any(x => x.FileID == attfile.FileID)) |
|
216 |
{ |
|
217 |
doc.AttFiles.Add(attfile); |
|
218 |
} |
|
170 | 219 |
} |
171 | 220 |
|
172 |
doc.Markups.Add(markusText); |
|
173 | 221 |
return doc; |
174 | 222 |
|
175 |
}, dynamicParameters, splitOn: "DocumentNo").Distinct();
|
|
223 |
}, dynamicParameters, splitOn: "DocID,FileID,MARKUP_DATA_ID").Distinct();
|
|
176 | 224 |
|
177 | 225 |
int totalCount = dynamicParameters.Get<int>("Total"); |
178 | 226 |
|
내보내기 Unified diff