예제 #1
0
 public NotifyService(DbWorker db, IServiceProvider serviceProvider, ICacheNotify <NotifyMessage> cacheNotify, IOptionsMonitor <ILog> options)
 {
     this.db          = db;
     ServiceProvider  = serviceProvider;
     this.cacheNotify = cacheNotify;
     log = options.CurrentValue;
 }
예제 #2
0
        public DistributedTaskQueue(string name, int maxThreadsCount)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }
            if (maxThreadsCount <= 0)
            {
                throw new ArgumentOutOfRangeException("maxThreadsCount");
            }

            key          = name + GetType().Name;
            cache        = AscCache.Default;
            notify       = AscCache.Notify;
            scheduler    = new LimitedConcurrencyLevelTaskScheduler(maxThreadsCount);
            cancelations = new ConcurrentDictionary <string, CancellationTokenSource>();

            notify.Subscribe <DistributedTaskCancelation>((c, a) =>
            {
                CancellationTokenSource s;
                if (cancelations.TryGetValue(c.Id, out s))
                {
                    s.Cancel();
                }
            });
        }
예제 #3
0
        public CachedQuotaService(IQuotaService service)
        {
            if (service == null)
            {
                throw new ArgumentNullException("service");
            }

            this.service    = service;
            cache           = AscCache.Memory;
            interval        = new TrustInterval();
            CacheExpiration = TimeSpan.FromMinutes(10);

            cacheNotify = AscCache.Notify;
            cacheNotify.Subscribe <QuotaCacheItem>((i, a) =>
            {
                if (i.Key == KEY_QUOTA_ROWS)
                {
                    interval.Expire();
                }
                else if (i.Key == KEY_QUOTA)
                {
                    cache.Remove(KEY_QUOTA);
                }
            });
        }
예제 #4
0
 static GoogleDriveProviderInfo()
 {
     CacheNotify = AscCache.Notify;
     CacheNotify.Subscribe <GoogleDriveCacheItem>((i, action) =>
     {
         if (action != CacheNotifyAction.Remove)
         {
             return;
         }
         if (i.ResetEntry)
         {
             CacheEntry.Remove("drive-" + i.Key);
         }
         if (i.ResetAll)
         {
             CacheEntry.Remove(new Regex("^drive-" + i.Key + ".*"));
             CacheChildFiles.Remove(new Regex("^drivef-" + i.Key + ".*"));
             CacheChildFolders.Remove(new Regex("^drived-" + i.Key + ".*"));
         }
         if (i.ResetChilds)
         {
             if (!i.ChildFolder.HasValue || !i.ChildFolder.Value)
             {
                 CacheChildFiles.Remove("drivef-" + i.Key);
             }
             if (!i.ChildFolder.HasValue || i.ChildFolder.Value)
             {
                 CacheChildFolders.Remove("drived-" + i.Key);
             }
         }
     });
 }
