public BranchGroupController(IPermissionService permissionService, IBranchService branchService, ILanguageService languageService, ILocalizationService localizationService, IStoreMappingService storeMappingService, ILocalizedEntityService localizedEntityService, IStoreService storeService, IPictureService pictureService, IUrlRecordService urlRecordService, ICustomerActivityService customerActivityService, IWorkContext workContext, ICacheManager cacheManager, BranchSettings branchSettings, IWebHelper webHelper) { _permissionService = permissionService; _branchService = branchService; _languageService = languageService; _localizationService = localizationService; _storeMappingService = storeMappingService; _localizedEntityService = localizedEntityService; _storeService = storeService; _pictureService = pictureService; _urlRecordService = urlRecordService; _customerActivityService = customerActivityService; _workContext = workContext; _cacheManager = cacheManager; _branchSettings = branchSettings; _webHelper = webHelper; }
private static IServiceProvider Setup(Options options, Repository repo) { IServiceCollection services = new ServiceCollection(); DiagnosticLogger logger = new(options.WarningsAsErrors); IBranchSettings branchSettings = new BranchSettings(releaseSuffix: options.ReleaseSuffix, package: options.Package); services.AddSingleton <ILogger>(logger); services.AddSingleton <IDiagnosticLogger>(logger); services.AddSingleton(typeof(ILogger <>), typeof(LoggerProxy <>)); services.AddSingleton(branchSettings); services.AddSingleton(repo); services.AddSingleton <IBranchDiscovery, GitBranchDiscovery>(); services.AddSingleton <IBranchClassification, BranchClassification>(); services.AddSingleton <IVersionPublisher, GitHubActionsVersionPublisher>(); services.AddSingleton <IVersionPublisher, TeamCityVersionPublisher>(); services.AddSingleton <IVersionDetector, VersionDetector>(); services.AddSingleton <IExternalBranchLocator, GitHubRefEnvironmentVariableBranchLocator>(); services.AddSingleton <IExternalBranchLocator, GitBranchEnvironmentVariableBranchLocator>(); IServiceProviderFactory <IServiceCollection> spf = new DefaultServiceProviderFactory(); return(spf.CreateServiceProvider(services)); }
public List <DbCheckResult> Execute(BranchSettings branch) { string connectionString = branch.DbLocation; List <DbCheckResult> list = new List <DbCheckResult>(128); using (ConnectionScope scope = ConnectionScope.Create(connectionString, "System.Data.SqlClient")) { list.AddRange(CheckPrimaryKey()); list.AddRange(TheSimilarIndexes()); list.AddRange(TextFieldWrongType()); list.AddRange(CanNotUseTrigger()); list.AddRange(CanNotUseCLRSP()); list.AddRange(CheckEnumTextField()); list.AddRange(CheckStoreProcedure()); list.AddRange(CheckUserFunction()); } list = list.ExecExcludeIgnoreRules(branch); if (string.IsNullOrEmpty(branch.IgnoreDbObjects) == false) { string[] names = branch.IgnoreDbObjects.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); list = (from x in list where names.FirstOrDefault(n => x.ObjectName.Equals(n, StringComparison.OrdinalIgnoreCase)) == null select x).ToList(); } return(list); }
public BranchReadController(IBranchService branchService, IPictureService pictureService, BranchSettings branchSettings) { _branchService = branchService; _pictureService = pictureService; _branchSettings = branchSettings; }
public AdminConfigurationModel GetHotelAdminConfigurationDetail(int branchID, int settingID) { BranchSettings result = entity.BranchSettings.Where(x => x.SettingId == settingID && x.BranchID == branchID).FirstOrDefault(); AdminConfigurationModel model = new AdminConfigurationModel(); model.HotelSettingID = (int)result.SettingId; model.HotelByPass = result != null ? ByPass.HotelAllow : ByPass.MobileAllow; return(model); }
public void AdminConfigurationEdit(AdminConfigurationModel model) { BranchSettings result = entity.BranchSettings.Where(x => x.SettingId == model.SettingID && x.BranchID == model.BranchOfficeID).FirstOrDefault(); if (model.ByPass == ByPass.Disallow) { entity.DeleteObject(result); entity.SaveChanges(); } }
public void AdminBusConfigurationAdd(AdminConfigurationModel model) { if (model.BusByPass == ByPass.BusAllow) { BranchSettings datamodel = new BranchSettings { BranchID = model.BranchOfficeID, SettingId = model.BusSettingID }; entity.AddToBranchSettings(datamodel); entity.SaveChanges(); } }
public static List <T> ExecExcludeIgnoreRules <T>(this List <T> list, BranchSettings branch) where T : BaseScanResult { if (string.IsNullOrEmpty(branch.IgnoreRules) == false) { // 存在排除规则 string[] rules = branch.IgnoreRules.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); return((from x in list where rules.FirstOrDefault(r => r == x.RuleCode) == null select x ).ToList()); } return(list); }
public List <AssemblyScanResult> Execute(BranchSettings branch, AssemblyScanOption option) { AppDomain domain = AppDomain.CreateDomain("AssemblyScan_Domain"); try { ScanerProxy server = (ScanerProxy)domain.CreateInstanceAndUnwrap( typeof(ScanerProxy).Assembly.FullName, typeof(ScanerProxy).FullName); return(server.Execute(branch, option)); } finally { if (domain != null) { AppDomain.Unload(domain); } } }
public async Task <IReadOnlyCollection <PackageUpdateSet> > SelectTargets( ForkData pushFork, IReadOnlyCollection <PackageUpdateSet> potentialUpdates, FilterSettings filterSettings, BranchSettings branchSettings) { var sorted = _sort.Sort(potentialUpdates) .ToList(); var filtered = await _updateSelection.Filter( sorted, filterSettings, p => _existingBranchFilter.CanMakeBranchFor(p, pushFork, branchSettings.BranchNamePrefix)); foreach (var updateSet in filtered) { _logger.Normal($"Selected package update of {updateSet.SelectedId} to {updateSet.SelectedVersion}"); } return(filtered); }
public List <CodeCheckResult> Execute(BranchSettings branch, string srcPath) { // 扫描所有文件 ScanAllFiles(srcPath); // 设置规范编号 foreach (CodeCheckResult result in _list) { // 早期没有这个属性,后来为了简单就统一在这里填充属性 if (string.IsNullOrEmpty(result.RuleCode)) { result.RuleCode = result.GetRuleCode(); } } // 排除一些误报的结果 CheckExcludeRule(srcPath); // 过滤有效的结果 _list = (from x in _list where x.Reason != null && // Reason = null ,表示需要排除的结果 s_excludeFlag.IsMatch(x.LineText) == false // 允许代码行中包含排除标记 select x).ToList(); // 排除指定要忽略的规则 _list = _list.ExecExcludeIgnoreRules(branch); // 整理文件名,去掉根目录,变成相对目录的短名 int rootLen = srcPath.Length; foreach (CodeCheckResult result in _list) { result.FileName = result.FileName.Substring(rootLen + 1); } return(_list); }
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)); }
/// <summary> /// 扫描DLL是否符合规范 /// </summary> /// <param name="branch"></param> /// <param name="option">解决方案文件名和BIN目录名</param> /// <returns></returns> public List <AssemblyScanResult> Execute(BranchSettings branch, AssemblyScanOption option) { List <Assembly> assemblies = LoadAssemblies(option); if (assemblies.Count == 0) { throw new InvalidOperationException("编译出错,没有产生程序集!"); } // 加载自定义的规则程序集 LoadCustomizeCheckerAssembly(option.Bin); // 加载工具内置的检查规则 _asmCheckers = GetCheckers <IAssemblyCheck>(); _typeCheckers = GetCheckers <ITypeCheck>(); _methodCheckers = GetCheckers <IMethodCheck>(); // 扫描所有指定的程序集 List <AssemblyScanResult> list = Scan(assemblies); // 过滤一些可忽略的规则 return(list.ExecExcludeIgnoreRules(branch)); }
public List <ProjectCheckResult> Execute(BranchSettings branch, string slnFilePath) { string slnPath = Path.GetDirectoryName(slnFilePath); List <ProjectCheckResult> result = new List <ProjectCheckResult>(); //string[] files = Directory.GetFiles(slnPath, "*.csproj", SearchOption.AllDirectories); List <string> files = SlnFileHelper.GetProjectFiles(slnFilePath); foreach (string filePath in files) { // 忽略WEB项目 if (filePath.IndexOf(".Web", StringComparison.OrdinalIgnoreCase) > 0) { continue; } // 忽略测试项目 if (filePath.IndexOf("Test", StringComparison.OrdinalIgnoreCase) > 0) { continue; } Project project = SlnFileHelper.ParseCsprojFile(filePath); // 判断项目是不是【纯类库】项目 bool isLibrary = project.IsLibrary() && project.IsWebApplication() == false; foreach (var group in project.Groups) { if (string.IsNullOrEmpty(group.Condition)) { continue; } Match match = Regex.Match(group.Condition, @"'(Debug|Release)\|AnyCPU'", RegexOptions.IgnoreCase); if (match.Success == false) { continue; } string configuration = match.Groups[1].Value; if (string.IsNullOrEmpty(group.OutputPath) || group.OutputPath.TrimEnd('\\').Equals("bin", StringComparison.OrdinalIgnoreCase) == false) { result.Add(new ProjectCheckResult { ProjectName = filePath.Substring(slnPath.Length + 1), Configuration = configuration, Reason = "SPEC:P00001; 请将项目的【输出路径】设置为【bin】" }); } if (isLibrary && string.IsNullOrEmpty(group.DocumentationFile)) { result.Add(new ProjectCheckResult { ProjectName = filePath.Substring(slnPath.Length + 1), Configuration = configuration, Reason = "SPEC:P00002; 请将【XML文档文件】设置为选中状态" }); } if (string.IsNullOrEmpty(group.TreatWarningsAsErrors)) { result.Add(new ProjectCheckResult { ProjectName = filePath.Substring(slnPath.Length + 1), Configuration = configuration, Reason = "SPEC:P00003; 请将【警告视为错误】设置为【全部】" }); } } } foreach (var x in result) { x.RuleCode = x.GetRuleCode(); } return(result); }
public List <VsRuleCheckResult> Execute(BranchSettings branch, string slnFilePath) { string slnPath = Path.GetDirectoryName(slnFilePath); //string[] files = Directory.GetFiles(slnPath, "*.CodeAnalysisLog.xml", SearchOption.AllDirectories); List <string> files = GetCodeAnalysisLogFiles(slnFilePath); List <VsRuleCheckResult> list = new List <VsRuleCheckResult>(); List <Rule> rules = new List <Rule>(); foreach (string file in files) { if (File.Exists(file) == false) { continue; } FxCopReport report = XmlHelper.XmlDeserializeFromFile <FxCopReport>(file); if (report.Rules != null) { rules.AddRange(report.Rules); } if (report.Targets != null) { foreach (Target target in report.Targets) { foreach (Module module in target.Modules) { foreach (Namespace ns in module.Namespaces) { foreach (var t in ns.Types) { if (t.Messages != null) { foreach (Message message in t.Messages) { foreach (Issue issue in message.Issues) { //if( issue.Path != null && issue.File != null ) list.Add(new VsRuleCheckResult { CheckId = message.CheckId, Url = rules.First(x => x.CheckId == message.CheckId).Url, Message = issue.Message, File = (issue.Path == null || issue.File == null) ? t.Name : Path.Combine(issue.Path, issue.File).Substring(slnPath.Length + 1), Line = issue.Line }); } } } foreach (Member member in t.Members) { if (member.Accessors != null) { foreach (Accessor a in member.Accessors) { foreach (Message message in a.Messages) { foreach (Issue issue in message.Issues) { //if( issue.Path != null && issue.File != null ) list.Add(new VsRuleCheckResult { CheckId = message.CheckId, Url = rules.First(x => x.CheckId == message.CheckId).Url, Message = issue.Message, File = (issue.Path == null || issue.File == null) ? a.Name : Path.Combine(issue.Path, issue.File).Substring(slnPath.Length + 1), Line = issue.Line }); } } } } if (member.Messages != null) { foreach (Message message in member.Messages) { foreach (Issue issue in message.Issues) { //if( issue.Path != null && issue.File != null ) list.Add(new VsRuleCheckResult { CheckId = message.CheckId, Url = rules.First(x => x.CheckId == message.CheckId).Url, Message = issue.Message, File = (issue.Path == null || issue.File == null) ? (ns.Name + "." + t.Name) : Path.Combine(issue.Path, issue.File).Substring(slnPath.Length + 1), Line = issue.Line }); } } } } } } } } } } foreach (var result in list) { result.RuleCode = result.GetRuleCode(); } // 排除这条规则,因为它基本上是误报! list = (from x in list where x.CheckId != "CA2202" select x ).ToList(); return(list); }
public SlnUnitTestResult Execute(BranchSettings branch, string slnFilePath) { if (File.Exists(slnFilePath) == false) { throw new FileNotFoundException("指定的文件不存在:" + slnFilePath); } _slnFilePath = slnFilePath; _branch = branch; if (string.IsNullOrEmpty(s_nunitPath) || string.IsNullOrEmpty(s_dotCoverPath)) { _context.ConsoleWrite("NUnit or ReSharper dotCover NOT INSTALL"); return(null); } //在 sln 文件中,类型项目,单元测试项目,WebApplication项目的GUID类型是一样,没法区开,所以就用名字来识别了。 string[] projectFiles = SlnFileHelper.GetProjectFiles(slnFilePath) .Where(x => x.EndsWithIgnoreCase(".UnitTest.csproj")).ToArray(); List <UnitTestWorker> threads = new List <UnitTestWorker>(); foreach (string file in projectFiles) { UnitTestWorker worker = new UnitTestWorker(_context, s_nunitPath, s_dotCoverPath, file); threads.Add(worker); // 运行每个单元测试项目 worker.Execute(); } // 等待所有线程执行 foreach (UnitTestWorker worker in threads) { worker.Wait(); if (worker.Output.Length > 0) { _context.ConsoleWrite(worker.Output.ToString()); } if (worker.Result != null) { _unitTestResults.Add(worker.Result); } } //汇总统计单元测试代码覆盖率 string mergeFile = MergedSnapshots(projectFiles); string reportFile = CreateCoverReport(mergeFile); EvalCodeCover(reportFile); SlnUnitTestResult total = new SlnUnitTestResult(); total.UnitTestResults = _unitTestResults; total.CodeCoverResults = _codeCoverResults; return(total); }
public ActionResult Settings(FormCollection form, BranchSettings branchSettings) { return(View()); }