-
Notifications
You must be signed in to change notification settings - Fork 11
/
Item.cs
1501 lines (1276 loc) · 53.7 KB
/
Item.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// <copyright file="Item.cs" company="Engage Software">
// Engage: Publish
// Copyright (c) 2004-2013
// by Engage Software ( http://www.engagesoftware.com )
// </copyright>
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
namespace Engage.Dnn.Publish
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Text;
using System.Web;
using System.Xml.Serialization;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Controllers;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Tabs;
using DotNetNuke.Entities.Users;
using DotNetNuke.Security.Roles;
using DotNetNuke.Services.Mail;
using Engage.Dnn.Publish.Data;
using Engage.Dnn.Publish.Portability;
using Engage.Dnn.Publish.Util;
/// <summary>
/// Summary description for ItemInfo.
/// </summary>
public abstract class Item : TransportableElement
{
private readonly ItemRelationshipCollection relationships;
private readonly ItemTagCollection tags;
private readonly ItemVersionSettingCollection versionSettings;
private string approvalComments = string.Empty;
private string approvalDate = string.Empty;
private int approvalStatusId = -1;
private int approvalUserId = -1;
private int approvedItemVersionId = -1;
private int authorUserId = -1;
private string createdDate = string.Empty;
private string description = string.Empty;
private bool disabled;
private int displayTabId = -1;
private string displayTabName = string.Empty;
private string endDate;
private int itemId = -1;
private Guid itemIdentifier;
private int itemTypeId = -1;
private string itemVersionDate = string.Empty;
private int itemVersionId = -1;
private Guid itemVersionIdentifier;
private int languageId = -1;
private string lastUpdated = string.Empty;
private string metaDescription = string.Empty;
private string metaKeywords = string.Empty;
private string metaTitle = string.Empty;
private int moduleId = -1;
private string name = string.Empty;
private bool newWindow;
private string originalApprovalUser = string.Empty;
private string originalAuthor = string.Empty;
private int originalItemVersionId = -1;
private string originalRevisingUser = string.Empty;
private int portalId = -1;
private int revisingUserId = -1;
private string startDate = string.Empty;
private string thumbnail = string.Empty;
private string url = string.Empty;
protected Item()
{
this.startDate = DateTime.Now.ToString(CultureInfo.InvariantCulture);
this.relationships = new ItemRelationshipCollection();
this.versionSettings = new ItemVersionSettingCollection();
this.tags = new ItemTagCollection();
}
[XmlElement(Order = 26)]
public string ApprovalComments
{
get { return this.approvalComments; }
set { this.approvalComments = value; }
}
[XmlElement(Order = 23)]
public string ApprovalDate
{
get { return this.approvalDate; }
set { this.approvalDate = value; }
}
[XmlElement(Order = 21)]
public int ApprovalStatusId
{
get { return this.approvalStatusId; }
set { this.approvalStatusId = value; }
}
[XmlElement(Order = 22)]
public string ApprovalStatusName
{
get { return ApprovalStatus.GetFromId(this.approvalStatusId, typeof(ApprovalStatus)).Name; }
set { }
}
[XmlElement(Order = 25)]
public string ApprovalUser
{
get { return this.originalApprovalUser; }
set { this.originalApprovalUser = value; }
}
[XmlElement(Order = 24)]
public int ApprovalUserId
{
get { return this.approvalUserId; }
set { this.approvalUserId = value; }
}
[XmlElement(Order = 6)]
public int ApprovedItemVersionId
{
get { return this.approvedItemVersionId; }
set { this.approvedItemVersionId = value; }
}
[XmlElement(Order = 7)]
public string ApprovedItemVersionIdentifier
{
get
{
if (this.approvedItemVersionId == 0)
{
return this.ItemVersionIdentifier.ToString();
}
// must resolve id to guid
string approvedItemVersionIdentifier = string.Empty;
using (IDataReader dr = DataProvider.Instance().GetItemVersionInfo(this.approvedItemVersionId))
{
if (dr.Read())
{
approvedItemVersionIdentifier = dr["ItemVersionIdentifier"].ToString();
}
}
return approvedItemVersionIdentifier;
}
set { }
}
[XmlElement(Order = 20)]
public string Author
{
get
{
// UserController controller = new UserController();
////verify that the user is a user in this system.
// UserInfo user = controller.GetUserByUsername(_portalId, _originalAuthor);
// if (user != null)
// {
// return user.Username;
// }
// else
// {
// return string.Empty;
// }
var authorNameSetting = ItemVersionSetting.GetItemVersionSetting(this.ItemVersionId, "lblAuthorName", "Text", this.PortalId);
if (authorNameSetting != null && authorNameSetting.ToString().Trim().Length > 0)
{
this.originalAuthor = authorNameSetting.PropertyValue;
}
else
{
var uc = new UserController();
UserInfo ui = uc.GetUser(this.portalId, this.authorUserId);
if (ui != null)
{
this.originalAuthor = ui.DisplayName;
}
}
return this.originalAuthor;
}
set { this.originalAuthor = value; }
}
[XmlElement(Order = 19)]
public int AuthorUserId
{
get { return this.authorUserId; }
set { this.authorUserId = value; }
}
[XmlIgnore]
public int CommentCount { get; set; }
[XmlElement(Order = 8)]
public string CreatedDate
{
get { return this.createdDate; }
set { this.createdDate = value; }
}
[XmlElement(Order = 14)]
public string Description
{
get { return this.description; }
set { this.description = value; }
}
[XmlElement(Order = 33)]
public bool Disabled
{
get { return this.disabled; }
set { this.disabled = value; }
}
[XmlElement(Order = 30)]
public int DisplayTabId
{
get { return this.displayTabId; }
set { this.displayTabId = value; }
}
[XmlElement(Order = 31)]
public string DisplayTabName
{
get
{
if (this.displayTabName.Length == 0)
{
using (IDataReader dr = DataProvider.Instance().GetPublishTabName(this.displayTabId, this.portalId))
{
if (dr.Read())
{
this.displayTabName = dr["TabName"].ToString();
}
}
}
return this.displayTabName;
}
set { this.displayTabName = value; }
}
public abstract string EmailApprovalBody { get; }
public abstract string EmailApprovalSubject { get; }
public abstract string EmailStatusChangeBody { get; }
public abstract string EmailStatusChangeSubject { get; }
[XmlElement(Order = 17)]
public string EndDate
{
get { return this.endDate; }
set { this.endDate = Engage.Utility.HasValue(value) ? value : null; }
}
[XmlIgnore]
public string GetItemExternalUrl
{
get
{
string strUrl = string.Empty;
switch (Globals.GetURLType(this.url))
{
case TabType.Normal:
strUrl = Globals.NavigateURL(this.displayTabId);
break;
case TabType.Tab:
strUrl = Globals.NavigateURL(Convert.ToInt32(this.url, CultureInfo.InvariantCulture));
break;
case TabType.File:
strUrl = Globals.LinkClick(this.url, this.displayTabId, Null.NullInteger);
break;
case TabType.Url:
strUrl = this.url;
break;
}
return strUrl;
}
}
public bool IsNew
{
get { return this.itemId == -1; }
}
[XmlElement(Order = 10)]
public int ItemId
{
get { return this.itemId; }
set { this.itemId = value; }
}
[XmlElement(Order = 4)]
public Guid ItemIdentifier
{
get { return this.itemIdentifier; }
set { this.itemIdentifier = value; }
}
[XmlIgnore]
public int ItemTypeId
{
get { return this.itemTypeId; }
set { this.itemTypeId = value; }
}
[XmlElement(Order = 15)]
public string ItemVersionDate
{
get { return this.itemVersionDate; }
set { this.itemVersionDate = value; }
}
[XmlElement(Order = 9)]
public int ItemVersionId
{
get { return this.itemVersionId; }
set { this.itemVersionId = value; }
}
[XmlElement(Order = 5)]
public Guid ItemVersionIdentifier
{
get { return this.itemVersionIdentifier; }
set { this.itemVersionIdentifier = value; }
}
[XmlElement(Order = 18)]
public int LanguageId
{
get { return this.languageId; }
set { this.languageId = value; }
}
[XmlElement(Order = 32)]
public string LastUpdated
{
get { return this.lastUpdated; }
set { this.lastUpdated = value; }
}
[XmlElement(Order = 28)]
public string MetaDescription
{
get { return this.metaDescription; }
set { this.metaDescription = value; }
}
[XmlElement(Order = 27)]
public string MetaKeywords
{
get { return this.metaKeywords; }
set { this.metaKeywords = value; }
}
[XmlElement(Order = 29)]
public string MetaTitle
{
get { return this.metaTitle; }
set { this.metaTitle = value; }
}
[XmlElement(Order = 1)]
public int ModuleId
{
get { return this.moduleId; }
set { this.moduleId = value; }
}
[XmlElement(Order = 2)]
public string ModuleTitle
{
get
{
string moduleTitle = string.Empty;
using (IDataReader dr = DataProvider.Instance().GetModuleInfo(this.moduleId))
{
if (dr.Read())
{
moduleTitle = dr["ModuleTitle"].ToString();
}
}
return moduleTitle;
}
set { }
}
[XmlElement(Order = 13)]
public string Name
{
get { return this.name; }
set { this.name = value; }
}
[XmlElement(Order = 36)]
public bool NewWindow
{
get { return this.newWindow; }
set { this.newWindow = value; }
}
[XmlElement(Order = 11)]
public int OriginalItemVersionId
{
get { return this.originalItemVersionId; }
set { this.originalItemVersionId = value; }
}
[XmlElement(Order = 12)]
public string OriginalItemVersionIdentifier
{
get
{
if (this.originalItemVersionId <= 0)
{
return this.ItemVersionIdentifier.ToString();
}
// must resolve id to guid
string originalItemVersionIdentifier = string.Empty;
using (IDataReader dr = DataProvider.Instance().GetItemVersionInfo(this.originalItemVersionId))
{
if (dr.Read())
{
originalItemVersionIdentifier = dr["ItemVersionIdentifier"].ToString();
}
}
return originalItemVersionIdentifier;
}
set { }
}
[XmlElement(Order = 3)]
public int PortalId
{
get { return this.portalId; }
set { this.portalId = value; }
}
[XmlIgnore]
public ItemRelationshipCollection Relationships
{
get { return this.relationships; }
}
[XmlElement(Order = 37)]
public string RevisingUser
{
get { return this.originalRevisingUser; }
set { this.originalRevisingUser = value; }
}
[XmlElement(Order = 38)]
public int RevisingUserId
{
get { return this.revisingUserId; }
set { this.revisingUserId = value; }
}
[XmlElement(Order = 16)]
public string StartDate
{
get { return this.startDate; }
set { this.startDate = Engage.Utility.HasValue(value) ? value : null; }
}
[XmlIgnore]
public ItemTagCollection Tags
{
get { return this.tags; }
}
[XmlElement(Order = 34)]
public string Thumbnail
{
get { return this.thumbnail; }
set { this.thumbnail = value; }
}
[XmlElement(Order = 35)]
public string Url
{
get { return this.url; }
set { this.url = value; }
}
[XmlIgnore]
public ItemVersionSettingCollection VersionSettings
{
get { return this.versionSettings; }
}
[XmlIgnore]
public int ViewCount { get; set; }
public static int AddItem(IDbTransaction trans, int itemTypeId, int portalId, int moduleId, Guid itemIdentifier)
{
return DataProvider.Instance().AddItem(trans, itemTypeId, portalId, moduleId, itemIdentifier);
}
public static int AddItemVersion(
int itemId,
int originalItemVersionId,
string name,
string description,
string startDate,
string endDate,
int languageId,
int authorUserId,
string metaKeywords,
string metaDescription,
string metaTitle,
int displayTabId,
bool disabled,
string thumbnail,
Guid itemVersionIdentifier,
string url,
bool newWindow,
int revisingUserId)
{
return DataProvider.Instance().AddItemVersion(
itemId,
originalItemVersionId,
name,
description,
startDate,
endDate,
languageId,
authorUserId,
metaKeywords,
metaDescription,
metaTitle,
displayTabId,
disabled,
thumbnail,
itemVersionIdentifier,
url,
newWindow,
revisingUserId);
}
public static int AddItemVersion(
IDbTransaction trans,
int itemId,
int originalItemVersionId,
string name,
string description,
string startDate,
string endDate,
int languageId,
int authorUserId,
string metaKeywords,
string metaDescription,
string metaTitle,
int displayTabId,
bool disabled,
string thumbnail,
Guid itemVersionIdentifier,
string url,
bool newWindow,
int revisingUserId)
{
return DataProvider.Instance().AddItemVersion(
trans,
itemId,
originalItemVersionId,
name,
description,
startDate,
endDate,
languageId,
authorUserId,
metaKeywords,
metaDescription,
metaTitle,
displayTabId,
disabled,
thumbnail,
itemVersionIdentifier,
url,
newWindow,
revisingUserId);
}
/// <summary>
/// Clears the comment count on the item table to 0 for all items within a portal
/// </summary>
/// <param name="portalId">The Portal in which the items will be cleared</param>
/// <returns></returns>
public static void ClearItemsCommentCount(int portalId)
{
DataProvider.Instance().ClearItemsCommentCount(portalId);
}
/// <summary>
/// Clears the view count on the item table to 0 for all items within a portal
/// </summary>
/// <param name="portalId">The Portal in which the items will be cleared</param>
/// <returns></returns>
public static void ClearItemsViewCount(int portalId)
{
DataProvider.Instance().ClearItemsViewCount(portalId);
}
[Obsolete("This method signature should not be used, please use the signature that accepts PortalId as a parameter so that the cache is cleared properly. DeleteItem(int _itemId, int _portalId).", false)]
public static void DeleteItem(int itemId)
{
DataProvider.Instance().DeleteItem(itemId);
}
public static void DeleteItem(int itemId, int portalId)
{
DataProvider.Instance().DeleteItem(itemId);
Utility.ClearPublishCache(portalId);
}
public static bool DoesItemExist(string name, int authorUserId)
{
// try loading the item, if we get an ItemID back we know this already exists.
if (DataProvider.Instance().FindItemId(name, authorUserId) > 0)
{
return true;
}
return false;
}
/// <summary>
/// Checks to see if an item exists by a specific name, from a specific author, in a specific category.
/// </summary>
/// <param name="name">The name of the item</param>
/// <param name="authorUserId">The ID of the author</param>
/// <param name="categoryId">The ID of the category</param>
/// <returns>true or false</returns>
public static bool DoesItemExist(string name, int authorUserId, int categoryId)
{
// try loading the item, if we get an ItemID back we know this already exists.
return DataProvider.Instance().FindItemId(name, authorUserId, categoryId) > 0;
}
public static DataSet GetAllChildren(int parentItemId, int relationshipTypeId, int portalId)
{
return DataProvider.Instance().GetAllChildren(parentItemId, relationshipTypeId, portalId);
}
public static DataSet GetAllChildren(int itemTypeId, int parentItemId, int relationshipTypeId, int portalId)
{
return DataProvider.Instance().GetAllChildren(itemTypeId, parentItemId, relationshipTypeId, portalId);
}
public static DataSet GetAllChildren(int itemTypeId, int parentItemId, int relationshipTypeId, int otherRelationshipTypeId, int portalId)
{
return DataProvider.Instance().GetAllChildren(itemTypeId, parentItemId, relationshipTypeId, otherRelationshipTypeId, portalId);
}
public static IDataReader GetAllChildrenAsDataReader(
int itemTypeId, int parentItemId, int relationshipTypeId, int otherRelationshipTypeId, int portalId)
{
return DataProvider.Instance().GetAllChildrenAsDataReader(itemTypeId, parentItemId, relationshipTypeId, otherRelationshipTypeId, portalId);
}
[Obsolete("This method is not used.")]
public static DataSet GetChildren(int parentItemId, int relationshipTypeId, int portalId)
{
return DataProvider.Instance().GetChildren(parentItemId, relationshipTypeId, portalId);
}
public static Item GetItem(int itemId, int portalId, int itemTypeId, bool isCurrent)
{
string cacheKey = Utility.CacheKeyPublishItem + itemId.ToString(CultureInfo.InvariantCulture);
Item i;
if (ModuleBase.UseCachePortal(portalId))
{
object o = DataCache.GetCache(cacheKey);
if (o != null)
{
i = (Item)o;
}
else
{
IDataReader dr = DataProvider.Instance().GetItem(itemId, portalId, isCurrent);
ItemType it = ItemType.GetFromId(itemTypeId, typeof(ItemType));
i = (Item)CBO.FillObject(dr, it.GetItemType);
// ReSharper disable ConditionIsAlwaysTrueOrFalse
if (i != null)
{
// ReSharper restore ConditionIsAlwaysTrueOrFalse
i.CorrectDates();
DataCache.SetCache(cacheKey, i, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId)));
Utility.AddCacheKey(cacheKey, portalId);
}
}
}
else
{
IDataReader dr = DataProvider.Instance().GetItem(itemId, portalId, isCurrent);
ItemType it = ItemType.GetFromId(itemTypeId, typeof(ItemType));
i = (Item)CBO.FillObject(dr, it.GetItemType);
i.CorrectDates();
}
return i;
// IDataReader dr = DataProvider.Instance().GetItem(_itemId, _portalId, isCurrent);
// ItemType it = ItemType.GetFromId(_itemTypeId, typeof(ItemType));
// Item a = (Item)CBO.FillObject(dr, it.GetItemType);
// a.CorrectDates();
// return a;
}
public static int GetItemIdFromVersion(int itemVersionId, int portalId)
{
return DataProvider.Instance().GetItemIdFromVersion(itemVersionId, portalId);
}
public static int GetItemIdFromVersion(int itemVersionId)
{
return DataProvider.Instance().GetItemIdFromVersion(itemVersionId);
}
public static string GetItemType(int itemId)
{
return DataProvider.Instance().GetItemType(itemId);
}
public static string GetItemType(int itemId, int portalId)
{
string itemType;
// return DataProvider.Instance().GetItemType(_itemId);
string cacheKey = Utility.CacheKeyPublishItemTypeNameItemId + itemId.ToString(CultureInfo.InvariantCulture); // +"PageId";
if (ModuleBase.UseCachePortal(portalId))
{
object o = DataCache.GetCache(cacheKey);
itemType = o != null ? o.ToString() : GetItemType(itemId);
if (itemType != null)
{
DataCache.SetCache(cacheKey, itemType, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId)));
Utility.AddCacheKey(cacheKey, portalId);
}
}
else
{
itemType = GetItemType(itemId);
}
return itemType;
}
public static int GetItemTypeId(int itemId)
{
return DataProvider.Instance().GetItemTypeId(itemId);
}
public static int GetItemTypeId(int itemId, int portalId)
{
int itemTypeId;
string cacheKey = Utility.CacheKeyPublishItemTypeIntForItemId + itemId.ToString(CultureInfo.InvariantCulture); // +"PageId";
if (ModuleBase.UseCachePortal(portalId))
{
object o = DataCache.GetCache(cacheKey);
itemTypeId = o != null ? Convert.ToInt32(o.ToString()) : GetItemTypeId(itemId);
if (itemTypeId != -1)
{
DataCache.SetCache(cacheKey, itemTypeId, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId)));
Utility.AddCacheKey(cacheKey, portalId);
}
}
else
{
itemTypeId = GetItemTypeId(itemId);
}
return itemTypeId;
}
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Not displaying properties of this class.")]
public static DataTable GetItemTypes()
{
// cached version below
return DataProvider.Instance().GetItemTypes();
}
public static DataTable GetItemTypes(int portalId)
{
DataTable dt;
string cacheKey = Utility.CacheKeyPublishItemTypesDT + portalId.ToString(CultureInfo.InvariantCulture); // +"PageId";
if (ModuleBase.UseCachePortal(portalId))
{
object o = DataCache.GetCache(cacheKey);
if (o != null)
{
dt = (DataTable)o;
}
else
{
dt = GetItemTypes();
}
if (dt != null)
{
DataCache.SetCache(cacheKey, dt, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId)));
Utility.AddCacheKey(cacheKey, portalId);
}
}
else
{
dt = GetItemTypes();
}
return dt;
// return DataProvider.Instance().GetItemTypes();
}
public static DataSet GetItemVersions(int itemId, int portalId)
{
return DataProvider.Instance().GetItemVersions(itemId, portalId);
}
public static IDataReader GetItems(int itemTypeId, int portalId)
{
return DataProvider.Instance().GetItems(itemTypeId, portalId);
}
public static DataSet GetItems(int parentItemId, int portalId, int relationshipTypeId)
{
return DataProvider.Instance().GetItems(parentItemId, portalId, relationshipTypeId);
}
public static DataSet GetItems(int parentItemId, int portalId, int relationshipTypeId, int itemTypeId)
{
return DataProvider.Instance().GetItems(parentItemId, portalId, relationshipTypeId, itemTypeId);
}
public static DataSet GetItems(int parentItemId, int portalId, int relationshipTypeId, int otherRelationshipTypeId, int itemTypeId)
{
return DataProvider.Instance().GetItems(parentItemId, portalId, relationshipTypeId, otherRelationshipTypeId, itemTypeId);
}
public static DataSet GetParentItems(int itemId, int portalId, int relationshipTypeId)
{
return DataProvider.Instance().GetParentItems(itemId, portalId, relationshipTypeId);
}
/// <summary>
/// Runs the stored procedure to calculate the views and comment counts for all items.
/// </summary>
/// <returns></returns>
public static void RunPublishStats()
{
DataProvider.Instance().RunPublishStats();
}
public static void UpdateItem(IDbTransaction trans, int itemId, int moduleId)
{
DataProvider.Instance().UpdateItem(trans, itemId, moduleId);
}
public static void UpdateItemVersion(
IDbTransaction trans, int itemId, int itemVersionId, int approvalStatusId, int userId, string approvalComments)
{
DataProvider.Instance().UpdateItemVersion(trans, itemId, itemVersionId, approvalStatusId, userId, approvalComments);
}
public void AddView(int userId, int tabId, string ipAddress, string userAgent, string httpReferrer, string siteUrl)
{
if (ModuleBase.IsViewTrackingEnabledForPortal(this.PortalId))
{
DataProvider.Instance().AddItemView(this.itemId, this.itemVersionId, userId, tabId, ipAddress, userAgent, httpReferrer, siteUrl);
}
}
public void CorrectDates()
{
if (!string.IsNullOrEmpty(this.ApprovalDate))
{
this.ApprovalDate = Convert.ToDateTime(this.ApprovalDate, CultureInfo.CurrentCulture).ToString(CultureInfo.InvariantCulture);
}
if (!string.IsNullOrEmpty(this.EndDate))
{
this.EndDate = Convert.ToDateTime(this.EndDate, CultureInfo.CurrentCulture).ToString(CultureInfo.InvariantCulture);
}
if (!string.IsNullOrEmpty(this.StartDate))
{
this.StartDate = Convert.ToDateTime(this.StartDate, CultureInfo.CurrentCulture).ToString(CultureInfo.InvariantCulture);
}
if (!string.IsNullOrEmpty(this.CreatedDate))
{
this.CreatedDate = Convert.ToDateTime(this.CreatedDate, CultureInfo.CurrentCulture).ToString(CultureInfo.InvariantCulture);
}
if (!string.IsNullOrEmpty(this.ItemVersionDate))
{
this.ItemVersionDate = Convert.ToDateTime(this.ItemVersionDate, CultureInfo.CurrentCulture).ToString(CultureInfo.InvariantCulture);
}
if (!string.IsNullOrEmpty(this.LastUpdated))
{
this.LastUpdated = Convert.ToDateTime(this.LastUpdated, CultureInfo.CurrentCulture).ToString(CultureInfo.InvariantCulture);
}
}
public bool DisplayOnCurrentPage()
{
return Utility.GetValueFromCache(
this.PortalId,
Utility.CacheKeyPublishDisplayOnCurrentPage + this.itemVersionId.ToString(CultureInfo.InvariantCulture),
delegate
{
ItemType type = ItemType.GetFromId(this.ItemTypeId, typeof(ItemType));
var currentPageSetting = ItemVersionSetting.GetItemVersionSetting(
this.ItemVersionId, type.Name + "Settings", "DisplayOnCurrentPage", this.portalId);
return currentPageSetting != null && Convert.ToBoolean(currentPageSetting.PropertyValue, CultureInfo.InvariantCulture);
});
}
/// <summary>
/// Determines whether this <see cref="Item"/> should be forced to always display on its assigned <see cref="DisplayTabId"/>, or whether it can display on any tab.
/// </summary>
/// <returns>
/// <c>true</c> if this <see cref="Item"/> should be forced to always display on its assigned <see cref="DisplayTabId"/>; otherwise, <c>false</c>.
/// </returns>
public bool ForceDisplayOnPage()
{
return Utility.GetValueFromCache(
this.PortalId,
Utility.CacheKeyPublishForceDisplayOn + this.itemVersionId.ToString(CultureInfo.InvariantCulture),