private void ShowScanData(ref CxWSQueryVulnerabilityData[] scanData, ref long scanId, CxWebServiceClient client) { // Get url to scanned project result string savedFileName = string.Format("report{0}", Guid.NewGuid()); long id = 0; CxWSResponseScanStatus scanStatus = client.ServiceClient.GetStatusOfSingleScan(_scan.LoginResult.SessionId, _scan.RunScanResult.ScanId); string ScanTaskId = scanStatus.ScanId.ToString();//after scan is finished the server replaces the scan id with task scan id scanData = PerspectiveHelper.GetScanResultsPaths(ScanTaskId, ref scanId); id = scanId; LoginData.BindProject bindProject = _scan.LoginResult.AuthenticationData.BindedProjects.Find(project => project.BindedProjectId == CommonData.ProjectId && project.ProjectName == CommonData.ProjectName && project.RootPath == CommonData.ProjectRootPath); if (bindProject == null) // scaned for the first time { bindProject = new LoginData.BindProject(); bindProject.ProjectName = CommonData.ProjectName; bindProject.RootPath = CommonData.ProjectRootPath; bindProject.IsBound = true; _scan.LoginResult.AuthenticationData.BindedProjects.Add(bindProject); } if (!CommonData.IsProjectBound) // its new project { bindProject.BindedProjectId = scanStatus.ProjectId; CommonData.ProjectId = scanStatus.ProjectId; CommonData.IsProjectPublic = scanStatus.IsPublic; bindProject.IsPublic = scanStatus.IsPublic; bindProject.IsBound = true; } bindProject.SelectedScanId = id; bindProject.ScanReports = new List <ScanReportInfo>(); LoginHelper.Save(_scan.LoginResult.AuthenticationData); BackgroundWorkerHelper bgWork = new BackgroundWorkerHelper(delegate { CommonData.SelectedScanId = id; String path = PerspectiveHelper.GetScanXML(id); ScanReportInfo scanReportInfo = new ScanReportInfo(); scanReportInfo.Path = path; scanReportInfo.Id = id; LoginData.BindProject projectToUpdate = _scan.LoginResult.AuthenticationData.BindedProjects.Find(delegate(LoginData.BindProject bp) { return(bp.BindedProjectId == CommonData.ProjectId); } ); projectToUpdate.ScanReports = new List <ScanReportInfo>(); projectToUpdate.ScanReports.Add(scanReportInfo); LoginHelper.Save(_scan.LoginResult.AuthenticationData); }); bgWork.DoWork(); }
/// <summary> /// Execute 'Previous Result' command /// </summary> public static void DoPrevResult() { Logger.Create().Debug("DoPrevResult in"); // Get logged user credentials and project relation data LoginData login = Helpers.LoginHelper.Load(0); CxWSQueryVulnerabilityData[] perspective = null; login.IsOpenPerspective = Entities.Enum.SimpleDecision.Yes; LoginData.BindProject bindProject = login.BindedProjects.Find(delegate(LoginData.BindProject bp) { return(bp.BindedProjectId == CommonData.ProjectId && bp.ProjectName == CommonData.ProjectName && bp.RootPath == CommonData.ProjectRootPath); } ); if (bindProject != null && bindProject.ScanReports != null && bindProject.ScanReports.Count > 0) { ScanReportInfo tmp = bindProject.ScanReports.Find(delegate(ScanReportInfo sri) { return(sri.Id == CommonData.SelectedScanId); } ); if (tmp == null || tmp.Id == 0) { tmp = bindProject.ScanReports[0]; CommonData.SelectedScanId = tmp.Id; } perspective = GetScanResultsPath(tmp.Id); bindProject.SelectedScanId = tmp.Id; if (!string.IsNullOrEmpty(tmp.Path)) { StorageHelper.Delete(tmp.Path); } BackgroundWorkerHelper bgWork = new BackgroundWorkerHelper(delegate { tmp.Path = PerspectiveHelper.GetScanXML(CommonData.SelectedScanId); LoginHelper.Save(login); }); bgWork.DoWork(); Dictionary <string, long> list = new Dictionary <string, long>(); foreach (ScanReportInfo item in bindProject.ScanReports) { if (!list.ContainsKey(item.Name)) { list.Add(item.Name, item.Id); } } CommonActionsInstance.getInstance().ReportPersepectiveView.SetScanList(list, tmp.Id); if (perspective != null) { ShowStored(perspective, login, tmp.Id); } } }