예제 #1
0
        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);
        }
예제 #2
0
        public static string GetConfigDataPath(string configTitle, MainConfigType mainConfigType)
        {
            string result = "";

            string configRootPath = GetConfigRootPath(mainConfigType);

            result = $"{configRootPath}\\{configTitle}\\{ConfigDataDirName}";

            return(result);
        }
예제 #3
0
        public static string GetConfigDataFilePath(string configTitle, MainConfigType mainConfigType)
        {
            string result = "";

            string configDataPath = GetConfigDataPath(configTitle, mainConfigType);

            result = $"{configDataPath}\\{ConfigDataFileName}";

            return(result);
        }
예제 #4
0
 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;
 }
예제 #5
0
 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;
 }
예제 #6
0
 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;
 }
예제 #7
0
 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;
 }
예제 #8
0
        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;
            }
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #11
0
        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);
        }