C2025-022-Remove-UCF-2
This commit is contained in:
@@ -75,9 +75,8 @@ namespace VEPROMS
|
||||
xa.InnerText = value;
|
||||
return xa;
|
||||
}
|
||||
public dlgExportImport(string mode, FolderInfo folderInfo, frmVEPROMS myFrmVEPROMS, E_UCFImportOptions frset, int unitIndex = 0)
|
||||
public dlgExportImport(string mode, FolderInfo folderInfo, frmVEPROMS myFrmVEPROMS, int unitIndex = 0)
|
||||
{
|
||||
UCFImportDefaultFromSettings = frset;
|
||||
MyFrmVEPROMS = myFrmVEPROMS;// Save frmVEPROMS for Import to shutoff SessionPing
|
||||
_MyMode = mode;
|
||||
MyFolder = folderInfo;
|
||||
@@ -97,9 +96,8 @@ namespace VEPROMS
|
||||
FormClosed += RemoveUnit_OnClose;
|
||||
}
|
||||
}
|
||||
public dlgExportImport(string mode, DocVersionInfo docVersionInfo, frmVEPROMS myFrmVEPROMS, E_UCFImportOptions frset, int unitIndex = 0)
|
||||
public dlgExportImport(string mode, DocVersionInfo docVersionInfo, frmVEPROMS myFrmVEPROMS, int unitIndex = 0)
|
||||
{
|
||||
UCFImportDefaultFromSettings = frset;
|
||||
MyFrmVEPROMS = myFrmVEPROMS;// Save frmVEPROMS for Import to shutoff SessionPing
|
||||
_MyMode = mode;
|
||||
MyDocVersion = docVersionInfo;
|
||||
@@ -120,9 +118,8 @@ namespace VEPROMS
|
||||
FormClosed += RemoveUnit_OnClose;
|
||||
}
|
||||
}
|
||||
public dlgExportImport(string mode, ProcedureInfo procedureInfo, frmVEPROMS myFrmVEPROMS, E_UCFImportOptions frset, int unitIndex = 0)
|
||||
public dlgExportImport(string mode, ProcedureInfo procedureInfo, frmVEPROMS myFrmVEPROMS, int unitIndex = 0)
|
||||
{
|
||||
UCFImportDefaultFromSettings = frset;
|
||||
MyFrmVEPROMS = myFrmVEPROMS;// Save frmVEPROMS for Import to shutoff SessionPing
|
||||
_MyMode = mode;
|
||||
MyProcedure = procedureInfo;
|
||||
@@ -724,28 +721,28 @@ namespace VEPROMS
|
||||
ImportProcedureNew(xd);
|
||||
isImported = true;
|
||||
}
|
||||
if (isImported && UCFImportCase == E_UCFImportOptions.LoadForSetOnly) UpdateFormatForUCFInSet();
|
||||
//if (isImported && UCFImportCase == E_UCFImportOptions.LoadForSetOnly) UpdateFormatForUCFInSet();
|
||||
return true;// Import Suceeded
|
||||
}
|
||||
private void UpdateFormatForUCFInSet()
|
||||
{
|
||||
// this gets called if the UCFImportCase == LoadForSetOnly, i.e. only items in this PROCEDURE Set whose formats point to a
|
||||
// UCF format should point to the updated (copied) UCF format.
|
||||
if (renamedUCFFormatId == null) return;
|
||||
foreach (int key in renamedUCFFormatId.Keys)
|
||||
{
|
||||
using (ContentInfoList cil = ContentInfoList.FixFormatIDAfterImport(MyDocVersion.VersionID.ToString(), renamedUCFFormatId[key], key))
|
||||
{
|
||||
foreach (ContentInfo ci in cil)
|
||||
{
|
||||
using (Content c = ci.Get())
|
||||
{
|
||||
ContentInfo.Refresh(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//private void UpdateFormatForUCFInSet()
|
||||
//{
|
||||
// // this gets called if the UCFImportCase == LoadForSetOnly, i.e. only items in this PROCEDURE Set whose formats point to a
|
||||
// // UCF format should point to the updated (copied) UCF format.
|
||||
// if (renamedUCFFormatId == null) return;
|
||||
// foreach (int key in renamedUCFFormatId.Keys)
|
||||
// {
|
||||
// using (ContentInfoList cil = ContentInfoList.FixFormatIDAfterImport(MyDocVersion.VersionID.ToString(), renamedUCFFormatId[key], key))
|
||||
// {
|
||||
// foreach (ContentInfo ci in cil)
|
||||
// {
|
||||
// using (Content c = ci.Get())
|
||||
// {
|
||||
// ContentInfo.Refresh(c);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// Added Error Handling to assure that Change Manager is turned-on regardless of success or failure of the import
|
||||
// B2019-046: improved error handling (added return value & error message)
|
||||
private bool TryToLoadImportDataDocument()
|
||||
@@ -1014,8 +1011,8 @@ namespace VEPROMS
|
||||
c.Save();
|
||||
}
|
||||
}
|
||||
private E_UCFImportOptions UCFImportDefaultFromSettings;
|
||||
private E_UCFImportOptions UCFImportCase = E_UCFImportOptions.LoadOnlyImported;
|
||||
//private E_UCFImportOptions UCFImportDefaultFromSettings;
|
||||
//private E_UCFImportOptions UCFImportCase = E_UCFImportOptions.LoadOnlyImported;
|
||||
Dictionary<string, string> existingCopyFCName = new Dictionary<string, string>();
|
||||
// note that this is used when importing a folder or a procedure (procedure was added for UCF changes)
|
||||
private bool LoadFormats(XmlDocument xd, string xmlpath)
|
||||
@@ -1057,7 +1054,6 @@ namespace VEPROMS
|
||||
{
|
||||
existingFC.Add(exFI.Config);
|
||||
importedFC.Add(config);
|
||||
conflictingUCFdata = true;
|
||||
fname.Add(name);
|
||||
}
|
||||
else
|
||||
@@ -1066,22 +1062,6 @@ namespace VEPROMS
|
||||
}
|
||||
}
|
||||
|
||||
// there is a difference in UCF data, see if user wants sections to use the existing or new ucf data:
|
||||
if (conflictingUCFdata)
|
||||
{
|
||||
// Bring up dialog to allow user to choose how the UCF data is handled:
|
||||
// Importing of a procedure(s) (names of UCF exist in current DB and in exported DB)
|
||||
//Case 0 - ignore (don't bring in new UCF)
|
||||
//Case 1 - bringing in new UCF and not using it
|
||||
//Case 2 - bringing in new UCF and only using it for imported data
|
||||
//Case 3 - bringing in new UCF and using it across the board
|
||||
//Case 4 - bringing in new UCF and using it for the current procedure set (not applicable for procedure sets)
|
||||
UCFImportCase = UCFImportDefaultFromSettings; // from the options/settings
|
||||
dlgUCFImportOptions ucfoptDlg = new dlgUCFImportOptions(fname, existingFC, importedFC, UCFImportCase, xmlpath);
|
||||
DialogResult dr = ucfoptDlg.ShowDialog();
|
||||
if (dr != DialogResult.OK) return false;
|
||||
UCFImportCase = ucfoptDlg.UCFImportOptionsCase; // may be reset from dialog.
|
||||
}
|
||||
// first see if any of the imported formats have different data. If so,
|
||||
foreach (XmlNode nd in nl)
|
||||
{
|
||||
@@ -1133,102 +1113,102 @@ namespace VEPROMS
|
||||
// various cases listed above:
|
||||
if (existingFormat.ContainsKey(name))
|
||||
{
|
||||
// if case 0 and this ucf already exists, ignore it:
|
||||
if (UCFImportCase == E_UCFImportOptions.Ignore) continue;
|
||||
//// if case 0 and this ucf already exists, ignore it:
|
||||
//if (UCFImportCase == E_UCFImportOptions.Ignore) continue;
|
||||
|
||||
// if case 1, 2, 4 and the name exists, make a 'copy' of the newly imported format:
|
||||
// need to add this format - name must be unique so add 'COPY(x) of 'original name'' where x is unique number:
|
||||
if (UCFImportCase == E_UCFImportOptions.LoadNotUsed || UCFImportCase == E_UCFImportOptions.LoadOnlyImported || UCFImportCase == E_UCFImportOptions.LoadForSetOnly)
|
||||
{
|
||||
int count = (fil.Where(fi => fi.Name.EndsWith(name))).Count();
|
||||
if (count > 0)
|
||||
{
|
||||
string origname = name;
|
||||
name = string.Format("Copy {0} of {1}", count.ToString(), name);
|
||||
if (UCFImportCase == E_UCFImportOptions.LoadOnlyImported || UCFImportCase == E_UCFImportOptions.LoadForSetOnly)
|
||||
{
|
||||
if (renamedUCFFormatName == null) renamedUCFFormatName = new Dictionary<string, string>();
|
||||
renamedUCFFormatName.Add(origname, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
//// if case 1, 2, 4 and the name exists, make a 'copy' of the newly imported format:
|
||||
//// need to add this format - name must be unique so add 'COPY(x) of 'original name'' where x is unique number:
|
||||
//if (UCFImportCase == E_UCFImportOptions.LoadNotUsed || UCFImportCase == E_UCFImportOptions.LoadOnlyImported || UCFImportCase == E_UCFImportOptions.LoadForSetOnly)
|
||||
//{
|
||||
// int count = (fil.Where(fi => fi.Name.EndsWith(name))).Count();
|
||||
// if (count > 0)
|
||||
// {
|
||||
// string origname = name;
|
||||
// name = string.Format("Copy {0} of {1}", count.ToString(), name);
|
||||
// if (UCFImportCase == E_UCFImportOptions.LoadOnlyImported || UCFImportCase == E_UCFImportOptions.LoadForSetOnly)
|
||||
// {
|
||||
// if (renamedUCFFormatName == null) renamedUCFFormatName = new Dictionary<string, string>();
|
||||
// renamedUCFFormatName.Add(origname, name);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// if case 3, take the existing config data and create in a record whose name is Old(x) of 'original name' (the record
|
||||
// creation gets done below). Then modify the existing record to have the config data. The result is that any
|
||||
// sections that used this UCF throughout the database will have the new config data.
|
||||
if (UCFImportCase == E_UCFImportOptions.LoadUseAll)
|
||||
{
|
||||
string savname = name;
|
||||
int count = (fil.Where(fi => fi.Name.EndsWith(name))).Count();
|
||||
if (count > 0)
|
||||
{
|
||||
name = string.Format("Old {0} of {1}", count.ToString(), name);
|
||||
}
|
||||
// update the 'old' record by getting the original config data.
|
||||
string savdesc = null;
|
||||
DateTime savdts = DateTime.Now;
|
||||
string savuid = null;
|
||||
int savpar = 0;
|
||||
string savconfig = null;
|
||||
using (Format origRecord = Format.Get(existingFormat[savname]))
|
||||
{
|
||||
savdesc = origRecord.Description;
|
||||
savdts = origRecord.DTS;
|
||||
savuid = origRecord.UserID;
|
||||
savpar = origRecord.ParentID;
|
||||
savconfig = origRecord.Config;
|
||||
origRecord.Name = savname;
|
||||
origRecord.Description = description;
|
||||
origRecord.DTS = dts;
|
||||
origRecord.UserID = userid;
|
||||
origRecord.MyParent = pformat;
|
||||
origRecord.Config = config;
|
||||
origRecord.Save();
|
||||
description = savdesc;
|
||||
dts = savdts;
|
||||
userid = savuid;
|
||||
pformat = Format.Get(savpar);
|
||||
config = savconfig;
|
||||
//if (UCFImportCase == E_UCFImportOptions.LoadUseAll)
|
||||
//{
|
||||
// string savname = name;
|
||||
// int count = (fil.Where(fi => fi.Name.EndsWith(name))).Count();
|
||||
// if (count > 0)
|
||||
// {
|
||||
// name = string.Format("Old {0} of {1}", count.ToString(), name);
|
||||
// }
|
||||
// // update the 'old' record by getting the original config data.
|
||||
// string savdesc = null;
|
||||
// DateTime savdts = DateTime.Now;
|
||||
// string savuid = null;
|
||||
// int savpar = 0;
|
||||
// string savconfig = null;
|
||||
// using (Format origRecord = Format.Get(existingFormat[savname]))
|
||||
// {
|
||||
// savdesc = origRecord.Description;
|
||||
// savdts = origRecord.DTS;
|
||||
// savuid = origRecord.UserID;
|
||||
// savpar = origRecord.ParentID;
|
||||
// savconfig = origRecord.Config;
|
||||
// origRecord.Name = savname;
|
||||
// origRecord.Description = description;
|
||||
// origRecord.DTS = dts;
|
||||
// origRecord.UserID = userid;
|
||||
// origRecord.MyParent = pformat;
|
||||
// origRecord.Config = config;
|
||||
// origRecord.Save();
|
||||
// description = savdesc;
|
||||
// dts = savdts;
|
||||
// userid = savuid;
|
||||
// pformat = Format.Get(savpar);
|
||||
// config = savconfig;
|
||||
|
||||
}
|
||||
}
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
if (UCFImportCase == 0) // ignore it
|
||||
{
|
||||
//if (UCFImportCase == 0) // ignore it
|
||||
//{
|
||||
importedFormat.Add(formatid, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
Format rec = Format.MakeFormat(pformat, name, description, null, null, dts, userid);
|
||||
rec.Config = config;
|
||||
rec.Save();
|
||||
if (UCFImportCase == E_UCFImportOptions.LoadNotUsed || UCFImportCase == E_UCFImportOptions.LoadUseAll) // don't reset format id (case 1 don't use it, case 3 copies new data into original record
|
||||
importedFormat.Add(formatid, name);
|
||||
else if (UCFImportCase == E_UCFImportOptions.LoadOnlyImported || UCFImportCase == E_UCFImportOptions.LoadForSetOnly) // case 2 uses it for any items imported, case 4 uses it for any sections within current set
|
||||
{
|
||||
existingFormat.Add(name, rec.FormatID); // change to original name?
|
||||
importedFormat.Add(rec.FormatID, name);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// Format rec = Format.MakeFormat(pformat, name, description, null, null, dts, userid);
|
||||
// rec.Config = config;
|
||||
// rec.Save();
|
||||
// if (UCFImportCase == E_UCFImportOptions.LoadNotUsed || UCFImportCase == E_UCFImportOptions.LoadUseAll) // don't reset format id (case 1 don't use it, case 3 copies new data into original record
|
||||
// importedFormat.Add(formatid, name);
|
||||
// else if (UCFImportCase == E_UCFImportOptions.LoadOnlyImported || UCFImportCase == E_UCFImportOptions.LoadForSetOnly) // case 2 uses it for any items imported, case 4 uses it for any sections within current set
|
||||
// {
|
||||
// existingFormat.Add(name, rec.FormatID); // change to original name?
|
||||
// importedFormat.Add(rec.FormatID, name);
|
||||
|
||||
// get format id for the original named format
|
||||
if (UCFImportCase == E_UCFImportOptions.LoadForSetOnly && renamedUCFFormatName != null)
|
||||
{
|
||||
int origformatid = -1;
|
||||
foreach (var kvp in renamedUCFFormatName)
|
||||
{
|
||||
if (kvp.Value == name)
|
||||
{
|
||||
origformatid = existingFormat[kvp.Key];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (origformatid != -1)
|
||||
{
|
||||
if (renamedUCFFormatId == null) renamedUCFFormatId = new Dictionary<int, int>();
|
||||
renamedUCFFormatId.Add(rec.FormatID, origformatid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// // get format id for the original named format
|
||||
// if (UCFImportCase == E_UCFImportOptions.LoadForSetOnly && renamedUCFFormatName != null)
|
||||
// {
|
||||
// int origformatid = -1;
|
||||
// foreach (var kvp in renamedUCFFormatName)
|
||||
// {
|
||||
// if (kvp.Value == name)
|
||||
// {
|
||||
// origformatid = existingFormat[kvp.Key];
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (origformatid != -1)
|
||||
// {
|
||||
// if (renamedUCFFormatId == null) renamedUCFFormatId = new Dictionary<int, int>();
|
||||
// renamedUCFFormatId.Add(rec.FormatID, origformatid);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
FormatInfoList.Reset();
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user