using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB.TDCINI
{
///
/// helper class for ISO Export section of INI
///
public class INIISOExportParameters
{
///
/// whether to automatically export ISO on download
///
public bool AutomaticISOExportOnDownload { get; set; }
///
/// the MME header template (empty if none)
///
public string MMEHeaderTemplateFilename { get; set; }
///
/// whether to prompt the user for MME header template file or not
///
public bool PromptUserForMMETemplateFilename { get; set; }
///
/// channel header template (empty if none)
///
public string ChannelHeaderTemplateFilename { get; set; }
///
/// whether to prompt the user for a channel header template file
///
public bool PromptUserForChannelHeaderFilename { get; set; }
public enum FilterOutputOptions
{
UnFiltered = 0,
Filtered = 1,
PromptUser = 2
}
///
/// what type of output is desired
///
public FilterOutputOptions FilterOutput { get; set; }
///
/// whether to supress the export completion dialog
///
public bool SuppressExportCompletionDialog { get; set; }
///
/// dummy template file (empty if none)
///
public string DummyTemplateFilename { get; set; }
///
/// whether to prompt the user for dummy template file or not
///
public bool PromptUserForDummyTemplateFilename { get; set; }
///
/// reads settings from a line
/// returns true if successful or false if not
///
///
///
///
///
public bool ReadFrom(string line, int curLine, ref List errors)
{
string[] tokens = line.Split(new char[] { ',' });
if (tokens.Length != 9)
{
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_ISOEXPORTPARAMETERS_INVALID, line, curLine));
return false;
}
switch (tokens[0])
{
case "0":
case "F":
case "N":
AutomaticISOExportOnDownload = false;
break;
case "1":
case "T":
case "Y":
AutomaticISOExportOnDownload = true;
break;
default:
{
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_ISOEXPORTPARAMETERS_INVALID, tokens[0], curLine));
return false;
}
}
MMEHeaderTemplateFilename = tokens[1];
switch (tokens[2])
{
case "0":
case "F":
case "N":
PromptUserForMMETemplateFilename = false;
break;
case "1":
case "T":
case "Y":
PromptUserForMMETemplateFilename = true;
break;
default:
{
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_ISOEXPORTPARAMETERS_INVALID, tokens[2], curLine));
return false;
}
}
ChannelHeaderTemplateFilename = tokens[3];
switch (tokens[4])
{
case "0":
case "F":
case "N":
PromptUserForChannelHeaderFilename = false;
break;
case "1":
case "T":
case "Y":
PromptUserForChannelHeaderFilename = true;
break;
default:
{
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_ISOEXPORTPARAMETERS_INVALID, tokens[4], curLine));
return false;
}
}
switch (tokens[5])
{
case "0": FilterOutput = FilterOutputOptions.UnFiltered; break;
case "1": FilterOutput = FilterOutputOptions.Filtered; break;
case "2": FilterOutput = FilterOutputOptions.PromptUser; break;
default:
{
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_ISOEXPORTPARAMETERS_INVALID, tokens[5], curLine));
return false;
}
}
switch (tokens[6])
{
case "0":
case "F":
case "N":
SuppressExportCompletionDialog = false; break;
case "1":
case "T":
case "Y":
SuppressExportCompletionDialog = true; break;
default:
{
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_ISOEXPORTPARAMETERS_INVALID, tokens[6], curLine));
return false;
}
}
DummyTemplateFilename = tokens[7];
switch (tokens[8])
{
case "0":
case "F":
case "N":
PromptUserForDummyTemplateFilename = false; break;
case "1":
case "T":
case "Y":
PromptUserForDummyTemplateFilename = true; break;
default:
{
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_ISOEXPORTPARAMETERS_INVALID, tokens[8], curLine));
return false;
}
}
return true;
}
}
}