Example #1
0
        private void InitializeMetaData()
        {
            try
            {
                Metadata.AppID     = ConfigurationManager.AppSettings["AppID"];
                Metadata.AppType   = ConfigurationManager.AppSettings["AppType"];
                Metadata.AuthToken = ConfigurationManager.AppSettings["AuthToken"];

                Metadata.PreferredCOMPort  = ConfigurationManager.AppSettings["LCPort"];
                Metadata.PreferredBaudRate = ConfigurationManager.AppSettings["LCPBaud"];

                Metadata.ServerIP   = ConfigurationManager.AppSettings["RServer"];
                Metadata.ServerPort = int.Parse(ConfigurationManager.AppSettings["RSPort"]);
            }
            catch (Exception imEx1)
            {
            }

            try
            {
                string HexaConfigFile = ConfigurationManager.AppSettings["HexaDictionary"];
                if (string.IsNullOrEmpty(HexaConfigFile))
                {
                    MessageBox.Show("Unable to find HexaConfig");
                    Application.Exit();
                    //throw new Exception("Unable to find HexaConfig");
                }

                if (!System.IO.File.Exists(HexaConfigFile))
                {
                    MessageBox.Show("Unable to find Hexa Config File");
                    Application.Exit();
                }

                foreach (string strlineitem in System.IO.File.ReadLines(HexaConfigFile))
                {
                    try
                    {
                        if (string.IsNullOrEmpty(strlineitem) || string.IsNullOrWhiteSpace(strlineitem))
                        {
                            continue;
                        }
                        HexaInput hIN = new HexaInput();
                        hIN.Raw  = strlineitem;
                        hIN.Hexa = strlineitem.Split(",".ToCharArray())[0];
                        hIN.Name = strlineitem.Split(",".ToCharArray())[1];
                        hIN.PX   = strlineitem.Substring(0, strlineitem.Length - strlineitem.IndexOf(','));
                    }
                    catch { }
                }
            }
            catch (Exception imEx2)
            {
            }
        }
Example #2
0
        private void ReadHexaInputFromFile(string FileName)
        {
            string HexaSetName = "";

            HexaSetName = Path.GetFileName(FileName).Split("_".ToCharArray())[1];
            HexaSetName = HexaSetName.ToUpper().Replace(".HEX", "");
            //if (string.IsNullOrEmpty(FileName))
            //{
            //    MessageBox.Show("Given file is empty.");
            //    Logger.Log("Given file is empty.");
            //    //Application.Exit();
            //    //throw new Exception("Unable to find HexaConfig");
            //}

            //if (!System.IO.File.Exists(FileName))
            //{
            //    MessageBox.Show("Unable to find given Config file:" + FileName);
            //    Logger.Log("Unable to find given Config file:" + FileName);
            //    //Application.Exit(); //test
            //}

            List <HexaInput> hexList = new List <HexaInput>();

            foreach (string strlineitem in System.IO.File.ReadLines(FileName))
            {
                try
                {
                    if (string.IsNullOrEmpty(strlineitem) || string.IsNullOrWhiteSpace(strlineitem))
                    {
                        continue;
                    }
                    HexaInput hIN = new HexaInput();
                    hIN.Raw  = strlineitem;
                    hIN.Hexa = strlineitem.Split(",".ToCharArray())[0];
                    hIN.Name = strlineitem.Split(",".ToCharArray())[1];
                    hIN.PX   = strlineitem.Substring(0, strlineitem.Length - strlineitem.IndexOf(','));

                    hexList.Add(hIN);
                    //Metadata.InputDictionary.Add(hIN);
                }
                catch { }
            }
            if (hexList.Count > 0 && !Metadata.InputDictionaryCollection.ContainsKey(HexaSetName))
            {
                Metadata.InputDictionaryCollection.Add(HexaSetName, hexList);
                Logger.Log("Hex Set : " + HexaSetName + ", Count: " + hexList.Count + " added ");
            }
        }