public string CreateWB2File()
{
StringBuilder sb = new StringBuilder();
List<CompanionFileType> fileorder = new List<CompanionFileType>()
{
CompanionFileType.FGRP, CompanionFileType.MGRP, CompanionFileType.DVIC, CompanionFileType.XMTR,
CompanionFileType.RCVR, CompanionFileType.ICMD, CompanionFileType.PRND, CompanionFileType.EVNT,
CompanionFileType.RESP, CompanionFileType.JOBF, CompanionFileType.TEXT, CompanionFileType.DIRC,
CompanionFileType.TELV, CompanionFileType.ZONE, CompanionFileType.FEMA, CompanionFileType.DIAL,
CompanionFileType.INPU, CompanionFileType.SCHD, CompanionFileType.TELL, CompanionFileType.ZNAM,
CompanionFileType.TRAN, CompanionFileType.RNAM, CompanionFileType.JOBX, CompanionFileType.WORK,
CompanionFileType.NOTE, CompanionFileType.RDAT, CompanionFileType.CWAP, CompanionFileType.IPSH,
CompanionFileType.IUSR, CompanionFileType.PAGR, CompanionFileType.REMS, CompanionFileType.LTXT
};
foreach (CompanionFileType fileType in fileorder)
{
sb.AppendLine("// " + fileType.ToString().ToLower() + ".txt");
// force update znam.shortname ==> zone.name
switch (fileType)
{
case CompanionFileType.EVNT:
break;
case CompanionFileType.ZONE:
for (int i = 0; i < Files[CompanionFileType.ZNAM].Count; i++)
{
var zone = Files[CompanionFileType.ZONE][i] as ZONE;
var znam = Files[CompanionFileType.ZNAM][i] as ZNAM;
if (znam != null && zone != null)
zone.Name = znam.ShortName;
}
break;
}
List<CompanionFile> list = Files[fileType];
bool useAltFormat = (fileType == CompanionFileType.LTXT);
int iiii = 0;
foreach (CompanionFile cf in list)
{
if (iiii == 7935)
{
}
iiii++;
if (cf != null)
sb.Append(cf.FormatFile(useAltFormat));
useAltFormat = false; // ltxt 1st record is b64. the rest are s64.
}
}
return sb.ToString();
}