private void ProcessRange(ProcessingInstruction processingInstruction) { var sqlParameters = new SqlParameter[2]; var pair = processingInstruction.Range.Split(new[] { '-' }, StringSplitOptions.RemoveEmptyEntries); sqlParameters[0] = new SqlParameter("@RangeStart", Convert.ToInt32(pair[0])); sqlParameters[1] = new SqlParameter("@RangeEnd", Convert.ToInt32(pair[1])); var identifier = string.Format("{0}_{1}_{2}", processingInstruction.Catalog, sqlParameters[0].Value, sqlParameters[1].Value); try { var startDt = DateTime.Now; Log.DebugFormat("[{0}] start", identifier); var counters = ProcessFeed(processingInstruction.Catalog, processingInstruction.Dbcmd, sqlParameters, identifier, processingInstruction.CatalogAttributesSection); var hasError = counters.NumberOfErrored > 0 && !counters.AllowErrors; if (hasError) { _hasError = true; } var endDt = DateTime.Now; var execTime = endDt - startDt; Log.InfoFormat("[{0}] completed with result {2}. Execution time in seconds: {1}", identifier, execTime.TotalSeconds, !hasError); _executionInformation.AddFileGenerationUpdate(counters); } catch (Exception ex) { Log.InfoFormat("[Feed] {0}; error {1}", processingInstruction.Catalog + "-" + pair[0] + pair[1], ex); _executionInformation.AddFileGenerationUpdate(identifier, false); _hasError = true; } }
private ProcessingInstruction GenerateCADProcessingInstructions(ASContext asContext, ProcessingInstruction previousPi, bool isFirstRequestForProcessingInstructions) { ProcessingInstruction nextPi = null; if (isFirstRequestForProcessingInstructions) { // Step 1 - attribute data in xml file to delegate processor for indexing nextPi = GenerateFirstCADIndexInstruction(asContext); // nextPi = GenerateFileReplaceInstruction(previousPi); } else if (Constants.Steps.KeyInStep == previousPi.Step) { // Step 2 - replace the file nextPi = GenerateFileReplaceInstruction(previousPi); } else if (Constants.Steps.ReplaceFileStep == previousPi.Step) { // Step 3 - to exit for reporting and cleanup nextPi = GenerateExitInstruction(previousPi); } else { // Don't understand the previous step, do nothing. nextPi = null; } return(nextPi); }
private List <ProcessingInstruction> GetRanges() { var ranges = new List <ProcessingInstruction>(); foreach (var instructionEntry in FeedGenerationInstructionsDictionary) { var isIncluded = bool.Parse(instructionEntry.Value["isincluded"]); var catalog = instructionEntry.Value["catalog"]; if (!isIncluded) { Log.InfoFormat("Catalog [{0}] excluded from feed generation", catalog); continue; } var dbcmd = instructionEntry.Value["dbcmd"]; var catalogattributesection = instructionEntry.Value["catalogattributesection"]; var feedSplitter = instructionEntry.Value["splitter"]; var baseProcessingInstruction = new ProcessingInstruction { Catalog = catalog, CatalogAttributesSection = catalogattributesection, Dbcmd = dbcmd }; foreach (var range in feedSplitter.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)) { baseProcessingInstruction.Range = range; ranges.Add(baseProcessingInstruction); } } return(ranges); }
public void ValidateDailyTransactionDetailLookup() { DLSMapper.Configure(); var request = new DailyTransactionDetailLookupRequest() { AgentId = "40698809", PosId = "", StartDate = "09/27/2017" }; var header = new Header(); var processingInstruction = new ProcessingInstruction { Action = "DailyTransactionDetailLookup", RollbackTransaction = false }; header.ProcessingInstruction = processingInstruction; request.header = header; request.header = header; var config = new DLSConfig(); var proxy = new DLSProxyFactory(config); var repo = new DLSRepository(proxy); var x = repo.DailyTransactionDetailLookup(false, request); }
private void ProcessRange(ProcessingInstruction processingInstruction) { var sqlParameters = new SqlParameter[2]; var pair = processingInstruction.Range.Split(new[] { '-' }, StringSplitOptions.RemoveEmptyEntries); sqlParameters[0] = new SqlParameter("@PIDRangeStart", Convert.ToInt32(pair[0])); sqlParameters[1] = new SqlParameter("@PIDRangeEnd ", Convert.ToInt32(pair[1])); var identifier = string.Format("{0}_{1}_{2}", processingInstruction.Catalog, sqlParameters[0].Value, sqlParameters[1].Value); try { var startDt = DateTime.Now; Log.DebugFormat("[{0}] start", identifier); WriteFeed(processingInstruction.Catalog, processingInstruction.Dbcmd, sqlParameters, identifier, processingInstruction.CatalogAttributesSection); var endDt = DateTime.Now; var execTime = endDt - startDt; Log.InfoFormat("[{0}] completed. Execution time in seconds: {1}", identifier, execTime.TotalSeconds); _executionLogLogger.AddFileGenerationUpdate(PlaRelatedFeedUtils.GetFeedFileName(identifier), true); } catch (Exception ex) { Log.InfoFormat("[Feed] {0}; error {1}", processingInstruction.Catalog + "-" + pair[0] + pair[1], ex); _executionLogLogger.AddFileGenerationUpdate(PlaRelatedFeedUtils.GetFeedFileName(identifier), false); if (HasTwoGenerators()) { _executionLogLoggerSecondary.AddFileGenerationUpdate(PlaRelatedFeedUtils.GetFeedFileName(identifier), false); } _hasError = true; } }
DOMProcessingInstruction createWrapper(ProcessingInstruction node) { DOMProcessingInstruction wrapper = new DOMProcessingInstruction(this, node); _wrapperMap.put(node, wrapper); return wrapper; }
public ProcessingInstruction ToElement() { var pi = new ProcessingInstruction(); pi.Data = _content; pi.Target = _target; return(pi); }
private ProcessingInstruction GenerateExitInstruction(ProcessingInstruction previousPi) { ExitInstruction ei = new ExitInstruction(true, "complete"); LogServer.Log(LogServer.LogASConstants.AutomationServicesLoggerNamespace, LogServer.LogASConstants.LAYER_SmartDispatcher, LogServer.LEVEL_Info, "Creating Exit Instruction"); ei.DocumentProcessorName = DocumentProcessorName; ei.DocumentProcessorGuid = DocumentProcessorGuid.ToString(); return(ei); }
private ProcessingInstruction GenerateFileReplaceInstruction(ProcessingInstruction previousPi) { DelegateInstruction di = new DelegateInstruction(); LogServer.Log(LogServer.LogASConstants.AutomationServicesLoggerNamespace, LogServer.LogASConstants.LAYER_SmartDispatcher, LogServer.LEVEL_Info, "Creating Replace Instruction"); di.DocumentProcessorName = DocumentProcessorName; di.DocumentProcessorGuid = DocumentProcessorGuid.ToString(); di.Step = Constants.Steps.ReplaceFileStep; return(di); }
/// <summary> /// Gives the smart dispatcher the sequence of steps needed to index widgets. /// </summary> /// <param name="asContext">Automation Services context object</param> /// <param name="previousPi">The previous step</param> /// <param name="isFirstRequestForProcessingInstructions">First step?</param> /// <returns>The next processing instruction to execute</returns> public override ProcessingInstruction GenerateProcessingInstructions ( ASContext asContext, ProcessingInstruction previousPi, bool isFirstRequestForProcessingInstructions ) { ProcessingInstruction nextPi = GenerateCADProcessingInstructions(asContext, previousPi, isFirstRequestForProcessingInstructions); return(nextPi); }
private string GetAgentPassword(string agentId, string posNumber) { var agentPasswordRequest = new AgentPasswordRequest { AgentId = decimal.Parse(agentId), AgentIdSpecified = true, PosNumber = decimal.Parse(posNumber), PosNumberSpecified = true }; var agentPasswordRequestHeader = new Header(); var agentPasswordProcessingInstruction = new ProcessingInstruction { Action = "GetAgentPassword", RollbackTransaction = false }; agentPasswordRequestHeader.ProcessingInstruction = agentPasswordProcessingInstruction; agentPasswordRequest.header = agentPasswordRequestHeader; var getAgentPasswordResp = partnerServiceIntegration.GetAgentPassword(agentPasswordRequest); return(getAgentPasswordResp.AgentPassword); }
public static void AddComment(this Document parent, HtmlToken token) { parent.AddNode(token.IsProcessingInstruction ? (Node)ProcessingInstruction.Create(parent, token.Data) : new Comment(parent, token.Data)); }
/// <summary>Converts the given annotation to an XML document using the specified options</summary> public static Document AnnotationToDoc(Annotation annotation, AnnotationOutputter.Options options) { // // create the XML document with the root node pointing to the namespace URL // Element root = new Element("root", NamespaceUri); Document xmlDoc = new Document(root); ProcessingInstruction pi = new ProcessingInstruction("xml-stylesheet", "href=\"" + StylesheetName + "\" type=\"text/xsl\""); xmlDoc.InsertChild(pi, 0); Element docElem = new Element("document", NamespaceUri); root.AppendChild(docElem); SetSingleElement(docElem, "docId", NamespaceUri, annotation.Get(typeof(CoreAnnotations.DocIDAnnotation))); SetSingleElement(docElem, "docDate", NamespaceUri, annotation.Get(typeof(CoreAnnotations.DocDateAnnotation))); SetSingleElement(docElem, "docSourceType", NamespaceUri, annotation.Get(typeof(CoreAnnotations.DocSourceTypeAnnotation))); SetSingleElement(docElem, "docType", NamespaceUri, annotation.Get(typeof(CoreAnnotations.DocTypeAnnotation))); SetSingleElement(docElem, "author", NamespaceUri, annotation.Get(typeof(CoreAnnotations.AuthorAnnotation))); SetSingleElement(docElem, "location", NamespaceUri, annotation.Get(typeof(CoreAnnotations.LocationAnnotation))); if (options.includeText) { SetSingleElement(docElem, "text", NamespaceUri, annotation.Get(typeof(CoreAnnotations.TextAnnotation))); } Element sentencesElem = new Element("sentences", NamespaceUri); docElem.AppendChild(sentencesElem); // // save the info for each sentence in this doc // if (annotation.Get(typeof(CoreAnnotations.SentencesAnnotation)) != null) { int sentCount = 1; foreach (ICoreMap sentence in annotation.Get(typeof(CoreAnnotations.SentencesAnnotation))) { Element sentElem = new Element("sentence", NamespaceUri); sentElem.AddAttribute(new Attribute("id", int.ToString(sentCount))); int lineNumber = sentence.Get(typeof(CoreAnnotations.LineNumberAnnotation)); if (lineNumber != null) { sentElem.AddAttribute(new Attribute("line", int.ToString(lineNumber))); } sentCount++; // add the word table with all token-level annotations Element wordTable = new Element("tokens", NamespaceUri); IList <CoreLabel> tokens = sentence.Get(typeof(CoreAnnotations.TokensAnnotation)); for (int j = 0; j < tokens.Count; j++) { Element wordInfo = new Element("token", NamespaceUri); AddWordInfo(wordInfo, tokens[j], j + 1, NamespaceUri); wordTable.AppendChild(wordInfo); } sentElem.AppendChild(wordTable); // add tree info Tree tree = sentence.Get(typeof(TreeCoreAnnotations.TreeAnnotation)); if (tree != null) { // add the constituent tree for this sentence Element parseInfo = new Element("parse", NamespaceUri); AddConstituentTreeInfo(parseInfo, tree, options.constituentTreePrinter); sentElem.AppendChild(parseInfo); } SemanticGraph basicDependencies = sentence.Get(typeof(SemanticGraphCoreAnnotations.BasicDependenciesAnnotation)); if (basicDependencies != null) { // add the dependencies for this sentence Element depInfo = BuildDependencyTreeInfo("basic-dependencies", sentence.Get(typeof(SemanticGraphCoreAnnotations.BasicDependenciesAnnotation)), tokens, NamespaceUri); if (depInfo != null) { sentElem.AppendChild(depInfo); } depInfo = BuildDependencyTreeInfo("collapsed-dependencies", sentence.Get(typeof(SemanticGraphCoreAnnotations.CollapsedDependenciesAnnotation)), tokens, NamespaceUri); if (depInfo != null) { sentElem.AppendChild(depInfo); } depInfo = BuildDependencyTreeInfo("collapsed-ccprocessed-dependencies", sentence.Get(typeof(SemanticGraphCoreAnnotations.CollapsedCCProcessedDependenciesAnnotation)), tokens, NamespaceUri); if (depInfo != null) { sentElem.AppendChild(depInfo); } depInfo = BuildDependencyTreeInfo("enhanced-dependencies", sentence.Get(typeof(SemanticGraphCoreAnnotations.EnhancedDependenciesAnnotation)), tokens, NamespaceUri); if (depInfo != null) { sentElem.AppendChild(depInfo); } depInfo = BuildDependencyTreeInfo("enhanced-plus-plus-dependencies", sentence.Get(typeof(SemanticGraphCoreAnnotations.EnhancedPlusPlusDependenciesAnnotation)), tokens, NamespaceUri); if (depInfo != null) { sentElem.AppendChild(depInfo); } } // add Open IE triples ICollection <RelationTriple> openieTriples = sentence.Get(typeof(NaturalLogicAnnotations.RelationTriplesAnnotation)); if (openieTriples != null) { Element openieElem = new Element("openie", NamespaceUri); AddTriples(openieTriples, openieElem, NamespaceUri); sentElem.AppendChild(openieElem); } // add KBP triples ICollection <RelationTriple> kbpTriples = sentence.Get(typeof(CoreAnnotations.KBPTriplesAnnotation)); if (kbpTriples != null) { Element kbpElem = new Element("kbp", NamespaceUri); AddTriples(kbpTriples, kbpElem, NamespaceUri); sentElem.AppendChild(kbpElem); } // add the MR entities and relations IList <EntityMention> entities = sentence.Get(typeof(MachineReadingAnnotations.EntityMentionsAnnotation)); IList <RelationMention> relations = sentence.Get(typeof(MachineReadingAnnotations.RelationMentionsAnnotation)); if (entities != null && !entities.IsEmpty()) { Element mrElem = new Element("MachineReading", NamespaceUri); Element entElem = new Element("entities", NamespaceUri); AddEntities(entities, entElem, NamespaceUri); mrElem.AppendChild(entElem); if (relations != null) { Element relElem = new Element("relations", NamespaceUri); AddRelations(relations, relElem, NamespaceUri, options.relationsBeam); mrElem.AppendChild(relElem); } sentElem.AppendChild(mrElem); } // Adds sentiment as an attribute of this sentence. Tree sentimentTree = sentence.Get(typeof(SentimentCoreAnnotations.SentimentAnnotatedTree)); if (sentimentTree != null) { int sentiment = RNNCoreAnnotations.GetPredictedClass(sentimentTree); sentElem.AddAttribute(new Attribute("sentimentValue", int.ToString(sentiment))); string sentimentClass = sentence.Get(typeof(SentimentCoreAnnotations.SentimentClass)); sentElem.AddAttribute(new Attribute("sentiment", sentimentClass.ReplaceAll(" ", string.Empty))); } // add the sentence to the root sentencesElem.AppendChild(sentElem); } } // // add the coref graph // IDictionary <int, CorefChain> corefChains = annotation.Get(typeof(CorefCoreAnnotations.CorefChainAnnotation)); if (corefChains != null) { IList <ICoreMap> sentences = annotation.Get(typeof(CoreAnnotations.SentencesAnnotation)); Element corefInfo = new Element("coreference", NamespaceUri); AddCorefGraphInfo(options, corefInfo, sentences, corefChains, NamespaceUri); docElem.AppendChild(corefInfo); } // // save any document-level annotations here // return(xmlDoc); }
public void TypeGet() { ProcessingInstruction target = new ProcessingInstruction(); Assert.AreEqual(NodeType.ProcessingInstruction, target.Type); }
internal DomProcessingInstruction(ProcessingInstruction node) : base(node.Name, node.Value, (XmlDocument)node.Document.XmlNode) { _node = node; }
public override void ProcessingInstruction(string arg0, string arg1) { ProcessingInstruction pi=new ProcessingInstruction(); pi.target=arg0; pi.data=arg1; getCurrentNode().appendChild(pi); }
internal void AddProcessingInstruction(ProcessingInstruction pi) { _nodes.Add(pi); _pis.Add(pi); }
public void Parse(StreamReader streamReader) { ParseState state = ParseState.Outside; bool parseCancelled = false; int depth = 0; string buffer = streamReader.ReadToEnd(); char[] c = buffer.ToCharArray(); char attrQuoteChar = '\0'; int i = -1; string elementName = ""; string attrName = ""; Dictionary <string, string> attributes = new Dictionary <string, string>(); bool documentStarted = false; bool tokenComplete = false; StringBuilder token = new StringBuilder(); while (++i < c.Length && !parseCancelled) { char cc = c[i]; // current char switch (state) { case ParseState.Outside: if (cc == '<') { documentStarted = true; StartDocument?.Invoke(); state = ParseState.LessThan; } else { token.Append(cc); } break; case ParseState.LessThan: if (char.IsWhiteSpace(cc)) { // do nothing } else if (MayStartXmlName(cc)) { elementName = ""; attributes = new Dictionary <string, string>(); token = new StringBuilder(cc.ToString()); state = ParseState.NewElementName; } else if (cc == '/') { tokenComplete = false; token = new StringBuilder(); state = ParseState.EndElementName; } else if (cc == '!') // !DOCTYPE or !CDATA[[ or !-- { var bang = new string(c.SubArray(i, 10)); if (bang.StartsWith("!DOCTYPE ")) { i += 8; token = new StringBuilder(); state = ParseState.DocType; } else if (bang.StartsWith("!CDATA[[")) { i += 7; token = new StringBuilder(); state = ParseState.CData; } else if (bang.StartsWith("!--")) { i += 2; token = new StringBuilder(); state = ParseState.Comment; } else { parseCancelled = RaiseError("Unexpected chars after <! : <" + c.SubArray(i, 5), i); } } else if (cc == '?') // ?xml declaration ? { if (new string(c.SubArray(i, 5)) == "?xml ") { i += 4; state = ParseState.XmlDeclaration; } else { state = ParseState.ProcessingInstruction; } } else { parseCancelled = RaiseError("Unexpected char '" + cc.ToString() + "' after <", i); } break; case ParseState.DocType: case ParseState.XmlDeclaration: if (cc == '>') { state = ParseState.Outside; } // Ignore anything else, until we get to '>' break; case ParseState.NewElementName: if (ValidInXmlName(cc)) { token.Append(cc); } else if (cc == '>') { elementName = token.ToString(); StartElement?.Invoke(elementName, attributes); depth++; token = new StringBuilder(); state = ParseState.InsideElement; } else if (cc == '/') { elementName = token.ToString(); state = ParseState.EmptyElement; } else if (cc == ' ') { elementName = token.ToString(); state = ParseState.SeekingAttrName; attributes = new Dictionary <string, string>(); } else { parseCancelled = RaiseError("Invalid char '" + cc.ToString() + "' in Element Name", i); } break; case ParseState.SeekingAttrName: if (char.IsWhiteSpace(cc)) { // do nothing } else if (MayStartXmlName(cc)) { token = new StringBuilder(cc.ToString()); state = ParseState.AttrName; } else if (cc == '/') { state = ParseState.EmptyElement; } else if (cc == '>') { StartElement?.Invoke(elementName, attributes); depth++; token = new StringBuilder(); state = ParseState.InsideElement; } else { parseCancelled = RaiseError("Invalid char '" + cc.ToString() + "' at start of Attribute Name", i); } break; case ParseState.AttrName: if (ValidInXmlName(cc)) { token.Append(cc); } else if (cc == ' ') { attrName = token.ToString(); token = new StringBuilder(); state = ParseState.SeekingEquals; } else if (cc == '=') { attrName = token.ToString(); token = new StringBuilder(); state = ParseState.SeekingAttrValue; } else { parseCancelled = RaiseError("Invalid char '" + cc.ToString() + "' in Attribute Name", i); } break; case ParseState.SeekingEquals: if (cc == '=') { state = ParseState.SeekingAttrValue; } else if (cc == '/') { attributes.Add(attrName, ""); state = ParseState.EmptyElement; } else if (cc == '>') { attributes.Add(attrName, ""); token = new StringBuilder(); state = ParseState.InsideElement; } else if (MayStartXmlName(cc)) { // Assume empty attribute (with no value) attributes.Add(attrName, ""); token = new StringBuilder(cc.ToString()); state = ParseState.AttrName; } else { parseCancelled = RaiseError("Found '" + cc.ToString() + "' when expecting '=' after Attribute Name", i); } break; case ParseState.SeekingAttrValue: if (cc == '\'' || cc == '\"') { attrQuoteChar = cc; token = new StringBuilder(); state = ParseState.AttrValue; } else { parseCancelled = RaiseError("Found '" + cc.ToString() + "' when expecting quoted Attribute Value", i); } break; case ParseState.AttrValue: if (cc == attrQuoteChar) { attributes.Add(attrName, token.ToString()); token = new StringBuilder(); state = ParseState.SeekingAttrName; } else { token.Append(cc); } break; case ParseState.EmptyElement: if (cc == '>') { StartElement?.Invoke(elementName, attributes); // no change to depth, because... EndElement?.Invoke(elementName); token = new StringBuilder(); state = ParseState.InsideElement; } else if (cc == ' ') { // do nothing } else { parseCancelled = RaiseError("Found '" + cc.ToString() + "' after '/' in empty Element Tag", i); } break; case ParseState.InsideElement: if (cc == '<') { string data = token.ToString(); if (data.Length > 0) { if (string.IsNullOrWhiteSpace(data)) { IgnorableWhitespace?.Invoke(data, 0, data.Length); } else { Characters?.Invoke(data, 0, data.Length); } } token = new StringBuilder(); state = ParseState.LessThan; } else { token.Append(cc); } break; case ParseState.EndElementName: if (MayStartXmlName(cc) && token.Length == 0) { token.Append(cc); tokenComplete = false; } else if (ValidInXmlName(cc) && !tokenComplete) { token.Append(cc); } else if (cc == '>') { elementName = token.ToString(); EndElement?.Invoke(elementName); token = new StringBuilder(); if (--depth > 0) { state = ParseState.InsideElement; } else { state = ParseState.Outside; } } else if (cc == ' ') { tokenComplete = true; } else { parseCancelled = RaiseError("Found '" + cc.ToString() + "' after Name in End-of-Element tag.", i); } break; case ParseState.Comment: if (cc == '-' && new string(c.SubArray(i, 3)) == "-->") { i += 2; Comment?.Invoke(token.ToString()); token = new StringBuilder(); if (depth > 0) { state = ParseState.InsideElement; } else { state = ParseState.Outside; } } else { token.Append(cc); } break; case ParseState.ProcessingInstruction: if (cc == '?' && new string(c.SubArray(i, 2)) == "?>") { i += 1; elementName = token.ToString(); ProcessingInstruction?.Invoke(elementName.Head(), elementName.Tail()); token = new StringBuilder(); if (depth > 0) { state = ParseState.InsideElement; } else { state = ParseState.Outside; } } else { token.Append(cc); } break; default: parseCancelled = RaiseError("Unhandled ParseState: " + state.ToString(), i); break; } } if (documentStarted) { EndDocument?.Invoke(); } }
public bool Write(ProcessingInstruction processingInstruction) { return this.writer.Write("<?") && this.writer.Write(processingInstruction.Target) && this.writer.Write(" ") && this.writer.AddIndent() && this.writer.Write(processingInstruction.Value) && this.writer.RemoveIndent() && this.writer.WriteLine(" ?>"); }