private void loadReportBilancio(IList<ReportBilancioDTO> bilancioDataSource)
        {
            var importoTotale = 0m;

            reportViewer1.LocalReport.ReportEmbeddedResource = "Gipasoft.Stabili.UI.Bilanci.Reports.BilancioConsuntivoDettaglio.rdlc";
            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("ReportBilancioDTO", getBilancioService().CloneReportBilancioDataSource(bilancioDataSource)));

            if (_bilancioDataSource != null)
            {
                _reportParameters.TotaleVersamenti = _reportParameters.TotaleVersamenti*-1;
                importoTotale = bilancioDataSource.Sum(item => item.ImportoSottoConto) + bilancioDataSource.Sum(item => item.ImportoMovimento);
                if (Security.Login.Instance.CurrentLogin().InversioneSaldiCondomini)
                {
                    importoTotale = importoTotale * -1;
                    _reportParameters.TotaleVersamenti = _reportParameters.TotaleVersamenti*-1;
                }
                
                importoTotale += _reportParameters.TotaleVersamenti;
                importoTotale += _reportParameters.SaldoPrecedente;
            }

            getReportParameters(importoTotale);

            // Add a handler for SubreportProcessing
            reportViewer1.LocalReport.SubreportProcessing += localReportSubreportProcessing;

            reportViewer1.LocalReport.SetParameters(getReportParameters(importoTotale));
            reportViewer1.RefreshReport();
        }
        public void Update(ICacheService cacheService, Account selectedAccount, WorkPeriod currentWorkPeriod)
        {
            var accountType = cacheService.GetAccountTypeById(selectedAccount.AccountTypeId);
            var transactions = Dao.Query(GetCurrentRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod)).OrderBy(x => x.Date);
            Transactions = transactions.Select(x => new AccountDetailData(x, selectedAccount)).ToList();
            if (accountType.DefaultFilterType > 0)
            {
                var pastDebit = Dao.Sum(x => x.Debit, GetPastRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod));
                var pastCredit = Dao.Sum(x => x.Credit, GetPastRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod));
                var pastExchange = Dao.Sum(x => x.Exchange, GetPastRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod));
                if (pastCredit > 0 || pastDebit > 0)
                {
                    Summaries.Add(new AccountSummaryData(Resources.Total, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));
                    var detailValue =
                        new AccountDetailData(
                        new AccountTransactionValue
                        {
                            Name = Resources.PastTransactions,
                            Credit = pastCredit,
                            Debit = pastDebit,
                            Exchange = pastExchange
                        }, selectedAccount) { IsBold = true };
                    Transactions.Insert(0, detailValue);
                }
            }

            Summaries.Add(new AccountSummaryData(Resources.GrandTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));

            for (var i = 0; i < Transactions.Count; i++)
            {
                Transactions[i].Balance = (Transactions[i].Debit - Transactions[i].Credit);
                if (i > 0) (Transactions[i].Balance) += (Transactions[i - 1].Balance);
            }
        }
 public static CoreDataSet CalculateAverage(IList<CoreDataSet> validData)
 {
     var average = CoreDataSet.GetNullObject();
     average.Count = validData.Sum(x => x.Count.Value);
     average.Value = validData.Sum(x => x.Count).Value / validData.Count;
     return average;
 }
