Exemple #1
0
        /// <summary>
        ///     enumerate each PdfAcroField, convert it's value to clr type, use reflection to set that value to the clr object
        ///     BaseDoc
        /// </summary>
        /// <param name="DocData"></param>
        /// <param name="DocRevStrict"></param>
        /// <returns></returns>
        public override BaseDoc Read(byte[] DocData, bool DocRevStrict = false)
        {
            using (MemoryStream _MemoryStream = new MemoryStream(DocData))
                using (PdfDocument _PdfDocument = PdfReader.Open(_MemoryStream, PdfDocumentOpenMode.ReadOnly))
                {
                    DocProcessingInstructions _DocProcessingInstructions = ReadDocPI(_PdfDocument);

                    BaseDoc _BaseDoc = Runtime.ActivateBaseDoc(
                        _DocProcessingInstructions.DocTypeName,
                        DocRevStrict
                        ? _DocProcessingInstructions.solutionVersion
                        : TemplateController.Instance.TopDocRev(_DocProcessingInstructions.DocTypeName));

                    Type _BaseDocType = _BaseDoc.GetType();

                    for (int i = 0; i < _PdfDocument.AcroForm.Fields.Elements.Count; i++)
                    {
                        PdfAcroField      _Field             = _PdfDocument.AcroForm.Fields[i];
                        CompositeProperty _CompositeProperty = _Field.AsCompositeProperty();
                        string            _Value             = string.Format("{0}", _Field.Value);

                        PropertyInfo _PropertyInfo = _BaseDocType.GetProperty(_CompositeProperty.Name, _CompositeProperty.PropertyType);
                        _PropertyInfo.SetValue(_BaseDoc, Convert.ChangeType(_Value, _PropertyInfo.PropertyType), null);
                    }

                    return(SetPI(_BaseDoc, _DocProcessingInstructions));
                }
        }
        public UnitModel(UnitData unitData, AllianceType alliance)         //constructor for the unit, takes unit data, sets it equal in the model.
        {
            Id       = IdTracker++;
            Alliance = alliance;
            UnitData = unitData;


            hP             = new CompositeProperty(unitData.initialHP);   //hp starts at 0; this is done throught he added value
            maxHp          = new CompositeProperty(unitData.initialHP);
            armor          = new CompositeProperty(unitData.initialArmor);
            heal           = new CompositeProperty(0);
            damage         = new CompositeProperty(0);
            moveRange      = new CompositeProperty(unitData.initialMoveRange);
            size           = new CompositeProperty(unitData.initialSize);
            moveSpeed      = new CompositeProperty(unitData.initialMoveSpeed);
            weight         = new CompositeProperty(unitData.initialWeight);
            range          = new CompositeProperty(unitData.initialRange);
            shield         = new CompositeProperty(0);
            shieldReducing = new CompositeProperty(5);              //figure out what this is
            healModifier   = new CompositeProperty(0);
            damageModifier = new CompositeProperty(0);
            unitType       = unitData.unitType;
            reviveTime     = 30;         //maybe change this elsewhere
            dieTime        = 30;



            //hP.setBaseValue (unitData.initialHP);
//			armor.setBaseValue (unitData.initialArmor);
        }
        public void LoadFile(string filename)
        {
            XmlDocument document = new XmlDocument();
            document.Load(filename);

            XmlNode compositeNode = document.SelectSingleNode(CompositeXPath);
            string rootNamespace = GetNodeValue(compositeNode, "@rootNamespace");
            RootNamespace = rootNamespace;

            XmlNodeList types = document.SelectNodes(TypesXPath);
            foreach (XmlNode typeNode in types)
            {
                string typeName = GetNodeValue(typeNode, "@name");
                string className = GetNodeValue(typeNode, "@className");
                string theNamespace = GetNodeValue(typeNode, "@namespace");
                if (!Namespaces.Contains(theNamespace))
                {
                    Namespaces.Add(theNamespace);
                }
                CompositeType compositeType = new CompositeType(typeName, className, theNamespace);

                Type foundType = FindType(className, theNamespace);

                foreach (PropertyInfo pi in foundType.GetProperties())
                {
                    if (pi.CanRead && pi.CanWrite)
                    {
                        CompositeProperty property = new CompositeProperty(typeName, pi.Name, pi.PropertyType);
                        compositeType.Properties.Add(property);
                    }
                }

                XmlNodeList hiddenNodes = typeNode.SelectNodes(PropertiesXPath);
                foreach (XmlNode propertyNode in hiddenNodes)
                {
                    string propertyName = GetNodeValue(propertyNode, "@name");
                    string alias = GetNodeValue(propertyNode, "@alias");
                    bool isReadOnly = GetBooleanNodeValue(propertyNode, "@isReadOnly");
                    bool isHidden = GetBooleanNodeValue(propertyNode, "@isHidden");

                    CompositeProperty property = compositeType.Properties.FindCompositeProperty(typeName, propertyName);

                    if (property != null)
                    {
                        if (!String.IsNullOrEmpty(alias))
                        {
                            property.Alias = alias;
                        }
                        property.IsReadOnly = isReadOnly;
                        property.IsHidden = isHidden;
                    }
                }
            }
        }
