Esempio n. 1
0
        public override void Handle(FoodModel model)
        {
            base.Handle(model);
            var manager = IoC.IocContainer.Get <IScoringManager>();

            manager.OnFoodConsume(BillingHelper.ParseId(model.CharacterId, "characterId"), model.LifeStyle);
        }
Esempio n. 2
0
 public NomenklaturaDto(Nomenklatura nomenklatura, bool main)
     : base(nomenklatura?.Specialisation, false)
 {
     if (nomenklatura == null)
     {
         return;
     }
     if (main)
     {
         this.Id   = nomenklatura.Id;
         this.Name = nomenklatura.Name;
     }
     this.BasePrice        = nomenklatura.BasePrice;
     this.NomenklaturaId   = nomenklatura.Id;
     this.NomenklaturaName = nomenklatura.Name;
     this.LifeStyleId      = nomenklatura.Lifestyle;
     this.LifeStyle        = BillingHelper.GetLifestyle(nomenklatura.Lifestyle).ToString();
     this.Code             = nomenklatura.Code;
     this.Description      = nomenklatura.Description;
     if (string.IsNullOrEmpty(nomenklatura.PictureUrl))
     {
         this.PictureUrl = nomenklatura?.Specialisation?.ProductType?.PictureUrl ?? "";
     }
     else
     {
         this.PictureUrl = nomenklatura.PictureUrl;
     }
     this.BaseCount = nomenklatura.BaseCount;
 }
        public async Task <bool> OnMessageDispatchedAsync(string engagementAccount, string messageId, string customMessageId, List <string> targets, ConnectorIdentifier connector)
        {
            if (!string.IsNullOrEmpty(customMessageId))
            {
                // Insert id mapping
                await MessageIdMappingTableEntity.InsertOrMergeAsync(this.idMappingTable, new MessageIdMappingTableEntity(engagementAccount, messageId, customMessageId));
            }

            // Get record from summary table
            var entity = await MessageSummaryTableEntity.GetAsync(this.summaryTable, messageId);

            if (entity == null)
            {
                SmsProviderEventSource.Current.Warning(SmsProviderEventSource.EmptyTrackingId, this, nameof(this.OnMessageReportUpdatedAsync), OperationStates.Dropped, $"Does not find record for account={engagementAccount} messageId={messageId}");
                return(false);
            }

            // Calculating the unit according to provider
            var metadata = await this.credentialManager.GetMetadata(connector.ConnectorName);

            var units = BillingHelper.CalculateBillingUnits(entity.MessageBody, metadata);

            if (entity.Units == null)
            {
                entity.Units          = units;
                entity.LastUpdateTime = DateTime.UtcNow;
                await MessageSummaryTableEntity.InsertOrMergeAsync(this.summaryTable, entity);
            }

            return(true);
        }
Esempio n. 4
0
        public DataResult <List <NamedEntity> > GetLifeStyles()
        {
            var ls     = BillingHelper.GetLifestyles();
            var result = RunAction(() => ls);

            return(result);
        }
Esempio n. 5
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var manager     = IocContainer.Get <IShopManager>();
            var character   = 0;
            var corporation = 0;

            if (filterContext.ActionArguments.ContainsKey("character"))
            {
                int.TryParse(filterContext.ActionArguments["character"].ToString(), out character);
            }
            if (filterContext.ActionArguments.ContainsKey("corporation"))
            {
                int.TryParse(filterContext.ActionArguments["corporation"].ToString(), out corporation);
            }
            else
            {
                object model;
                if (filterContext.ActionArguments.TryGetValue("request", out model) && model is CorporationBasedRequest)
                {
                    corporation = ((CorporationBasedRequest)model).Corporation;
                }
            }
            if (!BillingHelper.IsAdmin(character) && !manager.HasAccessToCorporation(character, corporation))
            {
                filterContext.Result = new StatusCodeResult(403);
                return;
            }
            base.OnActionExecuting(filterContext);
        }
Esempio n. 6
0
        private JobLifeDto DoItemsBeat(JobLifeDto beat)
        {
            Console.WriteLine("Запущен пересчет товаров");
            //Получить список корпораций с специализациями
            var corporations = Factory.Billing.GetList <CorporationWallet>(c => true, c => c.Specialisations);
            var inflation    = Factory.Settings.GetDecimalValue(SystemSettingsEnum.pre_inflation);

            foreach (var corporation in corporations)
            {
                corporation.LastSkuSold = corporation.SkuSold;
                corporation.SkuSold     = 0;
                corporation.LastKPI     = corporation.CurrentKPI;
                corporation.CurrentKPI  = 0;
                var skus  = Factory.Billing.GetList <Sku>(s => s.CorporationId == corporation.Id, s => s.Nomenklatura.Specialisation);
                var specs = corporation.Specialisations.Select(s => s.SpecialisationId);
                foreach (var sku in skus)
                {
                    sku.Count = sku.SkuBaseCount ?? sku.Nomenklatura.BaseCount;
                    decimal price = 0;
                    if (sku.SkuBasePrice == null)
                    {
                        price = BillingHelper.GetSpecialisationPrice(corporation.Specialisations.FirstOrDefault(s => s.SpecialisationId == sku.Nomenklatura.SpecialisationId && s.CorporationId == sku.CorporationId), sku.Nomenklatura);
                    }
                    else
                    {
                        price = sku.SkuBasePrice ?? 0;
                    }

                    sku.Price = price * inflation;
                }
                Factory.Billing.SaveContext();
                Console.WriteLine($"Корпорация {corporation.Name} обработана");
            }
            return(beat);
        }
Esempio n. 7
0
        public override void Handle(BaseLocationModel model)
        {
            base.Handle(model);
            var manager = IoC.IocContainer.Get <IScoringManager>();

            manager.OnDumpshock(BillingHelper.ParseId(model.CharacterId, "characterId"));
        }
Esempio n. 8
0
        public DataResult <NamedEntity> GetLifeStyle(Lifestyles lifestyle)
        {
            var ls     = BillingHelper.GetLifestyleDto(lifestyle);
            var result = RunAction(() => ls);

            return(result);
        }
Esempio n. 9
0
        public SessionDto GetSessionInfo(int character)
        {
            var result = new SessionDto();

            try
            {
                var ls = BillingHelper.GetLifeStyleDto();
                result.LifeStyle = new SessionDto.LifeStyleDto(ls);
                var cycle = Factory.Job.GetLastCycle();
                result.Cycle = new SessionDto.CycleDto(cycle);
                var beatCharacters = Factory.Job.GetLastBeatAsNoTracking(Core.Primitives.BeatTypes.Characters);
                var beatItems      = Factory.Job.GetLastBeatAsNoTracking(Core.Primitives.BeatTypes.Items);
                var jsoncharacters = Factory.Settings.GetValue(Core.Primitives.SystemSettingsEnum.beat_characters_dto);
                var lsDto          = Serialization.Serializer.Deserialize <JobLifeStyleDto>(jsoncharacters);
                result.BeatCharacters = new SessionDto.BeatCharactersDto(beatCharacters, lsDto);
                var corps = Factory.Shop.GetCorporationDtos(c => true);
                var shops = Factory.Shop.GetShops(character, s => true);
                result.BeatItems = new SessionDto.BeatItemsDto(beatItems, corps, shops);
                result.Deploy    = Environment.GetEnvironmentVariable(SystemHelper.Billing);
                var sin = Factory.Billing.GetSINByModelId(character, s => s.Passport);
                result.PersonName = BillingHelper.GetPassportName(sin.Passport);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
            }
            return(result);
        }