Example #4
1
        private void loadReportBilancio(IList<ReportBilancioDTO> bilancioDataSource, CondominioDTO condominioDTO, EsercizioDTO esercizioDTO)
        {
            var importoTotale = 0m;

            reportViewer1.LocalReport.ReportEmbeddedResource = _reportParameters.TipoDettaglio == TipoDettaglioReportBilancio.Movimenti ? "Gipasoft.Stabili.UI.Bilanci.Reports.BilancioConsuntivo_Movimenti.rdlc" : "Gipasoft.Stabili.UI.Bilanci.Reports.BilancioConsuntivo_SottoConti.rdlc";
            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("ReportBilancioDTO", _bilancioService.CloneReportBilancioDataSource(bilancioDataSource)));

            if (_bilancioDataSource != null)
            {
                _reportParameters.TotaleVersamenti = _reportParameters.TotaleVersamenti*-1;
                importoTotale = bilancioDataSource.Sum(item => item.ImportoSottoConto) + bilancioDataSource.Sum(item => item.ImportoMovimento);
                if (Login.Instance.CurrentLogin().InversioneSaldiCondomini)
                {
                    importoTotale = importoTotale * -1;
                    _reportParameters.TotaleVersamenti = _reportParameters.TotaleVersamenti*-1;
                }
                
                importoTotale += _reportParameters.TotaleVersamenti;
                importoTotale += _reportParameters.SaldoPrecedente;
            }

            getReportParameters(importoTotale, condominioDTO, esercizioDTO);

            reportViewer1.LocalReport.SetParameters(getReportParameters(importoTotale, condominioDTO, esercizioDTO));
            reportViewer1.RefreshReport();
        }
        public void Update(Account selectedAccount, DateTime? start, DateTime? end)
        {
            Start = start;
            End = end;
            var transactions = Dao.Query(GetCurrentRange(start, end, x => x.AccountId == selectedAccount.Id)).OrderBy(x => x.Date);
            Transactions = transactions.Select(x => new AccountDetailData(x, selectedAccount)).ToList();
            if (start.HasValue)
            {
                var pastDebit = Dao.Sum(x => x.Debit, GetPastRange(start, x => x.AccountId == selectedAccount.Id));
                var pastCredit = Dao.Sum(x => x.Credit, GetPastRange(start, x => x.AccountId == selectedAccount.Id));
                var pastExchange = Dao.Sum(x => x.Exchange, GetPastRange(start, x => x.AccountId == selectedAccount.Id));
                if (pastCredit > 0 || pastDebit > 0)
                {
                    Summaries.Add(new AccountSummaryData(Resources.TransactionTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));
                    var detailValue =
                        new AccountDetailData(
                        new AccountTransactionValue
                        {
                            Date = start.GetValueOrDefault(),
                            Name = Resources.BalanceBroughtForward,
                            Credit = pastCredit,
                            Debit = pastDebit,
                            Exchange = pastExchange
                        }, selectedAccount) { IsBold = true };
                    Transactions.Insert(0, detailValue);
                }
            }
            if (end.HasValue && end != start)
            {
                var futureDebit = Dao.Sum(x => x.Debit, GetFutureRange(end, x => x.AccountId == selectedAccount.Id));
                var futureCredit = Dao.Sum(x => x.Credit, GetFutureRange(end, x => x.AccountId == selectedAccount.Id));
                var futureExchange = Dao.Sum(x => x.Exchange, GetFutureRange(end, x => x.AccountId == selectedAccount.Id));
                if (futureCredit > 0 || futureDebit > 0)
                {
                    Summaries.Add(new AccountSummaryData(Resources.DateRangeTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));
                    var detailValue =
                        new AccountDetailData(
                        new AccountTransactionValue
                        {
                            Date = end.GetValueOrDefault(),
                            Name = Resources.BalanceAfterDate,
                            Credit = futureCredit,
                            Debit = futureDebit,
                            Exchange = futureExchange
                        }, selectedAccount) { IsBold = true };
                    Transactions.Add(detailValue);
                }
            }

            Summaries.Add(new AccountSummaryData(Resources.GrandTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));

            for (var i = 0; i < Transactions.Count; i++)
            {
                Transactions[i].Balance = (Transactions[i].Debit - Transactions[i].Credit);
                if (i > 0) (Transactions[i].Balance) += (Transactions[i - 1].Balance);
            }
        }
        public double Calculate(IList<Coder> participants)
        {
            var n = participants.Count;
            var ratAvg = participants.Average(x => x.R);

            var sqrRatStdev = participants.Sum(x => Math.Pow(x.R - ratAvg, 2)) / (n - 1);
            var sqrVolAvg = participants.Sum(x => x.V * x.V) / n;

            return Math.Sqrt(sqrVolAvg + sqrRatStdev);
        }
        public static CoreDataSet CalculateAverage(IList<CoreDataSet> validData, Unit unit)
        {
            var average = CoreDataSet.GetNullObject();
            average.Count = validData.Sum(x => x.Count.Value);
            average.Denominator = validData.Sum(x => x.Denominator);
            average.Value = (average.Count.Value / average.Denominator) * unit.Value;

            average.ValueNoteId = ValueNoteIds.ValueAggregatedFromAllKnownGeographyValues;
            return average;
        }
    private static StatisticsForPeriod ForPeriod(IList<FocusSession> sessions, string periodName)
    {
        var result = new StatisticsForPeriod
        {
            PeriodName = periodName,
            FocusMinutes = sessions.Sum(x => x.WasInterrupted ? - x.Minutes : x.Minutes),
            TotalMinutes = sessions.Sum(x => x.Minutes),
            InterruptionCount = sessions.Count(x => x.WasInterrupted),
            InterruptionMinutes = sessions.Where(x => x.WasInterrupted).Sum(x => x.Minutes),
            SessionCount = sessions.Count
        };

        return result;
    }
