Fix B2016-045, B2016-083 & 084: Procedure number hyphen representation, create non-existing annotation type & don’t import if user does not overwrite/copy existing procedure.
Fix B2016-083: Added a method ‘GetByNameOrCreate’ that will create the Annotation type if it doesn’t exist
This commit is contained in:
parent
5ec4b86663
commit
5d8d79e32c
@ -254,7 +254,8 @@ namespace VEPROMS
|
||||
dv.Save();
|
||||
}
|
||||
dv.Reset_DocVersionAssociations();
|
||||
MyDocVersion.RefreshDocVersionAssociations(); }
|
||||
MyDocVersion.RefreshDocVersionAssociations();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -264,9 +265,19 @@ namespace VEPROMS
|
||||
}
|
||||
}
|
||||
}
|
||||
// use resolvedProcNum to determine if procedure is 'unique', i.e. if the procedure number exists
|
||||
// and user does not overwrite or copy, then the procedure should NOT be imported. Fix for B2016-045
|
||||
bool resolvedProcNum = true;
|
||||
foreach (ProcedureInfo pi in MyDocVersion.Procedures)
|
||||
{
|
||||
if (pi.ItemID == int.Parse(xd.SelectSingleNode("procedure/@itemid").InnerText) || pi.MyContent.Number == xd.SelectSingleNode("procedure/content/@number").InnerText)
|
||||
// procedure numbers that contain a hyphen may have the hyphen represented as the unicode character
|
||||
// '\u8209?' or the '-' character. If proc number is same except for hyphen representation, they
|
||||
// 2 should be considered the same procedure (fix for B2016-084)
|
||||
string hyphenNum = pi.MyContent.Number == null ? pi.MyContent.Number : pi.MyContent.Number.Replace(@"\u8209?", "-");
|
||||
string hyphenImpNum = xd.SelectSingleNode("procedure/content/@number").InnerText;
|
||||
hyphenImpNum = hyphenImpNum == null ? hyphenImpNum : hyphenImpNum.Replace("\u8030?", "-");
|
||||
|
||||
if (pi.ItemID == int.Parse(xd.SelectSingleNode("procedure/@itemid").InnerText) || hyphenNum == hyphenImpNum)
|
||||
{
|
||||
DialogResult dr = MessageBox.Show(this, "The procedure you are importing already exists in this procedure set. Do you want to overwrite the existing procedure?", "Overwrite Existing Procedure", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop);
|
||||
if (dr == DialogResult.Yes)
|
||||
@ -284,10 +295,12 @@ namespace VEPROMS
|
||||
isImported = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
resolvedProcNum = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isImported)
|
||||
if (!isImported && resolvedProcNum)
|
||||
{
|
||||
ImportProcedureNew(xd);
|
||||
}
|
||||
@ -350,6 +363,8 @@ namespace VEPROMS
|
||||
ProcedureInfo lastProcedure = null;
|
||||
//determine count of existing procedures with same number
|
||||
string number = xd.SelectSingleNode("procedure/content/@number").InnerText;
|
||||
|
||||
// kbr - could replace '-' with unicode in number, here.
|
||||
int count = 0;
|
||||
foreach (ProcedureInfo pi in MyDocVersion.Procedures)
|
||||
{
|
||||
@ -2806,7 +2821,7 @@ namespace VEPROMS
|
||||
string config = nd.Attributes.GetNamedItem("config").InnerText;
|
||||
string userid = nd.Attributes.GetNamedItem("userid").InnerText;
|
||||
DateTime dts = DateTime.Parse(nd.Attributes.GetNamedItem("dts").InnerText);
|
||||
AnnotationType annType = AnnotationType.GetByName(nd.Attributes.GetNamedItem("typename").InnerText);
|
||||
AnnotationType annType = AnnotationType.GetByNameOrCreate(nd.Attributes.GetNamedItem("typename").InnerText);
|
||||
Annotation ann = Annotation.MakeAnnotation(itm, annType, rtftext, searchtext, config, dts, userid);
|
||||
ann.Save();
|
||||
}
|
||||
|
@ -602,6 +602,36 @@ namespace VEPROMS.CSLA.Library
|
||||
throw new DbCslaException("Error on AnnotationType.GetByName", ex);
|
||||
}
|
||||
}
|
||||
// GetByNameOrCreate: gets the AnnotationType by its name, if it exists. If it
|
||||
// doesn't exist, create it (fix B2016-083)
|
||||
public static AnnotationType GetByNameOrCreate(string name)
|
||||
{
|
||||
if (!CanGetObject())
|
||||
throw new System.Security.SecurityException("User not authorized to view a AnnotationType");
|
||||
try
|
||||
{
|
||||
AnnotationType tmp = GetCachedByName(name);
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<AnnotationType>(new NameCriteria(name));
|
||||
AddToCache(tmp);
|
||||
}
|
||||
// if the type doesn't exist, try to add it
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up AnnotationType
|
||||
tmp = null;
|
||||
tmp = AnnotationType.MakeAnnotationType(name, null);
|
||||
AddToCache(tmp);
|
||||
AnnotationTypeInfoList.Refresh();
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on AnnotationType.GetByNameOrCreate", ex);
|
||||
}
|
||||
}
|
||||
public static AnnotationType Get(SafeDataReader dr)
|
||||
{
|
||||
if (dr.Read()) return new AnnotationType(dr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user