Esempio n. 10
0
        public override void Handle(ImplantInstallModel model)
        {
            base.Handle(model);
            IScoringManager manager;

            switch (model.AbilityId)
            {
            case "autodoc":
                manager = IoC.IocContainer.Get <IScoringManager>();
                manager.OnImplantUninstalled(BillingHelper.ParseId(model.CharacterId, "characterId"), model.AutodocLifestyle);
                break;

            case "repoman-black":
                manager = IoC.IocContainer.Get <IScoringManager>();
                manager.OnImplantDeletedBlack(BillingHelper.ParseId(model.CharacterId, "characterId"));
                break;

            case "repoman-active":
                manager = IoC.IocContainer.Get <IScoringManager>();
                manager.OnImplantDeletedActive(BillingHelper.ParseId(model.CharacterId, "characterId"));
                break;

            default:
                break;
            }
        }
Esempio n. 11
0
        public async Task OnImplantInstalled(int model, string implantlifestyle, string autodoclifestyle)
        {
            var factorId = GetFactorId(ScoringFactorEnum.implant_install);
            var scoring  = GetScoringByModelId(model);

            if (!BillingHelper.LifestyleIsDefined(implantlifestyle) || !BillingHelper.LifestyleIsDefined(autodoclifestyle))
            {
                return;
            }
            var lifestyle = BillingHelper.GetLifestyle(implantlifestyle);

            await RaiseScoringEvent(scoring.Id, factorId, (context) =>
            {
                var ls    = (int)lifestyle;
                var value = context.Set <ScoringEventLifestyle>().AsNoTracking().FirstOrDefault(s => s.ScoringFactorId == factorId && s.EventNumber == ls);
                return(value?.Value ?? 1);
            });

            factorId  = GetFactorId(ScoringFactorEnum.where_implant_install);
            lifestyle = BillingHelper.GetLifestyle(autodoclifestyle);
            await RaiseScoringEvent(scoring.Id, factorId, (context) =>
            {
                var ls    = (int)lifestyle;
                var value = context.Set <ScoringEventLifestyle>().AsNoTracking().FirstOrDefault(s => s.ScoringFactorId == factorId && s.EventNumber == ls);
                return(value?.Value ?? 1);
            });
        }
Esempio n. 12
0
 public override void Handle(ImplantInstallModel model)
 {
     base.Handle(model);
     if (model.AbilityId == "autodoc")
     {
         var manager = IoC.IocContainer.Get <IScoringManager>();
         manager.OnImplantInstalled(BillingHelper.ParseId(model.CharacterId, "characterId"), model.ImplantLifestyle, model.AutodocLifestyle);
     }
 }
Esempio n. 13
0
        public Lifestyles GetForecastLifeStyle(Wallet wallet)
        {
            if (wallet.IsIrridium)
            {
                return(Lifestyles.Iridium);
            }
            var forecast = BillingHelper.GetForecast(wallet);

            return(forecast > ForecastPlatinum ? Lifestyles.Platinum : IsForecastGold(forecast));
        }
        private static async Task _completeBooking(Guid requestId, Reservation reservationDetails, HttpRequest originRequest)
        {
            LogUtility.LogWithContext(requestId, "Completing a booking");
            reservationDetails.State   = ReservationStatus.Completing.ToString();
            reservationDetails.EndTime = string.Empty;

            var reservationCompletingResult = await MongoHelper.UpdateReservationStateAndEndTime(requestId, reservationDetails);

            if (reservationCompletingResult.ModifiedCount == 0)
            {
                LogUtility.LogErrorWithContext(requestId, "Reservation not updated to 'Completing'! MatchedCount: {0}, ModifiedCount: {1}", reservationCompletingResult.MatchedCount.ToString(), reservationCompletingResult.ModifiedCount.ToString());
                await _failBooking(requestId, reservationDetails);

                return;
            }

            var freeBikeResponse = await BikesHelper.FreeBike(requestId, reservationDetails.BikeId, originRequest);

            if (!freeBikeResponse.IsSuccessStatusCode)
            {
                LogUtility.LogErrorWithContext(requestId, "Error response from Bikes! ResponseCode: {0}, Content: {1}", freeBikeResponse.StatusCode.ToString(), await freeBikeResponse.Content.ReadAsStringAsync());
                await _failBooking(requestId, reservationDetails);

                return;
            }

            reservationDetails.State   = ReservationStatus.Completed.ToString();
            reservationDetails.EndTime = DateTime.UtcNow.ToString(DateTimeFormat);
            var createInvoiceResponse = await BillingHelper.CreateInvoice(requestId, reservationDetails, originRequest);

            if (!createInvoiceResponse.HttpResponse.IsSuccessStatusCode)
            {
                LogUtility.LogErrorWithContext(requestId, "Couldn't create invoice, rolling back!");
                // Rollback
                reservationDetails.EndTime = string.Empty;
                await BikesHelper.ReserveBike(requestId, reservationDetails.BikeId, originRequest);
                await _failBooking(requestId, reservationDetails);

                return;
            }
            reservationDetails.InvoiceId = createInvoiceResponse.InvoiceId;

            var reservationCompletedResult = await MongoHelper.UpdateReservationStateAndEndTime(requestId, reservationDetails);

            if (reservationCompletedResult.ModifiedCount == 0)
            {
                LogUtility.LogErrorWithContext(requestId, "Reservation not updated to 'Completed'! MatchedCount: {0}, ModifiedCount: {1}", reservationCompletedResult.MatchedCount.ToString(), reservationCompletedResult.ModifiedCount.ToString());
                await _failBooking(requestId, reservationDetails);

                return;
            }

            LogUtility.LogWithContext(requestId, "Complete booking succeeded");
        }
