コード例 #1
0
        /// <summary>
        /// 重新计算某一天的小组日汇总数据
        /// URL: /ajax/scan/Admin/RefreshDailySummary.ppx?day=2016-04-28
        /// </summary>
        /// <param name="day"></param>
        /// <returns></returns>
        public string RefreshDailySummary(DateTime day)
        {
            List <GroupDailySummary2> list = new List <GroupDailySummary2>();

            foreach (JobOption job in JobManager.Jobs)
            {
                // 计算当天的汇总数据
                TotalResult data = ScanResultCache.LoadTotalResult(job.Id, day, true);

                GroupDailySummary2 summary = new GroupDailySummary2();
                summary.GroupName = job.Name;
                summary.Data      = ToSummary2(data);
                list.Add(summary);
            }

            string filename = GetDataFileName(day);

            string savepath = Path.GetDirectoryName(filename);

            if (Directory.Exists(savepath) == false)
            {
                Directory.CreateDirectory(savepath);
            }


            string json = list.ToJson();

            File.WriteAllText(filename, json);

            return(json);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: ivan-alles/poker-acpc
        static IGameLogReport CreateGameLogReport(string name)
        {
            IGameLogReport rep;

            if (String.IsNullOrEmpty(_cmdLine.ReportClass))
            {
                rep = new TotalResult();
            }
            else
            {
                ClassFactoryParams cfp = new ClassFactoryParams(_cmdLine.ReportClass);
                rep = ClassFactory.CreateInstance <IGameLogReport>(cfp);
            }
            rep.Name = name;
            rep.Configure(_reportParameters);

            // Show help only once
            if (_cmdLine.ShowReportHelp && !_isHelpShown)
            {
                rep.ShowHelp(_output);
                _isHelpShown = true;
            }

            return(rep);
        }
コード例 #3
0
        public void Execute(TaskContext context, TaskAction action)
        {
            if (action.Items == null || action.Items.Length == 0)
            {
                action.Items = context.JobOption.SlnFiles;
            }

            if (action.Items == null || action.Items.Length == 0)
            {
                return;
            }

            TotalResult totalResult             = context.TotalResult;
            List <VsRuleCheckResult> resultList = new List <VsRuleCheckResult>();

            try {
                foreach (string path in action.Items)
                {
                    VsRuleScaner             scaner = new VsRuleScaner();
                    List <VsRuleCheckResult> list   = scaner.Execute(context.Branch, path);
                    resultList.AddRange(list);
                }
                totalResult.VsRuleCheckResults.AddRange(resultList);
                context.ConsoleWrite("VsRuleScanTask OK");
            }
            catch (Exception ex) {
                totalResult.VsRuleCheckException = ex.ToString();
                context.ProcessException(ex);
            }
        }
コード例 #4
0
ファイル: HomeController.cs プロジェクト: DTaylor1986/Test1
        public async Task <ViewResult> Index()
        {
            IndexViewModel model  = new IndexViewModel();
            HttpClient     client = api.Initial();

            //Get Categories
            HttpResponseMessage catResponse = await client.GetAsync("categories");

            catResponse.EnsureSuccessStatusCode();
            string catJson = await catResponse.Content.ReadAsStringAsync();

            CategoryResult catResult = JsonConvert.DeserializeObject <CategoryResult>(catJson);

            model.Categories = catResult.value;

            //Get Number of jokes
            HttpResponseMessage totalResponse = await client.GetAsync("jokes/count");

            totalResponse.EnsureSuccessStatusCode();
            string totalJson = await totalResponse.Content.ReadAsStringAsync();

            TotalResult totalResult = JsonConvert.DeserializeObject <TotalResult>(totalJson);

            ViewBag.Total = totalResult.value;

            //Get Jokes
            model.Jokes = null;

            return(View(model));
        }
コード例 #5
0
        public Aggregator()
        {
            totalResult = new TotalResult();

            Receive <ReduceResult>(r => Aggregate(r));
            Receive <GetResult>(_ => Sender.Tell(totalResult));
        }
コード例 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pageIndex">0-based page index</param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public virtual Task <TotalResult <List <EventSettings <TKey> > > > Select(int pageIndex, int pageSize)
        {
            int skip = pageIndex * pageSize;
            List <EventSettings <TKey> > list = _items.Skip(skip).Take(pageSize).ToList();
            var result = new TotalResult <List <EventSettings <TKey> > >(list, _items.Count);

            return(Task.FromResult(result));
        }
        public virtual async Task <DispatchTemplate <TKey> > Select(TKey dispatchTemplatesId)
        {
            TotalResult <List <DispatchTemplate <TKey> > > allItems = await GetFromCacheOrFetch().ConfigureAwait(false);

            DispatchTemplate <TKey> item = allItems.Data.FirstOrDefault(
                x => EqualityComparer <TKey> .Default.Equals(x.DispatchTemplateId, dispatchTemplatesId));

            return(item);
        }
            protected override void When()
            {
                TotalResult <List <StoredNotification <long> > > totalResult =
                    SUT.Select(new List <long> {
                    _subscriberId
                }, 0, 10, false).Result;

                _actual = totalResult.Data;
            }
コード例 #9
0
        /// <summary>
        /// Plays the following scenario:
        /// 1. Prepares chance abstractions.
        /// 2. Computes a eq-strategy by EqLp.
        /// 3. Computes a BR on the eq strategies.
        /// 4. Runs a session with 2 instances of Patience, one is playing eq, the other br.
        /// 5. Compares actual game result with the predicted game value.
        /// The test is trying to reuse chance abstractions and merge strategies for different positions
        /// if the abstraction is the same.
        /// <param name="baseDir">The function copies all config files from _testResourceDir/baseDir
        /// to _outDir/baseDir-eq and _outDir/baseDir-br, all intermediate files are also created here.</param>
        /// </summary>
        void PlayEqVsBr(string [] bucketizerStrings, int sessionGamesCount, int sessionRepetitionCount, double relativeTolerance)
        {
            Console.WriteLine("Run eq vs eq for chance abstractions:");
            for (int p = 0; p < bucketizerStrings.Length; ++p)
            {
                Console.WriteLine("pos: {0} bucket string: {1}", p, bucketizerStrings[0]);
            }

            GameDefinition gd = XmlSerializerExt.Deserialize <GameDefinition>(
                Props.Global.Expand("${bds.DataDir}ai.pkr.metastrategy/${0}", "leduc-he.gamedef.xml"));

            string runDir = PrepareRunDir("EqVsBr_Leduc");

            IChanceAbstraction [] chanceAbstractions = PrepareConfigsAndChanceAbstractions(runDir, bucketizerStrings);
            double []             brValues           = new double[gd.MinPlayers];
            SolveGame(runDir, gd, chanceAbstractions, brValues);

            Console.WriteLine("Values of BR strategies:");
            for (int p = 0; p < brValues.Length; ++p)
            {
                Console.WriteLine("pos: {0} val: {1:0.00} mb0/g", p, brValues[p] * 1000);
            }

            // To tell the bots where the configs are:
            Props.Global.Set("dev.TestRunDir", runDir);

            runDir = CopyDirForEachBot(runDir, gd.MinPlayers);
            // Now runDir is eq dir.

            _actualResult = new TotalResult {
                Name = "Actual result"
            };

            string             ssConfigFile = Path.Combine(runDir, "ss.xml");
            SessionSuiteRunner runner       = new SessionSuiteRunner();

            runner.Configuration = XmlSerializerExt.Deserialize <SessionSuiteCfg>(ssConfigFile);
            runner.Configuration.Sessions[0].GamesCount  = sessionGamesCount;
            runner.Configuration.Sessions[0].RepeatCount = sessionRepetitionCount;
            runner.IsLoggingEnabled = false;
            runner.OnGameEnd       += new SessionSuiteRunner.OnGameEndHandler(runner_OnGameEnd);
            runner.Run();

            _actualResult.Print(Console.Out);

            for (int p = 0; p < gd.MinPlayers; ++p)
            {
                double expectedResult = brValues[p] * 1000;
                double actualResult   = _actualResult.Players["Patience-Br"].Rate(p);
                double epsilon        = Math.Abs(expectedResult * relativeTolerance);
                Assert.AreEqual(expectedResult, actualResult, epsilon);
            }

            // We can use the files created in other tests.
            //DeleteBotDirs(runDir);
        }
コード例 #10
0
ファイル: HomeController.cs プロジェクト: DTaylor1986/Test1
        public async Task <ViewResult> Random(IndexViewModel form)
        {
            IndexViewModel model  = new IndexViewModel();
            HttpClient     client = api.Initial();

            //Get Categories
            HttpResponseMessage catResponse = await client.GetAsync("categories");

            catResponse.EnsureSuccessStatusCode();
            string catJson = await catResponse.Content.ReadAsStringAsync();

            CategoryResult catResult = JsonConvert.DeserializeObject <CategoryResult>(catJson);

            model.Categories = catResult.value;

            //Get Number of jokes
            HttpResponseMessage totalResponse = await client.GetAsync("jokes/count");

            totalResponse.EnsureSuccessStatusCode();
            string totalJson = await totalResponse.Content.ReadAsStringAsync();

            TotalResult totalResult = JsonConvert.DeserializeObject <TotalResult>(totalJson);

            ViewBag.Total = totalResult.value;

            //Decide whether to pick by ID or get randoms
            if (form.PickID != 0)
            {
                //Pick by ID
                HttpResponseMessage pickResponse = await client.GetAsync("jokes/" + form.PickID);

                pickResponse.EnsureSuccessStatusCode();
                string pickJson = await pickResponse.Content.ReadAsStringAsync();

                JokeIndv  pickResult = JsonConvert.DeserializeObject <JokeIndv>(pickJson);
                JokeValue value      = pickResult.value;
                model.Jokes.Add(value);
            }
            else
            {
                //Get random Jokes
                if (form.NumJokes == 0)
                {
                    form.NumJokes = 1;
                }
                HttpResponseMessage jokeResponse = await client.GetAsync("jokes/random/" + form.NumJokes);

                jokeResponse.EnsureSuccessStatusCode();
                string jokeJson = await jokeResponse.Content.ReadAsStringAsync();

                JokeResult jokeResult = JsonConvert.DeserializeObject <JokeResult>(jokeJson);
                model.Jokes = jokeResult.value;
            }

            return(View("Index", model));
        }
        public virtual async Task <List <DispatchTemplate <TKey> > > SelectForEventSettings(TKey eventSettingsId)
        {
            TotalResult <List <DispatchTemplate <TKey> > > allItems = await GetFromCacheOrFetch().ConfigureAwait(false);

            List <DispatchTemplate <TKey> > items = allItems.Data.Where(
                x => EqualityComparer <TKey> .Default.Equals(x.EventSettingsId, eventSettingsId))
                                                    .ToList();

            return(items);
        }
コード例 #12
0
        public virtual async Task <EventSettings <TKey> > Select(TKey eventSettingsId)
        {
            TotalResult <List <EventSettings <TKey> > > allItems = await GetFromCacheOrFetch()
                                                                   .ConfigureAwait(false);

            EventSettings <TKey> item = allItems.Data.FirstOrDefault(
                x => EqualityComparer <TKey> .Default.Equals(x.EventSettingsId, eventSettingsId));

            return(item);
        }
コード例 #13
0
        public virtual async Task <List <EventSettings <TKey> > > SelectByKey(int eventKey)
        {
            TotalResult <List <EventSettings <TKey> > > allItems = await GetFromCacheOrFetch()
                                                                   .ConfigureAwait(false);

            List <EventSettings <TKey> > items = allItems.Data
                                                 .Where(x => x.EventKey == eventKey)
                                                 .ToList();

            return(items);
        }
        public virtual async Task <TotalResult <List <DispatchTemplate <TKey> > > > SelectPage(int page, int pageSize)
        {
            TotalResult <List <DispatchTemplate <TKey> > > allItems = await GetFromCacheOrFetch().ConfigureAwait(false);

            int skip = (page - 1) * pageSize;
            List <DispatchTemplate <TKey> > selectedPage = allItems.Data
                                                           .Skip(skip)
                                                           .Take(pageSize)
                                                           .ToList();

            return(new TotalResult <List <DispatchTemplate <TKey> > >(selectedPage, allItems.Total));
        }
コード例 #15
0
        /// <summary>
        /// 0-based page index
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public virtual async Task <TotalResult <List <EventSettings <TKey> > > > Select(int pageIndex, int pageSize)
        {
            TotalResult <List <EventSettings <TKey> > > allItems = await GetFromCacheOrFetch()
                                                                   .ConfigureAwait(false);

            int skip = pageIndex * pageSize;
            List <EventSettings <TKey> > selectedPage = allItems.Data
                                                        .Skip(skip)
                                                        .Take(pageSize)
                                                        .ToList();

            return(new TotalResult <List <EventSettings <TKey> > >(selectedPage, allItems.Total));
        }
コード例 #16
0
        /// <summary>
        /// 先尝试从缓存中加载数据,如果缓存不存在就从文件中加载(并添加到缓存)
        /// </summary>
        /// <param name="id"></param>
        /// <param name="day"></param>
        /// <returns></returns>
        public static TotalResult GetTotalResult(int id, DateTime day)
        {
            string      cacheKey = CreateCacheKey(id, day);
            TotalResult result   = HttpRuntime.Cache[cacheKey] as TotalResult;

            if (result == null)
            {
                result = LoadTotalResult(id, day, false);
                HttpRuntime.Cache[cacheKey] = result;
            }

            return(result);
        }
コード例 #17
0
 static void runner_OnSessionBegin(SessionCfg sessionCfg, int repetition)
 {
     _sessionsCount++;
     _curSessionCfg     = sessionCfg;
     _sessionName       = sessionCfg.Name;
     _sessionGamesCount = 0;
     _sessionRepetition = repetition;
     _sessionGamesTotal = sessionCfg.GetEstimatedGamesCount();
     if (repetition == 0)
     {
         _sessionResult      = new TotalResult();
         _sessionResult.Name = _SESSION_RESULT_NAME;
     }
 }
コード例 #18
0
        //[OutputCache(Duration = 60 * 30, VaryByParam = "id;day;flag;sort", VaryByHeader = "User-Agent")]
        public PageResult ShowScanResult(int id, DateTime day, string flag, string sort, int?page)
        {
            _totalResult = ScanResultCache.GetTotalResult(id, day);
            _branchId    = id;
            _dataFlag    = flag;
            _sortField   = sort;
            _pageIndex   = page;

            switch (flag)
            {
            case "RuntimeScan":
                return(ShowAssemblyScanResult());

            case "DatabaseScan":
                return(ShowDatabaseScanResult());

            case "JsCodeScan":
                return(ShowJsCodeScanResult());

            case "CsCodeScan":
                return(ShowCsCodeScanResult());

            case "ExceptionLog":
                return(ShowExceptionLog());

            case "PerformanceLog":
                return(ShowPerformanceLog());

            case "ProjectScan":
                return(ShowProjectScanResult());

            case "VsRuleScan":
                return(ShowVsRuleScanResult());

            case "UnitTest": {
                SetLogFileUrl(id, day);
                return(ShowUnitTestResult());
            }

            case "CodeCover":
                return(ShowCodeCoverResult());

            case "CommentScan":
                return(ShowCommentScanResult());

            default:
                throw new NotImplementedException();
            }
        }
コード例 #19
0
        internal static void SetIssueCategory(this TotalResult data)
        {
            if (data == null)
            {
                return;
            }

            data.RuntimeScanResults.SetIssueCategory();
            data.DbCheckResults.SetIssueCategory();
            data.JsCodeCheckResults.SetIssueCategory();
            data.CsCodeCheckResults.SetIssueCategory();
            data.ProjectCheckResults.SetIssueCategory();
            data.VsRuleCheckResults.SetIssueCategory();
            data.RuntimeScanResults.SetIssueCategory();
        }
コード例 #20
0
        public void Execute(TaskContext context, TaskAction action)
        {
            if (action.Items == null)
            {
                return;
            }

            TotalResult totalResult = context.TotalResult;
            List <AssemblyScanResult> resultList = new List <AssemblyScanResult>();

            try {
                foreach (string line in action.Items)
                {
                    AssemblyScaner scaner = new AssemblyScaner();

                    TextLineSerializer serializer = new TextLineSerializer();
                    AssemblyScanOption option     = serializer.Deserialize <AssemblyScanOption>(line);
                    if (string.IsNullOrEmpty(option.Bin))
                    {
                        throw new ArgumentException("AssemblyScan任务的参数不正确,没有指定 bin 参数");
                    }

                    if (string.IsNullOrEmpty(option.Sln))
                    {
                        if (context.JobOption.SlnFiles != null && context.JobOption.SlnFiles.Length == 1)
                        {
                            option.Sln = context.JobOption.SlnFiles[0];
                        }
                        else
                        {
                            throw new ArgumentException("AssemblyScan任务的参数不正确,没有指定 sln 参数");
                        }
                    }

                    List <AssemblyScanResult> list = scaner.Execute(context.Branch, option);
                    resultList.AddRange(list);
                }


                totalResult.RuntimeScanResults.AddRange(resultList);

                context.ConsoleWrite("AssemblyScanTask OK");
            }
            catch (Exception ex) {
                totalResult.RuntimeScanException = ex.ToString();
                context.ProcessException(ex);
            }
        }
コード例 #21
0
        public TaskContext(JobOption job, bool enableConsoleOut)
        {
            if (job == null)
            {
                throw new ArgumentNullException(nameof(job));
            }

            _job = job;
            _enableConsoleOut = enableConsoleOut;

            // 每个小组使用一个临时目录
            _tempPath = InitTempDirectory(job.Id);


            // 初始化数据结果对象
            _totalResult = InitTask();
        }
コード例 #22
0
        public void Execute(TaskContext context, TaskAction action)
        {
            string website = ConfigurationManager.AppSettings["ServiceWebsite"];

            if (string.IsNullOrEmpty(website))
            {
                throw new ConfigurationErrorsException("ServiceWebsite没有配置。");
            }

            TotalResult totalResult = context.TotalResult;

            // 按业务单元和扫描类别分组小计
            //CalculateSubTotal(totalResult);
            context.ConsoleWrite("ExecSubTotalResult OK");
            context.ConsoleWrite("\r\n任务结束时间:" + DateTime.Now.ToTimeString());

            // 获取控件台的所有输出内容
            totalResult.ConsoleText = context.OutputText;


            // 为了防止提交的数据过大,所以采用压缩的方式提交数据(大约可压缩10倍),
            string json = totalResult.ToJson();
            string data = CompressHelper.GzipCompress(json);


            HttpOption option = new HttpOption {
                Method = "POST",
                Url    = website.TrimEnd('/') + "/ajax/scan/Upload/UploadResult.ppx",
                Data   = new { base64 = data, branchId = context.Branch.Id }
            };

            option.Headers.Add("authentication-key", ConfigurationManager.AppSettings["authentication-key"]);
            option.Headers.Add("app-version", SpecChecker.CoreLibrary.Config.JobManager.AppVersion);
            string responseText = option.GetResult();

            if (responseText == "200")
            {
                context.ConsoleWrite("UploadResultTask OK");
            }
            else
            {
                context.ConsoleWrite("\r\n上传结果出现异常:##################");
                context.ConsoleWrite(responseText);
            }
        }
コード例 #23
0
        private TotalSummary2 ToSummary2(TotalResult data)
        {
            // 如果工具还没有生成扫描数据,就直接创建一个TotalSummary实例(全部属性为零)
            if (data == null)
            {
                return(new TotalSummary2());
            }


            IEnumerable <BaseScanResult>[] array =
            {
                data.RuntimeScanResults,
                //data.DbCheckResults,
                data.JsCodeCheckResults,
                data.CsCodeCheckResults,
                //data.ProjectCheckResults,
                data.VsRuleCheckResults
            };

            TotalSummary2 summary = new TotalSummary2();

            summary.BuildIsOK   = data.BuildIsOK;
            summary.Security    = GetIssueCount("安全规范", array);
            summary.Performance = GetIssueCount("高性能规范", array);
            summary.Stability   = GetIssueCount("稳定性规范", array);
            summary.Database    = data.DbCheckException == null ? data.DbCheckResults.Count : 0;
            summary.Project     = data.ProjectCheckException == null ? data.ProjectCheckResults.Count : 0;
            summary.ErpRule     = GetIssueCount("ERP特殊规范", array);
            summary.ObjectName  = GetIssueCount("命名规范", array);
            summary.Comment     = GetIssueCount("注释规范", array);
            summary.VsRule      = GetIssueCount("微软托管规则", array);
            summary.Others      = GetIssueCount(IssueCategoryManager.DefaultCategory, array);



            summary.PerformanceLog = data.PerformanceLogException == null ? data.PerformanceInfos.Count : 0;
            summary.ExceptionLog   = data.ExceptionLogException == null ? data.ExceptionInfos.Count : 0;
            summary.UnitTestPassed = data.UnitTestPassed;
            summary.UnitTestTotal  = data.UnitTestTotal;
            summary.CodeCover      = data.CodeCover;


            return(summary);
        }
コード例 #24
0
        public void Execute(TaskContext context, TaskAction action)
        {
            if (action.Items == null || action.Items.Length == 0)
            {
                action.Items = context.JobOption.CodePath;
            }

            if (action.Items == null || action.Items.Length == 0)
            {
                return;
            }

            TotalResult            totalResult = context.TotalResult;
            List <CodeCheckResult> resultList  = new List <CodeCheckResult>();

            try {
                foreach (string path in action.Items)
                {
                    CodeScaner scaner = new CodeScaner();
                    scaner.ExcludePaths = LoadExcludePaths(path);
                    List <CodeCheckResult> list = scaner.Execute(context.Branch, path);
                    resultList.AddRange(list);
                }


                // 过滤前端代码的检查结果
                totalResult.JsCodeCheckResults.AddRange(
                    (from x in resultList
                     where x.FileName.EndsWith(".js", StringComparison.OrdinalIgnoreCase)
                     select x).ToList());

                // 过滤服务端代码的检查结果
                totalResult.CsCodeCheckResults.AddRange(
                    (from x in resultList
                     where x.FileName.EndsWith(".js", StringComparison.OrdinalIgnoreCase) == false
                     select x).ToList());

                context.ConsoleWrite("CodeScanTask OK");
            }
            catch (Exception ex) {
                totalResult.CodeCheckException = ex.ToString();
                context.ProcessException(ex);
            }
        }
        //cache
        protected virtual async Task <TotalResult <List <DispatchTemplate <TKey> > > > GetFromCacheOrFetch()
        {
            if (_cache != null &&
                (_changeNotifier == null || _changeNotifier.HasUpdates == false))
            {
                return(_cache);
            }

            TotalResult <List <DispatchTemplate <TKey> > > allItems = await _storageQueries.SelectPage(0, int.MaxValue)
                                                                      .ConfigureAwait(false);

            _cache = allItems;
            if (_changeNotifier != null)
            {
                _changeNotifier.StartMonitor();
            }

            return(allItems);
        }
コード例 #26
0
        public IActionResult ShowPerformanceLog(int id, DateTime day, Guid g, int?xml)
        {
            TotalResult     totalResult = ScanResultCache.GetTotalResult(id, day);
            PerformanceInfo info        = totalResult.PerformanceInfos.FirstOrDefault(x => x.InfoGuid == g);

            if (info == null)
            {
                return(new TextResult("parameters is invaild."));
            }

            if (xml.HasValue && xml.Value == 1)
            {
                return(new XmlResult(info));
            }
            else
            {
                return(PageResult("/CodeScan/Partial/PerformanceDetail.cshtml", info));
            }
        }
コード例 #27
0
        public void Execute(TaskContext context, TaskAction action)
        {
            if (string.IsNullOrEmpty(context.Branch.MongoLocation))
            {
                return;
            }


            TotalResult totalResult = context.TotalResult;

            try {
                ExceptionLogScaner scaner = new ExceptionLogScaner();
                bool isMongoDb            = context.Branch.MongoLocation.StartsWith("mongodb", StringComparison.OrdinalIgnoreCase);

                DateTime start, end;
                if (DateTime.Now.Hour < 12)
                {
                    // 有些产品组只在凌晨运行扫描工具,会导致当天的数据几乎是零,
                    // 所以,这里的规则是:如果在 12点前运行工具,就取前一天的数据
                    start = DateTime.Today.AddDays(-1);
                    end   = DateTime.Today;
                }
                else
                {
                    start = DateTime.Today;
                    end   = DateTime.Today.AddDays(1d);
                }

                List <ExceptionInfo> list = isMongoDb
                                                        ? scaner.Execute(start, end, context.Branch.MongoLocation)
                                                        : scaner.Execute2(start, end, context.Branch.MongoLocation);


                totalResult.ExceptionInfos = list;
                context.ConsoleWrite("ExceptionLogTask OK");
            }
            catch (Exception ex) {
                totalResult.ExceptionLogException = ex.ToString();
                context.ProcessException(ex);
            }
        }
コード例 #28
0
        public IActionResult DailyReport(int id, DateTime day)
        {
            BranchSettings branch = JobManager.GetBranch(id);

            if (branch == null)
            {
                return(new TextResult("id is invaild."));
            }

            if (day > DateTime.Today)
            {
                return(new TextResult("day is invaild."));
            }


            DateTime             today = day.Date;
            DailyReportViewModel model = new DailyReportViewModel();

            model.Today    = today.ToDateString();
            model.DayMonth = today.Day.ToString() + "/" + today.Month.ToString();             //today.ToString("d/M");
            model.Branch   = branch;

            // 加载工具扫描的结果
            TotalResult totalResult = null;

            try {
                totalResult = ScanResultCache.GetTotalResult(id, day);
            }
            catch (FileNotFoundException) {
                return(new TextResult("找不到匹配的数据文件。"));
            }
            model.ComplieMessage = totalResult.CompilerError;
            model.TotalResult    = totalResult;

            // 注意:注释问题不是单独扫描出来的,
            // 是由于大家觉得这类问题的修复优先级可以降低点,所以就从【代码扫描结果】中提取
            // 提取之后,还要从【代码扫描结果】去掉那部分数据
            totalResult.EvalCommentScanResultCount();

            return(PageResult("/CodeScan/DailyReport.cshtml", model));
        }
コード例 #29
0
        public TotalResult GetShoppingCartDetails(ShoppingCart shoppingCart)
        {
            var totalResult = new TotalResult
            {
                SelectedProducts = shoppingCart.CartProducts
            };

            foreach (var product in shoppingCart.CartProducts)
            {
                totalResult.TotalPrice += product.Price;
            }

            //apply rebate of 10% if total exceeds 20M
            if (totalResult.TotalPrice > 20M)
            {
                totalResult.RebateValue     = totalResult.TotalPrice * 0.1M;
                totalResult.DiscountedPrice = totalResult.TotalPrice - totalResult.RebateValue;
            }

            return(totalResult);
        }
コード例 #30
0
        private TotalResult InitTask()
        {
            // 创建测试结果实例
            TotalResult totalResult = new TotalResult();

            totalResult.Today   = DateTime.Today.ToDateString();
            totalResult.Branch  = _job.Branch;
            totalResult.Version = "3.0";


            //// 初始一些集合便于后续操作
            //totalResult.RuntimeScanResults = new List<AssemblyScanResult>();
            //totalResult.DbCheckResults = new List<DbCheckResult>();
            //totalResult.CsCodeCheckResults = new List<CodeCheckResult>();
            //totalResult.JsCodeCheckResults = new List<CodeCheckResult>();
            //totalResult.ProjectCheckResults = new List<ProjectCheckResult>();
            //totalResult.VsRuleCheckResults = new List<VsRuleCheckResult>();
            //totalResult.PerformanceInfos = new List<PerformanceInfo>();
            //totalResult.ExceptionInfos = new List<ExceptionInfo>();
            //totalResult.UnitTestResults = new List<UnitTest.UnitTestResult>();
            //totalResult.CodeCoverResults = new List<UnitTest.UnitTestResult>();
            return(totalResult);
        }