Added Validity Check - Procedure Set Path against Config DataPath

Removed PDF Path and validity checks
This commit is contained in:
Rich 2014-10-22 22:15:43 +00:00
parent 505bfa467d
commit f8a73cfefe

View File

@ -16,6 +16,7 @@ namespace DataLoader
[Serializable] [Serializable]
class DataLoaderSettings:ICloneable class DataLoaderSettings:ICloneable
{ {
private static List<string> _MyDataPaths = Loader.DataPaths;
#region Clone #region Clone
public object Clone() public object Clone()
{ {
@ -221,18 +222,18 @@ namespace DataLoader
set { _PurgeExistingData = value; } set { _PurgeExistingData = value; }
} }
#endregion #endregion
#region PDFs //#region PDFs
private string _PDFFolder; // Folder //private string _PDFFolder; // Folder
[Category("PDFs")] //[Category("PDFs")]
[DisplayName("PDF Folder")] //[DisplayName("PDF Folder")]
[Description("Location for PDFs when printing.")] //[Description("Location for PDFs when printing.")]
[EditorAttribute(typeof(UIFolderEditor), typeof(System.Drawing.Design.UITypeEditor))] //[EditorAttribute(typeof(UIFolderEditor), typeof(System.Drawing.Design.UITypeEditor))]
public string PDFFolder //public string PDFFolder
{ //{
get { return _PDFFolder; } // get { return _PDFFolder; }
set { _PDFFolder = value; } // set { _PDFFolder = value; }
} //}
#endregion //#endregion
#region Debugging #region Debugging
private ExecutionMode _ExecutionMode; private ExecutionMode _ExecutionMode;
[TypeConverter(typeof(EnumDescConverter))] [TypeConverter(typeof(EnumDescConverter))]
@ -360,13 +361,34 @@ namespace DataLoader
} }
else else
{ {
if (!File.Exists(ProcedureSetPath + @"\set.dbf")) if (!InDataPaths(ProcedureSetPath))
{
sb.Append(ErrorPrefix + string.Format("Procedure Folder not in DataPath from Config File '{0}' \r\n", DataLoaderSettings._MyDataPaths[0]));
ErrorPrefix = "";
}
else if (!File.Exists(ProcedureSetPath + @"\set.dbf"))
{ {
sb.Append(ErrorPrefix + "Procedure Folder must point to an existing procedure data folder\r\n"); sb.Append(ErrorPrefix + "Procedure Folder must point to an existing procedure data folder\r\n");
ErrorPrefix = ""; ErrorPrefix = "";
} }
} }
} }
else
{
if ((ProcedureSetPath ?? "") == "" || !Directory.Exists(ProcedureSetPath))
{
sb.Append(ErrorPrefix + "Procedure Folder must point to an existing folder\r\n");
ErrorPrefix = "";
}
else
{
if (!InDataPaths(ProcedureSetPath))
{
sb.Append(ErrorPrefix + string.Format("Procedure Folder not in DataPath from Config File '{0}' \r\n", DataLoaderSettings._MyDataPaths[0]));
ErrorPrefix = "";
}
}
}
//added by jcb 20121127 //added by jcb 20121127
//check is ProcedureSetPath contains ProcessOnlyInLocation //check is ProcedureSetPath contains ProcessOnlyInLocation
if (ProcedureSetPath != null && ProcedureSetPath.StartsWith(ProcessOnlyInLocation ?? "") == false) if (ProcedureSetPath != null && ProcedureSetPath.StartsWith(ProcessOnlyInLocation ?? "") == false)
@ -459,11 +481,11 @@ namespace DataLoader
} }
} }
// PDFFolder = if not set, then don't set PDFFolder in DocVersion.Config // PDFFolder = if not set, then don't set PDFFolder in DocVersion.Config
if (ExecutionMode == ExecutionMode.Debug && ((PDFFolder ?? "") == "" || !Directory.Exists(PDFFolder))) //if (ExecutionMode == ExecutionMode.Debug && ((PDFFolder ?? "") == "" || !Directory.Exists(PDFFolder)))
{ //{
sb.Append(ErrorPrefix + "PDF Folder must point to an existing folder in debug mode\r\n"); // sb.Append(ErrorPrefix + "PDF Folder must point to an existing folder in debug mode\r\n");
ErrorPrefix = ""; // ErrorPrefix = "";
} //}
// Skip = Any NUmber // Skip = Any NUmber
// PurgeExistingData = N/A // PurgeExistingData = N/A
// OnlyThisSet = N/A // OnlyThisSet = N/A
@ -473,6 +495,12 @@ namespace DataLoader
return sb.ToString(); return sb.ToString();
} }
} }
private bool InDataPaths(string ProcedureSetPath)
{
foreach (string dp in _MyDataPaths)
if (ProcedureSetPath.ToUpper().StartsWith(dp.ToUpper())) return true;
return false;
}
private string ValidateConnectionString(string dbName) private string ValidateConnectionString(string dbName)
{ {
if(!ConnectionString.Contains("{DBName}")) if(!ConnectionString.Contains("{DBName}"))