Esempio n. 15
0
 public LifeStyleDto(LifeStyleAppDto appdto)
 {
     Bronze           = BillingHelper.Round(appdto.Bronze);
     Silver           = BillingHelper.Round(appdto.Silver);
     Gold             = BillingHelper.Round(appdto.Gold);
     Platinum         = BillingHelper.Round(appdto.Platinum);
     ForecastBronze   = BillingHelper.Round(appdto.ForecastBronze);
     ForecastSilver   = BillingHelper.Round(appdto.ForecastSilver);
     ForecastGold     = BillingHelper.Round(appdto.ForecastGold);
     ForecastPlatinum = BillingHelper.Round(appdto.ForecastPlatinum);
 }
        private static async Task <int> ProcessAggregatorAsync(ICostAggregationService service, TraceWriter log, ArgumentOptions options = null, int?monthsBack = null)
        {
            var dateStart = options != null?BillingHelper.GetStartDate(options) : BillingHelper.GetStartDateOfMonth(monthsBack.Value);

            var dateEnd = options != null?BillingHelper.GetEndDate(options) : BillingHelper.GetEndDateOfMonth(monthsBack.Value);

            log.Info($"Usage from {dateStart.ToLocalTime():yyyy-MM-dd HH:mm:ss} to {dateEnd.ToLocalTime():yyyy-MM-dd HH:mm:ss}:");

            var result = await service.ProcessAsync(dateStart, dateEnd).ConfigureAwait(false);

            return(result);
        }
Esempio n. 17
0
 public BalanceDto(SIN sin)
 {
     CurrentBalance = BillingHelper.Round(sin.Wallet.Balance);
     CurrentScoring = Math.Round(sin.Scoring.CurrentFix + sin.Scoring.CurerentRelative, 2);
     SIN            = sin.Passport.Sin;
     PersonName     = sin.Passport.PersonName;
     Metatype       = sin.Passport.Metatype?.Name ?? "неизвестно";
     Citizenship    = sin.Passport.Citizenship ?? "неизвестно";
     Viza           = sin.Passport.Viza ?? "неизвестно";
     Pledgee        = sin.Passport.Mortgagee ?? "неизвестно";
     Id             = ModelId;
 }
