/// <summary> /// The main logic for invoking a transformation. It does not return until a sweep /// for new scans is performed across all projects. /// </summary> /// <param name="concurrentThreads">The number of concurrent scan transformation threads.</param> /// <param name="previousStatePath">A folder path where files will be created to store any state /// data required to resume operations across program runs.</param> /// <param name="ctx"></param> /// <param name="outFactory">The factory implementation for making IOutput instances /// used for outputting various record types.</param> /// <param name="records">The names of the supported record types that will be used by /// the IOutputFactory to create the correct output implementation instance.</param> /// <param name="token">A cancellation token that can be used to stop processing of data if /// the task needs to be interrupted.</param> public static void DoTransform(int concurrentThreads, String previousStatePath, String instanceId, CxRestContext ctx, IOutputFactory outFactory, RecordNames records, CancellationToken token) { try { Transformer xform = new Transformer(ctx, token, previousStatePath) { ThreadOpts = new ParallelOptions() { CancellationToken = token, MaxDegreeOfParallelism = concurrentThreads }, ProjectInfoOut = outFactory.newInstance(records.ProjectInfo), SastScanSummaryOut = outFactory.newInstance(records.SASTScanSummary), SastScanDetailOut = outFactory.newInstance(records.SASTScanDetail), PolicyViolationDetailOut = outFactory.newInstance(records.PolicyViolations), ScaScanSummaryOut = outFactory.newInstance(records.SCAScanSummary), ScaScanDetailOut = outFactory.newInstance(records.SCAScanDetail), InstanceId = instanceId }; xform.ExecuteSweep(); } catch (Exception ex) { _log.Error("Unhandled exception caught.", ex); } }
private void InitOutputMappings(IOutputFactory outFactory) { var outmap = CxAnalytix.Configuration.Config.GetConfig <CxAuditTrailRecordNameMap>(CxAuditTrailRecordNameMap.SECTION_NAME); var fields = typeof(CxAuditTrailTableNameConsts).GetFields(); Dictionary <String, FieldInfo> fieldLookup = new Dictionary <string, FieldInfo>(); foreach (var f in fields) { fieldLookup.Add(f.Name, f); } foreach (var prop in typeof(CxAuditTrailRecordNameMap).GetProperties()) { if (fieldLookup.ContainsKey(prop.Name)) { _outMappings.Add(fieldLookup[prop.Name].Name, outFactory.newInstance(GetPropertyValue <CxAuditTrailRecordNameMap, String>(prop.Name, outmap))); } } }