Exemple #1
0
        public ReportVM GetReport(string token, int top = 5)
        {
            ReportVM ret = new ReportVM();
            var      to  = ScanDataBaseManager.GetToken().Token;

            if (to == token)
            {
                StringBuilder sb     = new StringBuilder();
                var           report = ScanDataBaseManager.GetReport();
                var           items  = ScanDataBaseManager.ReportItem(report.ReportId);

                ret.TotalCount = report.TotalExist;
                sb.AppendLine($"总Av数量: [{ret.TotalCount}]");
                ret.TotalSizeStr = FileSize.GetAutoSizeString((double)report.TotalExistSize, 1);
                sb.AppendLine($"总Av大小: [{ret.TotalSizeStr}]");
                ret.TotalSize    = (double)report.TotalExistSize;
                ret.ChineseCount = report.ChineseCount;
                sb.AppendLine($"中文Av数量: [{ret.ChineseCount}]");
                ret.FileLessThan1G = report.LessThenOneGiga;
                sb.AppendLine($"文件小于1GB: [{ret.FileLessThan1G}]");
                ret.FileLargeThan1G = report.OneGigaToTwo;
                sb.AppendLine($"大于1GB小于2GB: [{ret.FileLargeThan1G}]");
                ret.FileLargeThan2G = report.TwoGigaToFour;
                sb.AppendLine($"大于2GB小于4GB: [{ret.FileLargeThan2G}]");
                ret.FileLargeThan4G = report.FourGigaToSix;
                sb.AppendLine($"大于4GB小于6GB: [{ret.FileLargeThan4G}]");
                ret.FileLargeThan6G = report.GreaterThenSixGiga;
                sb.AppendLine($"文件大于6GB: [{ret.FileLargeThan6G}]");

                var extensionModel = JsonConvert.DeserializeObject <Dictionary <string, int> >(report.Extension);

                ret.Formats = extensionModel;
                sb.AppendLine("后缀分布:");
                foreach (var ext in extensionModel)
                {
                    sb.AppendLine($"\t{ext.Key} : {ext.Value}");
                }

                foreach (ReportType type in Enum.GetValues(typeof(ReportType)))
                {
                    List <ReportItem> i = new List <ReportItem>();
                    switch (type)
                    {
                    case ReportType.Actress:
                        i = items.Where(x => (ReportType)x.ReportType == type).OrderByDescending(x => x.ExistCount).Take(top).ToList();

                        sb.AppendLine("女优TOP" + top);

                        foreach (var temp in i)
                        {
                            var name  = temp.ItemName;
                            var count = temp.ExistCount;
                            var ratio = $"{temp.ExistCount} / {temp.TotalCount}";
                            var size  = FileSize.GetAutoSizeString(temp.TotalSize, 1);

                            sb.AppendLine($"\t{name} -> 作品 {ratio},总大小 {size}");
                        }

                        break;

                    case ReportType.Category:
                        i = items.Where(x => (ReportType)x.ReportType == type).OrderByDescending(x => x.ExistCount).Take(top).ToList();

                        sb.AppendLine("分类TOP" + top);

                        foreach (var temp in i)
                        {
                            var name  = temp.ItemName;
                            var count = temp.ExistCount;
                            var ratio = $"{temp.ExistCount} / {temp.TotalCount}";
                            var size  = FileSize.GetAutoSizeString(temp.TotalSize, 1);

                            sb.AppendLine($"\t{name} -> 作品 {ratio},总大小 {size}");
                        }

                        break;

                    case ReportType.Prefix:
                        i = items.Where(x => (ReportType)x.ReportType == type).OrderByDescending(x => x.ExistCount).Take(top).ToList();

                        sb.AppendLine("番号TOP" + top);

                        foreach (var temp in i)
                        {
                            var name  = temp.ItemName;
                            var count = temp.ExistCount;
                            var ratio = $"{temp.ExistCount} / {temp.TotalCount}";
                            var size  = FileSize.GetAutoSizeString(temp.TotalSize, 1);

                            sb.AppendLine($"\t{name} -> 作品 {ratio},总大小 {size}");
                        }

                        break;

                    case ReportType.Company:
                        i = items.Where(x => (ReportType)x.ReportType == type).OrderByDescending(x => x.ExistCount).Take(top).ToList();

                        sb.AppendLine("公司TOP" + top);

                        foreach (var temp in i)
                        {
                            var name  = temp.ItemName;
                            var count = temp.ExistCount;
                            var ratio = $"{temp.ExistCount} / {temp.TotalCount}";
                            var size  = FileSize.GetAutoSizeString(temp.TotalSize, 1);

                            sb.AppendLine($"\t{name} -> 作品 {ratio},总大小 {size}");
                        }

                        break;

                    case ReportType.Date:
                        i = items.Where(x => (ReportType)x.ReportType == type).OrderByDescending(x => x.ExistCount).Take(top).ToList();

                        sb.AppendLine("日期TOP" + top);

                        foreach (var temp in i)
                        {
                            var name  = temp.ItemName;
                            var count = temp.ExistCount;
                            var ratio = $"{temp.ExistCount} / {temp.TotalCount}";
                            var size  = FileSize.GetAutoSizeString(temp.TotalSize, 1);

                            sb.AppendLine($"\t{name} -> 作品 {ratio},总大小 {size}");
                        }

                        break;
                    }
                }

                ret.ShowContent = sb.ToString();
            }

            return(ret);
        }
