fixed sub format problems
This commit is contained in:
parent
6947709149
commit
77b8e31d8d
@ -142,42 +142,46 @@ namespace DataLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public FormatInfo GetFormat(string format)
|
public FormatInfo GetFormat(string format)
|
||||||
{
|
{
|
||||||
Format parent = null;
|
Format parent = null;
|
||||||
Format rec = null;
|
Format rec = null;
|
||||||
|
|
||||||
// get base
|
// get base
|
||||||
Format baseparent = Format.Get(1);
|
Format baseparent = Format.Get(1);
|
||||||
|
|
||||||
// if there is no format - what should be done? maybe nothing.
|
// if there is no format - what should be done? maybe nothing.
|
||||||
if (format == null || format == "") return null;
|
if (format == null || format == "") return null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (format.IndexOf(' ') > -1) // will have spaces if it's a user format
|
if (format.IndexOf(' ') > -1) // will have spaces if it's a user format
|
||||||
{
|
{
|
||||||
string part1 = format.Substring(0, format.IndexOf(' '));
|
string part1 = format.Substring(0, format.IndexOf(' '));
|
||||||
string part2 = format.Substring(format.LastIndexOf(' ') + 1, 2);
|
string part2 = format.Substring(format.LastIndexOf(' ') + 1, 2);
|
||||||
format = part1 + part2;
|
format = part1 + part2;
|
||||||
|
|
||||||
// get the parent format's id (for example, AEP for AEP00).
|
// get the parent format's id (for example, AEP for AEP00).
|
||||||
parent = Format.GetByParentID_Name(baseparent.FormatID, part1);
|
parent = Format.GetByParentID_Name(baseparent.FormatID, part1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
parent = baseparent;
|
parent = baseparent;
|
||||||
|
|
||||||
// see if the format has been added, if not go get it.
|
// see if the format has been added, if not go get it.
|
||||||
rec = Format.GetByParentID_Name(parent.FormatID, format);
|
rec = Format.GetByParentID_Name(parent.FormatID, format);
|
||||||
}
|
// JSJ - 02/04/10 this fixes cases where a subformat is no longer available,
|
||||||
catch (Exception ex)
|
// default to the parent format
|
||||||
{
|
if (rec == null)
|
||||||
log.ErrorFormat("Error getting xml version of format {0}", ex.Message);
|
rec = parent;
|
||||||
frmMain.AddError(ex, "GetFormat('{0}')", format);
|
}
|
||||||
}
|
catch (Exception ex)
|
||||||
FormatInfo recInfo = FormatInfo.Get(rec.FormatID);
|
{
|
||||||
return recInfo;
|
log.ErrorFormat("Error getting xml version of format {0}", ex.Message);
|
||||||
}
|
frmMain.AddError(ex, "GetFormat('{0}')", format);
|
||||||
|
}
|
||||||
|
FormatInfo recInfo = FormatInfo.Get(rec.FormatID);
|
||||||
|
return recInfo;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user