コード例 #1
0
        /// <summary>Shows the <see cref="LicensingGui"/> object's license management form.</summary>
        private void ManageLicense()
        {
            if (LicenseConfiguration.EncryptionKey.LastError.ErrorNumber != LicenseError.ERROR_NONE &&
                LicenseConfiguration.EncryptionKey.LastError.ErrorNumber != LicenseError.ERROR_PLUS_EVALUATION_WARNING)
            {
                m_License.LastError = LicenseConfiguration.EncryptionKey.LastError;
            }
            else if (SampleLicense.IsClockBackdatedAtRuntime(m_LastLicenseValidationTime))
            {
                m_LastLicenseValidationResult = false;
                m_License.LastError           = new LicenseError(LicenseError.ERROR_SYSTEM_TIME_INVALID);
            }
            else if (m_License.LastError.ErrorNumber != LicenseError.ERROR_COULD_NOT_LOAD_LICENSE)
            {
                m_LastLicenseValidationResult = m_License.Validate();
                m_LastLicenseValidationTime   = DateTime.UtcNow;
                statusLabel.Text = "Status: " + m_License.LastError.ErrorString;
            }

            this.criticalFeatureButton.Enabled = UpdateLicenseStatus();

            sampleLicensingGui.ShowDialog(LicensingGuiDialog.LicenseManagement, this, FormStartPosition.CenterParent);

            //Update the status
            this.criticalFeatureButton.Enabled = UpdateLicenseStatus();
        }
コード例 #2
0
        /// <summary>Performs post-processing updates for actions performed through the <see cref="LicensingGui"/>.</summary>
        /// <remarks><para>This method is called by the <see cref="LicensingGui.LicenseManagementActionComplete"/> event handler method.  In the
        /// sample application form source code (i.e. MainForm.cs), this method is similarly named PostProcessingUpdates.  This might be named
        /// something like licensingGui1_LicenseManagementActionComplete in your application.</para></remarks>
        /// <param name="lic">The <see cref="License"/> being processed.</param>
        /// <param name="licGui">The <see cref="LicensingGui"/> used to process updates for the license.</param>
        /// <param name="e">The post-processing event arguments returned from the <see cref="LicensingGui"/> object.</param>
        /// <param name="newValidationSuccessful">Whether or not validation after processing updates has passed successfully.</param>
        internal static void PostProcessingUpdates(ref SampleLicense lic, ref LicensingGui licGui, ref LicenseManagementActionCompleteEventArgs e, out bool newValidationSuccessful)
        {
            //If an action was processed, run some post-processing actions.
            if (LicenseManagementActionTypes.ManualTriggerCode == e.ActionType)
            {
                //A trigger code needs to be processed...
                if (!lic.ProcessTriggerCode(e.LicenseID, e.Password, e.TriggerCodeNumber, e.TriggerCodeEventData))
                {
                    //If trigger code processing failed, show the error in the license management dialog.
                    e.PostProcessingSuccessful = false;
                    e.LastError = lic.LastError;
                }

                //Reload and revalidate the license file.
                if (lic.LoadFile(LicenseConfiguration.LicenseFilePath))
                {
                    newValidationSuccessful = lic.Validate();
                }
                else
                {
                    newValidationSuccessful = false;
                }
            }
            else if (LicenseError.ERROR_WEBSERVICE_RETURNED_FAILURE == e.LastError.ErrorNumber)
            {
                //The last action failed because the license is no longer valid in SOLO Server, so remove the license from the system.
                if (ShouldLicenseBeRevoked(lic.LastError.ExtendedErrorNumber))
                {
                    RevokeLicense(ref lic, ref licGui);
                    newValidationSuccessful = false;
                }
                else
                {
                    //The web service returned an error, which should be disabled to the user.
                    e.PostProcessingSuccessful = false;
                    e.LastError = lic.LastError;
                }
            }
            else if (LicenseManagementActionTypes.OnlineDeactivation == e.ActionType ||
                     LicenseManagementActionTypes.ManualDeactivation == e.ActionType)
            {
                RevokeLicense(ref lic, ref licGui);
                newValidationSuccessful = false;
                return;
            }
            else if (e.ProcessedSuccessfully &&
                     (LicenseManagementActionTypes.OnlineActivation == e.ActionType ||
                      LicenseManagementActionTypes.OnlineRefresh == e.ActionType ||
                      LicenseManagementActionTypes.ManualActivation == e.ActionType ||
                      LicenseManagementActionTypes.ManualRefresh == e.ActionType))
            {
                //This was a successful activation or license refresh attempt, which means we have a new license to process.
                lic.ProcessNewLicense(ref e, out newValidationSuccessful);
            }

            newValidationSuccessful = lic.Validate();
        }
