public async Task WriteXhtmlFragmentAsync(StringWriter writer, ContentURI uri, string xmlDocToReadPath, string htmlFragmentDocPath, DataHelpers.GeneralHelpers.DOC_STATE_NUMBER displayDocType) { if (DataHelpers.FileStorageIO.URIAbsoluteExists(uri, htmlFragmentDocPath)) { //write html DataHelpers.FileStorageIO oFileStorageIO = new DataHelpers.FileStorageIO(); await oFileStorageIO.SaveHtmlURIToWriterAsync(uri, writer, htmlFragmentDocPath); } else { //transform xml await WriteXhtmlFragmentAsync(writer, uri, xmlDocToReadPath, displayDocType); } }
public async Task <bool> DisplayURIAsync(StringWriter writer, ContentURI uri, DataHelpers.GeneralHelpers.DOC_STATE_NUMBER displayDocType) { bool bIsCompleted = false; if (displayDocType == DataHelpers.GeneralHelpers.DOC_STATE_NUMBER.thirddoc) { if (uri.URIDataManager.NeedsFullView == false && uri.URIDataManager.NeedsSummaryView == false) { uri.ErrorMessage += AppHelper.GetErrorMessage("DISPLAYHELPER_DONTNEEDHTMLDOC"); return(bIsCompleted); } } //don't let existing errors interfere with html generation string sErrorMsg = uri.ErrorMessage; uri.ErrorMessage = string.Empty; //xhtml state is saved to increase performance and improve packaging string sDocToReadPath = await DataHelpers.AddInHelper.GetDevTrekPath(uri, displayDocType); if (await DataHelpers.FileStorageIO.URIAbsoluteExists(uri, sDocToReadPath)) { //first uri string sHtmlFragDocPath = string.Empty; string sHtmlDocPath = string.Empty; //ajax state management needs html fragments (for partial page updates) //the html fragment can be reused in full html doc bool bHasHtmlDoc = await SaveFullXhtmlDocFromXmlDoc2Async(uri, sDocToReadPath, sHtmlFragDocPath, DataAppHelpers.Resources.FILEEXTENSION_TYPES.frag, displayDocType); sHtmlFragDocPath = uri.URIDataManager.MiscDocPath; if (bHasHtmlDoc) { //init with frag file sHtmlDocPath = sHtmlFragDocPath; //restful state management needs full xhtml documents (for ebook packages) await SaveFullXhtmlDocFromXmlDoc2Async(uri, sDocToReadPath, sHtmlDocPath, DataAppHelpers.Resources.FILEEXTENSION_TYPES.html, displayDocType); sHtmlDocPath = uri.URIDataManager.MiscDocPath; //write the fragment html doc to the writer DataHelpers.FileStorageIO oFileStorageIO = new DataHelpers.FileStorageIO(); await oFileStorageIO.SaveHtmlURIToWriterAsync(uri, writer, sHtmlFragDocPath); if (string.IsNullOrEmpty(uri.ErrorMessage)) { //check whether additional html files are needed //(i.e. full, rather than summary, docs) await SaveFullXhtmlDocFromFullXmlDoc1Async(writer, uri, sDocToReadPath, displayDocType); } } else { if (displayDocType == DataHelpers.GeneralHelpers.DOC_STATE_NUMBER.seconddoc) { //if it doesn't have an addin it's not an error bool bHasAddIn = DataHelpers.LinqHelpers.LinkedViewHaveAddIn(uri.URIDataManager.LinkedView); if (bHasAddIn) { string sComplexMsg = uri.ErrorMessage; uri.ErrorMessage = AppHelper.GetErrorMessage("DISPLAYHELPER_NOHTMLFILE"); uri.ErrorMessage += sComplexMsg; } } else { string sComplexMsg = uri.ErrorMessage; uri.ErrorMessage = AppHelper.GetErrorMessage("DISPLAYHELPER_NOHTMLFILE"); uri.ErrorMessage += sComplexMsg; } } } else { if (displayDocType == DataHelpers.GeneralHelpers.DOC_STATE_NUMBER.seconddoc) { if (uri.URIDataManager.UseSelectedLinkedView) { if ((uri.URIDataManager.AppType == DataHelpers.GeneralHelpers.APPLICATION_TYPES.linkedviews || uri.URIDataManager.AppType == DataHelpers.GeneralHelpers.APPLICATION_TYPES.devpacks) && uri.URIDataManager.ServerSubActionType == DataHelpers.GeneralHelpers.SERVER_SUBACTION_TYPES.runaddin) { //if it doesn't have an addin it's not an error bool bHasAddIn = DataHelpers.LinqHelpers.LinkedViewHaveAddIn(uri.URIDataManager.LinkedView); if (bHasAddIn) { SetNoXmlDocErrorMsg(uri, displayDocType); } } //no error -just showing a selected view explanation } else { //if it doesn't have an addin it's not an error bool bHasAddIn = DataHelpers.LinqHelpers.LinkedViewHaveAddIn(uri.URIDataManager.LinkedView); if (bHasAddIn) { SetNoXmlDocErrorMsg(uri, displayDocType); } } } else { SetNoXmlDocErrorMsg(uri, displayDocType); } } uri.ErrorMessage = string.Concat(sErrorMsg, uri.ErrorMessage); bIsCompleted = true; return(bIsCompleted); }