Exemple #4
0
        // Token: 0x06000333 RID: 819 RVA: 0x0001423C File Offset: 0x0001243C
        internal override void ExecuteTheDoomed()
        {
            ICollection values = this.moveLists.Values;

            if (values.Count > 0)
            {
                foreach (object obj in values)
                {
                    MovePolicyItems movePolicyItems = (MovePolicyItems)obj;
                    if (movePolicyItems.SetDateWhileMoving)
                    {
                        this.ExpireInBatches(movePolicyItems.ItemList, ExpirationExecutor.Action.MoveToFolderAndSet, new StoreObjectId[]
                        {
                            movePolicyItems.DestinationFolderId
                        });
                    }
                    else
                    {
                        this.ExpireInBatches(movePolicyItems.ItemList, ExpirationExecutor.Action.MoveToFolder, new StoreObjectId[]
                        {
                            movePolicyItems.DestinationFolderId
                        });
                    }
                    FolderExpirationExecutor.Tracer.TraceDebug <FolderExpirationExecutor, int, StoreObjectId>((long)this.GetHashCode(), "{0}: {1} items moved to destination folder: '{2}'.", this, movePolicyItems.ItemList.Count, movePolicyItems.DestinationFolderId);
                    ExpirationExecutor.TracerPfd.TracePfd((long)this.GetHashCode(), "PFD IWE {0} {1}: {2} items moved to destination folder: '{3}'.", new object[]
                    {
                        22807,
                        this,
                        movePolicyItems.ItemList.Count,
                        movePolicyItems.DestinationFolderId
                    });
                }
            }
            ItemUpdater itemUpdater = new ItemUpdater((MailboxDataForFolders)base.MailboxData, this.provisionedFolder, base.ElcAssistant);

            if (this.expiryTimeList.Count > 0)
            {
                int num = itemUpdater.SetProperty(this.expiryTimeList, MessageItemSchema.ExpiryTime, base.MailboxData.UtcNow);
                ELCPerfmon.TotalItemsTagged.IncrementBy((long)num);
                ELCPerfmon.TotalItemsExpired.IncrementBy((long)num);
                FolderExpirationExecutor.Tracer.TraceDebug <FolderExpirationExecutor, int, int>((long)this.GetHashCode(), "{0}: {1} items in ExpiryTime tag list. Setting property completed on {2} items.", this, this.expiryTimeList.Count, num);
            }
            if (this.moveDateStampingList.Count > 0)
            {
                CompositeProperty compositeProperty = new CompositeProperty(Server.Exchange2007MajorVersion, base.MailboxData.Now);
                byte[]            bytes             = compositeProperty.GetBytes();
                itemUpdater.SetProperty(this.moveDateStampingList, ItemSchema.ElcMoveDate, bytes);
                FolderExpirationExecutor.Tracer.TraceDebug <FolderExpirationExecutor, int>((long)this.GetHashCode(), "{0}: {1} items in MoveDate stamping list. Setting property completed.", this, this.expiryTimeList.Count);
            }
            base.ExecuteTheDoomed();
        }
#pragma warning restore 649

        #region GenericInvocator Members

        public virtual Object Invoke(Object composite, MethodInfo method, Object[] args)
        {
            Object            result = null;
            CompositeProperty cProp  = this._state.Properties[this._state.QualifiedNamesForMethods[method]];

            if (args.Length == 0)
            {
                result = cProp.PropertyValueAsObject;
            }
            else
            {
                cProp.PropertyValueAsObject = args[0];
            }
            return(result);
        }
