Exemplo n.º 1
0
        public static void ClearPolicyTagForArchiveOnItem(StoreObject item)
        {
            if (item.GetValueOrDefault <object>(StoreObjectSchema.ArchiveTag) != null)
            {
                item.DeleteProperties(new PropertyDefinition[]
                {
                    StoreObjectSchema.ArchiveTag
                });
            }
            if (item.GetValueOrDefault <object>(StoreObjectSchema.ArchivePeriod) != null)
            {
                item.DeleteProperties(new PropertyDefinition[]
                {
                    StoreObjectSchema.ArchivePeriod
                });
            }
            if (item.GetValueOrDefault <object>(InternalSchema.ArchiveDate) != null)
            {
                item.DeleteProperties(new PropertyDefinition[]
                {
                    InternalSchema.ArchiveDate
                });
            }
            object valueOrDefault = item.GetValueOrDefault <object>(StoreObjectSchema.RetentionFlags);

            if (valueOrDefault != null && valueOrDefault is int)
            {
                RetentionAndArchiveFlags retentionAndArchiveFlags = (RetentionAndArchiveFlags)((int)valueOrDefault & -33);
                item[StoreObjectSchema.RetentionFlags] = (int)retentionAndArchiveFlags;
            }
        }
Exemplo n.º 2
0
        public static void SetPolicyTagForDeleteOnItem(PolicyTag policyTag, StoreObject item)
        {
            item[StoreObjectSchema.PolicyTag] = policyTag.PolicyGuid.ToByteArray();
            CompositeRetentionProperty compositeRetentionProperty = null;

            byte[] valueOrDefault = item.GetValueOrDefault <byte[]>(ItemSchema.StartDateEtc);
            if (valueOrDefault != null)
            {
                try
                {
                    compositeRetentionProperty = CompositeRetentionProperty.Parse(valueOrDefault, true);
                }
                catch (ArgumentException)
                {
                    compositeRetentionProperty = null;
                }
            }
            if (compositeRetentionProperty == null)
            {
                compositeRetentionProperty         = new CompositeRetentionProperty();
                compositeRetentionProperty.Integer = (int)policyTag.TimeSpanForRetention.TotalDays;
                object valueOrDefault2 = item.GetValueOrDefault <object>(InternalSchema.ReceivedTime);
                if (valueOrDefault2 == null)
                {
                    valueOrDefault2 = item.GetValueOrDefault <object>(StoreObjectSchema.CreationTime);
                }
                if (valueOrDefault2 == null)
                {
                    compositeRetentionProperty.Date = new DateTime?((DateTime)ExDateTime.Now);
                }
                else
                {
                    compositeRetentionProperty.Date = new DateTime?((DateTime)((ExDateTime)valueOrDefault2));
                }
                item[InternalSchema.StartDateEtc] = compositeRetentionProperty.GetBytes(true);
            }
            long fileTime = 0L;

            try
            {
                fileTime = compositeRetentionProperty.Date.Value.AddDays(policyTag.TimeSpanForRetention.TotalDays).ToFileTimeUtc();
            }
            catch (ArgumentOutOfRangeException)
            {
                fileTime = 0L;
            }
            item[InternalSchema.RetentionPeriod] = (int)policyTag.TimeSpanForRetention.TotalDays;
            DateTime dateTime = DateTime.FromFileTimeUtc(fileTime);

            item[InternalSchema.RetentionDate] = dateTime;
            if (item.GetValueOrDefault <object>(StoreObjectSchema.ExplicitPolicyTag) != null)
            {
                item.DeleteProperties(new PropertyDefinition[]
                {
                    StoreObjectSchema.ExplicitPolicyTag
                });
            }
        }
Exemplo n.º 3
0
 public static void ClearPolicyTagForDeleteOnItem(StoreObject item)
 {
     if (item.GetValueOrDefault <object>(StoreObjectSchema.PolicyTag) != null)
     {
         item.DeleteProperties(new PropertyDefinition[]
         {
             StoreObjectSchema.PolicyTag
         });
     }
     if (item.GetValueOrDefault <object>(StoreObjectSchema.RetentionPeriod) != null)
     {
         item.DeleteProperties(new PropertyDefinition[]
         {
             StoreObjectSchema.RetentionPeriod
         });
     }
     if (item.GetValueOrDefault <object>(InternalSchema.RetentionDate) != null)
     {
         item.DeleteProperties(new PropertyDefinition[]
         {
             InternalSchema.RetentionDate
         });
     }
 }