Пример #1
0
        /// <summary>
        /// Removes all sync ignores flags from the given cmis object
        /// </summary>
        /// <param name="obj">Remote CMIS Object.</param>
        public static void RemoveAllSyncIgnores(this ICmisObject obj)
        {
            Dictionary <string, object> properties = new Dictionary <string, object>();
            var ids = obj.SecondaryObjectTypeIds();

            if (ids.Remove("gds:sync"))
            {
                properties.Add(PropertyIds.SecondaryObjectTypeIds, ids);
                obj.UpdateProperties(properties, true);
            }
        }
Пример #2
0
        /// <summary>
        /// Removes the sync ignore flags of the given device Ids from the given cmis object.
        /// </summary>
        /// <param name="obj">Remote CMIS Object.</param>
        /// <param name="deviceIds">Device identifiers which should be removed from ignore list.</param>
        public static void RemoveSyncIgnore(this ICmisObject obj, params string[] deviceIds)
        {
            var ids = obj.SecondaryObjectTypeIds();

            if (ids.Contains("gds:sync"))
            {
                var devices = obj.IgnoredDevices();
                if (deviceIds == null || deviceIds.Length == 0)
                {
                    if (devices.Remove("*") ||
                        devices.Remove(ConfigManager.CurrentConfig.DeviceId.ToString().ToLower()))
                    {
                        if (devices.Count > 0)
                        {
                            Dictionary <string, object> properties = new Dictionary <string, object>();
                            properties.Add("gds:ignoreDeviceIds", devices);
                            obj.UpdateProperties(properties, true);
                        }
                        else
                        {
                            obj.RemoveAllSyncIgnores();
                        }
                    }
                }
                else
                {
                    bool changed = false;
                    foreach (var removeId in deviceIds)
                    {
                        if (devices.Remove(removeId))
                        {
                            changed = true;
                        }
                    }

                    if (changed)
                    {
                        if (devices.Count > 0)
                        {
                            Dictionary <string, object> properties = new Dictionary <string, object>();
                            properties.Add("gds:ignoreDeviceIds", devices);
                            obj.UpdateProperties(properties, true);
                        }
                        else
                        {
                            obj.RemoveAllSyncIgnores();
                        }
                    }
                }
            }
        }