Exemple #6
0
        // Token: 0x06000496 RID: 1174 RVA: 0x00021274 File Offset: 0x0001F474
        private bool UpdateDefaultRetentionPeriod(CompositeProperty compositeProperty, string itemClass)
        {
            int            integer = compositeProperty.Integer;
            ContentSetting defaultContentSettingForMsgClass = base.ElcUserTagInformation.GetDefaultContentSettingForMsgClass(itemClass);
            int            num = 0;

            if (defaultContentSettingForMsgClass != null && defaultContentSettingForMsgClass.RetentionEnabled)
            {
                num = (int)defaultContentSettingForMsgClass.AgeLimitForRetention.Value.TotalDays;
            }
            if (integer != num)
            {
                compositeProperty.Integer = num;
                return(true);
            }
            return(false);
        }
        public UnitModel(UnitData unitData, AllianceType alliance)         //constructor for the unit, takes unit data, sets it equal in the model.
        {
            Alliance = alliance;
            UnitData = unitData;

            hP        = new CompositeProperty(unitData.initialHP);
            armor     = new CompositeProperty(unitData.initialArmor);
            size      = new CompositeProperty(unitData.initialSize);
            moveSpeed = new CompositeProperty(unitData.initialMoveSpeed);
            weight    = new CompositeProperty(unitData.initialWeight);
            range     = new CompositeProperty(unitData.initialRange);
            unitType  = unitData.unitType;


            //hP.setBaseValue (unitData.initialHP);
//			armor.setBaseValue (unitData.initialArmor);
        }
        public static CompositeProperty AsCompositeProperty(this PdfAcroField o)
        {
            CompositeProperty _CompositeProperty = asCompositeProperty((dynamic)o);

            if (o.Flags == PdfAcroFieldFlags.Required)
            {
                if (_CompositeProperty.PropertyType != typeof(string))
                {
                    if (_CompositeProperty.PropertyType != typeof(byte[]))
                    {
                        _CompositeProperty.PropertyType = typeof(Nullable <>).MakeGenericType(Nullable.GetUnderlyingType(_CompositeProperty.PropertyType) ?? _CompositeProperty.PropertyType);
                    }
                }
            }

            return(_CompositeProperty);
        }
        private void AttachProperty(
            CodeTypeDeclaration generatedClass, CompositeType compositeType, CompositeProperty property)
        {
            if (property.IsHidden)
            {
                return;
            }

            CodeMemberField field = new CodeMemberField(property.Type, property.FieldName);

            // public property
            CodeMemberProperty prop = new CodeMemberProperty();

            prop.Name       = property.EffectivePropertyName;
            prop.Type       = new CodeTypeReference(property.Type);
            prop.Attributes = MemberAttributes.Public;
            CodeCommentStatement commentStatement =
                new CodeCommentStatement("<summary>\r\n " + compositeType.ClassName + "." +
                                         property.EffectivePropertyName + "\r\n </summary>", true);

            prop.Comments.Add(commentStatement);

            CodeFieldReferenceExpression fieldRef;

            fieldRef = new CodeFieldReferenceExpression();
            fieldRef.TargetObject = new CodeThisReferenceExpression();
            fieldRef.FieldName    = property.FieldName;

            // property getter
            CodeMethodReturnStatement ret;

            ret = new CodeMethodReturnStatement(fieldRef);
            prop.GetStatements.Add(ret);

            if (!property.IsReadOnly)
            {
                // property setter
                CodeAssignStatement assign = new CodeAssignStatement();
                assign.Left  = fieldRef;
                assign.Right = new CodePropertySetValueReferenceExpression();
                prop.SetStatements.Add(assign);
            }

            generatedClass.Members.Add(prop);
        }
Exemple #10
0
 // Token: 0x06000495 RID: 1173 RVA: 0x000211B0 File Offset: 0x0001F3B0
 private bool UpdateStartDate(CompositeProperty compositeProperty, VersionedId itemId, string itemClass, object[] itemProperties)
 {
     if (compositeProperty.Date == null)
     {
         PropertySynchronizerBase.Tracer.TraceDebug <ItemPropertySynchronizer>((long)this.GetHashCode(), "{0}: Updating Start Date on item because it is null.", this);
         compositeProperty.Date = new DateTime?(this.itemStartDateCalculator.GetStartDateForTag(itemId, itemClass, itemProperties, null, false));
         return(true);
     }
     if (this.IsConflictableItem(itemClass))
     {
         DateTime startDateForTag = this.itemStartDateCalculator.GetStartDateForTag(itemId, itemClass, itemProperties, null, false);
         bool     flag            = !startDateForTag.Equals(compositeProperty.Date.Value);
         if (flag)
         {
             compositeProperty.Date = new DateTime?(startDateForTag);
         }
         PropertySynchronizerBase.Tracer.TraceDebug <ItemPropertySynchronizer, bool>((long)this.GetHashCode(), "{0}: Recalculating Start Date on item because it is ConflictableItem.  Has changed = {1}", this, flag);
         return(flag);
     }
     return(false);
 }
        public ProjectileModel(ProjectileData projectileData, UnitModel sender, ITarget receiver, WorldPosition position) //constructor for the unit, takes unit data, sets it equal in the model.
        {
            _sender   = sender;
            _receiver = receiver;
            SetPosition(position);
            _projectileData = projectileData;

            hP     = new CompositeProperty(0);           //hp starts at 0; this is done throught he added value: I DONT GET THIS AT ALL WHY I WROTE THIS
            damage = new CompositePropertyNegative(projectileData.int1);
            //	Debug.Log ("Damage is " + damage);

            moveSpeed = new CompositeProperty(projectileData.speed.GetValue());

//			Debug.Log ("speed is " + moveSpeed.value);
            weight = new CompositeProperty(projectileData.projectileHP);
            range  = new CompositeProperty(projectileData.range.GetValue());
//			Debug.Log (range.value + " this is the range should be 1 ");
            _projectileData = projectileData;

            //hP.setBaseValue (unitData.initialHP);
            //			armor.setBaseValue (unitData.initialArmor);
        }
