示例#1
0
文件: Form1.cs 项目: krunix23/mvMAQL
        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";
        }
示例#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);
        }
示例#3
0
        public MAQLWorker(TextWriterTraceListener logger)
        {
            logger_         = logger as Logger;
            cfg_            = new ConfigHandling();
            sqldata_        = new mvOSQLDataHandling(cfg_.DatabaseName(), cfg_.ConnectionString());
            LicenseStoreDir = cfg_.LicenseStoreDir();

            if (System.Environment.OSVersion.Platform == PlatformID.Unix)
            {
                LinuxOS = true;
            }
        }
示例#4
0
 public SpreadsheetHandling(ConfigHandling cfgdoc)
 {
     cfgdoc_ = cfgdoc;
     lMACs_  = new List <string>();
     Trace.WriteLine("Created ConfigHandler");
 }