Exemplo n.º 1
0
    public void Awake()
    {
        if (!created)
        {
            DontDestroyOnLoad(this.gameObject);
            created = true;
        }
        else
        {
            Destroy(this.gameObject);
        }

        if (userMacAddress == "" || userMacAddress == null)
        {
            userMacAddress = LicenceManager.GetMacAddress();
            //Debug.Log("MAC Adress: " + LicenceManager.GetMacAddress());
        }

        if (productID == "" || productID == null)
        {
            productID = LicenceManager.Encrypt(userMacAddress);
            //Debug.Log("Product ID: " + productID);
        }

        //SaveData();

        LoadData();
    }
Exemplo n.º 2
0
 private void GetRegistrationDetails()
 {
     try
     {
         string licpathFolder = ConfigurationManager.AppSettings["licFolder"];
         if (string.IsNullOrEmpty(newPath))
         {
             LicPath(licpathFolder);
         }
         Stream          stream         = File.Open(newPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
         BinaryFormatter bformatter     = new BinaryFormatter();
         LicenceManager  licenceManager = (LicenceManager)bformatter.Deserialize(stream);
         if (licenceManager != null)
         {
             LblClientCode.Text         = licenceManager.ClientCode;
             LblInstallationDate.Text   = licenceManager.InstallationDate;
             LblTrialDays.Text          = licenceManager.TrialDays + " Days";
             LblRegisteredLicences.Text = licenceManager.RegisteredLicences.ToString();
             LblSerialKeys.Text         = licenceManager.SerialKey;
             LblTrialLicences.Text      = licenceManager.TrialLicences.ToString();
             LblNotes.Text = licenceManager.Notes;
         }
         stream.Close();
         stream.Dispose();
     }
     catch (Exception ex)
     {
         Response.Write(ex.Message);
     }
 }
Exemplo n.º 3
0
 private void btnLicence_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtLicence.Text != "")
         {
             LicenceManager licMG = new LicenceManager();
             Lic            lic   = licMG.GetAll().FirstOrDefault(l => l.Lic1 == txtLicence.Text);
             if (lic != null)
             {
                 File.Create(@"C:\Windows\lic.txt");
                 licMG.Delete(lic);
                 Users.FRM_Login login = new  Users.FRM_Login();
                 this.Hide();
                 login.ShowDialog();
                 Application.Exit();
             }
             else
             {
                 MessageBox.Show("عفواّ رقم الترخيص غير صحيح");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        public DownloadWindow(LicenceManager licenceManager, DownloaderService downloaderService)
        {
            InitializeComponent();

            var cancellationToken = new CancellationToken();

            this.licenceManager = licenceManager;
            downloader          = downloaderService;

            Task.Factory.StartNew(() => StartListeningToDownloadChannel(downloader.GetChannelReader(), cancellationToken));

            DisplayInstalledProducts();
        }
        /// <summary>
        /// Displays the registration details.
        /// </summary>
        /// <remarks>
        /// Sequence Diagram:<br/>
        ///     <img src="SequenceDiagrams/SD_PrintRoverWeb.Administration.ApplicationRegistration.DisplayRegistrationDetails.jpg"/>
        /// </remarks>
        private void DisplayRegistrationDetails()
        {
            try
            {
                string licpathFolder = ConfigurationManager.AppSettings["licFolder"];
                if (string.IsNullOrEmpty(newPath))
                {
                    LicPath(licpathFolder);
                }
                Stream          stream         = File.Open(newPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
                BinaryFormatter bformatter     = new BinaryFormatter();
                LicenceManager  licenceManager = (LicenceManager)bformatter.Deserialize(stream);
                if (!string.IsNullOrEmpty(licenceManager.ActivationKey))
                {
                    TableTrialdaysLeft.Visible    = false;
                    TableTrialLicenseText.Visible = false;
                }
                if (licenceManager != null)
                {
                    string trialDays     = string.Empty;
                    string trialLicences = string.Empty;
                    if (licenceManager.RegisteredLicences == 0)
                    {
                        trialDays     = licenceManager.TrialDays + " Days";
                        trialLicences = licenceManager.TrialLicences.ToString();
                    }
                    else
                    {
                        trialDays     = "-";
                        trialLicences = "-";
                    }
                    LabelInstallationDate.Text = licenceManager.InstallationDate;
                    LabelTrialDays.Text        = trialDays;

                    LabelRegisteredLicences.Text = licenceManager.RegisteredLicences.ToString();
                    LabelSerialKeys.Text         = licenceManager.LicenceID.ToString();
                    LabelTrialLicences.Text      = trialLicences;
                    LabelNotes.Text = licenceManager.Notes;
                }
                stream.Close();
                stream.Dispose();
            }
            catch (Exception ex)
            {
            }
        }
        /// <summary>
        /// Provides the registration info.
        /// </summary>
        /// <remarks>
        /// Sequence Diagram:<br/>
        ///     <img src="SequenceDiagrams/SD_PrintRoverWeb.Administration.ApplicationRegistration.ProvideRegistrationInfo.jpg"/>
        /// </remarks>
        private void ProvideRegistrationInfo()
        {
            try
            {
                //string licPath = Server.MapPath("~");
                //licPath = Path.Combine(licPath, "PR.Lic");
                string licpathFolder = ConfigurationManager.AppSettings["licFolder"];
                if (string.IsNullOrEmpty(newPath))
                {
                    LicPath(licpathFolder);
                }
                Stream          stream         = File.Open(newPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
                BinaryFormatter bformatter     = new BinaryFormatter();
                LicenceManager  licenceManager = (LicenceManager)bformatter.Deserialize(stream);
                string[]        requestCodes   = licenceManager.LicenceID.Split(",".ToCharArray());
                stream.Close();
                stream.Dispose();

                TextBoxRequestCode.Text = requestCodes[requestCodes.Length - 1];
            }
            catch (Exception ex)
            {
            }
        }
        /// <summary>
        /// Handles the Click event of the ButtonSave control.
        /// </summary>
        /// <param name="sender">Source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/>Instance containing the event data.</param>
        /// <remarks>
        /// Sequence Diagram:<br/>
        ///     <img src="SequenceDiagrams/SD_PrintRoverWeb.Administration.ApplicationRegistration.ButtonSave_Click.jpg"/>
        /// </remarks>
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                string requestCode  = TextBoxRequestCode.Text;
                string responseCode = TextBoxRegistartionCode.Text;

                if (!string.IsNullOrEmpty(responseCode))
                {
                    bool validLicense = DataManager.Provider.Registration.isValidLicsence(responseCode, requestCode);
                    if (validLicense)
                    {
                        int numberOfLicense = DataManager.Provider.Registration.ProvideNumberofLicense(responseCode);

                        string licpathFolder = ConfigurationManager.AppSettings["licFolder"];
                        if (string.IsNullOrEmpty(newPath))
                        {
                            LicPath(licpathFolder);
                        }
                        Stream          stream         = File.Open(newPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
                        BinaryFormatter bformatter     = new BinaryFormatter();
                        LicenceManager  licenceManager = (LicenceManager)bformatter.Deserialize(stream);
                        string[]        requestCodes   = licenceManager.LicenceID.Split(",".ToCharArray());

                        int    registeredLicences = Convert.ToInt32(numberOfLicense);
                        string activationKey      = "";

                        if (licenceManager.ActivationKey != null)
                        {
                            activationKey = licenceManager.ActivationKey.ToString();
                        }
                        string[] activationResponse = activationKey.Split(",".ToCharArray());

                        for (int i = 0; i < activationResponse.Length; i++)
                        {
                            if (activationResponse[i] == responseCode)
                            {
                                stream.Close();
                                stream.Dispose();
                                string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "RESPONSE_CODE_ALREADY_USED");
                                DisplayActionMessage(AppLibrary.MessageType.Warning.ToString(), serverMessage, null);
                                return;
                            }
                        }
                        // Generate New Request Code and update

                        licenceManager.LicenceID += "," + SystemInformation.GetRequestCode(requestCodes.Length + 1);

                        licenceManager.RegisteredLicences = registeredLicences;
                        licenceManager.ActivationKey     += "," + responseCode;
                        licenceManager.SerialKey         += " " + TextBoxRequestCode.Text;
                        licenceManager.Notes += "<br />" + registeredLicences.ToString() + " licence(s) registered on " + formateDate();

                        stream.Position = 0;
                        bformatter.Serialize(stream, licenceManager);
                        stream.Close();
                        stream.Dispose();

                        Session["IsValidLicence"] = "NO";     // This will recheck licence in InnerPage.master
                        string serverMessag = Localization.GetServerMessage("", Session["selectedCulture"] as string, "REG_COMPLETED");
                        MessageBox.Show(serverMessag);
                        ProvideRegistrationInfo();
                        DisplayRegistrationDetails();
                        TextBoxRegistartionCode.Text = "";
                        if (Request.Params["mc"] != "421")
                        {
                            Label lblTrial = Page.Master.FindControl("PageForm").FindControl("LblTrialMessage") as Label;
                            lblTrial.Visible = false;
                            return;
                        }
                    }
                    else
                    {
                        string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "INVALID_RESPONSE_CODE");
                        DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage, null);
                        return;
                    }
                }
                else
                {
                    string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "PLEASE_ENTER_RESPONSE_CODE");
                    DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage, null);
                }
            }
            catch (Exception)
            {
                string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "FAILED_TO_REGISTER");
                DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage, null);
            }
        }