Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// If I am currently configured to do so, synchronise the items for which I am
 /// responsible once.
 /// </summary>
 internal override void PerformIteration()
 {
     if (Globals.ThisAddIn.HasCrmUserSession)
     {
         if (SyncDirection.AllowInbound(this.Direction))
         {
             Log.Debug($"{this.GetType().Name} SynchroniseAll starting");
             this.SynchroniseAll();
             Log.Debug($"{this.GetType().Name} SynchroniseAll completed");
         }
         else
         {
             Log.Debug($"{this.GetType().Name}.SynchroniseAll not running because not enabled");
         }
     }
     else
     {
         Log.Debug($"{this.GetType().Name}.SynchroniseAll not running because no session");
     }
 }
Ejemplo n.º 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);
        }