Beispiel #1
0
 public static void DeleteSiblingDevDocs(XPathNavigator insertToNav,
                                         IList <string> deletionIds)
 {
     if (deletionIds != null)
     {
         string sQry = string.Empty;
         foreach (string devDocId in deletionIds)
         {
             sQry = XmlIO.MakeLinkedViewQry(insertToNav.LocalName, Helpers.GeneralHelpers.AT_ID,
                                            insertToNav.GetAttribute(AppHelpers.Calculator.cId, string.Empty), devDocId);
             XPathNavigator navToDelete = insertToNav.SelectSingleNode(sQry);
             if (navToDelete != null)
             {
                 navToDelete.DeleteSelf();
             }
         }
     }
 }
Beispiel #2
0
        public static async Task <bool> SaveNameValueList(ContentURI uri,
                                                          IDictionary <string, string> lstUpdates,
                                                          string docPath, string nodeName)
        {
            bool bHasCompleted = false;

            if (lstUpdates.Count > 0)
            {
                string      sValue      = string.Empty;
                XmlDocument oUpdatesDoc = new XmlDocument();
                oUpdatesDoc.LoadXml(Helpers.GeneralHelpers.ROOT_NODE);
                XPathNavigator navDoc = oUpdatesDoc.CreateNavigator();
                //move to the root node
                navDoc.MoveToFirstChild();
                //use an xmlwriter to write remaining nodes
                XmlWriterSettings oXmlWriterSettings = new XmlWriterSettings();
                oXmlWriterSettings.Indent             = true;
                oXmlWriterSettings.OmitXmlDeclaration = true;
                oXmlWriterSettings.ConformanceLevel   = ConformanceLevel.Auto;
                using (XmlWriter oUpdateElWriter
                           = XmlWriter.Create(navDoc.AppendChild(), oXmlWriterSettings))
                {
                    foreach (KeyValuePair <string, string> kvp in lstUpdates)
                    {
                        oUpdateElWriter.WriteStartElement(nodeName);
                        oUpdateElWriter.WriteAttributeString(AppHelpers.Calculator.cId,
                                                             kvp.Key);
                        oUpdateElWriter.WriteAttributeString(Helpers.GeneralHelpers.VALUE,
                                                             kvp.Value);
                        oUpdateElWriter.WriteEndElement();
                    }
                }
                if (oUpdatesDoc != null)
                {
                    XmlTextReader xmlUpdates = XmlIO.ConvertStringToReader(oUpdatesDoc.OuterXml);
                    //new XmlTextReader(oUpdatesDoc.OuterXml)
                    Helpers.FileStorageIO fileStorageIO = new Helpers.FileStorageIO();
                    bHasCompleted
                        = await fileStorageIO.SaveXmlInURIAsync(uri, xmlUpdates, docPath);
                }
            }
            return(bHasCompleted);
        }