Exemplo n.º 1
0
        private void buttonAssignSerialMACFree_Click(object sender, EventArgs e)
        {
            string sMac = sqldata_.FindUnusedMAC(comboBoxType.Text);

            if ((sMac != string.Empty) && (textBoxAssignSerialFreeMAC.Text != string.Empty))
            {
                sqldata_.UpdateMACWithSerial(comboBoxType.Text, sMac, textBoxAssignSerialFreeMAC.Text);
            }
            else
            {
                Trace.WriteLine(string.Format("Assign Serial={0} to free MAC failed!", textBoxAssignSerialFreeMAC.Text), "ERROR");
            }
        }
Exemplo n.º 2
0
        public Int32 FetchLicense()
        {
            Int32  result  = -1;
            string db_MAC0 = string.Empty;

            try
            {
                if (NeedsNewLicense == true)
                {
                    db_MAC0 = sqldata_.FindUnusedMAC(ColType);
                }
                else
                {
                    db_MAC0 = sqldata_.FindMAC(ColType, MAC0.ToUpper());
                }

                if (string.IsNullOrEmpty(db_MAC0))
                {
                    Trace.WriteLine("ERROR: Can't find requested MAC0 in database.");
                    return(result);
                }

                if (sqldata_.UpdateMACWithSerial(ColType, db_MAC0.ToUpper(), Serial) == true)
                {
                    result = StoreLicenseFile(ColType, db_MAC0);
                }
                else
                {
                    if (sqldata_.FindMACBySerial(ColType, Serial) == MAC0.ToUpper())
                    {
                        Trace.WriteLine(string.Format("{0} is already assinged to {1}", Serial, MAC0));
                        result = StoreLicenseFile(ColType, db_MAC0);
                    }
                    else
                    {
                        Trace.WriteLine(string.Format("ERROR: Did not fetch license file from db. Serialnumber already assigned to another MAC"));
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(string.Format("ERROR: Exception thrown - {0}", ex.Message));
            }

            return(result);
        }