@@ -48,6 +48,14 @@ public WBDocument(WBRecordsLibrary library, SPListItem item)
48
48
DebugName = "<WBDocument>" ;
49
49
}
50
50
51
+ public WBDocument ( WBRecordsLibrary library , SPListItemVersion item )
52
+ : base ( item )
53
+ {
54
+ RecordsLibrary = library ;
55
+ WorkBox = null ;
56
+ DebugName = "<WBDocument>" ;
57
+ }
58
+
51
59
public WBDocument ( WorkBox workBox , SPListItem item )
52
60
: base ( item )
53
61
{
@@ -56,6 +64,15 @@ public WBDocument(WorkBox workBox, SPListItem item)
56
64
DebugName = "<WBDocument>" ;
57
65
}
58
66
67
+ public WBDocument ( WorkBox workBox , SPListItemVersion item )
68
+ : base ( item )
69
+ {
70
+ RecordsLibrary = null ;
71
+ WorkBox = workBox ;
72
+ DebugName = "<WBDocument>" ;
73
+ }
74
+
75
+
59
76
public WBDocument ( ) : base ( )
60
77
{
61
78
RecordsLibrary = null ;
@@ -158,7 +175,7 @@ public String AbsoluteURL
158
175
{
159
176
get
160
177
{
161
- if ( IsSPListItem ) return Item . Web . Url + "/" + Item . Url ;
178
+ if ( IsSPListItem || IsSPListItemVersion ) return Item . Web . Url + "/" + Item . Url ;
162
179
return "" ;
163
180
}
164
181
}
@@ -167,7 +184,7 @@ public String LibraryRelativePath
167
184
{
168
185
get
169
186
{
170
- if ( IsSPListItem && RecordsLibrary != null )
187
+ if ( ( IsSPListItem || IsSPListItemVersion ) && RecordsLibrary != null )
171
188
{
172
189
WBLogging . Debug ( "AbsoluteURL = " + AbsoluteURL ) ;
173
190
WBLogging . Debug ( "RecordsLibrary.URL = " + RecordsLibrary . URL ) ;
@@ -245,6 +262,48 @@ public WBTerm SeriesTag
245
262
set { this [ WBColumn . SeriesTag ] = value ; }
246
263
}
247
264
265
+ public bool HasDateForFiling
266
+ {
267
+ get {
268
+ //if (HasReferenceDate) return true;
269
+ //if (HasDatePublished) return true;
270
+
271
+ // In the absence of a metadata set value - we'll just use the current date - so we 'have' a usable date:
272
+ return true ;
273
+ }
274
+ }
275
+
276
+ public DateTime DateForFiling
277
+ {
278
+ get
279
+ {
280
+ if ( HasReferenceDate ) return ReferenceDate ;
281
+ if ( HasDatePublished ) return DatePublished ;
282
+
283
+ // In the absence of any other appropriate date we'll just return today's date:
284
+ return DateTime . Now ;
285
+ }
286
+ }
287
+
288
+ public bool HasDatePublished { get { return this . IsNotEmpty ( WBColumn . DatePublished ) ; } }
289
+ public DateTime DatePublished
290
+ {
291
+ get
292
+ {
293
+ if ( this . IsNullOrEmpty ( WBColumn . DatePublished ) )
294
+ {
295
+ WBLogging . Generic . Unexpected ( "Trying to read a 'DatePublished' value of a WBDocument that hasn't been set!!" ) ;
296
+ return DateTime . Now ;
297
+ }
298
+
299
+ return ( DateTime ) this [ WBColumn . DatePublished ] ;
300
+ }
301
+ set
302
+ {
303
+ this [ WBColumn . DatePublished ] = value ;
304
+ }
305
+ }
306
+
248
307
249
308
public bool HasReferenceDate { get { return this . IsNotEmpty ( WBColumn . ReferenceDate ) ; } }
250
309
public DateTime ReferenceDate
@@ -505,7 +564,7 @@ public Stream OpenBinaryStream()
505
564
506
565
507
566
508
- public bool MaybeUpdateRecordColumns ( WBDocument documentToCopy , IEnumerable < WBColumn > columnsToCopy )
567
+ public bool MaybeUpdateRecordColumns ( String callingUserLogin , WBDocument documentToCopy , IEnumerable < WBColumn > columnsToCopy , String reasonForUpdate )
509
568
{
510
569
WBLogging . Debug ( "In MaybeUpdateRecordColumns() for " + DebugName ) ;
511
570
bool updateRequired = false ;
@@ -536,8 +595,21 @@ public bool MaybeUpdateRecordColumns(WBDocument documentToCopy, IEnumerable<WBCo
536
595
537
596
if ( updateRequired )
538
597
{
598
+ SPUser callingUser = item . Web . WBxEnsureUserOrNull ( callingUserLogin ) ;
599
+
600
+ if ( callingUserLogin != null )
601
+ {
602
+ WBLogging . Debug ( "Updating with callingUserLogin = " + callingUserLogin + " and callingUser = " + callingUser . Name ) ;
603
+ item . WBxSet ( WBColumn . ModifiedBy , callingUserLogin ) ;
604
+ item . WBxSet ( WBColumn . Modified , DateTime . Now ) ;
605
+ }
606
+ else
607
+ {
608
+ WBLogging . Debug ( "Updating withtout a calling user (callingUserLogin = " + callingUserLogin + ")" ) ;
609
+ }
610
+
539
611
item . Update ( ) ;
540
- item . File . CheckIn ( "Metadata updated" ) ;
612
+ item . File . WBxCheckInAs ( reasonForUpdate , callingUser ) ;
541
613
}
542
614
else
543
615
{
@@ -550,6 +622,5 @@ public bool MaybeUpdateRecordColumns(WBDocument documentToCopy, IEnumerable<WBCo
550
622
return updateRequired ;
551
623
}
552
624
553
-
554
625
}
555
626
}
0 commit comments