67 lines
2.6 KiB
C#
67 lines
2.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.IO;
|
|
using System.Linq;
|
|
|
|
namespace Volian.Base.Library
|
|
{
|
|
public static class ExeInfo
|
|
{
|
|
#region Log4Net
|
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
#endregion
|
|
public static string GetROEditorPath()
|
|
{
|
|
string roapp = PROMSExecutableFolderPath() + @"\ROEDITOR.EXE";
|
|
return roapp;
|
|
}
|
|
|
|
// returns the path to the executable folder
|
|
public static string PROMSExecutableFolderPath()
|
|
{
|
|
string pathPROMSexe = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
|
|
if (pathPROMSexe[7] == ':') // either a local drive or a mapped network drive
|
|
pathPROMSexe = pathPROMSexe.Substring(6);
|
|
else
|
|
pathPROMSexe = @"\" + pathPROMSexe.Substring(5); // non-mapped network drive - need to add extra back slash in front
|
|
return pathPROMSexe;
|
|
}
|
|
|
|
// C2022-030 get the version of PROMSFixes associated with this execuable
|
|
public static string GetAssocicatedPROMSFixesVersion()
|
|
{
|
|
try
|
|
{
|
|
// Build the path to the PROMSFixes.sql file located in the PROMS exe folder
|
|
string pathPROMSFixes = PROMSExecutableFolderPath() + @"\PROMSFixes.sql";
|
|
|
|
// open the PROMSFixes.sql file and grab the line of text containing the PROMSFixes RevDate
|
|
// using Linq to open and read the PROMSFixes file
|
|
// it returns a list of lines. we look at only the first one (should only be one of these in PROMSFixes)
|
|
var lines = from text in File.ReadLines(pathPROMSFixes)
|
|
where text.Contains("set @RevDate =")
|
|
select new
|
|
{
|
|
Text = text
|
|
};
|
|
var txt = lines.First(); // get the first line of text where "set @RevDate =" was found
|
|
string dtstring = txt.Text; // this is the actual text line
|
|
// Parse out the date/time text that follows "set @RevDate ="
|
|
int idx = dtstring.IndexOf('=') + 3;
|
|
dtstring = dtstring.Substring(idx);
|
|
dtstring = dtstring.Substring(0, dtstring.IndexOf("'"));
|
|
// convert the parsed date/time text string to a DateTime and string format it to yyMM.ddHH like used in Help About
|
|
string rtnStr = string.Format("{0:yyMM.ddHH}", DateTime.Parse(dtstring));
|
|
return rtnStr; // return the PROMSFixes version date stored in the PROMSFixes.sql file that's in the PROMS exe folder
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_MyLog.ErrorFormat("GetAssociatedPROMSFixesVersion - {0}", ex.Message);
|
|
return null; // return null to signal that we could not find or parse the PROMSFixes version date
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|