コード例 #1
0
ファイル: BankListFlatFile.cs プロジェクト: baonguyen96/Linq
        public void Problem10()
        {
            // How many CERT values are above 20000 ?
            var result = Records.Count(r => int.Parse(r.GetItemWithKey("cert").Value) > 20000);

            Console.WriteLine(result);
        }
コード例 #2
0
        private void ApplyFilter()
        {
            //_Filters.Check1 = check;
            if (_Filters.Check1 == false && _Filters.Check2 == false && _Filters.Check3 == false &&
                _Filters.Check4 == false && _Filters.Check5 == false)
            {
                dialogService.ShowMessage("Не задан ни один фильтр...");
                return;
            }

            if (Records.Count() == 0)
            {
                dialogService.ShowMessage("Сначала обновите данные (Ctrl+R)");
                return;
            }
            LoadDataForUsersList();
            ObservableCollection <UserRecord> tmp = new ObservableCollection <UserRecord>();

            tmp = _Filters.SetFilters2(Records, _Filters.Param1, _Filters.Param2, _Filters.Param3,
                                       _Filters.StartDateparam, _Filters.EndtDateparam,
                                       _Filters.StartDateparam2, _Filters.EndtDateparam2,
                                       _Filters.Check1, _Filters.Check2, _Filters.Check3,
                                       _Filters.Check4, _Filters.Check5);
            if (tmp.Count() == 0)
            {
                Records.Clear();
                dialogService.ShowMessage("Совпадений не найдено");
                return;
            }
            Records.Clear();
            foreach (UserRecord item in tmp)
            {
                Records.Add(item);
            }
        }
コード例 #3
0
ファイル: BankListFlatFile.cs プロジェクト: baonguyen96/Linq
        public void Problem12()
        {
            // How many banks closed in the year 2008?
            var result = Records.Count(r => DateTime.Parse(r.GetItemWithKey("closing date").Value).Year == 2008);

            Console.WriteLine(result);
        }
コード例 #4
0
ファイル: BankListFlatFile.cs プロジェクト: baonguyen96/Linq
        public void Problem8()
        {
            // How many failed banks don't have the word \"Bank\" in their name?
            var result = Records.Count(r => !r.GetItemWithKey("bank name").Value.Contains("Bank"));

            Console.WriteLine(result);
        }
コード例 #5
0
ファイル: BankListFlatFile.cs プロジェクト: baonguyen96/Linq
        public void Problem9()
        {
            // How many bank names start with the letter 's' ?
            var result = Records.Count(r => r.GetItemWithKey("bank name").Value.StartsWith("S"));

            Console.WriteLine(result);
        }
コード例 #6
0
        protected override void CalculatePriorities(IEnumerable <TableRecord> records)
        {
            // If previous rules haven't solved any rows, the recursion must be stopped.
            if (records.Count() == Records.Count())
            {
                return;
            }

            short              tourneyId = records.First().tourneyId;
            IEnumerable <int>  teamIds   = records.Select(rg => rg.teamId);
            IEnumerable <Game> games     = gameBll.GetGamesByTourneyBetweenTeams(tourneyId, teamIds);

            if (!games.Any())
            {
                return;
            }

            TableBase table = new ClassicTable();

            table.BuildFromGames(tourneyId, games);

            IRanking ranking = new Implementations.Components.Ranking();

            ranking.CalculateTable(Rule, games);

            IEnumerable <TableRecord> prioritizedTable = ranking.CalculateTable(Rule, games);

            foreach (TableRecord record in records)
            {
                record.PointsVirtual = prioritizedTable.FirstOrDefault()?.PointsVirtual ?? 0;
            }
        }
