Пример #1
0
 private static void ResolveConflicts(Dictionary <PropertyDefinition, PropertyConflict> conflicts, AcrPropertyResolver resolver, Dictionary <PropertyDefinition, AcrPropertyProfile.ValuesToResolve> propertyValuesToResolve, PropertyDefinition[] propertiesToResolve)
 {
     AcrPropertyProfile.ValuesToResolve[] array        = AcrProfile.FilterValuesToResolve(propertyValuesToResolve, propertiesToResolve);
     AcrPropertyProfile.ValuesToResolve[] dependencies = AcrProfile.FilterValuesToResolve(propertyValuesToResolve, resolver.Dependencies);
     object[] array2 = resolver.Resolve(array, dependencies);
     for (int i = 0; i < propertiesToResolve.Length; i++)
     {
         PropertyConflict value = new PropertyConflict(propertiesToResolve[i], array[i].OriginalValue, array[i].ClientValue, array[i].ServerValue, (array2 != null) ? array2[i] : null, array2 != null);
         conflicts.Add(propertiesToResolve[i], value);
     }
 }
Пример #2
0
        private ConflictResolutionResult ApplyAcr(PropertyBag acrPropBag, SaveMode saveMode)
        {
            Dictionary <PropertyDefinition, AcrPropertyProfile.ValuesToResolve> valuesToResolve = this.GetValuesToResolve(acrPropBag);
            string valueOrDefault = this.PropertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass, string.Empty);

            if (ObjectClass.IsCalendarItemCalendarItemOccurrenceOrRecurrenceException(valueOrDefault) || ObjectClass.IsMeetingMessage(valueOrDefault))
            {
                LocationIdentifierHelper           locationIdentifierHelper = new LocationIdentifierHelper();
                AcrPropertyProfile.ValuesToResolve valuesToResolve2;
                object serverValue;
                if (valuesToResolve.TryGetValue(InternalSchema.ChangeList, out valuesToResolve2))
                {
                    locationIdentifierHelper.ChangeBuffer = (byte[])valuesToResolve2.ClientValue;
                    serverValue = valuesToResolve2.ServerValue;
                }
                else
                {
                    serverValue = new PropertyError(InternalSchema.ChangeList, PropertyErrorCode.NotFound);
                }
                locationIdentifierHelper.SetLocationIdentifier(53909U, LastChangeAction.AcrPerformed);
                valuesToResolve2 = new AcrPropertyProfile.ValuesToResolve(locationIdentifierHelper.ChangeBuffer, serverValue, null);
                valuesToResolve[InternalSchema.ChangeList] = valuesToResolve2;
            }
            ConflictResolutionResult conflictResolutionResult = this.profile.ResolveConflicts(valuesToResolve);

            if (this.propertiesWrittenAsStream.Count > 0)
            {
                List <PropertyConflict> list = new List <PropertyConflict>(conflictResolutionResult.PropertyConflicts);
                foreach (PropertyDefinition propertyDefinition in this.propertiesWrittenAsStream.Keys)
                {
                    PropertyConflict item = new PropertyConflict(propertyDefinition, null, null, null, null, false);
                    list.Add(item);
                }
                conflictResolutionResult = new ConflictResolutionResult(SaveResult.IrresolvableConflict, list.ToArray());
            }
            if (this.irresolvableChanges || saveMode == SaveMode.FailOnAnyConflict)
            {
                conflictResolutionResult = new ConflictResolutionResult(SaveResult.IrresolvableConflict, conflictResolutionResult.PropertyConflicts);
            }
            if (conflictResolutionResult.SaveStatus != SaveResult.IrresolvableConflict)
            {
                List <PropertyDefinition> list2 = new List <PropertyDefinition>();
                List <PropertyDefinition> list3 = new List <PropertyDefinition>();
                List <object>             list4 = new List <object>();
                if (this.propertyBag == acrPropBag)
                {
                    foreach (PropertyConflict propertyConflict in conflictResolutionResult.PropertyConflicts)
                    {
                        if (propertyConflict.ResolvedValue is PropertyError)
                        {
                            if (PropertyError.IsPropertyNotFound(propertyConflict.ResolvedValue) && (!PropertyError.IsPropertyError(propertyConflict.ClientValue) || !PropertyError.IsPropertyNotFound(propertyConflict.ClientValue)))
                            {
                                list2.Add(propertyConflict.PropertyDefinition);
                            }
                        }
                        else if (propertyConflict.ResolvedValue != propertyConflict.ClientValue)
                        {
                            list3.Add(propertyConflict.PropertyDefinition);
                            list4.Add(propertyConflict.ResolvedValue);
                        }
                    }
                }
                else
                {
                    foreach (PropertyConflict propertyConflict2 in conflictResolutionResult.PropertyConflicts)
                    {
                        if (propertyConflict2.ResolvedValue is PropertyError)
                        {
                            if (PropertyError.IsPropertyNotFound(propertyConflict2.ResolvedValue))
                            {
                                list2.Add(propertyConflict2.PropertyDefinition);
                            }
                        }
                        else if (propertyConflict2.ServerValue != propertyConflict2.ResolvedValue)
                        {
                            list3.Add(propertyConflict2.PropertyDefinition);
                            list4.Add(propertyConflict2.ResolvedValue);
                        }
                    }
                }
                for (int k = 0; k < list2.Count; k++)
                {
                    acrPropBag.Delete(list2[k]);
                }
                for (int l = 0; l < list3.Count; l++)
                {
                    acrPropBag[list3[l]] = list4[l];
                }
            }
            return(conflictResolutionResult);
        }