/// <summary> /// This function loads up the ozasmtSource file and adds its stats to a new finding called savedCreatedOzasmtAs /// which will have the fingdings in o2AssessmentTarget /// </summary> /// <param name="ozasmtSource"></param> /// <param name="o2AssessmentTarget"></param> /// <param name="savedCreatedOzasmtAs"></param> public bool addAssessmentStatsFromSourceToO2AssessmentAndSaveIt(string ozasmtSource, IO2Assessment o2AssessmentTarget, string savedCreatedOzasmtAs) { AssessmentRun assessmentRunToImport = OzasmtUtils_OunceV6.LoadAssessmentRun(ozasmtSource); var targetAssessmentRun = createAssessmentRunObject(o2AssessmentTarget); // map assessmentRunToImport to targetAssessmentRun // add targetAssessmentRun top level data targetAssessmentRun.AssessmentStats = assessmentRunToImport.AssessmentStats; targetAssessmentRun.AssessmentConfig = assessmentRunToImport.AssessmentConfig; targetAssessmentRun.Messages = assessmentRunToImport.Messages; // add Assessment data targetAssessmentRun.Assessment.assessee_name = assessmentRunToImport.Assessment.assessee_name; targetAssessmentRun.Assessment.AssessmentStats = assessmentRunToImport.AssessmentStats; targetAssessmentRun.Assessment.owner_name = assessmentRunToImport.Assessment.owner_name; targetAssessmentRun.Assessment.owner_type = assessmentRunToImport.Assessment.owner_type; // add project and file data //create backup of current findings var currentAssessmentDataBackup = targetAssessmentRun.Assessment.Assessment[0]; // there should only be one // assign current Assessment array to assessmentRunToImport.Assessment.Assessment targetAssessmentRun.Assessment.Assessment = assessmentRunToImport.Assessment.Assessment; // remove all findings references (since what we want is the stats foreach (var assessment in targetAssessmentRun.Assessment.Assessment) { if (assessment.AssessmentFile != null) { foreach (var assessmentFile in assessment.AssessmentFile) { assessmentFile.Finding = null; } } } // apppend the currentAssessmentDataBackup to the current Assessment Array var assessments = new List <Assessment>(targetAssessmentRun.Assessment.Assessment); assessments.Add(currentAssessmentDataBackup); targetAssessmentRun.Assessment.Assessment = assessments.ToArray(); //targetAssessmentRun.name = "AAAA"; // save it return(OzasmtUtils_OunceV6.SaveAssessmentRun(assessmentRun, savedCreatedOzasmtAs)); }
public bool save(string assessmentName, IEnumerable <IO2Finding> o2Findings, string sPathToSaveAssessment) { createAssessmentRunObject(assessmentName, o2Findings); return(OzasmtUtils_OunceV6.SaveAssessmentRun(assessmentRun, sPathToSaveAssessment)); }