예제 #1
0
        public static IReadOnlyDictionary <string, object> ConfigureReferences(this SharePointItemTracking itemTracking,
                                                                               SharePointListItemTracking listTracking, bool isOriginalFields = false)
        {
            var references = (isOriginalFields ? itemTracking.OriginalItem : itemTracking.Item).GetReferences();
            var fields     = isOriginalFields ? itemTracking.OriginalFields.ToDictionary() : itemTracking.Fields.ToDictionary();

            foreach (var reference in references)
            {
                if (fields.ContainsKey(reference.Key))
                {
                    var value = listTracking.Get(reference.Value as ISharePointItem, isOriginalFields);
                    if (value != null)
                    {
                        if (isOriginalFields)
                        {
                            itemTracking.OriginalFields[reference.Key] = value.OriginalItem.Id;
                        }
                        else
                        {
                            itemTracking.Fields[reference.Key] = value.Id;
                        }
                    }
                }
            }

            return(fields);
        }
예제 #2
0
 public static async Task ConfigureUserFieldsAsync(this SharePointItemTracking itemTracking, SharePointClientBase sharePointClient)
 {
     foreach (var userField in itemTracking.Item.GetUserFields())
     {
         if (!string.IsNullOrWhiteSpace(userField.Value as string))
         {
             itemTracking.Fields[userField.Key] =
                 (await sharePointClient.GetUserByLoginAsync(userField.Value as string)).Id;
         }
     }
 }
 public void Add(SharePointItemTracking item) => _items.Add(item);