Exemplo n.º 1
0
        public void ShowCalculationExceptionListView(CalculationDTO calculation)
        {
            var view = ServiceLocator.Current.GetInstance <ICalculationExceptionListView>();

            ((CalculationExceptionListVM)view.ViewModel).Load(calculation);
            viewManager.ShowInDialog(view);
        }
Exemplo n.º 2
0
        public async Task <Response <CalculationDTO> > Calculate()
        {
            var uniqueUsers = _repository.GetUsersByLifetime(7);
            var allUsers    = await _repository.GetList(GetAllUsersQuery(), null, null);

            string rollingRetention = _service.CalculateRollingRetention((ushort)uniqueUsers.Count(), (ushort)allUsers.Total);

            var usersByReg = await _repository.GetList(GetAllUsersQuery(), true, null);

            var usersByLastActivity = await _repository.GetList(GetAllUsersQuery(), true, true);

            IEnumerable <UserDTO> userDtos = _mapper.Map <IEnumerable <UserModel>, IEnumerable <UserDTO> >(allUsers.Items);
            var result = _service.CreateUsersLifetimeInfo(usersByReg.Items.First().RegistrationDate,
                                                          usersByLastActivity.Items.First().LastActivityDate, userDtos);

            var calculations = new CalculationDTO
            {
                RollingRetention = rollingRetention,
                UsersLifetime    = result,
            };

            return(new Response <CalculationDTO>
            {
                ResultData = calculations,
            });
        }
Exemplo n.º 3
0
        public void ChangeDeterministicCalculation(Action <Exception> action, CalculationDTO calacDto)
        {
            var url = string.Format(baseAddress + makeApiAdress(calacDto.PeriodId));

            WebClientHelper.Put <CalculationDTO, CalculationDTO>(new Uri(url, UriKind.Absolute), (res, exp) => action(exp), calacDto
                                                                 , PMSClientConfig.MsgFormat, PMSClientConfig.CreateHeaderDic(userProvider.Token));
        }
