//============================================================================*
        // GetLicenses()
        //============================================================================*

        protected void GetLicenses()
        {
            m_eErrorCode = eErrorCodes.None;

            cSQL SQL = new cSQL(Server, Database, UserID, Password);

            string strCommand = String.Format("SELECT * FROM Licenses WHERE ActivationKey = '{0}' AND Name = '{1}' AND Email = '{2}'", m_strKey, m_strName, m_strEmail);

            SqlDataReader Reader = SQL.ExecuteQuery(strCommand);

            if (Reader != null)
            {
                m_Page.Response.Write(String.Format("GetLicenses: {0:G}<br />\n", (int)cKeyCommand.eErrorCodes.None));

                while (Reader.Read())
                {
                    m_Page.Response.Write("License:<br />\n");
                    m_Page.Response.Write(String.Format("Key: {0}<br />\n", Reader["ActivationKey"].ToString()));
                    m_Page.Response.Write(String.Format("Name: {0}<br />\n", Reader["Name"].ToString()));
                    m_Page.Response.Write(String.Format("Email: {0}<br />\n", Reader["Email"].ToString()));
                    m_Page.Response.Write(String.Format("Computer: {0}<br />\n", Reader["Computer"].ToString()));
                    m_Page.Response.Write(String.Format("NIC: {0}<br />\n", Reader["NIC"].ToString()));
                }
            }
            else
            {
                m_Page.Response.Write(String.Format("AddLicense: Error {0:G} - {1}", SQL.ErrorCode, SQL.ErrorMessage));
            }

            SQL.Close();
        }
        //============================================================================*
        // ErrorString Property
        //============================================================================*

        public static string ErrorString(eErrorCodes eErrorCode)
        {
            switch (eErrorCode)
            {
            case eErrorCodes.None:
                return("Success");

            case eErrorCodes.NotConnected:
                return("Not Connected");

            case eErrorCodes.InvalidCommand:
                return("Invalid Command");

            case eErrorCodes.InvalidKey:
                return("Invalid Key");

            case eErrorCodes.InvalidResponse:
                return("Invalid Response");

            case eErrorCodes.MissingParameter:
                return("Missing Parameter");
            }

            return("Unknown Error");
        }
        //============================================================================*
        // ActivateKey()
        //============================================================================*

        protected void ActivateKey()
        {
            //----------------------------------------------------------------------------*
            // Get and verify the input data
            //----------------------------------------------------------------------------*

            if (!string.IsNullOrEmpty(m_Page.Request.QueryString["ActivationKey"]))
            {
                m_strKey = m_Page.Request.QueryString["ActivationKey"];
            }

            if (!string.IsNullOrEmpty(m_Page.Request.QueryString["UserName"]))
            {
                m_strName = m_Page.Request.QueryString["UserName"];
            }

            if (!string.IsNullOrEmpty(m_Page.Request.QueryString["Email"]))
            {
                m_strEmail = m_Page.Request.QueryString["Email"];
            }

            //----------------------------------------------------------------------------*
            // If any data is missing, set the error code
            //----------------------------------------------------------------------------*

            if (string.IsNullOrEmpty(m_strKey) ||
                string.IsNullOrEmpty(m_strName) ||
                string.IsNullOrEmpty(m_strEmail))
            {
                m_eErrorCode = eErrorCodes.MissingParameter;

                return;
            }
        }
        //============================================================================*
        // AddLicense()
        //============================================================================*

        protected void AddLicense()
        {
            m_eErrorCode = eErrorCodes.None;

            cSQL SQL = new cSQL(Server, Database, UserID, Password);

            string strCommand = String.Format("INSERT INTO Licenses (ActivationKey, Name, Email) VALUES ('{0}', '{1}', '{2}')", m_strKey, m_strName, m_strEmail);

            int nCount = SQL.ExecuteCommand(strCommand);

            m_Page.Response.Write(String.Format("AddLicense: {0:G}\n", SQL.ErrorCode));
        }
Beispiel #5
0
 private static void processErrorCode(string function, eErrorCodes errCode)
 {
     switch (errCode)
     {
         case eErrorCodes.Success: break;
         case eErrorCodes.NoAction: break;
         default:
             {
                 StringBuilder Message = new StringBuilder(function);
                 Message.Append(": ");
                 Message.Append(errCode.ToString());
                 print(Message.ToString());
                 throw new OL490DLLException(Message.ToString());
             }
     }
 }
        //============================================================================*
        // Execute()
        //============================================================================*

        public void Execute()
        {
            //----------------------------------------------------------------------------*
            // Get and verify the input data
            //----------------------------------------------------------------------------*

            if (!string.IsNullOrEmpty(m_Page.Request.QueryString["Command"]))
            {
                m_strCommand = m_Page.Request.QueryString["Command"];
            }

            if (!string.IsNullOrEmpty(m_Page.Request.QueryString["Key"]))
            {
                m_strKey = m_Page.Request.QueryString["Key"];
            }

            if (!string.IsNullOrEmpty(m_Page.Request.QueryString["Name"]))
            {
                m_strName = m_Page.Request.QueryString["Name"];
            }

            if (!string.IsNullOrEmpty(m_Page.Request.QueryString["Email"]))
            {
                m_strEmail = m_Page.Request.QueryString["Email"];
            }

            if (!string.IsNullOrEmpty(m_Page.Request.QueryString["ComputerName"]))
            {
                m_strComputerName = m_Page.Request.QueryString["ComputerName"];
            }

            if (!string.IsNullOrEmpty(m_Page.Request.QueryString["NIC"]))
            {
                m_strNIC = m_Page.Request.QueryString["NIC"];
            }

            //----------------------------------------------------------------------------*
            // If any data is missing, set the error code
            //----------------------------------------------------------------------------*

            m_eErrorCode = eErrorCodes.None;

            if (string.IsNullOrEmpty(m_strKey) ||
                string.IsNullOrEmpty(m_strName) ||
                string.IsNullOrEmpty(m_strEmail) ||
                string.IsNullOrEmpty(m_strCommand))
            {
                m_eErrorCode = eErrorCodes.MissingParameter;

                return;
            }

            //----------------------------------------------------------------------------*
            // Execute the Command
            //----------------------------------------------------------------------------*

            switch (Command)
            {
            case eCommands.Activate:
                ActivateKey();
                break;

            case eCommands.AddLicense:
                AddLicense();
                break;

            case eCommands.GetLicenses:
                GetLicenses();
                break;

            case eCommands.ValidateLicense:
                ValidateLicense();
                break;

            default:
                m_eErrorCode = eErrorCodes.InvalidCommand;
                break;
            }
        }
        //============================================================================*
        // ValidateLicense()
        //============================================================================*

        protected void ValidateLicense()
        {
            m_eErrorCode = eErrorCodes.InvalidKey;
        }