protected void gridRegKeys_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                string strID = DataBinder.Eval(e.Row.DataItem, "ID").ToString();
                RegistrationKeyController ctrlKey = new RegistrationKeyController();
                RegistrationKey key = ctrlKey.Get(Int32.Parse(strID), _regID);

                //hide gen key if not module editor
                if (!_currentUserHasEdit)
                {
                    ((LinkButton)e.Row.Cells[3].Controls[0]).Visible = false;
                }

                //hide gen key and delete if exists already
                if (key.RegKey != null)
                {
                    ((LinkButton)e.Row.Cells[2].Controls[0]).Visible = false;
                    ((LinkButton)e.Row.Cells[3].Controls[0]).Visible = false;
                }
            }
            catch { }
        }
        protected void gridRegKeys_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            GridViewRow gvr = this.gridRegKeys.Rows[Convert.ToInt32(e.CommandArgument)];
            var hiddenID = gvr.FindControl("hiddenID") as HtmlInputHidden;
            RegistrationKeyController ctrlKey = new RegistrationKeyController();
            RegistrationKey key = ctrlKey.Get(Int32.Parse(hiddenID.Value), _regID);

            switch (e.CommandName)
            {
                case "Delete":
                    ctrlKey.Delete(key);
                    break;
                case "Select": //gen key
                    key.RegKey = ctrlKey.GenerateRegistrationKey(Settings["Seed"].ToString(), key, _regProduct);
                    ctrlKey.Update(key);

                    SendCustomerNotification(key.HostName, key.RegKey);

                    RegistrationProductController ctrlProd = new RegistrationProductController();
                    _regProduct.Status = "Keys Generated";
                    ctrlProd.Update(_regProduct);

                    Response.Redirect(EditUrl("RegID", _regID.ToString()));
                    break;
            }
        }
Beispiel #3
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void Page_Load(System.Object sender, System.EventArgs e)
        {
            try
            {
                //Get Reg ID
                if (this.Request.QueryString["RegKeyID"] != null) //if none, then _regID = -1
                {
                    _regKeyID = Int32.Parse(this.Request.QueryString["RegKeyID"]);
                }

                if (this.Request.QueryString["RegProdID"] != null) //if none, then _regID = -1
                {
                    _regProdID = Int32.Parse(this.Request.QueryString["RegProdID"]);
                }

                if (_regProdID == -1 || _regKeyID == -1)
                {
                    DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "No key ID or product ID provided", DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError);
                    return;
                }

                if (!Page.IsPostBack)
                {
                    RegistrationProductController ctrlProd = new RegistrationProductController();
                    RegistrationKeyController ctrlKey = new RegistrationKeyController();
                    UserController ctrlUser = new UserController();

                    _regKey = ctrlKey.Get(_regKeyID, _regProdID );
                    _regProduct = ctrlProd.Get(_regProdID, ModuleId);
                    _customer = ctrlUser.GetUser(PortalId, _regProduct.UserID);

                    if (_regKey == null || _regProduct == null || _customer == null)
                    {
                        DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "Product, Key, or Customer not found.", DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError);
                        return;
                    }

                    linkGoToList.NavigateUrl = Globals.NavigateURL();
                    linkGoToRegistration.NavigateUrl = Globals.NavigateURL("Edit", "RegID=" + _regProdID.ToString(), "mid=" + ModuleId.ToString());

                    if (_regKey.RegKey != null)
                    {
                        DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "A registration key has already been generated for the site.", DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError);
                        return;
                    }
                    else
                    {
                        _regKey.RegKey = ctrlKey.GenerateRegistrationKey(Settings["Seed"].ToString(), _regKey, _regProduct);
                        ctrlKey.Update(_regKey);

                        SendCustomerNotification(_regKey.HostName, _regKey.RegKey);

                        DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "Key generated for site.", DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.GreenSuccess);
                    }

                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }