public override void PrepareCollectionOfObjects(IEnumerable <ObjectType> allItemsToCollect, VariablesEvaluated variables) { base.PrepareCollectionOfObjects(allItemsToCollect, variables); if (allItemsToCollect.Count() > 0) { var variableEvaluator = new VariableEntityEvaluator(variables); var allSapObjects = allItemsToCollect.OfType <sapcode_object>().ToList(); var issues = allSapObjects.SelectMany(x => variableEvaluator.EvaluateVariableForEntity(((EntitySimpleBaseType)(x.Items[x.ItemsElementName.ToList().IndexOf(SapCodeObjectItemsChoices.issue)])))).Distinct(); var systemNames = allSapObjects.SelectMany(x => variableEvaluator.EvaluateVariableForEntity(((EntitySimpleBaseType)x.Items[x.ItemsElementName.ToList().IndexOf(SapCodeObjectItemsChoices.system_name)]))).Distinct(); var systemIds = systemNames.Select(x => Convert.ToInt32(x)); if (systemIds.Count() > 1) { throw new NotSupportedException("Only concurrent collections of a single system is supported!"); } ExecutionLogBuilder.AddInfo(string.Format("Authenticating at code control with user '{0}'.", AuthUser)); var authResult = connectionProvider.authenticate(AuthUser, AuthPassword); if (authResult.error) { ExecutionLogBuilder.AnErrorOccurred(string.Format("Error authenticating at code control : {0}.", authResult.errorMessage)); } else { ExecutionLogBuilder.AddInfo(string.Format("Successfully authenticated.", AuthUser)); int nSystem = systemIds.Single(); var allIssues = issues.Select(x => (long)Convert.ToInt32(x)).ToArray(); ExecutionLogBuilder.AddInfo( string.Format("Starting scan request for system {0} and issues '{1}'.", nSystem, string.Join(",", allIssues))); issueResult = connectionProvider.scanIssueListBySystem(authResult.token, nSystem, allIssues); var scanCriteria = new ScanCriteriaDTO() { scanIdList = new[] { issueResult.scanId ?? 0 } }; var waitTime = 0L; //const int timeOut = 3600000; // 1 hour //const int timeOut = 10800000; // 3 hs const int timeOut = 18000000; while (((issueResult.status == "AWAITING") || (issueResult.status == "PROCESSING")) && (waitTime <= timeOut) ) { Thread.Sleep(40000); issueResult = connectionProvider.findScan(authResult.token, scanCriteria).FirstOrDefault(); // Wait time is desconsidering remote call duration, // should be done with a stop watch waitTime += 40000; } } } }
public override void PrepareCollectionOfObjects(IEnumerable<ObjectType> allItemsToCollect, VariablesEvaluated variables) { base.PrepareCollectionOfObjects(allItemsToCollect, variables); if (allItemsToCollect.Count() > 0) { var variableEvaluator = new VariableEntityEvaluator(variables); var allSapObjects = allItemsToCollect.OfType<sapcode_object>().ToList(); var issues = allSapObjects.SelectMany(x => variableEvaluator.EvaluateVariableForEntity(((EntitySimpleBaseType)(x.Items[x.ItemsElementName.ToList().IndexOf(SapCodeObjectItemsChoices.issue)])))).Distinct(); var systemNames = allSapObjects.SelectMany(x => variableEvaluator.EvaluateVariableForEntity(((EntitySimpleBaseType)x.Items[x.ItemsElementName.ToList().IndexOf(SapCodeObjectItemsChoices.system_name)]))).Distinct(); var systemIds = systemNames.Select(x => Convert.ToInt32(x)); if (systemIds.Count() > 1) throw new NotSupportedException("Only concurrent collections of a single system is supported!"); ExecutionLogBuilder.AddInfo(string.Format("Authenticating at code control with user '{0}'.", AuthUser)); var authResult = connectionProvider.authenticate(AuthUser, AuthPassword); if (authResult.error) { ExecutionLogBuilder.AnErrorOccurred(string.Format("Error authenticating at code control : {0}.", authResult.errorMessage)); } else { ExecutionLogBuilder.AddInfo(string.Format("Successfully authenticated.", AuthUser)); int nSystem = systemIds.Single(); var allIssues = issues.Select(x => (long)Convert.ToInt32(x)).ToArray(); ExecutionLogBuilder.AddInfo( string.Format("Starting scan request for system {0} and issues '{1}'.", nSystem, string.Join(",", allIssues))); issueResult = connectionProvider.scanIssueListBySystem(authResult.token, nSystem,allIssues); var scanCriteria = new ScanCriteriaDTO() {scanIdList = new[] {issueResult.scanId ?? 0}}; var waitTime = 0L; //const int timeOut = 3600000; // 1 hour //const int timeOut = 10800000; // 3 hs const int timeOut = 18000000; while (((issueResult.status == "AWAITING") || (issueResult.status == "PROCESSING")) && (waitTime <= timeOut) ) { Thread.Sleep(40000); issueResult = connectionProvider.findScan(authResult.token, scanCriteria).FirstOrDefault(); // Wait time is desconsidering remote call duration, // should be done with a stop watch waitTime += 40000; } } } }