コード例 #3
0
        /// <summary>Shows the <see cref="LicensingGui"/> object's license management form.</summary>
        private void ManageLicense()
        {
            if (LicenseConfiguration.EncryptionKey.LastError.ErrorNumber != LicenseError.ERROR_NONE &&
                LicenseConfiguration.EncryptionKey.LastError.ErrorNumber != LicenseError.ERROR_PLUS_EVALUATION_WARNING)
            {
                m_License.LastError = LicenseConfiguration.EncryptionKey.LastError;
            }
            else if (SampleLicense.IsClockBackdatedAtRuntime(m_LastLicenseValidationTime))
            {
                //It looks like our system clock was back-dated while the application was running.
                m_LastLicenseValidationResult = false;
                m_License.LastError           = new LicenseError(LicenseError.ERROR_SYSTEM_TIME_INVALID);
            }
            else if (m_License.LastError.ErrorNumber != LicenseError.ERROR_COULD_NOT_LOAD_LICENSE)
            {
                //If the license was loaded, validate it.
                m_LastLicenseValidationResult = m_License.Validate();
                m_LastLicenseValidationTime   = DateTime.UtcNow;
            }

            //Update the license status on the form.
            UpdateLicenseStatus();

            //Show the license management dialog.
            sampleLicensingGui.ShowDialog(LicensingGuiDialog.LicenseManagement, this, FormStartPosition.CenterParent);
        }
