//public static SqlConnection MasterConnection = connect("XDBConnectString"); //public static SqlConnection TaskLogConnection = connect("XDBConnectString"); public static Dictionary <String, String> createDictionary() { // Populate the Dictionary! XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); return(myDictionaryLoader.ParseXML()); }
//public Dictionary<String, String> createDictionary() //{ // Populate the Dictionary! // XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); // return myDictionaryLoader.ParseXML(); //} /* * public new static XObject consumeXML(Dictionary<String, String> myConfig, string XmlElement, bool bDeep = false) * { * //XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); * //myDictionaryLoader.Augment(); * // * // Consume XML to create the XComponent object. * // if bDeep is false, then ONLY do this object. * // if bDeep is true, then also do recursive objects. * return new XComponent(); * } * */ public new static XTRMObject consumeXML(Dictionary <String, String> existingConfig, string XmlFragment, int lVariant = 0, bool bDeep = false) { //XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); //myDictionaryLoader.Augment(); // // Consume XML to create the XComponent object. // if bDeep is false, then ONLY do this object. // if bDeep is true, then also do recursive objects. XmlTextReader reader = null; XmlParserContext context = null; Dictionary <String, String> myConfig = new Dictionary <string, string>(existingConfig); XTRMJob thisJob = new XTRMJob(); try { // Load the reader with the data file and ignore all white space nodes. context = new XmlParserContext(null, null, null, XmlSpace.None); reader = new XmlTextReader(XmlFragment, XmlNodeType.Element, context); reader.WhitespaceHandling = WhitespaceHandling.None; // Parse the file and display each of the nodes. bool bResult = reader.Read(); string outerXML; int lElementType = 0; XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); Dictionary <String, String> elementAttributes; while (bResult) { bool bProcessed = false; switch (reader.NodeType) { case XmlNodeType.Element: string elementName = reader.Name; switch (elementName.ToUpper()) { case "XTRMTask": // XTRMTask outerXML = reader.ReadOuterXml(); XTRMTask thisTask = (XTRMTask)XTRMTask.consumeXML(myConfig, outerXML, 1, true); thisJob.tasks.Add(thisTask); bProcessed = true; break; } // May wish to get all the attributes here for new elements! if (!bProcessed) { elementAttributes = new Dictionary <String, String>(); if (reader.HasAttributes) { reader.MoveToFirstAttribute(); for (int i = 0; i < reader.AttributeCount; i++) { //reader.GetAttribute(i); elementAttributes.Add(reader.Name, reader.Value); reader.MoveToNextAttribute(); } if (elementAttributes.ContainsKey("Name")) { thisJob.jobName = elementAttributes["Name"]; } if (elementAttributes.ContainsKey("Host")) { thisJob.jobHost = elementAttributes["Host"]; } reader.MoveToElement(); } // Need to see if we are interested in this element! switch (elementName.ToUpper()) { //case "XTRMTask": // XTRMTask // outerXML = reader.ReadOuterXml(); // XTRMTask thisTask = (XTRMTask)XTRMTask.consumeXML(myConfig, outerXML, 1, true); // thisJob.tasks.Add(thisTask); // break; // Reset Dictionary! // XConfig case "BASECONFIG": outerXML = reader.ReadOuterXml(); myDictionaryLoader = new XDictionaryLoader(); myConfig = new Dictionary <string, string>(); myDictionaryLoader.Augment(myConfig, outerXML); break; // Add to the current dictionary! // XConfig case "WITHCONFIG": outerXML = reader.ReadOuterXml(); //myDictionaryLoader = new XDictionaryLoader(); myDictionaryLoader.Augment(myConfig, outerXML); break; default: bResult = reader.Read(); break; } } break; case XmlNodeType.XmlDeclaration: case XmlNodeType.ProcessingInstruction: //writer.WriteProcessingInstruction(reader.Name, reader.Value); bResult = reader.Read(); break; case XmlNodeType.Comment: //writer.WriteComment(reader.Value); bResult = reader.Read(); break; case XmlNodeType.EndElement: //writer.WriteFullEndElement(); bResult = reader.Read(); break; case XmlNodeType.Text: //Console.Write(reader.Value); switch (lElementType) { //case 1: // PARMS //thisTask.parms.Add(reader.Value); default: break; } bResult = reader.Read(); break; default: bResult = reader.Read(); break; } } } catch (Exception ex) { exCount_XML++; XLogger(2320, -1, string.Format("XML={0}; Message={1}", XmlFragment, ex.Message)); } finally { if (reader != null) { reader.Close(); } } thisJob.config = myConfig; return(thisJob); }
public static XTRMObject consumeXML(string XmlFragment, int lVariant = 0, bool bDeep = false) { //XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); //myDictionaryLoader.Augment(); // // Consume XML to create the XComponent object. // if bDeep is false, then ONLY do this object. // if bDeep is true, then also do recursive objects. XmlTextReader reader = null; XmlParserContext context = null; XTRMFSEntity thisEntity = null; if (lVariant == 1) { thisEntity = new XTRMFSEntity(); thisEntity.Initialize(-1); } else { thisEntity = new XTRMFSEntity(); } thisEntity.variant = lVariant; try { // Load the reader with the data file and ignore all white space nodes. context = new XmlParserContext(null, null, null, XmlSpace.None); reader = new XmlTextReader(XmlFragment, XmlNodeType.Element, context); reader.WhitespaceHandling = WhitespaceHandling.None; // Parse the file and display each of the nodes. bool bResult = reader.Read(); int lElementType = 0; XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); Dictionary <String, String> elementAttributes; while (bResult) { bool bProcessed = false; switch (reader.NodeType) { case XmlNodeType.Element: string elementName = reader.Name; if (!bProcessed) { // May wish to get all the attributes here for new elements! elementAttributes = new Dictionary <String, String>(); if (reader.HasAttributes) { reader.MoveToFirstAttribute(); for (int i = 0; i < reader.AttributeCount; i++) { //reader.GetAttribute(i); elementAttributes.Add(reader.Name, reader.Value); reader.MoveToNextAttribute(); } // Check to see if ID is supplied! //if (elementAttributes["ID"] != null) if (elementAttributes.ContainsKey("Tag")) { thisEntity.entityTag = elementAttributes["Tag"]; } if (elementAttributes.ContainsKey("Source")) { thisEntity.entitySource = elementAttributes["Source"]; } if (elementAttributes.ContainsKey("User")) { thisEntity.entityUser = elementAttributes["User"]; } if (elementAttributes.ContainsKey("EventPath")) { thisEntity.entityEventPath = elementAttributes["EventPath"]; } reader.MoveToElement(); } // Need to see if we are interested in this element! //string elementName = reader.Name; switch (elementName.ToUpper()) { case "PATH": // Path lElementType = 1; bResult = reader.Read(); break; case "PATTERN": // Pattern lElementType = 2; bResult = reader.Read(); break; case "RECURSE": // Recurse lElementType = 3; bResult = reader.Read(); break; case "BUFSIZE": // Bufsize lElementType = 4; bResult = reader.Read(); break; case "HOLDTIME": // HoldTime lElementType = 5; bResult = reader.Read(); break; default: bResult = reader.Read(); break; } } break; case XmlNodeType.XmlDeclaration: case XmlNodeType.ProcessingInstruction: //writer.WriteProcessingInstruction(reader.Name, reader.Value); bResult = reader.Read(); break; case XmlNodeType.Comment: //writer.WriteComment(reader.Value); bResult = reader.Read(); break; case XmlNodeType.EndElement: //writer.WriteFullEndElement(); bResult = reader.Read(); break; case XmlNodeType.Text: //Console.Write(reader.Value); switch (lElementType) { case 1: // Path thisEntity.entityPath = reader.Value; break; case 2: // Pattern thisEntity.entityPattern = reader.Value; break; case 3: // Recurse thisEntity.entityRecurse = Convert.ToInt16(reader.Value); break; case 4: // Bufsize thisEntity.entityBufsize = Convert.ToInt16(reader.Value); break; case 5: // HoldTime thisEntity.entityHoldTime = Convert.ToInt16(reader.Value); break; default: break; } lElementType = 0; bResult = reader.Read(); break; default: bResult = reader.Read(); break; } } } catch (Exception ex) { exCount_XML++; XLogger(2210, -1, string.Format("XML={0}; Message={1}", XmlFragment, ex.Message)); } finally { if (reader != null) { reader.Close(); } } return(thisEntity); }
//public Dictionary<String, String> createDictionary() //{ // Populate the Dictionary! // XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); // return myDictionaryLoader.ParseXML(); //} /* public new static XObject consumeXML(Dictionary<String, String> myConfig, string XmlElement, bool bDeep = false) { //XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); //myDictionaryLoader.Augment(); // // Consume XML to create the XComponent object. // if bDeep is false, then ONLY do this object. // if bDeep is true, then also do recursive objects. return new XComponent(); } * */ public static new XTRMObject consumeXML(Dictionary<String, String> existingConfig, string XmlFragment, int lVariant = 0, bool bDeep = false) { //XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); //myDictionaryLoader.Augment(); // // Consume XML to create the XComponent object. // if bDeep is false, then ONLY do this object. // if bDeep is true, then also do recursive objects. XmlTextReader reader = null; XmlParserContext context = null; Dictionary<String, String> myConfig = new Dictionary<string, string>(existingConfig); XTRMWorkFlow thisWorkflow = new XTRMWorkFlow(); int lElementType = 0; XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); Dictionary<String, String> elementAttributes; try { // Load the reader with the data file and ignore all white space nodes. context = new XmlParserContext(null, null, null, XmlSpace.None); reader = new XmlTextReader(XmlFragment, XmlNodeType.Element, context); reader.WhitespaceHandling = WhitespaceHandling.None; // Parse the file and display each of the nodes. bool bResult = reader.Read(); string outerXML; //XDictionaryLoader myDictionaryLoader; while (bResult) { bool bProcessed = false; switch (reader.NodeType) { case XmlNodeType.Element: string elementName = reader.Name; switch (elementName.ToUpper()) { case "IFEVENT": // XEvent outerXML = reader.ReadOuterXml(); XTRMEvent thisEvent = (XTRMEvent)XTRMEvent.consumeXML(myConfig, outerXML, 1, true); thisWorkflow.workflowEvents.Add(thisEvent); bProcessed = true; break; // Reset Dictionary! // XConfig case "BASECONFIG": outerXML = reader.ReadOuterXml(); //myDictionaryLoader = new XDictionaryLoader(); myConfig = new Dictionary<string, string>(); myDictionaryLoader.Augment(myConfig, outerXML); bProcessed = true; break; // Add to the current dictionary! // XConfig case "WITHCONFIG": outerXML = reader.ReadOuterXml(); myDictionaryLoader = new XDictionaryLoader(); myDictionaryLoader.Augment(myConfig, outerXML); bProcessed = true; break; } if (!bProcessed) { // May wish to get all the attributes here for new elements! elementAttributes = new Dictionary<String, String>(); if (reader.HasAttributes) { reader.MoveToFirstAttribute(); for (int i = 0; i < reader.AttributeCount; i++) { //reader.GetAttribute(i); elementAttributes.Add(reader.Name, reader.Value); reader.MoveToNextAttribute(); } if (elementAttributes.ContainsKey("Name")) { // Try to instantiate the XEvent Object! thisWorkflow.name = elementAttributes["Name"]; } if (elementAttributes.ContainsKey("ID")) { // Try to instantiate the XEvent Object! thisWorkflow.name = elementAttributes["ID"]; } reader.MoveToElement(); } // Need to see if we are interested in this element! //string elementName = reader.Name; switch (elementName.ToUpper()) { //case "IFEVENT": // XEvent // outerXML = reader.ReadOuterXml(); // XEvent thisEvent = (XEvent)XEvent.consumeXML(myConfig, outerXML, 1, true); // thisWorkflow.workflowEvents.Add(thisEvent); // break; // Reset Dictionary! // XConfig //case "BASECONFIG": // outerXML = reader.ReadOuterXml(); // //myDictionaryLoader = new XDictionaryLoader(); // myConfig = new Dictionary<string, string>(); // myDictionaryLoader.Augment(myConfig, outerXML); // break; // Add to the current dictionary! // XConfig //case "WITHCONFIG": // outerXML = reader.ReadOuterXml(); // myDictionaryLoader = new XDictionaryLoader(); // myDictionaryLoader.Augment(myConfig, outerXML); // break; default: bResult = reader.Read(); break; } } break; case XmlNodeType.XmlDeclaration: case XmlNodeType.ProcessingInstruction: //writer.WriteProcessingInstruction(reader.Name, reader.Value); bResult = reader.Read(); break; case XmlNodeType.Comment: //writer.WriteComment(reader.Value); bResult = reader.Read(); break; case XmlNodeType.EndElement: //writer.WriteFullEndElement(); bResult = reader.Read(); break; case XmlNodeType.Text: //Console.Write(reader.Value); switch (lElementType) { //case 1: // PARMS // thisTask.parms.Add(reader.Value); default: break; } bResult = reader.Read(); break; default: bResult = reader.Read(); break; } } } catch (Exception ex) { exCount_XML++; XLogger(3100, -1, string.Format("XML={0}; Message={1}", XmlFragment, ex.Message)); } finally { if (reader != null) reader.Close(); } thisWorkflow.config = myConfig; return thisWorkflow; }
public static XTRMObject consumeXML(string XmlFragment, int lVariant = 0, bool bDeep = false) { //XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); //myDictionaryLoader.Augment(); // // Consume XML to create the XComponent object. // if bDeep is false, then ONLY do this object. // if bDeep is true, then also do recursive objects. XmlTextReader reader = null; XmlParserContext context = null; XTRMConfig thisEntity = null; if (lVariant == 1) { thisEntity = new XTRMConfig(); thisEntity.Initialize(-1); } else { thisEntity = new XTRMConfig(); } thisEntity.variant = lVariant; try { // Load the reader with the data file and ignore all white space nodes. context = new XmlParserContext(null, null, null, XmlSpace.None); reader = new XmlTextReader(XmlFragment, XmlNodeType.Element, context); reader.WhitespaceHandling = WhitespaceHandling.None; // Parse the file and display each of the nodes. bool bResult = reader.Read(); int lElementType = 0; XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); Dictionary<String, String> elementAttributes; while (bResult) { bool bProcessed = false; switch (reader.NodeType) { case XmlNodeType.Element: string elementName = reader.Name; if (!bProcessed) { // May wish to get all the attributes here for new elements! elementAttributes = new Dictionary<String, String>(); if (reader.HasAttributes) { reader.MoveToFirstAttribute(); for (int i = 0; i < reader.AttributeCount; i++) { //reader.GetAttribute(i); elementAttributes.Add(reader.Name.ToUpper(), reader.Value); reader.MoveToNextAttribute(); } // Check to see if ID is supplied! //if (elementAttributes["ID"] != null) if (elementAttributes.ContainsKey("TAG")) { thisEntity.entityTag = elementAttributes["TAG"]; } if (elementAttributes.ContainsKey("SOURCE")) { thisEntity.entitySource = elementAttributes["SOURCE"]; } if (elementAttributes.ContainsKey("USER")) { thisEntity.entityUser = elementAttributes["USER"]; } if (elementAttributes.ContainsKey("PATH")) { thisEntity.entityPath = elementAttributes["PATH"]; } if (elementAttributes.ContainsKey("PATTERN")) { thisEntity.entityPattern = elementAttributes["PATTERN"]; } if (elementAttributes.ContainsKey("RECURSE")) { thisEntity.entityRecurse = Convert.ToInt16(elementAttributes["RECURSE"]); } if (elementAttributes.ContainsKey("BUFSIZE")) { thisEntity.entityBufsize = Convert.ToInt16(elementAttributes["BUFSIZE"]); } if (elementAttributes.ContainsKey("HOLDTIME")) { thisEntity.entityHoldTime = Convert.ToInt16(elementAttributes["HOLDTIME"]); } if (elementAttributes.ContainsKey("SCHEMA")) { thisEntity.entitySchema = elementAttributes["SCHEMA"]; } reader.MoveToElement(); } // Need to see if we are interested in this element! //string elementName = reader.Name; switch (elementName.ToUpper()) { case "PATH": // Path lElementType = 1; bResult = reader.Read(); break; case "PATTERN": // Pattern lElementType = 2; bResult = reader.Read(); break; case "RECURSE": // Recurse lElementType = 3; bResult = reader.Read(); break; case "BUFSIZE": // Bufsize lElementType = 4; bResult = reader.Read(); break; case "HOLDTIME": // HoldTime lElementType = 5; bResult = reader.Read(); break; default: bResult = reader.Read(); break; } } break; case XmlNodeType.XmlDeclaration: case XmlNodeType.ProcessingInstruction: //writer.WriteProcessingInstruction(reader.Name, reader.Value); bResult = reader.Read(); break; case XmlNodeType.Comment: //writer.WriteComment(reader.Value); bResult = reader.Read(); break; case XmlNodeType.EndElement: //writer.WriteFullEndElement(); bResult = reader.Read(); break; case XmlNodeType.Text: //Console.Write(reader.Value); switch (lElementType) { case 1: // Path thisEntity.entityPath = reader.Value; break; case 2: // Pattern thisEntity.entityPattern = reader.Value; break; case 3: // Recurse thisEntity.entityRecurse = Convert.ToInt16(reader.Value); break; case 4: // Bufsize thisEntity.entityBufsize = Convert.ToInt16(reader.Value); break; case 5: // HoldTime thisEntity.entityHoldTime = Convert.ToInt16(reader.Value); break; default: break; } lElementType = 0; bResult = reader.Read(); break; default: bResult = reader.Read(); break; } } } catch (Exception ex) { exCount_XML++; XLogger(2210, -1, string.Format("XML={0}; Message={1}", XmlFragment, ex.Message)); } finally { if (reader != null) reader.Close(); } return thisEntity; }
public int ParseConfig(string configFile, bool bDeep = false) { // // Consume XML to create the XFSEntity objects. // if bDeep is false, then ONLY do this object. // if bDeep is true, then also do recursive objects. XmlTextReader reader = null; int rc = -1; string connectString = XTRMObject.getDictionaryEntry("TaskConnectString"); string outerXML; int lElementType = 0; XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); Dictionary<String, String> elementAttributes; entities.Clear(); try { // Load the reader with the data file and ignore all white space nodes. reader = new XmlTextReader(configFile); reader.WhitespaceHandling = WhitespaceHandling.None; // Parse the file and display each of the nodes. bool bResult = reader.Read(); while (bResult) { bool bProcessed = false; switch (reader.NodeType) { case XmlNodeType.Element: string elementName = reader.Name; switch (elementName.ToUpper()) { case "XFSENTITY": outerXML = reader.ReadOuterXml(); XTRMFSEntity thisEntity = (XTRMFSEntity)XTRMFSEntity.consumeXML(outerXML, 1, true); entities.Add(thisEntity); bProcessed = true; break; } if (!bProcessed) { // May wish to get all the attributes here for new elements! elementAttributes = new Dictionary<String, String>(); if (reader.HasAttributes) { reader.MoveToFirstAttribute(); for (int i = 0; i < reader.AttributeCount; i++) { //reader.GetAttribute(i); elementAttributes.Add(reader.Name, reader.Value); reader.MoveToNextAttribute(); } if (elementAttributes.ContainsKey("Tag")) { agentTag = elementAttributes["Tag"]; } if (elementAttributes.ContainsKey("Source")) { agentSource = elementAttributes["Source"]; } if (elementAttributes.ContainsKey("User")) { agentUser = elementAttributes["User"]; } if (elementAttributes.ContainsKey("EventPath")) { agentEventPath = elementAttributes["EventPath"]; } reader.MoveToElement(); } // Need to see if we are interested in this element! //string elementName = reader.Name; switch (elementName.ToUpper()) { case "XFILEAGENTCONFIG": // Advance into Elements! reader.MoveToContent(); bResult = reader.Read(); break; default: bResult = reader.Read(); break; } } break; case XmlNodeType.XmlDeclaration: case XmlNodeType.ProcessingInstruction: //writer.WriteProcessingInstruction(reader.Name, reader.Value); bResult = reader.Read(); break; case XmlNodeType.Comment: //writer.WriteComment(reader.Value); bResult = reader.Read(); break; case XmlNodeType.EndElement: //writer.WriteFullEndElement(); bResult = reader.Read(); break; case XmlNodeType.Text: //Console.Write(reader.Value); switch (lElementType) { default: break; } bResult = reader.Read(); break; default: bResult = reader.Read(); break; } } } catch (Exception ex) { exCount_XML++; XLogger(2400, -1, string.Format("XTRMFileAgent::parseConfig(); ConfigFile={0}; Message={1}", configFile, ex.Message)); } finally { if (reader != null) reader.Close(); } return rc; }
public int IncludeConfig(string inFile, Dictionary<String, String> myConfig, int lVariant = 0, bool bDeep = false) { // // Consume XML to create the XLator object. // if bDeep is false, then ONLY do this object. // if bDeep is true, then also do recursive objects. int rc = -1; XmlTextReader reader = null; string connectString = XTRMObject.getDictionaryEntry("TaskConnectString"); string outerXML; int lElementType = 0; XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); Dictionary<String, String> elementAttributes; try { // Load the reader with the data file and ignore all white space nodes. reader = new XmlTextReader(inFile); reader.WhitespaceHandling = WhitespaceHandling.None; // Parse the file and display each of the nodes. bool bResult = reader.Read(); while (bResult) { bool bProcessed = false; switch (reader.NodeType) { case XmlNodeType.Element: string elementName = reader.Name; switch (elementName.ToUpper()) { case "BASECONFIG": outerXML = reader.ReadOuterXml(); myDictionaryLoader = new XDictionaryLoader(); myConfig = myDictionaryLoader.Augment(myConfig, outerXML); bProcessed = true; break; case "WITHCONFIG": outerXML = reader.ReadOuterXml(); myDictionaryLoader.Augment(myConfig, outerXML); bProcessed = true; break; case "EVENTFILTER": outerXML = reader.ReadOuterXml(); XTRMEvent thisFilter = (XTRMEvent)XTRMEvent.consumeXML(myConfig, outerXML, 2, true); eventFilters.Add(thisFilter); bProcessed = true; break; case "XTRMEVENT": outerXML = reader.ReadOuterXml(); XTRMEvent thisEvent = (XTRMEvent)XTRMEvent.consumeXML(myConfig, outerXML, 1, true); events.Add(thisEvent); bProcessed = true; break; case "XTRMWORKFLOW": outerXML = reader.ReadOuterXml(); XTRMWorkFlow thisFlow = (XTRMWorkFlow)XTRMWorkFlow.consumeXML(myConfig, outerXML, 1, true); workflows.Add(thisFlow); bProcessed = true; break; } if (!bProcessed) { // May wish to get all the attributes here for new elements! elementAttributes = new Dictionary<String, String>(); if (reader.HasAttributes) { reader.MoveToFirstAttribute(); for (int i = 0; i < reader.AttributeCount; i++) { elementAttributes.Add(reader.Name, reader.Value); reader.MoveToNextAttribute(); } if (elementAttributes.ContainsKey("Name")) { // Try to instantiate the XEvent Object! name = elementAttributes["Name"]; } reader.MoveToElement(); } // Need to see if we are interested in this element! //string elementName = reader.Name; switch (elementName.ToUpper()) //switch (reader.Name) { case "EVENTFOLDER": lElementType = 1; bResult = reader.Read(); break; case "XTRM": // Advance into Elements! reader.MoveToContent(); bResult = reader.Read(); break; default: bResult = reader.Read(); break; } } break; case XmlNodeType.XmlDeclaration: case XmlNodeType.ProcessingInstruction: bResult = reader.Read(); break; case XmlNodeType.Comment: bResult = reader.Read(); break; case XmlNodeType.EndElement: bResult = reader.Read(); break; case XmlNodeType.Text: switch (lElementType) { case 1: // EventFolder eventFolders.Add(ResolveText(reader.Value, XDictionary)); break; default: break; } bResult = reader.Read(); break; default: bResult = reader.Read(); break; } } } catch (Exception ex) { exCount_XML++; XLogger(2402, -1, string.Format("XLator::IncludeConfig(); ConfigFile={0}; Message={1}", configFile, ex.Message)); } finally { if (reader != null) reader.Close(); } return rc; }
public static new XTRMObject consumeXML(Dictionary<String, String> existingConfig, string XmlFragment, int lVariant = 0, bool bDeep = false) { //XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); //myDictionaryLoader.Augment(); // // Consume XML to create the XComponent object. // if bDeep is false, then ONLY do this object. // if bDeep is true, then also do recursive objects. XmlTextReader reader = null; XmlParserContext context = null; Dictionary<String, String> myConfig = new Dictionary<string, string>(existingConfig); XTRMTask thisTask = new XTRMTask(); thisTask.taskPath = getConfig(myConfig, "TaskPath", @"C:\"); try { // Load the reader with the data file and ignore all white space nodes. context = new XmlParserContext(null, null, null, XmlSpace.None); reader = new XmlTextReader(XmlFragment, XmlNodeType.Element, context); reader.WhitespaceHandling = WhitespaceHandling.None; // Parse the file and display each of the nodes. bool bResult = reader.Read(); string outerXML; int lElementType = 0; XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); Dictionary<String, String> elementAttributes; while (bResult) { bool bProcessed = false; switch (reader.NodeType) { case XmlNodeType.Element: string elementName = reader.Name; switch (elementName.ToUpper()) { case "BASECONFIG": outerXML = reader.ReadOuterXml(); myDictionaryLoader = new XDictionaryLoader(); myConfig = new Dictionary<string, string>(); myDictionaryLoader.Augment(myConfig, outerXML); thisTask.taskPath = getConfig(myConfig, "TaskPath"); bProcessed = true; break; // Add to the current dictionary! // XConfig case "WITHCONFIG": outerXML = reader.ReadOuterXml(); //myDictionaryLoader = new XDictionaryLoader(); myDictionaryLoader.Augment(myConfig, outerXML); thisTask.taskPath = getConfig(myConfig, "TaskPath"); bProcessed = true; break; } if (!bProcessed) { // May wish to get all the attributes here for new elements! elementAttributes = new Dictionary<String, String>(); if (reader.HasAttributes) { reader.MoveToFirstAttribute(); for (int i = 0; i < reader.AttributeCount; i++) { //reader.GetAttribute(i); elementAttributes.Add(reader.Name, reader.Value); reader.MoveToNextAttribute(); } if (elementAttributes.ContainsKey("Path")) { thisTask.taskPath = elementAttributes["Path"]; } if (elementAttributes.ContainsKey("Name")) { thisTask.taskName = elementAttributes["Name"]; } if (elementAttributes.ContainsKey("Exec")) { thisTask.taskExecutable = elementAttributes["Exec"]; } if (elementAttributes.ContainsKey("Execute")) { thisTask.taskExecutable = elementAttributes["Execute"]; } reader.MoveToElement(); } // Need to see if we are interested in this element! lElementType = 0; //string elementName = reader.Name; switch (elementName.ToUpper()) { case "PARM": case "XPARM": case "XTRMPARM": lElementType = 1; bResult = reader.Read(); break; case "EXEC": case "EXECUTABLE": lElementType = 2; bResult = reader.Read(); break; // Reset Dictionary! // XConfig //case "BASECONFIG": // outerXML = reader.ReadOuterXml(); // myDictionaryLoader = new XDictionaryLoader(); // myConfig = new Dictionary<string, string>(); // myDictionaryLoader.Augment(myConfig, outerXML); // break; // Add to the current dictionary! // XConfig //case "WITHCONFIG": // outerXML = reader.ReadOuterXml(); //myDictionaryLoader = new XDictionaryLoader(); // myDictionaryLoader.Augment(myConfig, outerXML); // break; default: bResult = reader.Read(); break; } } break; case XmlNodeType.XmlDeclaration: case XmlNodeType.ProcessingInstruction: bResult = reader.Read(); break; case XmlNodeType.Comment: bResult = reader.Read(); break; case XmlNodeType.EndElement: bResult = reader.Read(); break; case XmlNodeType.Text: switch (lElementType) { case 1: // XParms thisTask.parms.Add(reader.Value); break; case 2: // Executable thisTask.taskExecutable = reader.Value; break; } bResult = reader.Read(); break; default: bResult = reader.Read(); break; } } } catch (Exception ex) { exCount_XML++; XLogger(2615, -1, string.Format("XML={0}; Message={1}", XmlFragment, ex.Message)); } finally { if (reader != null) reader.Close(); } thisTask.config = myConfig; return thisTask; }
public static new XTRMObject consumeXML(Dictionary<String, String> existingConfig, string XmlFragment, int lVariant = 0, bool bDeep = false) { //XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); //myDictionaryLoader.Augment(); // // Consume XML to create the XComponent object. // if bDeep is false, then ONLY do this object. // if bDeep is true, then also do recursive objects. XmlTextReader reader = null; XmlParserContext context = null; Dictionary<String, String> myConfig = new Dictionary<string, string>(existingConfig); XTRMEvent thisEvent = null; if (lVariant == 1) { thisEvent = new XTRMEvent(); thisEvent.Initialize(-1); } else { thisEvent = new XTRMEvent(); } thisEvent.variant = lVariant; try { // Load the reader with the data file and ignore all white space nodes. context = new XmlParserContext(null, null, null, XmlSpace.None); reader = new XmlTextReader(XmlFragment, XmlNodeType.Element, context); reader.WhitespaceHandling = WhitespaceHandling.None; // Parse the file and display each of the nodes. bool bResult = reader.Read(); string outerXML; int lElementType = 0; XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); Dictionary<String, String> elementAttributes; while (bResult) { bool bProcessed = false; switch (reader.NodeType) { case XmlNodeType.Element: string elementName = reader.Name; switch (elementName.ToUpper()) { case "THENJOB": // XTRMJob outerXML = reader.ReadOuterXml(); XTRMJob thisJob = (XTRMJob)XTRMJob.consumeXML(myConfig, outerXML, 0, true); thisEvent.eventJobs.Add(thisJob); bProcessed = true; break; case "BASECONFIG": outerXML = reader.ReadOuterXml(); myDictionaryLoader = new XDictionaryLoader(); myConfig = new Dictionary<string, string>(); myDictionaryLoader.Augment(myConfig, outerXML); bProcessed = true; break; // Add to the current dictionary! // XConfig case "WITHCONFIG": outerXML = reader.ReadOuterXml(); //myDictionaryLoader = new XDictionaryLoader(); myDictionaryLoader.Augment(myConfig, outerXML); bProcessed = true; break; } if (!bProcessed) { // May wish to get all the attributes here for new elements! elementAttributes = new Dictionary<String, String>(); if (reader.HasAttributes) { reader.MoveToFirstAttribute(); for (int i = 0; i < reader.AttributeCount; i++) { //reader.GetAttribute(i); elementAttributes.Add(reader.Name, reader.Value); reader.MoveToNextAttribute(); } // Check to see if ID is supplied! //if (elementAttributes["ID"] != null) if (elementAttributes.ContainsKey("Serial")) { // Try to instantiate the XTRMEvent Object! int myEventID = Convert.ToInt32(elementAttributes["Serial"]); thisEvent.Initialize(myEventID); } if (elementAttributes.ContainsKey("Action")) { thisEvent.eventAction = elementAttributes["Action"]; } if (elementAttributes.ContainsKey("Source")) { thisEvent.eventSource = elementAttributes["Source"]; } reader.MoveToElement(); } // Need to see if we are interested in this element! //string elementName = reader.Name; switch (elementName.ToUpper()) { case "SERIAL": // Serial lElementType = 1; bResult = reader.Read(); break; case "SOURCE": // Source lElementType = 2; bResult = reader.Read(); break; case "ACTION": // Action lElementType = 3; bResult = reader.Read(); break; //case "NORMALPATH": // NormalPath // lElementType = 4; // bResult = reader.Read(); // break; case "SUFFIX": // Suffix lElementType = 5; bResult = reader.Read(); break; case "REGEX": // Regex lElementType = 6; bResult = reader.Read(); break; case "UUID": // UUID lElementType = 7; bResult = reader.Read(); break; case "NORMALPATH": // Parm1 case "NORMALNAME": case "PRISMFULLNAME": case "P4FULLNAME": case "PARM1": lElementType = 8; bResult = reader.Read(); break; case "PRISMPATH": case "P4VERSION": // P4Version case "PARM2": // Parm2 lElementType = 9; bResult = reader.Read(); break; case "PRISMNAME": case "P4CHANGELIST": case "PARM3": // Parm3 lElementType = 10; bResult = reader.Read(); break; case "PRISMVERSION": case "P4TYPE": case "PARM4": // Parm4 lElementType = 11; bResult = reader.Read(); break; case "PRISMBRANCH": case "P4SIZE": case "PARM5": // Parm5 lElementType = 12; bResult = reader.Read(); break; case "P4CLIENT": case "PRISMLOCALNAME": case "PARM6": // Parm6 lElementType = 13; bResult = reader.Read(); break; case "PRISMTIME": case "P4TIME": case "PARM7": // Parm7 lElementType = 14; bResult = reader.Read(); break; case "PARM8": // Parm8 lElementType = 15; bResult = reader.Read(); break; case "PARM9": // Parm9 lElementType = 16; bResult = reader.Read(); break; case "PARM10": // Parm10 lElementType = 17; bResult = reader.Read(); break; case "USER": // User lElementType = 18; bResult = reader.Read(); break; case "PIN": // PIN lElementType = 19; bResult = reader.Read(); break; case "TAG": // Tag lElementType = 20; bResult = reader.Read(); break; case "DATESTAMP": // Date lElementType = 21; bResult = reader.Read(); break; case "EVENTDATE": // Date (new format that imports directly). lElementType = 22; bResult = reader.Read(); break; case "STATUS": // Date (new format that imports directly). lElementType = 23; bResult = reader.Read(); break; case "PATH": // Date (new format that imports directly). lElementType = 24; bResult = reader.Read(); break; case "DESC": // Date (new format that imports directly). lElementType = 25; bResult = reader.Read(); break; //case "THENJOB": // XTRMJob // outerXML = reader.ReadOuterXml(); // XTRMJob thisJob = (XTRMJob)XTRMJob.consumeXML(myConfig, outerXML, 0, true); // thisEvent.eventJobs.Add(thisJob); // break; // Reset Dictionary! // XConfig //case "BASECONFIG": // outerXML = reader.ReadOuterXml(); // myDictionaryLoader = new XDictionaryLoader(); // myConfig = new Dictionary<string, string>(); // myDictionaryLoader.Augment(myConfig, outerXML); // break; // Add to the current dictionary! // XConfig //case "WITHCONFIG": // outerXML = reader.ReadOuterXml(); // //myDictionaryLoader = new XDictionaryLoader(); // myDictionaryLoader.Augment(myConfig, outerXML); // break; default: bResult = reader.Read(); break; } } break; case XmlNodeType.XmlDeclaration: case XmlNodeType.ProcessingInstruction: //writer.WriteProcessingInstruction(reader.Name, reader.Value); bResult = reader.Read(); break; case XmlNodeType.Comment: //writer.WriteComment(reader.Value); bResult = reader.Read(); break; case XmlNodeType.EndElement: //writer.WriteFullEndElement(); bResult = reader.Read(); break; case XmlNodeType.Text: //Console.Write(reader.Value); switch (lElementType) { case 1: // Serial thisEvent.eventSerial = Convert.ToInt16(reader.Value); break; case 2: // Source thisEvent.eventSource = reader.Value; break; case 3: // Action thisEvent.eventAction = reader.Value; break; case 4: // NormalPath thisEvent.normalPath.Add(reader.Value); break; case 5: // Suffix thisEvent.suffix.Add(reader.Value); break; case 6: // Regex thisEvent.regex.Add(reader.Value); break; case 7: // eventUUID thisEvent.eventUUID = reader.Value; break; case 8: // eventParm1 thisEvent.eventParm1 = reader.Value; thisEvent.normalPath.Add(reader.Value); break; case 9: // eventParm2 thisEvent.eventParm2 = reader.Value; break; case 10: // eventParm3 thisEvent.eventParm3 = reader.Value; break; case 11: // eventParm4 thisEvent.eventParm4 = reader.Value; break; case 12: // eventParm5 thisEvent.eventParm5 = reader.Value; break; case 13: // eventParm6 thisEvent.eventParm6 = reader.Value; break; case 14: // eventParm7 thisEvent.eventParm7 = reader.Value; break; case 15: // eventParm8 thisEvent.eventParm8 = reader.Value; break; case 16: // eventParm9 thisEvent.eventParm9 = reader.Value; break; case 17: // eventParm10 thisEvent.eventParm10 = reader.Value; break; case 18: // eventUser thisEvent.eventUser = reader.Value; break; case 19: // eventPIN thisEvent.eventPIN = reader.Value; break; case 20: // eventTag thisEvent.eventTag = reader.Value; break; case 21: // eventDate string inputDate = reader.Value; int year, month, day, hour, min, sec; DateTime dateStamp; // If contains "/", then use method 2! if (inputDate.Contains("/")) { //year = Convert.ToInt16(inputDate.Substring(6, 4)); //month = Convert.ToInt16(inputDate.Substring(0, 2)); //day = Convert.ToInt16(inputDate.Substring(3, 2)); //hour = Convert.ToInt16(inputDate.Substring(11, 2)); //min = Convert.ToInt16(inputDate.Substring(14, 2)); //sec = Convert.ToInt16(inputDate.Substring(17, 2)); dateStamp = DateTime.Parse(inputDate, System.Globalization.CultureInfo.InvariantCulture); } else { year = Convert.ToInt16(inputDate.Substring(0, 4)); month = Convert.ToInt16(inputDate.Substring(4, 2)); day = Convert.ToInt16(inputDate.Substring(6, 2)); hour = Convert.ToInt16(inputDate.Substring(9, 2)); min = Convert.ToInt16(inputDate.Substring(12, 2)); sec = Convert.ToInt16(inputDate.Substring(15, 2)); dateStamp = new DateTime(year, month, day, hour, min, sec); } //inputDate = "6/7/2012 06:00:00"; //thisEvent.eventDate = dateStamp.ToString(); //thisEvent.eventDate = inputDate; break; case 22: // eventDate (mm/dd/yyyy hh24:mi:ss) thisEvent.eventDate = reader.Value; break; case 23: // Status //thisEvent. = reader.Value; break; case 24: // Path //thisEvent = reader.Value; break; case 25: // Description //thisEvent.eventDate = reader.Value; break; case 26: // eventHost thisEvent.eventHost = reader.Value; break; default: break; } lElementType = 0; bResult = reader.Read(); break; default: bResult = reader.Read(); break; } } } catch (Exception ex) { exCount_XML++; XLogger(2210, -1, string.Format("XML={0}; Message={1}", XmlFragment, ex.Message)); } finally { if (reader != null) reader.Close(); } thisEvent.config = myConfig; return thisEvent; }
public int IncludeConfig(string inFile, Dictionary <String, String> myConfig, int lVariant = 0, bool bDeep = false) { // // Consume XML to create the XLator object. // if bDeep is false, then ONLY do this object. // if bDeep is true, then also do recursive objects. int rc = -1; XmlTextReader reader = null; string connectString = XTRMObject.getDictionaryEntry("TaskConnectString"); string outerXML; int lElementType = 0; XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); Dictionary <String, String> elementAttributes; try { // Load the reader with the data file and ignore all white space nodes. reader = new XmlTextReader(inFile); reader.WhitespaceHandling = WhitespaceHandling.None; // Parse the file and display each of the nodes. bool bResult = reader.Read(); while (bResult) { bool bProcessed = false; switch (reader.NodeType) { case XmlNodeType.Element: string elementName = reader.Name; switch (elementName.ToUpper()) { case "BASECONFIG": outerXML = reader.ReadOuterXml(); myDictionaryLoader = new XDictionaryLoader(); myConfig = myDictionaryLoader.Augment(myConfig, outerXML); bProcessed = true; break; case "WITHCONFIG": outerXML = reader.ReadOuterXml(); myDictionaryLoader.Augment(myConfig, outerXML); bProcessed = true; break; case "EVENTFILTER": outerXML = reader.ReadOuterXml(); XTRMEvent thisFilter = (XTRMEvent)XTRMEvent.consumeXML(myConfig, outerXML, 2, true); eventFilters.Add(thisFilter); bProcessed = true; break; case "XTRMEVENT": outerXML = reader.ReadOuterXml(); XTRMEvent thisEvent = (XTRMEvent)XTRMEvent.consumeXML(myConfig, outerXML, 1, true); events.Add(thisEvent); bProcessed = true; break; case "XTRMWORKFLOW": outerXML = reader.ReadOuterXml(); XTRMWorkFlow thisFlow = (XTRMWorkFlow)XTRMWorkFlow.consumeXML(myConfig, outerXML, 1, true); workflows.Add(thisFlow); bProcessed = true; break; } if (!bProcessed) { // May wish to get all the attributes here for new elements! elementAttributes = new Dictionary <String, String>(); if (reader.HasAttributes) { reader.MoveToFirstAttribute(); for (int i = 0; i < reader.AttributeCount; i++) { elementAttributes.Add(reader.Name, reader.Value); reader.MoveToNextAttribute(); } if (elementAttributes.ContainsKey("Name")) { // Try to instantiate the XEvent Object! name = elementAttributes["Name"]; } reader.MoveToElement(); } // Need to see if we are interested in this element! //string elementName = reader.Name; switch (elementName.ToUpper()) //switch (reader.Name) { case "EVENTFOLDER": lElementType = 1; bResult = reader.Read(); break; case "XTRM": // Advance into Elements! reader.MoveToContent(); bResult = reader.Read(); break; default: bResult = reader.Read(); break; } } break; case XmlNodeType.XmlDeclaration: case XmlNodeType.ProcessingInstruction: bResult = reader.Read(); break; case XmlNodeType.Comment: bResult = reader.Read(); break; case XmlNodeType.EndElement: bResult = reader.Read(); break; case XmlNodeType.Text: switch (lElementType) { case 1: // EventFolder eventFolders.Add(ResolveText(reader.Value, XDictionary)); break; default: break; } bResult = reader.Read(); break; default: bResult = reader.Read(); break; } } } catch (Exception ex) { exCount_XML++; XLogger(2402, -1, string.Format("XLator::IncludeConfig(); ConfigFile={0}; Message={1}", configFile, ex.Message)); } finally { if (reader != null) { reader.Close(); } } return(rc); }
//public static SqlConnection MasterConnection = connect("XDBConnectString"); //public static SqlConnection TaskLogConnection = connect("XDBConnectString"); public static Dictionary<String, String> createDictionary() { // Populate the Dictionary! XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); return myDictionaryLoader.ParseXML(); }
public int ParseConfig(string configFile, bool bDeep = false) { // // Consume XML to create the XFSEntity objects. // if bDeep is false, then ONLY do this object. // if bDeep is true, then also do recursive objects. XmlTextReader reader = null; int rc = -1; string connectString = XTRMObject.getDictionaryEntry("TaskConnectString"); string outerXML; int lElementType = 0; XDictionaryLoader myDictionaryLoader = new XDictionaryLoader(); Dictionary <String, String> elementAttributes; entities.Clear(); try { // Load the reader with the data file and ignore all white space nodes. reader = new XmlTextReader(configFile); reader.WhitespaceHandling = WhitespaceHandling.None; // Parse the file and display each of the nodes. bool bResult = reader.Read(); while (bResult) { bool bProcessed = false; switch (reader.NodeType) { case XmlNodeType.Element: string elementName = reader.Name; switch (elementName.ToUpper()) { case "XFSENTITY": outerXML = reader.ReadOuterXml(); XTRMFSEntity thisEntity = (XTRMFSEntity)XTRMFSEntity.consumeXML(outerXML, 1, true); entities.Add(thisEntity); bProcessed = true; break; } if (!bProcessed) { // May wish to get all the attributes here for new elements! elementAttributes = new Dictionary <String, String>(); if (reader.HasAttributes) { reader.MoveToFirstAttribute(); for (int i = 0; i < reader.AttributeCount; i++) { //reader.GetAttribute(i); elementAttributes.Add(reader.Name, reader.Value); reader.MoveToNextAttribute(); } if (elementAttributes.ContainsKey("Tag")) { agentTag = elementAttributes["Tag"]; } if (elementAttributes.ContainsKey("Source")) { agentSource = elementAttributes["Source"]; } if (elementAttributes.ContainsKey("User")) { agentUser = elementAttributes["User"]; } if (elementAttributes.ContainsKey("EventPath")) { agentEventPath = elementAttributes["EventPath"]; } reader.MoveToElement(); } // Need to see if we are interested in this element! //string elementName = reader.Name; switch (elementName.ToUpper()) { case "XFILEAGENTCONFIG": // Advance into Elements! reader.MoveToContent(); bResult = reader.Read(); break; default: bResult = reader.Read(); break; } } break; case XmlNodeType.XmlDeclaration: case XmlNodeType.ProcessingInstruction: //writer.WriteProcessingInstruction(reader.Name, reader.Value); bResult = reader.Read(); break; case XmlNodeType.Comment: //writer.WriteComment(reader.Value); bResult = reader.Read(); break; case XmlNodeType.EndElement: //writer.WriteFullEndElement(); bResult = reader.Read(); break; case XmlNodeType.Text: //Console.Write(reader.Value); switch (lElementType) { default: break; } bResult = reader.Read(); break; default: bResult = reader.Read(); break; } } } catch (Exception ex) { exCount_XML++; XLogger(2400, -1, string.Format("XTRMFileAgent::parseConfig(); ConfigFile={0}; Message={1}", configFile, ex.Message)); } finally { if (reader != null) { reader.Close(); } } return(rc); }