Example #9
1
        public OrderLine(Product product, int quantity, IList<Outcome> outcomes):this()
        {
            Product = product;
            Quantity = quantity;
            Price = product.Price;
            ProductName = product.Name;

            Outcomes = outcomes;
            outcomes.ForEach(x => x.OrderLine = this);

            Profit = Outcomes.Sum(outcome => outcome.Profit);
            SummWithDiscount = Outcomes.Sum(outcome => outcome.SummWithDiscount);

        }
Example #10
1
 public Spectrum(double startRt, double endRt, IList<double> xValues, IList<double> yValues)
     : base(xValues, yValues)
 {
     StartRT = startRt;
     EndRT = endRt;
     totalIntensity = yValues.Sum();
 }
Example #11
1
        public static LineEquation ApproximateLine(IList<double> values)
        {
            double sumX = 0;
            for (int i = 0; i < values.Count; ++i)
            {
                sumX += i;
            }

            int n = values.Count;
            double ssXX = 0;
            double ssYY = 0;
            double ssXY = 0;
            double meanX = sumX / n;
            double meanY = values.Sum() / n;
            for (int i = 0; i < values.Count; ++i)
            {
                ssXX += (double)Math.Pow(i - meanX, 2);
                ssYY += (double)Math.Pow(values[i] - meanY, 2);
                ssXY += (i - meanX)*(values[i] - meanY);
            }

            double b = ssXY / ssXX;
            double a = meanY - b * meanX;

            return new LineEquation(a, b);
        }
        public static int CalculateUpdatedTeamMoney(IList<Transfer> transfers, int currentMoney)
        {
            //process transfers as a whole
            int totalMoneySpent = transfers.Sum(t => t.PlayerIn.NowCost);

            int totalMoneyIn = 0;
            foreach (var transfer in transfers)
            {
                if (transfer.PlayerOut.NowCost <= transfer.PlayerOut.OriginalCost)
                {
                    totalMoneyIn += transfer.PlayerOut.NowCost;
                }
                else
                {
                    var difference = transfer.PlayerOut.NowCost - transfer.PlayerOut.OriginalCost;

                    //you get 50% of the difference, rounded down to nearest 0.1 mllion
                    totalMoneyIn += transfer.PlayerOut.OriginalCost + (difference / 2);
                }
            }

            var newMoneyValue = currentMoney - totalMoneySpent + totalMoneyIn;

            return newMoneyValue;
        }
      public async Task<IssuesCollectionStatistics> Calculate(IList<JiraIssue> issues)
      {
         if(issues == null || issues.Any() == false)
            return null;

         return await Task.Factory.StartNew(() =>
         {
            return new IssuesCollectionStatistics
            {
               IssuesCount = issues.Count(),
               ResolvedIssuesCount = issues.Where(i => i.Resolved.HasValue).Count(),
               UnresolvedIssuesCount = issues.Where(i => i.Resolved.HasValue == false).Count(),

               AverageResolutionTimeHours = issues
                                               .Where(i => i.Resolved.HasValue)
                                               .Select(i => (i.Resolved.Value - i.Created).TotalHours).Average(),
               MaxResolutionTimeHours = issues
                                               .Where(i => i.Resolved.HasValue)
                                               .Select(i => (i.Resolved.Value - i.Created).TotalHours).Max(),

               TotalStorypoints = issues.Sum(i => i.StoryPoints),
               AverageStorypointsPerTask = issues.Average(i => i.StoryPoints),

               AverageSubtasksCount = issues.Average(i => i.Subtasks),

               EpicsInvolved = issues.Select(i => i.EpicLink).Distinct().Count(),

               DistinctReporters = issues.Select(i => i.Reporter).Distinct().Count()
            };
         });
      }
