Exemple #1
0
        public Form1()
        {
            InitializeComponent();
            tabArea     = tabControl1.GetTabRect(0);
            tabTextArea = (RectangleF)tabControl1.GetTabRect(0);
            logger_     = new Logger(richTextBox, "mvMAQLClient.log", "mvMAQLClient");
            Trace.Listeners.Add(logger_);
            cfg_ = new ConfigHandling();
            exc_ = new SpreadsheetHandling(cfg_);

            if (cfg_.DatabaseProvider() != string.Empty)
            {
                if (cfg_.DatabaseProvider() == "oracle")
                {
                    sqldata_ = new mvOSQLDataHandling(cfg_.DatabaseName(), cfg_.ConnectionString());
                }
                else
                {
                    throw new SystemException("No valid database provider found in config.xml");
                }
            }
            else
            {
                throw new SystemException("Couldn't determine database provider from config.xml");
            }

            string[] sTypes = cfg_.GetAllTypes();
            for (int i = 0; i < sTypes.Length; i++)
            {
                comboBoxType.Items.Add(sTypes[i]);
            }
            comboBoxType.SelectedIndex = 0;
            textBoxInsertLicense.Text  = @"C:\Users\matrix\halcon\mvBlueGEMINI\old\license_000c8d000cf1.dat";
            textBoxMACLicenseFile.Text = "00:0C:8D:00:0C:F1";
        }
Exemple #2
0
        /// <summary>
        /// Check existing data in SQL table.
        /// </summary>
        /// <param name="data">The string value to check for.</param>
        /// <returns>Returns TRUE if data already exists.</returns>
        private bool CheckExistingData(string data)
        {
            ConfigHandling cfg_ = new ConfigHandling();

            string[] sTypes  = cfg_.GetAllTypes();
            string   sCmdSub = string.Empty;
            bool     result  = false;

            if (data.Contains(" "))
            {
                Trace.WriteLine(string.Format("Whitespace are not allowed ({0})", data), "ERROR");
                return(true);
            }

            if (sTypes.Length > 0)
            {
                for (int i = 0; i < sTypes.Length; i++)
                {
                    sCmdSub += string.Format(" OR {0}='{1}'", sTypes[i], data);
                }
            }

            string sCmd = string.Format("SELECT * FROM {0} WHERE Serialnumber='{1}'{2}", tablename_, data, sCmdSub);

            try
            {
                MySqlCommand sqlcmd = new MySqlCommand(sCmd, sqlcon_);
                sqlcon_.Open();
                MySqlDataReader reader = sqlcmd.ExecuteReader();
                while (reader.Read())
                {
                    string tmp = null;
                    if (reader.FieldCount > 0)
                    {
                        for (int i = 0; i < reader.FieldCount; i++)
                        {
                            if (reader.GetDataTypeName(i).Equals("VARCHAR"))
                            {
                                tmp += reader[i].ToString() + " - ";
                            }
                        }
                    }
                    Trace.WriteLine(String.Format("Found in table: {0}", tmp));
                    result = true;
                }
            }
            catch (SystemException ex)
            {
                Trace.WriteLine(string.Format("{0}(): {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message), "ERROR");
            }

            sqlcon_.Close();
            return(result);
        }
Exemple #3
0
        private string checkLicenseDir(string folderName)
        {
            string result    = string.Empty;
            Char   delimiter = '\\';

            if (string.IsNullOrEmpty(folderName))
            {
                return(result);
            }

            string[] sDirs = folderName.Split(delimiter);

            string[] types = cfg_.GetAllTypes();
            for (int i = 0; i < types.Length; i++)
            {
                if (types[i] == sDirs[sDirs.Length - 1])
                {
                    result = types[i];
                    break;
                }
            }
            return(result);
        }