Exemplo n.º 1
0
        private static void OnSynchronizedSelectedItemsChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            if (e.OldValue != null)
            {
                SynchronizationManager synchronizer = GetSynchronizationManager(dependencyObject);
                synchronizer.StopSynchronizing();
                SetSynchronizationManager(dependencyObject, null);
            }

            IList    list     = e.NewValue as IList;
            Selector selector = dependencyObject as Selector;

            // check that this property is an IList, and that it is being set on a ListBox
            if (list != null && selector != null)
            {
                SynchronizationManager synchronizer  = GetSynchronizationManager(dependencyObject);
                IListItemConverter     itemConverter = GetItemConverter(dependencyObject);
                if (synchronizer == null)
                {
                    synchronizer = new SynchronizationManager(selector, itemConverter);
                    SetSynchronizationManager(dependencyObject, synchronizer);
                }
                synchronizer.StartSynchronizingList();
            }
        }
Exemplo n.º 2
0
 public TwoListSynchronizer(
     IList masterList,
     IList targetList,
     IListItemConverter masterTargetConverter)
 {
     this._masterList            = masterList;
     this._targetList            = targetList;
     this._masterTargetConverter = masterTargetConverter;
 }
Exemplo n.º 3
0
        private IEnumerable <T> GetSharepointList <T>(String listName, String query, IListItemConverter <T> converter, String sharepointName = null, bool isfirmware = false)
        {
            try
            {
                using (var sp = _sharepointClientFactory.Create(isfirmware))
                {
                    if (sharepointName == null)
                    {
                        sharepointName = SharepointToCacheNamesMapper.SharepointKeyByCacheKey(listName);
                    }

                    var items = sp.GetList(sharepointName, query);

                    var convertedList = new List <T>();

                    Log.Trace($"GetSharepointList is '{listName}' Count: '{items.Count}");



                    foreach (var item in items)
                    {
                        // Log.Trace($"Convert SharepointList is '{listName}' Item: {(item.FieldValues["Name"] as Microsoft.SharePoint.Client.Taxonomy.TaxonomyFieldValue).Label}'");
                        try
                        {
                            /*
                             * if (item.Id>349) {
                             * var    converted = converter.Convert(item, sp);
                             * }
                             */
                            var converted = converter.Convert(item, sp);

                            if (converted != null)
                            {
                                convertedList.Add(converted);
                            }
                        }
                        catch (Exception ex)
                        {
                            // Log.Error(ex, $"Conversion from ListItem error. Result type: '{typeof(T)}' Item: '{(item.FieldValues["Name"] as Microsoft.SharePoint.Client.Taxonomy.TaxonomyFieldValue).Label}' List: '{listName}'");
                            Log.Error(ex, $"Conversion from ListItem error. Result type: '{typeof(T)}' {listName}' ");
                            //throw;
                        }
                    }

                    return(convertedList);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, $"Unable to get sharepoint list'{listName}'");
                throw;
            }
        }
Exemplo n.º 4
0
        private void LoadSharepointListAsAppend <T>(String listName, String query, IListItemConverter <T> converter, String sharepointName = null)
        {
            var isfirmware = false;

            if (sharepointName == SharepointKeys.FirmwareFiles)
            {
                isfirmware = true;
            }

            var convertedList = GetSharepointList(listName, query, converter, sharepointName, isfirmware);

            _storage.Append(listName, convertedList);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TwoListSynchronizer"/> class.
 /// </summary>
 /// <param name="masterList">The master list.</param>
 /// <param name="targetList">The target list.</param>
 /// <param name="masterTargetConverter">The master-target converter.</param>
 public TwoListSynchronizer(IList masterList, IList targetList, IListItemConverter masterTargetConverter, string selectedValuePath, IEnumerable itemsSourceList)
 {
     _masterList = masterList;
     _targetList = targetList;
     if (masterTargetConverter == null)
     {
         _masterTargetConverter = DefaultConverter;
     }
     else
     {
         _masterTargetConverter = masterTargetConverter;
     }
     _selectedValuePath = selectedValuePath;
     _itemsSourceList   = itemsSourceList;
     _masterTargetConverter.SetSelectedValuePath(_selectedValuePath);
     _masterTargetConverter.SetItemsSourceList(_itemsSourceList);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TwoListSynchronizer"/> class.
 /// </summary>
 /// <param name="masterList">The master list.</param>
 /// <param name="targetList">The target list.</param>
 /// <param name="masterTargetConverter">The master-target converter.</param>
 public TwoListSynchronizer(IList masterList, IList targetList, IListItemConverter masterTargetConverter)
 {
     _masterList = masterList;
     _targetList = targetList;
     _masterTargetConverter = masterTargetConverter;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TwoListSynchronizer"/> class.
 /// </summary>
 /// <param name="masterList">The master list.</param>
 /// <param name="targetList">The target list.</param>
 /// <param name="masterTargetConverter">The master-target converter.</param>
 public TwoListSynchronizer(IList masterList, IList targetList, IListItemConverter masterTargetConverter)
 {
     _masterList            = masterList;
     _targetList            = targetList;
     _masterTargetConverter = masterTargetConverter ?? DefaultConverter;
 }
Exemplo n.º 8
0
 public void Setup()
 {
     singleItemConverter = A.Fake <IListItemConverter>();
     deserializer        = A.Fake <IListResponseDeserializer>();
     itemsConverter      = new ListItemsConverter <IListItemConverter>(singleItemConverter, deserializer);
 }
Exemplo n.º 9
0
 public static void SetItemConverter(DependencyObject dependencyObject, IListItemConverter value)
 {
     dependencyObject.SetValue(ItemConverter, value);
 }
Exemplo n.º 10
0
            //SelectedValuePath  use it.

            /// <summary>
            /// Initializes a new instance of the <see cref="SynchronizationManager"/> class.
            /// </summary>
            /// <param name="selector">The selector.</param>
            /// <param name="itemConverter"></param>
            internal SynchronizationManager(Selector selector, IListItemConverter itemConverter)
            {
                _multiSelector = selector;
                _itemConverter = itemConverter;
            }
Exemplo n.º 11
0
        private void LoadSharepointList <T>(String listName, String query, IListItemConverter <T> converter, String sharepointName = null)
        {
            var convertedList = GetSharepointList(listName, query, converter, sharepointName);

            _storage.Set(listName, convertedList);
        }