Example #14
1
 public NumericRange(IList<double> values)
 {
     double num3;
     double num4;
     double current;
     Func<double, double> selector = null;
     double num = 0.0;
     double num2 = 0.0;
     goto Label_016A;
     Label_00F1:
     using (IEnumerator<double> enumerator = values.GetEnumerator())
     {
         goto Label_011B;
     Label_00FB:
         if ((((uint) current) - ((uint) num)) > uint.MaxValue)
         {
             goto Label_0142;
         }
         num4 += current * current;
     Label_011B:
         if (!enumerator.MoveNext())
         {
             goto Label_0157;
         }
         current = enumerator.Current;
         num = Math.Max(num, current);
         num2 = Math.Min(num2, current);
     Label_0142:
         num3 += current;
         goto Label_00FB;
     }
     Label_0157:
     this._xdc8f3f8857bee4c6 = values.Count;
     this._x628ea9b89457a2a9 = num;
     this._xd12d1dba8a023d95 = num2;
     this._x0eb49ee242305597 = num3 / ((double) this._xdc8f3f8857bee4c6);
     this._xcce91100698a4514 = Math.Sqrt(num4 / ((double) this._xdc8f3f8857bee4c6));
     if (((((uint) num2) & 0) != 0) || ((((uint) num2) + ((uint) current)) >= 0))
     {
         if (selector == null)
         {
             selector = new Func<double, double>(this, (IntPtr) this.xf29670e286f5562f);
         }
         double num6 = values.Sum<double>(selector);
         this._x8db8a12c7e795fea = Math.Sqrt(num6 / ((double) this._xdc8f3f8857bee4c6));
         if ((((uint) current) + ((uint) num4)) > uint.MaxValue)
         {
             goto Label_00F1;
         }
         if ((((uint) num6) - ((uint) current)) <= uint.MaxValue)
         {
             return;
         }
     }
     Label_016A:
     num3 = 0.0;
     num4 = 0.0;
     goto Label_00F1;
 }
        private static void FindSumAndAverage(IList<int> numbers)
        {
            long numbersSum = 0;
            double numbersAverage = 0;

            numbersSum = numbers.Sum();
            numbersAverage = numbers.Average();
            Console.WriteLine("The sum of your sequence is: {0} and the avgerage is: {1}.", numbersSum, numbersAverage);
        }
 public static DailyBuildSummary Create(DateTime date, IList<BuildDetails> dailyBuilds)
 {
     return new DailyBuildSummary()
     {
         Date = date,
         FailedBuilds = dailyBuilds.Count(b => b.Status == BuildState.Broken),
         TotalBuilds = dailyBuilds.Count(),
         NumberChangedFiles = dailyBuilds.Sum(b => b.NumberChangedFiles)
     };
 }
