protected override void Initialize() { base.Initialize(); this.UseEncryptionQueue = Settings.Default.UseEncryptionQueue; this.EncrptionQueueLimit = Settings.Default.EncryptionQueueLimit; WebRequest.DefaultWebProxy = null; this.InitHealthMonitoring(); this.AuthenticationHandler = AccountServiceFactory.GetAuthenticationHandler(this.HealthMonitor); this.AuthenticationCache = AccountCache.CreateCache(this.AuthenticationHandler, false); CounterPublisher.DefaultInstance.AddStaticCounterClass(typeof(Counter), this.ApplicationName); CounterPublisher.DefaultInstance.AddStaticCounterClass(typeof(PhotonCustomAuthCounters), this.ApplicationName); try { Counter.InitializePerformanceCounter(this.ApplicationName); } catch (Exception ex) { log.Error(string.Format("Failed to initialize authentication performance counter. Exception Msg:{0}", ex.Message), ex); } var monitorRequestHandler = new MonitorRequestHandler(this); if (!monitorRequestHandler.AddHandler(/*this*/)) { log.WarnFormat("Failed to register requests handler with path:{0}", MonitorRequestHandler.Path); } }
internal SteamFriends() { friendList = new List<SteamID>(); clanList = new List<SteamID>(); cache = new AccountCache(); }
internal SteamFriends() { friendList = new List <SteamID>(); clanList = new List <SteamID>(); cache = new AccountCache(); dispatchMap = new Dictionary <EMsg, Action <IPacketMsg> > { { EMsg.ClientPersonaState, HandlePersonaState }, { EMsg.ClientClanState, HandleClanState }, { EMsg.ClientFriendsList, HandleFriendsList }, { EMsg.ClientFriendMsgIncoming, HandleFriendMsg }, { EMsg.ClientFriendMsgEchoToSender, HandleFriendEchoMsg }, { EMsg.ClientFSGetFriendMessageHistoryResponse, HandleFriendMessageHistoryResponse }, { EMsg.ClientAccountInfo, HandleAccountInfo }, { EMsg.ClientAddFriendResponse, HandleFriendResponse }, { EMsg.ClientChatEnter, HandleChatEnter }, { EMsg.ClientChatMsg, HandleChatMsg }, { EMsg.ClientChatMemberInfo, HandleChatMemberInfo }, { EMsg.ClientChatRoomInfo, HandleChatRoomInfo }, { EMsg.ClientChatActionResult, HandleChatActionResult }, { EMsg.ClientChatInvite, HandleChatInvite }, { EMsg.ClientSetIgnoreFriendResponse, HandleIgnoreFriendResponse }, { EMsg.ClientFriendProfileInfoResponse, HandleProfileInfoResponse }, { EMsg.ClientPersonaChangeResponse, HandlePersonaChangeResponse }, }; }
private AccountCache FindCache(Address address) { AccountCache cache; var currentTime = DateTime.UtcNow; if (_accountCaches.ContainsKey(address)) { cache = _accountCaches[address]; var diff = currentTime - cache.LastUpdated; if (diff.TotalMinutes < 5) { return(cache); } } cache = new AccountCache() { LastUpdated = currentTime, Holdings = AccountController.GetAccountHoldings(address.Text).Result, Tokens = AccountController.GetAccountTokens(address.Text).Result.ToArray(), Transactions = AccountController.GetAccountTransactions(address.Text).Result //todo remove .Result, }; _accountCaches[address] = cache; return(cache); }
public IMetricTypeCacheReadObject CreateMetricType(Guid accountId, CreateMetricTypeRequestData data) { if (data == null) { throw new ArgumentNullException("data"); } if (string.IsNullOrWhiteSpace(data.SystemName)) { throw new UserFriendlyException("Не укзан SystemName"); } if (string.IsNullOrWhiteSpace(data.DisplayName)) { data.DisplayName = data.SystemName; } var metricTypeId = AllCaches.MetricTypes.CreateMetricType(accountId, data.SystemName); var cache = new AccountCache(accountId); using (var metricType = cache.MetricTypes.Write(metricTypeId)) { metricType.DisplayName = data.DisplayName; metricType.ConditionRed = data.AlarmCondition; metricType.ConditionYellow = data.WarningCondition; metricType.ConditionGreen = data.SuccessCondition; metricType.ElseColor = data.ElseColor; metricType.ActualTime = TimeSpanHelper.FromSeconds(data.ActualTimeSecs); metricType.NoSignalColor = data.NoSignalColor; metricType.BeginSave(); metricType.WaitSaveChanges(); return(metricType); } }
internal SteamFriends() { friendList = new List<SteamID>(); clanList = new List<SteamID>(); cache = new AccountCache(); dispatchMap = new Dictionary<EMsg, Action<IPacketMsg>> { { EMsg.ClientPersonaState, HandlePersonaState }, { EMsg.ClientClanState, HandleClanState }, { EMsg.ClientFriendsList, HandleFriendsList }, { EMsg.ClientFriendMsgIncoming, HandleFriendMsg }, { EMsg.ClientFriendMsgEchoToSender, HandleFriendEchoMsg }, { EMsg.ClientAccountInfo, HandleAccountInfo }, { EMsg.ClientAddFriendResponse, HandleFriendResponse }, { EMsg.ClientChatEnter, HandleChatEnter }, { EMsg.ClientChatMsg, HandleChatMsg }, { EMsg.ClientChatMemberInfo, HandleChatMemberInfo }, { EMsg.ClientChatRoomInfo, HandleChatRoomInfo }, { EMsg.ClientChatActionResult, HandleChatActionResult }, { EMsg.ClientChatInvite, HandleChatInvite }, { EMsg.ClientSetIgnoreFriendResponse, HandleIgnoreFriendResponse }, { EMsg.ClientFriendProfileInfoResponse, HandleProfileInfoResponse }, { EMsg.ClientPersonaChangeResponse, HandlePersonaChangeResponse }, }; }
public void DeleteMetricType(Guid accountId, Guid metricTypeId) { var cache = new AccountCache(accountId); using (var metricType = cache.MetricTypes.Write(metricTypeId)) { metricType.IsDeleted = true; metricType.BeginSave(); } var metrics = cache.Metrics.GetAllLoaded() .Where(x => x.MetricTypeId == metricTypeId) .ToArray(); foreach (var metric in metrics) { using (var writeMetric = cache.Metrics.Write(metric)) { writeMetric.IsDeleted = true; writeMetric.BeginSave(); } } // подождем сохранения всех изменений в БД AllCaches.MetricTypes.SaveChanges(); AllCaches.Metrics.SaveChanges(); // обновим статистику лимитов var limitChecker = AccountLimitsCheckerManager.GetCheckerForAccount(accountId); limitChecker.RefreshMetricsCount(); // статусы НЕ обновляем, т.к. это может выполняться очень долго }
public UserHandler() { login = new Login.LoginHandler(); register = new Register.RegisterHandler(); userdataRequest = new UserData.UserDataRequestHandler(); accountCache = AccountCache.Instance; }
public IMetricCacheReadObject CreateMetric(Guid accountId, CreateMetricRequestData data) { if (data == null) { throw new ArgumentNullException("data"); } var meticType = GetOrCreateType(accountId, data.MetricName); var metricId = CreateMetric(accountId, data.ComponentId, meticType.Id); var cache = new AccountCache(accountId); using (var metric = cache.Metrics.Write(metricId)) { metric.ActualTime = TimeSpanHelper.FromSeconds(data.ActualTimeSecs); metric.NoSignalColor = data.NoSignalColor; metric.ConditionRed = data.AlarmCondition; metric.ConditionYellow = data.WarningCondition; metric.ConditionGreen = data.SuccessCondition; metric.ElseColor = data.ElseColor; metric.BeginSave(); } var metrikRead = cache.Metrics.Read(metricId); metrikRead.WaitSaveChanges(); return(metrikRead); }
public void SetUnitTestNextTime(Guid accountId, SetUnitTestNextTimeRequestData data) { if (data == null) { throw new ArgumentNullException("data"); } if (data.UnitTestId == null) { throw new ParameterRequiredException("UnitTestId"); } var cache = new AccountCache(accountId); using (var unitTest = cache.UnitTests.Write(data.UnitTestId.Value)) { if (data.NextTime == null) { unitTest.NextDate = DateTime.Now; } else { unitTest.NextDate = data.NextTime.Value; } unitTest.BeginSave(); } }
public JobUnitAppService(JobUnitManager jobUnitManager, IRepository <JobUnit> jobUnitRepository, IRepository <JobCommercialUnit> jobDetailUnitRepository, IRepository <EmployeeUnit> employeeUnitRepository, IRepository <CustomerUnit> customerUnitRepository, IJobCommercialAppService jobCommercialAppService, IRepository <OrganizationUnit, long> organizationUnitRepository, IRepository <JobAccountUnit, long> jobAccountUnitRepository, IRepository <CoaUnit> coaUnitRepository, IRepository <AccountUnit, long> accountUnitRepository, IRepository <ValueAddedTaxRecoveryUnit> valueAddedTaxRecoveryUnitRepository, IRepository <ValueAddedTaxTypeUnit> valueAddedTaxTypeUnitRepository, IRepository <TypeOfCountryUnit, short> typeOfCountryUnitRepository, IRepository <CountryUnit> countryUnitRepository, IJobAccountUnitAppService jobAccountUnitAppService, IRepository <TaxCreditUnit> taxCreditUnitRepository, ICacheManager cacheManager, CustomAppSession customAppSession, IUnitOfWorkManager unitOfWorkManager, IRepository <JobLocationUnit> jobLocationRepository, DivisionCache divisioncache, AccountCache accountcache, CustomerCache customercache, ICustomJobAccountRepository jobAccountRepository) { _jobUnitManager = jobUnitManager; _jobUnitRepository = jobUnitRepository; _jobDetailUnitRepository = jobDetailUnitRepository; _employeeUnitRepository = employeeUnitRepository; _customerUnitRepository = customerUnitRepository; _jobCommercialAppService = jobCommercialAppService; _organizationUnitRepository = organizationUnitRepository; _coaUnitRepository = coaUnitRepository; _accountUnitRepository = accountUnitRepository; _jobAccountUnitRepository = jobAccountUnitRepository; _valueAddedTaxRecoveryUnitRepository = valueAddedTaxRecoveryUnitRepository; _valueAddedTaxTypeUnitRepository = valueAddedTaxTypeUnitRepository; _typeOfCountryUnitRepository = typeOfCountryUnitRepository; _countryUnitRepository = countryUnitRepository; _jobAccountUnitAppService = jobAccountUnitAppService; _taxCreditUnitRepository = taxCreditUnitRepository; _cacheManager = cacheManager; _customAppSession = customAppSession; _unitOfWorkManager = unitOfWorkManager; _jobLocationRepository = jobLocationRepository; _divisioncache = divisioncache; _accountcache = accountcache; _customercache = customercache; _jobAccountRepository = jobAccountRepository; }
public void LockRepeat() { var account = TestHelper.GetTestAccount(); var componentObj = account.CreateTestApplicationComponent(); var componentId = componentObj.Id; ComponentCacheWriteObject component0 = null; var cache = new AccountCache(account.Id); var component1 = cache.Components.Write(componentId); Assert.Equal(1, component1.Response.Lock.Count); var component2 = cache.Components.Write(componentId); Assert.Equal(2, component1.Response.Lock.Count); component0 = component1; component1.Dispose(); component2.Dispose(); Assert.False(component0.Response.Lock.IsLocked); Assert.Equal(0, component0.Response.Lock.Count); account.CheckCacheNoLocks(); }
internal SteamFriends() { friendList = new List <SteamID>(); clanList = new List <SteamID>(); cache = new AccountCache(); }
public void GetAccountReturnsCachedAccountTest() { var expected = new Account { Id = Guid.NewGuid(), Provider = Guid.NewGuid().ToString(), Subject = Guid.NewGuid().ToString() }; var username = expected.Provider + "|" + expected.Subject; var cacheKey = "Account|" + username; var cache = Substitute.For <IMemoryCache>(); var config = Substitute.For <ICacheConfig>(); object value; cache.TryGetValue(cacheKey, out value).Returns( x => { x[1] = expected.Id; return(true); }); var sut = new AccountCache(cache, config); var actual = sut.GetAccount(username); actual.Should().BeEquivalentTo(expected); }
public IBulbCacheReadObject GetUnitTestResult(Guid accountId, Guid unitTestId) { var cache = new AccountCache(accountId); var unitTest = cache.UnitTests.Read(unitTestId); var processDate = DateTime.Now; return(GetUnitTestResultInternal(unitTest, processDate)); }
private Account CreateNewAccount(string name, string password) { var ac = Account.CreateAccount(name, password, 20); AccountCache.Add(ac); Directory.CreateDirectory(Directory.GetParent(accountFilePath).FullName); GameSerializer.SaveToFile(accountFilePath, AccountCache); return(ac); }
protected override SynthesizedBlock SynthesizeBlock(IBlock block, AccountCache accountCache, Dictionary <TransactionId, ITransaction> blockConfirmedTransactions) { SynthesizedBlock synthesizedBlock = base.SynthesizeBlock(block, accountCache, blockConfirmedTransactions); if (synthesizedBlock is NeuraliumSynthesizedBlock neuraliumSynthesizedBlock && block is INeuraliumBlock neuraliumBlock) { } return(synthesizedBlock); }
public void GetAccountThrowsExceptionWithInvalidUsernameTest(string username) { var cache = Substitute.For <IMemoryCache>(); var config = Substitute.For <ICacheConfig>(); var sut = new AccountCache(cache, config); Action action = () => sut.GetAccount(username); action.Should().Throw <ArgumentException>(); }
public void StoreAccountThrowsExceptionWithNullAccountTest() { var cache = Substitute.For <IMemoryCache>(); var config = Substitute.For <ICacheConfig>(); var sut = new AccountCache(cache, config); Action action = () => sut.StoreAccount(null); action.Should().Throw <ArgumentNullException>(); }
private static void CheckCacheSize(AccountCache cache) { var totalCacheSize = cache.Sum(x => System.IO.File.Exists(x.Path) ? new System.IO.FileInfo(x.Path).Length : 0); var totalCacheSizeMB = (totalCacheSize / 1024f / 1024f); if (totalCacheSizeMB > 64) { System.Console.WriteLine("Flushing cache due to size..."); cache.DeleteAll(); } }
public IComponentCacheReadObject CalculateAllStatuses(Guid accountId, Guid componentId) { var cache = new AccountCache(accountId); var component = cache.Components.Read(componentId); if (component.IsDeleted) { return(component); } return(RecalculateComponentStatuses(component)); }
private static void CheckCacheSize(AccountCache cache) { var totalCacheSize = cache.Sum(x => System.IO.File.Exists(x.Path) ? new System.IO.FileInfo(x.Path).Length : 0); var totalCacheSizeMB = (totalCacheSize / 1024f / 1024f); if (totalCacheSizeMB > 64) { System.Console.WriteLine("Flushing cache due to size..."); cache.DeleteAll(); } }
public IComponentCacheReadObject GetComponentById(Guid accountId, Guid id) { var cache = new AccountCache(accountId); var component = cache.Components.Read(id); if (component == null) { throw new UnknownComponentIdException(id, accountId); } return(component); }
private static void LogonRequestCallback(Client pClient, Header pHeader, LogonRequest pLogonRequest) { Account account = AccountCache.RetrieveAccountByEmail(pLogonRequest.Email); if (account == null) { pClient.PermittedServices.Clear(); pClient.ImportedServices.Clear(); pClient.SendAuthenticationClientLogonComplete(new LogonResult(EErrorCode.LoginInformationWasIncorrect)); return; } }
public List <ProjectAccountViewModel> GetProjectAccountsByProjectId(int projectId) { var viewModels = ProjectAccountCache.Where(o => o.ProjectID == projectId).ToList(); viewModels.ForEach(o => { if (o.Account == null) { o.Account = AccountCache.FirstOrDefault(a => a.Id == o.AccountID); } }); return(viewModels); }
public void EnableComponent(Guid accountId, Guid componentId) { var cache = new AccountCache(accountId); IComponentCacheReadObject componentCacheRead = null; using (var component = cache.Components.Write(componentId)) { componentCacheRead = component; component.Enable = true; component.BeginSave(); } UpdateParentEnableFlags(componentCacheRead, true); RecalculateComponentStatuses(componentCacheRead); }
public void RemoveAccountRemovesCachedAccountTest() { var username = Guid.NewGuid().ToString(); var cacheKey = "Account|" + username; var cache = Substitute.For <IMemoryCache>(); var config = Substitute.For <ICacheConfig>(); var sut = new AccountCache(cache, config); sut.RemoveAccount(username); cache.Received().Remove(cacheKey); }
protected Event CreateUnitTestResultEvent( IUnitTestCacheReadObject unitTest, SendUnitTestResultRequestData data, DateTime processDate) { data.Message = data.Message ?? string.Empty; if (data.Message.Length > 255) { data.Message = data.Message.Substring(0, 255); } var importance = EventImportanceHelper.Get(data.Result ?? UnitTestResult.Unknown); var cache = new AccountCache(unitTest.AccountId); var unittestType = cache.UnitTestTypes.Read(unitTest.TypeId); var actualInterval = unitTest.ActualTime // сначала берем из настроек проверки в ЛК ?? TimeSpanHelper.FromSeconds(unittestType.ActualTimeSecs) // потом из настроек типа проверки в ЛК ?? TimeSpanHelper.FromSeconds(data.ActualIntervalSeconds) // потом из сообщения ?? TimeSpan.FromMinutes(5); // по умолчанию 5 мин var actualDate = processDate + actualInterval; var joinKeyHash = data.ReasonCode ?? 0; var result = new Event() { Id = Guid.NewGuid(), Count = 1, JoinKeyHash = joinKeyHash, Importance = importance, OwnerId = unitTest.Id, ActualDate = actualDate, CreateDate = DateTime.Now, LastUpdateDate = processDate, StartDate = processDate, EndDate = processDate, Message = data.Message, EventTypeId = SystemEventType.UnitTestResult.Id, Category = EventCategory.UnitTestResult }; if (data.Properties != null) { result.Properties = ApiConverter.GetEventProperties(data.Properties); } return(result); }
public int UpdateMetrics(Guid accountId, int maxCount) { var accountDbContext = Context.GetAccountDbContext(accountId); var metricRepository = accountDbContext.GetMetricRepository(); var metrics = metricRepository.GetNotActual(maxCount); var cache = new AccountCache(accountId); foreach (var metric in metrics) { var metricRead = cache.Metrics.Read(metric.Id); var processDate = DateTime.Now; GetActualMetricInternal(metricRead, processDate); } return(metrics.Count); }
private async Task <bool> ExecutePrinter(OnPrintBaseRender onPrintBase, CardOrderItemResponse orderItem) { var isRefund = orderItem.Type == (int)CardOrderTypeEnums.Refund; if (isRefund) { var refundResp = await onPrintBase.ExecuteRefundAsync(orderItem.ToRefundModel(), AccountCache.ToMerchantResponse(), false); return(refundResp?.IsSuccess ?? false); } var resp = await onPrintBase.ExecutePrintAsync(orderItem.ToModel(), AccountCache.ToMerchantResponse(), false); return(resp?.IsSuccess ?? false); }
public void UpdateMetric(Guid accountId, UpdateMetricRequestData data) { var cache = new AccountCache(accountId); using (var metric = cache.Metrics.Write(data.MetricId)) { metric.ConditionRed = data.AlarmCondition; metric.ConditionYellow = data.WarningCondition; metric.ConditionGreen = data.SuccessCondition; metric.ElseColor = data.ElseColor; metric.ActualTime = TimeSpanHelper.FromSeconds(data.ActualTimeSecs); metric.NoSignalColor = data.NoSignalColor; metric.BeginSave(); } cache.Metrics.Read(data.MetricId).WaitSaveChanges(); }
public void GetAccountReturnsNullWhenCachedAccountNotFoundTest() { var username = Guid.NewGuid().ToString(); var cacheKey = "Account|" + username; var cache = Substitute.For <IMemoryCache>(); var config = Substitute.For <ICacheConfig>(); object value; cache.TryGetValue(cacheKey, out value).Returns(x => false); var sut = new AccountCache(cache, config); var actual = sut.GetAccount(username); actual.Should().BeNull(); }
public void DisableComponent(Guid accountId, Guid componentId, DateTime?toDate, string comment) { if (comment != null && comment.Length > 1000) { throw new ResponseCodeException( Zidium.Api.ResponseCode.ParameterError, "Максимальная длина комментария 1000 символов, а указано " + comment.Length); } if (toDate.HasValue && toDate < DateTime.Now) { throw new ResponseCodeException( Zidium.Api.ResponseCode.ParameterError, "Дата, до которой выключается компонент, должна быть больше текущего времени"); } var cache = new AccountCache(accountId); // обновим компонент IComponentCacheReadObject componentCacheRead = null; using (var component = cache.Components.Write(componentId)) { // настройки выключения component.Enable = false; component.DisableComment = comment; component.DisableToDate = toDate; componentCacheRead = component; component.BeginSave(); } UpdateParentEnableFlags(componentCacheRead, true); RecalculateComponentStatuses(componentCacheRead); // обновим родительский компонент if (componentCacheRead.ParentId != null) { var parent = cache.Components.Read(componentCacheRead.ParentId.Value); RecalculateComponentStatuses(parent); } }
public GitHubCache(Account account) { _account = account.Cache; }