Esempio n. 18
0
        public FullUserDto GetFullUser(int modelid)
        {
            var user = new FullUserDto(modelid)
            {
                Sin       = Factory.Billing.GetBalance(modelid),
                Transfers = Factory.Billing.GetTransfers(modelid),
                Rents     = Factory.Billing.GetRentas(modelid),
                Scoring   = Factory.Scoring.GetFullScoring(modelid),
                IsAdmin   = BillingHelper.IsAdmin(modelid)
            };

            return(user);
        }
Esempio n. 19
0
        public ActionResult GenerateBilling(GenerateBillingViewModel model)
        {
            if (ModelState.IsValid)
            {
                var start    = DateTime.Parse(model.StartDateTime);
                var end      = DateTime.Parse(model.EndDateTime);
                var billings = BillingHelper.GetBillingsGrouppedByParking(start, end);

                return(Json(new { Success = true, Content = RenderRazorViewToString("_BillingPartial", billings) }));
            }

            return(Json(new { Success = false, Content = RenderRazorViewToString("_GenerateBillingPartial", model) }));
        }
        private static async Task <int> ProcessReminderAsync(ICostReminderService service, TraceWriter log, ArgumentOptions options)
        {
            var dateStart = BillingHelper.GetStartDate(options);
            var dateEnd   = BillingHelper.GetEndDate(options);

            log.Info(options.RunEntirePeriod
                         ? $"Usage from the entire billing history:"
                         : $"Usage from {dateStart.ToLocalTime():yyyy-MM-dd HH:mm:ss} to {dateEnd.AddDays(-1).ToLocalTime():yyyy-MM-dd HH:mm:ss}:");

            var result = await service.ProcessAsync(dateStart, dateEnd, options.RunEntirePeriod, (decimal)options.Threshold).ConfigureAwait(false);

            return(result);
        }
Esempio n. 21
0
        public async Task OnShopLifestyle(SIN sin, int shoplifestyle)
        {
            var factorId     = GetFactorId(ScoringFactorEnum.shop_lifestyle);
            var dto          = BillingHelper.GetLifeStyleDto();
            var sinlifestyle = dto.GetLifeStyle(sin.Wallet);
            var scoring      = sin.Scoring;
            var lifestyle    = CompareLifestyle(shoplifestyle, (int)sinlifestyle);

            await RaiseScoringEvent(scoring.Id, factorId, (context) =>
            {
                var value = context.Set <ScoringEventLifestyle>().AsNoTracking().FirstOrDefault(s => s.ScoringFactorId == factorId && s.EventNumber == lifestyle);
                return(value?.Value ?? 1);
            });
        }
Esempio n. 22
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var character = 0;

            if (filterContext.ActionArguments.ContainsKey("character"))
            {
                int.TryParse(filterContext.ActionArguments["character"].ToString(), out character);
            }
            if (!BillingHelper.IsAdmin(character))
            {
                filterContext.Result = new StatusCodeResult(403);
                return;
            }
            base.OnActionExecuting(filterContext);
        }
Esempio n. 23
0
        public ActionResult GenerateBilling(GenerateBillingViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user       = User.Identity.GetApplicationUser();
                var localAdmin = BusinessManager.Instance.LocalManagers.FindAll().SingleOrDefault(l => l.Email == user.Email);
                var parking    = BusinessManager.Instance.Parkings.FindAll().SingleOrDefault(p => p.LocalManager.CPF == localAdmin.CPF);
                var start      = DateTime.Parse(model.StartDateTime);
                var end        = DateTime.Parse(model.EndDateTime);
                var billings   = BillingHelper.GetBillingsForParking(parking.CNPJ, start, end);

                return(Json(new { Success = true, Content = RenderRazorViewToString("_BillingPartial", billings) }));
            }

            return(Json(new { Success = false, Content = RenderRazorViewToString("_GenerateBillingPartial", model) }));
        }