コード例 #4
0
        /// <summary>Refreshes the license status on the main form</summary>
        /// <returns>bool</returns>
        public bool RefreshLicenseStatus()
        {
            if (!m_CurrentLicense.IsEvaluation)
            {
                mnuRefreshLicense.Enabled = true;
            }
            else
            {
                mnuRefreshLicense.Enabled = false;
            }

            m_IsLicenseValid = m_CurrentLicense.Validate();
            if (!m_IsLicenseValid)
            {
                mnuRefreshLicense.Enabled = false;
                UpdateLicenseStatusProperty();
                return(false);
            }

            if (m_CurrentLicense.IsEvaluation)
            {
                mnuRefreshLicense.Enabled = false;
                TimeSpan ts = m_CurrentLicense.EffectiveEndDate.ToLocalTime() - DateTime.Now.Date;
                LicenseStatus = "Evaluation expires in " + Math.Round(ts.TotalDays, 0).ToString() + " days.";
                return(false);
            }
            else
            {
                mnuRefreshLicense.Enabled = true;
                LicenseStatus             = "Fully Licensed.";
            }

            return(true);
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: pklompPCCA/Windows.Forms
        /// <summary>Refreshes the license status on the main form</summary>
        internal void RefreshLicenseStatus()
        {
            refreshLicenseButton.Enabled = (m_License.InstallationID.Length > 0);
            if (!m_License.Validate())
            {
                statusTextLabel.Text = "The license is invalid or expired.";
                return;
            }

            StringBuilder registerInfo = new StringBuilder();

            //Check if first name is not empty and not unregistered
            if (m_License.Customer.FirstName != "" && m_License.Customer.FirstName != "UNREGISTERED")
            {
                registerInfo.Append("Registered To: ");

                //Append first name
                registerInfo.Append(m_License.Customer.FirstName);
            }

            //Check if last name is not empty and not unregistered
            if (m_License.Customer.LastName != "" && m_License.Customer.LastName != "UNREGISTERED")
            {
                if (registerInfo.ToString() == "")
                {
                    registerInfo.Append("Registered To:");
                }
                registerInfo.Append(" ");

                //Append last name
                registerInfo.Append(m_License.Customer.LastName);
            }

            //Check if company name is not empty and not unregistered
            if (m_License.Customer.CompanyName != "" && m_License.Customer.CompanyName != "UNREGISTERED")
            {
                if (registerInfo.ToString() == "")
                {
                    registerInfo.Append("Registered To:");
                }
                registerInfo.Append(" ");

                //Append company name
                registerInfo.Append("[" + m_License.Customer.CompanyName + "]");
            }

            if (registerInfo.ToString() != "")
            {
                registerInfo.Append(Environment.NewLine);
            }

            //Append license ID
            registerInfo.Append("License ID: " + m_License.LicenseID);

            statusTextLabel.Text = "Fully Licensed. " + Environment.NewLine +
                                   registerInfo.ToString();
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: pklompPCCA/Windows.Forms
        /// <summary>Refreshes the license status on the main form</summary>
        public bool RefreshLicenseStatus()
        {
            mnuRefreshLicense.Enabled = (m_License.InstallationID.Length > 0);
            m_IsLicenseValid          = m_License.Validate();
            if (!m_IsLicenseValid)
            {
                UpdateLicenseStatusProperty();
                return(false);
            }

            LicenseStatus = "Fully Licensed.";
            return(true);
        }
コード例 #7
0
ファイル: MainForm.cs プロジェクト: pklompPCCA/Windows.Forms
        /// <summary>Refreshes the license status on the main form</summary>
        /// <returns>bool</returns>
        public bool RefreshLicenseStatus()
        {
            if (!m_License.IsEvaluation)
            {
                mnuRefreshLicense.Enabled = true;
            }
            else
            {
                mnuRefreshLicense.Enabled = false;
            }

            m_IsLicenseValid = m_License.Validate();

            //If license is trial and valid license, initializes trial features
            if (m_License.IsEvaluation && m_IsLicenseValid)
            {
                SplashScreen.InitializeTrialFeatures(m_Features, m_License);
            }
            else
            {
                SplashScreen.InitializeFeatures(m_Features, m_License, m_IsLicenseValid);
            }
            ToggleFeatures();

            if (!m_IsLicenseValid)
            {
                mnuRefreshLicense.Enabled = false;
                UpdateLicenseStatusProperty();
                return(false);
            }

            if (m_License.IsEvaluation)
            {
                mnuRefreshLicense.Enabled = false;
                TimeSpan ts = m_License.EffectiveEndDate.ToLocalTime() - DateTime.Now.Date;
                LicenseStatus = "Evaluation expires in " + Math.Round(ts.TotalDays, 0).ToString() + " days.";
                return(false);
            }
            else
            {
                mnuRefreshLicense.Enabled = true;
                LicenseStatus             = "Fully Licensed.";
            }

            return(true);
        }
コード例 #8
0
        /// <summary>Refreshes the license status on the main form</summary>
        internal void RefreshLicenseStatus()
        {
            if (!m_License.IsEvaluation)
            {
                refreshLicenseButton.Enabled = true;
                deactivateButton.Enabled     = true;
            }
            else
            {
                refreshLicenseButton.Enabled = false;
                deactivateButton.Enabled     = false;
            }

            m_isLicenseValid = m_License.Validate();
            if (!m_isLicenseValid)
            {
                statusTextLabel.Text = "The license is invalid or expired.";
                return;
            }

            if (m_License.IsEvaluation)
            {
                refreshLicenseButton.Enabled = false;
                deactivateButton.Enabled     = false;
                TimeSpan ts = m_License.EffectiveEndDate - DateTime.Now.Date;
                statusTextLabel.Text = "Trial expires in " + Math.Round(ts.TotalDays, 0).ToString() + " days.";
            }
            else
            {
                refreshLicenseButton.Enabled = true;
                deactivateButton.Enabled     = true;
                StringBuilder registerInfo = new StringBuilder();

                //Check if first name is not empty and not unregistered
                if (m_License.Customer.FirstName != "" && m_License.Customer.FirstName != "UNREGISTERED")
                {
                    registerInfo.Append("Registered To: ");

                    //Append first name
                    registerInfo.Append(m_License.Customer.FirstName);
                }

                //Check if last name is not empty and not unregistered
                if (m_License.Customer.LastName != "" && m_License.Customer.LastName != "UNREGISTERED")
                {
                    if (registerInfo.ToString() == "")
                    {
                        registerInfo.Append("Registered To:");
                    }
                    registerInfo.Append(" ");

                    //Append last name
                    registerInfo.Append(m_License.Customer.LastName);
                }

                //Check if company name is not empty and not unregistered
                if (m_License.Customer.CompanyName != "" && m_License.Customer.CompanyName != "UNREGISTERED")
                {
                    if (registerInfo.ToString() == "")
                    {
                        registerInfo.Append("Registered To:");
                    }
                    registerInfo.Append(" ");

                    //Append company name
                    registerInfo.Append("[" + m_License.Customer.CompanyName + "]");
                }

                if (registerInfo.ToString() != "")
                {
                    registerInfo.Append(Environment.NewLine);
                }

                //Append license ID
                registerInfo.Append("License ID: " + m_License.LicenseID);

                statusTextLabel.Text = "Fully Licensed." + Environment.NewLine +
                                       registerInfo.ToString();
            }
        }
コード例 #9
0
        /// <summary>Refreshes the license status on the main form</summary>
        public void RefreshLicenseStatus()
        {
            refreshLicenseButton.Enabled = (m_License.InstallationID.Length > 0);

            if (!m_License.Validate())
            {
                if (m_Semaphore != null)
                {
                    m_Semaphore.Close(); // close our network session if it is open
                    m_Semaphore = null;
                }

                statusTextLabel.Text = "The license is invalid or expired.";
                userCountLabel.Text  = "N/A";
            }
            else
            {
                if (m_Semaphore == null)
                {
                    m_Semaphore          = new NetworkSemaphore(Path.GetDirectoryName(LicenseConfiguration.LicenseFilePath), LicenseConfiguration.NetworkSemaphorePrefix, m_License.LicenseCounter, true, 15, true);
                    m_Semaphore.Invalid += new NetworkSemaphore.InvalidEventHandler(InvalidSemaphoreHandler);

                    if (!m_Semaphore.Open() && m_Semaphore.LastError.ErrorNumber == LicenseError.ERROR_NETWORK_LICENSE_FULL) // try to open a network session
                    {
                        NetworkLicenseSearchForm searchDlg = new NetworkLicenseSearchForm(m_Semaphore);                      // try to search for an open network seat

                        if (searchDlg.ShowDialog() != DialogResult.OK)
                        {
                            statusTextLabel.Text = "Unable to establish a network session. " + m_Semaphore.LastError;
                            userCountLabel.Text  = "N/A";
                            m_Semaphore          = null;
                        }
                    }
                    else if (m_Semaphore.LastError.ErrorNumber != LicenseError.ERROR_NONE)
                    {
                        statusTextLabel.Text = "Unable to establish a network session. " + m_Semaphore.LastError;
                        userCountLabel.Text  = "N/A";
                        m_Semaphore          = null;
                    }
                }

                if (m_Semaphore != null && m_Semaphore.IsValid)
                {
                    StringBuilder registerInfo = new StringBuilder();

                    //Check if first name is not empty and not unregistered
                    if (m_License.Customer.FirstName != "" && m_License.Customer.FirstName != "UNREGISTERED")
                    {
                        registerInfo.Append("Registered To: ");

                        //Append first name
                        registerInfo.Append(m_License.Customer.FirstName);
                    }

                    //Check if last name is not empty and not unregistered
                    if (m_License.Customer.LastName != "" && m_License.Customer.LastName != "UNREGISTERED")
                    {
                        if (registerInfo.ToString() == "")
                        {
                            registerInfo.Append("Registered To:");
                        }
                        registerInfo.Append(" ");

                        //Append last name
                        registerInfo.Append(m_License.Customer.LastName);
                    }

                    //Check if company name is not empty and not unregistered
                    if (m_License.Customer.CompanyName != "" && m_License.Customer.CompanyName != "UNREGISTERED")
                    {
                        if (registerInfo.ToString() == "")
                        {
                            registerInfo.Append("Registered To:");
                        }
                        registerInfo.Append(" ");

                        //Append company name
                        registerInfo.Append("[" + m_License.Customer.CompanyName + "]");
                    }

                    if (registerInfo.ToString() != "")
                    {
                        registerInfo.Append(Environment.NewLine);
                    }

                    //Append license ID
                    registerInfo.Append("License ID: " + m_License.LicenseID);

                    statusTextLabel.Text = "Fully Licensed." + Environment.NewLine +
                                           registerInfo.ToString();

                    userCountLabel.Text = m_Semaphore.SeatsActive.ToString() + " out of " + m_License.LicenseCounter.ToString(); // display how many network users are running the application
                }
            }
        }