public static void startMiniGame(XmlNode gameData) { string name = gameData.getString(); singleton.current = (GameObject)Instantiate(singleton.miniGameTypes[name]); singleton.current.transform.parent = singleton.gameObject.transform; singleton.current.GetComponent<MiniGameAPI>().Data = gameData; }
/* * 分析位置 包含座標及位置物件 * parse * <Position3D x="x" y="y" z="z" /> * <Position3D objectName="objectName" /> */ public static bool ParsePosition( XmlNode _PositionNode , ref PosAnchor _PosAnchor ) { if( "Position3D" == _PositionNode.Name ) { if( null != _PositionNode.Attributes[ "objectName" ] ) { string objectName = _PositionNode.Attributes[ "objectName" ].Value ; _PosAnchor.Setup( objectName ) ; } else { // 絕對座標 string strx = _PositionNode.Attributes[ "x" ].Value ; string stry = _PositionNode.Attributes[ "y" ].Value ; string strz = _PositionNode.Attributes[ "z" ].Value ; float x , y , z ; float.TryParse( strx , out x ) ; float.TryParse( stry , out y ) ; float.TryParse( strz , out z ) ; Vector3 setPosition = new Vector3( x , y , z ) ; _PosAnchor.Setup( setPosition ) ; } return true ; } return false ; }
/// <summary> /// Ensures the repository Xml Node has the correct site value /// </summary> /// <param name="xmlDoc"></param> /// <param name="xnodeRepository"></param> /// <param name="serverMapInfo"></param> private static void helper_SetRespositorySite(XmlDocument xmlDoc, XmlNode xnodeRepository, ITableauServerSiteInfo serverMapInfo) { var attrSite = xnodeRepository.Attributes["site"]; //If we have NOT site id, then get rid of the attribute if it exists var siteId = serverMapInfo.SiteId; if(string.IsNullOrWhiteSpace(siteId)) { if(attrSite != null) { xnodeRepository.Attributes.Remove(attrSite); } return; //Nothing left to do } //If the the site attribute is missing, then add it if (attrSite == null) { attrSite = xmlDoc.CreateAttribute("site"); xnodeRepository.Attributes.Append(attrSite); } //Set the attribute value attrSite.Value = siteId; }
void ReadXML() { //load the file reader = new StreamReader(documentsPath); //Create an XML Document and load it in. xmlDoc = new XmlDocument(); xmlDoc.LoadXml(reader.ReadToEnd()); //Check to see if xml loaded if (xmlDoc == null) Debug.Log("Failed load Variables DLL"); //Load Nodes m_FullScreen = xmlDoc.SelectSingleNode("SEPT/Fullscreen"); m_ResolutionX = xmlDoc.SelectSingleNode("SEPT/ResolutionX"); m_ResolutionY = xmlDoc.SelectSingleNode("SEPT/ResolutionY"); m_ResolutionWidth = xmlDoc.SelectSingleNode("SEPT/ResolutionWidth"); m_ResolutionHeight = xmlDoc.SelectSingleNode("SEPT/ResolutionHeight"); m_GUIOffsetX = xmlDoc.SelectSingleNode("SEPT/GUIOffsetX"); m_GUIOffsetY = xmlDoc.SelectSingleNode("SEPT/GUIOffsetY"); //Convert to format needed m_bFullScreen = bool.Parse(m_FullScreen.InnerXml); m_fResolutionX = float.Parse(m_ResolutionX.InnerXml); m_fResolutionY = float.Parse(m_ResolutionY.InnerXml); m_fResolutionWidth = float.Parse(m_ResolutionWidth.InnerXml); m_fResolutionHeight = float.Parse(m_ResolutionHeight.InnerXml); m_fGUIOffsetX = float.Parse(m_GUIOffsetX.InnerXml); m_fGUIOffsetY = float.Parse(m_GUIOffsetY.InnerXml); //Clear up xmldoc reader.Close(); //xmlDoc = null; }
public void InjectXmlString(string source) { //Debug.Log("InjectXmlString :"+source); xmlNode = DataMakerXmlUtils.StringToXmlNode(source); RegisterEventHandlers(); }
public void Load() { xmldoc = new XmlDocument(); xmldoc.Load("Config.xml"); root = xmldoc.SelectSingleNode("XML"); }
public static Name GetName(XmlNode node) { string first_name = GetField (node, "t:name/t:first-name"); string last_name = GetField (node, "t:name/t:last-name"); return new Name (first_name, last_name); }
/// <summary> /// Import atlasData from sparrow xml /// </summary> protected override OTAtlasData[] Import() { if (!ValidXML()) return new OTAtlasData[] { }; List<OTAtlasData> data = new List<OTAtlasData>(); if (xml.DocumentElement.Name == "TextureAtlas") { XmlNodeList subTextures = xml.DocumentElement.SelectNodes("SubTexture"); for (int si = 0; si < subTextures.Count; si++) { subTexture = subTextures[si]; OTAtlasData ad = new OTAtlasData(); ad.name = S("name"); ad.position = new Vector2(I("x"), I("y")); ad.size = new Vector2(I("width"), I("height")); ad.frameSize = new Vector2(I("frameWidth"), I("frameHeight")); ad.offset = new Vector2(I("frameX"), I("frameY")) * -1; data.Add(ad); } } return data.ToArray(); }
public static bool Parse( /*in*/ XmlNode _TableNode , out InterpolateTable _Result ) { InterpolatePair anewPair = null ; _Result = new InterpolateTable() ; if( null != _TableNode.Attributes[ "name" ] ) { _Result.m_Name =_TableNode.Attributes[ "name" ].Value ; if( _TableNode.HasChildNodes ) { for( int i = 0 ; i < _TableNode.ChildNodes.Count ; ++i ) { if( "InterpolatePair" == _TableNode.ChildNodes[ i ].Name ) { if( true == XMLParseInterpolatePair.Parse( _TableNode.ChildNodes[ i ] , out anewPair ) ) { _Result.m_Table.Add( anewPair ) ; } } } } return true ; } return false ; }
/// <summary> /// Creates a serialized object from an XmlNode that is the child of a parent node /// </summary> /// <param name="node">The xml node that this serialized object is wrapping</param> /// <param name="parentNode">The parent node that we are a part of</param> protected SerializedObjectNode(XmlNode node, SerializedObjectNode parentNode) { m_xmlNode = node; m_parentNode = parentNode; if (m_xmlNode.Attributes != null) { XmlAttribute versionAttribute = m_xmlNode.Attributes["version"]; if (versionAttribute != null) { string fullVersionString = versionAttribute.Value; while (!string.IsNullOrEmpty(fullVersionString)) { int versionNameDelimiterIndex = fullVersionString.IndexOf(','); string versionName = versionNameDelimiterIndex < 0 ? fullVersionString : fullVersionString.Substring(0, versionNameDelimiterIndex); if (versionNameDelimiterIndex > -1) fullVersionString = fullVersionString.Substring(versionNameDelimiterIndex + 1); else fullVersionString = null; SerializedVersionInfo newVersionInfo = SerializedVersionInfo.Parse(versionName); m_versionInfo.AddFirst(newVersionInfo); } } } foreach (XmlNode childNode in m_xmlNode.ChildNodes) { SerializedObjectNode newChildNode = new SerializedObjectNode(childNode, this); m_children.Add(childNode.Name, newChildNode); } }
public static List<List<int>> GetXmlAttrIntss(XmlNode node, string key) { //Debug.Log(key); int num = 0; List<List<int>> result = new List<List<int>>(); string str = node.Attributes[key].InnerText; if (!string.IsNullOrEmpty(str)) { string[] strs = str.Split(','); foreach (string item in strs) { List<int> r = new List<int>(); string[] items = item.Split('|'); foreach (string s in items) { if (int.TryParse(s, out num)) { r.Add(num); } } result.Add(r); } } return result; }
public override void xmlToVo(XmlNode node) { XmlElement xmlelement = (XmlElement)node; id = int.Parse(xmlelement.GetAttribute("id")); name = xmlelement.GetAttribute("name"); age = int.Parse(xmlelement.GetAttribute("age")); }
/*! \brief This function create a new Medium based on the information in the given XML Node \param node The XmlNode to load. \return Return the new Medium */ public Medium loadMedium(XmlNode node) { Medium medium = new Medium(); foreach (XmlNode attr in node) { switch (attr.Name) { case "Id": medium.setId(Convert.ToInt32(attr.InnerText)); break; case "Name": medium.setName(attr.InnerText); break; case "Energy": loadEnergy(attr.InnerText, medium); break; case "EnergyProductionRate": loadEnergyProductionRate(attr.InnerText, medium); break; case "MaxEnergy": loadMaxEnergy(attr.InnerText, medium); break; case "ReactionsSet": medium.setReactionsSet(attr.InnerText); break; case "MoleculesSet": medium.setMoleculesSet(attr.InnerText); break; } } return medium; }
/* * Tanks are subset of Vehicles. * Tanks has turrets rotation and are subject of interest. */ public Vehicle(XmlNode vdata) { VehicleXmlParser parser = new VehicleXmlParser(vdata); hpstock = parser.getHpStock(); hptop = parser.getHpTop(); status = defineStatus(parser); }
public Level(XmlNode data) { this.data = data; target = data.FindSkills().First(); level = data.GetInt(); xp = data.Child(XP).GetFloat(); }
public static Vector2 FromXMLVector2(XmlNode node) { Vector2 output = new Vector3(); output.x = float.Parse(node["x"].FirstChild.Value); output.y = float.Parse(node["y"].FirstChild.Value); return output; }
public bool loadInstantReactions(XmlNode node, LinkedList<IReaction> reactions) { XmlNodeList IReactionsList = node.SelectNodes("instantReaction"); bool b = true; foreach (XmlNode IReaction in IReactionsList) { InstantReaction ir = new InstantReaction(); foreach (XmlNode attr in IReaction) { switch (attr.Name) { case "name": ir.setName(attr.InnerText); break; case "reactants": loadInstantReactionReactants(attr, ir); break; case "products": loadInstantReactionProducts(attr, ir); break; } } reactions.AddLast(ir); } return b; }
public DesignationData( XmlNode node) { try { SetValue( ref id, node, "SubTitle_ID"); SetValue( ref eType, node, "SubTitle_Type"); SetValue( ref eCategory, node, "SubTitle_Category"); SetValue( ref name, node, "SubTitle_Name"); SetValue( ref nameColor, node, "SubTitle_Color"); SetValue( ref desc, node, "SubTitle_Description1"); SetValue( ref effectDesc, node, "SubTitle_Description2"); SetValue( ref notice, node, "SubTitle_Notice"); SetValue( ref rankPoint, node, "SubTitle_RankPoint"); SetValue( ref DivineKnight_Item_ID, node, "DivineKnight_Item_ID"); SetValue( ref DivineKnight_Item_Count, node, "DivineKnight_Item_Count"); SetValue( ref Magician_Item_ID, node, "Magician_Item_ID"); SetValue( ref Magician_Item_Count, node, "Magician_Item_Count"); SetValue( ref Cleric_Item_ID, node, "Cleric_Item_ID"); SetValue( ref Cleric_Item_Count, node, "Cleric_Item_Count"); SetValue( ref Hunter_Item_ID, node, "Hunter_Item_ID"); SetValue( ref Hunter_Item_Count, node, "Hunter_Item_Count"); } catch( System.Exception e) { Debug.LogError(e); } }
private bool loadInstantReactionProducts(XmlNode node, InstantReaction ir) { foreach (XmlNode attr in node) if (attr.Name == "product") loadInstantReactionProduct(attr, ir); return true; }
public DialogResponse(XmlNode xnode) { text = MyXml.GetString(xnode, "text"); action = MyXml.GetString(xnode, "action"); jump = MyXml.GetString(xnode, "jump"); condition = MyXml.GetString(xnode, "condition"); }
// Use this for initialization void Start() { panelText = GetComponentInChildren<UnityEngine.UI.Text>(); if (currentConvo) { currentNode = currentConvo.conversationXml.GetElementsByTagName("ContentNode")[0]; } }
/// <summary> /// Constructor /// </summary> /// <param name="projectNode"></param> public SiteProject(XmlNode projectNode) { var sbDevNotes = new StringBuilder(); if(projectNode.Name.ToLower() != "project") { AppDiagnostics.Assert(false, "Not a project"); throw new Exception("Unexpected content - not project"); } this.Id = projectNode.Attributes["id"].Value; this.Name = projectNode.Attributes["name"].Value; var descriptionNode = projectNode.Attributes["description"]; if(descriptionNode != null) { this.Description = descriptionNode.Value; } else { this.Description = ""; sbDevNotes.AppendLine("Project is missing description attribute"); } this.DeveloperNotes = sbDevNotes.ToString(); }
public virtual void ReadFromXMLNode(XmlNode node) { try { // Deal with model path, must be only one LoadModelPathNode(node); // Deal with the start position XmlNode startPositionNode = node.SelectSingleNode(ModelXMLDefinition.StartPosition); if (startPositionNode != null) { m_ptStartPoint = CPoint3DSerializer.ReadPoint(startPositionNode); } // Read the scaleDirection XmlNode scaleDirectionNode = node.SelectSingleNode(ModelXMLDefinition.SacleDirection); CPoint3D scaleDirection = CPoint3DSerializer.ReadPoint(scaleDirectionNode); Vector3D vec = new Vector3D(scaleDirection.X, scaleDirection.Y, scaleDirection.Z); if (vec.LengthSquared != 0) { vec.Normalize(); m_scaleDirection = vec; } } catch (SystemException ex) { string errMsg = ex.Message + "\n" + ex.StackTrace; vtk.vtkOutputWindow.GetInstance().DisplayErrorText(errMsg); throw; } }
string SafeGetAttribute (XmlNode node, string name) { XmlAttribute attr = node.Attributes [name]; if (attr != null) return attr.Value; return String.Empty; }
protected SiteDocumentBase(XmlNode xmlNode) { this.Name = xmlNode.Attributes["name"].Value; this.Id = xmlNode.Attributes["id"].Value; //Note: [2015-10-28] Datasources presently don't return this information // this.ContentUrl = xmlNode.Attributes["contentUrl"].Value; //Namespace for XPath queries var nsManager = XmlHelper.CreateTableauXmlNamespaceManager("iwsOnline"); //Get the project attributes var projectNode = xmlNode.SelectSingleNode("iwsOnline:project", nsManager); this.ProjectId = projectNode.Attributes["id"].Value; this.ProjectName = projectNode.Attributes["name"].Value; //Get the owner attributes var ownerNode = xmlNode.SelectSingleNode("iwsOnline:owner", nsManager); this.OwnerId = ownerNode.Attributes["id"].Value; //See if there are tags var tagsNode = xmlNode.SelectSingleNode("iwsOnline:tags", nsManager); if (tagsNode != null) { this.TagsSet = new SiteTagsSet(tagsNode); } }
public SelectableItemEx(XmlNode node, MenuElement menuElement) { XmlNode bg = node.SelectSingleNode("component"); if (bg == null){ Debug.Log("XXXXXXXX"); Texture2D texture = Resources.Load("page/"+node.Attributes["src"].Value, typeof(Texture2D)) as Texture2D; setTexutre(texture, 1024f, 686f); } else{ Texture2D texture = Resources.Load("page/pbg", typeof(Texture2D)) as Texture2D; setTexutre(texture, 1024f, 686f); XmlNodeList cs = bg.SelectNodes("c"); foreach (XmlNode c in cs){ Texture2D tex = menuElement.GetTextureById(c.Attributes["src"].Value); float x = float.Parse(c.Attributes["x"].Value); float y = float.Parse(c.Attributes["y"].Value); float w = float.Parse(c.Attributes["w"].Value); float h = float.Parse(c.Attributes["h"].Value); Sprite s = new Sprite(tex, w, h); s.x = x; s.y = y; addChild(s); } } }
public GameInformation(XmlNode node) { if (node ["Title"] != null) gameName = node ["Title"].InnerText; if (node ["Description"] != null) description = node ["Description"].InnerText; if (node ["LongDescription"] != null) longDescription = node ["LongDescription"].InnerText; if (node ["FileLocation"] != null) programLocation = node ["FileLocation"].InnerText; if (node ["Arguments"] != null) arguments = node ["Arguments"].InnerText; if (node ["Website"] != null) website = node ["Website"].InnerText; if (node ["CreationDate"] != null) releaseDate = node ["CreationDate"].InnerText; if (node ["NumberOfPlayers"] != null) requiredPlayers = int.Parse (node ["NumberOfPlayers"].InnerText); if (node ["Authors"] != null) { XmlNodeList aths = node ["Authors"].GetElementsByTagName ("Author"); authors = new string[aths.Count]; for (int i = 0; i < aths.Count; i++) { authors [i] = aths [i].InnerText; } } if (node ["ImageLocation"] != null) { imagePath = "file://" + Application.dataPath + node ["ImageLocation"].InnerText; } }
public override void Load(XmlNode xnode) { type = LocalType.Get(xnode.Name); texture = new Texture(); name = MyXml.GetString(xnode, "name"); variations = MyXml.GetInt(xnode, "variations", 1); maxHP = MyXml.GetInt(xnode, "hp"); damage = MyXml.GetInt(xnode, "damage"); attack = MyXml.GetInt(xnode, "attack"); defence = MyXml.GetInt(xnode, "defence"); armor = MyXml.GetInt(xnode, "armor"); movementTime = MyXml.GetFloat(xnode, "movementTime"); attackTime = MyXml.GetFloat(xnode, "attackTime"); isWalkable = MyXml.GetBool(xnode, "walkable"); isFlat = MyXml.GetBool(xnode, "flat"); if (xnode.Name == "Thing") isWalkable = true; string s = MyXml.GetString(xnode, "type"); if (s != "") creatureType = CreatureType.Get(s); s = MyXml.GetString(xnode, "corpse"); if (creatureType != null && (creatureType.name == "Animal" || creatureType.name == "Sentient")) s = "Blood"; if (s != "") corpse = Get(s); s = MyXml.GetString(xnode, "onDeath"); if (creatureType != null && creatureType.name == "Animal") s = "Large Chunk of Meat"; if (s != "") onDeath = ItemShape.Get(s); for (xnode = xnode.FirstChild; xnode != null; xnode = xnode.NextSibling) abilities.Add(BigBase.Instance.abilities.Get(MyXml.GetString(xnode, "name"))); }
private static bool RunFileAction (XmlNode fileElement) { string path = GetAttribute (fileElement, "Path"); XmlDocument doc = new XmlDocument (); try { doc.Load (path); } catch { Console.WriteLine ("ERROR: Could not open {0}.", path); return false; } Console.WriteLine ("Processing {0}...", path); foreach (XmlNode element in fileElement.SelectNodes ("Replace")) if (!ReplaceNode (fileElement.OwnerDocument, doc, element)) return false; foreach (XmlNode element in fileElement.SelectNodes ("Insert")) if (!InsertNode (fileElement.OwnerDocument, doc, element)) return false; foreach (XmlNode element in fileElement.SelectNodes ("Remove")) if (!RemoveNodes (doc, element)) return false; doc.Save (path); Console.WriteLine ("{0} saved.", path); return true; }
public virtual void ReadFromXMLNode(XmlNode node) { try { // Read the pylons models XmlNodeList cableStates = node.SelectNodes(ModelXMLDefinition.CableState); foreach (XmlNode cableState in cableStates) { CCableState normalNode = new CCableState(this, new CCablingConnectionIndicator(new CLineTwoPointsIndicatorsImpl())); normalNode.ReadFromXMLNode(cableState); } //// Set active cable state to the first one if it exists //if (CableStates != null && CableStates.Count != 0) //{ // ActiveCableState = CableStates[0]; //} // Read the cable switch condition XmlNode cableConditionNode = node.SelectSingleNode(ModelXMLDefinition.CableSwitchCondition); if (cableConditionNode != null) { m_cableSwitchCondition = CCableSwitchConditionFactory.ReadFromXMLNode(cableConditionNode, this); } } catch (SystemException ex) { string errMsg = "Read cable data failed:\n" + ex.Message + "\n" + ex.StackTrace; vtk.vtkOutputWindow.GetInstance().DisplayErrorText(errMsg); throw; } }
public static bool InstallPackages(string folders, string webRootPath) { bool install = false; string binFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location); foreach (string folder in folders.Split(',')) { string sourceFolder = Path.Combine(webRootPath, folder); if (!Directory.Exists(sourceFolder)) { Directory.CreateDirectory(sourceFolder); } // iterate through Nuget packages in source folder foreach (string packagename in Directory.GetFiles(sourceFolder, "*.nupkg")) { // iterate through files using (ZipArchive archive = ZipFile.OpenRead(packagename)) { string frameworkversion = ""; // locate nuspec foreach (ZipArchiveEntry entry in archive.Entries) { if (entry.FullName.ToLower().EndsWith(".nuspec")) { // open nuspec XmlTextReader reader = new XmlTextReader(entry.Open()); reader.Namespaces = false; // remove namespace XmlDocument doc = new XmlDocument(); doc.Load(reader); // get framework dependency XmlNode node = doc.SelectSingleNode("/package/metadata/dependencies/dependency[@id='Oqtane.Framework']"); if (node != null) { frameworkversion = node.Attributes["version"].Value; } reader.Close(); } } // if compatible with framework version if (frameworkversion == "" || Version.Parse(Constants.Version).CompareTo(Version.Parse(frameworkversion)) >= 0) { List <string> assets = new List <string>(); // module and theme packages must be in form of name.1.0.0.nupkg string name = Path.GetFileNameWithoutExtension(packagename); string[] segments = name?.Split('.'); if (segments != null) { name = string.Join('.', segments, 0, segments.Length - 3); } // deploy to appropriate locations foreach (ZipArchiveEntry entry in archive.Entries) { string foldername = Path.GetDirectoryName(entry.FullName).Split(Path.DirectorySeparatorChar)[0]; string filename = Path.GetFileName(entry.FullName); switch (foldername) { case "lib": filename = Path.Combine(binFolder, filename); ExtractFile(entry, filename); assets.Add(filename); break; case "wwwroot": filename = Path.Combine(webRootPath, Utilities.PathCombine(entry.FullName.Replace("wwwroot/", "").Split('/'))); ExtractFile(entry, filename); assets.Add(filename); break; case "runtimes": var destSubFolder = Path.GetDirectoryName(entry.FullName); filename = Path.Combine(binFolder, destSubFolder, filename); ExtractFile(entry, filename); assets.Add(filename); break; } } // save list of assets if (assets.Count != 0) { string assetfilepath = Path.Combine(webRootPath, folder, name, "assets.json"); if (File.Exists(assetfilepath)) { File.Delete(assetfilepath); } File.WriteAllText(assetfilepath, JsonSerializer.Serialize(assets)); } } } // remove package File.Delete(packagename); install = true; } } return(install); }
public override void SetSettings(XmlNode settings) { Log.Info("Settings set!"); //var oldToken = Settings.OAuthToken; Settings.SetSettings(settings); }
public clipFunction(IRaster raster, XmlNode xmlnode) { InitializeComponent(); this.m_raster = raster; this.m_xmlnode = xmlnode; }
/// <summary> /// This method is syntactic sugar for attempting to read a data field /// from an XmlNode. This version sets the output variable to its /// default value in case of a failed read and can be used for /// initializing variables /// </summary> /// <typeparam name="T">The type to convert to</typeparam> /// <param name="node">The XmlNode to read from</param> /// <param name="field">The field to try and extract from the XmlNode</param> /// <param name="read">The variable to save the read to</param> /// <param name="onError">The value to return in case of failure. This parameter is optional</param> /// <returns>true if successful read</returns> public static bool TryGetField <T>(this XmlNode node, string field, out T read, T onError = default) where T : IConvertible { /* * This extension method allows easier access of xml, instead of * the old TryCatch blocks, not even logging the error * * It works because most of the types we read from the XmlNode is * IConvertible that can be converted to or from string with just * a type argument, first known at runtime (not true, but generics) * * because it is now a generic method, instead of * try{convert();} * catch{noop();} * * We can do some actual error checking instead of relying on exceptions * in case anything happens. We could do that before, but typing 10 * lines to read a single variable 100 times would be insane * * That means this should be an order of magnitude faster in case of * missing fields and a little bit slower in case of fields being there * * To use this method, call it like this * * aXmlNode.TryGetField("fieldname", out myVariable); * * The compiler will fill out <T> itself, unless you specifically * tell it to be something else * * in case you need to act on whether the read was successful * do it like this * if(aXmlNode.TryGetField("fieldname", out myVariable)) * { * success(); * } * else * { * failure(); * } */ string fieldValue = null; if (!CheckGetField <T>(node, field, ref fieldValue)) { read = onError; return(false); } try { read = (T)Convert.ChangeType(fieldValue, typeof(T), GlobalSettings.InvariantCultureInfo); return(true); } catch { //If we are debugging, great //Utils.BreakIfDebug(); //Otherwise just log it #if DEBUG System.Reflection.MethodBase mth = new StackTrace().GetFrame(1).GetMethod(); string errorMsg = string.Format ( GlobalSettings.InvariantCultureInfo, "Tried to read missing field \"{0}\" in {1}.{2}", field, mth.ReflectedType?.Name, mth ); #else string errorMsg = "Tried to read missing field \"" + field + '\"'; #endif Log.Error(errorMsg); //Finally, we have to assign an out parameter something, so default //null or 0 most likely read = onError; return(false); } }
public static CT_ScatterSer Parse(XmlNode node, XmlNamespaceManager namespaceManager) { if (node == null) { return(null); } CT_ScatterSer ctObj = new CT_ScatterSer(); ctObj.dPt = new List <CT_DPt>(); ctObj.trendline = new List <CT_Trendline>(); ctObj.errBars = new List <CT_ErrBars>(); ctObj.extLst = new List <CT_Extension>(); foreach (XmlNode childNode in node.ChildNodes) { if (childNode.LocalName == "idx") { ctObj.idx = CT_UnsignedInt.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "order") { ctObj.order = CT_UnsignedInt.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "tx") { ctObj.tx = CT_SerTx.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "spPr") { ctObj.spPr = CT_ShapeProperties.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "marker") { ctObj.marker = CT_Marker.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "dLbls") { ctObj.dLbls = CT_DLbls.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "xVal") { ctObj.xVal = CT_AxDataSource.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "yVal") { ctObj.yVal = CT_NumDataSource.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "smooth") { ctObj.smooth = CT_Boolean.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "dPt") { ctObj.dPt.Add(CT_DPt.Parse(childNode, namespaceManager)); } else if (childNode.LocalName == "trendline") { ctObj.trendline.Add(CT_Trendline.Parse(childNode, namespaceManager)); } else if (childNode.LocalName == "errBars") { ctObj.errBars.Add(CT_ErrBars.Parse(childNode, namespaceManager)); } else if (childNode.LocalName == "extLst") { ctObj.extLst.Add(CT_Extension.Parse(childNode, namespaceManager)); } } return(ctObj); }
/// <summary> /// 移除子结点 /// </summary> /// <param name="XmlFatherNode">父域节点</param> /// <param name="XmlDeleteNode">需要查询的子结点</param> /// <returns></returns> public static XmlNode RemoveChildNode(XmlNode XmlFatherNode, XmlNode XmlDeleteNode) { XmlFatherNode.RemoveChild(XmlDeleteNode); return(XmlFatherNode); }
/// <summary> /// 删除一个子结点 /// </summary> /// <param name="QueryString">XPath查询表达式</param> public void RemoveChild(string QueryString) { _XmlNode = RemoveChildNode(_XmlNode, QueryString); }
public static string Infoset (XmlNode nod) { StringBuilder sb = new StringBuilder (); GetInfoset (nod, sb); return sb.ToString (); }
/// <summary> /// 读取某个XML节点的属性值(根据属性名) /// </summary> /// <param name="xmlNode"></param> /// <param name="attrName"></param> /// <returns></returns> public static string ReadAttrValue(XmlNode xmlNode, string attrName) { return(((XmlElement)xmlNode).GetAttribute(attrName)); }
/// <summary> /// 获取父节点下指定名称的子节点列表 /// </summary> /// <param name="parentNode"></param> /// <param name="childNodeName"></param> /// <returns></returns> public static XmlNodeList GetChildNodes(XmlNode parentNode, string childNodeName) { return(GetXmlNodesByXPathExpr(parentNode, childNodeName)); }
void AddDataXmlNode(string xPath, string sValue) { XmlNode nodeControl = xDoc.SelectSingleNode(xPath); nodeControl.Attributes["Value"].Value = sValue; }
private void setControlLanguage() { try { XmlDocument doc = new XmlDocument(); doc.Load(@"..\..\bin\Debug\DrillOS_" + AppDrill.language + ".xml"); //加载XML文件 XmlNode xn = doc.SelectSingleNode("Form"); //获取根节点 XmlNodeList xnl = xn.ChildNodes; //得到根节点下的所有子节点(Form-xxxForm) foreach (XmlNode x in xnl) { if (x.Name == this.Name) //比较当前节点的名称是否是当前Form名称 { XmlNodeList xn_list = x.ChildNodes; //得到根节点下的所有子节点 foreach (XmlNode node in xn_list) { XmlElement xe = (XmlElement)node;//将节点转换为元素 //循环每个控件,设置当前语言应设置的值 foreach (Control c in this.Controls) { //判断当前Node的key是否是当前需要设置的控件名称 if (c.Name == xe.GetAttribute("key")) { #region 单独针对panel if (c.Name == "radPanel1" || c.Name == "radPanel3" || c.Name == "radPanel2" || c.Name == "rpal_formset" || c.Name == "rpnl_wits") { XmlNodeList xn_list2 = node.ChildNodes;//寻找control下面的control foreach (XmlNode node2 in xn_list2) { XmlElement xe2 = (XmlElement)node2; foreach (Control ctl in c.Controls) { if (ctl.Name == xe2.GetAttribute("key")) { switch (ctl.Name) { case "rdp_language": XmlNodeList xn_list_language = node2.ChildNodes; foreach (XmlNode node3 in xn_list_language) { XmlElement xe3 = (XmlElement)node3; list_language.Add(new RadListDataItem(xe3.GetAttribute("value"), xe3.GetAttribute("key"))); } break; case "rdp_sys": XmlNodeList xn_list_sys = node2.ChildNodes; foreach (XmlNode node3 in xn_list_sys) { XmlElement xe3 = (XmlElement)node3; list_sys.Add(new RadListDataItem(xe3.GetAttribute("value"), xe3.GetAttribute("key"))); } break; case "rdp_wellNo": selectDrill = xe2.GetAttribute("value"); break; default: ctl.Text = xe2.GetAttribute("value"); break; } } } } } #endregion if (c.Name == "lbl_error") { XmlNodeList xn_list_error = node.ChildNodes; foreach (XmlNode node3 in xn_list_error) { XmlElement xe3 = (XmlElement)node3; list_error.Add(xe3.GetAttribute("value")); } } c.Text = xe.GetAttribute("value");//设置控件的Text break; } } } } } } catch { } }
/// <summary> /// Returns an XmlNode representing the current result after /// adding it as a child of the supplied parent node. /// </summary> /// <param name="parentNode">The parent node.</param> /// <param name="recursive">If true, descendant results are included</param> /// <returns></returns> public abstract XmlNode AddToXml(XmlNode parentNode, bool recursive);
public Node CreateInstance(Graph g, XmlNode reader) { return(FactoryXml(g, reader)); }
/// <summary> /// Constructor /// </summary> /// <param name="worksheet"></param> /// <param name="address"></param> /// <param name="validationType"></param> /// <param name="itemElementNode"></param> /// <param name="namespaceManager"></param> internal ExcelDataValidationTime(ExcelWorksheet worksheet, string address, ExcelDataValidationType validationType, XmlNode itemElementNode, XmlNamespaceManager namespaceManager) : base(worksheet, address, validationType, itemElementNode, namespaceManager) { Formula = new ExcelDataValidationFormulaTime(NameSpaceManager, TopNode, _formula1Path); Formula2 = new ExcelDataValidationFormulaTime(NameSpaceManager, TopNode, _formula2Path); }
/// <summary> /// Initializes a new instance of the charttitle class. /// </summary> /// <param name="document">The document.</param> /// <param name="node">The node.</param> public ChartTitle(IDocument document, XmlNode node) { this.Document = document; this.Node = node; this.InitStandards(); }
/// <summary> /// 获取需要查询的子节点值 /// </summary> /// <param name="XmlFatherNode">父域节点</param> /// <param name="QueryString">XPath查询表达式</param> /// <returns></returns> public static string getNodeValue(XmlNode XmlFatherNode, string QueryString) { return(getNodeValue(FindSencetion(XmlFatherNode, QueryString))); }
private void bW_SubmitScores_DoWork(object sender, DoWorkEventArgs e) { bW_SubmitScores.ReportProgress(1); // Downloading score manifest... string manifestResponseString = GetResponseAsString("api/manifest"); List<string> guids = JsonConvert.DeserializeObject<List<string>>(manifestResponseString); bW_SubmitScores.ReportProgress(2, guids.Count); // Found n scores. bW_SubmitScores.ReportProgress(3); // Downloading simfile catalog... WebClient webClient = new WebClient(); webClient.DownloadFile(BuildURI("catalog.json.zip"), "catalog.json.zip"); bW_SubmitScores.ReportProgress(4); // Decompressing catalog... using (var unzip = new Internals.Unzip("catalog.json.zip")) { unzip.Extract(@"catalog.json", "catalog.json"); } StreamReader catalogfile = File.OpenText("catalog.json"); bW_SubmitScores.ReportProgress(6); // Serializing JSON Data... JsonSerializer serializer = new JsonSerializer(); List<Simfile> catalog = (List<Simfile>)serializer.Deserialize(catalogfile, typeof(List<Simfile>)); File.Delete("catalog.json.zip"); bW_SubmitScores.ReportProgress(5); // Validating catalog checksum... string cataloghash = GetSHA(File.OpenText("catalog.json")).ToUpper(); if (cataloghash != GetResponseAsString("api/catalog/sha").ToUpper()) { bW_SubmitScores.ReportProgress(18); // Simfile catalog mismatch. bW_SubmitScores.CancelAsync(); } bW_SubmitScores.ReportProgress(7, catalog.Count); // Loaded N Simfile hashes. //Start iterating scores. bW_SubmitScores.ReportProgress(8); // Loading config file... // Load App parameters from config file. XmlDocument config = new XmlDocument(); config.Load("config.xml"); XmlNode app = config.SelectSingleNode("//app"); // See if there's a LocalProfile to use. bW_SubmitScores.ReportProgress(9); // Checking for local profile... string PlayerGuid = ""; if (File.Exists(app.Attributes["datadir"].Value + "/Save/LocalProfiles/" + app.Attributes["localprofile"].Value + "/Stats.xml")) { XmlDocument profilestats = new XmlDocument(); profilestats.Load(app.Attributes["datadir"].Value + "/Save/LocalProfiles/" + app.Attributes["localprofile"].Value + "/Stats.xml"); PlayerGuid = profilestats.SelectSingleNode("//Stats/GeneralData/Guid").InnerText; } // Count scores in Upload folder. bW_SubmitScores.ReportProgress(10); // Examining uploads folder... string[] uploads = Directory.GetFiles(app.Attributes["datadir"].Value + "/Save/Upload"); bW_SubmitScores.ReportProgress(11, uploads.Length); // Found N Scores //Parse scores. var dict = new Dictionary<int, Dictionary<string, string>> { }; int i = 0; foreach (string upload in uploads) { XmlDocument uploadxml = new XmlDocument(); uploadxml.Load(upload); // If the Guid of this upload is already in the database for this user, skip this file. if (guids.Contains(uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/Guid").InnerText)) { bW_SubmitScores.ReportProgress(15, uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/Guid").InnerText); continue; } // If we're skipping fails and this is a fail, skip this file. string HighScore = uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/Grade").InnerText; if (HighScore == "Failed" && app.Attributes["uploadfails"].Value == "0") { bW_SubmitScores.ReportProgress(12, uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/Guid").InnerText); continue; } string xPlayerGuid = uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/PlayerGuid").InnerText; if (PlayerGuid == "" || PlayerGuid == xPlayerGuid) { // Check the hash of the file in the song dir against the catalog. try { string[] stepchart = Directory.GetFiles(app.Attributes["sm5dir"].Value + "\\" + uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/Song").Attributes["Dir"].Value, "*.sm"); if (stepchart.Length == 0) { // No .sm, look for a .dwi stepchart = Directory.GetFiles(app.Attributes["sm5dir"].Value + "\\" + uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/Song").Attributes["Dir"].Value, "*.dwi"); if (stepchart.Length == 0) { // No .dwi either, can't hash this, skip it. bW_SubmitScores.ReportProgress(13, uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/Guid").InnerText); continue; } } // At this point we should be able to hash whatever stepchart we ended up with in index 0. string simfilesha = GetSHA(File.OpenText(stepchart[0])).ToUpper(); string chartID = ""; try { Simfile simfile = catalog.Find(x => x.SHA256.Contains(simfilesha)); int simfile_id = simfile.ID; string difficulty = uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/Steps").Attributes["Difficulty"].Value.ToUpper(); string stepstype = uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/Steps").Attributes["StepsType"].Value.ToUpper(); Chart chart = simfile.Catalog.Find( x => (x.Difficulty.ToUpper() == difficulty && x.StepsType.ToUpper() == stepstype) ); chartID = chart.ID.ToString(); } // If this errors out it'll be immediate on the assignment of the simfile var because nothing in the Xenon DB has the same hash as this simfile. catch (ArgumentNullException error) { bW_SubmitScores.ReportProgress(14, uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/Guid").InnerText); continue; } catch (NullReferenceException error) { bW_SubmitScores.ReportProgress(14, uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/Guid").InnerText); continue; } // At this point all we have left are files which... // * Are not already in the scores table for this user... // * and have a matching hash in the simfile manifest... // * and have a corresponding chart ID to use. // We can, finally, begin uploading a new score. Dictionary<string, string> score = new Dictionary<string, string> { { "chart_id", chartID }, { "W1", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/TapNoteScores/W1").InnerText }, { "W2", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/TapNoteScores/W2").InnerText }, { "W3", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/TapNoteScores/W3").InnerText }, { "W4", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/TapNoteScores/W4").InnerText }, { "W5", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/TapNoteScores/W5").InnerText }, { "Miss", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/TapNoteScores/Miss").InnerText }, { "Held", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/HoldNoteScores/Held").InnerText }, { "LetGo", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/HoldNoteScores/LetGo").InnerText }, { "x_MachineGuid", uploadxml.SelectSingleNode("//Stats/MachineGuid").InnerText }, { "x_Grade", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/Grade").InnerText }, { "x_Score", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/Score").InnerText }, { "x_PercentDP", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/PercentDP").InnerText }, { "x_MaxCombo", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/MaxCombo").InnerText }, { "x_StageAward", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/StageAward").InnerText }, { "x_PeakComboAward", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/PeakComboAward").InnerText }, { "x_Modifiers", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/Modifiers").InnerText }, { "x_DateTime", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/DateTime").InnerText }, { "x_PlayerGuid", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/PlayerGuid").InnerText }, { "x_HitMine", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/TapNoteScores/HitMine").InnerText }, { "x_AvoidMine", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/TapNoteScores/AvoidMine").InnerText }, { "x_CheckpointMiss", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/TapNoteScores/CheckpointMiss").InnerText }, { "x_CheckpointHit", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/TapNoteScores/CheckpointHit").InnerText }, { "x_MissedHold", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/HoldNoteScores/MissedHold").InnerText }, { "x_Stream", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/RadarValues/Stream").InnerText }, { "x_Voltage", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/RadarValues/Voltage").InnerText }, { "x_Air", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/RadarValues/Air").InnerText }, { "x_Freeze", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/RadarValues/Freeze").InnerText }, { "x_Chaos", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/RadarValues/Chaos").InnerText }, { "x_Notes", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/RadarValues/Notes").InnerText }, { "x_TapsAndHolds", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/RadarValues/TapsAndHolds").InnerText }, { "x_Jumps", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/RadarValues/Jumps").InnerText }, { "x_Holds", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/RadarValues/Holds").InnerText }, { "x_Mines", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/RadarValues/Mines").InnerText }, { "x_Hands", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/RadarValues/Hands").InnerText }, { "x_Rolls", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/RadarValues/Rolls").InnerText }, { "x_Lifts", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/RadarValues/Lifts").InnerText }, { "x_Fakes", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/RadarValues/Fakes").InnerText }, { "x_Disqualified", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/Disqualified").InnerText }, { "x_Pad", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/Pad").InnerText }, { "x_StageGuid", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/StageGuid").InnerText }, { "x_Guid", uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/Guid").InnerText } }; // Add this score to the dictionary we'll serialize and send. dict.Add(i, score); i++; // Report the upload. bW_SubmitScores.ReportProgress(16, uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/Guid").InnerText); } catch (DirectoryNotFoundException error) { bW_SubmitScores.ReportProgress(13, uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/Guid").InnerText); continue; } catch (FileNotFoundException error) { bW_SubmitScores.ReportProgress(13, uploadxml.SelectSingleNode("//Stats/RecentSongScores/HighScoreForASongAndSteps/HighScore/Guid").InnerText); continue; } } } //We've iterated all scores now, let's send the final json dict. int scorecount = dict.Count; string json = JsonConvert.SerializeObject(dict, Newtonsoft.Json.Formatting.Indented); config.Load("config.xml"); XmlNode auth = config.SelectSingleNode("//auth"); // Build the web client... WebRequest request = WebRequest.Create(BuildURI("api/scores")); request.Method = "PUT"; request.Headers.Add("Authorization: Bearer " + auth.Attributes["access_token"].Value); request.ContentType = "application/json"; ASCIIEncoding encoding = new ASCIIEncoding(); Byte[] bytes = encoding.GetBytes(json); Stream stream = request.GetRequestStream(); // Send the PUT Request. stream.Write(bytes, 0, bytes.Length); stream.Close(); var response = (HttpWebResponse)request.GetResponse(); if ((int)response.StatusCode == 200) { bW_SubmitScores.ReportProgress(17, scorecount); } }
public LogicLoopContinue (XmlNode node):base (node) { }
// X, Xwidth,Xstride, Y, Yheight, Ystride public (int, int, int, int, int, int, float, bool, bool) ReadAmbianceSettings() { XmlNode result = settings.DocumentElement.SelectSingleNode("//AmbianceSettings"); //default settings int X = 0; int Xwidth = 1920; int Xstride = 10; int Y = 1060; int Yheight = 20; int Ystride = 2; float LimiterTimeValue = 10; bool LimiterActive = true; bool LimiterSecondsUpdate = false; //attempt read the options if (result != null) {//<X>0</X><Xwidth>1920</Xwidth><Xstride>10</Xstride><Y>1060</Y><Yheight>20</Yheight><Ystride>2</Ystride> Debug.WriteLine("[ReadAmbianceSettings()] " + result.InnerXml); //Parse the Xml try { X = int.Parse(result["X"].InnerText); } catch (Exception ex) { Debug.WriteLine("[ReadAmbianceSettings()] Encountered exception while reading X."); Debug.WriteLine(ex.Message); } try { Xwidth = int.Parse(result["Xwidth"].InnerText); } catch (Exception ex) { Debug.WriteLine("[ReadAmbianceSettings()] Encountered exception while reading Xwidth."); Debug.WriteLine(ex.Message); } try { Xstride = int.Parse(result["Xstride"].InnerText); } catch (Exception ex) { Debug.WriteLine("[ReadAmbianceSettings()] Encountered exception while reading Xstride."); Debug.WriteLine(ex.Message); } try { Y = int.Parse(result["Y"].InnerText); } catch (Exception ex) { Debug.WriteLine("[ReadAmbianceSettings()] Encountered exception while reading Y."); Debug.WriteLine(ex.Message); } try { Yheight = int.Parse(result["Yheight"].InnerText); } catch (Exception ex) { Debug.WriteLine("[ReadAmbianceSettings()] Encountered exception while reading Yheight."); Debug.WriteLine(ex.Message); } try { Ystride = int.Parse(result["Ystride"].InnerText); } catch (Exception ex) { Debug.WriteLine("[ReadAmbianceSettings()] Encountered exception while reading Ystride."); Debug.WriteLine(ex.Message); } try { LimiterTimeValue = float.Parse(result["LimiterTimeValue"].InnerText); } catch (Exception ex) { Debug.WriteLine("[ReadAmbianceSettings()] Encountered exception while reading LimiterTimeValue."); Debug.WriteLine(ex.Message); } try { LimiterActive = bool.Parse(result["LimiterActive"].InnerText); } catch (Exception ex) { Debug.WriteLine("[ReadAmbianceSettings()] Encountered exception while reading LimiterActive."); Debug.WriteLine(ex.Message); } try { LimiterSecondsUpdate = bool.Parse(result["LimiterSecondsUpdate"].InnerText); } catch (Exception ex) { Debug.WriteLine("[ReadAmbianceSettings()] Encountered exception while reading LimiterSecondsUpdate."); Debug.WriteLine(ex.Message); } } //Default values return (X, Xwidth, Xstride, Y, Yheight, Ystride, LimiterTimeValue, LimiterActive, LimiterSecondsUpdate); }
private void ProcessSqlQuery(XmlNode x) { }
/// <summary> /// Processes a single operation node with children that are either nodes to check whether the parent has a node that fulfills a condition, or they are nodes that are parents to further operation nodes /// </summary> /// <param name="blnIsOrNode">Whether this is an OR node (true) or an AND node (false). Default is AND (false).</param> /// <param name="xmlOperationNode">The node containing the filter operation or a list of filter operations. Every element here is checked against corresponding elements in the parent node, using an operation specified in the element's attributes.</param> /// <param name="xmlParentNode">The parent node against which the filter operations are checked.</param> /// <returns>True if the parent node passes the conditions set in the operation node/nodelist, false otherwise.</returns> public static bool ProcessFilterOperationNode(this XmlNode xmlParentNode, XmlNode xmlOperationNode, bool blnIsOrNode) { if (xmlOperationNode == null) { return(false); } using (XmlNodeList xmlOperationChildNodeList = xmlOperationNode.SelectNodes("*")) { if (xmlOperationChildNodeList != null) { foreach (XmlNode xmlOperationChildNode in xmlOperationChildNodeList) { XmlAttributeCollection xmlOperationChildNodeAttributes = xmlOperationChildNode.Attributes; bool blnInvert = xmlOperationChildNodeAttributes?["NOT"] != null; bool blnOperationChildNodeResult = blnInvert; string strNodeName = xmlOperationChildNode.Name; switch (strNodeName) { case "OR": blnOperationChildNodeResult = ProcessFilterOperationNode(xmlParentNode, xmlOperationChildNode, true) != blnInvert; break; case "AND": blnOperationChildNodeResult = ProcessFilterOperationNode(xmlParentNode, xmlOperationChildNode, false) != blnInvert; break; case "NONE": blnOperationChildNodeResult = (xmlParentNode == null) != blnInvert; break; default: { if (xmlParentNode != null) { string strOperationType = xmlOperationChildNodeAttributes?["operation"]?.InnerText ?? "=="; XmlNodeList objXmlTargetNodeList = xmlParentNode.SelectNodes(strNodeName); // If we're just checking for existence of a node, no need for more processing if (strOperationType == "exists") { blnOperationChildNodeResult = (objXmlTargetNodeList.Count > 0) != blnInvert; } else { // default is "any", replace with switch() if more check modes are necessary bool blnCheckAll = xmlOperationChildNodeAttributes?["checktype"]?.InnerText == "all"; blnOperationChildNodeResult = blnCheckAll; string strOperationChildNodeText = xmlOperationChildNode.InnerText; bool blnOperationChildNodeEmpty = string.IsNullOrWhiteSpace(strOperationChildNodeText); foreach (XmlNode objXmlTargetNode in objXmlTargetNodeList) { bool boolSubNodeResult = blnInvert; if (objXmlTargetNode.SelectSingleNode("*") != null) { if (xmlOperationChildNode.SelectSingleNode("*") != null) { boolSubNodeResult = ProcessFilterOperationNode(objXmlTargetNode, xmlOperationChildNode, xmlOperationChildNodeAttributes?["OR"] != null) != blnInvert; } } else { string strTargetNodeText = objXmlTargetNode.InnerText; bool blnTargetNodeEmpty = string.IsNullOrWhiteSpace(strTargetNodeText); if (blnTargetNodeEmpty || blnOperationChildNodeEmpty) { if (blnTargetNodeEmpty == blnOperationChildNodeEmpty && (strOperationType == "==" || strOperationType == "equals")) { boolSubNodeResult = !blnInvert; } else { boolSubNodeResult = blnInvert; } } // Note when adding more operation cases: XML does not like the "<" symbol as part of an attribute value else { switch (strOperationType) { case "doesnotequal": case "notequals": case "!=": blnInvert = !blnInvert; goto default; case "lessthan": blnInvert = !blnInvert; goto case ">="; case "lessthanequals": blnInvert = !blnInvert; goto case ">"; case "like": case "contains": { boolSubNodeResult = strTargetNodeText.Contains(strOperationChildNodeText) != blnInvert; break; } case "greaterthan": case ">": { boolSubNodeResult = (int.TryParse(strTargetNodeText, out int intTargetNodeValue) && int.TryParse(strOperationChildNodeText, out int intChildNodeValue) && intTargetNodeValue > intChildNodeValue) != blnInvert; break; } case "greaterthanequals": case ">=": { boolSubNodeResult = (int.TryParse(strTargetNodeText, out int intTargetNodeValue) && int.TryParse(strOperationChildNodeText, out int intChildNodeValue) && intTargetNodeValue >= intChildNodeValue) != blnInvert; break; } default: boolSubNodeResult = (strTargetNodeText.Trim() == strOperationChildNodeText.Trim()) != blnInvert; break; } } } if (blnCheckAll) { if (!boolSubNodeResult) { blnOperationChildNodeResult = false; break; } } // default is "any", replace above with a switch() should more than two check types be required else if (boolSubNodeResult) { blnOperationChildNodeResult = true; break; } } } } break; } } switch (blnIsOrNode) { case true when blnOperationChildNodeResult: return(true); case false when !blnOperationChildNodeResult: return(false); } } } } return(!blnIsOrNode); }
public void AddAmbianceSettings(int X, int Xwidth, int Xstride, int Y, int Yheight, int Ystride, float LimiterTimeValue, bool LimiterActive, bool LimiterSecondsUpdate) { XmlNode result = settings.DocumentElement.SelectSingleNode("//AmbianceSettings"); Debug.WriteLine("[AddAmbianceSettings] {0}, {1}, {2}, {3}, {4}, {5}", X, Xwidth, Xstride, Y, Yheight, Ystride); if (result == null) {//No settings at all XmlElement colorSettings = settings.CreateElement("AmbianceSettings"); //Set up the internal structure and values XmlElement setting = settings.CreateElement("X"); setting.InnerText = X.ToString(); colorSettings.AppendChild(setting); setting = settings.CreateElement("Xwidth"); setting.InnerText = Xwidth.ToString(); colorSettings.AppendChild(setting); setting = settings.CreateElement("Xstride"); setting.InnerText = Xstride.ToString(); colorSettings.AppendChild(setting); setting = settings.CreateElement("Y"); setting.InnerText = Y.ToString(); colorSettings.AppendChild(setting); setting = settings.CreateElement("Yheight"); setting.InnerText = Yheight.ToString(); colorSettings.AppendChild(setting); setting = settings.CreateElement("Ystride"); setting.InnerText = Ystride.ToString(); colorSettings.AppendChild(setting); setting = settings.CreateElement("LimiterTimeValue"); setting.InnerText = LimiterTimeValue.ToString(); colorSettings.AppendChild(setting); setting = settings.CreateElement("LimiterActive"); setting.InnerText = LimiterActive.ToString(); colorSettings.AppendChild(setting); setting = settings.CreateElement("LimiterSecondsUpdate"); setting.InnerText = LimiterSecondsUpdate.ToString(); colorSettings.AppendChild(setting); settings.DocumentElement.AppendChild(colorSettings); } else {//There are some settings Debug.WriteLine("[AddAmbianceSettings] " + result.InnerXml); Debug.WriteLine("[ReadAmbianceSettings()] " + result.InnerXml); //Parse the Xml try { result["X"].InnerText = X.ToString(); } catch (Exception ex) { Debug.WriteLine("[AddAmbianceSettings()] Encountered exception while reading X."); Debug.WriteLine(ex.Message); XmlElement setting = settings.CreateElement("X"); setting.InnerText = X.ToString(); result.AppendChild(setting); } try { result["Xwidth"].InnerText = Xwidth.ToString(); } catch (Exception ex) { Debug.WriteLine("[AddAmbianceSettings()] Encountered exception while reading Xwidth."); Debug.WriteLine(ex.Message); XmlElement setting = settings.CreateElement("Xwidth"); setting.InnerText = Xwidth.ToString(); result.AppendChild(setting); } try { result["Xstride"].InnerText = Xstride.ToString(); } catch (Exception ex) { Debug.WriteLine("[AddAmbianceSettings()] Encountered exception while reading Xstride."); Debug.WriteLine(ex.Message); XmlElement setting = settings.CreateElement("Xstride"); setting.InnerText = Xstride.ToString(); result.AppendChild(setting); } try { result["Y"].InnerText = Y.ToString(); } catch (Exception ex) { Debug.WriteLine("[AddAmbianceSettings()] Encountered exception while reading Y."); Debug.WriteLine(ex.Message); XmlElement setting = settings.CreateElement("Y"); setting.InnerText = Y.ToString(); result.AppendChild(setting); } try { result["Yheight"].InnerText = Yheight.ToString(); } catch (Exception ex) { Debug.WriteLine("[AddAmbianceSettings()] Encountered exception while reading Yheight."); Debug.WriteLine(ex.Message); XmlElement setting = settings.CreateElement("Yheight"); setting.InnerText = Yheight.ToString(); result.AppendChild(setting); } try { result["Ystride"].InnerText = Ystride.ToString(); } catch (Exception ex) { Debug.WriteLine("[AddAmbianceSettings()] Encountered exception while reading Ystride."); Debug.WriteLine(ex.Message); XmlElement setting = settings.CreateElement("Ystride"); setting.InnerText = Ystride.ToString(); result.AppendChild(setting); } try { result["LimiterTimeValue"].InnerText = LimiterTimeValue.ToString(); } catch (Exception ex) { Debug.WriteLine("[AddAmbianceSettings()] Encountered exception while reading LimiterTimeValue."); Debug.WriteLine(ex.Message); XmlElement setting = settings.CreateElement("LimiterTimeValue"); setting.InnerText = LimiterTimeValue.ToString(); result.AppendChild(setting); } try { result["LimiterActive"].InnerText = LimiterActive.ToString(); } catch (Exception ex) { Debug.WriteLine("[AddAmbianceSettings()] Encountered exception while reading LimiterActive."); Debug.WriteLine(ex.Message); XmlElement setting = settings.CreateElement("LimiterActive"); setting.InnerText = LimiterActive.ToString(); result.AppendChild(setting); } try { result["LimiterSecondsUpdate"].InnerText = LimiterSecondsUpdate.ToString(); } catch (Exception ex) { Debug.WriteLine("[AddAmbianceSettings()] Encountered exception while reading LimiterSecondsUpdate."); Debug.WriteLine(ex.Message); XmlElement setting = settings.CreateElement("LimiterSecondsUpdate"); setting.InnerText = LimiterSecondsUpdate.ToString(); result.AppendChild(setting); } } }
public void AddAmbianceColorTuningSettings(float red, float green, float blue, string mode) { XmlNode result = settings.DocumentElement.SelectSingleNode("//AmbianceColorTuningSettings"); //Debug.WriteLine("[AddAmbianceSettings] " + result.InnerXml); if (result == null) { XmlElement colorSettings = settings.CreateElement("AmbianceColorTuningSettings"); //Set up the internal structure and values XmlElement setting = settings.CreateElement("Red"); setting.InnerText = red.ToString(); colorSettings.AppendChild(setting); setting = settings.CreateElement("Green"); setting.InnerText = green.ToString(); colorSettings.AppendChild(setting); setting = settings.CreateElement("Blue"); setting.InnerText = blue.ToString(); colorSettings.AppendChild(setting); setting = settings.CreateElement("Mode"); setting.InnerText = mode; colorSettings.AppendChild(setting); settings.DocumentElement.AppendChild(colorSettings); } else { try { result["Red"].InnerText = red.ToString(); } catch (Exception ex) { Debug.WriteLine("[AddAmbianceColorTuningSettings()] Encountered exception while reading Red."); Debug.WriteLine(ex.Message); XmlElement setting = settings.CreateElement("Red"); setting.InnerText = red.ToString(); result.AppendChild(setting); } try { result["Green"].InnerText = green.ToString(); } catch (Exception ex) { Debug.WriteLine("AddAmbianceColorTuningSettings()] Encountered exception while reading Green."); Debug.WriteLine(ex.Message); XmlElement setting = settings.CreateElement("Green"); setting.InnerText = green.ToString(); result.AppendChild(setting); } try { result["Blue"].InnerText = blue.ToString(); } catch (Exception ex) { Debug.WriteLine("[AddAmbianceColorTuningSettings()] Encountered exception while reading Blue."); Debug.WriteLine(ex.Message); XmlElement setting = settings.CreateElement("Blue"); setting.InnerText = blue.ToString(); result.AppendChild(setting); } try { result["Mode"].InnerText = mode; } catch (Exception ex) { Debug.WriteLine("[AddAmbianceColorTuningSettings()] Encountered exception while reading Mode."); Debug.WriteLine(ex.Message); XmlElement setting = settings.CreateElement("Mode"); setting.InnerText = mode.ToString(); result.AppendChild(setting); } } }
public bool Undo(string packageName, XmlNode xmlData) { throw new NotImplementedException(); }
internal ExportFlowResult(XmlNode node) : base(node) { this.FlowRule = FlowRule.GetFlowRule(node); }
/* Main NavBar */ protected void nbMenu_ItemDataBound(object source, DevExpress.Web.ASPxNavBar.NavBarItemEventArgs e) { e.Item.Name = e.Item.Text; IHierarchyData itemHierarchyData = (e.Item.DataItem as IHierarchyData); XmlElement xmlElement = itemHierarchyData.Item as XmlElement; if (xmlElement.Attributes["Caption"] != null) { e.Item.Name = xmlElement.Attributes["Caption"].Value; } if (string.IsNullOrEmpty(DemoName)) { this.demoName = "ASPxperience"; if (xmlElement.OwnerDocument.DocumentElement.Attributes["Name"] != null) { this.demoName = xmlElement.OwnerDocument.DocumentElement.Attributes["Name"].Value; } } if (GetUrl(e.Item.NavigateUrl).ToLower() == Request.AppRelativeCurrentExecutionFilePath.ToLower()) { if (Request.QueryString["Section"] != null) { if (xmlElement.Attributes["Section"] == null || Request.QueryString["Section"] != xmlElement.Attributes["Section"].Value) { return; } } e.Item.Selected = true; e.Item.Group.Expanded = true; XmlAttribute useFullTitle = xmlElement.Attributes["UseFullTitle"]; if (useFullTitle != null && !bool.Parse(useFullTitle.Value)) { if (xmlElement.Attributes["Title"] != null) { this.title = xmlElement.Attributes["Title"].Value; } } else { XmlNode xmlGroupNode = xmlElement.ParentNode; XmlNode xmlMainNode = xmlGroupNode.ParentNode; string titleFormatString = xmlMainNode.Attributes["TitleFormatString"] != null ? xmlMainNode.Attributes["TitleFormatString"].Value : ""; string mainTitle = xmlMainNode.Attributes["Title"] != null ? xmlMainNode.Attributes["Title"].Value : ""; string groupTitle = xmlGroupNode.Attributes["Title"] != null ? xmlGroupNode.Attributes["Title"].Value : ""; string demoTitle = xmlElement.Attributes["Title"] != null ? xmlElement.Attributes["Title"].Value : ""; if (string.IsNullOrEmpty(titleFormatString)) { if (!string.IsNullOrEmpty(mainTitle)) { titleFormatString = "{0}"; } if (!string.IsNullOrEmpty(groupTitle)) { titleFormatString += " - {1}"; } if (!string.IsNullOrEmpty(demoTitle)) { titleFormatString += " - {2}"; } } this.title = string.Format(titleFormatString, mainTitle, groupTitle, demoTitle); } foreach (XmlNode itemNode in xmlElement.ChildNodes) { switch (itemNode.Name) { case "Description": { this.description = itemNode.InnerXml; break; } case "GeneralTerms": { this.generalTerms = itemNode.InnerXml; if (itemNode.Attributes["ShowHeader"] != null && itemNode.Attributes["ShowHeader"].Value.ToLower() == "false") { this.showTermsHeader = false; } break; } } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //if(!String.IsNullOrEmpty(Request.QueryString["PatientId"])) if (Session["PatientID"] != null) { patientid = Convert.ToInt32(Session["PatientId"]); IReports theQBuilderReports = (IReports)ObjectFactory.CreateInstance("BusinessProcess.Reports.BReports, BusinessProcess.Reports"); theRepDS = theQBuilderReports.GetbluecartIEFUinfo(patientid); // theRepDS.WriteXml("c:\\TestHL7.xml"); #region "TableNames" // Moh reg theRepDS.Tables[0].TableName = "patientinfo"; theRepDS.Tables[1].TableName = "EmergContact"; theRepDS.Tables[2].TableName = "Referred"; theRepDS.Tables[3].TableName = "PrevARV"; theRepDS.Tables[4].TableName = "HIVDiagnosis"; theRepDS.Tables[5].TableName = "patientAllergy"; theRepDS.Tables[6].TableName = "FamilyInfo"; theRepDS.Tables[7].TableName = "patientlabresults"; theRepDS.Tables[8].TableName = "firstgegimen"; // theRepDS.Tables[9].TableName = "secondregimen"; // Moh visit theRepDS.Tables[9].TableName = "IEFuinfopervisit"; theRepDS.Tables[10].TableName = "Disclosure"; theRepDS.Tables[11].TableName = "NewOisOtherProblems"; // theRepDS.Tables[12].TableName = "Assessment"; theRepDS.Tables[12].TableName = "CotrimoxazoleAdherence"; theRepDS.Tables[13].TableName = "INHdrug"; theRepDS.Tables[14].TableName = "sideeffect"; theRepDS.Tables[15].TableName = "Patientvisitinfo"; theRepDS.Tables[16].TableName = "Tuberclulosis"; theRepDS.Tables[17].TableName = "otherMedication"; theRepDS.Tables[18].TableName = "labinvestigation"; theRepDS.Tables[19].TableName = "ArvdrugAdherence"; theRepDS.Tables[20].TableName = "HIVTest"; #endregion // Use For HL7 add namespace <ClinicalDocument xmlns=""urn:hl7-org:v3"">") StringBuilder a = new StringBuilder(); StringBuilder b = new StringBuilder(); StringBuilder c = new StringBuilder(); StringBuilder d = new StringBuilder(); b.Append(@"<?xml version=""1.0""?><ClinicalDocument xmlns=""urn:hl7-org:v3"">"); d.Append("</ClinicalDocument>"); //Response.Redirect("..\\ExcelFiles\\TZNACPMonthlyReport.xls"); theRepDS.WriteXml(Server.MapPath("..\\XMLFiles\\HL7\\" + patientid.ToString() + "HLData.xml"), XmlWriteMode.WriteSchema); // Use For HL7 new xml file with namespace XmlDocument doc1 = new XmlDocument(); doc1.Load(Server.MapPath("..\\XMLFiles\\HL7\\" + patientid.ToString() + "HLData.xml")); XmlNode rootNode = doc1.SelectSingleNode("NewDataSet"); a.Append(rootNode.OuterXml.ToString()); c.Append(b).Append(a).Append(d); doc1 = new XmlDocument(); doc1.LoadXml(c.ToString()); doc1.Save(Server.MapPath("..\\XMLFiles\\HL7\\" + patientid.ToString() + "HLData.xml")); //theRepDS.WriteXml(Server.MapPath("..\\XMLFiles\\HL7\\" + patientid.ToString() + "HLData.xml")); Excel.SpreadsheetClass theApp = new Microsoft.Office.Interop.Owc11.SpreadsheetClass(); string theFilePath = Server.MapPath("..\\ExcelFiles\\Templates\\Bluecard.xml"); theApp.XMLURL = theFilePath; fillMohRegSheet(theApp); fillMohVisitsheet(theApp); // theApp.Export(Server.MapPath("..\\ExcelFiles\\TZNACPMonthlyReport.xls"), Microsoft.Office.Interop.Owc11.SheetExportActionEnum.ssExportActionOpenInExcel, Microsoft.Office.Interop.Owc11.SheetExportFormat.ssExportAsAppropriate); theApp.Export(Server.MapPath("..\\ExcelFiles\\Bluecard.xls"), Microsoft.Office.Interop.Owc11.SheetExportActionEnum.ssExportActionNone, Microsoft.Office.Interop.Owc11.SheetExportFormat.ssExportXMLSpreadsheet); //theUtils.OpenExcelFile(Server.MapPath("..\\ExcelFiles\\TZNACPMonthlyReport.xls"), Response); IQWebUtils theUtl = new IQWebUtils(); theUtl.ShowExcelFile(Server.MapPath("..\\ExcelFiles\\Bluecard.xls"), Response); releaseObject(theApp); } } }
public CommodityBase(XmlNode xmlNode) : base(xmlNode) { }
public static void Sui_SetInnerText(this XmlNode Node, string VALUE) { Node.InnerText = VALUE; }