public void AddColumn(IExcelColumn column) { string columnKey = GetColumnKey(column); column.Field = _fieldDispatcherService.GetDtoFields <TDto>().FirstOrDefault(x => x.Name == column.Property.Name); _columns[columnKey] = column; }
protected override Dynamic Process() { Dynamic data = new Dynamic() { ["Code"] = 0, ["Data"] = null }; try { ExcelPackage p = _provider.GetService(typeof(ExcelPackage)) as ExcelPackage; int tableIndex = 0; do { IExcelSheet sheet = p.AddSheet("Sheet" + (++tableIndex)); int rowIndex = 0; int rStart = 2, cStart = 1; while (ReadLine()) { for (int colIndex = 0; colIndex < FieldCount; colIndex++) { IExcelRange range = sheet.Range(rStart + rowIndex, cStart + colIndex); range.Value = GetFieldValue(colIndex); } rowIndex++; } rStart = 1; for (int colIndex = 0; colIndex < FieldCount; colIndex++) { IExcelRange range = sheet.Range(rStart, colIndex + cStart); range.Value = GetFieldName(colIndex); IExcelColumn column = sheet.Column(colIndex + cStart); column.SetFormat(GetFieldType(colIndex)); column.AutoFit(); } } while (ReadNextResult()); data["Data"] = p.GetBytes(); p.Dispose(); } catch (Exception) { data["Code"] = 1; } return(data); }
private void FillColumnOrder(List <string> columnTitles) { foreach (var columnKey in _columns.Keys.ToList()) { int colInd = columnTitles.IndexOf(columnKey); if (colInd >= 0) { IExcelColumn column = _columns[columnKey]; column.ColumnIndex = colInd + 1; } else { _columns.Remove(columnKey); } } }
/// <summary> /// Gets the column at the specified column index /// </summary> /// <param name="index">The zero-based index of the column.</param> /// <param name="create">If set to <see langword="true" />. It will create the column if /// the column is null at the specified index when the index is in the valid range</param> /// <returns> /// An <see cref="T:Dt.Xls.IExcelColumn" /> instance represent the column at the specified index /// </returns> public IExcelColumn GetColumn(int index, bool create = true) { IExcelColumn column = this._columns1[index]; if (column != null) { return(column); } if (((index >= 0) && (index <= this._columnCount)) && create) { ExcelColumn column2 = new ExcelColumn(this) { Index = index, Width = this._defaultColumnWidth }; column2.SetFormatId(-1); column2.Visible = true; this._columns1[index] = column2; return(column2); } return(null); }
public bool GetColumnPageBreaks(short sheet, List <short> pageBreaks) { IExcelWorksheet worksheet = this._workbook.Worksheets[sheet]; ushort num = 0; if (this._workbook.Operator.ExportedExcelVersion == ExcelVersion.Excel2007) { num = (ushort)Math.Min(0x4000, worksheet.ColumnCount); } else { num = (ushort)Math.Min(0x100, worksheet.ColumnCount); } for (short i = 0; i < num; i++) { IExcelColumn column = worksheet.GetColumn(i, false); if ((column != null) && column.PageBreak) { pageBreaks.Add(i); } } return(true); }
public static XmlElement GetAnswerNode(XmlDocument xml, IExcelColumn <ExamExcelColumnType> answerColumn, string questionId, bool addMissingValue = false, string elementName = "pb-choice-block") { return(GetAnswerNode(xml, answerColumn != null && answerColumn.HaveValue() ? answerColumn.Value : "", questionId, addMissingValue, elementName)); }
private string GetColumnKey(IExcelColumn column) { var res = column.Property.ReflectedType.Name.ToLower() + "_" + column.Property.Name.ToLower(); return(res); }
public ExcelColumn(IExcelColumn internalColumn) { this.internalColumn = internalColumn; }
public XmlDocument ConvertExcelToCourseXml(Excel <MainStructureExcelColumn, MainStructureColumnType> mainStructureExcel, Excel <QuestionExcelColumn, QuestionExcelColumnType> questionExcel, Excel <LosExcelColumn, LosExcelColumnType> losExcel, Excel <AcceptanceCriteriaExcelColumn, AcceptanceCriteriaColumnType> acceptanceCriteriaExcel, Excel <ExamExcelColumn, ExamExcelColumnType> ssTestExcel, Excel <ExamExcelColumn, ExamExcelColumnType> progressTestExcel, Excel <ExamExcelColumn, ExamExcelColumnType> MockExamsExcel, Excel <ExamExcelColumn, ExamExcelColumnType> TopicWorkshopExcel, bool setTranscripts) { CourseConverterHelper.generatedQuestionIds = new Dictionary <string, string>(); CourseConverterHelper._generatedGuids = new Dictionary <string, guidRequest>(); XmlDocument xml = new XmlDocument(); var xmlTranscriptAccessor = new XmlTranscriptAccessor(); XmlElement rootNode = xml.CreateElement("xbundle"); xml.AppendChild(rootNode); // Getting Metadata from xml file XmlDocument doc = new XmlDocument(); System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly(); doc.Load(a.GetManifestResourceStream("ExcelParser.MetadataXml.xml")); XmlNode importNode = doc.DocumentElement.SelectSingleNode("/metadata"); XmlNode metadataNode = rootNode.OwnerDocument.ImportNode(importNode, true); rootNode.AppendChild(metadataNode); XmlElement courseNode = xml.CreateElement("course"); courseNode.SetAttribute("advanced_modules", "["annotatable", "videoalpha", "openassessment", "container", "problem-builder-block", "problem-builder-progress-test", "problem-builder-mock-exam", "textualatom"]"); courseNode.SetAttribute("display_name", "CFA Course Default name"); courseNode.SetAttribute("language", "en"); courseNode.SetAttribute("start", ""2016-01-01T00:00:00+00:00""); courseNode.SetAttribute("org", "s"); courseNode.SetAttribute("course", "s"); courseNode.SetAttribute("url_name_orig", "course"); courseNode.SetAttribute("semester", "course"); courseNode.SetAttribute("days_before_review_unlock", "28"); rootNode.AppendChild(courseNode); // Add Introduction Node courseNode.AppendChild(AddIntroductionTopic(xml)); XmlElement chapterNode = null; XmlElement sequentialNode = null; XmlElement previousSequentialNode = null; XmlElement previousChapterNode = null; XmlElement verticalNode = null; XmlElement bandContainerNode = null; XmlElement conceptNameContainerNode = null; bool skip = false; IExcelColumn <MainStructureColumnType> previousStudySessionId = null; IExcelColumn <MainStructureColumnType> previousTopicId = null; foreach (var row in mainStructureExcel.Rows) { var structureTokens = row.First(c => c.Type == MainStructureColumnType.Structure).Value.Split('|'); //Band need to be legal value else skip this row var bandColumn = row.FirstOrDefault(c => c.Type == MainStructureColumnType.Band); if (bandColumn == null || bandColumn.Value == null || bandColumn.Value[0].ToString().ToLower() != "b") { continue; } var atomType = row.FirstOrDefault(c => c.Type == MainStructureColumnType.AtomType); if (atomType == null || !atomType.HaveValue() || !(atomType.Value == "IN" || atomType.Value == "Q" || atomType.Value == "TXT")) { continue; } var atomIdColumn = row.FirstOrDefault(c => c.Type == MainStructureColumnType.AtomId); List <IExcelColumn <QuestionExcelColumnType> > questionRow = null; if (atomType.Value == "Q") { if (atomIdColumn == null || !atomIdColumn.HaveValue()) { continue; } questionRow = questionExcel.Rows.FirstOrDefault(r => r.Any(c => c.Type == QuestionExcelColumnType.QuestionId && c.Value == atomIdColumn.Value)); if (questionRow == null) { continue; } } var topicNameColumn = row.FirstOrDefault(c => c.Type == MainStructureColumnType.TopicName); skip = (chapterNode != null && chapterNode.GetAttribute("display_name") != topicNameColumn.Value) ? false : skip; var topicId = row.FirstOrDefault(c => c.Type == MainStructureColumnType.TopicShortName); if (!skip) { var topicShortName = row.FirstOrDefault(c => c.Type == MainStructureColumnType.TopicShortName); var examPercantage = row.FirstOrDefault(c => c.Type == MainStructureColumnType.ExamPercentage); var cfatopicweight = row.FirstOrDefault(c => c.Type == MainStructureColumnType.CfaTopicWeight); var lockedColumn = row.FirstOrDefault(c => c.Type == MainStructureColumnType.Locked); var demoColumn = row.FirstOrDefault(c => c.Type == MainStructureColumnType.Demo); var colorColumn = row.FirstOrDefault(c => c.Type == MainStructureColumnType.Color); var cfaTypeColumn = row.FirstOrDefault(c => c.Type == MainStructureColumnType.CfaType); var locked = lockedColumn != null && lockedColumn.HaveValue() ? lockedColumn.Value : ""; locked = locked.ToLower() == "true" ? "yes" : "no"; var demo = demoColumn != null && demoColumn.HaveValue() ? demoColumn.Value : ""; demo = demo.ToLower() == "true" ? "yes" : "no"; var description = row.FirstOrDefault(c => c.Type == MainStructureColumnType.Description); chapterNode = xml.CreateElement("chapter"); chapterNode.SetAttribute("display_name", topicNameColumn != null && topicNameColumn.HaveValue() ? topicNameColumn.Value : ""); chapterNode.SetAttribute("url_name", CourseConverterHelper.getGuid(topicShortName.Value, CourseTypes.Topic)); chapterNode.SetAttribute("cfa_short_name", topicShortName != null && topicShortName.HaveValue() ? topicShortName.Value : ""); chapterNode.SetAttribute("exam_percentage", examPercantage != null && examPercantage.HaveValue() ? examPercantage.Value : ""); chapterNode.SetAttribute("cfa_topic_weight", cfatopicweight != null && cfatopicweight.HaveValue() ? cfatopicweight.Value : ""); chapterNode.SetAttribute("description", description != null && description.HaveValue() ? description.Value : ""); chapterNode.SetAttribute("locked", locked); chapterNode.SetAttribute("demo_topic", demo); chapterNode.SetAttribute("topic_color", colorColumn != null && colorColumn.HaveValue() ? colorColumn.Value : ""); chapterNode.SetAttribute("cfa_type", cfaTypeColumn != null && cfaTypeColumn.HaveValue() ? cfaTypeColumn.Value : "topic"); chapterNode.SetAttribute("taxon_id", String.Join("|", structureTokens.Take(2))); courseNode.AppendChild(chapterNode); //ADD TOPIC WORKSHOP if (TopicWorkshopExcel != null && previousChapterNode != null && previousTopicId != null) { AppendTopicWorkshop(xml, previousChapterNode, previousTopicId.Value, TopicWorkshopExcel); } previousChapterNode = chapterNode; previousTopicId = topicId; } var sessionNameColumn = row.FirstOrDefault(c => c.Type == MainStructureColumnType.SessionName); skip = (sequentialNode != null && sequentialNode.GetAttribute("display_name") != sessionNameColumn.Value) ? false : skip; var studySessionId = row.FirstOrDefault(c => c.Type == MainStructureColumnType.StudySessionId); if (!skip) { var studySession = row.FirstOrDefault(c => c.Type == MainStructureColumnType.StudySession); sequentialNode = xml.CreateElement("sequential"); sequentialNode.SetAttribute("display_name", sessionNameColumn != null && sessionNameColumn.HaveValue() ? sessionNameColumn.Value : ""); sequentialNode.SetAttribute("url_name", CourseConverterHelper.getGuid(studySessionId.Value, CourseTypes.StudySession)); sequentialNode.SetAttribute("cfa_short_name", studySession != null && studySession.HaveValue() ? studySession.Value : ""); sequentialNode.SetAttribute("taxon_id", String.Join("|", structureTokens.Take(3))); sequentialNode.SetAttribute("proficiency_target", "70"); chapterNode.AppendChild(sequentialNode); //ADD TEST TO THE BOTTOM OF LAST SESSION NAME NODE if (ssTestExcel != null && previousSequentialNode != null && previousStudySessionId != null) { AppendStudySessionTestQuestions(xml, previousSequentialNode, previousStudySessionId.Value, ssTestExcel); } previousSequentialNode = sequentialNode; previousStudySessionId = studySessionId; } var readingNameColumn = row.FirstOrDefault(c => c.Type == MainStructureColumnType.ReadingName); var downloads1Column = row.FirstOrDefault(c => c.Type == MainStructureColumnType.Downloads1); var downloads2Column = row.FirstOrDefault(c => c.Type == MainStructureColumnType.Downloads2); var downloads = new List <string>(); if (downloads1Column != null && downloads1Column.HaveValue()) { downloads.Add(downloads1Column.Value); } if (downloads2Column != null && downloads2Column.HaveValue()) { downloads.Add(downloads2Column.Value); } skip = (verticalNode != null && verticalNode.GetAttribute("display_name") != readingNameColumn.Value) ? false : skip; if (!skip) { var readingColumn = row.FirstOrDefault(c => c.Type == MainStructureColumnType.Reading); var readingIdColumn = row.FirstOrDefault(c => c.Type == MainStructureColumnType.ReadingId); var readingLockedColumn = row.FirstOrDefault(c => c.Type == MainStructureColumnType.Locked); var readingLocked = readingLockedColumn != null && readingLockedColumn.HaveValue() ? readingLockedColumn.Value : ""; readingLocked = readingLocked.ToLower() == "true" ? "yes" : "no"; verticalNode = xml.CreateElement("vertical"); verticalNode.SetAttribute("display_name", readingNameColumn != null && readingNameColumn.HaveValue() ? readingNameColumn.Value : ""); verticalNode.SetAttribute("url_name", CourseConverterHelper.getGuid(readingIdColumn.Value, CourseTypes.Reading)); verticalNode.SetAttribute("cfa_short_name", readingColumn != null && readingColumn.HaveValue() ? readingColumn.Value : ""); verticalNode.SetAttribute("downloads", JsonConvert.SerializeObject(downloads)); verticalNode.SetAttribute("taxon_id", String.Join("|", structureTokens.Take(4))); verticalNode.SetAttribute("proficiency_target", "70"); verticalNode.SetAttribute("locked", readingLocked); if (losExcel != null) { var outcomes = new List <object>(); var losRows = losExcel.Rows.Where(r => r.Any(c => c.Type == LosExcelColumnType.ReadingRef && c.Value == readingIdColumn.Value) && r.Any(c => c.Type == LosExcelColumnType.TopicRef && c.Value == topicId.Value) && r.Any(c => c.Type == LosExcelColumnType.SessionRef && c.Value == studySessionId.Value) ); foreach (var losRow in losRows) { var cfaAlpfaColumn = losRow.Find(c => c.Type == LosExcelColumnType.CfaAlpha); var losTextColumn = losRow.Find(c => c.Type == LosExcelColumnType.LosText); outcomes.Add(new { text = losTextColumn != null ? losTextColumn.Value : "", letter = cfaAlpfaColumn != null ? cfaAlpfaColumn.Value : "" }); } verticalNode.SetAttribute("outcome_statements", JsonConvert.SerializeObject(outcomes)); } sequentialNode.AppendChild(verticalNode); } var conceptNameColumn = row.FirstOrDefault(c => c.Type == MainStructureColumnType.ConceptName); var conceptIdColumn = row.FirstOrDefault(c => c.Type == MainStructureColumnType.ConceptId); skip = (bandContainerNode != null && bandContainerNode.GetAttribute("display_name") != bandColumn.Value) ? false : skip; if (!skip) { var bandIdColumn = row.FirstOrDefault(c => c.Type == MainStructureColumnType.BandId); bandContainerNode = xml.CreateElement("container"); bandContainerNode.SetAttribute("url_name", CourseConverterHelper.getGuid(bandIdColumn.Value, CourseTypes.Band)); bandContainerNode.SetAttribute("display_name", bandColumn != null && bandColumn.HaveValue() ? bandColumn.Value : ""); bandContainerNode.SetAttribute("xblock-family", "xblock.v1"); bandContainerNode.SetAttribute("container_description", ""); bandContainerNode.SetAttribute("learning_objective_id", ""); bandContainerNode.SetAttribute("taxon_id", String.Join("|", structureTokens.Take(5))); string targetScore = ""; if (acceptanceCriteriaExcel != null) { var acceptanceCriteriaRow = acceptanceCriteriaExcel.Rows.FirstOrDefault( r => r.Any(c => c.Type == AcceptanceCriteriaColumnType.Lo1 && c.Value == conceptIdColumn.Value)); if (acceptanceCriteriaRow != null) { var scoreColumn = acceptanceCriteriaRow.FirstOrDefault(c => c.Type == AcceptanceCriteriaColumnType.TargetScore); if (scoreColumn != null && scoreColumn.HaveValue()) { targetScore = scoreColumn.Value; } } } bandContainerNode.SetAttribute("acceptance_criteria", targetScore); verticalNode.AppendChild(bandContainerNode); } skip = (conceptNameContainerNode != null && conceptNameContainerNode.GetAttribute("learning_objective_id") != conceptIdColumn.Value) ? false : skip; if (!skip) { conceptNameContainerNode = xml.CreateElement("container"); conceptNameContainerNode.SetAttribute("url_name", CourseConverterHelper.getGuid(conceptIdColumn.Value, CourseTypes.Concept)); conceptNameContainerNode.SetAttribute("display_name", conceptNameColumn != null && conceptNameColumn.HaveValue() ? conceptNameColumn.Value : ""); conceptNameContainerNode.SetAttribute("xblock-family", "xblock.v1"); conceptNameContainerNode.SetAttribute("container_description", ""); conceptNameContainerNode.SetAttribute("learning_objective_id", conceptIdColumn != null && conceptIdColumn.HaveValue() ? conceptIdColumn.Value : ""); conceptNameContainerNode.SetAttribute("taxon_id", String.Join("|", structureTokens.Take(6))); bandContainerNode.AppendChild(conceptNameContainerNode); } string atomTaxonId = String.Format("{0}|{1}", String.Join("|", structureTokens.Take(6)), atomIdColumn.Value); //VIDEO if (atomType.Value == "IN") { var atomTitleColumn = row.FirstOrDefault(c => c.Type == MainStructureColumnType.AtomTitle); var itemIdCoclumn = row.FirstOrDefault(c => c.Type == MainStructureColumnType.ItemId); var videoNode = xml.CreateElement("brightcove-video"); videoNode.SetAttribute("url_name", CourseConverterHelper.getGuid(atomIdColumn.Value, CourseTypes.Video)); videoNode.SetAttribute("xblock-family", "xblock.v1"); videoNode.SetAttribute("api_bckey", "AQ~~,AAAELMh4AWE~,vVFFDlX6sNOap1Tww7YwaMvqbQ8TtDoh"); videoNode.SetAttribute("display_name", atomTitleColumn != null && atomTitleColumn.HaveValue() ? atomTitleColumn.Value : ""); videoNode.SetAttribute("api_key", "JqnRdhYvLWNtVJllXkMzGGGTh66uLLmz8JB8YlcZQlC8OX94H4ZXXw.."); videoNode.SetAttribute("text_values", "[]"); videoNode.SetAttribute("api_bctid", itemIdCoclumn.Value); videoNode.SetAttribute("begin_values", "[]"); videoNode.SetAttribute("api_bcpid", "4830051907001"); videoNode.SetAttribute("cfa_type", "video"); videoNode.SetAttribute("atom_id", atomIdColumn.Value); videoNode.SetAttribute("taxon_id", atomTaxonId); if (setTranscripts) { string xmlTranscriptString = ""; if (atomIdColumn != null && atomIdColumn.HaveValue()) { XmlDocument xmlTranscript = xmlTranscriptAccessor.FindVideoTranscript(atomIdColumn.Value); if (xmlTranscript != null) { xmlTranscriptString = xmlTranscript.InnerXml.Replace("<br />", "").Replace("<br/>", ""); } } videoNode.SetAttribute("xml_string", xmlTranscriptString); } else { videoNode.SetAttribute("xml_string", " "); } conceptNameContainerNode.AppendChild(videoNode); } //TEXT else if (atomType.Value == "TXT") { var atomTitleColumn = row.FirstOrDefault(c => c.Type == MainStructureColumnType.AtomTitle); var itemIdCoclumn = row.FirstOrDefault(c => c.Type == MainStructureColumnType.ItemId); var atomText = row.FirstOrDefault(c => c.Type == MainStructureColumnType.AtomBody); var textualNode = xml.CreateElement("textualatom"); textualNode.SetAttribute("url_name", CourseConverterHelper.getGuid(atomIdColumn.Value, CourseTypes.TextAtom)); textualNode.SetAttribute("xblock-family", "xblock.v1"); textualNode.SetAttribute("atom_text", atomText != null && atomText.HaveValue() ? atomText.Value : ""); textualNode.SetAttribute("display_name", atomTitleColumn != null && atomTitleColumn.HaveValue() ? atomTitleColumn.Value : ""); textualNode.SetAttribute("cfa_type", "text"); textualNode.SetAttribute("atom_id", atomIdColumn.Value); textualNode.SetAttribute("taxon_id", atomTaxonId); conceptNameContainerNode.AppendChild(textualNode); } //QUESTION else { var questionDic = CourseConverterHelper.generateQuestionIds(); var problemBuilderNode = xml.CreateElement("problem-builder-block"); var questionIdColumn = questionRow.FirstOrDefault(c => c.Type == QuestionExcelColumnType.QuestionId); var questionColumn = questionRow.FirstOrDefault(c => c.Type == QuestionExcelColumnType.Question); var inFlowColumn = questionRow.FirstOrDefault(c => c.Type == QuestionExcelColumnType.InFlow); string questionValue = questionColumn.HaveValue() ? questionColumn.Value : "Question Missing"; problemBuilderNode.SetAttribute("display_name", Regex.Replace(questionValue, "<.*?>", string.Empty)); problemBuilderNode.SetAttribute("url_name", CourseConverterHelper.getGuid(atomIdColumn.Value, CourseTypes.Question)); problemBuilderNode.SetAttribute("xblock-family", "xblock.v1"); problemBuilderNode.SetAttribute("cfa_type", "question"); problemBuilderNode.SetAttribute("atom_id", atomIdColumn != null && atomIdColumn.HaveValue() ? atomIdColumn.Value : ""); problemBuilderNode.SetAttribute("instruct_assessment", inFlowColumn != null && inFlowColumn.HaveValue() ? inFlowColumn.Value : ""); problemBuilderNode.SetAttribute("taxon_id", atomTaxonId); conceptNameContainerNode.AppendChild(problemBuilderNode); var pbMcqNode = xml.CreateElement("pb-mcq-block"); var correctColumn = questionRow.FirstOrDefault(c => c.Type == QuestionExcelColumnType.Correct); var actualCorrectValues = new List <string>(); if (correctColumn != null && correctColumn.HaveValue()) { var correctValues = correctColumn.Value.Trim().Split(' '); foreach (var correctValue in correctValues) { actualCorrectValues.Add(questionDic[correctValue]); } } pbMcqNode.SetAttribute("url_name", CourseConverterHelper.getNewGuid()); pbMcqNode.SetAttribute("xblock-family", "xblock.v1"); pbMcqNode.SetAttribute("question", questionValue); pbMcqNode.SetAttribute("fitch_question_id", questionIdColumn.Value); pbMcqNode.SetAttribute("correct_choices", (correctColumn != null && correctColumn.Value != null) ? JsonConvert.SerializeObject(actualCorrectValues) : ""); problemBuilderNode.AppendChild(pbMcqNode); var questionIds = new List <string>(); var answer1Column = questionRow.FirstOrDefault(c => c.Type == QuestionExcelColumnType.Answer1); var question1Id = questionDic["A"]; var answer1Node = CourseConverterHelper.GetAnswerNode(xml, answer1Column, question1Id, false); if (answer1Node != null) { pbMcqNode.AppendChild(answer1Node); questionIds.Add(question1Id); } var answer2Column = questionRow.FirstOrDefault(c => c.Type == QuestionExcelColumnType.Answer2); var question2Id = questionDic["B"]; var answer2Node = CourseConverterHelper.GetAnswerNode(xml, answer2Column, question2Id, true); if (answer2Node != null) { pbMcqNode.AppendChild(answer2Node); questionIds.Add(question2Id); } var answer3Column = questionRow.FirstOrDefault(c => c.Type == QuestionExcelColumnType.Answer3); var question3Id = questionDic["C"]; var answer3Node = CourseConverterHelper.GetAnswerNode(xml, answer3Column, question3Id, true); if (answer3Node != null) { pbMcqNode.AppendChild(answer3Node); questionIds.Add(question3Id); } var answer4Column = questionRow.FirstOrDefault(c => c.Type == QuestionExcelColumnType.Answer4); var question4Id = questionDic["D"]; var answer4Node = CourseConverterHelper.GetAnswerNode(xml, answer4Column, question4Id); if (answer4Node != null) { pbMcqNode.AppendChild(answer4Node); questionIds.Add(question4Id); } //tip block var justificationCell = questionRow.FirstOrDefault(c => c.Type == QuestionExcelColumnType.Justification); string justificationValue = (justificationCell != null && justificationCell.HaveValue()) ? justificationCell.Value : ""; var questionTipNode = xml.CreateElement("pb-tip-block"); questionTipNode.SetAttribute("url_name", CourseConverterHelper.getNewGuid()); questionTipNode.SetAttribute("xblock-family", "xblock.v1"); questionTipNode.SetAttribute("values", JsonConvert.SerializeObject(questionIds)); questionTipNode.InnerText = String.Format("{0}", justificationValue); pbMcqNode.AppendChild(questionTipNode); } skip = true; } if (ssTestExcel != null) { AppendStudySessionTestQuestions(xml, previousSequentialNode, previousStudySessionId.Value, ssTestExcel); } if (progressTestExcel != null) { var progressTestChapterNode = ProgressTestExcelConverter.Convert(xml, progressTestExcel); // Insert Progress Test after Equity var equityTopicNode = courseNode.SelectSingleNode("chapter[@cfa_short_name = 'EQ']"); courseNode.InsertAfter(progressTestChapterNode, equityTopicNode); } if (MockExamsExcel != null) { var mockExamChapterNodes = MockExamsExcelConverter.Convert(xml, MockExamsExcel); foreach (var mockExamChapterNode in mockExamChapterNodes) { courseNode.AppendChild(mockExamChapterNode); } } if (TopicWorkshopExcel != null) { AppendTopicWorkshop(xml, previousChapterNode, previousTopicId.Value, TopicWorkshopExcel); } // Add Revision and FinalExam Node courseNode.AppendChild(AddRevisionTopic(xml)); courseNode.AppendChild(AddFinalExamTopic(xml)); LockStudySessionsTopic(courseNode); XmlElement wikiNode = xml.CreateElement("wiki"); wikiNode.SetAttribute("slug", "sf1.sf1.sf1"); courseNode.AppendChild(wikiNode); return(xml); }
public static ExcelDoubleMapper <TDto, TFormDto, TInnerDto> MapColumn <TDto, TFormDto, TInnerDto, TField>(this ExcelDoubleMapper <TDto, TFormDto, TInnerDto> excelDoubleMapper, Expression <Func <TDto, TField> > property, IExcelColumn column) where TDto : new() where TFormDto : new() where TInnerDto : new() { var propertyBody = property.Body as MemberExpression; if (propertyBody != null) { var propertyInfo = propertyBody.Member as PropertyInfo; if (propertyInfo != null) { column.Property = propertyInfo; excelDoubleMapper.AddColumn(column); } } return(excelDoubleMapper); }
private string GetColumnKey(IExcelColumn column) { var res = column.Property.Name.ToLower(); return(res); }
/// <summary> /// Initialize the column at the specified index. /// </summary> /// <param name="index">The zero-based index of the column</param> /// <param name="column">An <see cref="T:Dt.Xls.IExcelColumn" /> used to initialize the column at the specified index</param> public void SetColumn(int index, IExcelColumn column) { this._columns1[index] = column; }