public static async Task <bool> NeedsNewXhtmlDoc(ContentURI uri, GeneralHelpers.DOC_STATE_NUMBER displayDocType, string xmlDocPath, string xhtmlDocPath) { bool bNeedsNewXhtmlDoc = false; //rule 1: authorized edits always get new html bNeedsNewXhtmlDoc = await AuthorizedEditNeedsHtmlFragment(uri, displayDocType, xmlDocPath); if (bNeedsNewXhtmlDoc) { bNeedsNewXhtmlDoc = true; return(bNeedsNewXhtmlDoc); } if (!await FileStorageIO.URIAbsoluteExists(uri, xhtmlDocPath)) { //rule 2: if the html doesn't exist, make it bNeedsNewXhtmlDoc = true; return(bNeedsNewXhtmlDoc); } bNeedsNewXhtmlDoc = await FileStorageIO.File1IsNewerAsync( uri, xmlDocPath, xhtmlDocPath); return(bNeedsNewXhtmlDoc); }
public static async Task <bool> AddNewestFileWithFileExtension( ContentURI uri, DirectoryInfo folder, string fileExtension, IDictionary <string, string> lstFilePaths) { bool bHasCompleted = false; FileInfo[] files = folder.GetFiles(); FileInfo newestFile = null; bool bIsNewerFile = false; foreach (FileInfo file in files) { if (Path.GetFileNameWithoutExtension(file.FullName).EndsWith(fileExtension) && file.Extension == Helpers.GeneralHelpers.EXTENSION_XML) { //rule 1: analyzers can only use calculator data if (file.Name.StartsWith(GeneralHelpers.ADDIN)) { //rule2: use only the latest file calculated with that fileextension //if this folder had more than one file with this extension, //it could mean that an old calculation, //from a previous calculator, was not deleted properly uri.URIDataManager.ParentStartRow++; if (newestFile != null) { bIsNewerFile = await FileStorageIO.File1IsNewerAsync( uri, file.FullName, newestFile.FullName); if (bIsNewerFile) { newestFile = file; } } else { newestFile = file; } } } } if (newestFile != null) { AddFileToList(newestFile, uri, lstFilePaths); } bHasCompleted = true; return(bHasCompleted); }
public static async Task <bool> AddNewestIOFile( ContentURI uri, DirectoryInfo folder, IDictionary <string, string> lstFilePaths) { bool bHasCompleted = false; //inputs and outputs don't have base NPV calcs and can be used directly without running new calculations FileInfo[] files = folder.GetFiles(); FileInfo newestFile = null; bool bIsNewerFile = false; foreach (FileInfo file in files) { if (file.Extension == Helpers.GeneralHelpers.EXTENSION_XML) { //rule2: use only the latest file calculated with that fileextension //if this folder had more than one file with this extension, //it could mean that an old calculation, //from a previous calculator, was not deleted properly uri.URIDataManager.ParentStartRow++; if (newestFile != null) { bIsNewerFile = await FileStorageIO.File1IsNewerAsync( uri, file.FullName, newestFile.FullName); if (bIsNewerFile) { newestFile = file; } } else { newestFile = file; } } } if (newestFile != null) { AddFileToList(newestFile, uri, lstFilePaths); } bHasCompleted = true; return(bHasCompleted); }