コード例 #1
0
ファイル: OrdersService.cs プロジェクト: abaula/MixedCode
        public async Task <decimal> GetOrderAmountAsync(Guid orderId)
        {
            using (var scope = _scopeFactory.Create())
            {
                _logger.LogTrace("Start => GetOrderAmountAsync({0})", orderId);

                var amount = await scope.Get <IGetOrderAmountAsyncWork>()
                             .DoAsync(orderId)
                             .ConfigureAwait(false);

                _logger.LogTrace("End => GetOrderAmountAsync({0}) = {1}", orderId, amount);

                return(amount);
            }
        }
コード例 #2
0
        private async Task LoadExistingJobs()
        {
            try
            {
                using (var scope = scopeFactory.Create("LoadExistingJobs"))
                {
                    var jobStorage = scope.Resolve <IJobStorageService>();
                    var jobs       = await GetCurrentJobs(jobStorage);

                    foreach (var job in jobs)
                    {
                        StartMonitoringJob(job, JobType.EarningsJob);
                    }
                }
            }
            catch (Exception e)
            {
                logger.LogError($"Failed to load existing jobs. Error: {e.Message}", e);
            }
        }
コード例 #3
0
        private async Task LoadExistingJobs()
        {
            try
            {
                using (var scope = scopeFactory.Create("LoadExistingJobs"))
                {
                    var jobStorage = scope.Resolve <IJobStorageService>();
                    var jobs       = await jobStorage.GetCurrentJobs(cancellationToken).ConfigureAwait(false);

                    foreach (var job in jobs)
                    {
                        StartMonitoringJob(job, JobType.EarningsJob);
                    }
                }
            }
            catch (Exception e)
            {
                logger.LogError("Failed to load existing jobs.");
            }
        }
コード例 #4
0
        public void Logon(Guid?licenseGuid, LogonHistory history)
        {
            IUnitOfWorkScope scope   = null;
            Account          account = null;

            try
            {
                scope = _scopeFactory.Create();

                IsValid = true;
                _logger.Info($"Начало запроса авторизации для {licenseGuid}");
                if (!licenseGuid.HasValue)
                {
                    SetError("Не определен гуид лицензии");
                }
                else
                {
                    account = _accountRepository.GetByLicenseId(licenseGuid.Value);
                    if (account == null)
                    {
                        SetError($"Не найдена УЗ для {licenseGuid}");
                    }
                    else
                    {
                        var license = account.Licenses.FirstOrDefault(l => l.Guid == licenseGuid);
                        if (license == null)
                        {
                            SetError($"Не найдена лицензия по гуиду {licenseGuid}");
                        }
                        else if (!license.Access)
                        {
                            SetError($"Для УЗ {account.Id} заблокирован доступ для лицензии {licenseGuid}");
                        }
                    }
                }

                history.Account = account;
                _logonHistoryRepository.Save(history);

                scope.Commit();
                _logger.Info($"Завершение запроса авторизации для {licenseGuid} и УЗ {account.Return(a=>a.Id)} и логона {history.Return(h=>h.Id)}");
            }
            catch (Exception e)
            {
                SetError(e.ToString(), true);
            }
            finally
            {
                scope.Do(s => s.Dispose());
            }
        }
コード例 #5
0
        public Account GetByLicenseId(Guid guid)
        {
            Account account = null;

            using (var scope = _scopeFactory.Create())
            {
                _repository.FetchMany(a => a.Licenses).ThenFetch(l => l.Application);
                _repository.FetchMany(a => a.Licenses).ThenFetch(l => l.Type);
                account = _repository.FirstOrDefault(a => a.Licenses.Any(l => l.Guid == guid));
                scope.Commit();
            }

            return(account);
        }
コード例 #6
0
        public void Save(LogonHistory history)
        {
            Guard.AssertNotNull(history, "Не определен логон для сохранения");

            using (var scope = _scopeFactory.Create())
            {
                history.DateTime = DateTime.Now;
                history.Host     = HttpContext.Current.GetUserHostName();
                history.IP       = HttpContext.Current.GetVisitorIPAddress(); //Processor.GetClientIP(HttpContext.Current);
                                                                              //history.Comment = string.Format("{0}; IP={1}; {2}", customComment,
                                                                              //    (HttpContext.Current.Request != null ? HttpContext.Current.Request.UserHostAddress : ""),
                                                                              //    comment);

                //history.LogonApplicationID = LogonApplication.iCRM;
                history.InternalIP = HttpContext.Current.GetUserHostAddress();

                _repository.Add(history);
                scope.Commit();
            }
        }