Exemplo n.º 4
0
        public async Task <IEnumerable <CalculationDTO> > GetCalculationInfosByChargeIdAsync(int chargeId)
        {
            var result = new List <CalculationDTO>();

            using (var connection = new SqlConnection(_connectionString))
            {
                using (var cmd = new SqlCommand())
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.CommandText = "[dbo].[SpGetExpensesByChargeId]";
                    cmd.Parameters.AddWithValue("@chargeId", chargeId);

                    cmd.Connection = connection;
                    cmd.Connection.Open();
                    using (var dataReader = await cmd.ExecuteReaderAsync())
                    {
                        while (await dataReader.ReadAsync())
                        {
                            var calculationInfo = new CalculationDTO();
                            calculationInfo.Amount      = Convert.ToDecimal(dataReader["Amount"]);
                            calculationInfo.ExpenseId   = Convert.ToInt32(dataReader["ExpenseID"]);
                            calculationInfo.FormulaName = Convert.ToString(dataReader["FormulaType"]);
                            calculationInfo.From        = Convert.ToDateTime(dataReader["From"]);
                            calculationInfo.To          = Convert.ToDateTime(dataReader["To"]);
                            calculationInfo.IsForOwner  = Convert.ToBoolean(dataReader["IsForOwner"]);
                            calculationInfo.BuildingId  = Convert.ToInt32(dataReader["BuildingId"]);
                            result.Add(calculationInfo);
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 5
0
        public void DoAction(CalculationListVM vm)
        {
            var calculation = new CalculationDTO {
                PeriodId = vm.Period.Id
            };

            periodController.ShowPeriodCalculationExecView(calculation, ActionType.AddCalculation);
        }
Exemplo n.º 6
0
        public void Handle(CalculationDTO dto)
        {
            var newValue = _calculator.GetNext(dto.PreviousValue, dto.CurrentValue);

            _logger.Debug(newValue);

            _sender.SendResult(new CalculationDTO(dto.CurrentValue, newValue));
        }
Exemplo n.º 7
0
 public CalculationDTO PutCalculation(CalculationDTO calculation)
 {
     if (calculation.PutActionName.ToLower() == "changecalculationdeterministicstatus")
     {
         calculationService.ChangeDeterministicStatus(calculation.Id, calculation.IsDeterministic);
     }
     return(calculation);
 }
Exemplo n.º 8
0
        public CalculationResultItemModel GetResult(CalculationDTO dto)
        {
            CalculationResultItemModel Model = new CalculationResultItemModel();

            Model.Expression = dto.Expression;
            Model.Result     = dto.Result;
            return(Model);
        }
        public HttpResponseMessage Post([FromBody] CalculationDTO dto)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
            }

            _fibonacciService.Handle(dto);
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Calculation"/> class
        /// </summary>
        /// <param name="calculation">a <see cref="CalculationDTO"/> representing the calculation</param>
        internal Calculation(CalculationDTO calculation)
        {
            if (calculation == null)
            {
                throw new ArgumentNullException(nameof(calculation));
            }

            Odds        = calculation.Odds;
            Probability = calculation.Probability;
        }
Exemplo n.º 11
0
        public CalculationDTO AddCalculation(CalculationDTO calculation)
        {
            var calc = calculationService.AddCalculation(new PolicyId(calculation.PolicyId),
                                                         new PeriodId(calculation.PeriodId), calculation.Name, calculation.EmployeeIdList);
            var res = new CalculationWithPolicyAndPeriod
            {
                Calculation = calc,
                Policy      = PolicyRep.GetById(calc.PolicyId),
                Period      = PeriodRep.GetById(calc.PeriodId)
            };

            return(calculationMapper.MapToModel(res));
        }
Exemplo n.º 12
0
        private async Task <IEnumerable <ShareInfo> > GetShareInfosAsync(CalculationDTO calculationInfo)
        {
            if (calculationInfo.IsForOwner)
            {
                var gateway    = _gatewayFactory.CreateOwnershipTableGateway();
                var shareInfos = await gateway.GetOwnerShareInfoAsync(calculationInfo.BuildingId, calculationInfo.From, calculationInfo.To);

                return(shareInfos);
            }
            else
            {
                var gateway    = _gatewayFactory.CreateTenancyTableGateway();
                var shareInfos = await gateway.GetTenantShareInfoAsync(calculationInfo.BuildingId, calculationInfo.From, calculationInfo.To);

                return(shareInfos);
            }
        }
Exemplo n.º 13
0
 public CalculationStatusVM()
 {
     PeriodMgtAppLocalizedResources = new PeriodMgtAppLocalizedResources();
     Calculation = new CalculationDTO {
     };
     Summary     = new CalculationStateWithRunSummaryDTO
     {
         Percent     = 20,
         StateName   = "Running",
         MessageList = new List <string>
         {
             { "sdkafhsadjfksdajfsdkjf" },
             { "kfs skfhdjf" }
         }
     };
     init();
 }
Exemplo n.º 14
0
        public void TestCalculations_AllPositiveDecimals_Even()
        {
            CalculationHelper calc = new CalculationHelper(generateTestData_AllPositiveDecimals_Even());
            CalculationDTO    dto  = calc.Calculate();

            Assert.IsNotNull(dto.mean);
            Assert.IsNotNull(dto.median);
            Assert.IsNotNull(dto.mode);

            Assert.AreEqual(0.5355599999999999, dto.mean);
            Assert.AreEqual(0.59793, dto.median);

            List <double> testMode = new List <double>()
            {
                0.234, 0.7101
            };

            for (var i = 0; i < dto.mode.Count; i++)
            {
                Assert.AreEqual(testMode[i], dto.mode[i]);
            }
        }
Exemplo n.º 15
0
        public void TestCalculations_AllNegativeDecimals_Even()
        {
            CalculationHelper calc = new CalculationHelper(generateTestData_AllNegativeDecimals_Even());
            CalculationDTO    dto  = calc.Calculate();

            Assert.IsNotNull(dto.mean);
            Assert.IsNotNull(dto.median);
            Assert.IsNotNull(dto.mode);

            Assert.AreEqual(-0.3862486666666667, dto.mean);
            Assert.AreEqual(-0.35988000000000003, dto.median);

            List <double> testMode = new List <double>()
            {
                -0.234, -0.018932, -0.8394, -0.7101, -0.0293, -0.48576
            };

            for (var i = 0; i < dto.mode.Count; i++)
            {
                Assert.AreEqual(testMode[i], dto.mode[i]);
            }
        }
Exemplo n.º 16
0
        public void TestCalculations_MixedBag_Odd()
        {
            CalculationHelper calc = new CalculationHelper(generateTestData_MixedBag_Odd());
            CalculationDTO    dto  = calc.Calculate();

            Assert.IsNotNull(dto.mean);
            Assert.IsNotNull(dto.median);
            Assert.IsNotNull(dto.mode);

            Assert.AreEqual(164122.13748818, dto.mean);
            Assert.AreEqual(0.0328409, dto.median);

            List <double> testMode = new List <double>()
            {
                -19304.273, 838984, 0.0328409, -0.0204, 930.948
            };

            for (var i = 0; i < dto.mode.Count; i++)
            {
                Assert.AreEqual(testMode[i], dto.mode[i]);
            }
        }
Exemplo n.º 17
0
        public void TestCalculations_AllNegativeIntegers_Even()
        {
            CalculationHelper calc = new CalculationHelper(generateTestData_AllNegativeIntegers_Even());
            CalculationDTO    dto  = calc.Calculate();

            Assert.IsNotNull(dto.mean);
            Assert.IsNotNull(dto.median);
            Assert.IsNotNull(dto.mode);

            Assert.AreEqual(-34.333333333333336, dto.mean);
            Assert.AreEqual(-28.5, dto.median);

            List <double> testMode = new List <double>()
            {
                -12
            };

            for (var i = 0; i < dto.mode.Count; i++)
            {
                Assert.AreEqual(testMode[i], dto.mode[i]);
            }
        }
Exemplo n.º 18
0
        public void TestCalculations_MixedBag_Even()
        {
            CalculationHelper calc = new CalculationHelper(generateTestData_MixedBag_Even());
            CalculationDTO    dto  = calc.Calculate();

            Assert.IsNotNull(dto.mean);
            Assert.IsNotNull(dto.median);
            Assert.IsNotNull(dto.mode);

            Assert.AreEqual(104594.44790681665, dto.mean);
            Assert.AreEqual(0.006220449999999999, dto.median);


            List <double> testMode = new List <double>()
            {
                -19304.273, 838984, 0.0328409, -0.0204, 930.948, -193044
            };

            for (var i = 0; i < dto.mode.Count; i++)
            {
                Assert.AreEqual(testMode[i], dto.mode[i]);
            }
        }
Exemplo n.º 19
0
 public void Load(CalculationDTO caclculationParam, ActionType action)
 {
     preLoad();
     Calculation = caclculationParam;
 }
Exemplo n.º 20
0
        //public PeriodDTOsFecadeService(IMa)
        //{

        //}

        public CalculationDTO AddCalculation(CalculationDTO calculation)
        {
            var calc = calculationMapper.MapToModel(calculation);
        }
Exemplo n.º 21
0
 public CalculationDTO PostCalculation(CalculationDTO calculation)
 {
     return(calculationService.AddCalculation(calculation));
 }
Exemplo n.º 22
0
        public void ShowPeriodCalculationExecView(CalculationDTO calculation, ActionType action)
        {
            var view = viewManager.ShowInTabControl <ICalculationView>();

            ((CalculationVM)view.ViewModel).Load(calculation, action);
        }
Exemplo n.º 23
0
        public void AddCalculation(Action <CalculationDTO, Exception> action, CalculationDTO calculation)
        {
            var url = string.Format(baseAddress + makeApiAdress(calculation.PeriodId));

            WebClientHelper.Post(new Uri(url, UriKind.Absolute), action, calculation, WebClientHelper.MessageFormat.Json, PMSClientConfig.CreateHeaderDic(userProvider.Token));
        }
Exemplo n.º 24
0
 public void Load(CalculationDTO calculationParam)
 {
     calculation = calculationParam;
     DisplayName = PeriodMgtAppLocalizedResources.CalculationExceptionListViewTitle;
     refresh();
 }