B2017-260 - Add a prefix to the temporary MSWord section file names including the SQL server name and the database name.

This commit is contained in:
Rich 2017-11-20 19:53:54 +00:00
parent 7ef955a981
commit 7469b70b06
2 changed files with 14 additions and 3 deletions

View File

@ -19,6 +19,7 @@ using Volian.Controls.Library;
using DescriptiveEnum;
using Volian.Base.Library;
using Volian.Print.Library;
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
namespace VEPROMS
@ -224,7 +225,6 @@ namespace VEPROMS
Volian.MSWord.WordDoc.KillWordApps();
// cleanup from previous run:
Volian.Base.Library.TmpFile.RemoveAllTmps();
if (VlnSettings.DebugMode)
{
//use local data (for development/debug mode)
@ -312,6 +312,8 @@ namespace VEPROMS
displayBookMarks.SetupBookMarks();
DateTime dtSunday = DateTime.Now.AddDays(-((int)DateTime.Now.DayOfWeek));
string c = Database.DBServer;
// D2017-260 - Use a prefix of the server name combined with the database name for temporary MSWord sections
DSOFile.TempFilePrefix = System.Text.RegularExpressions.Regex.Replace(System.Text.RegularExpressions.Regex.Replace(c, @"([^[\]]*) \[.*\]", "$1"), @"[\#\~\%\@\[\]\(\)\{\}\-. \\*<>:;""/?|]+", "_");
ChangeLogFileName("LogFileAppender", Database.ActiveDatabase + " " + dtSunday.ToString("yyyyMMdd") + " ErrorLog.txt");
_MyLog.InfoFormat("\r\nSession Beginning\r\n<===={0}[SQL:{1:yyMM.ddHH}]====== User: {2}/{3} Started {4} ===============>"
, Application.ProductVersion,Database.RevDate, Environment.UserDomainName,Environment.UserName, DateTime.Now.ToString("dddd MMMM d, yyyy h:mm:ss tt"));

View File

@ -465,6 +465,13 @@ namespace VEPROMS.CSLA.Library
get { return _StartDTS; }
set { _StartDTS = value; }
}
//B2017-260 Prefix the Temporary document file with server name and database name
private static string _TempFilePrefix = "";
public static string TempFilePrefix
{
get { return DSOFile._TempFilePrefix; }
set { DSOFile._TempFilePrefix = value; }
}
private void CreateTemporaryFile()
{
_Unique = 0;
@ -472,7 +479,8 @@ namespace VEPROMS.CSLA.Library
{
if (_MyDocument != null)
{
_MyFile = new FileInfo(string.Format(@"{0}\tmp_{1}{2}{3}", VlnSettings.TemporaryFolder, MyDocument.DocID, Unique, MyDocument.FileExtension));
//B2017-260 Prefix the Temporary document file with server name and database name
_MyFile = new FileInfo(string.Format(@"{0}\{1}_tmp_{2}{3}{4}", VlnSettings.TemporaryFolder,TempFilePrefix, MyDocument.DocID, Unique, MyDocument.FileExtension));
FileInfo matchingFile = null;
while (_MyFile.Exists)
{
@ -501,7 +509,8 @@ namespace VEPROMS.CSLA.Library
matchingFile = _MyFile;
}
}
_MyFile = new FileInfo(string.Format(@"{0}\tmp_{1}{2}{3}", VlnSettings.TemporaryFolder, MyDocument.DocID, Unique, MyDocument.FileExtension));
//B2017-260 Prefix the Temporary document file with server name and database name
_MyFile = new FileInfo(string.Format(@"{0}\{1}_tmp_{2}{3}{4}", VlnSettings.TemporaryFolder, TempFilePrefix, MyDocument.DocID, Unique, MyDocument.FileExtension));
}
// B2017-249 Recover Temporary File And AutoSave support for MSWord
if (matchingFile != null)