public static async Task <List <ConfigurationBase> > LoadConfiguration(MainConfigType mainConfigType) { List <ConfigurationBase> configurationBases = new List <ConfigurationBase>(); string omrConfigPath = GetConfigRootPath(mainConfigType); if (!Directory.Exists(omrConfigPath)) { return(configurationBases); } string[] configsPaths = Directory.GetDirectories(omrConfigPath); await Task.Run(() => { for (int i = 0; i < configsPaths.Length; i++) { string configDataFilePath = Path.Combine(configsPaths[i], ConfigDataDirName, configDataFileName); BinaryFormatter bf = new BinaryFormatter(); using (FileStream fs = new FileStream(configDataFilePath, FileMode.Open)) { ConfigurationBase configurationBase = (ConfigurationBase)bf.Deserialize(fs); configurationBases.Add(configurationBase); } } }); return(configurationBases); }
public static string GetConfigDataPath(string configTitle, MainConfigType mainConfigType) { string result = ""; string configRootPath = GetConfigRootPath(mainConfigType); result = $"{configRootPath}\\{configTitle}\\{ConfigDataDirName}"; return(result); }
public static string GetConfigDataFilePath(string configTitle, MainConfigType mainConfigType) { string result = ""; string configDataPath = GetConfigDataPath(configTitle, mainConfigType); result = $"{configDataPath}\\{ConfigDataFileName}"; return(result); }
public ConfigurationBase(ConfigurationBase initializationData) { Title = initializationData.Title; this.mainConfigType = initializationData.GetMainConfigType; this.configArea = initializationData.GetConfigArea; ValueDataType = initializationData.ValueDataType; Typography = initializationData.Typography; ValueRepresentation = initializationData.ValueRepresentation; ValueEditType = initializationData.ValueEditType; this.configRange = initializationData.configRange; }
public ConfigurationBase(BaseData baseData) { Title = baseData.title; this.mainConfigType = baseData.mainConfigType; this.configArea = baseData.configArea; ValueDataType = baseData.valueDataType; Typography = baseData.typography; ValueRepresentation = baseData.valueRepresentation; ValueEditType = baseData.valueEditType; this.configRange = baseData.configRange; ProcessingIndex = baseData.processingIndex; }
public ConfigurationBase(string title, MainConfigType mainConfigType, ConfigArea configArea, ValueDataType valueDataType, Typography typography, ValueRepresentation valueRepresentation, ValueEditType valueEditType, ConfigRange configRange, int processingIndex) { Title = title; this.mainConfigType = mainConfigType; this.configArea = configArea; ValueDataType = valueDataType; Typography = typography; ValueRepresentation = valueRepresentation; ValueEditType = valueEditType; this.configRange = configRange; ProcessingIndex = processingIndex; }
public BaseData(ConfigurationBase initializationData) { title = initializationData.Title; mainConfigType = initializationData.GetMainConfigType; configArea = initializationData.GetConfigArea; valueDataType = initializationData.ValueDataType; typography = initializationData.Typography; valueRepresentation = initializationData.ValueRepresentation; valueEditType = initializationData.ValueEditType; configRange = initializationData.configRange; this.processingIndex = initializationData.ProcessingIndex; }
void SetConfigType(MainConfigType configType) { switch (configType) { case MainConfigType.OMR: configTypeIcon.Image = OMRConfigIcon; break; case MainConfigType.BARCODE: configTypeIcon.Image = OBRConfigIcon; break; case MainConfigType.ICR: configTypeIcon.Image = ICRConfigIcon; break; } }
public static bool DeleteConfigData(ConfigurationBase config, MainConfigType mainConfigType, out Exception _ex) { bool result = true; _ex = new Exception(); string configRootPath = GetConfigRootPath(mainConfigType); string configPath = $"{configRootPath}\\{config.Title}"; try { Directory.Delete(configPath, true); } catch (Exception ex) { _ex = ex; result = false; } return(result); }
public static string GetConfigRootPath(MainConfigType mainConfigType) { string result = ""; string templateRootPath = GetCurrentTemplateRootPath(); switch (mainConfigType) { case MainConfigType.OMR: result = $"{templateRootPath}\\{OMRConfigRootDirName}"; break; case MainConfigType.BARCODE: result = $"{templateRootPath}\\{OBRConfigRootDirName}"; break; case MainConfigType.ICR: result = $"{templateRootPath}\\{ICRConfigRootDirName}"; break; } return(result); }
public static bool SaveConfigData(ConfigurationBase config, MainConfigType mainConfigType, out Exception _ex) { bool result = true; _ex = new Exception(); string configDataPath = GetConfigDataPath(config.Title, mainConfigType); if (!Directory.Exists(configDataPath)) { Directory.CreateDirectory(configDataPath); } string configDataFilePath = GetConfigDataFilePath(config.Title, mainConfigType); switch (mainConfigType) { case MainConfigType.OMR: OMRConfiguration omrConfiguration = (OMRConfiguration)config; try { BinaryFormatter bf = new BinaryFormatter(); using (FileStream fs = new FileStream(configDataFilePath, FileMode.Create)) { bf.Serialize(fs, omrConfiguration); } } catch (Exception ex) { _ex = ex; result = false; } break; case MainConfigType.BARCODE: OBRConfiguration obrConfiguration = (OBRConfiguration)config; try { BinaryFormatter bf = new BinaryFormatter(); using (FileStream fs = new FileStream(configDataFilePath, FileMode.Create)) { bf.Serialize(fs, obrConfiguration); } } catch (Exception ex) { _ex = ex; result = false; } break; case MainConfigType.ICR: ICRConfiguration icrConfiguration = (ICRConfiguration)config; try { BinaryFormatter bf = new BinaryFormatter(); using (FileStream fs = new FileStream(configDataFilePath, FileMode.Create)) { bf.Serialize(fs, icrConfiguration); } } catch (Exception ex) { _ex = ex; result = false; } break; } return(result); }