Exemple #12
0
    public void NewEditModeTestSimplePasses()
    {
        CompositeProperty lincoln = abe;

        /*
         * for (int i = 0; i < 50000; i++) {
         *      abe.addedValueChange (added);
         *      abe.multiplierValueChange (multiplied);
         * }
         *
         * for (int i = 0; i < 50000; i++) {
         *      abe.addedValueChange (-added);
         *      abe.multiplierValueChange (-multiplied);
         * }
         */
        Assert.AreEqual(abe, lincoln);


        wash.multiplierValueChange((Fix64)10);
        Debug.Log(wash.value);
        wash.multiplierValueChange((Fix64)(-10f));
        Debug.Log(wash.value);
        Assert.AreEqual(wash.value, (Fix64)10f);
    }
Exemple #13
0
        // Token: 0x06000494 RID: 1172 RVA: 0x00021100 File Offset: 0x0001F300
        private DateTime UpdateStartDateEtc(VersionedId itemId, string itemClass, object[] itemProperties)
        {
            CompositeProperty compositeProperty = new CompositeProperty();

            try
            {
                if (itemProperties[this.propertyIndexHolder.StartDateEtcIndex] is byte[])
                {
                    compositeProperty = CompositeProperty.Parse((byte[])itemProperties[this.propertyIndexHolder.StartDateEtcIndex], true);
                }
            }
            catch (ArgumentException arg)
            {
                PropertySynchronizerBase.Tracer.TraceError <ItemPropertySynchronizer, string, ArgumentException>((long)this.GetHashCode(), "{0}: Could not parse StartDateEtc property of item. ItemClass: {1} Exception: {2}.", this, itemClass, arg);
            }
            bool flag  = this.UpdateStartDate(compositeProperty, itemId, itemClass, itemProperties);
            bool flag2 = this.UpdateDefaultRetentionPeriod(compositeProperty, itemClass);

            if (flag || flag2)
            {
                base.PropertiesToBeUpdated.Add(ItemSchema.StartDateEtc, compositeProperty.GetBytes(true));
            }
            return(compositeProperty.Date.Value);
        }
Exemple #14
0
 /// <summary>
 /// Invokes the <see cref="CompositeStateParticipant{T}.TryInvokeFunctionWithRef"/> method with given delegate, assuming that field type is same as property type.
 /// </summary>
 /// <typeparam name="TProperty">The type of the property.</typeparam>
 /// <param name="property">The <see cref="CompositeProperty{T}"/>.</param>
 /// <param name="function">The delegate to invoke.</param>
 /// <returns>The return value of <paramref name="function"/>.</returns>
 /// <exception cref="InvalidOperationException">If <see cref="CompositeStateParticipant{T}.TryInvokeFunctionWithRef"/> returns <c>false</c>, that is, when the field type does not match <typeparamref name="TProperty"/>.</exception>
 /// <remarks>
 /// TODO link to documentation about how field type is deduced (it is not always the same as type of property or event).
 /// </remarks>
 /// <seealso cref="CompositeStateParticipant{T}.TryInvokeFunctionWithRef"/>
 public static TProperty InvokeFunctionWithRefSameType <TProperty>(this CompositeProperty <TProperty> property, FunctionWithRef <TProperty> function)
 {
     return(property.InvokeFunctionWithRef(function));
 }