Esempio n. 24
0
        public override void Handle(HealthModel model)
        {
            base.Handle(model);
            IScoringManager scoring;
            IBillingManager billing;
            var             modelId = BillingHelper.ParseId(model.CharacterId, "characterId");

            switch (model.StateTo)
            {
            case "wounded":
                scoring = IoC.IocContainer.Get <IScoringManager>();
                scoring.OnWounded(modelId);
                break;

            case "clinically_dead":
                scoring = IoC.IocContainer.Get <IScoringManager>();
                scoring.OnClinicalDeath(modelId);
                break;

            case "biologically_dead":
                billing = IoC.IocContainer.Get <IBillingManager>();
                billing.DropCharacter(modelId);
                break;

            case "healthy":
                switch (model.StateFrom)
                {
                case "clinically_dead":
                    billing = IoC.IocContainer.Get <IBillingManager>();
                    billing.DropInsurance(modelId);
                    break;

                case "biologically_dead":
                    billing = IoC.IocContainer.Get <IBillingManager>();
                    billing.RestoreCharacter(modelId);
                    break;

                default:
                    break;
                }
                break;

            default:
                break;
            }
        }
Esempio n. 25
0
        public async Task OnPillConsumed(int model, string pillLifestyle)
        {
            var factorId = GetFactorId(ScoringFactorEnum.pill_use);

            if (!BillingHelper.LifestyleIsDefined(pillLifestyle))
            {
                return;
            }
            var lifestyle = BillingHelper.GetLifestyle(pillLifestyle);
            var scoring   = GetScoringByModelId(model);

            await RaiseScoringEvent(scoring.Id, factorId, (context) =>
            {
                var ls    = (int)lifestyle;
                var value = context.Set <ScoringEventLifestyle>().AsNoTracking().FirstOrDefault(s => s.ScoringFactorId == factorId && s.EventNumber == ls);
                return(value?.Value ?? 1);
            });
        }
Esempio n. 26
0
        public void HandleAbility(AbilityModel model)
        {
            ActiveAbility activeAbilityEnum;

            ModelPrimitives.Abilities.TryGetValue(model.Id, out activeAbilityEnum);
            switch (activeAbilityEnum)
            {
            case ActiveAbility.HowMuch:
                break;

            case ActiveAbility.WhoNeed:
                break;

            case ActiveAbility.PayAndCry:
                break;

            case ActiveAbility.LetHim:
                IocContainer.Get <IAbilityManager>().LetHimPay(BillingHelper.ParseId(model?.CharacterId, "characterId"), BillingHelper.ParseId(model?.TargetCharacterId, "TargetCharacterId"), BillingHelper.ParseId(model?.QrCode?.Data?.DealId, "DealId"), model?.QrCode?.ModelId);
                break;

            case ActiveAbility.Letme:
                IocContainer.Get <IAbilityManager>().LetMePay(BillingHelper.ParseId(model?.CharacterId, "characterId"), BillingHelper.ParseId(model?.QrCode?.Data?.DealId, "DealId"), model?.QrCode?.ModelId);
                break;

            case ActiveAbility.Rerent:
                IocContainer.Get <IAbilityManager>().Rerent(BillingHelper.ParseId(model?.CharacterId, "characterId"), BillingHelper.ParseId(model?.QrCode?.Data?.DealId, "DealId"), model?.QrCode?.ModelId);
                break;

            case ActiveAbility.Marauder:
                IocContainer.Get <IAbilityManager>().Marauder(BillingHelper.ParseId(model?.CharacterId, "characterId"), BillingHelper.ParseId(model?.TargetCharacterId, "TargetCharacterId"));
                break;

            case ActiveAbility.SleepCheck:
                IocContainer.Get <IAbilityManager>().Marauder(BillingHelper.ParseId(model?.CharacterId, "characterId"), BillingHelper.ParseId(model?.bodyStorage?.Data?.Body?.CharacterId, "TargetCharacterId"), true);
                break;

            case ActiveAbility.SaveScoring:
                IocContainer.Get <IAbilityManager>().SaveScoring(BillingHelper.ParseId(model?.TargetCharacterId, "TargetCharacterId"), BillingHelper.ParseId(model?.QrCode?.Data?.DealId, "DealId"), model?.QrCode?.ModelId);
                break;

            default:
                break;
            }
        }
