public async Task <bool> SaveFullXhtmlDocFromXmlDoc2Async(ContentURI uri, string xmlDocToReadPath, string filePathToXhtmlDoc, DataAppHelpers.Resources.FILEEXTENSION_TYPES fileExtType, DataHelpers.GeneralHelpers.DOC_STATE_NUMBER displayDocType) { bool bHasHtmlDoc = false; string sFragHtmlFile = string.Empty; if (fileExtType == DataAppHelpers.Resources.FILEEXTENSION_TYPES.html && filePathToXhtmlDoc != string.Empty && filePathToXhtmlDoc.EndsWith( DataAppHelpers.Resources.FILEEXTENSION_TYPES.frag.ToString())) { //fragfile path is done first sFragHtmlFile = filePathToXhtmlDoc; } //std html doc path filePathToXhtmlDoc = DataHelpers.AppSettings.GetXhtmlDocPath( uri, displayDocType, xmlDocToReadPath, fileExtType, DataHelpers.GeneralHelpers.GetViewEditType(uri, displayDocType)); //pass back uri.URIDataManager.MiscDocPath = filePathToXhtmlDoc; //check whether a new html doc is needed bool bNeedsNewHtmlDoc = await DataHelpers.XmlFileIO.NeedsNewXhtmlDoc( uri, displayDocType, xmlDocToReadPath, filePathToXhtmlDoc); if (!bNeedsNewHtmlDoc) { //also returns the referenced filePathToXhtmlDoc bHasHtmlDoc = true; } else { //need two separate stateful html documents: //1) ajax responses: html fragments (i.e. no head or body elements) // fragments have a uri.urifilextensiontype == "frag" //2) restful and package responses: full xhtml compliant documents (i.e. both head and body elements) // full html documents have a uri.urifilextensiontype == "full" using (StringWriter writer = new StringWriter()) { string sPathToHeaderFiles = string.Empty; //the fragment should be written prior to the full html (for reuse) if (fileExtType == DataAppHelpers.Resources.FILEEXTENSION_TYPES.html) { //both server and client use same relative paths to all resources HtmlHelperExtensions.MakeXhtmlHeader(writer, uri, sPathToHeaderFiles); if (await DataHelpers.FileStorageIO.URIAbsoluteExists(uri, sFragHtmlFile) && Path.GetExtension(sFragHtmlFile).EndsWith( DataAppHelpers.Resources.FILEEXTENSION_TYPES.frag.ToString())) { //use the existing html fragment await WriteXhtmlFragmentAsync(writer, uri, xmlDocToReadPath, sFragHtmlFile, displayDocType); } else { //needs to transform xml doc await WriteXhtmlFragmentAsync(writer, uri, xmlDocToReadPath, displayDocType); } //close out the html doc (body, html) HtmlHelperExtensions.MakeXhtmlFooter(writer); } else { await WriteXhtmlFragmentAsync(writer, uri, xmlDocToReadPath, displayDocType); } ////put the html into the stringwriter //writer.Flush(); //writer.Close(); if (string.IsNullOrEmpty(uri.ErrorMessage)) { //write the full html doc to disk DataHelpers.FileStorageIO oFileStorageIO = new DataHelpers.FileStorageIO(); await oFileStorageIO.SaveHtmlTextURIAsync(uri, writer, filePathToXhtmlDoc); if (string.IsNullOrEmpty(uri.ErrorMessage)) { bHasHtmlDoc = true; } } } } return(bHasHtmlDoc); }