//=========================================================== // IOnInsert //=========================================================== /// <summary> /// DragDrop によって挿入される時の処理です。 /// </summary> void NodeDragDrop.IOnInsert.BeforeInsert(System.Windows.Forms.TreeNode target, int index) { File tgfile = (File)target; System.Xml.XmlElement scelem = this.ParentElement; System.Xml.XmlElement tgelem = tgfile != null?tgfile.Element:OwnerDocument.DocumentElement; if (index >= 0) { goto insert; } add: scelem.RemoveChild(this.Element); tgelem.AppendChild(this.Element); return; insert: if (scelem == tgelem && this.ElementIndex == index) { return; } //--挿入位置参照用 File (兄弟 File) File sibling; if (tgfile != null) { if (index >= tgfile.Nodes.Count) { goto add; } sibling = (File)tgfile.Nodes[index]; } else { if (index >= OwnerDocument.files.Count) { goto add; } sibling = (File)OwnerDocument.files[index]; } //--移動元から削除 scelem.RemoveChild(this.Element); //--移動先に挿入 tgelem.InsertBefore(this.Element, sibling.Element); if (tgfile == null) { OwnerDocument.RefreshFiles(); } return; }
/// <summary> /// Removes a section. </summary> /// <param name="section"> /// The name of the section to remove. </param> /// <exception cref="InvalidOperationException"> /// <see cref="Profile.Name" /> is null or empty or /// <see cref="Profile.ReadOnly" /> is true. </exception> /// <exception cref="ArgumentNullException"> /// section is null. </exception> /// <exception cref="XmlException"> /// Parse error in the XML being loaded from the file or /// the resulting XML document would not be well formed. </exception> /// <remarks> /// The <see cref="Profile.Changing" /> event is raised before removing the section. /// If its <see cref="ProfileChangingArgs.Cancel" /> property is set to true, this method /// returns immediately without removing the section. After the section has been removed, /// the <see cref="Profile.Changed" /> event is raised. /// <para> /// Note: If <see cref="XmlBased.Buffering" /> is enabled, the section is not removed from the /// XML file until the buffer is flushed (or closed). </para></remarks> /// <seealso cref="RemoveUserSetting" /> public void RemoveUserSection(string section) { VerifyNotReadOnly(); VerifyAndAdjustSection(ref section); // Verify the document exists System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.Load(_filePath); if (doc == null) { return; } // Get the root node, if it exists System.Xml.XmlElement root = doc.DocumentElement; if (root == null) { return; } // Get the section's node, if it exists System.Xml.XmlNode sectionNode = root.SelectSingleNode(GetSectionsPath(section)); if (sectionNode == null) { return; } root.RemoveChild(sectionNode); doc.Save(_filePath); }
/// <summary>delete a Value from Configuration-Data</summary> /// <param name="Name">the Name for the Value to delete...</param> /// <returns>TRUE on success, FALSE on error</returns> private bool _DeleteValue(string Name) { if (!_CheckForInit()) { return(false); } // <Setting Name="" Value="" /> System.Xml.XmlElement _docRoot = _intXml["UserSettings"]; if (_docRoot == null) // no root found { return(false); } if (!_docRoot.HasChildNodes) // there are no elements inside { return(false); } // check the content for item System.Xml.XmlElement _delItem = null; foreach (System.Xml.XmlElement _xElement in _docRoot.ChildNodes) { if (_xElement.Name == "Setting") { if (_xElement.GetAttribute("Name") == Name) { _delItem = _xElement; break; } } } if (_delItem != null) // item found { try { _docRoot.RemoveChild(_delItem); } catch (Exception ex) { if (_throwExceptions) { throw new Exception("Could not delete XML-Node...", ex); } else { return(false); } } return(true); // all ok - deleted } else // not found { return(false); } }
/// <summary> /// Removes a child element from the entry element /// </summary> /// <param name="elementName">The element to remove</param> private void RemoveElement(string elementName) { log.Debug("RemoveElement(" + elementName + ")"); log.Debug("Entry Node XML:" + entryNode.OuterXml); if (String.IsNullOrEmpty(elementName)) { throw new ArgumentNullException("elementName"); } System.Xml.XmlNode node = entryNode.SelectSingleNode("./" + elementName); if (node == null) { log.Debug(elementName + " node was not found"); } else { entryNode.RemoveChild(node); log.Debug(elementName + " node found and removed."); } }
public void MyXml(SST.SSTCaseRow sstr, System.Xml.XmlDocument xd) { //special doc folders System.Xml.XmlElement xdoc = (System.Xml.XmlElement)xd.SelectSingleNode("//toc[@type='document' and @filter='true']"); System.Xml.XmlElement xDocFilt; if (xdoc != null) { xdoc.InnerXml = ""; if (sstr.AppealLevelID == 1) { xDocFilt = xd.CreateElement("toc"); xDocFilt.SetAttribute("type", "document"); xDocFilt.SetAttribute("filter", "DocTypeMajorCode='P1'"); xDocFilt.SetAttribute("titlee", "Part 1"); xDocFilt.SetAttribute("titlef", "Partie 1"); xDocFilt.SetAttribute("sort", "10"); xdoc.AppendChild(xDocFilt); xDocFilt = xd.CreateElement("toc"); xDocFilt.SetAttribute("type", "document"); xDocFilt.SetAttribute("filter", "DocTypeMajorCode='P2'"); xDocFilt.SetAttribute("titlee", "Part 2"); xDocFilt.SetAttribute("titlef", "Partie 2"); xDocFilt.SetAttribute("sort", "20"); xdoc.AppendChild(xDocFilt); xDocFilt = xd.CreateElement("toc"); xDocFilt.SetAttribute("type", "document"); xDocFilt.SetAttribute("filter", "DocTypeMajorCode is null"); xDocFilt.SetAttribute("titlee", "Internal"); xDocFilt.SetAttribute("titlef", "Interne"); xDocFilt.SetAttribute("sort", "30"); xdoc.AppendChild(xDocFilt); } else { xDocFilt = xd.CreateElement("toc"); xDocFilt.SetAttribute("type", "document"); xDocFilt.SetAttribute("filter", "DocTypeMajorCode='P1' and SourceDivision=1"); xDocFilt.SetAttribute("titlee", "GD - Part 1"); xDocFilt.SetAttribute("titlef", "GD - Partie 1"); xDocFilt.SetAttribute("sort", "10"); xdoc.AppendChild(xDocFilt); xDocFilt = xd.CreateElement("toc"); xDocFilt.SetAttribute("type", "document"); xDocFilt.SetAttribute("filter", "DocTypeMajorCode='P2' and SourceDivision=1"); xDocFilt.SetAttribute("titlee", "GD - Part 2"); xDocFilt.SetAttribute("titlef", "GD - Partie 2"); xDocFilt.SetAttribute("sort", "20"); xdoc.AppendChild(xDocFilt); xDocFilt = xd.CreateElement("toc"); xDocFilt.SetAttribute("type", "document"); xDocFilt.SetAttribute("filter", "DocTypeMajorCode='P1' and SourceDivision<>1"); xDocFilt.SetAttribute("titlee", "AD - Part 1"); xDocFilt.SetAttribute("titlef", "AD - Partie 1"); xDocFilt.SetAttribute("sort", "30"); xdoc.AppendChild(xDocFilt); xDocFilt = xd.CreateElement("toc"); xDocFilt.SetAttribute("type", "document"); xDocFilt.SetAttribute("filter", "DocTypeMajorCode='P2' and SourceDivision<>1"); xDocFilt.SetAttribute("titlee", "AD - Part 2"); xDocFilt.SetAttribute("titlef", "AD - Partie 2"); xDocFilt.SetAttribute("sort", "40"); xdoc.AppendChild(xDocFilt); xDocFilt = xd.CreateElement("toc"); xDocFilt.SetAttribute("type", "document"); xDocFilt.SetAttribute("filter", "DocTypeMajorCode is null"); xDocFilt.SetAttribute("titlee", "AD - Internal"); xDocFilt.SetAttribute("titlef", "AD - Interne"); xDocFilt.SetAttribute("sort", "50"); xdoc.AppendChild(xDocFilt); } } System.Xml.XmlElement xe = (System.Xml.XmlElement)xd.SelectSingleNode("//toc[@supertype='sstcase' and @type='sstcase']"); if (xe == null) { string sort = "109"; xe = xd.CreateElement("toc"); xe.SetAttribute("supertype", "sstcase"); xe.SetAttribute("type", "sstcase"); xe.SetAttribute("sort", sort); xe.SetAttribute("id", sstr.SSTCaseId.ToString()); System.Xml.XmlElement xeAfter = (System.Xml.XmlElement)xd.SelectSingleNode("//toc[@sort>" + sort + "]"); if (xeAfter == null) { xeAfter = (System.Xml.XmlElement)xd.SelectSingleNode("//fld[@sort>" + sort + "]"); } if (xeAfter == null) { xd.DocumentElement.AppendChild(xe); } else { xd.DocumentElement.InsertBefore(xe, xeAfter); } } xe.SetAttribute("titlee", "SST Appeal"); xe.SetAttribute("titlef", "Appel au TSS"); //if (!sstr.IsCaseStatusDescEngNull() && !sstr.IsCaseStatusDescFreNull()) //{ // xe.SetAttribute("titlee", "SST Appeal (" + sstr.CaseStatusDescEng + ")"); // xe.SetAttribute("titlef", "Appel au TSS (" + sstr.CaseStatusDescFre + ")"); // if (sstr.CaseStatus == 2)//Hearing Scheduled // { int Fileid = sstr.FileId; if (xe.HasChildNodes) { xe.RemoveChild(xe.FirstChild); } SST.HearingRow[] aHrs = (SST.HearingRow[])myA.DB.Hearing.Select("Fileid=" + Fileid.ToString() + " and HearingStatus=1"); //myA.FM.CurrentFile.SetMisc1DateNull(); //it's all inhearing before update now 2015-3-10 CJW if (aHrs.Length > 0) { foreach (SST.HearingRow aHr in aHrs) { // JLL: If Hearing/ApptId is null, don't create xmldate node if (!aHr.IsApptIdNull()) { int ApptId = aHr.ApptId; atriumDB.AppointmentRow aDr = (atriumDB.AppointmentRow)myA.FM.DB.Appointment.Select("ApptId=" + ApptId.ToString())[0]; DateTime dateTimeLocal = aDr.StartDateLocal; string dtDateEng = dateTimeLocal.ToString("MMMM dd, yyyy @ hh:mm tt", System.Globalization.CultureInfo.CreateSpecificCulture("en-CA")); string dtDateFre = dateTimeLocal.ToString("dd MMMM yyyy à HH:mm", System.Globalization.CultureInfo.CreateSpecificCulture("fr-CA")); string[] tzv = GetAcronymTimeZoneLabel(); System.Xml.XmlElement xmlDate = xd.CreateElement("toc"); xmlDate.SetAttribute("supertype", "sstcase"); xmlDate.SetAttribute("type", "sstcase"); xmlDate.SetAttribute("bold", "true"); xmlDate.SetAttribute("titlef", dtDateFre + " " + tzv[0]); xmlDate.SetAttribute("titlee", dtDateEng + " " + tzv[1]); if (xe.HasChildNodes) { xe.RemoveChild(xe.FirstChild); } xe.AppendChild(xmlDate); if (!aHr.IsSCOfficeIdNull()) { myA.FM.EFile.XmlAddTocACS(xd, 105352, "sstcase", 109); } } } } //} //Hearing Postponed || Hearing Adjourned ||Hearing Held || Decision Issued //if ((sstr.CaseStatus == 6) || (sstr.CaseStatus == 7) || (sstr.CaseStatus == 5) || (sstr.CaseStatus == 4) || (sstr.CaseStatus == 9)) //{ // if (xe.HasChildNodes) // { // xe.RemoveChild(xe.FirstChild); // } //} //} //else //{ // xe.SetAttribute("titlee", "SST Appeal"); // xe.SetAttribute("titlef", "Appel au TSS"); //} System.Xml.XmlElement xe2 = (System.Xml.XmlElement)xd.SelectSingleNode("//toc[@supertype='sstcase' and @type='sstdetail']"); if (xe2 == null) { string sort = "110"; xe2 = xd.CreateElement("toc"); xe2.SetAttribute("supertype", "sstcase"); xe2.SetAttribute("type", "sstdetail"); xe2.SetAttribute("sort", sort); xe2.SetAttribute("id", sstr.SSTCaseId.ToString()); xe2.SetAttribute("titlee", "Program Information"); xe2.SetAttribute("titlef", "Information sur le Programme"); System.Xml.XmlElement xeAfter = (System.Xml.XmlElement)xd.SelectSingleNode("//toc[@sort>" + sort + "]"); if (xeAfter == null) { xeAfter = (System.Xml.XmlElement)xd.SelectSingleNode("//fld[@sort>" + sort + "]"); } if (xeAfter == null) { xd.DocumentElement.AppendChild(xe2); } else { xd.DocumentElement.InsertBefore(xe2, xeAfter); } } }