Add code to stop the process of loading data and notify the user when there is a problem with the 16-bit data, especially proc.ini files.
Added improvements to the code to better handle proc.ini files when they are part of a multi unit site, especially case sensitivity of elements of the proc.ini file. The changes involve all of the stored procedures, functions and table changes to support multiuser and security configuration of PROMS.
This commit is contained in:
parent
1f2c18bdf1
commit
46a70899bd
@ -113,6 +113,8 @@ namespace DataLoader
|
||||
|
||||
XmlDocument d = cfg.IniToXml(vb.Path + "\\proc.ini");
|
||||
AddSlaveUnits(d, vb.Path);
|
||||
if (frmMain.ProcessFailed)
|
||||
return null;
|
||||
//DocVersionConfig fld_cfg = new DocVersionConfig(d == null ? "" : d.InnerXml);
|
||||
FolderConfig fld_cfg = (d==null)?null:new FolderConfig(d.InnerXml);
|
||||
// translate curset.dat into xml & add to d (somehow).
|
||||
@ -166,10 +168,21 @@ namespace DataLoader
|
||||
private void AddSlaveUnits(XmlDocument d, string path)
|
||||
{
|
||||
string masterDir = GetMasterDir(d);
|
||||
if (masterDir == null) return;
|
||||
if (masterDir == null)
|
||||
{
|
||||
//not a master slave procedure set
|
||||
return;
|
||||
}
|
||||
DirectoryInfo master = new DirectoryInfo(path);
|
||||
if (master.Name.ToUpper() != masterDir.ToUpper()) return;
|
||||
List<string> names = GetUnitNames(d);
|
||||
if (names == null)
|
||||
{
|
||||
frmMain.ProcessFailed = true;
|
||||
MessageBox.Show("Could not find Unit names in slave proc.ini files");
|
||||
frmMain.MyError = "Could not find Unit names in slave proc.ini files";
|
||||
return;
|
||||
}
|
||||
DirectoryInfo[] slaves = master.Parent.GetDirectories(masterDir.ToUpper().Replace(".PRC",".SL*"));
|
||||
XmlDocument units = new XmlDocument();
|
||||
units.LoadXml("<Slaves/>");
|
||||
@ -184,11 +197,18 @@ namespace DataLoader
|
||||
XmlDocument xSlave = cfg.IniToXml(ini.FullName);
|
||||
xSlave.LoadXml(xSlave.OuterXml.Replace("<Unit", "<Slave"));
|
||||
string slaveDir = GetMasterDir(xSlave);
|
||||
if (slaveDir == null)
|
||||
{
|
||||
frmMain.ProcessFailed = true;
|
||||
MessageBox.Show("Could not find MasterDir in slave proc.ini files");
|
||||
frmMain.MyError = "Could not find MasterDir in slave proc.ini files";
|
||||
return;
|
||||
}
|
||||
if (slaveDir.ToUpper() == masterDir.ToUpper())
|
||||
{
|
||||
XmlNode unit = xSlave.SelectSingleNode("Config/Slave");
|
||||
XmlAttribute oldindex = xSlave.CreateAttribute("oldindex");
|
||||
oldindex.InnerText = slave.Extension.Replace(".SL", "");
|
||||
oldindex.InnerText = slave.Extension.ToUpper().Replace(".SL", "");
|
||||
unit.Attributes.SetNamedItem(oldindex);
|
||||
XmlAttribute index = xSlave.CreateAttribute("index");
|
||||
idx++;
|
||||
@ -199,10 +219,12 @@ namespace DataLoader
|
||||
if (xSlave.SelectSingleNode("Config/ProcedureSet") != null)
|
||||
{
|
||||
XmlAttribute setName = xSlave.CreateAttribute("SetName");
|
||||
setName.InnerText = xSlave.SelectSingleNode("Config/ProcedureSet/@Name").InnerText;
|
||||
if(xSlave.SelectSingleNode("Config/ProcedureSet/@Name") != null)
|
||||
setName.InnerText = xSlave.SelectSingleNode("Config/ProcedureSet/@Name").InnerText;
|
||||
unit.Attributes.SetNamedItem(setName);
|
||||
XmlAttribute setID = xSlave.CreateAttribute("SetID");
|
||||
setID.InnerText = xSlave.SelectSingleNode("Config/ProcedureSet/@ID").InnerText;
|
||||
if(xSlave.SelectSingleNode("Config/ProcedureSet/@ID") != null)
|
||||
setID.InnerText = xSlave.SelectSingleNode("Config/ProcedureSet/@ID").InnerText;
|
||||
unit.Attributes.SetNamedItem(setID);
|
||||
}
|
||||
units.DocumentElement.AppendChild(units.ImportNode(unit, true));
|
||||
@ -213,12 +235,50 @@ namespace DataLoader
|
||||
//d.DocumentElement.RemoveChild(d.SelectSingleNode("Config/Unit"));
|
||||
Console.WriteLine(d.OuterXml);
|
||||
}
|
||||
|
||||
private static XmlNode GetXMLNode(XmlDocument d, string nodeName)
|
||||
{
|
||||
return GetXMLNode(d.DocumentElement, nodeName);
|
||||
}
|
||||
private static XmlNode GetXMLNode(XmlNode nd, string nodeName)
|
||||
{
|
||||
XmlNodeList xl = nd.SelectNodes(string.Format("//{0}", nodeName));
|
||||
if (xl.Count == 0 && System.Text.RegularExpressions.Regex.IsMatch(nodeName, "^[A-Za-z0-9]+$"))
|
||||
xl = nd.SelectNodes(
|
||||
string.Format("//*[translate(local-name(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='{0}']", nodeName.ToLower()));
|
||||
switch (xl.Count)
|
||||
{
|
||||
case 0: // No nodes found
|
||||
return null;
|
||||
case 1: // Found the node
|
||||
XmlNode xn = xl[0];
|
||||
if (xn.GetType() == typeof(XmlElement)) return xn;
|
||||
throw new Exception(string.Format("Retrieved {0} while looking for XmlElement //{1}", xn.GetType().ToString(), nodeName));
|
||||
default: // Found more than 1 node
|
||||
throw new Exception(string.Format("Found more than one node //{0}", nodeName));
|
||||
}
|
||||
}
|
||||
private static XmlAttribute GetXMLAttribute(XmlNode xx, string item)
|
||||
{
|
||||
//XmlNodeList xl = xx.SelectNodes(string.Format("@{0}", item));
|
||||
XmlNodeList xl = xx.SelectNodes(
|
||||
string.Format("@*[translate(local-name(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='{0}']", item.ToLower()));
|
||||
switch (xl.Count)
|
||||
{
|
||||
case 0: // No nodes found
|
||||
return null;
|
||||
case 1: // Found the node
|
||||
XmlNode xn = xl[0];
|
||||
if (xn.GetType() == typeof(XmlAttribute)) return (XmlAttribute)xn;
|
||||
throw new Exception(string.Format("Retrieved {0} while looking for XmlAttribute @{1}", xn.GetType().ToString(), item));
|
||||
default: // Found more than 1 node
|
||||
throw new Exception(string.Format("Found more than one node @{0}", item));
|
||||
}
|
||||
}
|
||||
private List<string> GetUnitNames(XmlDocument d)
|
||||
{
|
||||
XmlNode zapp = d.SelectSingleNode("//Unit");
|
||||
XmlNode zapp = GetXMLNode(d, "Unit");// d.SelectSingleNode("//Unit");
|
||||
if (zapp == null) return null;
|
||||
XmlNode zmstr = zapp.Attributes.GetNamedItem("Name");
|
||||
XmlNode zmstr = GetXMLAttribute(zapp, "Name");// zapp.Attributes.GetNamedItem("Name");
|
||||
if (zmstr == null) return null;
|
||||
string[] names = zmstr.InnerText.Split(",".ToCharArray());
|
||||
return new List<string>(names);
|
||||
@ -226,9 +286,9 @@ namespace DataLoader
|
||||
|
||||
private static string GetMasterDir(XmlDocument d)
|
||||
{
|
||||
XmlNode zapp = d.SelectSingleNode("//Applicability");
|
||||
XmlNode zapp = GetXMLNode(d, "Applicability");// d.SelectSingleNode("//Applicability");
|
||||
if (zapp == null) return null;
|
||||
XmlNode zmstr = zapp.Attributes.GetNamedItem("MasterDir");
|
||||
XmlNode zmstr = GetXMLAttribute(zapp, "MasterDir");// zapp.Attributes.GetNamedItem("MasterDir");
|
||||
if (zmstr == null) return null;
|
||||
return zmstr.InnerText;
|
||||
}
|
||||
@ -277,6 +337,8 @@ namespace DataLoader
|
||||
{
|
||||
TreeNode tnc = tn.Nodes.Add(vbc.Title);
|
||||
object idc = cslaObject(vbc, dbConn, parent, tnc);
|
||||
if (frmMain.ProcessFailed)
|
||||
return;
|
||||
frmMain.Status = "Loading " + vbc.Title;
|
||||
MigrateChildren(vbc, vs, dbConn, idc, tnc);
|
||||
}
|
||||
|
@ -129,12 +129,15 @@ namespace DataLoader
|
||||
vlnServer vs = new vlnServer();
|
||||
frmMain.Status = "Loading " + fldr.Name;
|
||||
MigrateChildren(vb, vs, dbConn, fldr, tn);
|
||||
if (frmMain.ProcessFailed)
|
||||
return false;
|
||||
tn.Expand();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.ErrorFormat("Could not load data, error = {0}", ex.Message);
|
||||
log.Error("Error in LoadFolders", ex);
|
||||
// log.ErrorFormat("Could not load data, error = {0}", ex.Message);
|
||||
//return false;
|
||||
throw new Exception("Error in LoadFolders", ex);
|
||||
}
|
||||
@ -166,6 +169,8 @@ namespace DataLoader
|
||||
vlnServer vs = new vlnServer();
|
||||
frmMain.Status = "Loading " + fldr.Name;
|
||||
MigrateChildren(vb, vs, dbConn, fldr, tn);
|
||||
if (frmMain.ProcessFailed)
|
||||
return false;
|
||||
tn.Expand();
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user