Example #17
0
        protected void WriteFramesToStream(IList<Frame> frames, Stream stream)
        {
            //TODO: Issue #11 -- Implement BufferPool (or consider WCF BufferManager?)
            //TODO: Issue #12 -- Consider custom implementation of FrameWriter for sockets.
            var rawMessage = new Byte[frames.Count * Frame.PreambleSize + frames.Sum(frame => frame.Body.Count)];
            var offset = 0;

            foreach (var frame in frames)
            {
                unsafe
                {
                    fixed (Byte* numRef = this.preamble)
                        *((Int32*)numRef) = sizeof(Byte) + frame.Body.Count;

                    this.preamble[Frame.PreambleFlagsOffset] = (Byte)frame.Flags;
                }

                Buffer.BlockCopy(this.preamble, 0, rawMessage, offset, Frame.PreambleSize);
                offset += Frame.PreambleSize;

                Buffer.BlockCopy(frame.Body.Array, frame.Body.Offset, rawMessage, offset, frame.Body.Count);
                offset += frame.Body.Count;
            }

            stream.Write(rawMessage, 0, rawMessage.Length);
        }
Example #18
0
 public override void Update()
 {
     base.Update();
     var enemies = Scene.GetEntities<Monster>();
     if (enemies.IsEmpty())
         return;
     var targetsDistance = enemies.Select(x => new { Target = x, Distance = Vector2.Distance(new Vector2(x.X, x.Y), new Vector2(Entity.X, Entity.Y))}).ToList();
     Targets = targetsDistance.OrderBy(x => x.Distance).Select(x => x.Target).Take(Tower.MaxTargets).ToList();
     if (Targets.Any())
     {
         Tower.Direction.X = Targets.Sum(target => target.X) / Targets.Count;
         Tower.Direction.Y = Targets.Sum(target => target.Y) / Targets.Count;
     }
     if (AtMax)
         Shoot();
 }
Example #19
0
 public override WebSocketPackageInfo Handle(IAppSession session, WebSocketContext context, IList<ArraySegment<byte>> data)
 {
     var total = data.Sum(d => d.Count);
     var payloadLength = context.PayloadLength;
     var text = Encoding.UTF8.GetString(data, total - payloadLength, payloadLength);
     return new WebSocketPackageInfo(text, ServiceProvider.StringParser);
 }
 public AggregationOperationResult Do(IList<UniversalValue> input)
 {
     if (input == null)
         throw new ArgumentNullException("input");
     AggregationOperationResult result = new AggregationOperationResult();
     result.Add("sum", input.Sum());
     return result;
 }
        public ProgramFitnessFunction(Puzzle puzzle, IList<int> funcSlotCount)
        {
            Debug.Assert(puzzle != null && funcSlotCount != null && funcSlotCount.Count > 0);

            this.puzzle = puzzle;
            this.funcSlotCount = funcSlotCount;
            this.totalSlots = funcSlotCount.Sum();
        }
 public AggregationOperationResult Do(IList<double> input)
 {
     if (input == null)
         throw new ArgumentNullException("input");
     if (!input.Any())
         throw new InvalidOperationException("No elements to aggregate");
     return new AggregationOperationResult(AggregationType.Sum, input.Sum());
 }
Example #23
0
 public QuotaWrapper(TenantQuota quota, IList<TenantQuotaRow> quotaRows)
 {
     StorageSize = (ulong) Math.Max(0, quota.MaxTotalSize);
     MaxFileSize = (ulong) Math.Max(0, quota.MaxFileSize);
     UsedSize = (ulong) Math.Max(0, quotaRows.Sum(r => r.Counter));
     StorageUsage =
         quotaRows.Select(x => new QuotaUsage() {Path = x.Path.TrimStart('/').TrimEnd('/'), Size = x.Counter,}).
             ToList();
 }
