When importing a folder, if the RO database name is the same as a RO database currently in the data, but the RO path of the importing folder is different than the current RO database path, compare the FST contents of the two and if the same use the current RO database. Also when importing a RO database of the same name but has a different RO Path, rename the importing RO database name to keep the RO database names unique. B2016-119

This commit is contained in:
John Jenko 2016-05-11 14:23:53 +00:00
parent 253f2ee224
commit cc6735db05

View File

@ -2710,7 +2710,7 @@ namespace VEPROMS
{
XmlNode xrofst = xassoc.SelectSingleNode("rofst");
XmlNode xrodb = xrofst.SelectSingleNode("rodb");
MyRODb = AddRODb(xrodb);
MyRODb = AddRODb(xrodb);
ROFst rofst = AddROFst(xrofst);
DocVersionAssociation dva = dv.DocVersionAssociations.Add(rofst);
dv.Save();
@ -2752,9 +2752,18 @@ namespace VEPROMS
string userid = xrofst.Attributes.GetNamedItem("userid").InnerText;
DateTime dts = DateTime.Parse(xrofst.Attributes.GetNamedItem("dts").InnerText);
ROFst rv = null;
rv = ROFst.GetByRODbID_DTS(MyRODb.RODbID, dts); //MyRODb.DTS);
rv = ROFst.GetByRODbID_DTS(MyRODb.RODbID, dts);
// if the RO database is not found in the current data (does not have the same RODBid nor date/time stamp
// then spin through the list of RO databases and compare the FST information.
// If the RO FST information is the same, then use that current RO database when importing
if (rv == null)
{
RODbInfoList rodblst = RODbInfoList.Get();
foreach (RODbInfo roinfo in rodblst)
{
rv = ROFst.GetByRODbID_DTS(roinfo.RODbID, dts);
if (rv != null && Same(rv.ROLookup,rolookup)) return rv;
}
rv = ROFst.MakeROFst(MyRODb, rolookup, config, dts, userid);
XmlNode xfigures = xrofst.SelectSingleNode("figures");
if (xfigures != null)
@ -2762,6 +2771,15 @@ namespace VEPROMS
}
return rv;
}
private bool Same(byte[] p, byte[] rolookup)
{
if (p.Length != rolookup.Length) return false;
for (int i = 0; i < p.Length; i++)
if (p[i] != rolookup[i]) return false;
return true;
}
private void AddFigures(XmlNode xfigures, ROFst rofst)
{
foreach (XmlNode nd in xfigures.SelectNodes("figure"))
@ -2820,7 +2838,24 @@ namespace VEPROMS
RODb rv = null;
rv = RODb.GetByFolderPath(folderpath);
if (rv == null)
rv = RODb.MakeRODb(roname, folderpath, dbconnectionstring, config, dts, userid);
{
// create a list of the RO databases currently in the database
List<string> roDbNameList = new List<string>();
RODbInfoList rolist = RODbInfoList.Get();
foreach (RODbInfo rodbinfo in rolist)
{
if (!roDbNameList.Contains(rodbinfo.ROName))
roDbNameList.Add(rodbinfo.ROName);
}
rolist.Dispose();
int cnt = 0;
string roNameNew = roname;
// if the ROname we are importing is the same as one already in the database
// and the ROpaths are different, then rename the one we are importing
while (roDbNameList.Contains(roNameNew))
roNameNew = string.Format("{0}_{1}",roname,(++cnt).ToString());
rv = RODb.MakeRODb(roNameNew, folderpath, dbconnectionstring, config, dts, userid);
}
newRODbID = rv.RODbID;
return rv;
}