Exemple #2
0
        public ActionResult ShowChart()
        {
            var report = ScanDataBaseManager.GetReport();

            var items = ScanDataBaseManager.ReportItem(report.ReportId);

            string extension = "['后缀', 'total']";
            Dictionary <string, string> actress   = new Dictionary <string, string>();
            Dictionary <string, string> category  = new Dictionary <string, string>();
            Dictionary <string, string> director  = new Dictionary <string, string>();
            Dictionary <string, string> company   = new Dictionary <string, string>();
            Dictionary <string, string> publisher = new Dictionary <string, string>();
            Dictionary <string, string> prefix    = new Dictionary <string, string>();
            Dictionary <string, string> date      = new Dictionary <string, string>();

            Dictionary <string, string> actressRatio   = new Dictionary <string, string>();
            Dictionary <string, string> categoryRatio  = new Dictionary <string, string>();
            Dictionary <string, string> directorRatio  = new Dictionary <string, string>();
            Dictionary <string, string> companyRatio   = new Dictionary <string, string>();
            Dictionary <string, string> publisherRatio = new Dictionary <string, string>();
            Dictionary <string, string> prefixRatio    = new Dictionary <string, string>();
            Dictionary <string, string> dateRatio      = new Dictionary <string, string>();

            Dictionary <string, string> actressSize   = new Dictionary <string, string>();
            Dictionary <string, string> categorySize  = new Dictionary <string, string>();
            Dictionary <string, string> directorSize  = new Dictionary <string, string>();
            Dictionary <string, string> companySize   = new Dictionary <string, string>();
            Dictionary <string, string> publisherSize = new Dictionary <string, string>();
            Dictionary <string, string> prefixSize    = new Dictionary <string, string>();
            Dictionary <string, string> dateSize      = new Dictionary <string, string>();

            List <string> actressKey     = new List <string>();
            List <int>    actressValue   = new List <int>();
            List <string> categoryKey    = new List <string>();
            List <int>    categoryValue  = new List <int>();
            List <string> directorKey    = new List <string>();
            List <int>    directorValue  = new List <int>();
            List <string> companyKey     = new List <string>();
            List <int>    companyValue   = new List <int>();
            List <string> publisherKey   = new List <string>();
            List <int>    publisherValue = new List <int>();
            List <string> prefixKey      = new List <string>();
            List <int>    prefixValue    = new List <int>();
            List <string> dateKey        = new List <string>();
            List <int>    dateValue      = new List <int>();

            List <string>  actressRatioKey     = new List <string>();
            List <decimal> actressRatioValue   = new List <decimal>();
            List <string>  categoryRatioKey    = new List <string>();
            List <decimal> categoryRatioValue  = new List <decimal>();
            List <string>  directorRatioKey    = new List <string>();
            List <decimal> directorRatioValue  = new List <decimal>();
            List <string>  companyRatioKey     = new List <string>();
            List <decimal> companyRatioValue   = new List <decimal>();
            List <string>  publisherRatioKey   = new List <string>();
            List <decimal> publisherRatioValue = new List <decimal>();
            List <string>  prefixRatioKey      = new List <string>();
            List <decimal> prefixRatioValue    = new List <decimal>();
            List <string>  dateRatioKey        = new List <string>();
            List <decimal> dateRatioValue      = new List <decimal>();

            List <string> actressSizeKey     = new List <string>();
            List <double> actressSizeValue   = new List <double>();
            List <string> categorySizeKey    = new List <string>();
            List <double> categorySizeValue  = new List <double>();
            List <string> directorSizeKey    = new List <string>();
            List <double> directorSizeValue  = new List <double>();
            List <string> companySizeKey     = new List <string>();
            List <double> companySizeValue   = new List <double>();
            List <string> publisherSizeKey   = new List <string>();
            List <double> publisherSizeValue = new List <double>();
            List <string> prefixSizeKey      = new List <string>();
            List <double> prefixSizeValue    = new List <double>();
            List <string> dateSizeKey        = new List <string>();
            List <double> dateSizeValue      = new List <double>();

            var extensionModel = JsonConvert.DeserializeObject <Dictionary <string, int> >(report.Extension);

            foreach (var e in extensionModel)
            {
                extension += string.Format(",['{1}',{0}]", e.Value, e.Key);
            }

            foreach (ReportType type in Enum.GetValues(typeof(ReportType)))
            {
                List <ReportItem> i = new List <ReportItem>();
                switch (type)
                {
                case ReportType.Actress:
                    i = items.Where(x => (ReportType)x.ReportType == type).OrderByDescending(x => x.ExistCount).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        actressKey.Add("'" + temp.ItemName + "'");
                        actressValue.Add(temp.ExistCount);
                    }

                    i = items.Where(x => (ReportType)x.ReportType == type && x.TotalCount >= 100).OrderByDescending(x => (decimal)x.ExistCount / (decimal)x.TotalCount).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        actressRatioKey.Add("'" + temp.ItemName + "'");
                        actressRatioValue.Add(Math.Round(((decimal)temp.ExistCount / (decimal)temp.TotalCount) * 100, 1));
                    }

                    i = items.Where(x => (ReportType)x.ReportType == type).OrderByDescending(x => x.TotalSize).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        actressSizeKey.Add("'" + temp.ItemName + "'");
                        actressSizeValue.Add(temp.TotalSize);
                    }

                    break;

                case ReportType.Category:
                    i = items.Where(x => (ReportType)x.ReportType == type).OrderByDescending(x => x.ExistCount).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        categoryKey.Add("'" + temp.ItemName + "'");
                        categoryValue.Add(temp.ExistCount);
                    }

                    i = items.Where(x => (ReportType)x.ReportType == type && x.TotalCount >= 100).OrderByDescending(x => (decimal)x.ExistCount / (decimal)x.TotalCount).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        categoryRatioKey.Add("'" + temp.ItemName + "'");
                        categoryRatioValue.Add(Math.Round(((decimal)temp.ExistCount / (decimal)temp.TotalCount) * 100, 1));
                    }

                    i = items.Where(x => (ReportType)x.ReportType == type).OrderByDescending(x => x.TotalSize).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        categorySizeKey.Add("'" + temp.ItemName + "'");
                        categorySizeValue.Add(temp.TotalSize);
                    }

                    break;

                case ReportType.Director:
                    i = items.Where(x => (ReportType)x.ReportType == type).OrderByDescending(x => x.ExistCount).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        directorKey.Add("'" + temp.ItemName + "'");
                        directorValue.Add(temp.ExistCount);
                    }


                    i = items.Where(x => (ReportType)x.ReportType == type && x.TotalCount >= 100).OrderByDescending(x => (decimal)x.ExistCount / (decimal)x.TotalCount).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        directorRatioKey.Add("'" + temp.ItemName + "'");
                        directorRatioValue.Add(Math.Round(((decimal)temp.ExistCount / (decimal)temp.TotalCount) * 100, 1));
                    }

                    i = items.Where(x => (ReportType)x.ReportType == type).OrderByDescending(x => x.TotalSize).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        directorSizeKey.Add("'" + temp.ItemName + "'");
                        directorSizeValue.Add(temp.TotalSize);
                    }

                    break;

                case ReportType.Company:
                    i = items.Where(x => (ReportType)x.ReportType == type).OrderByDescending(x => x.ExistCount).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        companyKey.Add("'" + temp.ItemName + "'");
                        companyValue.Add(temp.ExistCount);
                    }


                    i = items.Where(x => (ReportType)x.ReportType == type && x.TotalCount >= 100).OrderByDescending(x => (decimal)x.ExistCount / (decimal)x.TotalCount).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        companyRatioKey.Add("'" + temp.ItemName + "'");
                        companyRatioValue.Add(Math.Round(((decimal)temp.ExistCount / (decimal)temp.TotalCount) * 100, 1));
                    }

                    i = items.Where(x => (ReportType)x.ReportType == type).OrderByDescending(x => x.TotalSize).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        companySizeKey.Add("'" + temp.ItemName + "'");
                        companySizeValue.Add(temp.TotalSize);
                    }

                    break;

                case ReportType.Publisher:
                    i = items.Where(x => (ReportType)x.ReportType == type).OrderByDescending(x => x.ExistCount).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        publisherKey.Add("'" + temp.ItemName + "'");
                        publisherValue.Add(temp.ExistCount);
                    }


                    i = items.Where(x => (ReportType)x.ReportType == type && x.TotalCount >= 100).OrderByDescending(x => (decimal)x.ExistCount / (decimal)x.TotalCount).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        publisherRatioKey.Add("'" + temp.ItemName + "'");
                        publisherRatioValue.Add(Math.Round(((decimal)temp.ExistCount / (decimal)temp.TotalCount) * 100, 1));
                    }

                    i = items.Where(x => (ReportType)x.ReportType == type).OrderByDescending(x => x.TotalSize).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        publisherSizeKey.Add("'" + temp.ItemName + "'");
                        publisherSizeValue.Add(temp.TotalSize);
                    }

                    break;

                case ReportType.Prefix:
                    i = items.Where(x => (ReportType)x.ReportType == type).OrderByDescending(x => x.ExistCount).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        prefixKey.Add("'" + temp.ItemName + "'");
                        prefixValue.Add(temp.ExistCount);
                    }


                    i = items.Where(x => (ReportType)x.ReportType == type && x.TotalCount >= 100).OrderByDescending(x => (decimal)x.ExistCount / (decimal)x.TotalCount).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        prefixRatioKey.Add("'" + temp.ItemName + "'");
                        prefixRatioValue.Add(Math.Round(((decimal)temp.ExistCount / (decimal)temp.TotalCount) * 100, 1));
                    }

                    i = items.Where(x => (ReportType)x.ReportType == type).OrderByDescending(x => x.TotalSize).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        prefixSizeKey.Add("'" + temp.ItemName + "'");
                        prefixSizeValue.Add(temp.TotalSize);
                    }

                    break;

                case ReportType.Date:
                    i = items.Where(x => (ReportType)x.ReportType == type).OrderByDescending(x => x.ExistCount).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        dateKey.Add("'" + temp.ItemName + "'");
                        dateValue.Add(temp.ExistCount);
                    }


                    i = items.Where(x => (ReportType)x.ReportType == type && x.TotalCount >= 100).OrderByDescending(x => (decimal)x.ExistCount / (decimal)x.TotalCount).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        dateRatioKey.Add("'" + temp.ItemName + "'");
                        dateRatioValue.Add(Math.Round(((decimal)temp.ExistCount / (decimal)temp.TotalCount) * 100, 1));
                    }

                    i = items.Where(x => (ReportType)x.ReportType == type).OrderByDescending(x => x.TotalSize).Take(20).ToList();

                    foreach (var temp in i)
                    {
                        dateSizeKey.Add("'" + temp.ItemName + "'");
                        dateSizeValue.Add(temp.TotalSize);
                    }

                    break;
                }
            }

            actress.Add("[" + string.Join(",", actressKey) + "]", "[" + string.Join(",", actressValue) + "]");
            category.Add("[" + string.Join(",", categoryKey) + "]", "[" + string.Join(",", categoryValue) + "]");
            director.Add("[" + string.Join(",", directorKey) + "]", "[" + string.Join(",", directorValue) + "]");
            company.Add("[" + string.Join(",", companyKey) + "]", "[" + string.Join(",", companyValue) + "]");
            publisher.Add("[" + string.Join(",", publisherKey) + "]", "[" + string.Join(",", publisherValue) + "]");
            date.Add("[" + string.Join(",", dateKey) + "]", "[" + string.Join(",", dateValue) + "]");
            prefix.Add("[" + string.Join(",", prefixKey) + "]", "[" + string.Join(",", prefixValue) + "]");

            actressRatio.Add("[" + string.Join(",", actressRatioKey) + "]", "[" + string.Join(",", actressRatioValue) + "]");
            categoryRatio.Add("[" + string.Join(",", categoryRatioKey) + "]", "[" + string.Join(",", categoryRatioValue) + "]");
            directorRatio.Add("[" + string.Join(",", directorRatioKey) + "]", "[" + string.Join(",", directorRatioValue) + "]");
            companyRatio.Add("[" + string.Join(",", companyRatioKey) + "]", "[" + string.Join(",", companyRatioValue) + "]");
            publisherRatio.Add("[" + string.Join(",", publisherRatioKey) + "]", "[" + string.Join(",", publisherRatioValue) + "]");
            dateRatio.Add("[" + string.Join(",", dateRatioKey) + "]", "[" + string.Join(",", dateRatioValue) + "]");
            prefixRatio.Add("[" + string.Join(",", prefixRatioKey) + "]", "[" + string.Join(",", prefixRatioValue) + "]");

            actressSize.Add("[" + string.Join(",", actressSizeKey) + "]", "[" + string.Join(",", actressSizeValue) + "]");
            categorySize.Add("[" + string.Join(",", categorySizeKey) + "]", "[" + string.Join(",", categorySizeValue) + "]");
            directorSize.Add("[" + string.Join(",", directorSizeKey) + "]", "[" + string.Join(",", directorSizeValue) + "]");
            companySize.Add("[" + string.Join(",", companySizeKey) + "]", "[" + string.Join(",", companySizeValue) + "]");
            publisherSize.Add("[" + string.Join(",", publisherSizeKey) + "]", "[" + string.Join(",", publisherSizeValue) + "]");
            dateSize.Add("[" + string.Join(",", dateSizeKey) + "]", "[" + string.Join(",", dateSizeValue) + "]");
            prefixSize.Add("[" + string.Join(",", prefixSizeKey) + "]", "[" + string.Join(",", prefixSizeValue) + "]");

            ViewData.Add("countString", string.Format("['总数', 'total'],['总共',{0}],['存在',{1}]", report.TotalCount, report.TotalExist));
            ViewData.Add("chineseString", string.Format("['中文', 'total'],['总共',{0}],['中文',{1}]", report.TotalCount, report.ChineseCount));
            ViewData.Add("sizeString", string.Format("['大小', 'total'],['[0,1GB)',{0}], ['[1GB,2GB)',{1}], ['[2GB,4GB)',{2}], ['[4GB,6GB)',{3}], ['[6GB,∞)',{4}]", report.LessThenOneGiga, report.OneGigaToTwo, report.TwoGigaToFour, report.FourGigaToSix, report.GreaterThenSixGiga));
            ViewData.Add("extensionString", extension);

            ViewData.Add("actressString", actress);
            ViewData.Add("categoryString", category);
            ViewData.Add("directorString", director);
            ViewData.Add("companyString", company);
            ViewData.Add("publisherString", publisher);
            ViewData.Add("dateString", date);
            ViewData.Add("prefixString", prefix);

            ViewData.Add("actressRatioString", actressRatio);
            ViewData.Add("categoryRatioString", categoryRatio);
            ViewData.Add("directorRatioString", directorRatio);
            ViewData.Add("companyRatioString", companyRatio);
            ViewData.Add("publisherRatioString", publisherRatio);
            ViewData.Add("dateRatioString", dateRatio);
            ViewData.Add("prefixRatioString", prefixRatio);

            ViewData.Add("actressSizeString", actressSize);
            ViewData.Add("categorySizeString", categorySize);
            ViewData.Add("directorSizeString", directorSize);
            ViewData.Add("companySizeString", companySize);
            ViewData.Add("publisherSizeString", publisherSize);
            ViewData.Add("dateSizeString", dateSize);
            ViewData.Add("prefixSizeString", prefixSize);

            return(View());
        }