Example #1
0
        public static void UpdateNurserNode(string appPath, Nurser nurser)
        {
            string      rootNode = AppConfiguration.GetNurserXMLRootNode();
            XmlDocument doc      = new XmlDocument();

            doc.Load(appPath);
            bool    isUpdated = false;
            XmlNode nodes     = doc.SelectSingleNode(rootNode);

            foreach (XmlNode item in nodes)
            {
                XmlElement ele   = (XmlElement)item;
                string     eleId = ele.GetAttribute("id");
                if (eleId.Equals(nurser.Id))
                {
                    XmlNodeList nls = item.ChildNodes;
                    nls[0].InnerText = nurser.NurserName;
                    nls[1].InnerText = nurser.NurserLevel;
                    nls[2].InnerText = nurser.NurserLevelRating;
                    isUpdated        = true;
                    break;
                }
            }
            if (isUpdated)
            {
                doc.Save(appPath);
            }
        }
Example #2
0
        public static void CreateNurseNode(string xmlFilefullPath, string rootElement, Nurser element)
        {
            try {
                //XMLHelper.checkFileExisted(xmlFileName);
                checkFileExisted(xmlFilefullPath);
                XmlDocument xmlDoc = new XmlDocument();
                //xmlDoc.Load(HttpContext.Current.Server.MapPath(xmlFileName));
                xmlDoc.Load(xmlFilefullPath);
                XmlNode rootNode = xmlDoc.SelectSingleNode(rootElement);

                //string newElementName = element.GetType().Name;
                //XmlElement newTag = xmlDoc.CreateElement(newElementName);
                string     newElementName = "Nurser";
                XmlElement newTag         = xmlDoc.CreateElement(newElementName);
                newTag.SetAttribute("id", Guid.NewGuid().ToString());

                XmlElement nameEle = xmlDoc.CreateElement("NurseName");
                nameEle.InnerText = element.NurserName;
                newTag.AppendChild(nameEle);

                XmlElement assignedBedEle = xmlDoc.CreateElement("Level");
                assignedBedEle.InnerText = element.NurserLevel;
                newTag.AppendChild(assignedBedEle);

                XmlElement indexEle = xmlDoc.CreateElement("LevelIndex");
                indexEle.InnerText = element.NurserLevelRating;
                newTag.AppendChild(indexEle);


                rootNode.AppendChild(newTag);
                xmlDoc.Save(xmlFilefullPath);
            }catch (Exception ex) {
            }
        }
Example #3
0
 public Task Edit(Nurser entity)
 {
     throw new NotImplementedException();
 }