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