hytos / ID2.Manager / ID2.Manager.Dapper / Repository / DocumentRepository.cs @ e5ade387
이력 | 보기 | 이력해설 | 다운로드 (20.3 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 System.Data; |
8 |
|
9 |
using ID2.Manager.Data.Models; |
10 |
|
11 |
using Dapper; |
12 |
using System.ComponentModel; |
13 |
using System.Reflection; |
14 |
|
15 |
namespace ID2.Manager.Dapper.Repository |
16 |
{ |
17 |
public class DocumentRepository : BaseRepository |
18 |
{ |
19 |
public DocumentRepository(string connectionStr) : base(connectionStr) { } |
20 |
|
21 |
public IEnumerable<Documents> GetAllDocuments(string projectGroupID) |
22 |
{ |
23 |
var dynamicParameters = new DynamicParameters(); |
24 |
StringBuilder sbWhere = new StringBuilder(); |
25 |
var parameters = new Dictionary<string, object>(); |
26 |
if (!string.IsNullOrEmpty(projectGroupID)) |
27 |
{ |
28 |
sbWhere.Append(" and doc.RefProjectCode in (select Code from dbo.Projects where ParentID=@RefGroupID) "); |
29 |
parameters.Add("RefGroupID", projectGroupID); |
30 |
} |
31 |
|
32 |
try |
33 |
{ |
34 |
string query = $@" |
35 |
select doc.* |
36 |
from dbo.Documents doc |
37 |
where doc.IsDeleted=0 {sbWhere} |
38 |
order by doc.Seq;"; |
39 |
|
40 |
if (parameters.Count > 0) |
41 |
{ |
42 |
dynamicParameters.AddDynamicParams(parameters); |
43 |
} |
44 |
|
45 |
return Query<Documents>(query, dynamicParameters); |
46 |
} |
47 |
catch (Exception ex) |
48 |
{ |
49 |
throw ex; |
50 |
} |
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 |
|
60 |
|
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) |
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 |
|
68 |
var dynamicParameters = new DynamicParameters(); |
69 |
dynamicParameters.Add("Total", dbType: DbType.Int32, direction: ParameterDirection.Output); |
70 |
|
71 |
StringBuilder sbWhere = new StringBuilder(); |
72 |
StringBuilder sbTotalWhere = new StringBuilder(); |
73 |
var parameters = new Dictionary<string, object>(); |
74 |
if (!string.IsNullOrEmpty(projectCode)) |
75 |
{ |
76 |
sbWhere.Append(" and doc.RefProjectCode=@RefProjectCode "); |
77 |
sbTotalWhere.Append(" and doc.RefProjectCode=@RefProjectCode "); |
78 |
parameters.Add("RefProjectCode", projectCode); |
79 |
} |
80 |
if (!string.IsNullOrEmpty(personIncharge)) |
81 |
{ |
82 |
sbWhere.Append(" and doc.PersonInCharge=@PersonInCharge "); |
83 |
parameters.Add("PersonInCharge", personIncharge); |
84 |
} |
85 |
if (!string.IsNullOrEmpty(jobLevel)) |
86 |
{ |
87 |
sbWhere.Append(" and doc.JobLevel=@JobLevel "); |
88 |
parameters.Add("JobLevel", jobLevel); |
89 |
} |
90 |
if (!string.IsNullOrEmpty(documentNo)) |
91 |
{ |
92 |
sbWhere.Append(" and doc.DocumentNo like '%' + @DocumentNo +'%' "); |
93 |
parameters.Add("DocumentNo", documentNo); |
94 |
} |
95 |
|
96 |
if (!string.IsNullOrEmpty(isToIsDiscussion)) |
97 |
{ |
98 |
sbWhere.Append(" and doc.ToIsDiscussion=@ToIsDiscussion "); |
99 |
parameters.Add("ToIsDiscussion", isToIsDiscussion); |
100 |
} |
101 |
|
102 |
if (!string.IsNullOrEmpty(isFrReviewStatus)) |
103 |
{ |
104 |
sbWhere.Append(" and doc.FrReviewStatus=@FrReviewStatus "); |
105 |
parameters.Add("FrReviewStatus", isFrReviewStatus); |
106 |
} |
107 |
|
108 |
if (!string.IsNullOrEmpty(isID2Work)) |
109 |
{ |
110 |
sbWhere.Append(" and doc.IsID2Work=@IsID2Work "); |
111 |
parameters.Add("IsID2Work", isID2Work); |
112 |
} |
113 |
|
114 |
if (!string.IsNullOrEmpty(id2Status)) |
115 |
{ |
116 |
sbWhere.Append(" and doc.ID2Status=@ID2Status "); |
117 |
parameters.Add("ID2Status", id2Status); |
118 |
} |
119 |
if (!string.IsNullOrEmpty(avevaStatus)) |
120 |
{ |
121 |
sbWhere.Append(" and doc.AVEVAStatus=@AVEVAStatus "); |
122 |
parameters.Add("AVEVAStatus", avevaStatus); |
123 |
} |
124 |
|
125 |
if (!string.IsNullOrEmpty(prodIsResult)) |
126 |
{ |
127 |
sbWhere.Append(" and doc.ProdIsResult=@ProdIsResult "); |
128 |
parameters.Add("ProdIsResult", prodIsResult); |
129 |
} |
130 |
if (!string.IsNullOrEmpty(clientIsResult)) |
131 |
{ |
132 |
sbWhere.Append(" and doc.ClientIsResult=@ClientIsResult "); |
133 |
parameters.Add("ClientIsResult", clientIsResult); |
134 |
} |
135 |
if (!string.IsNullOrEmpty(isGateWay)) |
136 |
{ |
137 |
sbWhere.Append(" and doc.DTIsGateWay=@DTIsGateWay "); |
138 |
parameters.Add("DTIsGateWay", isGateWay); |
139 |
} |
140 |
if (!string.IsNullOrEmpty(isRegSystem)) |
141 |
{ |
142 |
sbWhere.Append(" and doc.DTIsRegSystem=@DTIsRegSystem "); |
143 |
parameters.Add("DTIsRegSystem", isRegSystem); |
144 |
} |
145 |
|
146 |
try |
147 |
{ |
148 |
|
149 |
//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, |
150 |
string query = $@" |
151 |
select doc.*, datediff(SECOND, doc.ID2StartDate, doc.ID2EndDate) as ID2JobTime, |
152 |
files.[FileID] as FileID, files.*, |
153 |
markus.MARKUP_DATA_ID as MARKUP_DATA_ID, markus.*, |
154 |
datediff(SECOND, doc.ID2StartDate, doc.ID2EndDate) as ID2JobTime |
155 |
from dbo.Documents doc |
156 |
LEFT OUTER JOIN AttachFIles files ON doc.DocID = fIles.RefID |
157 |
LEFT OUTER JOIN |
158 |
(SELECT [MARKUP_DATA_ID] |
159 |
,[PROJECT_NO] as PROJECT_NO |
160 |
,[DOCUMENT_ID] as DocumentNo |
161 |
|
162 |
,[PAGENUMBER] |
163 |
,[Text] as TEXT |
164 |
,[CREATE_DATE] as CREATE_DATE |
165 |
,[NAME] as CREATE_USER |
166 |
FROM ViewMarkupData) markus |
167 |
ON doc.DocumentNo = markus.DocumentNo |
168 |
where doc.IsDeleted=0 {sbWhere} |
169 |
order by doc.Seq |
170 |
|
171 |
select @Total=count(*) from dbo.Documents doc where doc.IsDeleted=0 {sbTotalWhere} |
172 |
select @Total;"; |
173 |
|
174 |
if (parameters.Count > 0) |
175 |
{ |
176 |
dynamicParameters.AddDynamicParams(parameters); |
177 |
} |
178 |
|
179 |
var docDictionary = new Dictionary<string, Documents>(); |
180 |
|
181 |
var ret = MultiQuery<Documents, AttFileInfo, MarkupText, Documents>(query, |
182 |
(document, attfile, markusText) => |
183 |
{ |
184 |
Documents doc; |
185 |
|
186 |
if (!docDictionary.TryGetValue(document.DocID, out doc)) |
187 |
{ |
188 |
doc = document; |
189 |
docDictionary.Add(doc.DocID, doc); |
190 |
} |
191 |
|
192 |
if (markusText != null) |
193 |
{ |
194 |
doc.Markups = doc.Markups ?? new List<MarkupText>(); |
195 |
|
196 |
if (!doc.Markups.Any(x => x.MARKUP_DATA_ID == markusText.MARKUP_DATA_ID)) |
197 |
{ |
198 |
doc.Markups.Add(markusText); |
199 |
} |
200 |
} |
201 |
|
202 |
if (attfile != null) |
203 |
{ |
204 |
doc.AttFiles = doc.AttFiles ?? new List<AttFileInfo>(); |
205 |
System.Diagnostics.Debug.WriteLine(attfile.FileName); |
206 |
if (!doc.AttFiles.Any(x => x.FileID == attfile.FileID)) |
207 |
{ |
208 |
doc.AttFiles.Add(attfile); |
209 |
} |
210 |
} |
211 |
|
212 |
return doc; |
213 |
|
214 |
}, dynamicParameters, splitOn: "DocID,FileID,MARKUP_DATA_ID").Distinct(); |
215 |
|
216 |
int totalCount = dynamicParameters.Get<int>("Total"); |
217 |
|
218 |
return (ret, totalCount); |
219 |
} |
220 |
catch (Exception ex) |
221 |
{ |
222 |
throw ex; |
223 |
} |
224 |
} |
225 |
|
226 |
public bool SetDocumentData(List<Documents> docList, List<Documents> delDocList, string userId) |
227 |
{ |
228 |
bool isSuccess = false; |
229 |
|
230 |
try |
231 |
{ |
232 |
using (var transaction = base.BeginTransaction()) |
233 |
{ |
234 |
string query = string.Empty; |
235 |
|
236 |
if (delDocList.Count > 0) |
237 |
{ |
238 |
string docIDList = string.Join("','", delDocList.Where(x => !string.IsNullOrEmpty(x.DocID)).Select(x => x.DocID).ToList()); |
239 |
|
240 |
if (docIDList.Length > 0) |
241 |
{ |
242 |
query = $@" |
243 |
update dbo.Documents |
244 |
set IsDeleted=1 |
245 |
,DeletedDate=getdate(), |
246 |
,DeletedUser=@DeletedUser |
247 |
where DocID in ('{docIDList}');"; |
248 |
base.Execute(query, new { DeletedUser = userId }, transaction); |
249 |
} |
250 |
} |
251 |
|
252 |
foreach (Documents doc in docList) |
253 |
{ |
254 |
if (string.IsNullOrEmpty(doc.DocID)) |
255 |
{ |
256 |
doc.RegisteredUser = userId; |
257 |
query = $@" |
258 |
declare @tbdoc table(docid varchar(36)) |
259 |
insert into dbo.Documents |
260 |
( |
261 |
DocID |
262 |
,DocumentNo |
263 |
,RevisonNo |
264 |
,RefProjectCode |
265 |
,DocFilePath |
266 |
,DocFileName |
267 |
,JobLevel |
268 |
,IsTypical |
269 |
,PersonInCharge |
270 |
,RegisteredDate |
271 |
,RegisteredUser |
272 |
,ToIsDiscussion |
273 |
,ToRemarks |
274 |
,ToCreator |
275 |
,ToCapture |
276 |
,ToIsMarkup |
277 |
,FrReviewStatus |
278 |
,FrRemarks |
279 |
,FrCreator |
280 |
,FrCapture |
281 |
,FrIsMarkup |
282 |
,IsID2Work |
283 |
,ID2Connection |
284 |
,ID2StartDate |
285 |
,ID2EndDate |
286 |
,ID2Status |
287 |
,ID2Issues |
288 |
,AVEVAConnection |
289 |
,AVEVAConvertDate |
290 |
,AVEVAReviewDate |
291 |
,AVEVAStatus |
292 |
,AVEVAIssues |
293 |
,ReviewFilePath |
294 |
,ReviewFileName |
295 |
,ProdReviewer |
296 |
,ProdIsResult |
297 |
,ProdRemarks |
298 |
,ClientReviewer |
299 |
,ClientIsResult |
300 |
,ClientRemarks |
301 |
,DTIsGateWay |
302 |
,DTIsImport |
303 |
,DTIsRegSystem |
304 |
,DTRemarks |
305 |
) |
306 |
output inserted.DocID into @tbdoc |
307 |
values |
308 |
( |
309 |
lower(newid()) |
310 |
,@DocumentNo |
311 |
,@RevisonNo |
312 |
,@RefProjectCode |
313 |
,@DocFilePath |
314 |
,@DocFileName |
315 |
,@JobLevel |
316 |
,@IsTypical |
317 |
,@PersonInCharge |
318 |
,getdate() |
319 |
,@RegisteredUser |
320 |
,@ToIsDiscussion |
321 |
,@ToRemarks |
322 |
,@ToCreator |
323 |
,@ToCapture |
324 |
,@ToIsMarkup |
325 |
,@FrReviewStatus |
326 |
,@FrRemarks |
327 |
,@FrCreator |
328 |
,@FrCapture |
329 |
,@FrIsMarkup |
330 |
,@IsID2Work |
331 |
,@ID2Connection |
332 |
,@ID2StartDate |
333 |
,@ID2EndDate |
334 |
,@ID2Status |
335 |
,@ID2Issues |
336 |
,@AVEVAConnection |
337 |
,@AVEVAConvertDate |
338 |
,@AVEVAReviewDate |
339 |
,@AVEVAStatus |
340 |
,@AVEVAIssues |
341 |
,@ReviewFilePath |
342 |
,@ReviewFileName |
343 |
,@ProdReviewer |
344 |
,@ProdIsResult |
345 |
,@ProdRemarks |
346 |
,@ClientReviewer |
347 |
,@ClientIsResult |
348 |
,@ClientRemarks |
349 |
,@DTIsGateWay |
350 |
,@DTIsImport |
351 |
,@DTIsRegSystem |
352 |
,@DTRemarks |
353 |
) |
354 |
|
355 |
if @@rowcount > 0 |
356 |
begin |
357 |
select docid from @tbdoc |
358 |
end |
359 |
else |
360 |
begin |
361 |
select '' |
362 |
end;"; |
363 |
} |
364 |
else |
365 |
{ |
366 |
doc.ModifiedUser = userId; |
367 |
query = $@" |
368 |
update dbo.Documents |
369 |
set DocumentNo=@DocumentNo |
370 |
,RevisonNo=@RevisonNo |
371 |
,RefProjectCode=@RefProjectCode |
372 |
,DocFilePath=@DocFilePath |
373 |
,DocFileName=@DocFileName |
374 |
,JobLevel=@JobLevel |
375 |
,IsTypical=@IsTypical |
376 |
,PersonInCharge=@PersonInCharge |
377 |
,ModifiedDate=getdate() |
378 |
,ModifiedUser=@ModifiedUser |
379 |
,ToIsDiscussion=@ToIsDiscussion |
380 |
,ToRemarks=@ToRemarks |
381 |
,ToCreator=@ToCreator |
382 |
,ToCapture=@ToCapture |
383 |
,ToIsMarkup=@ToIsMarkup |
384 |
,FrReviewStatus=@FrReviewStatus |
385 |
,FrRemarks=@FrRemarks |
386 |
,FrCreator=@FrCreator |
387 |
,FrCapture=@FrCapture |
388 |
,FrIsMarkup=@FrIsMarkup |
389 |
,IsID2Work=@IsID2Work |
390 |
,ID2Connection=@ID2Connection |
391 |
,ID2StartDate=@ID2StartDate |
392 |
,ID2EndDate=@ID2EndDate |
393 |
,ID2Status=@ID2Status |
394 |
,ID2Issues=@ID2Issues |
395 |
,AVEVAConnection=@AVEVAConnection |
396 |
,AVEVAConvertDate=@AVEVAConvertDate |
397 |
,AVEVAReviewDate=@AVEVAReviewDate |
398 |
,AVEVAStatus=@AVEVAStatus |
399 |
,AVEVAIssues=@AVEVAIssues |
400 |
,ReviewFilePath=@ReviewFilePath |
401 |
,ReviewFileName=@ReviewFileName |
402 |
,ProdReviewer=@ProdReviewer |
403 |
,ProdIsResult=@ProdIsResult |
404 |
,ProdRemarks=@ProdRemarks |
405 |
,ClientReviewer=@ClientReviewer |
406 |
,ClientIsResult=@ClientIsResult |
407 |
,ClientRemarks=@ClientRemarks |
408 |
,DTIsGateWay=@DTIsGateWay |
409 |
,DTIsImport=@DTIsImport |
410 |
,DTIsRegSystem=@DTIsRegSystem |
411 |
,DTRemarks=@DTRemarks |
412 |
where DocID=@DocID |
413 |
|
414 |
if @@rowcount > 0 |
415 |
begin |
416 |
select @DocID |
417 |
end |
418 |
else |
419 |
begin |
420 |
select '' |
421 |
end;"; |
422 |
} |
423 |
string refID = base.QueryFirstOrDefault<string>(query, doc, transaction); |
424 |
|
425 |
if (doc.AttFiles != null && doc.AttFiles.Count > 0) |
426 |
{ |
427 |
string attDelIDList = string.Join("','", doc.AttFiles.Where(x => !string.IsNullOrEmpty(x.FileID)).Select(x => x.FileID).ToList()); |
428 |
|
429 |
if (!string.IsNullOrEmpty(refID) && attDelIDList.Length > 0) |
430 |
{ |
431 |
query = $@" |
432 |
delete from dbo.AttachFIles |
433 |
where RefID=@RefID and FileID in ('{attDelIDList}');"; |
434 |
base.Execute(query, new { RefID = refID }, transaction); |
435 |
} |
436 |
|
437 |
foreach (AttFileInfo attFile in doc.AttFiles) |
438 |
{ |
439 |
if (string.IsNullOrEmpty(attFile.RefID)) |
440 |
{ |
441 |
attFile.RefID = refID; |
442 |
attFile.Creator = userId; |
443 |
|
444 |
query = $@" |
445 |
insert into dbo.AttachFIles (FileID,RefID,Category,FileType,FileName,FilePath,FileExtension,FileData,Creator) |
446 |
values |
447 |
( |
448 |
lower(newid()) |
449 |
,@RefID |
450 |
,@Category |
451 |
,@FileType |
452 |
,@FileName |
453 |
,@FilePath |
454 |
,@FileExtension |
455 |
,@FileData |
456 |
,@Creator |
457 |
)"; |
458 |
|
459 |
base.Execute(query, attFile, transaction); |
460 |
} |
461 |
} |
462 |
} |
463 |
} |
464 |
|
465 |
transaction.Commit(); |
466 |
isSuccess = true; |
467 |
} |
468 |
} |
469 |
catch (Exception ex) |
470 |
{ |
471 |
throw ex; |
472 |
} |
473 |
|
474 |
return isSuccess; |
475 |
} |
476 |
|
477 |
public Documents SetDocumentDataField(Documents doc, string userId) |
478 |
{ |
479 |
Documents resultData = null; |
480 |
|
481 |
try |
482 |
{ |
483 |
using (var transaction = base.BeginTransaction()) |
484 |
{ |
485 |
string query = string.Empty; |
486 |
|
487 |
if (!string.IsNullOrEmpty(doc.DocID)) |
488 |
{ |
489 |
StringBuilder sbSet = new StringBuilder(); |
490 |
var parameters = new Dictionary<string, object>(); |
491 |
|
492 |
#region Update 할 목록 |
493 |
if (doc.ID2StartDate != null) |
494 |
{ |
495 |
sbSet.Append(" ,ID2StartDate=(case when ID2StartDate is null then @DateTimeNow else ID2StartDate end) "); |
496 |
parameters.Add("ID2StartDate", doc.ID2StartDate); |
497 |
} |
498 |
|
499 |
if (doc.Worker != null) |
500 |
{ |
501 |
sbSet.Append(" ,Worker=@Worker "); |
502 |
parameters.Add("Worker", doc.Worker); |
503 |
} |
504 |
#endregion |
505 |
|
506 |
if (parameters.Count > 0) |
507 |
{ |
508 |
sbSet.Append(" ,ModifiedUser=@ModifiedUser "); |
509 |
parameters.Add("ModifiedUser", userId); |
510 |
|
511 |
parameters.Add("DocID", doc.DocID); |
512 |
|
513 |
query = $@" |
514 |
declare @DateTimeNow datetime |
515 |
set @DateTimeNow = getdate() |
516 |
|
517 |
update dbo.Documents |
518 |
set ModifiedDate=@DateTimeNow {sbSet} |
519 |
where [DocID]=@DocID |
520 |
|
521 |
if @@rowcount > 0 |
522 |
begin |
523 |
select *, datediff(SECOND, ID2StartDate, ID2EndDate) as ID2JobTime from dbo.Documents where DocID=@DocID |
524 |
end |
525 |
else |
526 |
begin |
527 |
select *, 0 as ID2JobTime from dbo.Documents where 1=2 |
528 |
end;"; |
529 |
resultData = base.QueryFirstOrDefault<Documents>(query, parameters, transaction); |
530 |
} |
531 |
} |
532 |
|
533 |
transaction.Commit(); |
534 |
} |
535 |
} |
536 |
catch (Exception ex) |
537 |
{ |
538 |
throw ex; |
539 |
} |
540 |
|
541 |
return resultData; |
542 |
} |
543 |
|
544 |
public bool SetDocumentDatasField(List<Documents> docs, string userId) |
545 |
{ |
546 |
bool isSuccess = false; |
547 |
|
548 |
try |
549 |
{ |
550 |
using (var transaction = base.BeginTransaction()) |
551 |
{ |
552 |
foreach (Documents doc in docs) |
553 |
{ |
554 |
string query = string.Empty; |
555 |
|
556 |
if (!string.IsNullOrEmpty(doc.DocID)) |
557 |
{ |
558 |
StringBuilder sbSet = new StringBuilder(); |
559 |
var parameters = new Dictionary<string, object>(); |
560 |
|
561 |
#region Update 할 목록 |
562 |
if (doc.ID2EndDate != null) |
563 |
{ |
564 |
sbSet.Append(" ,ID2EndDate=@ID2EndDate "); |
565 |
parameters.Add("ID2EndDate", doc.ID2EndDate); |
566 |
} |
567 |
#endregion |
568 |
|
569 |
if (parameters.Count > 0) |
570 |
{ |
571 |
sbSet.Append(" ,ModifiedUser=@ModifiedUser "); |
572 |
parameters.Add("ModifiedUser", userId); |
573 |
|
574 |
parameters.Add("DocID", doc.DocID); |
575 |
|
576 |
query = $@" |
577 |
update dbo.Documents |
578 |
set ModifiedDate=getdate() {sbSet} |
579 |
where [DocID]=@DocID;"; |
580 |
base.Execute(query, parameters, transaction); |
581 |
} |
582 |
} |
583 |
} |
584 |
transaction.Commit(); |
585 |
isSuccess = true; |
586 |
} |
587 |
} |
588 |
catch (Exception ex) |
589 |
{ |
590 |
throw ex; |
591 |
} |
592 |
|
593 |
return isSuccess; |
594 |
} |
595 |
|
596 |
|
597 |
//ID2 |
598 |
public IEnumerable<ID2Drawings> GetID2DrawingsByProject(ID2ProjectInfo id2Info) |
599 |
{ |
600 |
try |
601 |
{ |
602 |
string query = $@" |
603 |
select @Name PROJECTNAME |
604 |
,dw.[UID], dw.[NAME], left(dw.[NAME], len(dw.[NAME]) - dw.lastidx) DOCNAME |
605 |
,case when rtrim(ltrim(isnull(convert(varchar, dw.[DATETIME]),''))) = '' then null else convert(datetime, convert(varchar, dw.[DATETIME])) end [DATETIME] |
606 |
,dw.OCCUPIED, dw.[Image] |
607 |
from |
608 |
( |
609 |
select [UID], [NAME], [DATETIME], OCCUPIED, [Image], charindex('.', reverse([NAME])) lastidx |
610 |
from dbo.Drawings |
611 |
) dw;"; |
612 |
return Query<ID2Drawings>(query, id2Info); |
613 |
} |
614 |
catch (Exception ex) |
615 |
{ |
616 |
throw ex; |
617 |
} |
618 |
} |
619 |
} |
620 |
} |