Exemple #15
0
 /// <summary>
 /// Invokes the <see cref="CompositeStateParticipant{T}.TryInvokeActionWithRef"/> method with given delegate, assuming that field type is same as property type.
 /// </summary>
 /// <typeparam name="TProperty">The type of the property.</typeparam>
 /// <param name="property">The <see cref="CompositeProperty{T}"/>.</param>
 /// <param name="action">The delegate to invoke.</param>
 /// <exception cref="InvalidOperationException">If <see cref="CompositeStateParticipant{T}.TryInvokeFunctionWithRef"/> returns <c>false</c>, that is, when the field type does not match <typeparamref name="TProperty"/>.</exception>
 /// <remarks>
 /// TODO link to documentation about how field type is deduced (it is not always the same as type of property or event).
 /// </remarks>
 /// <seealso cref="CompositeStateParticipant{T}.TryInvokeActionWithRef"/>
 public static void InvokeActionWithRefSameType <TProperty>(this CompositeProperty <TProperty> property, ActionWithRef <TProperty> action)
 {
     property.InvokeActionWithRef(action);
 }
        private CompositeClass ReadSourceFile()
        {
            Assembly[]     assemblies     = _customTool.GetReferencedAssemblies(false);
            CompositeClass compositeClass = new CompositeClass(assemblies);

            compositeClass.Namespaces.Add("System");

            XmlDocument document = new XmlDocument();

            document.Load(_inputFileName);

            XmlNode compositeNode = document.SelectSingleNode(CompositeXPath);

            compositeClass.RootNamespace = GetNodeValue(compositeNode, "@rootNamespace");

            XmlNodeList types = document.SelectNodes(TypesXPath);

            foreach (XmlNode typeNode in types)
            {
                string name         = GetNodeValue(typeNode, "@name");
                string className    = GetNodeValue(typeNode, "@className");
                string theNamespace = GetNodeValue(typeNode, "@namespace");
                if (!compositeClass.Namespaces.Contains(theNamespace))
                {
                    compositeClass.Namespaces.Add(theNamespace);
                }

                CompositeType compositeType = new CompositeType(name, className, theNamespace);
                compositeClass.Types.Add(compositeType);
                Type actualType = FindType(className, theNamespace);

                foreach (PropertyInfo pi in actualType.GetProperties())
                {
                    if (pi.CanRead && pi.CanWrite)
                    {
                        CompositeProperty property = new CompositeProperty(compositeType.TypeName, pi.Name, pi.PropertyType);
                        compositeType.Properties.Add(property);
                    }
                }

                XmlNodeList hiddenNodes = typeNode.SelectNodes(PropertiesXPath);
                foreach (XmlNode propertyNode in hiddenNodes)
                {
                    string propertyName = GetNodeValue(propertyNode, "@name");
                    string alias        = GetNodeValue(propertyNode, "@alias");
                    bool   isReadOnly   = GetBooleanNodeValue(propertyNode, "@isReadOnly");
                    bool   isHidden     = GetBooleanNodeValue(propertyNode, "@isHidden");

                    CompositeProperty property = compositeType.Properties.FindCompositeProperty(name, propertyName);

                    if (property != null)
                    {
                        if (!String.IsNullOrEmpty(alias))
                        {
                            property.Alias = alias;
                        }
                        property.IsReadOnly = isReadOnly;
                        property.IsHidden   = isHidden;
                    }
                }
            }

            return(compositeClass);
        }
        private CompositeClass ReadSourceFile()
        {
            CompositeClass compositeClass = new CompositeClass();
            compositeClass.Namespaces.Add("System");

            XmlDocument document = new XmlDocument();
            document.Load(_inputFileName);

            XmlNode compositeNode = document.SelectSingleNode(CompositeXPath);
            compositeClass.RootNamespace = GetNodeValue(compositeNode, "@rootNamespace");

            XmlNodeList types = document.SelectNodes(TypesXPath);
            foreach (XmlNode typeNode in types)
            {
                string name = GetNodeValue(typeNode, "@name");
                string className = GetNodeValue(typeNode, "@className");
                string theNamespace = GetNodeValue(typeNode, "@namespace");
                if (!compositeClass.Namespaces.Contains(theNamespace))
                {
                    compositeClass.Namespaces.Add(theNamespace);
                }

                CompositeType compositeType = new CompositeType(name, className, theNamespace);
                compositeClass.Types.Add(compositeType);
                Type actualType = FindType(className, theNamespace);

                foreach (PropertyInfo pi in actualType.GetProperties())
                {
                    if (pi.CanRead && pi.CanWrite)
                    {
                        CompositeProperty property = new CompositeProperty(compositeType.TypeName, pi.Name, pi.PropertyType);
                        compositeType.Properties.Add(property);
                    }
                }

                XmlNodeList hiddenNodes = typeNode.SelectNodes(PropertiesXPath);
                foreach (XmlNode propertyNode in hiddenNodes)
                {
                    string propertyName = GetNodeValue(propertyNode, "@name");
                    string alias = GetNodeValue(propertyNode, "@alias");
                    bool isReadOnly = GetBooleanNodeValue(propertyNode, "@isReadOnly");
                    bool isHidden = GetBooleanNodeValue(propertyNode, "@isHidden");

                    CompositeProperty property = compositeType.Properties.FindCompositeProperty(name, propertyName);

                    if (property != null)
                    {
                        if (!String.IsNullOrEmpty(alias))
                        {
                            property.Alias = alias;
                        }
                        property.IsReadOnly = isReadOnly;
                        property.IsHidden = isHidden;
                    }
                }
            }

            return compositeClass;
        }
        private void AttachProperty(
            CodeTypeDeclaration generatedClass, CompositeType compositeType, CompositeProperty property)
        {
            if (property.IsHidden)
            {
                return;
            }

            CodeMemberField field = new CodeMemberField(property.Type, property.FieldName);

            // public property
            CodeMemberProperty prop = new CodeMemberProperty();
            prop.Name = property.EffectivePropertyName;
            prop.Type = new CodeTypeReference(property.Type);
            prop.Attributes = MemberAttributes.Public;
            CodeCommentStatement commentStatement =
                new CodeCommentStatement("<summary>\r\n " + compositeType.ClassName + "." +
                    property.EffectivePropertyName + "\r\n </summary>", true);
            prop.Comments.Add(commentStatement);

            CodeFieldReferenceExpression fieldRef;
            fieldRef = new CodeFieldReferenceExpression();
            fieldRef.TargetObject = new CodeThisReferenceExpression();
            fieldRef.FieldName = property.FieldName;

            // property getter
            CodeMethodReturnStatement ret;
            ret = new CodeMethodReturnStatement(fieldRef);
            prop.GetStatements.Add(ret);

            if (!property.IsReadOnly)
            {
                // property setter
                CodeAssignStatement assign = new CodeAssignStatement();
                assign.Left = fieldRef;
                assign.Right = new CodePropertySetValueReferenceExpression();
                prop.SetStatements.Add(assign);
            }

            generatedClass.Members.Add(prop);
        }
        // Token: 0x0600037C RID: 892 RVA: 0x000180B4 File Offset: 0x000162B4
        internal override void Invoke(ProvisionedFolder provisionedFolder, List <object[]> items, PropertyIndexHolder propertyIndexHolder)
        {
            FolderExpirationExecutor folderExpirationExecutor = new FolderExpirationExecutor(provisionedFolder, base.MailboxData, base.Assistant);

            ExpirationEnforcer.Tracer.TraceDebug <object, string, int>((long)this.GetHashCode(), "{0}: Number of items found in folder '{1}' is {2}.", TraceContext.Get(), provisionedFolder.DisplayName, items.Count);
            DefaultFolderType folderType = DefaultFolderType.None;

            if (provisionedFolder.FolderId.Equals(base.MailboxData.MailboxSession.GetDefaultFolderId(DefaultFolderType.DeletedItems)))
            {
                folderType = DefaultFolderType.DeletedItems;
            }
            else if (provisionedFolder.ContainerClass != null && ObjectClass.IsCalendarFolder(provisionedFolder.ContainerClass))
            {
                folderType = DefaultFolderType.Calendar;
            }
            else if (provisionedFolder.ContainerClass != null && ObjectClass.IsTaskFolder(provisionedFolder.ContainerClass))
            {
                folderType = DefaultFolderType.Tasks;
            }
            ItemStartDateCalculator itemStartDateCalculator = new ItemStartDateCalculator(propertyIndexHolder, provisionedFolder.Folder.DisplayName, folderType, base.MailboxData.MailboxSession, ExpirationEnforcer.Tracer);
            FolderAuditLogData      folderAuditLogData      = null;

            if (base.MailboxData.ElcAuditLog.ExpirationLoggingEnabled)
            {
                folderAuditLogData = new FolderAuditLogData(provisionedFolder, base.MailboxData, ELCAction.Retention.ToString());
            }
            foreach (object[] array in items)
            {
                VersionedId versionedId = array[propertyIndexHolder.IdIndex] as VersionedId;
                string      text        = array[propertyIndexHolder.ItemClassIndex] as string;
                if (versionedId == null)
                {
                    ExpirationEnforcer.Tracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: Current item in folder {1} is null. Skipping it.", TraceContext.Get(), provisionedFolder.DisplayName);
                }
                else
                {
                    provisionedFolder.CurrentItems = new VersionedId[]
                    {
                        versionedId
                    };
                    text = ((text == null) ? string.Empty : text.ToLower());
                    ContentSetting contentSetting = null;
                    contentSetting = ElcPolicySettings.GetApplyingPolicy(provisionedFolder.ElcPolicies, text, provisionedFolder.ItemClassToPolicyMapping);
                    if (contentSetting == null)
                    {
                        ExpirationEnforcer.Tracer.TraceDebug <object, string, string>((long)this.GetHashCode(), "{0}: Policy for item class {1} in folder {2} is null. Skipping item.", TraceContext.Get(), text, provisionedFolder.DisplayName);
                    }
                    else if (!base.MailboxData.FolderProcessor.IsPolicyValid(provisionedFolder, contentSetting, text, base.MailboxData))
                    {
                        ExpirationEnforcer.Tracer.TraceDebug <object, string, string>((long)this.GetHashCode(), "{0}: Removing policy {1} from the list in folder {2} because it is invalid.", TraceContext.Get(), contentSetting.Name, provisionedFolder.DisplayName);
                        provisionedFolder.RemovePolicy(contentSetting);
                    }
                    else
                    {
                        double totalDays = contentSetting.AgeLimitForRetention.Value.TotalDays;
                        int    num;
                        if (contentSetting.TriggerForRetention == RetentionDateType.WhenMoved)
                        {
                            ExpirationEnforcer.Tracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: Applying policy. Policy '{1}' expires based on move date.", TraceContext.Get(), contentSetting.Name);
                            CompositeProperty compositeProperty = null;
                            if (ElcMailboxHelper.Exists(array[propertyIndexHolder.MoveDateIndex]))
                            {
                                try
                                {
                                    compositeProperty = CompositeProperty.Parse((byte[])array[propertyIndexHolder.MoveDateIndex]);
                                }
                                catch (ArgumentException ex)
                                {
                                    ExpirationEnforcer.Tracer.TraceError((long)this.GetHashCode(), "{0}: Could not parse move date property of item. Folder: {1} ItemClass: {2} Exception: {3}.", new object[]
                                    {
                                        TraceContext.Get(),
                                        provisionedFolder.DisplayName,
                                        text,
                                        ex
                                    });
                                    base.MailboxData.ThrowIfErrorsOverLimit();
                                }
                            }
                            if (compositeProperty == null)
                            {
                                string arg = "Stamped Move date is null.";
                                ExpirationEnforcer.Tracer.TraceDebug <object, VersionedId, string>((long)this.GetHashCode(), "{0}: Move date needs to be stamped on item {1}. {2}", TraceContext.Get(), versionedId, arg);
                                folderExpirationExecutor.AddToMoveDateStampingList(new ItemData(versionedId, (int)array[propertyIndexHolder.SizeIndex]));
                                continue;
                            }
                            ExpirationEnforcer.Tracer.TraceDebug <object, VersionedId>((long)this.GetHashCode(), "{0}: Calculating age of item {1} based on move date", TraceContext.Get(), versionedId);
                            num = (int)base.MailboxData.Now.Subtract(compositeProperty.Date.Value).TotalDays;
                        }
                        else
                        {
                            DateTime startDate = itemStartDateCalculator.GetStartDate(versionedId, text, array);
                            if (startDate == DateTime.MinValue)
                            {
                                num = 0;
                            }
                            else
                            {
                                num = (int)base.MailboxData.UtcNow.Subtract(startDate).TotalDays;
                            }
                        }
                        try
                        {
                            if ((double)num >= totalDays)
                            {
                                if (contentSetting.RetentionAction == RetentionActionType.MarkAsPastRetentionLimit && array[propertyIndexHolder.ExpiryTimeIndex] != null && !(array[propertyIndexHolder.ExpiryTimeIndex] is PropertyError))
                                {
                                    ExpirationEnforcer.Tracer.TraceDebug <object, VersionedId>((long)this.GetHashCode(), "{0}: Item {1} is already tagged with expiry time, hence will not tag again.", TraceContext.Get(), versionedId);
                                }
                                else
                                {
                                    ExpirationEnforcer.Tracer.TraceDebug <object, VersionedId>((long)this.GetHashCode(), "{0}: Adding item {1} to list to be expired.", TraceContext.Get(), versionedId);
                                    ItemAuditLogData itemAuditLogData = null;
                                    if (base.MailboxData.ElcAuditLog.ExpirationLoggingEnabled)
                                    {
                                        folderAuditLogData.ExpirationAction = contentSetting.RetentionAction.ToString();
                                        itemAuditLogData = new ItemAuditLogData(array, propertyIndexHolder, folderAuditLogData);
                                    }
                                    ItemData itemData = new ItemData(versionedId, (array[propertyIndexHolder.ReceivedTimeIndex] is ExDateTime) ? ((DateTime)((ExDateTime)array[propertyIndexHolder.ReceivedTimeIndex])) : DateTime.MinValue, itemAuditLogData, (int)array[propertyIndexHolder.SizeIndex]);
                                    folderExpirationExecutor.AddToReportAndDoomedList(array, propertyIndexHolder, contentSetting, itemData, text, this.allPolicyTags);
                                }
                            }
                        }
                        catch (InvalidExpiryDestinationException ex2)
                        {
                            ExpirationEnforcer.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: Removing policy '{1}', that applies to folder '{2}' from list of policies to process. Exception: {3}", new object[]
                            {
                                TraceContext.Get(),
                                contentSetting.Name,
                                contentSetting.ManagedFolderName,
                                ex2
                            });
                            provisionedFolder.RemovePolicy(contentSetting);
                        }
                        catch (SkipFolderException ex3)
                        {
                            ExpirationEnforcer.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: Policy '{1}', that applies to folder '{2}' will be skipped for the current folder. Exception: {3}", new object[]
                            {
                                TraceContext.Get(),
                                contentSetting.Name,
                                contentSetting.ManagedFolderName,
                                ex3
                            });
                            return;
                        }
                    }
                }
            }
            ExpirationEnforcer.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: Done identifying items for expiration. Proceed to expire.", new object[]
            {
                TraceContext.Get()
            });
            ExpirationEnforcer.TracerPfd.TracePfd <int, object>((long)this.GetHashCode(), "PFD IWE {0} {1}: Done identifying items for expiration. Calling ExpirationExecutor to expire.", 26903, TraceContext.Get());
            folderExpirationExecutor.ExecuteTheDoomed();
        }