Esempio n. 27
0
            public PerMessageAggregation(
                MessageHistoryTableEntity historyEntity,
                IReadOnlyDictionary <string, int> countByState)
            {
                this.MessageId           = historyEntity.MessageId;
                this.MessageCategory     = historyEntity.MessageCategory;
                this.MessageBody         = historyEntity.MessageBody;
                this.SendTimeUnixSeconds = new DateTimeOffset(historyEntity.SendTime).ToUnixTimeSeconds();
                this.TotalTargets        = historyEntity.Targets * BillingHelper.GetTotalSegments(historyEntity.MessageBody);

                if (countByState.TryGetValue(MessageState.DELIVERED.ToString(), out int delivered))
                {
                    this.TotalSucceeded = delivered;
                }
                else
                {
                    this.TotalSucceeded = 0;
                }
            }
        private static async Task <int> ProcessAsync(ICostAggregationService service, ArgumentOptions options = null, int?monthsBack = null)
        {
            var dateStart = options != null?BillingHelper.GetStartDate(options) : BillingHelper.GetStartDateOfMonth(monthsBack.Value);

            var dateEnd = options != null?BillingHelper.GetEndDate(options) : BillingHelper.GetEndDateOfMonth(monthsBack.Value);

            Console.WriteLine($"Usage from {dateStart.ToLocalTime():yyyy-MM-dd HH:mm:ss} to {dateEnd.ToLocalTime():yyyy-MM-dd HH:mm:ss}:");
            Console.WriteLine();

            var watch = Stopwatch.StartNew();

            var result = await service.ProcessAsync(dateStart, dateEnd).ConfigureAwait(false);

            watch.Stop();

            Console.WriteLine();
            Console.WriteLine($"Execution time: {watch.ElapsedMilliseconds} ms");

            return(result);
        }
Esempio n. 29
0
 public RentaDto(Renta renta)
 {
     HasQRWrite       = renta.HasQRWrite;
     PriceId          = renta.PriceId;
     RentaId          = renta.Id;
     FinalPrice       = BillingHelper.GetFinalPrice(renta);
     BasePrice        = renta.BasePrice;
     Discount         = renta.Discount;
     Scoring          = renta.CurrentScoring;
     CharacterName    = renta.Sin?.Passport?.PersonName ?? "Unknown";
     ProductType      = renta.Sku?.Nomenklatura?.Specialisation?.ProductType?.Name;
     Shop             = renta.Shop?.Name;
     NomenklaturaName = $"{renta.Sku?.Nomenklatura?.Name} x {renta.Count}";
     SkuName          = renta.Sku?.Name;
     Corporation      = renta.Sku?.Corporation?.Name;
     QRRecorded       = renta.QRRecorded;
     DateCreated      = renta.DateCreated;
     Specialisation   = renta.Sku?.Nomenklatura?.Specialisation?.Name;
     Stealable        = renta.Stealable;
     Count            = renta.Count;
     BeatId           = renta.BeatId;
 }
        private static async Task <int> ProcessAsync(ICostReminderService service, ArgumentOptions options)
        {
            var dateStart = BillingHelper.GetStartDate(options);
            var dateEnd   = BillingHelper.GetEndDate(options);

            Console.WriteLine(
                options.RunEntirePeriod
                                  ? $"Usage from the entire billing history:"
                                  : $"Usage from {dateStart.ToLocalTime():yyyy-MM-dd HH:mm:ss} to {dateEnd.AddDays(-1).ToLocalTime():yyyy-MM-dd HH:mm:ss}:");
            Console.WriteLine();

            var watch = Stopwatch.StartNew();

            var result = await service.ProcessAsync(dateStart, dateEnd, options.RunEntirePeriod, (decimal)options.Threshold).ConfigureAwait(false);

            watch.Stop();

            Console.WriteLine();
            Console.WriteLine($"Execution time: {watch.ElapsedMilliseconds} ms");

            return(result);
        }