Added call to AddSlaveUnits method of ConfigInfo class when processing proc.ini file in Loader class
Added private methods AddSlaveUnits, GetUnitNames and GetMasterDir to Loader class
This commit is contained in:
parent
7d1f4f4200
commit
cd3e0af534
@ -110,10 +110,11 @@ namespace DataLoader
|
|||||||
ConfigFile cfg = new ConfigFile();
|
ConfigFile cfg = new ConfigFile();
|
||||||
|
|
||||||
XmlDocument d = cfg.IniToXml(vb.Path + "\\proc.ini");
|
XmlDocument d = cfg.IniToXml(vb.Path + "\\proc.ini");
|
||||||
|
AddSlaveUnits(d, vb.Path);
|
||||||
//DocVersionConfig fld_cfg = new DocVersionConfig(d == null ? "" : d.InnerXml);
|
//DocVersionConfig fld_cfg = new DocVersionConfig(d == null ? "" : d.InnerXml);
|
||||||
FolderConfig fld_cfg = (d == null) ? null : new FolderConfig(d.InnerXml);
|
FolderConfig fld_cfg = (d==null)?null:new FolderConfig(d.InnerXml);
|
||||||
// translate curset.dat into xml & add to d (somehow).
|
// translate curset.dat into xml & add to d (somehow).
|
||||||
string csfile = string.Format("{0}\\curset.dat", vb.Path);
|
string csfile = string.Format("{0}\\curset.dat",vb.Path);
|
||||||
string defPlantFmt = null;
|
string defPlantFmt = null;
|
||||||
if (File.Exists(csfile))
|
if (File.Exists(csfile))
|
||||||
{
|
{
|
||||||
@ -150,7 +151,7 @@ namespace DataLoader
|
|||||||
else
|
else
|
||||||
format = FormatInfo.Get(1);
|
format = FormatInfo.Get(1);
|
||||||
|
|
||||||
using (Format fmt = format.Get())
|
using(Format fmt = format.Get())
|
||||||
v = DocVersion.MakeDocVersion(tmpfld, (int)DocVersionType(vb.Path.ToLower()), vb.Title, vb.Path.ToLower(), null, fmt, fld_cfg == null ? null : fld_cfg.ToString(), DateTime.Now, "Migration");
|
v = DocVersion.MakeDocVersion(tmpfld, (int)DocVersionType(vb.Path.ToLower()), vb.Title, vb.Path.ToLower(), null, fmt, fld_cfg == null ? null : fld_cfg.ToString(), DateTime.Now, "Migration");
|
||||||
}
|
}
|
||||||
tn.Tag = v;
|
tn.Tag = v;
|
||||||
@ -159,6 +160,76 @@ namespace DataLoader
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AddSlaveUnits(XmlDocument d, string path)
|
||||||
|
{
|
||||||
|
string masterDir = GetMasterDir(d);
|
||||||
|
if (masterDir == null) return;
|
||||||
|
DirectoryInfo master = new DirectoryInfo(path);
|
||||||
|
if (master.Name.ToUpper() != masterDir.ToUpper()) return;
|
||||||
|
List<string> names = GetUnitNames(d);
|
||||||
|
DirectoryInfo[] slaves = master.Parent.GetDirectories(masterDir.ToUpper().Replace(".PRC",".SL*"));
|
||||||
|
XmlDocument units = new XmlDocument();
|
||||||
|
units.LoadXml("<Slaves/>");
|
||||||
|
int idx = 0;
|
||||||
|
foreach (DirectoryInfo slave in slaves)
|
||||||
|
{
|
||||||
|
FileInfo[] inis = slave.GetFiles("proc.ini");
|
||||||
|
if (inis.Length > 0)
|
||||||
|
{
|
||||||
|
FileInfo ini = inis[0];
|
||||||
|
ConfigFile cfg = new ConfigFile();
|
||||||
|
XmlDocument xSlave = cfg.IniToXml(ini.FullName);
|
||||||
|
xSlave.LoadXml(xSlave.OuterXml.Replace("<Unit", "<Slave"));
|
||||||
|
string slaveDir = GetMasterDir(xSlave);
|
||||||
|
if (slaveDir.ToUpper() == masterDir.ToUpper())
|
||||||
|
{
|
||||||
|
XmlNode unit = xSlave.SelectSingleNode("Config/Slave");
|
||||||
|
XmlAttribute oldindex = xSlave.CreateAttribute("oldindex");
|
||||||
|
oldindex.InnerText = slave.Extension.Replace(".SL", "");
|
||||||
|
unit.Attributes.SetNamedItem(oldindex);
|
||||||
|
XmlAttribute index = xSlave.CreateAttribute("index");
|
||||||
|
idx++;
|
||||||
|
index.InnerText = idx.ToString();
|
||||||
|
unit.Attributes.SetNamedItem(index);
|
||||||
|
if (names.Count == slaves.Length)
|
||||||
|
oldindex.InnerText = index.InnerText;
|
||||||
|
if (xSlave.SelectSingleNode("Config/ProcedureSet") != null)
|
||||||
|
{
|
||||||
|
XmlAttribute setName = xSlave.CreateAttribute("SetName");
|
||||||
|
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;
|
||||||
|
unit.Attributes.SetNamedItem(setID);
|
||||||
|
}
|
||||||
|
units.DocumentElement.AppendChild(units.ImportNode(unit, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
d.DocumentElement.AppendChild(d.ImportNode(units.DocumentElement, true));
|
||||||
|
//d.DocumentElement.RemoveChild(d.SelectSingleNode("Config/Unit"));
|
||||||
|
Console.WriteLine(d.OuterXml);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string> GetUnitNames(XmlDocument d)
|
||||||
|
{
|
||||||
|
XmlNode zapp = d.SelectSingleNode("//Unit");
|
||||||
|
if (zapp == null) return null;
|
||||||
|
XmlNode zmstr = zapp.Attributes.GetNamedItem("Name");
|
||||||
|
if (zmstr == null) return null;
|
||||||
|
string[] names = zmstr.InnerText.Split(",".ToCharArray());
|
||||||
|
return new List<string>(names);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetMasterDir(XmlDocument d)
|
||||||
|
{
|
||||||
|
XmlNode zapp = d.SelectSingleNode("//Applicability");
|
||||||
|
if (zapp == null) return null;
|
||||||
|
XmlNode zmstr = zapp.Attributes.GetNamedItem("MasterDir");
|
||||||
|
if (zmstr == null) return null;
|
||||||
|
return zmstr.InnerText;
|
||||||
|
}
|
||||||
private string _OnlyThisFolder;
|
private string _OnlyThisFolder;
|
||||||
public string OnlyThisFolder
|
public string OnlyThisFolder
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user