Example #1
0
        public static async Task <bool> SaveStandardContentXmlDocAsync(ContentURI uri, XElement root)
        {
            //asynch because base xmldoc is not used by calling methods
            bool bHasGoodXml = false;

            if ((!string.IsNullOrEmpty(uri.URIClub.ClubDocFullPath)))
            {
                if (root != null)
                {
                    //standard content rules
                    if (root.Name == Helpers.GeneralHelpers.ROOT_PATH)
                    {
                        if (root.HasElements)
                        {
                            Helpers.FileStorageIO fileStorageIO = new Helpers.FileStorageIO();
                            bHasGoodXml = await fileStorageIO.SaveXmlInURIAsync(uri,
                                                                                root.CreateReader(), uri.URIClub.ClubDocFullPath);

                            if (string.IsNullOrEmpty(uri.ErrorMessage))
                            {
                                bHasGoodXml = true;
                            }
                        }
                    }
                }
            }
            if (!bHasGoodXml)
            {
                //add an error message
                uri.ErrorMessage += DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg(
                    string.Empty, "MODELHELPERS_BADXMLCONTENT");
            }
            return(bHasGoodXml);
        }
Example #2
0
        public static async Task <bool> SaveEditsAsync(XmlDocument updatedDoc, ContentURI uri)
        {
            Helpers.FileStorageIO fileStorageIO = new Helpers.FileStorageIO();
            //210: changed to async and eliminated byref vars
            XmlTextReader xmlUpdates = EditHelpers.XmlIO.ConvertStringToReader(updatedDoc.OuterXml);
            bool          bHasSaved  = await fileStorageIO.SaveXmlInURIAsync(uri,
                                                                             xmlUpdates, uri.URIClub.ClubDocFullPath);

            return(bHasSaved);
        }
Example #3
0
        public static async Task <bool> SaveEditsAsync(XElement updatedDoc, ContentURI uri)
        {
            bool bHasCompleted = false;

            //make sure the file and directory were not deleted
            if (Helpers.FileStorageIO.DirectoryCreate(uri,
                                                      uri.URIClub.ClubDocFullPath))
            {
                Helpers.FileStorageIO fileStorageIO = new Helpers.FileStorageIO();
                //210: changed to async and eliminated byref vars
                bHasCompleted = await fileStorageIO.SaveXmlInURIAsync(uri,
                                                                      updatedDoc.CreateReader(), uri.URIClub.ClubDocFullPath);
            }
            return(bHasCompleted);
        }
Example #4
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);
        }