예제 #5
0
 public GoogleDriveApp(
     PathProvider pathProvider,
     TenantUtil tenantUtil,
     AuthContext authContext,
     SecurityContext securityContext,
     UserManager userManager,
     UserManagerWrapper userManagerWrapper,
     CookiesManager cookiesManager,
     MessageService messageService,
     Global global,
     GlobalStore globalStore,
     EmailValidationKeyProvider emailValidationKeyProvider,
     FilesLinkUtility filesLinkUtility,
     SettingsManager settingsManager,
     PersonalSettingsHelper personalSettingsHelper,
     BaseCommonLinkUtility baseCommonLinkUtility,
     IOptionsMonitor <ILog> option,
     FileUtility fileUtility,
     FilesSettingsHelper filesSettingsHelper,
     IOptionsSnapshot <AccountLinker> snapshot,
     SetupInfo setupInfo,
     GoogleLoginProvider googleLoginProvider,
     TokenHelper tokenHelper,
     DocumentServiceConnector documentServiceConnector,
     ThirdPartyAppHandler thirdPartyAppHandler,
     IServiceProvider serviceProvider,
     TenantManager tenantManager,
     CoreBaseSettings coreBaseSettings,
     CoreSettings coreSettings,
     IConfiguration configuration,
     ICacheNotify <ConsumerCacheItem> cache,
     string name, int order, Dictionary <string, string> additional)
     : base(tenantManager, coreBaseSettings, coreSettings, configuration, cache, name, order, additional)
 {
     Logger                     = option.CurrentValue;
     PathProvider               = pathProvider;
     TenantUtil                 = tenantUtil;
     AuthContext                = authContext;
     SecurityContext            = securityContext;
     UserManager                = userManager;
     UserManagerWrapper         = userManagerWrapper;
     CookiesManager             = cookiesManager;
     MessageService             = messageService;
     Global                     = global;
     GlobalStore                = globalStore;
     EmailValidationKeyProvider = emailValidationKeyProvider;
     FilesLinkUtility           = filesLinkUtility;
     SettingsManager            = settingsManager;
     PersonalSettingsHelper     = personalSettingsHelper;
     BaseCommonLinkUtility      = baseCommonLinkUtility;
     FileUtility                = fileUtility;
     FilesSettingsHelper        = filesSettingsHelper;
     Snapshot                   = snapshot;
     SetupInfo                  = setupInfo;
     GoogleLoginProvider        = googleLoginProvider;
     TokenHelper                = tokenHelper;
     DocumentServiceConnector   = documentServiceConnector;
     ThirdPartyAppHandler       = thirdPartyAppHandler;
     ServiceProvider            = serviceProvider;
 }
        static TariffService()
        {
            cache  = AscCache.Memory;
            notify = new KafkaCache <TariffCacheItem>();
            notify.Subscribe((i) =>
            {
                cache.Remove(GetTariffCacheKey(i.TenantId));
                cache.Remove(GetBillingUrlCacheKey(i.TenantId));
                cache.Remove(GetBillingPaymentCacheKey(i.TenantId, DateTime.MinValue, DateTime.MaxValue)); // clear all payments
            }, CacheNotifyAction.Remove);

            //TODO: Change code of WCF -> not supported in .NET standard/.Net Core

            /*try
             * {
             *  var section = (ClientSection)ConfigurationManager.GetSection("system.serviceModel/client");
             *  if (section != null)
             *  {
             *      billingConfigured = section.Endpoints.Cast<ChannelEndpointElement>()
             *          .Any(e => e.Contract == typeof(IService).FullName);
             *  }
             * }
             * catch (Exception err)
             * {
             *  log.Error(err);
             * }*/
        }
예제 #7
0
 public StudioNotifyServiceHelper(StudioNotifyHelper studioNotifyHelper, AuthContext authContext, TenantManager tenantManager, ICacheNotify <NotifyItem> cache)
 {
     StudioNotifyHelper = studioNotifyHelper;
     AuthContext        = authContext;
     TenantManager      = tenantManager;
     Cache = cache;
 }
예제 #8
0
        static DropboxDaoBase()
        {
            CacheNotify = AscCache.Notify;
            CacheNotify.Subscribe <DropboxCacheItem>((i, action) =>
            {
                if (action != CacheNotifyAction.Remove)
                {
                    return;
                }
                if (i.ResetAll)
                {
                    CacheFile.Remove(new Regex("^dropboxf-.*"));
                    CacheFolder.Remove(new Regex("^dropboxd-.*"));
                    CacheChildItems.Remove(new Regex("^dropbox-.*"));
                }

                if (!i.IsFile.HasValue)
                {
                    CacheChildItems.Remove("dropbox-" + i.Key);

                    CacheFolder.Remove("dropboxd-" + i.Key);
                }
                else
                {
                    if (i.IsFile.Value)
                    {
                        CacheFile.Remove("dropboxf-" + i.Key);
                    }
                    else
                    {
                        CacheFolder.Remove("dropboxd-" + i.Key);
                    }
                }
            });
        }
