public static void AddNewestFileWithFileExtension( ContentURI uri, DirectoryInfo folder, string fileExtension, ref int i, ref IDictionary <string, string> lstFilePaths) { 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 i++; if (newestFile != null) { bIsNewerFile = FileStorageIO.File1IsNewer( uri, file.FullName, newestFile.FullName); if (bIsNewerFile) { newestFile = file; } } else { newestFile = file; } } } } if (newestFile != null) { AddFileToList(newestFile, i, ref lstFilePaths); } }
public static void AddNewestIOFile( ContentURI uri, DirectoryInfo folder, ref int i, ref IDictionary <string, string> lstFilePaths) { //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 i++; if (newestFile != null) { bIsNewerFile = FileStorageIO.File1IsNewer( uri, file.FullName, newestFile.FullName); if (bIsNewerFile) { newestFile = file; } } else { newestFile = file; } } } if (newestFile != null) { AddFileToList(newestFile, i, ref lstFilePaths); } }
public static 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 = AuthorizedEditNeedsHtmlFragment(uri, displayDocType, xmlDocPath); if (bNeedsNewXhtmlDoc) { bNeedsNewXhtmlDoc = true; return(bNeedsNewXhtmlDoc); } if (!FileStorageIO.URIAbsoluteExists(uri, xhtmlDocPath)) { //rule 2: if the html doesn't exist, make it bNeedsNewXhtmlDoc = true; return(bNeedsNewXhtmlDoc); } bNeedsNewXhtmlDoc = FileStorageIO.File1IsNewer( uri, xmlDocPath, xhtmlDocPath); return(bNeedsNewXhtmlDoc); }