コード例 #1
0
        private void GetFullPageRecord(int i, FullPageRecord[] records, ILookup <string, NumberingPool> allPrefixes)
        {
            string query = i.ToString();

            var q      = allPrefixes.Where(x => x.Key == i.ToString());
            var record = new FullPageRecord
            {
                //Row = Convert.ToInt32(query.Substring(0, 2)),
                Prefix = i.ToString()
            };

            if (q.Count() == 0)
            {
                record.Description = "";
                record.Color       = Color.White;
                records[i - 2000]  = record;
            }
            else
            {
                int capacity = 0;


                foreach (var number in q.First())
                {
                    switch (number.Prefix.Length)
                    {
                    case 4:
                        capacity += 10000;
                        break;

                    case 5:
                        capacity += 1000;
                        break;

                    case 6:
                        capacity += 100;
                        break;

                    case 7:
                        capacity += 10;
                        break;

                    case 8:
                        capacity += 1;
                        break;

                    default:
                        break;
                    }
                }
                if (capacity == 10000)
                {
                    record.Color = Color.LightGray;
                }
                else
                {
                    record.Color = Color.LightGreen;
                }

                var typeGroup = (from r in q.First()
                                 orderby r.Status
                                 group r by r.NumberType into grp
                                 select new { NumberType = grp.Key, grp }).ToArray();

                StringBuilder sb = new StringBuilder();
                foreach (var item in typeGroup)
                {
                    sb.Append($"<b>{item.NumberType}</b>:<br/>");
                    var statusGroup = from r in item.grp
                                      group r by r.Status into sgrp
                                      select new { Status = sgrp.Key, Count = sgrp.Count() };
                    foreach (var stat in statusGroup)
                    {
                        if (stat.Status == NumberingStatus.Used)
                        {
                            var linkTypeGroup = from r in item.grp
                                                where r.Status == stat.Status && r.Link != null
                                                group r by r.Link into lgrp
                                                select new { LinkType = lgrp.Key, Count = lgrp.Count() };
                            if (linkTypeGroup.Count() != 0)
                            {
                                sb.Append($"{stat.Status}: {stat.Count}(");


                                foreach (var link in linkTypeGroup)
                                {
                                    sb.Append($"{link.LinkType}: {link.Count}");
                                }

                                sb.Append(")<br/>");
                            }
                            else
                            {
                                sb.Append($"{stat.Status}: {stat.Count}");
                            }
                        }
                        else
                        {
                            sb.Append($"{stat.Status}: {stat.Count}<br/>");
                        }
                    }
                }
                record.Description = sb.ToString();
                records[i - 2000]  = record;
            }
        }
コード例 #2
0
        public IActionResult FullSheet()
        {
            var model = new FullPageRecord[7000];


            var allPrefixes = repository.NumberingPools
                              .Where(x =>
                                     (x.Prefix.StartsWith('2') ||
                                      x.Prefix.StartsWith('3') ||
                                      x.Prefix.StartsWith('4') ||
                                      x.Prefix.StartsWith('5') ||
                                      x.Prefix.StartsWith('6') ||
                                      x.Prefix.StartsWith('7') ||
                                      x.Prefix.StartsWith('8')) && x.Prefix.Length > 3)
                              .AsNoTracking()
                              .ToLookup(x => x.Prefix.Substring(0, 4));

            Parallel.For(2000, 9000, (i) =>
            {
                GetFullPageRecord(i, model, allPrefixes);
            });

            var lessThan4Digit = repository.NumberingPools
                                 .Where(x =>
                                        (x.Prefix.StartsWith('2') ||
                                         x.Prefix.StartsWith('3') ||
                                         x.Prefix.StartsWith('4') ||
                                         x.Prefix.StartsWith('5') ||
                                         x.Prefix.StartsWith('6') ||
                                         x.Prefix.StartsWith('7') ||
                                         x.Prefix.StartsWith('8')) && x.Prefix.Length < 4)
                                 .AsNoTracking()
                                 .ToList();

            foreach (var np in lessThan4Digit)
            {
                int j = 0;
                switch (np.Prefix.Length)
                {
                case 3:
                    j = 10;
                    break;

                case 2:
                    j = 100;
                    break;

                case 1:
                    j = 1000;
                    break;

                default:
                    break;
                }
                for (int i = 0; i < j; i++)
                {
                    if (!int.TryParse(np.Prefix, out int p))
                    {
                        continue;
                    }
                    p = p * j;
                    model[(p + i) - 2000].Color       = Color.LightGray;
                    model[(p + i) - 2000].Description = $"Please refer to '{np.Prefix}' for detail.";
                }
            }



            return(View(model));
        }