public void ProcessAssessment(int assessmentID, MemoryStream stream) { DataTable dt = BuildAssessment(assessmentID); // Create an Excel document from the data that has been gathered var doc = new CSETtoExcelDocument(); doc.AddDataTable(dt); List <DataMap> list = new List <DataMap>(); doc.WriteExcelFile(stream, list); }
/// <summary> /// /// </summary> /// <param name="userID"></param> /// <param name="stream"></param> public void ProcessAllAssessmentsForUser(int userID, MemoryStream stream) { DataTable dtAll = null; var sm = new StandardsManager(); // get all the assessment IDs that this user has access to var myAssessmentIDs = db.ASSESSMENT_CONTACTS.Where(x => x.UserId == userID).Select(y => y.Assessment_Id).ToList(); foreach (int assessmentID in myAssessmentIDs) { // ignore assessments that don't have the ACET standard if (!sm.GetACET(assessmentID)) { continue; } // get the values as a DataTable DataTable dt = BuildAssessment(assessmentID); // append the row into dtAll ..... if (dtAll == null) { dtAll = dt.Copy(); } else { if (dt.Rows.Count > 0) { dtAll.LoadDataRow(dt.Rows[0].ItemArray, true); } } } // Create an Excel document from the data that has been gathered var doc = new CSETtoExcelDocument(); doc.AddDataTable(dtAll); List <DataMap> list = new List <DataMap>(); doc.WriteExcelFile(stream, list); }
/// <summary> /// /// </summary> /// <param name="userID"></param> /// <param name="stream"></param> public void ProcessDiagram(int assessmentId, MemoryStream stream) { DataTable dtComponents = BuildDiagramComponents(assessmentId); DataTable dtZones = BuildDiagramZones(assessmentId); DataTable dtLinks = BuildDiagramLinks(assessmentId); DataTable dtShapes = BuildDiagramShapes(assessmentId); DataTable dtTexts = BuildDiagramText(assessmentId); // Create an Excel document from the data that has been gathered var doc = new CSETtoExcelDocument(); doc.AddDataTable(dtComponents); doc.AddDataTable(dtZones); doc.AddDataTable(dtLinks); doc.AddDataTable(dtShapes); doc.AddDataTable(dtTexts); List <DataMap> list = new List <DataMap>(); doc.WriteExcelFile(stream, list); }
/// <summary> /// /// </summary> /// <param name="stream"></param> public void processTables(MemoryStream stream) { CSETtoExcelDocument doc = new CSETtoExcelDocument(); IEnumerable <QuestionExport> list; List <ANSWER> answers = assessmentEntity.ANSWER.ToList <ANSWER>(); // Determine whether the assessment is questions based or requirements based var applicationMode = assessmentEntity.STANDARD_SELECTION.Where(a => a.Assessment_Id == this.assessment_id).FirstOrDefault().Application_Mode; // Questions worksheet if (applicationMode.ToLower().Contains("questions")) { list = from a in answers join q in assessmentEntity.NEW_QUESTION on a.Question_Or_Requirement_Id equals q.Question_Id join h in assessmentEntity.vQUESTION_HEADINGS on q.Heading_Pair_Id equals h.Heading_Pair_Id where a.Is_Requirement == false && a.Assessment_Id == assessment_id select new QuestionExport() { Question_Id = q.Question_Id, Question_Group_Heading = h.Question_Group_Heading, Simple_Question = q.Simple_Question, Answer_Text = a.Answer_Text, Mark_For_Review = a.Mark_For_Review, Reviewed = a.Reviewed, Is_Requirement = a.Is_Requirement, Is_Component = a.Is_Component, Is_Framework = a.Is_Framework, Comment = a.Comment, Alternate_Justification = a.Alternate_Justification, Component_Guid = a.Component_Guid, Component_Id = a.Component_Id, Answer_Id = a.Answer_Id }; doc.AddList <QuestionExport>(list.ToList <QuestionExport>(), "Questions", QuestionExport.Headings); } // Requirements worksheet if (applicationMode.ToLower().Contains("requirements")) { list = from a in answers join q in assessmentEntity.NEW_REQUIREMENT on a.Question_Or_Requirement_Id equals q.Requirement_Id join h in assessmentEntity.QUESTION_GROUP_HEADING on q.Question_Group_Heading_Id equals h.Question_Group_Heading_Id where a.Is_Requirement == true && a.Assessment_Id == assessment_id select new QuestionExport() { Question_Id = q.Requirement_Id, Question_Group_Heading = h.Question_Group_Heading1, Simple_Question = q.Requirement_Text, Answer_Text = a.Answer_Text, Mark_For_Review = a.Mark_For_Review, Reviewed = a.Reviewed, Is_Requirement = a.Is_Requirement, Is_Component = a.Is_Component, Is_Framework = a.Is_Framework, Comment = a.Comment, Alternate_Justification = a.Alternate_Justification, Component_Guid = a.Component_Guid, Component_Id = a.Component_Id, Answer_Id = a.Answer_Id }; doc.AddList <QuestionExport>(list.ToList <QuestionExport>(), "Requirements", QuestionExport.Headings); } // Framework worksheet var qlist = from a in answers join q in assessmentEntity.NEW_QUESTION on a.Question_Or_Requirement_Id equals q.Question_Id join h in assessmentEntity.vQUESTION_HEADINGS on q.Heading_Pair_Id equals h.Heading_Pair_Id where a.Is_Framework == true && a.Assessment_Id == assessment_id select new QuestionExport() { Question_Id = q.Question_Id, Question_Group_Heading = h.Question_Group_Heading, Simple_Question = q.Simple_Question, Answer_Text = a.Answer_Text, Mark_For_Review = a.Mark_For_Review, Reviewed = a.Reviewed, Is_Requirement = a.Is_Requirement, Is_Component = a.Is_Component, Is_Framework = a.Is_Framework, Comment = a.Comment, Alternate_Justification = a.Alternate_Justification, Component_Guid = a.Component_Guid, Component_Id = a.Component_Id, Answer_Id = a.Answer_Id }; doc.AddList <QuestionExport>(qlist.ToList <QuestionExport>(), "Framework", QuestionExport.Headings); List <DataMap> maps = new List <DataMap>(); doc.WriteExcelFile(stream, maps); }