private void setColumnSqlExpression(ref clsColumn column, string columnData) { string sqlExpression = clsUtility.getSubStringBetweenTwoStrings(columnData, "<sawx:expr xsi:type=\"sawx:sqlExpression\">", "</sawx:expr>"); if (sqlExpression != null) column.SqlExpression = sqlExpression; }
// possible bug: not veirfying if the view is actually table? private void setColumnTableViewHeaderBackgroundOrFontColor(ref clsColumn column, string column_EdgeLayerSectionData, string keyWord) { if (column_EdgeLayerSectionData.Contains(keyWord)) { int index = column_EdgeLayerSectionData.IndexOf(keyWord); if (keyWord == "backgroundColor=\"") // to-do : remove magic number 7 and use method that gets the string from first 2 quotes. column.BackgroundHexaColor = column_EdgeLayerSectionData.Substring(index + keyWord.Length, 7); //7 is the lenght of hexa code color in xml code eg: "#FFFFFF" else if (keyWord == "fontColor=\"") column.HeaderFontColor = column_EdgeLayerSectionData.Substring(index + keyWord.Length, 7); } else column.BackgroundHexaColor = null; }
private void updateXmlFontStyleAndColumnHeaderFontColorAndColumnHeaderBackgroundColor(clsColumn column, string xmlColumnEdgeLayer) { if (column.OriginalColumnName == "Req. Organization Level 5" || column.OriginalColumnName.Contains("First Fully") || column.OriginalColumnName == "job offer status") column.Type = "Regular"; string toInsert = "<saw:edgeLayer type=\"column\" columnID=\"" + column.ID + "\">" + "<saw:headerFormat><saw:displayFormat><saw:formatSpec "; if (column.HeaderFontStyle != "Default (System)" && column.HeaderFontStyle != "regular" && !string.IsNullOrWhiteSpace(column.HeaderFontStyle)) toInsert = toInsert + " fontStyle=\"" + column.HeaderFontStyle + "\" "; if (!string.IsNullOrWhiteSpace(column.HeaderFontColor)) toInsert = toInsert + " fontColor=\"" + column.HeaderFontColor + "\" "; if (!string.IsNullOrWhiteSpace(column.BackgroundHexaColor)) toInsert = toInsert + " backgroundColor=\"" + column.BackgroundHexaColor + "\" "; toInsert = toInsert + "wrapText=\"true\"/></saw:displayFormat></saw:headerFormat></saw:edgeLayer>"; int removingIndex = _xmlSections.ColumnIndividualData_EdgeLayersSection.IndexOf(_xmlSections.ColumnIndividualData_EdgeLayersSection.FirstOrDefault(a => a.Contains(column.ID))); if (removingIndex != -1) { _xmlSections.ColumnIndividualData_EdgeLayersSection.RemoveAt(removingIndex); if (column.isExcluded == false) // isExcluded == true > remove the edgeLayer xml code _xmlSections.ColumnIndividualData_EdgeLayersSection.Insert(removingIndex, toInsert); } else { if (column.isExcluded == false) // isExcluded == true > remove the edgeLayer xml code _xmlSections.ColumnIndividualData_EdgeLayersSection.Add(toInsert); } }
private void setColumnsExistingPropertiesFromXmlCode() { for (int i = 0; i < _xmlSections.ColumnIndividualData_ColumnsSection.Count; i++) { clsColumn column = new clsColumn(); setAllColumnExistingPropertiesFromColumnsSectionData(ref column, _xmlSections.ColumnIndividualData_ColumnsSection[i]); //from EdgeLayers xml: extract column Properties string match = _xmlSections.ColumnIndividualData_EdgeLayersSection.FirstOrDefault(stringToCheck => stringToCheck.Contains(column.ID)); if (match != null) setColumnPropertiesFromSawEdgeLayers(ref column, match); else column.isExcluded = true; _lstColumns.Add(column); } }
private void setHierarchyID(ref clsColumn column, string columnData) { column.hierarchyID = clsUtility.getStringBetweenFirstTwoQuotesAfterKeyword(columnData, "hierarchyID="); }
//to-do if from client event is changed > change xml accordingly private void updateColumnValuesInteraction(clsColumn column, string xmlIndividualColumnSection) { string firstHalf = xmlIndividualColumnSection; string secondHalf = ""; if (xmlIndividualColumnSection.Contains("<saw:columnHeading>")) { int firstPartStopIndex = xmlIndividualColumnSection.IndexOf("<saw:columnHeading>"); firstHalf = xmlIndividualColumnSection.Substring(0, firstPartStopIndex); secondHalf = xmlIndividualColumnSection.Substring(firstPartStopIndex); } if (!string.IsNullOrWhiteSpace(column.ValuesPrimaryInteraction) && column.ValuesPrimaryInteraction != "default (drill)") { if (firstHalf.Contains("<saw:formatSpec ")) { if (firstHalf.Contains("interaction=")) { string existingInteraction = clsUtility.getStringBetweenFirstTwoQuotesAfterKeyword(firstHalf, "interaction"); firstHalf = firstHalf.Replace("interaction=\"" + existingInteraction + "\"", " interaction=\"" + column.ValuesPrimaryInteraction + "\" "); } else { firstHalf = clsUtility.insertStringInStringAfterKeyword(firstHalf, " interaction=\"" + column.ValuesPrimaryInteraction + "\" ", "<saw:formatSpec"); } } else { firstHalf = clsUtility.insertStringInStringAfterKeyword(firstHalf, "<saw:displayFormat> <saw:formatSpec interaction=\"" + column.ValuesPrimaryInteraction + "\"/></saw:displayFormat>", "</saw:columnFormula>"); } } else { if (!firstHalf.Contains("interaction=\"")) return; string existingInteraction = clsUtility.getStringBetweenFirstTwoQuotesAfterKeyword(firstHalf, "interaction=\""); firstHalf = firstHalf.Replace("interaction=\"" + existingInteraction + "\"", ""); } int removingIndex = _xmlSections.ColumnIndividualData_ColumnsSection.IndexOf(_xmlSections.ColumnIndividualData_ColumnsSection.FirstOrDefault(a => a.Contains(column.ID))); _xmlSections.ColumnIndividualData_ColumnsSection.RemoveAt(removingIndex); _xmlSections.ColumnIndividualData_ColumnsSection.Insert(removingIndex, firstHalf + secondHalf); }
private void setcolumnFolderAndOriginalName(ref clsColumn column, string columnSqlExpression) { //column.FolderName = columnSqlExpression.Substring(0, columnSqlExpression.LastIndexOf('.')).Replace("\"", ""); //column.OriginalColumnName = columnSqlExpression.Substring(columnSqlExpression.LastIndexOf('.') + 1).Replace("\"", ""); if (string.IsNullOrWhiteSpace(columnSqlExpression)) return; column.FolderName = columnSqlExpression.Substring(0, columnSqlExpression.LastIndexOf("\".\"")).Replace("\"", ""); column.OriginalColumnName = columnSqlExpression.Substring(columnSqlExpression.LastIndexOf("\".\"") + 3).Replace("\"", ""); }
private void setColumn_Type(ref clsColumn column, string columnData) { if (columnData.Contains("saw:regularColumn")) column.Type = "Regular"; else if (columnData.Contains("saw:hierarchicalColumn")) column.Type = "Hierarchical"; }
// can not make a generic method with setColumnsqlExpression because the cutom heading will have two tags in the input private void setColumnCustomHeaading(ref clsColumn column, string columnData) { string customHeading = clsUtility.getSubStringBetweenTwoStrings(columnData, "<saw:text>", "</saw:text>"); if (customHeading != null) column.CustomHeading = customHeading; }
private void setColumnDateFormat(ref clsColumn column, string columnData) { if (columnData.Contains("DD/MM/YYYY")) column.DateFormat_DDMMYYYY = true; }
// ID columnorginalName CustomHeading private void setAllColumnExistingPropertiesFromColumnsSectionData(ref clsColumn column, string column_ColumnSectionData) { setColumnID(ref column, column_ColumnSectionData.Substring(column_ColumnSectionData.IndexOf("columnID=\""))); setColumnSqlExpression(ref column, column_ColumnSectionData); setcolumnFolderAndOriginalName(ref column, column.SqlExpression); if (column_ColumnSectionData.IndexOf("<saw:columnHeading>") != -1) { // set customHeading set HeaderInteraction [set anything that is in the this section] string columnHeading_Section = clsUtility.getSubStringBetweenTwoStrings(column_ColumnSectionData, "<saw:columnHeading>", "</saw:columnHeading>"); setColumnCustomHeaading(ref column, columnHeading_Section); setColumnHeaderInteraction(ref column, columnHeading_Section); } setColumn_Type(ref column, column_ColumnSectionData); if (column.Type == "Hierarchical") { setHierarchyID(ref column, column_ColumnSectionData); setDimensionID(ref column, column_ColumnSectionData); column.OriginalColumnName = column.hierarchyID; } setColumnRepeatOrSuppress(ref column, column_ColumnSectionData); setColumnValuesInteraction(ref column, column_ColumnSectionData); setColumnVisibility(ref column, column_ColumnSectionData); setColumnDateFormat(ref column, column_ColumnSectionData); }
private void updateXmlRepeatOrSuprress(clsColumn column, string xmlIndividualColumnSection) { string firstPart = xmlIndividualColumnSection; string lastPart = null; if (xmlIndividualColumnSection.Contains("<saw:columnHeading>")) { firstPart = xmlIndividualColumnSection.Substring(0, xmlIndividualColumnSection.IndexOf("<saw:columnHeading>")); lastPart = xmlIndividualColumnSection.Substring(xmlIndividualColumnSection.IndexOf("<saw:columnHeading>")); } string suppressOrRepeat = null; if (column.RepeatRows == true) suppressOrRepeat = "repeat"; else suppressOrRepeat = "suppress"; if (firstPart.Contains("<saw:formatSpec")) { if (firstPart.Contains("suppress=\"suppress\"") && suppressOrRepeat == "repeat") firstPart = firstPart.Replace("suppress=\"suppress\"", "suppress=\"" + suppressOrRepeat + "\""); else if (firstPart.Contains("suppress=\"repeat\"") && suppressOrRepeat == "suppress") firstPart = firstPart.Replace("suppress=\"repeat\"", "suppress=\"" + suppressOrRepeat + "\""); else if (!firstPart.Contains("suppress=") && suppressOrRepeat == "repeat") // not present && user wants repeated firstPart = clsUtility.insertStringInStringAfterKeyword(firstPart, " suppress=\"" + suppressOrRepeat + "\" ", "<saw:formatSpec"); } else if (!firstPart.Contains("<saw:formatSpec")) { if (firstPart.Contains("</saw:columnFormula>")) { firstPart = clsUtility.insertStringInStringAfterKeyword(firstPart, " <saw:displayFormat><saw:formatSpec suppress=\"" + suppressOrRepeat + "\" wrapText=\"true\"/></saw:displayFormat> ", "</saw:columnFormula>"); } } if (lastPart != null) firstPart = firstPart + lastPart; int removingIndex = _xmlSections.ColumnIndividualData_ColumnsSection.IndexOf(_xmlSections.ColumnIndividualData_ColumnsSection.FirstOrDefault(a => a.Contains(column.ID))); _xmlSections.ColumnIndividualData_ColumnsSection.RemoveAt(removingIndex); _xmlSections.ColumnIndividualData_ColumnsSection.Insert(removingIndex, firstPart); }
private void updateXmlHiddenColumn(clsColumn column, string xmlIndividualColumnSection) { string firstPart = xmlIndividualColumnSection; string lastPart = null; if (column.isHidden && !xmlIndividualColumnSection.Contains("visibility=\"hidden\"")) // user wants to hide column but column is not hidden { if (xmlIndividualColumnSection.Contains("<saw:columnHeading>")) { firstPart = xmlIndividualColumnSection.Substring(0, xmlIndividualColumnSection.IndexOf("<saw:columnHeading>")); lastPart = xmlIndividualColumnSection.Substring(xmlIndividualColumnSection.IndexOf("<saw:columnHeading>")); } if (firstPart.Contains("<saw:formatSpec")) { firstPart = clsUtility.insertStringInStringAfterKeyword(firstPart, " visibility=\"hidden\" ", "<saw:formatSpec"); } else { if (firstPart.Contains("</saw:columnFormula>")) { firstPart = clsUtility.insertStringInStringAfterKeyword(firstPart, " <saw:displayFormat><saw:formatSpec visibility=\"hidden\" wrapText=\"true\"/></saw:displayFormat> ", "</saw:columnFormula>"); } } } else if (column.isHidden == false && firstPart.Contains("visibility=\"hidden\"")) // user wants to show column but column is hidden { firstPart = firstPart.Replace("visibility=\"hidden\"", ""); } string replacement = firstPart; if (lastPart != null) replacement = firstPart + lastPart; int removingIndex = _xmlSections.ColumnIndividualData_ColumnsSection.IndexOf(_xmlSections.ColumnIndividualData_ColumnsSection.FirstOrDefault(a => a.Contains(column.ID))); _xmlSections.ColumnIndividualData_ColumnsSection.RemoveAt(removingIndex); _xmlSections.ColumnIndividualData_ColumnsSection.Insert(removingIndex, replacement); }
private void setColumnValuesInteraction(ref clsColumn column, string columnData) { if (columnData.IndexOf("<saw:columnHeading>") != -1) { string toRemove = clsUtility.getSubStringBetweenTwoStrings(columnData, "<saw:columnHeading>", "</saw:columnHeading>"); columnData = columnData.Replace(toRemove, ""); } column.ValuesPrimaryInteraction = clsUtility.getStringBetweenFirstTwoQuotesAfterKeyword((columnData), "interaction"); if (column.ValuesPrimaryInteraction == "clientEvent") { if (columnData.Contains("channel=\"")) { column.ValuesPrimaryInteraction_SpecifyChannel = clsUtility.getStringBetweenFirstTwoQuotesAfterKeyword((columnData), "channel"); } } }
private void setColumnFontStyle(ref clsColumn column, string column_EdgeLayerSectionData) { column.HeaderFontStyle = clsUtility.getStringBetweenFirstTwoQuotesAfterKeyword(column_EdgeLayerSectionData, "fontStyle="); }
private void setColumnVisibility(ref clsColumn column, string columnData) { if (columnData.Contains("visibility=\"")) column.isHidden = true; else column.isHidden = false; }
private void setColumnHeaderInteraction(ref clsColumn column, string columnData) { column.HeadingPrimaryInteraction = clsUtility.getStringBetweenFirstTwoQuotesAfterKeyword(columnData, "interaction="); }
private void setDimensionID(ref clsColumn column, string columnData) { column.dimensionID = clsUtility.getStringBetweenFirstTwoQuotesAfterKeyword(columnData, "dimensionID="); }
private void setColumnPropertiesFromSawEdgeLayers(ref clsColumn column, string column_EdgeLayerSectionData) { setColumnTableViewHeaderBackgroundOrFontColor(ref column, column_EdgeLayerSectionData, "backgroundColor=\""); setColumnTableViewHeaderBackgroundOrFontColor(ref column, column_EdgeLayerSectionData, "fontColor=\""); setColumnFontStyle(ref column, column_EdgeLayerSectionData); }
private void updateColumnHeaderInteraction(clsColumn column, string xmlIndividualColumnSection) { string updatedColumnData = null; if (xmlIndividualColumnSection.Contains("<saw:columnHeading>")) { int firstPartStopIndex = xmlIndividualColumnSection.IndexOf("<saw:columnHeading>"); string firstHalf = xmlIndividualColumnSection.Substring(0, firstPartStopIndex); string secondHalf = xmlIndividualColumnSection.Substring(firstPartStopIndex); if (secondHalf.Contains("<saw:formatSpec")) { if (secondHalf.Contains("interaction=\"")) { string existingInteraction = clsUtility.getStringBetweenFirstTwoQuotesAfterKeyword(secondHalf, "interaction"); if (string.IsNullOrWhiteSpace(column.HeadingPrimaryInteraction) || column.HeadingPrimaryInteraction == "default (drill)") { secondHalf = secondHalf.Replace("interaction=\"" + existingInteraction + "\"", ""); } secondHalf = secondHalf.Replace("interaction=\"" + existingInteraction + "\"", "interaction=\"" + column.HeadingPrimaryInteraction + "\""); } // interaction not present but user wants to add interaction else if (!string.IsNullOrWhiteSpace(column.HeadingPrimaryInteraction) && column.HeadingPrimaryInteraction != "default (drill)") { secondHalf = clsUtility.insertStringInStringAfterKeyword(secondHalf, " interaction=\"" + column.HeadingPrimaryInteraction + "\" ", "<saw:formatSpec"); } } else //column Heading present but not format Spec { if (!string.IsNullOrWhiteSpace(column.HeadingPrimaryInteraction) && column.HeadingPrimaryInteraction != "default (drill)") // user want to add interaction { secondHalf = clsUtility.insertStringInStringBeforeKeyword(secondHalf, "<saw:displayFormat><saw:formatSpec interaction=\"" + column.HeadingPrimaryInteraction + "\" /></saw:displayFormat>", "</saw:columnHeading>"); } } updatedColumnData = firstHalf + secondHalf; } else // column heading not present { if (!string.IsNullOrWhiteSpace(column.HeadingPrimaryInteraction) && column.HeadingPrimaryInteraction != "default (drill)") { string insertString = "<saw:columnHeading><saw:displayFormat><saw:formatSpec interaction=\"" + column.HeadingPrimaryInteraction + "\"/></saw:displayFormat></saw:columnHeading>"; updatedColumnData = clsUtility.insertStringInStringBeforeKeyword(xmlIndividualColumnSection, insertString, "</saw:column>"); } } if (!string.IsNullOrWhiteSpace(updatedColumnData)) { int removingIndex = _xmlSections.ColumnIndividualData_ColumnsSection.IndexOf(_xmlSections.ColumnIndividualData_ColumnsSection.FirstOrDefault(a => a.Contains(column.ID))); _xmlSections.ColumnIndividualData_ColumnsSection.RemoveAt(removingIndex); _xmlSections.ColumnIndividualData_ColumnsSection.Insert(removingIndex, updatedColumnData); } }
private void setColumnRepeatOrSuppress(ref clsColumn column, string columnData) { if (columnData.Contains("suppress=\"repeat\"")) column.RepeatRows = true; else column.RepeatRows = false; }
private void updateCustomHeading(clsColumn column, string xmlIndividualColumnSection) { if (string.IsNullOrWhiteSpace(column.CustomHeading) )//&& !xmlIndividualColumnSection.Contains("<saw:columnHeading>")) return; int indexOfKeywordColumnHeading = xmlIndividualColumnSection.IndexOf("<saw:columnHeading>"); if (indexOfKeywordColumnHeading != -1) // column heading is present { int indexOfKeywordSawText = xmlIndividualColumnSection.IndexOf("<saw:text>"); if (indexOfKeywordSawText != -1) // saw text is present { string startingkeyword = "<saw:text>"; int insertIndex = xmlIndividualColumnSection.LastIndexOf(startingkeyword) + startingkeyword.Length; int storeSecondPartIndex = xmlIndividualColumnSection.LastIndexOf("</saw:text>"); string firsPart = xmlIndividualColumnSection.Substring(0, insertIndex); string lastPart = xmlIndividualColumnSection.Substring(storeSecondPartIndex); string replacement = firsPart + column.CustomHeading + lastPart; int removingIndex = _xmlSections.ColumnIndividualData_ColumnsSection.IndexOf(_xmlSections.ColumnIndividualData_ColumnsSection.FirstOrDefault(a => a.Contains(column.ID))); _xmlSections.ColumnIndividualData_ColumnsSection.RemoveAt(removingIndex); _xmlSections.ColumnIndividualData_ColumnsSection.Insert(removingIndex, replacement); } else { // saw text is not present but column heading is present if (!xmlIndividualColumnSection.Contains("<saw:tableHeading>")) { xmlIndividualColumnSection = clsUtility.insertStringInStringBeforeKeyword(xmlIndividualColumnSection, "<saw:tableHeading> <saw:caption fmt=\"text\"><saw:text>" + column.FolderName + "</saw:text></saw:caption></saw:tableHeading>", "<saw:columnHeading>"); } string updatedXmlColumnSection = clsUtility.insertStringInStringBeforeKeyword(xmlIndividualColumnSection, "<saw:caption fmt=\"text\">" + "<saw:text>" + column.CustomHeading + "</saw:text></saw:caption>", "</saw:columnHeading>"); int removingIndex = _xmlSections.ColumnIndividualData_ColumnsSection.IndexOf(_xmlSections.ColumnIndividualData_ColumnsSection.FirstOrDefault(a => a.Contains(column.ID))); _xmlSections.ColumnIndividualData_ColumnsSection.RemoveAt(removingIndex); _xmlSections.ColumnIndividualData_ColumnsSection.Insert(removingIndex, updatedXmlColumnSection); } } else if (!string.IsNullOrWhiteSpace(column.CustomHeading)) { string customeHeadingSyntax = "<saw:tableHeading><saw:caption fmt=\"text\"><saw:text>" + column.FolderName + "</saw:text></saw:caption></saw:tableHeading><saw:columnHeading><saw:caption fmt=\"text\"><saw:text>" + column.CustomHeading + "</saw:text></saw:caption></saw:columnHeading>"; string strToInsert = clsUtility.insertStringInStringBeforeKeyword(xmlIndividualColumnSection, customeHeadingSyntax, "</saw:column>"); int removingIndex = _xmlSections.ColumnIndividualData_ColumnsSection.IndexOf(_xmlSections.ColumnIndividualData_ColumnsSection.FirstOrDefault(a => a.Contains(column.ID))); _xmlSections.ColumnIndividualData_ColumnsSection.RemoveAt(removingIndex); _xmlSections.ColumnIndividualData_ColumnsSection.Insert(removingIndex, strToInsert); } }
private void updateXmlColumnDateFormatDDMMYYY(clsColumn column, string xmlIndividualColumnSection) { string updatedXmlIndividualColumnSection = null; if (column.DateFormat_DDMMYYYY == false && !xmlIndividualColumnSection.Contains("<saw:dataFormat ")) return; if (column.DateFormat_DDMMYYYY == true && xmlIndividualColumnSection.Contains("customFormat=\"DD/MM/YYYY\"")) return; if (xmlIndividualColumnSection.Contains("customFormat=\"DD/MM/YYYY\"") && column.DateFormat_DDMMYYYY == false) updatedXmlIndividualColumnSection = deleteXmlDateFormatSyntax(xmlIndividualColumnSection); if (!xmlIndividualColumnSection.Contains("customFormat=\"DD/MM/YYYY\"") && column.DateFormat_DDMMYYYY == true) updatedXmlIndividualColumnSection = updateAndInsertXmlDateFormat_DDMMYYYY(xmlIndividualColumnSection); int removingIndex = _xmlSections.ColumnIndividualData_ColumnsSection.IndexOf(_xmlSections.ColumnIndividualData_ColumnsSection.FirstOrDefault(a => a.Contains(column.ID))); _xmlSections.ColumnIndividualData_ColumnsSection.RemoveAt(removingIndex); _xmlSections.ColumnIndividualData_ColumnsSection.Insert(removingIndex, updatedXmlIndividualColumnSection); }