Exemple #20
0
        private string GetMRMProps(Item item)
        {
            StringBuilder stringBuilder = new StringBuilder();
            bool          flag          = false;

            byte[] propertyBytes = null;
            string str           = string.Empty;

            try
            {
                Guid guid = new Guid((byte[])item[StoreObjectSchema.PolicyTag]);
                stringBuilder.AppendLine("RetentionTagGuid: " + guid);
            }
            catch (PropertyErrorException)
            {
                stringBuilder.AppendLine("RetentionTagGuid: Not Found");
            }
            try
            {
                propertyBytes = (byte[])item[ItemSchema.StartDateEtc];
                flag          = true;
            }
            catch (PropertyErrorException)
            {
            }
            try
            {
                if (flag)
                {
                    DateTime value = CompositeProperty.Parse(propertyBytes, true).Date.Value;
                    stringBuilder.AppendLine("StartDate: " + value);
                }
            }
            catch (PropertyErrorException)
            {
            }
            try
            {
                DateTime universalTime = ((ExDateTime)item[ItemSchema.RetentionDate]).UniversalTime;
                stringBuilder.AppendLine("RetentionDate: " + universalTime);
            }
            catch (PropertyErrorException)
            {
            }
            try
            {
                int?num = new int?((int)item[StoreObjectSchema.RetentionPeriod]);
                stringBuilder.AppendLine("RetentionPeriod: " + num);
            }
            catch (PropertyErrorException)
            {
            }
            try
            {
                Guid guid2 = new Guid((byte[])item[StoreObjectSchema.ArchiveTag]);
                stringBuilder.AppendLine("ArchiveGuid: " + guid2);
            }
            catch (PropertyErrorException)
            {
            }
            try
            {
                DateTime universalTime2 = ((ExDateTime)item[ItemSchema.ArchiveDate]).UniversalTime;
                stringBuilder.AppendLine("ArchiveDate: " + universalTime2);
            }
            catch (PropertyErrorException)
            {
            }
            try
            {
                int?num2 = new int?((int)item[StoreObjectSchema.ArchivePeriod]);
                stringBuilder.AppendLine("ArchivePeriod: " + num2);
            }
            catch (PropertyErrorException)
            {
            }
            try
            {
                DateTime universalTime3 = ((ExDateTime)item[ItemSchema.ReceivedTime]).UniversalTime;
                stringBuilder.AppendLine("ReceivedDate: " + universalTime3);
            }
            catch (PropertyErrorException)
            {
            }
            try
            {
                DateTime universalTime4 = ((ExDateTime)item[StoreObjectSchema.LastModifiedTime]).UniversalTime;
                stringBuilder.AppendLine("LastModifiedTime: " + universalTime4);
            }
            catch (PropertyErrorException)
            {
            }
            try
            {
                str = item[StoreObjectSchema.ParentItemId].ToString();
                stringBuilder.AppendLine("FolderId: " + str);
            }
            catch (PropertyErrorException)
            {
            }
            return(stringBuilder.ToString());
        }