Example #24
0
        private static void PrintResult(IList<Item> getResult)
        {
            Console.WriteLine(getResult.Sum(x => x.Price));

            foreach (var item in getResult)
            {
                Console.WriteLine(item);
            }
        }
Example #25
0
        private static void AssertSortedDescending(IEnumerable<int> input, IList<int> output)
        {
            Assert.Equal(input.Sum(), output.Sum());

            for (var i = 0; i < output.Count - 1; i++)
            {
                Assert.True(output[i] >= output[i + 1]);
            }
        }
Example #26
0
 public static string PorcentagemEquivalente(IList<Estatistica> estatisticas)
 {
     string retorno = "";
     int total = estatisticas.Sum(estatistica => estatistica.Votos);
     foreach (Estatistica estatistica in estatisticas)
     {
         retorno += Environment.NewLine + String.Format("{0}: {1:0.00}%", estatistica.Nome, ((double)estatistica.Votos * 100 / (double)total));
     }
     return retorno + Environment.NewLine;
 }
Example #27
0
        public CarCalculatorSummary(IList<FuelEntryModel> fuelEntries)
        {
            HasData = fuelEntries != null && fuelEntries.Any();
            if (!HasData) return;

            MinAmountOf100Km = fuelEntries.Min(i => i.AmountOfFuelPer100Km);
            MaxAmountOf100Km = fuelEntries.Max(i => i.AmountOfFuelPer100Km);

            MinCost1Km = fuelEntries.Min(i => i.CostOf1Km);
            MaxCost1Km = fuelEntries.Max(i => i.CostOf1Km);

            SumDistance = fuelEntries.Sum(i => i.CurrentDistance);
            SumAmountOfFuel = fuelEntries.Sum(i => i.AmountOfFuel);
            SumTotalCost = fuelEntries.Sum(i => i.GasPrice * i.AmountOfFuel);

            var minDate = fuelEntries.Min(i => i.Date);
            var maxDate = fuelEntries.Max(i => i.Date);
            AverageFuel = (decimal)((maxDate - minDate).TotalDays/fuelEntries.Count);
        }
Example #28
0
 /// <summary>
 /// 全てのチャンネルを独立して計算し、
 /// 全て同じ比率でミックスします。
 /// <para>厳密にはこれはFM音源にはなりません。</para>
 /// </summary>
 /// <param name="op">オペレーターのリスト</param>
 /// <param name="tag">フィードバックの保持など自由に使えるタグオブジェクト</param>
 /// <param name="state">合成状態の情報</param>
 /// <returns>状態</returns>
 public static double ParallelMixAlgorithm(IList<FMOperator> op, ref object tag, FMSynthesisState state)
 {
     var mix = 0.0;
     var max = op.Sum(p => p.ModulationIndex);
     foreach (var i in op)
     {
         mix += i.GetState(state);
     }
     return mix / max;
 }
Example #29
0
 public void Print(IList<Transaction> transactions)
 {
     _Console.WriteLine(StatementHeader);
     var balance = new Money(transactions.Sum(a => a.Money.Amount));
     foreach (var transaction in transactions.OrderByDescending(a => a.Date))
     {
          _Console.WriteLine(GetFormattedLine(transaction, balance));
          balance.Amount -= transaction.Money.Amount;
     }
 }
 /// <summary>
 /// Create a new BinaryTokenStreamReader to read from the specified input buffers.
 /// </summary>
 /// <param name="buffs">The list of ArraySegments to use for the data.</param>
 public BinaryTokenStreamReader(IList<ArraySegment<byte>> buffs)
 {
     buffers = buffs;
     totalProcessedBytes = 0;
     currentSegmentIndex = 0;
     InitializeCurrentSegment(0);
     totalLength = buffs.Sum(b => b.Count);
     buffersCount = buffs.Count;
     Trace("Starting new stream reader");
 }