/// <summary> /// Gets the content of the item. /// </summary> /// <param name="row">The row.</param> /// <param name="itemExportProperty">The item export property.</param> /// <returns></returns> private static string GetItemContent(IRow row, GeoRSSExportItem itemExportProperty) { string itemContent = null; try { if (!string.IsNullOrEmpty(itemExportProperty.FixedContent)) { itemContent = itemExportProperty.FixedContent; } if (!string.IsNullOrEmpty(itemExportProperty.MappedContent)) { StringBuilder content = new StringBuilder(); bool multiContent = false; //check for pre and post conditions if (!string.IsNullOrEmpty(itemExportProperty.PreConditon)) content.Append(itemExportProperty.PreConditon); //mapped content supports multiple fields - if there is more than one field supplied, display as html, using provided delimeter List<string> inputFields = itemExportProperty.MappedContent.Split(',').ToList(); //check if multiple fields if (inputFields.Count > 1) multiContent = true; //vaidate List<string> inputFieldAlias = null; if (multiContent) { inputFieldAlias = itemExportProperty.MappedContentAlias.Split(',').ToList(); if (inputFields.Count != inputFieldAlias.Count) throw new Exception("Mapped field count does not equal alias field count"); } for (int i = 0; i < inputFields.Count; i++) { int fieldIndex = row.Fields.FindField(inputFields[i]); if (row.get_Value(fieldIndex) != null) { var value = row.get_Value(fieldIndex); if (multiContent) { //include field alias and mapped delimeter content.Append(inputFieldAlias[i] + ": "); content.Append(Convert.ToString(value)); content.Append(itemExportProperty.MappedContentDelimeter); } else content.Append(Convert.ToString(value)); } } //foreach (string inputField in inputFields) //{ // int fieldIndex = row.Fields.FindField(inputField); // if (row.get_Value(fieldIndex) != null) // { // var value = row.get_Value(fieldIndex); // if (multiContent) // { // //include field alias and mapped delimeter // content.Append(row.Fields.Field[fieldIndex].AliasName + ": "); // content.Append(Convert.ToString(value)); // content.Append(itemExportProperty.MappedContentDelimeter); // } // else // content.Append(Convert.ToString(value)); // } //} //apply post condition if required if (!string.IsNullOrEmpty(itemExportProperty.PostCondition)) content.Append(itemExportProperty.PostCondition); itemContent = content.ToString(); } return itemContent; } catch (Exception ex) { Exporter.logger.LogMessage(ESRI.ArcGIS.SOESupport.ServerLogger.msgType.error, "GetItemContent", 999999, "Item Export Property Mapped Content:" + itemExportProperty.MappedContent + "Item Export Property Mapped Content Alias:" + itemExportProperty.MappedContentAlias + "Item Export Property Fixed Content:" + itemExportProperty.FixedContent + "Error Message: " + ex.Message.ToString()); for (int r = 0; r < row.Fields.FieldCount; r++) { IField field = row.Fields.get_Field(r); Exporter.logger.LogMessage(ESRI.ArcGIS.SOESupport.ServerLogger.msgType.infoDetailed, "GetItemContent", 999999, "field Name: " + field.Name + "field alias: " + field.AliasName ); } throw ex; } finally { } }
private static void SetItemValues(IRow row, ref SyndicationItem item, KeyValuePair<string, GeoRSSExportItem> itemConfig, GeoRSSExportItem itemExportProperty) { try { //Title if (itemConfig.Key == "Title") item.Title = new TextSyndicationContent(GetItemContent(row, itemExportProperty)); //Content if (itemConfig.Key == "Content") item.Content = new TextSyndicationContent(GetItemContent(row, itemExportProperty)); //Author //todo - we only currently support author as a single string, assume to be name - better to support all author properties i.e. //authorName //authorEmail //authorUri if (itemConfig.Key == "Author") { SyndicationPerson author = new SyndicationPerson(); author.Name = GetItemContent(row, itemExportProperty); item.Authors.Add(author); } //Contributors //todo - we only currently support author as a single string, assume to be name - better to support all author properties i.e. //controbutorName //controbutorEmail //controbutorNameUri if (itemConfig.Key == "Contributors") { SyndicationPerson author = new SyndicationPerson(); author.Name = GetItemContent(row, itemExportProperty); item.Contributors.Add(author); } //Copyright if (itemConfig.Key == "Copyright") item.Copyright = new TextSyndicationContent(GetItemContent(row, itemExportProperty)); //Id if (itemConfig.Key == "Id") { if (itemExportProperty.AutoGenerate) item.Id = Guid.NewGuid().ToString(); else item.Id = GetItemContent(row, itemExportProperty); } //PublishDate if (itemConfig.Key == "PublishDate") { if (itemExportProperty.AutoGenerate) item.PublishDate = DateTime.Now; else item.PublishDate = Convert.ToDateTime(GetItemContent(row, itemExportProperty)); } //LastUpdatedTime if (itemConfig.Key == "LastUpdatedTime") { if (itemExportProperty.AutoGenerate) item.LastUpdatedTime = DateTime.Now; else item.LastUpdatedTime = Convert.ToDateTime(GetItemContent(row, itemExportProperty)); } //Links //todo - we only currently support link as a single string, assume to be uri - better to support all link properties if (itemConfig.Key == "Links") { SyndicationLink link = new SyndicationLink(); link.Uri = new Uri(GetItemContent(row, itemExportProperty)); item.Links.Add(link); } //Summary if (itemConfig.Key == "Summary") //item.Summary = new TextSyndicationContent(GetItemContent(row, itemExportProperty)); item.Summary = SyndicationContent.CreateHtmlContent(GetItemContent(row, itemExportProperty)); } catch (Exception ex) { Exporter.logger.LogMessage(ESRI.ArcGIS.SOESupport.ServerLogger.msgType.error, "SetItenValues", 999999, "Item Config Key:" + itemConfig.Key + "Error Message: " + ex.Message.ToString()); } finally { } }