/// <summary>
        /// Populate one of the synchronisation direction menus.
        /// </summary>
        /// <param name="directionMenu">The menu to populate.</param>
        /// <param name="setting">The value of the setting to set the menu value from.</param>
        private void PopulateDirectionsMenu(ComboBox directionMenu, SyncDirection.Direction setting)
        {
            var syncDirectionItems = Enum.GetValues(typeof(SyncDirection.Direction))
                                     .Cast <SyncDirection.Direction>()
                                     .Select(p => new { Key = (int)p, Value = SyncDirection.ToString(p) })
                                     .OrderBy(o => o.Key)
                                     .ToList();

            directionMenu.ValueMember   = "Key";
            directionMenu.DisplayMember = "Value";
            directionMenu.DataSource    = syncDirectionItems;
            directionMenu.SelectedValue = Convert.ToInt32(setting);
        }
Пример #2
0
        /// <summary>
        /// Does the currently cached value allow access to this module name in this direction?
        /// </summary>
        /// <param name="moduleName"></param>
        /// <param name="direction"></param>
        /// <returns>True if access is permitted, false if it's denied, null if there's no
        /// cached value.</returns>
        private bool?HasCachedAccess(string moduleName, string direction)
        {
            bool?result = null;

            if (this.crmImportExportPermissionsCache.ContainsKey(moduleName))
            {
                SyncDirection.Direction cachedValue = this.crmImportExportPermissionsCache[moduleName];
                result = (direction == ImportPermissionToken && SyncDirection.AllowOutbound(cachedValue)) ||
                         (direction == ExportPermissionToken && SyncDirection.AllowInbound(cachedValue));
            }

            return(result);
        }
Пример #3
0
        /// <summary>
        /// Does the currently cached value allow access to this module name in this direction?
        /// </summary>
        /// <remarks>
        /// Should never throw a KeyNotFoundException.
        /// </remarks>
        /// <param name="moduleKey">The module to which access may be granted.</param>
        /// <param name="direction">The direction in which access may be granted.</param>
        /// <returns>True if access is permitted, false if it's denied, null if there's no
        /// cached value.</returns>
        private bool?HasCachedAccess(string moduleKey, string direction)
        {
            bool?result = null;

            try
            {
                if (CRMPermissionsCache.cache.ContainsKey(moduleKey))
                {
                    SyncDirection.Direction cachedValue = CRMPermissionsCache.cache[moduleKey];
                    result = (direction == ImportPermissionToken && SyncDirection.AllowOutbound(cachedValue)) ||
                             (direction == ExportPermissionToken && SyncDirection.AllowInbound(cachedValue));
                }
            }
            catch (Exception any)
            {
                Log.Error("Failed in HasCahedAccess", any);
            }

            return(result);
        }
        /// <summary>
        /// Does the currently cached value allow access to this module name in this direction?
        /// </summary>
        /// <remarks>
        /// Should never throw a KeyNotFoundException.
        /// </remarks>
        /// <param name="moduleKey">The module to which access may be granted.</param>
        /// <param name="direction">The direction in which access may be granted.</param>
        /// <returns>True if access is permitted, false if it's denied, null if there's no
        /// cached value.</returns>
        private bool?HasCachedAccess(string moduleKey, string direction)
        {
            bool?result = null;

            try
            {
                if (CRMPermissionsCache.cache.ContainsKey(moduleKey))
                {
                    SyncDirection.Direction cachedValue = CRMPermissionsCache.cache[moduleKey];
                    result = (direction == ImportPermissionToken && SyncDirection.AllowOutbound(cachedValue)) ||
                             (direction == ExportPermissionToken && SyncDirection.AllowInbound(cachedValue));
                }
            }
            catch (Exception any)
            {
                ErrorHandler.Handle($"Failed while checking the permissions cache for access to {moduleKey}/{direction}", any);
            }

            return(result);
        }