Example #1
0
 private RegCoreClient(string regCoreSrv, IActivationDataStore src)
 {
     // fill activations
     _initActivations = src.GetActivations();
     _validActivations = new Dictionary<string, ILicenseActivation>();
     _src = src;
     _regCoreSrv = new RegCoreServer(regCoreSrv);
 }
        public void InitRegCore(bool isAdmin, string regCoreServer, string productName, string productCode, string productKey, string version, string regCoreManageUrl, Type controller)
        {
            _isAdmin = isAdmin;

            _RegCoreServer = new RegCoreServer(regCoreServer);
            _RegCoreApp = new RegCoreApp(productName, productCode, productKey, version);

            _unlockTrialUrl = regCoreManageUrl.TrimEnd('/') + "/UnlockTrial.aspx?t=" + HttpUtility.UrlEncode(controller.AssemblyQualifiedName) + "&rurl=" + HttpUtility.UrlEncode(Request.RawUrl);
            _activateUrl = regCoreManageUrl.TrimEnd('/') + "/Activation.aspx?t=" + HttpUtility.UrlEncode(controller.AssemblyQualifiedName) + "&rurl=" + HttpUtility.UrlEncode(Request.RawUrl);

            _RegCoreClient = (IRegCoreClient)controller.GetProperty("RegCore", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public).GetValue(null, null);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // try to load data
            string returnUrl = Request.QueryString["rurl"];
            if (string.IsNullOrEmpty(returnUrl))
                returnUrl = ResolveUrl("~/");

            string strDataType = Request.QueryString["t"];
            Type dataType = Type.GetType(strDataType);

            if (!(bool)dataType.GetProperty("IsAdmin", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public).GetValue(null, null)) {
                throw new Exception("Access denied!");
            }

            _RegCoreClient = (IRegCoreClient)dataType.GetProperty("RegCore", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public).GetValue(null, null);

            _RegCoreServer = new RegCoreServer((string)dataType.GetProperty("RegCoreServer", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public).GetValue(null, null));
            _RegCoreApp = new RegCoreApp();
            _RegCoreApp.FromController(dataType);

            // check activation
            if (Request.QueryString["_avta"] == "unlock-trial" && Request.QueryString["p"] == _RegCoreApp.ProductCode) {
                UnlockTrial1();
            }

            if (!Page.IsPostBack) {

                // determine which case is this
                //if (_RegCoreClient.IsActivated(_RegCoreApp.ProductCode, _RegCoreApp.Version, Request.Url.Host))
                //    Response.Redirect(Request.QueryString["rurl"]);

                if (_RegCoreClient.IsTrialExpired(_RegCoreApp.ProductCode, _RegCoreApp.Version, Request.Url.Host)) {
                    EnableTrialExpired();
                } else {
                    EnableFirstTime();
                }
            }
        }
        protected void Page_Init(Object Sender, EventArgs args)
        {
            try {
                string strDataType = Request.QueryString["t"];
                Type dataType = Type.GetType(strDataType);

                if (!(bool)dataType.GetProperty("IsAdmin", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public).GetValue(null, null)) {
                    throw new Exception("Access denied!");
                }

                _RegCoreClient = (IRegCoreClient)dataType.GetProperty("RegCore", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public).GetValue(null, null);

                _RegCoreServer = new RegCoreServer((string)dataType.GetProperty("RegCoreServer", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public).GetValue(null, null));
                _RegCoreApp = new RegCoreApp();
                _RegCoreApp.FromController(dataType);

                _hosts = (List<ListItem>)dataType.GetProperty("Hosts").GetValue(Activator.CreateInstance(dataType), null);

            } catch {
                // TODO: log this?
                try {
                    Response.Redirect(Request.QueryString["rurl"]);
                } catch {
                    Response.Redirect(ResolveUrl("~/"));
                }
                return;
            }

            //PortalSettings portalSettings = DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings();

            //// check that user has rights
            //if (!PortalSecurity.IsInRole(portalSettings.AdministratorRoleName)) {
            //    Response.Write("Access denied!");
            //    Response.End();
            //}
        }