예제 #9
0
        static TariffService()
        {
            cache  = AscCache.Memory;
            notify = AscCache.Notify;
            notify.Subscribe <TariffCacheItem>((i, a) =>
            {
                cache.Remove(GetTariffCacheKey(i.TenantId));
                cache.Remove(GetBillingUrlCacheKey(i.TenantId));
                cache.Remove(GetBillingPaymentCacheKey(i.TenantId, DateTime.MinValue, DateTime.MaxValue)); // clear all payments
            });

            try
            {
                var section = (ClientSection)ConfigurationManager.GetSection("system.serviceModel/client");
                if (section != null)
                {
                    billingConfigured = section.Endpoints.Cast <ChannelEndpointElement>()
                                        .Any(e => e.Contract == typeof(IService).FullName);
                }
            }
            catch (Exception err)
            {
                log.Error(err);
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">Name of queue</param>
        /// <param name="maxThreadsCount">limit of threads count; Default: -1 - no limit</param>
        public DistributedTaskQueue(string name, int maxThreadsCount = -1)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            key       = name + GetType().Name;
            scheduler = maxThreadsCount <= 0
                ? TaskScheduler.Default
                : new LimitedConcurrencyLevelTaskScheduler(maxThreadsCount);

            notify = new KafkaCache <DistributedTaskCancelation>();
            notify.Subscribe((c) =>
            {
                if (cancelations.TryGetValue(c.Id, out var s))
                {
                    s.Cancel();
                }
            }, CacheNotifyAction.Remove);

            notifyCache = new KafkaCache <DistributedTaskCache>();
            notifyCache.Subscribe((c) =>
            {
                cache.HashSet(key, c.Id, (DistributedTaskCache)null);
            }, CacheNotifyAction.Remove);

            notifyCache.Subscribe((c) =>
            {
                cache.HashSet(key, c.Id, c);
            }, CacheNotifyAction.InsertOrUpdate);
        }
예제 #11
0
        static BoxProviderInfo()
        {
            CacheNotify = AscCache.Notify;
            CacheNotify.Subscribe <BoxCacheItem>((i, action) =>
            {
                if (action != CacheNotifyAction.Remove)
                {
                    return;
                }
                if (i.ResetAll)
                {
                    CacheChildItems.Remove(new Regex("^box-" + i.Key + ".*"));
                    CacheFile.Remove(new Regex("^boxf-" + i.Key + ".*"));
                    CacheFolder.Remove(new Regex("^boxd-" + i.Key + ".*"));
                }

                if (!i.IsFile.HasValue)
                {
                    CacheChildItems.Remove("box-" + i.Key);

                    CacheFolder.Remove("boxd-" + i.Key);
                }
                else
                {
                    if (i.IsFile.Value)
                    {
                        CacheFile.Remove("boxf-" + i.Key);
                    }
                    else
                    {
                        CacheFolder.Remove("boxd-" + i.Key);
                    }
                }
            });
        }
예제 #12
0
 public CachedAzService(DbAzService service, AzServiceCache azServiceCache)
 {
     this.service    = service ?? throw new ArgumentNullException("service");
     Cache           = azServiceCache.Cache;
     cacheNotify     = azServiceCache.CacheNotify;
     CacheExpiration = TimeSpan.FromMinutes(10);
 }
예제 #13
0
 static GoogleDriveDaoBase()
 {
     CacheNotify = AscCache.Notify;
     CacheNotify.Subscribe <GoogleDriveCacheItem>((i, o) =>
     {
         if (i.ResetEntry)
         {
             DriveFile d;
             CacheEntry.TryRemove(i.Key, out d);
         }
         if (i.ResetAll)
         {
             CacheEntry.Clear();
             CacheChildFiles.Clear();
             CacheChildFolders.Clear();
         }
         if (i.ResetChilds)
         {
             List <DriveFile> value;
             if (!i.ChildFolder.HasValue || !i.ChildFolder.Value)
             {
                 CacheChildFiles.TryRemove(i.Key, out value);
             }
             if (!i.ChildFolder.HasValue || i.ChildFolder.Value)
             {
                 CacheChildFolders.TryRemove(i.Key, out value);
             }
         }
     });
 }
예제 #14
0
        public TariffServiceStorage(ICacheNotify <TariffCacheItem> notify, ICache cache)
        {
            Cache  = cache;
            Notify = notify;
            Notify.Subscribe((i) =>
            {
                Cache.Remove(TariffService.GetTariffCacheKey(i.TenantId));
                Cache.Remove(TariffService.GetBillingUrlCacheKey(i.TenantId));
                Cache.Remove(TariffService.GetBillingPaymentCacheKey(i.TenantId)); // clear all payments
            }, CacheNotifyAction.Remove);

            //TODO: Change code of WCF -> not supported in .NET standard/.Net Core

            /*try
             * {
             *  var section = (ClientSection)ConfigurationManager.GetSection("system.serviceModel/client");
             *  if (section != null)
             *  {
             *      billingConfigured = section.Endpoints.Cast<ChannelEndpointElement>()
             *          .Any(e => e.Contract == typeof(IService).FullName);
             *  }
             * }
             * catch (Exception err)
             * {
             *  log.Error(err);
             * }*/
        }
예제 #15
0
        private TariffService(
            IQuotaService quotaService,
            ITenantService tenantService,
            CoreBaseSettings coreBaseSettings,
            CoreSettings coreSettings,
            IConfiguration configuration,
            TariffServiceStorage tariffServiceStorage,
            IOptionsMonitor <ILog> options)

        {
            log = options.CurrentValue;
            this.quotaService    = quotaService;
            this.tenantService   = tenantService;
            CoreSettings         = coreSettings;
            Configuration        = configuration;
            TariffServiceStorage = tariffServiceStorage;
            Options          = options;
            CoreBaseSettings = coreBaseSettings;
            CacheExpiration  = DEFAULT_CACHE_EXPIRATION;
            test             = configuration["core:payment:test"] == "true";
            int.TryParse(configuration["core:payment:delay"], out paymentDelay);

            cache  = TariffServiceStorage.Cache;
            notify = TariffServiceStorage.Notify;
        }
        static UserPhotoManager()
        {
            try
            {
                CacheNotify = new KafkaCache <UserPhotoManagerCacheItem>();

                CacheNotify.Subscribe((data) =>
                {
                    var userId = new Guid(data.UserID.ToByteArray());
                    Photofiles.GetOrAdd(data.Size, (r) => new ConcurrentDictionary <Guid, string>())[userId] = data.FileName;
                }, CacheNotifyAction.InsertOrUpdate);

                CacheNotify.Subscribe((data) =>
                {
                    var userId = new Guid(data.UserID.ToByteArray());

                    try
                    {
                        foreach (var s in (CacheSize[])Enum.GetValues(typeof(CacheSize)))
                        {
                            Photofiles.TryGetValue(s, out var dict);
                            dict?.TryRemove(userId, out _);
                        }
                        SetCacheLoadedForTenant(false, data.TenantId);
                    }
                    catch { }
                }, CacheNotifyAction.Remove);
            }
            catch (Exception)
            {
            }
        }
예제 #17
0
 public SmsKeyStorageCache(ICacheNotify <SmsKeyCacheKey> keyCacheNotify)
 {
     CheckCache     = AscCache.Memory;
     KeyCache       = AscCache.Memory;
     KeyCacheNotify = keyCacheNotify;
     KeyCacheNotify.Subscribe(r => KeyCache.Remove(r.Key), CacheNotifyAction.Remove);
 }
예제 #18
0
 public StorageUploader(IServiceProvider serviceProvider, TempStream tempStream, ICacheNotify <MigrationProgress> cacheMigrationNotify, DistributedTaskQueueOptionsManager options)
 {
     ServiceProvider      = serviceProvider;
     TempStream           = tempStream;
     CacheMigrationNotify = cacheMigrationNotify;
     Queue = options.Get(nameof(StorageUploader));
 }
예제 #19
0
        public DistributedTaskCacheNotify(ICacheNotify <DistributedTaskCancelation> notify, ICacheNotify <DistributedTaskCache> notifyCache)
        {
            Cancelations = new ConcurrentDictionary <string, CancellationTokenSource>();

            this.notify = notify;

            notify.Subscribe((c) =>
            {
                if (Cancelations.TryGetValue(c.Id, out var s))
                {
                    s.Cancel();
                }
            }, CacheNotifyAction.Remove);

            this.notifyCache = notifyCache;

            notifyCache.Subscribe((c) =>
            {
                Cache.HashSet(c.Key, c.Id, (DistributedTaskCache)null);
            }, CacheNotifyAction.Remove);

            notifyCache.Subscribe((c) =>
            {
                Cache.HashSet(c.Key, c.Id, c);
            }, CacheNotifyAction.InsertOrUpdate);
        }
예제 #20
0
        public QuotaServiceCache(IConfiguration Configuration, ICacheNotify <QuotaCacheItem> cacheNotify)
        {
            if (Configuration["core:enable-quota-cache"] == null)
            {
                QuotaCacheEnabled = true;
            }
            else
            {
                QuotaCacheEnabled = !bool.TryParse(Configuration["core:enable-quota-cache"], out var enabled) || enabled;
            }

            CacheNotify = cacheNotify;
            Cache       = AscCache.Memory;
            Interval    = new TrustInterval();

            cacheNotify.Subscribe((i) =>
            {
                if (i.Key == KEY_QUOTA_ROWS)
                {
                    Interval.Expire();
                }
                else if (i.Key == KEY_QUOTA)
                {
                    Cache.Remove(KEY_QUOTA);
                }
            }, CacheNotifyAction.Any);
        }
예제 #21
0
        static BoxDaoBase()
        {
            CacheNotify = AscCache.Notify;
            CacheNotify.Subscribe <BoxCacheItem>((i, o) =>
            {
                if (i.ResetAll)
                {
                    CacheFile.Clear();
                    CacheFolder.Clear();
                    CacheChildItems.Clear();
                }

                if (!i.IsFile.HasValue)
                {
                    List <BoxItem> item;
                    CacheChildItems.TryRemove(i.Key, out item);

                    BoxFolder folder;
                    CacheFolder.TryRemove(i.Key, out folder);
                }
                else
                {
                    if (i.IsFile.Value)
                    {
                        BoxFile file;
                        CacheFile.TryRemove(i.Key, out file);
                    }
                    else
                    {
                        BoxFolder folder;
                        CacheFolder.TryRemove(i.Key, out folder);
                    }
                }
            });
        }
예제 #22
0
 public NotifyService(DbWorker db, IServiceProvider serviceProvider, ICacheNotify <NotifyMessage> cacheNotify, ICacheNotify <NotifyInvoke> cacheInvoke, IOptionsMonitor <ILog> options)
 {
     Db = db;
     ServiceProvider = serviceProvider;
     CacheNotify     = cacheNotify;
     CacheInvoke     = cacheInvoke;
     Log             = options.CurrentValue;
 }
        static TenantLogoManager()
        {
            var hideSettings = (ConfigurationManager.AppSettings["web.hide-settings"] ?? "").Split(new[] { ',', ';', ' ' });

            WhiteLabelEnabled = !hideSettings.Contains("WhiteLabel", StringComparer.CurrentCultureIgnoreCase);
            CacheNotify       = new KafkaCache <TenantLogoCacheItem>();
            CacheNotify.Subscribe(r => Cache.Remove(r.Key), CacheNotifyAction.Remove);
        }
예제 #24
0
 public CachedSubscriptionService(DbSubscriptionService service, SubscriptionServiceCache subscriptionServiceCache)
 {
     this.service    = service ?? throw new ArgumentNullException("service");
     cache           = subscriptionServiceCache.Cache;
     notifyRecord    = subscriptionServiceCache.NotifyRecord;
     notifyMethod    = subscriptionServiceCache.NotifyMethod;
     CacheExpiration = TimeSpan.FromMinutes(5);
 }
예제 #25
0
        public AzServiceCache(ICacheNotify <AzRecordCache> cacheNotify)
        {
            CacheNotify = cacheNotify;
            Cache       = AscCache.Memory;

            cacheNotify.Subscribe((r) => UpdateCache(r, true), CacheNotifyAction.Remove);
            cacheNotify.Subscribe((r) => UpdateCache(r, false), CacheNotifyAction.InsertOrUpdate);
        }
예제 #26
0
 public IPRestrictionsService(
     IPRestrictionsRepository iPRestrictionsRepository,
     IPRestrictionsServiceCache iPRestrictionsServiceCache)
 {
     IPRestrictionsRepository = iPRestrictionsRepository;
     cache  = iPRestrictionsServiceCache.Cache;
     notify = iPRestrictionsServiceCache.Notify;
 }
예제 #27
0
        public void GetProgress(ICacheNotify <ProgressEncryption> progress)
        {
            var progressEncryption = new ProgressEncryption()
            {
                Progress = Percentage
            };

            progress.Publish(progressEncryption, CacheNotifyAction.Insert);
        }
예제 #28
0
 public BaseIndexerHelper(ICacheNotify <ClearIndexAction> cacheNotify)
 {
     IsExist = new ConcurrentDictionary <string, bool>();
     Notify  = cacheNotify;
     Notify.Subscribe((a) =>
     {
         IsExist.AddOrUpdate(a.Id, false, (q, w) => false);
     }, CacheNotifyAction.Any);
 }
예제 #29
0
 public GlobalNotify(ICacheNotify <AscCacheItem> notify, IOptionsMonitor <ILog> options, CoreBaseSettings coreBaseSettings)
 {
     Notify = notify;
     Logger = options.Get("ASC.Files");
     if (coreBaseSettings.Standalone)
     {
         ClearCache();
     }
 }
예제 #30
0
 public DataStoreConsumer(
     TenantManager tenantManager,
     CoreBaseSettings coreBaseSettings,
     CoreSettings coreSettings,
     IConfiguration configuration,
     ICacheNotify <ConsumerCacheItem> cache)
     : base(tenantManager, coreBaseSettings, coreSettings, configuration, cache)
 {
 }