/// <summary> /// Map the information sent back by Campaign into a format which can be saved as a file to disk. /// </summary> /// <param name="requestHandler">Request handler, which can be used if further information from Campaign is required for the mapping.</param> /// <param name="rawQueryResponse">Raw response from Campaign.</param> /// <returns>Class containing file content and metadata</returns> public override Template ParseQueryResponse(IRequestHandler requestHandler, string rawQueryResponse) { var doc = new XmlDocument(); doc.LoadXml(rawQueryResponse); var metadata = new TemplateMetadata { Schema = InternalName.Parse(Schema), Name = new InternalName(doc.DocumentElement.Attributes["namespace"].InnerText, doc.DocumentElement.Attributes["name"].InnerText), }; var labelNode = doc.DocumentElement.Attributes["label"]; if (labelNode != null) { metadata.Label = labelNode.InnerText; } var codeNode = doc.DocumentElement.SelectSingleNode("data"); var rawCode = codeNode == null ? string.Empty : codeNode.InnerText; return(new Template { Code = rawCode, Metadata = metadata, FileExtension = FileTypes.JavaScript, }); }
/// <summary> /// Map the information sent back by Campaign into a format which can be saved as a file to disk. /// </summary> /// <param name="requestHandler">Request handler, which can be used if further information from Campaign is required for the mapping.</param> /// <param name="rawQueryResponse">Raw response from Campaign.</param> /// <returns>Class containing file content and metadata</returns> public override Template ParseQueryResponse(IRequestHandler requestHandler, string rawQueryResponse) { var doc = new XmlDocument(); doc.LoadXml(rawQueryResponse); var metadata = new TemplateMetadata { Schema = InternalName.Parse(Schema), Name = new InternalName(null, doc.DocumentElement.Attributes["internalName"].InnerText), Label = doc.DocumentElement.Attributes["label"].InnerText, }; var folderInternalName = doc.DocumentElement.SelectSingleNode("folder").Attributes["name"].InnerText; metadata.AdditionalProperties.Add(AdditionalData_Folder, folderInternalName); doc.DocumentElement.RemoveAllAttributesExcept(AttributesToKeep); doc.DocumentElement.RemoveChild("createdBy"); doc.DocumentElement.RemoveChild("modifiedBy"); // Substitute delivery internal name for id in each delivery activity. var deliveryActions = doc.DocumentElement.SelectNodes("activities/delivery"); if (deliveryActions != null) { foreach (XmlElement deliveryAction in deliveryActions) { var deliveryIdAttr = deliveryAction.Attributes["scenario-id"]; if (deliveryIdAttr == null) { continue; } int deliveryId; if (!int.TryParse(deliveryIdAttr.Value, out deliveryId)) { continue; } var deliveryInternalName = GetDeliveryInternalName(requestHandler, deliveryId); if (deliveryInternalName == null) { continue; } deliveryAction.Attributes.Remove(deliveryIdAttr); deliveryAction.AppendAttribute("scenario-internalName", deliveryInternalName); } } var rawCode = doc.OuterXml; return(new Template { Code = rawCode, Metadata = metadata, FileExtension = FileTypes.Xml, }); }
public void ParseTest(string raw, bool valid, string expectedNamespace, string expectedName) { InternalName internalName; try { internalName = InternalName.Parse(raw); } catch { internalName = null; } if (!valid) { Assert.IsNull(internalName); } else if (internalName == null) { Assert.Fail("Valid name, but failed to parse"); } else { Assert.AreEqual(expectedNamespace, internalName.Namespace); Assert.AreEqual(expectedName, internalName.Name); Assert.AreEqual(raw, internalName.ToString()); } }
/// <summary> /// Map the information sent back by Campaign into a format which can be saved as a file to disk. /// </summary> /// <param name="requestHandler">Request handler, which can be used if further information from Campaign is required for the mapping.</param> /// <param name="rawQueryResponse">Raw response from Campaign.</param> /// <returns>Class containing file content and metadata</returns> public override Template ParseQueryResponse(IRequestHandler requestHandler, string rawQueryResponse) { var doc = new XmlDocument(); doc.LoadXml(rawQueryResponse); var metadata = new TemplateMetadata { Schema = InternalName.Parse(Schema), Name = new InternalName(doc.DocumentElement.Attributes["namespace"].InnerText, doc.DocumentElement.Attributes["name"].InnerText), Label = doc.DocumentElement.Attributes["label"].InnerText, }; doc.DocumentElement.RemoveAllAttributesExcept(AttributesToKeep); doc.DocumentElement.RemoveChild("createdBy"); doc.DocumentElement.RemoveChild("modifiedBy"); var rawCode = doc.OuterXml; return(new Template { Code = rawCode, Metadata = metadata, FileExtension = FileTypes.Xml, }); }
/// <summary> /// Map the information sent back by Campaign into a format which can be saved as a file to disk. /// </summary> /// <param name="requestHandler">Request handler, which can be used if further information from Campaign is required for the mapping.</param> /// <param name="rawQueryResponse">Raw response from Campaign.</param> /// <returns>Class containing file content and metadata</returns> public override Template ParseQueryResponse(IRequestHandler requestHandler, string rawQueryResponse) { var doc = new XmlDocument(); doc.LoadXml(rawQueryResponse); var metadata = new TemplateMetadata { Schema = InternalName.Parse(IncludeView.EntitySchema), Name = new InternalName(null, doc.DocumentElement.Attributes["name"].InnerText), Label = doc.DocumentElement.Attributes["label"].InnerText, }; var folderInternalName = doc.DocumentElement.SelectSingleNode("folder").Attributes["name"].InnerText; metadata.AdditionalProperties.Add(AdditionalData_Folder, folderInternalName); var visibleAttribute = doc.DocumentElement.Attributes["visible"]; if (visibleAttribute != null) { metadata.AdditionalProperties.Add(AdditionalData_Visible, (visibleAttribute.InnerText == "1").ToString()); } var textCodeNode = doc.DocumentElement.SelectSingleNode("source/text"); var rawTextCode = textCodeNode == null ? string.Empty : textCodeNode.InnerText; var htmlCodeNode = doc.DocumentElement.SelectSingleNode("source/html"); var rawHtmlCode = htmlCodeNode == null ? string.Empty : htmlCodeNode.InnerText; var dependOnFormat = false; var dependOnFormatAttribute = doc.DocumentElement.SelectSingleNode("source/@dependOnFormat"); if (dependOnFormatAttribute != null) { dependOnFormat = dependOnFormatAttribute.InnerText == "true"; } var rawCode = dependOnFormat ? string.Concat(rawTextCode, Environment.NewLine, Environment.NewLine, FormatSeparator, Environment.NewLine, Environment.NewLine, rawHtmlCode) : rawTextCode; return(new Template { Code = rawCode, Metadata = metadata, FileExtension = FileTypes.Jssp, }); }
/// <summary> /// Map the information sent back by Campaign into a format which can be saved as a file to disk. /// </summary> /// <param name="requestHandler">Request handler, which can be used if further information from Campaign is required for the mapping.</param> /// <param name="rawQueryResponse">Raw response from Campaign.</param> /// <returns>Class containing file content and metadata</returns> public override Template ParseQueryResponse(IRequestHandler requestHandler, string rawQueryResponse) { var doc = new XmlDocument(); doc.LoadXml(rawQueryResponse); var metadata = new TemplateMetadata { Schema = InternalName.Parse(Schema), Name = new InternalName(null, doc.DocumentElement.Attributes["name"].InnerText), }; var option = new Option { DataType = (DataType)int.Parse(doc.DocumentElement.Attributes["dataType"].InnerText), StringValue = doc.DocumentElement.Attributes["stringValue"].InnerText, MemoValue = doc.DocumentElement.SelectSingleNode("memoValue").InnerText, }; long longValue; if (long.TryParse(doc.DocumentElement.Attributes["longValue"].InnerText, out longValue)) { option.LongValue = longValue; } double doubleValue; if (double.TryParse(doc.DocumentElement.Attributes["doubleValue"].InnerText, out doubleValue)) { option.DoubleValue = doubleValue; } DateTime timeStampValue; if (DateTime.TryParse(doc.DocumentElement.Attributes["timeStampValue"].InnerText, out timeStampValue)) { option.TimeStampValue = timeStampValue; } metadata.AdditionalProperties.Add(AdditionalData_DataType, option.DataType.ToString()); return(new Template { Code = Convert.ToString(option.GetValue()), Metadata = metadata, FileExtension = FileTypes.Jssp, }); }