public static string GetContentByTableStyle(string content, string separator, SiteInfo siteInfo, TableStyleInfo styleInfo, string formatString, Dictionary <string, string> attributes, string innerXml, bool isStlEntity) { var parsedContent = content; var inputType = styleInfo.InputType; if (inputType == InputType.Date) { var dateTime = TranslateUtils.ToDateTime(content); if (dateTime != DateUtils.SqlMinValue) { if (string.IsNullOrEmpty(formatString)) { formatString = DateUtils.FormatStringDateOnly; } parsedContent = DateUtils.Format(dateTime, formatString); } else { parsedContent = string.Empty; } } else if (inputType == InputType.DateTime) { var dateTime = TranslateUtils.ToDateTime(content); if (dateTime != DateUtils.SqlMinValue) { if (string.IsNullOrEmpty(formatString)) { formatString = DateUtils.FormatStringDateTime; } parsedContent = DateUtils.Format(dateTime, formatString); } else { parsedContent = string.Empty; } } else if (inputType == InputType.CheckBox || inputType == InputType.Radio || inputType == InputType.SelectMultiple || inputType == InputType.SelectOne)//选择类型 { var selectedTexts = new ArrayList(); var selectedValues = TranslateUtils.StringCollectionToStringList(content); var styleItems = styleInfo.StyleItems ?? DataProvider.TableStyleItemDao.GetStyleItemInfoList(styleInfo.Id); foreach (var itemInfo in styleItems) { if (selectedValues.Contains(itemInfo.ItemValue)) { selectedTexts.Add(isStlEntity ? itemInfo.ItemValue : itemInfo.ItemTitle); } } parsedContent = separator == null?TranslateUtils.ObjectCollectionToString(selectedTexts) : TranslateUtils.ObjectCollectionToString(selectedTexts, separator); } //else if (styleInfo.InputType == InputType.TextArea) //{ // parsedContent = StringUtils.ReplaceNewlineToBR(parsedContent); //} else if (inputType == InputType.TextEditor) { parsedContent = ContentUtility.TextEditorContentDecode(siteInfo, parsedContent, true); } else if (inputType == InputType.Image) { parsedContent = GetImageOrFlashHtml(siteInfo, parsedContent, attributes, isStlEntity); } else if (inputType == InputType.Video) { parsedContent = GetVideoHtml(siteInfo, parsedContent, attributes, isStlEntity); } else if (inputType == InputType.File) { parsedContent = GetFileHtmlWithoutCount(siteInfo, parsedContent, attributes, innerXml, isStlEntity); } return(parsedContent); }
public static string GetContentByTableStyle(ContentInfo contentInfo, string separator, SiteInfo siteInfo, TableStyleInfo styleInfo, string formatString, int no, Dictionary <string, string> attributes, string innerXml, bool isStlEntity) { var value = contentInfo.GetString(styleInfo.AttributeName); var parsedContent = string.Empty; var inputType = styleInfo.InputType; if (inputType == InputType.Date) { var dateTime = TranslateUtils.ToDateTime(value); if (dateTime != DateUtils.SqlMinValue) { if (string.IsNullOrEmpty(formatString)) { formatString = DateUtils.FormatStringDateOnly; } parsedContent = DateUtils.Format(dateTime, formatString); } } else if (inputType == InputType.DateTime) { var dateTime = TranslateUtils.ToDateTime(value); if (dateTime != DateUtils.SqlMinValue) { if (string.IsNullOrEmpty(formatString)) { formatString = DateUtils.FormatStringDateTime; } parsedContent = DateUtils.Format(dateTime, formatString); } } else if (inputType == InputType.CheckBox || inputType == InputType.Radio || inputType == InputType.SelectMultiple || inputType == InputType.SelectOne)//选择类型 { var selectedTexts = new ArrayList(); var selectedValues = TranslateUtils.StringCollectionToStringList(value); var styleItems = styleInfo.StyleItems ?? DataProvider.TableStyleItemDao.GetStyleItemInfoList(styleInfo.Id); foreach (var itemInfo in styleItems) { if (selectedValues.Contains(itemInfo.ItemValue)) { selectedTexts.Add(isStlEntity ? itemInfo.ItemValue : itemInfo.ItemTitle); } } parsedContent = separator == null?TranslateUtils.ObjectCollectionToString(selectedTexts) : TranslateUtils.ObjectCollectionToString(selectedTexts, separator); } else if (inputType == InputType.TextEditor) { parsedContent = ContentUtility.TextEditorContentDecode(siteInfo, value, true); } else if (inputType == InputType.Image) { if (no <= 1) { parsedContent = GetImageOrFlashHtml(siteInfo, value, attributes, isStlEntity); } else { var extendAttributeName = ContentAttribute.GetExtendAttributeName(styleInfo.AttributeName); var extendValues = contentInfo.GetString(extendAttributeName); if (!string.IsNullOrEmpty(extendValues)) { var index = 2; foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues)) { if (index == no) { parsedContent = GetImageOrFlashHtml(siteInfo, extendValue, attributes, isStlEntity); break; } index++; } } } } else if (inputType == InputType.Video) { if (no <= 1) { parsedContent = GetVideoHtml(siteInfo, value, attributes, isStlEntity); } else { var extendAttributeName = ContentAttribute.GetExtendAttributeName(styleInfo.AttributeName); var extendValues = contentInfo.GetString(extendAttributeName); if (!string.IsNullOrEmpty(extendValues)) { var index = 2; foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues)) { if (index == no) { parsedContent = GetVideoHtml(siteInfo, extendValue, attributes, isStlEntity); break; } index++; } } } } else if (inputType == InputType.File) { if (no <= 1) { parsedContent = GetFileHtmlWithoutCount(siteInfo, value, attributes, innerXml, isStlEntity); } else { var extendAttributeName = ContentAttribute.GetExtendAttributeName(styleInfo.AttributeName); var extendValues = contentInfo.GetString(extendAttributeName); if (!string.IsNullOrEmpty(extendValues)) { var index = 2; foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues)) { if (index == no) { parsedContent = GetFileHtmlWithoutCount(siteInfo, extendValue, attributes, innerXml, isStlEntity); break; } index++; } } } } else { parsedContent = value; } return(parsedContent); }