protected void Page_Load(System.Object sender, System.EventArgs e)
        {
            try
            {
                #region Get parameter and registration
                //Get Reg ID
                if (this.Request.QueryString["RegID"] != null) //if none, then _regID = -1
                {
                    _regID = Int32.Parse(this.Request.QueryString["RegID"]);
                    RegistrationProductController ctrl = new RegistrationProductController();
                    _regProduct = ctrl.Get(_regID, ModuleId);
                }

                if (this.Request.QueryString["Message"] != null)
                {
                    DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, this.Request.QueryString["Message"].ToString(), DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.YellowWarning);
                }

                if (this.Request.QueryString["Success"] != null)
                {
                    DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, this.Request.QueryString["Success"].ToString(), DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.GreenSuccess);
                }

                //get if current user can edit module
                _currentUserHasEdit = DotNetNuke.Security.Permissions.ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Edit, "EDIT", ModuleConfiguration);
                #endregion

                #region Return if not allowed to see registration
                if (_regProduct != null)
                {
                    //registration found
                    //verify it belongs to current user or current user
                    //Has edit permission
                    if (_regProduct.UserID != UserId && !_currentUserHasEdit)
                    {
                        //todo add log and email notification
                        Response.Redirect(Globals.NavigateURL());
                    }
                    _registrationKeysUsed = _regProduct.KeysUsed();
                }

                #endregion

                this.lbnAddHostName.Attributes.Add("onClick", "javascript:return confirm('Are you sure this is the correct site alias?  Once the key has been generated, site alias can not be changed.');");

                //new reg
                if (_regID == -1)
                {
                    labelKeysRemaining.Visible = false;
                    lblKeysRemaining.Visible = false;
                    lblAddHostName.Visible = false;
                    txtAddHostName.Visible = false;
                    lbnAddHostName.Visible = false;

                    string strProducts = Settings["ProductNames"].ToString();
                    List<string> products = strProducts.Split(';').ToList<string>();
                    if (products.Count > 1)
                    {
                        ddlProductNames.Visible = true;
                        if (!Page.IsPostBack)
                        {
                            ddlProductNames.DataSource = products;
                            ddlProductNames.DataBind();
                        }
                    }
                    else
                    {
                        lblProduct.Text = products[0];
                    }

                    lbnDelete.Visible = false;
                    lbnOK.Text = "Next >";
                }
                //existing reg product
                else
                {
                    //update form
                    ddlProductNames.Visible = false;
                    lblProduct.Text = _regProduct.ProductName;
                    HasKeysAvailable();
                    txtOrderNumber.Visible = false;
                    lblOrderNumber.Text = _regProduct.OrderNumber;
                    lbnCancel.Visible = false;
                    lbnOK.Text = "Close";
                    BindKeys();

                    //current user is module editor
                    if (_currentUserHasEdit)
                    {
                        lbnUpdateTotal.Visible = true;
                        txtNewTotal.Visible = true;
                        lblUpdateKeys.Visible = true;
                        chkApproved.Visible = true;
                        lblApproved.Visible = true;
                        chkApproved.Checked = _regProduct.Approved;
                        if (_regProduct.Approved)
                        {
                            lbnApprove.Visible = false;
                        }
                        else
                        {
                            lbnApprove.Visible = true;
                        }
                    }
                    //current user is customer for existing registration
                    else
                    {

                    }

                    //allow delete for existing prod if no reg keys
                    if (_registrationKeysUsed == 0)
                    {
                        lbnDelete.Visible = true;
                    }
                    else
                    {
                        lbnDelete.Visible = false;
                    }
                }

            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
示例#2
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);
            }
        }
        protected void lbnDelete_Click(object sender, EventArgs e)
        {
            RegistrationProductController ctrlReg = new RegistrationProductController();
            RegistrationProduct regProd = ctrlReg.Get(_regID, ModuleId);
            ctrlReg.Delete(regProd);

            Response.Redirect(Globals.NavigateURL());
        }
        protected void gridRegistrations_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                string strID = DataBinder.Eval(e.Row.DataItem, "ID").ToString();
                HyperLink link = (HyperLink)e.Row.Cells[0].Controls[0];
                link.NavigateUrl = EditUrl("RegID", strID);

                RegistrationProductController ctrlReg = new RegistrationProductController();
                RegistrationProduct prod = ctrlReg.Get(Int32.Parse(strID), ModuleId);

                e.Row.Cells[4].Text = String.Format("{0} of {1}", prod.KeysUsed(), prod.TotalKeysText());
            }
            catch { }
        }