コード例 #7
0
ファイル: TableDecorator.cs プロジェクト: DelLitt/FCWebSite
        public override void Sort()
        {
            Table.Sort();

            log.Trace("Sorting table '{0}'.", Name);

            IEnumerable <IGrouping <short, TableRecord> > groupedRecords = GetGroupsByPointsVirtual(Table.Records);

            log.Trace("Groups count: {0}", groupedRecords.Count());
            log.Trace("Groups: [{0}]", string.Join(", ", groupedRecords.Select(g => g.Key)));

            if (groupedRecords.Count() == Records.Count())
            {
                return;
            }

            foreach (IGrouping <short, TableRecord> recordsGroup in groupedRecords)
            {
                if (recordsGroup.Key == ResolvedValue)
                {
                    continue;
                }

                IEnumerable <TableRecord> virtualRecords = GetNewRecordsWithPriorities(recordsGroup);
                FillZeroVirtualPoints(virtualRecords);

                log.Trace("Virtual point applied to group with Key {0}:", recordsGroup.Key);
                log.Trace(virtualRecords.ToTextTable());

                IEnumerable <IGrouping <short, TableRecord> > groupedRecordsInnner = GetGroupsByPointsVirtual(virtualRecords);
                log.Trace("Groups after virtual point applied: [{0}]", string.Join(", ", groupedRecordsInnner.Select(g => g.Key)));

                // No changes were applied, go to next group
                if (groupedRecordsInnner.Count() == 1)
                {
                    log.Trace("Group with Key {0} cannot be resolved by '{1}'.", recordsGroup.Key, Name);
                    continue;
                }

                // max position must be from real group. we don't know what happens with virtual records outside
                short maxPosition = recordsGroup.Max(g => g.Position);
                log.Trace("Max position: {0}", maxPosition);

                // If changes where applied, sort postions in the real table
                SetPositionsByFolowingPriorities(maxPosition, virtualRecords);
                // If changes where applied, set virtual points of single rows to -1
                SetSingleGroupsAsResolved(groupedRecordsInnner);

                log.Trace("Table after group with key {0} changes applied:", recordsGroup.Key);
                log.Trace(Records.ToTextTable());
            }

            SaveLog();
        }
コード例 #8
0
        public void Update()
        {
            foreach (var setting in Settings)
            {
                var predicate = new Func <ValueHistoryRecord, bool>((r) => r.PropertyName == setting.PropertyName);

                while (Records.Count(predicate) > setting.Amount)
                {
                    Records.Remove(Records.Where(predicate)
                                   .OrderBy(r => r.RecordDate)
                                   .First());
                }
            }
        }
コード例 #9
0
        /*__________________________________________________________________________________________*/
        private void MapPDL_xppLoanScheduleFromProperties()
        {
            foreach (var PDLRecord in PDLLoanList)
            {
                List <PDLoanXPPScheduleList> Records;
                Records = PDLRecord.GetPDLoanXPPScheduleList;

                for (int index = 0; index < Records.Count(); index++)
                {
                    int             gvIdx    = DGVxxpPaySchedule.Rows.Add();
                    DataGridViewRow LineItem = DGVxxpPaySchedule.Rows[gvIdx];
                    LineItem.Cells["DgvColxppLineItem"].Value         = "StartDate";
                    LineItem.Cells["DgvColxppPaymentSeqNumber"].Value = Records[index].xppPaymentSeqNumber.ToString();
                    LineItem.Cells["DgvColxppPaymentNumber"].Value    = Records[index].xppPaymentNumber;
                    LineItem.Cells["DgvColxppPaymentDate"].Value      = Records[index].xppDate == DateTime.MaxValue ? "" : (Records[index].xppDate).FormatDate();
                    LineItem.Cells["DgvColxppPaymentAmt"].Value       = Records[index].xppAmount.ToString();
                }
            }
        }
コード例 #10
0
 public void Calculate()
 {
     if (Records.Count() > 0)
     {
         RecordsCount = Records.Count();
         List <Record> SortedRecords = Records.OrderBy(r => r.Date).ToList();
         TotalPayments = SumOfTopUps();
         TotalCost     = ((SortedRecords.First().Balance - SortedRecords.Last().Balance) + TotalPayments) - SortedRecords.First().TopUp;
         DailyCost     = CalculateDailyAvg(SortedRecords);
         MonthlyCost   = m_dailyCost * Properties.Settings.Default.DaysPerMonth;
         YearlyCost    = m_dailyCost * Properties.Settings.Default.DaysPerYear;
     }
     else
     {
         RecordsCount  = 0;
         TotalPayments = 0;
         TotalCost     = 0;
         DailyCost     = 0;
         MonthlyCost   = 0;
         YearlyCost    = 0;
     }
 }
コード例 #11
0
        private void ListMergeSort() // merges until only 1 list left
        {
            int totalRounds = Records.Count();
            int round       = totalRounds;
            int percent     = split;
            int oldPercent  = split;

            double logRounds = Math.Log(totalRounds);

            while (Records.Count > 1)
            {
                MergeFirstTwo();
                round--;

                percent = (int)((split * Math.Log(totalRounds / round)) / logRounds) + split;
                if (oldPercent < percent)
                {
                    oldPercent = percent;
                    bgw.ReportProgress(percent);
                }
            }
        }
コード例 #12
0
        private void FilterCheckValidation()// us in ApplyFilter methode
        {
            if (_Filters.Check1 == false && _Filters.Check2 == false && _Filters.Check3 == false &&
                _Filters.Check4 == false && _Filters.Check5 == false && _Filters.Check6 == false &&
                _Filters.Check7 == false && _Filters.Check8 == false && _Filters.Check9 == false &&
                _Filters.Check10 == false && _Filters.Check11 == false && _Filters.Check12 == false &&
                _Filters.Check13 == false && _Filters.Check14 == false && _Filters.Check15 == false &&
                _Filters.Check16 == false && _Filters.Check17 == false && _Filters.Check18 == false &&
                _Filters.Check19 == false && _Filters.Check20 == false)

            {
                Records.Clear();
                LoadData();
                return;
            }

            if (Records.Count() == 0)
            {
                dialogService.ShowMessage("Сначала обновите данные (Ctrl+R)");
                return;
            }
        }
コード例 #13
0
    protected Dictionary<string, object> ResultTypeColumnValues_NodalDisplacements(List<int> indices)
    {
      if (Records == null || Records.Count() == 0)
      {
        return new Dictionary<string, object>();
      }
      var factors = GetFactors(SpeckleGSAResultsHelper.ResultUnitType.Length);
      var factorsRotation = GetFactors(SpeckleGSAResultsHelper.ResultUnitType.Angle);

      var retDict = new Dictionary<string, object>
      {
        { "ux", indices.Select(i => ApplyFactors(((CsvNode) Records[i]).Ux, factors)).Cast<object>().ToList() },
        { "uy", indices.Select(i => ApplyFactors(((CsvNode) Records[i]).Uy, factors)).Cast<object>().ToList() },
        { "uz", indices.Select(i => ApplyFactors(((CsvNode) Records[i]).Uz, factors)).Cast<object>().ToList() },
        { "|u|", indices.Select(i => ApplyFactors(((CsvNode) Records[i]).U, factors)).Cast<object>().ToList() },
        { "rxx", indices.Select(i => ApplyFactors(((CsvNode) Records[i]).Rxx, factors)).Cast<object>().ToList() },
        { "ryy", indices.Select(i => ApplyFactors(((CsvNode) Records[i]).Ryy, factors)).Cast<object>().ToList() },
        { "rzz", indices.Select(i => ApplyFactors(((CsvNode) Records[i]).Rzz, factors)).Cast<object>().ToList() },
        { "|r|", indices.Select(i => ApplyFactors(((CsvNode) Records[i]).R_Disp, factorsRotation)).Cast<object>().ToList() },
        { "uxy", indices.Select(i => ApplyFactors(((CsvNode) Records[i]).Uxy, factors)).Cast<object>().ToList() }
      };
      return retDict;
    }
コード例 #14
0
            public int GetRecordIndex(int stationAId, int stationBId) // returns index corresponding to record on line with these two stations
            {
                for (int i = 0; i < Records.Count(); i++)
                {
                    if (Records[i].StationA.Id == stationAId)
                    {
                        if (Records[i].StationB.Id == stationBId)
                        {
                            return(i);
                        }
                    }

                    else if (Records[i].StationB.Id == stationAId)
                    {
                        if (Records[i].StationA.Id == stationBId)
                        {
                            return(i);
                        }
                    }
                }

                return(-1); // error has occured
            }
コード例 #15
0
        private int FirstPass(StationDictionary stations) // reads in data and converts to numerical form
        {
            StreamReader r = new StreamReader(SourceFile);
            FinalLine    f = new FinalLine();

            FileInfo fi   = new FileInfo(SourceFile);
            long     size = fi.Length; //bytes in file

            long bytesRead = 0;
            int  percent   = 0;

            string line;

            const int bytesPerChar = 1; // UTF-8

            while (!r.EndOfStream)
            {
                line = r.ReadLine();
                if (f.TryInitialise(line, stations))
                {
                    Records.AddFirst(new List <FinalLine> {
                        new FinalLine(f)
                    });
                }

                bytesRead += (line.Length + 2) * bytesPerChar; // +2 to account for return and new line

                if (percent < (bytesRead * split) / size)
                {
                    percent++;
                    bgw.ReportProgress(percent);
                }
            }

            r.Close();
            return(Records.Count());
        }
コード例 #16
0
ファイル: CSVFile.cs プロジェクト: claresudbery/Reconciliate
 public int Num_unmatched_records()
 {
     return(Records.Count(x => !x.Matched));
 }