/// <include file='doc\ProvideObjectAttribute.uex' path='docs/doc[@for="Register"]' />
        /// <devdoc>
        ///     Called to register this attribute with the given context.  The context
        ///     contains the location where the registration inforomation should be placed.
        ///     it also contains such as the type being registered, and path information.
        ///
        ///     This method is called both for registration and unregistration.  The difference is
        ///     that unregistering just uses a hive that reverses the changes applied to it.
        /// </devdoc>
        public override void Register(RegistrationContext context)
        {
            context.Log.WriteLine(string.Format(Resources.Culture, Resources.Reg_NotifyCreateObject, ObjectType.Name));

            using (Key childKey = context.CreateKey(CLSIDRegKey))
            {
                childKey.SetValue(string.Empty, ObjectType.FullName);
                childKey.SetValue("InprocServer32", context.InprocServerPath);
                childKey.SetValue("Class", ObjectType.FullName);

                // If specified on the command line, let the command line option override
                if (context.RegistrationMethod != RegistrationMethod.Default)
                {
                    registrationMethod = context.RegistrationMethod;
                }

                switch (registrationMethod)
                {
                case RegistrationMethod.Default:
                case RegistrationMethod.Assembly:
                    childKey.SetValue("Assembly", ObjectType.Assembly.FullName);
                    break;

                case RegistrationMethod.CodeBase:
                    childKey.SetValue("CodeBase", context.CodeBase);
                    break;
                }

                childKey.SetValue("ThreadingModel", "Both");
            }
        }
        public override void Register(RegistrationContext context)
        {
            using (Key key = context.CreateKey(ClsidRegKey))
            {
                key.SetValue(string.Empty, ObjectType.FullName);
                key.SetValue("InprocServer32", context.InprocServerPath);
                key.SetValue("Class", ObjectType.FullName);
                if (context.RegistrationMethod != RegistrationMethod.Default)
                {
                    _registrationMethod = context.RegistrationMethod;
                }

                switch (RegistrationMethod)
                {
                case Microsoft.VisualStudio.Shell.RegistrationMethod.Default:
                case Microsoft.VisualStudio.Shell.RegistrationMethod.Assembly:
                    key.SetValue("Assembly", ObjectType.Assembly.FullName);
                    break;

                case Microsoft.VisualStudio.Shell.RegistrationMethod.CodeBase:
                    key.SetValue("CodeBase", CodeBase);
                    break;

                default:
                    throw new InvalidOperationException();
                }

                key.SetValue("ThreadingModel", "Both");
            }
        }
Example #3
0
        public async Task <IActionResult> RequestPasswordReset([FromBody] string email)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(email))
                {
                    CoreFunc.Error(ref ErrorsList, "Email is required!");
                    return(StatusCode(412, ErrorsList));
                }

                User user = await _UserManager
                            .FindByEmailAsync(email).ConfigureAwait(false);

                if (user == null)
                {
                    CoreFunc.Error(ref ErrorsList, "Email not registered");
                    return(StatusCode(412, ErrorsList));
                }
                RegistrationMethod registrationMethod = await _DbContext.RegistrationMethods.FirstOrDefaultAsync(rm => rm.User.Id == user.Id).ConfigureAwait(false);

                if (registrationMethod.Type != RegistrationTypes.Application)
                {
                    CoreFunc.Error(ref ErrorsList, $"Your account is linked to your {registrationMethod.Type} account.");
                    return(StatusCode(412, ErrorsList));
                }

                if (user.LockoutEnabled)
                {
                    var currentLockoutDate =
                        await _UserManager.GetLockoutEndDateAsync(user).ConfigureAwait(false);

                    if (user.LockoutEnd > DateTimeOffset.UtcNow)
                    {
                        CoreFunc.Error(ref ErrorsList, string.Format("Account Locked for {0}"
                                                                     , CoreFunc.CompareWithCurrentTime(user.LockoutEnd)));
                        return(StatusCode(412, ErrorsList));
                    }
                    await _UserManager.SetLockoutEnabledAsync(user, false).ConfigureAwait(false);

                    await _UserManager.ResetAccessFailedCountAsync(user).ConfigureAwait(false);
                }

                Request.Headers.TryGetValue("Origin", out StringValues OriginValue);
                if (!await _EmailService.PasswordResetAsync(user, OriginValue).ConfigureAwait(false))
                {
                    CoreFunc.Error(ref ErrorsList, "Unable to send email.");
                    return(StatusCode(417, ErrorsList));
                }

                return(Created("", "Created"));
            }

            catch (Exception ex)
            {
                CoreFunc.Error(ref ErrorsList, _LoggingService.LogException(Request.Path, ex, User));
                return(StatusCode(417, ErrorsList));
            }
        }
        public async Task <IActionResult> ExternalLogin(ExternalLoginDetails externalLoginInfo)
        {
            try
            {
                IEnumerable <string> policies = AppFunc.GetCurrentRequestPolicies(Request, out AppTypes apptype);
                if (apptype == AppTypes.Invalid)
                {
                    CoreFunc.Error(ref ErrorsList, "Unauthorised Application Access. 🤔");
                    return(Unauthorized(ErrorsList));
                }

                if (!TryValidateModel(externalLoginInfo))
                {
                    CoreFunc.ExtractErrors(ModelState, ref ErrorsList);
                    return(UnprocessableEntity(ErrorsList));
                }

                User externalLoginUser = new User();
                switch (externalLoginInfo.Type)
                {
                case RegistrationTypes.Google:
                    externalLoginUser = await GetGoogleUserInfo(externalLoginInfo).ConfigureAwait(false);

                    break;

                case RegistrationTypes.Facebook:
                    externalLoginUser = await GetFacebookUserInfo(externalLoginInfo).ConfigureAwait(false);

                    break;
                }

                // Check if the user is already registered
                User registeredUser = await _DbContext.Users
                                      .Include(u => u.Role)
                                      .Include(u => u.RegistrationMethod)
                                      .SingleOrDefaultAsync(u => u.RegistrationMethod.Type == externalLoginInfo.Type &&
                                                            u.RegistrationMethod.ExternalLinkedId == externalLoginUser.RegistrationMethod.ExternalLinkedId)
                                      .ConfigureAwait(false);

                // if the user is already registered
                if (registeredUser != null)
                {
                    if (!await IsUserPolicyAccepted(registeredUser, policies).ConfigureAwait(false))
                    {
                        CoreFunc.Error(ref ErrorsList, "You do not have permission to login here.");
                        return(Unauthorized(ErrorsList));
                    }

                    // sign the user in without any password
                    await _SignInManager.SignInAsync(registeredUser, externalLoginInfo.RememberMe).ConfigureAwait(false);

                    return(Ok(registeredUser));
                }

                if (apptype == AppTypes.Admin)
                {
                    CoreFunc.Error(ref ErrorsList, "You do not have permission to login here. Please contact administrator.");
                    return(Unauthorized(ErrorsList));
                }
                /// check if the user is registered using other methods
                User user = await _UserManager
                            .FindByEmailAsync(externalLoginUser?.Email).ConfigureAwait(false);

                if (user != null)
                {
                    RegistrationMethod registrationMethod = await _DbContext.RegistrationMethods
                                                            .FirstOrDefaultAsync(r => r.User.Id == user.Id).ConfigureAwait(false);

                    if (registrationMethod.Type != RegistrationTypes.Application)
                    {
                        /// in the case any exceptions return the following error
                        CoreFunc.Error(ref ErrorsList, $"Please use {registrationMethod.Type} account to login.");
                    }
                    else
                    {
                        /// in the case any exceptions return the following error
                        CoreFunc.Error(ref ErrorsList, $"Please use Email and Password to login");
                    }
                    return(StatusCode(403, ErrorsList));
                }

                externalLoginUser.Role = await _DbContext.Roles.FirstOrDefaultAsync(r => r.Name == "Customer").ConfigureAwait(false);

                // else if the user is not registered but information is received from external login
                externalLoginUser.Id = -1;
                return(StatusCode(206, externalLoginUser));
            }
            catch (Exception ex)
            {
                CoreFunc.Error(ref ErrorsList, _LoggingService.LogException(Request.Path, ex, User));
                return(StatusCode(417, ErrorsList));
            }
        }
Example #5
0
        /// <devdoc>
        ///     Called to register this attribute with the given context.  The context
        ///     contains the location where the registration information should be placed.
        ///     it also contains such as the type being registered, and path information.
        ///
        ///     This method is called both for registration and unregistration.  The difference is
        ///     that unregistering just uses a hive that reverses the changes applied to it.
        /// </devdoc>
        /// <param name="context">
        ///     Contains the location where the registration information should be placed.
        ///     It also contains other information such as the type being registered
        ///     and path of the assembly.
        /// </param>
        public override void Register(RegistrationContext context)
        {
            Type t = context.ComponentType;

            Key packageKey = null;

            try
            {
                packageKey = context.CreateKey(RegKeyName(context));

                //use a friendly description if it exists.
                DescriptionAttribute attr =
                    TypeDescriptor.GetAttributes(t)[typeof(DescriptionAttribute)] as DescriptionAttribute;
                if (attr != null && !String.IsNullOrEmpty(attr.Description))
                {
                    packageKey.SetValue(string.Empty, attr.Description);
                }
                else
                {
                    packageKey.SetValue(string.Empty, t.Name);
                }

                packageKey.SetValue("InprocServer32", context.InprocServerPath);
                packageKey.SetValue("Class", t.FullName);

                // If specified on the command line, let the command line option override
                if (context.RegistrationMethod != RegistrationMethod.Default)
                {
                    registrationMethod = context.RegistrationMethod;
                }

                // Select registration method
                switch (registrationMethod)
                {
                case RegistrationMethod.Assembly:
                case RegistrationMethod.Default:
                    packageKey.SetValue("Assembly", t.Assembly.FullName);
                    break;

                case RegistrationMethod.CodeBase:
                    packageKey.SetValue("CodeBase", context.CodeBase);
                    break;
                }

                Key childKey = null;
                if (!useManagedResources)
                {
                    try
                    {
                        childKey = packageKey.CreateSubkey("SatelliteDll");

                        // Register the satellite dll
                        string satelliteDllPath;
                        if (SatellitePath != null)
                        {
                            // Use provided path
                            satelliteDllPath = context.EscapePath(SatellitePath);
                        }
                        else
                        {
                            // Default to package path
                            satelliteDllPath = context.ComponentPath;
                        }

                        childKey.SetValue("Path", satelliteDllPath);
                        childKey.SetValue("DllName",
                                          String.Format(CultureInfo.InvariantCulture, "{0}UI.dll",
                                                        Path.GetFileNameWithoutExtension(t.Assembly.ManifestModule.Name)));
                    }
                    finally
                    {
                        if (childKey != null)
                        {
                            childKey.Close();
                        }
                    }
                }

                if (allowsBackgroundLoad)
                {
                    packageKey.SetValue("AllowsBackgroundLoad", true);
                }

                if (typeof(IVsPackageDynamicToolOwner).IsAssignableFrom(context.ComponentType) ||
                    typeof(IVsPackageDynamicToolOwnerEx).IsAssignableFrom(context.ComponentType))
                {
                    packageKey.SetValue("SupportsDynamicToolOwner", true);
                }
            }
            finally
            {
                if (packageKey != null)
                {
                    packageKey.Close();
                }
            }
        }
Example #6
0
        /// <devdoc>
        ///     Called to register this attribute with the given context.  The context
        ///     contains the location where the registration inforomation should be placed.
        ///     it also contains such as the type being registered, and path information.
        ///
        ///     This method is called both for registration and unregistration.  The difference is
        ///     that unregistering just uses a hive that reverses the changes applied to it.
        /// </devdoc>
        /// <param name="context">
        ///     Contains the location where the registration inforomation should be placed.
        ///     It also contains other information such as the type being registered
        ///     and path of the assembly.
        /// </param>
        public override void Register(RegistrationContext context)
        {
            Type t = context.ComponentType;

            context.Log.WriteLine(SR.GetString(SR.Reg_NotifyPackage, t.Name, t.GUID.ToString("B")));

            Key packageKey = null;

            try
            {
                packageKey = context.CreateKey(RegKeyName(context));

                //use a friendly description if it exists.
                DescriptionAttribute attr = TypeDescriptor.GetAttributes(t)[typeof(DescriptionAttribute)] as DescriptionAttribute;
                if (attr != null && !String.IsNullOrEmpty(attr.Description))
                {
                    packageKey.SetValue(string.Empty, attr.Description);
                }
                else
                {
                    packageKey.SetValue(string.Empty, t.AssemblyQualifiedName);
                }

                packageKey.SetValue("InprocServer32", context.InprocServerPath);
                packageKey.SetValue("Class", t.FullName);

                // If specified on the command line, let the command line option override
                if (context.RegistrationMethod != RegistrationMethod.Default)
                {
                    registrationMethod = context.RegistrationMethod;
                }

                // Select registration method
                switch (registrationMethod)
                {
                case RegistrationMethod.Assembly:
                case RegistrationMethod.Default:
                    packageKey.SetValue("Assembly", t.Assembly.GetName().FullName);
                    break;

                case RegistrationMethod.CodeBase:
                    packageKey.SetValue("CodeBase", context.CodeBase);
                    break;
                }

                Key childKey = null;
                if (!useManagedResources)
                {
                    try
                    {
                        childKey = packageKey.CreateSubkey("SatelliteDll");
                        // ALLEND
                        // Make sure this is escaped properly
                        string satelliteDllPath = context.ComponentPath;
                        childKey.SetValue("Path", satelliteDllPath);
                        childKey.SetValue("DllName", String.Format(CultureInfo.InvariantCulture, "{0}UI.dll", Path.GetFileNameWithoutExtension(t.Assembly.ManifestModule.Name)));
                    }
                    finally
                    {
                        if (childKey != null)
                        {
                            childKey.Close();
                        }
                    }
                }
            }
            finally
            {
                if (packageKey != null)
                {
                    packageKey.Close();
                }
            }
        }
Example #7
0
 public LoginSteps(BrowserDriver driver)
 {
     registrationMethod = new RegistrationMethod(driver.Current);
     bcsc      = new BCSC(driver.Current);
     bcscUsers = driver.Configuration.GetSection("users").Get <IEnumerable <BcscUser> >();
 }
        private void UpdateRegistrationsUpToLimit(RegistrationMethod registrationMethod, EventType eventType)
        {
            if (registrationMethod == RegistrationMethod.Admin)
            {
                RegisterMgr.OpenAdminRegisterPage(this.eventID, this.sessionID);
            }
            else
            {
                RegisterMgr.OpenRegisterPage(this.eventID);
            }

            RegisterMgr.CheckinWithEmail(this.primaryEmail);
            RegisterMgr.Continue();
            RegisterMgr.EnterPassword(ConfigReader.DefaultProvider.AccountConfiguration.Password);
            RegisterMgr.Continue();

            string regType = string.Empty;
            string message = string.Empty;

            switch (eventType)
            {
                case EventType.EventWithoutLimitWithRegTypesEachHavingLimitsForceSameRegType:
                    int index = 1;
                    regType = RegisterMgr.GetRegTypeText(index);

                    int regQuantityForPrimaryAttendee = 1;

                    for (int regCount = 1; regCount <= RegLimitForRegType - regQuantityForPrimaryAttendee; regCount++)
                    {
                        this.AddAnotherPerson(registrationMethod, null);
                    }

                    RegisterMgr.CurrentEmail = this.primaryEmail;
                    message = string.Format(RegisterManager.Error.RegTypeLimitReachedAndContinueFormat, regType);
                    break;

                default:
                    break;
            }

            RegisterMgr.VerifyEventLimitReachedAndContinueMessage(message);
            RegisterMgr.Continue();
            RegisterMgr.VerifyHasAddAnotherPersonButton(false);
            RegisterMgr.FinishRegistration();
            RegisterMgr.ConfirmRegistration();
        }
        private void UpdateGroupRegistrationWhenLimitReached(RegistrationMethod registrationMethod, EventType eventType)
        {
            double totalFee = 0;

            if (registrationMethod == RegistrationMethod.Admin)
            {
                RegisterMgr.OpenAdminRegisterPage(this.eventID, this.sessionID);
            }
            else
            {
                RegisterMgr.OpenRegisterPage(this.eventID);
            }

            RegisterMgr.CheckinWithEmail(this.primaryEmail);
            RegisterMgr.ClickCheckinAlreadyRegistered();
            RegisterMgr.EnterEmailAddress(this.primaryEmail);

            if (registrationMethod == RegistrationMethod.Admin)
            {
                RegisterMgr.Continue();
                int regTypeKey = this.GetRandomRegTypeKey();
                string regType = this.regTypes[regTypeKey];

                RegisterMgr.VerifyHasAddAnotherPersonButton(true);

                switch (eventType)
                {
                    case EventType.EventWithLimitWithoutRegTypes:
                        totalFee = EventFee * (EventLimit + 1);
                        break;

                    case EventType.EventWithLimitWithRegTypes:
                    case EventType.EventWithLimitWithRegTypesForceSameRegType:
                        totalFee = RegTypeFee * (EventLimit + 1);
                        break;

                    case EventType.EventWithoutLimitWithRegTypesEachHavingLimits:
                        totalFee = RegTypeFee * (RegLimitForRegType * RegTypeQuantity + 1);
                        break;

                    case EventType.EventWithoutLimitWithRegTypesEachHavingLimitsForceSameRegType:
                        totalFee = RegTypeFee * (RegLimitForRegType + 1);
                        break;

                    default:
                        break;
                }

                this.AddAnotherPerson(registrationMethod, regType);

                RegisterMgr.Continue();
                RegisterMgr.VerifyHasAddAnotherPersonButton(true);
                RegisterMgr.CurrentEmail = this.primaryEmail;
                this.PayAndVerifyAmountAndFinish(totalFee);
            }
            else
            {
                RegisterMgr.EnterPassword(ConfigReader.DefaultProvider.AccountConfiguration.Password);
                RegisterMgr.Continue();

                RegisterMgr.VerifyHasAddAnotherPersonButton(false);

                int index = 1;
                string regType = string.Empty;

                switch (eventType)
                {
                    case EventType.EventWithLimitWithRegTypes:
                    case EventType.EventWithLimitWithRegTypesForceSameRegType:
                    case EventType.EventWithoutLimitWithRegTypesEachHavingLimits:
                    case EventType.EventWithoutLimitWithRegTypesEachHavingLimitsForceSameRegType:
                        regType = RegisterMgr.GetRegTypeText(index);
                        break;

                    default:
                        break;
                }

                RegisterMgr.ClickEditPersonalInformationLink(index - 1);
                RegisterMgr.EnterPersonalInfoAddress(null, "Update", null, null, null, null);
                string message = string.Empty;

                switch (eventType)
                {
                    case EventType.EventWithLimitWithoutRegTypes:
                        message = RegisterManager.Error.EventLimitReachedAndContinue;
                        break;

                    case EventType.EventWithLimitWithRegTypes:
                    case EventType.EventWithLimitWithRegTypesForceSameRegType:
                    case EventType.EventWithoutLimitWithRegTypesEachHavingLimits:
                    case EventType.EventWithoutLimitWithRegTypesEachHavingLimitsForceSameRegType:
                        message = string.Format(RegisterManager.Error.RegTypeLimitReachedAndContinueFormat, regType);
                        break;

                    default:
                        break;
                }

                RegisterMgr.VerifyEventLimitReachedAndContinueMessage(message);
                RegisterMgr.Continue();
                RegisterMgr.VerifyHasAddAnotherPersonButton(false);
                RegisterMgr.ClickFinalizeButton();
                RegisterMgr.FinishRegistration();
                RegisterMgr.ConfirmRegistration();
            }
        }
        private void EnterCheckinAndProfileInfo(RegistrationMethod registrationType, string regType)
        {
            RegisterMgr.Checkin();

            if (regType != null)
            {
                RegisterMgr.SelectRegType(regType);
            }

            RegisterMgr.Continue();

            if (RegisterMgr.HasCheckinErrorMessage())
            {
                Assert.Fail(string.Format("Checkin error message: {0}", RegisterMgr.GetCheckinErrorMessage()));
            }

            if (registrationType == RegistrationMethod.Admin)
            {
                RegisterMgr.EnterProfileInfoWithoutPassword();
            }
            else
            {
                RegisterMgr.EnterProfileInfo();
            }
        }
        private void CreateIndividualRegistrationWhenLimitReached(RegistrationMethod registrationMethod, EventType eventType)
        {
            int regTypeKey = this.GetRandomRegTypeKey();

            double totalFee = 0;

            switch (eventType)
            {
                case EventType.EventWithLimitWithoutRegTypes:
                    switch (registrationMethod)
                    {
                        case RegistrationMethod.Registrant:
                            RegisterMgr.OpenRegisterPage(this.eventID);
                            RegisterMgr.VerifyEventLimitReachedMessage(RegisterManager.Error.CheckinEventSoldOut);
                            RegisterMgr.VerifyHasContinueOrContinueNextStepButton(false);
                            break;

                        case RegistrationMethod.Admin:
                            RegisterMgr.OpenAdminRegisterPage(this.eventID, this.sessionID);
                            RegisterMgr.VerifyHasContinueOrContinueNextStepButton(true);
                            this.EnterCheckinAndProfileInfo(RegistrationMethod.Admin, null);
                            totalFee = EventFee;
                            RegisterMgr.Continue();
                            RegisterMgr.VerifyHasAddAnotherPersonButton(true);
                            this.PayAndVerifyAmountAndFinish(totalFee);
                            break;

                        case RegistrationMethod.EventWebsite:
                            RegisterMgr.OpenRegisterPage(this.eventID, RegisterMgr.Fetch_EventWebsiteUrl(this.eventID));
                            RegisterMgr.VerifyEventLimitReachedMessage(RegisterManager.Error.CheckinEventSoldOut);
                            RegisterMgr.VerifyHasContinueOrContinueNextStepButton(false);
                            break;

                        default:
                            break;
                    }

                    break;

                case EventType.EventWithLimitWithRegTypes:
                    switch (registrationMethod)
                    {
                        case RegistrationMethod.Registrant:
                            RegisterMgr.OpenRegisterPage(this.eventID);
                            RegisterMgr.VerifyEventLimitReachedMessage(RegisterManager.Error.CheckinEventSoldOut);
                            RegisterMgr.VerifyHasContinueOrContinueNextStepButton(false);
                            break;

                        case RegistrationMethod.EventWebsite:
                            RegisterMgr.OpenRegisterPage(this.eventID, RegisterMgr.Fetch_EventWebsiteUrl(this.eventID));
                            RegisterMgr.VerifyEventLimitReachedMessage(RegisterManager.Error.CheckinEventSoldOut);
                            RegisterMgr.VerifyHasContinueOrContinueNextStepButton(false);
                            break;

                        case RegistrationMethod.RegTypeDirectLink:
                            RegisterMgr.OpenRegisterPage(this.eventID, this.directLinks[regTypeKey]);
                            RegisterMgr.VerifyEventLimitReachedMessage(RegisterManager.Error.CheckinEventSoldOut);
                            RegisterMgr.VerifyHasContinueOrContinueNextStepButton(false);
                            break;

                        case RegistrationMethod.Admin:
                            RegisterMgr.OpenAdminRegisterPage(this.eventID, this.sessionID);
                            RegisterMgr.VerifyHasContinueOrContinueNextStepButton(true);
                            this.EnterCheckinAndProfileInfo(RegistrationMethod.Admin, this.regTypes[regTypeKey]);
                            totalFee = RegTypeFee;
                            RegisterMgr.Continue();
                            RegisterMgr.VerifyHasAddAnotherPersonButton(true);
                            this.PayAndVerifyAmountAndFinish(totalFee);
                            break;

                        default:
                            break;
                    }

                    break;

                case EventType.EventWithoutLimitWithRegTypesEachHavingLimits:
                    switch (registrationMethod)
                    {
                        case RegistrationMethod.Registrant:
                            RegisterMgr.OpenRegisterPage(this.eventID);
                            //Registration.VerifyEventLimitReachedMessage(RegistrationManager.CheckinEventAvailableMessage);
                            RegisterMgr.VerifyHasContinueOrContinueNextStepButton(true);
                            RegisterMgr.Checkin();
                            RegisterMgr.ContinueWithErrors();
                            RegisterMgr.VerifyHasCheckinErrorMessage(true);
                            RegisterMgr.VerifyCheckinErrorMessage(RegisterManager.Error.CheckinRequiredFieldsError);
                            break;

                        case RegistrationMethod.EventWebsite:
                            RegisterMgr.OpenRegisterPage(this.eventID, RegisterMgr.Fetch_EventWebsiteUrl(this.eventID));
                            //Registration.VerifyEventLimitReachedMessage(RegistrationManager.CheckinEventAvailableMessage);
                            RegisterMgr.VerifyHasContinueOrContinueNextStepButton(true);
                            RegisterMgr.Checkin();
                            RegisterMgr.ContinueWithErrors();
                            RegisterMgr.VerifyHasCheckinErrorMessage(true);
                            RegisterMgr.VerifyCheckinErrorMessage(RegisterManager.Error.CheckinRequiredFieldsError);
                            break;

                        case RegistrationMethod.RegTypeDirectLink:
                            RegisterMgr.OpenRegisterPage(this.eventID, this.directLinks[regTypeKey]);

                            RegisterMgr.VerifyEventLimitReachedMessage(string.Format(
                                RegisterManager.Error.RegTypeLimitReachedFormat,
                                this.regTypes[regTypeKey]));

                            RegisterMgr.VerifyHasContinueOrContinueNextStepButton(false);
                            break;

                        case RegistrationMethod.Admin:
                            RegisterMgr.OpenAdminRegisterPage(this.eventID, this.sessionID);
                            RegisterMgr.VerifyHasContinueOrContinueNextStepButton(true);

                            // Admin reg can go over limit, either event limit, or reg type limit
                            // So using random number as reg type key is OK here
                            this.EnterCheckinAndProfileInfo(RegistrationMethod.Admin, this.regTypes[regTypeKey]);
                            totalFee = RegTypeFee;
                            RegisterMgr.Continue();
                            RegisterMgr.VerifyHasAddAnotherPersonButton(true);
                            this.PayAndVerifyAmountAndFinish(totalFee);
                            break;

                        default:
                            break;
                    }

                    break;

                default:
                    break;
            }
        }
        private void CreateIndividualRegistration(bool isAbleToAddAnotherPerson,
            RegistrationMethod registrationMethod, EventType eventType, int? regTypeKey)
        {
            if (regTypeKey == SelectRandom)
            {
                regTypeKey = this.GetRandomRegTypeKey();
            }

            switch (registrationMethod)
            {
                case RegistrationMethod.Registrant:
                    RegisterMgr.OpenRegisterPage(this.eventID);
                    break;

                case RegistrationMethod.RegTypeDirectLink:
                    RegisterMgr.OpenRegisterPage(this.eventID, this.directLinks[regTypeKey.Value]);
                    break;

                case RegistrationMethod.EventWebsite:
                    RegisterMgr.OpenRegisterPage(this.eventID, RegisterMgr.Fetch_EventWebsiteUrl(this.eventID));
                    break;

                default:
                    break;
            }

            double totalFee = 0;
            string message = string.Empty;

            switch (eventType)
            {
                case EventType.EventWithLimitWithoutRegTypes:
                    this.EnterCheckinAndProfileInfo(registrationMethod, null);
                    totalFee = EventFee;
                    message = RegisterManager.Error.EventLimitReachedAndContinue;
                    break;

                case EventType.EventWithLimitWithRegTypes:
                case EventType.EventWithoutLimitWithRegTypesEachHavingLimits:
                    string regType = this.regTypes[regTypeKey.Value];
                    this.EnterCheckinAndProfileInfo(registrationMethod, regType);
                    totalFee = RegTypeFee;
                    message = string.Format(RegisterManager.Error.RegTypeLimitReachedAndContinueFormat, regType);
                    break;

                case EventType.EventWithoutLimitWithRegTypesEachHavingLimitsForceSameRegType:
                    string unavailableRegType = null;
                    List<EventRegType> regTypes = BuilderMgr.RegTypeMgr.Fetch_RegTypes(this.eventID);

                    foreach (EventRegType registrantType in regTypes)
                    {
                        if (!RegisterMgr.IsRegTypeAvailable(registrantType.Id))
                        {
                            regTypes.Remove(registrantType);
                            int randomKey = new Random((int)DateTime.Now.Ticks).Next(0, regTypes.Count);
                            unavailableRegType = regTypes[randomKey].Description;
                            break;
                        }
                    }

                    if (string.IsNullOrEmpty(unavailableRegType))
                    {
                        Assert.Fail("All reg types are available!");
                    }

                    this.EnterCheckinAndProfileInfo(registrationMethod, unavailableRegType);
                    totalFee = RegTypeFee;
                    message = string.Format(RegisterManager.Error.RegTypeLimitReachedAndContinueFormat, unavailableRegType);
                    break;

                default:
                    break;
            }

            RegisterMgr.VerifyHasAddAnotherPersonButton(isAbleToAddAnotherPerson);

            if (!isAbleToAddAnotherPerson)
            {
                RegisterMgr.VerifyEventLimitReachedAndContinueMessage(message);
            }

            RegisterMgr.Continue();
            this.PayAndVerifyAmountAndFinish(totalFee);
        }
        private void CreateGroupRegistrationsUpToLimit(RegistrationMethod registrationMethod, EventType eventType)
        {
            int regTypeKey = SelectRandom;

            switch (registrationMethod)
            {
                case RegistrationMethod.Registrant:
                    RegisterMgr.OpenRegisterPage(this.eventID);
                    break;

                case RegistrationMethod.EventWebsite:
                    RegisterMgr.OpenRegisterPage(this.eventID, RegisterMgr.Fetch_EventWebsiteUrl(this.eventID));
                    break;

                case RegistrationMethod.RegTypeDirectLink:
                    regTypeKey = this.GetRandomRegTypeKey();
                    RegisterMgr.OpenRegisterPage(this.eventID, this.directLinks[regTypeKey]);
                    break;

                case RegistrationMethod.Admin:
                    RegisterMgr.OpenAdminRegisterPage(this.eventID, this.sessionID);
                    break;

                default:
                    break;
            }

            // "1" represents the registration of the primary attendee
            int regQuantityForPrimaryAttendee = 1;

            string message = string.Empty;

            switch (eventType)
            {
                case EventType.EventWithLimitWithoutRegTypes:
                    this.EnterCheckinAndProfileInfo(registrationMethod, null);
                    this.primaryEmail = RegisterMgr.CurrentEmail;

                    for (int count = 1; count <= EventLimit - regQuantityForPrimaryAttendee; count++)
                    {
                        this.AddAnotherPerson(registrationMethod, null);
                    }

                    message = RegisterManager.Error.EventLimitReachedAndContinue;
                    break;

                case EventType.EventWithLimitWithRegTypes:
                    if (regTypeKey == SelectRandom)
                    {
                        this.EnterCheckinAndProfileInfo(registrationMethod, this.regTypes[this.GetRandomRegTypeKey()]);
                    }
                    // 'regTypeKey != SelectRandom' means the current registration is using reg type direct link,
                    // under this situation, all registrations in the same group are forced to one reg type
                    else
                    {
                        this.EnterCheckinAndProfileInfo(registrationMethod, null);
                    }

                    this.primaryEmail = RegisterMgr.CurrentEmail;
                    string lastRegType = string.Empty;

                    for (int count = 1; count <= EventLimit - regQuantityForPrimaryAttendee; count++)
                    {
                        int key = this.GetRandomRegTypeKey();

                        if (regTypeKey == SelectRandom)
                        {
                            this.AddAnotherPerson(registrationMethod, this.regTypes[key]);
                        }
                        else
                        {
                            this.AddAnotherPerson(registrationMethod, null);
                        }

                        if (count == EventLimit - regQuantityForPrimaryAttendee)
                        {
                            lastRegType = this.regTypes[key];
                        }
                    }

                    if (regTypeKey == SelectRandom)
                    {
                        message = string.Format(
                            RegisterManager.Error.RegTypeLimitReachedAndContinueFormat,
                            lastRegType);
                    }
                    else
                    {
                        message = string.Format(
                            RegisterManager.Error.RegTypeLimitReachedAndContinueFormat,
                            this.regTypes[regTypeKey]);
                    }

                    break;

                case EventType.EventWithLimitWithRegTypesForceSameRegType:
                    if (regTypeKey == SelectRandom)
                    {
                        regTypeKey = this.GetRandomRegTypeKey();
                    }

                    string regType = this.regTypes[regTypeKey];
                    this.EnterCheckinAndProfileInfo(registrationMethod, regType);
                    this.primaryEmail = RegisterMgr.CurrentEmail;

                    for (int count = 1; count <= EventLimit - regQuantityForPrimaryAttendee; count++)
                    {
                        this.AddAnotherPerson(registrationMethod, null);
                    }

                    message = string.Format(RegisterManager.Error.RegTypeLimitReachedAndContinueFormat, regType);
                    break;

                case EventType.EventWithoutLimitWithRegTypesEachHavingLimits:
                    if (regTypeKey == SelectRandom)
                    {
                        regTypeKey = this.GetRandomRegTypeKey();
                    }

                    int lastRegTypeKey = regTypeKey;
                    bool firstRegForStartingRegType = true;

                    this.EnterCheckinAndProfileInfo(registrationMethod, this.regTypes[regTypeKey]);
                    this.primaryEmail = RegisterMgr.CurrentEmail;

                    for (int regTypeCount = 1; regTypeCount <= RegTypeQuantity; regTypeCount++)
                    {
                        for (int regCount = 1; regCount <= RegLimitForRegType; regCount++)
                        {
                            if (firstRegForStartingRegType && regTypeCount == regTypeKey)
                            {
                                firstRegForStartingRegType = false;
                                continue;
                            }
                            else
                            {
                                this.AddAnotherPerson(registrationMethod, this.regTypes[regTypeCount]);
                            }

                            lastRegTypeKey = regTypeCount;
                        }
                    }

                    message = string.Format(RegisterManager.Error.RegTypeLimitReachedAndContinueFormat, this.regTypes[lastRegTypeKey]);
                    break;

                case EventType.EventWithoutLimitWithRegTypesEachHavingLimitsForceSameRegType:
                    if (regTypeKey == SelectRandom)
                    {
                        regTypeKey = this.GetRandomRegTypeKey();
                    }

                    regType = this.regTypes[regTypeKey];
                    this.EnterCheckinAndProfileInfo(registrationMethod, regType);
                    this.primaryEmail = RegisterMgr.CurrentEmail;

                    for (int count = 1; count <= RegLimitForRegType - regQuantityForPrimaryAttendee; count++)
                    {
                        this.AddAnotherPerson(registrationMethod, null);
                    }

                    message = string.Format(RegisterManager.Error.RegTypeLimitReachedAndContinueFormat, regType);
                    break;

                default:
                    break;
            }

            RegisterMgr.VerifyHasAddAnotherPersonButton(registrationMethod == RegistrationMethod.Admin ? true : false);

            if (registrationMethod != RegistrationMethod.Admin)
            {
                RegisterMgr.VerifyEventLimitReachedAndContinueMessage(message);
            }

            RegisterMgr.CurrentEmail = this.primaryEmail;
            RegisterMgr.Continue();
            RegisterMgr.VerifyHasAddAnotherPersonButton(registrationMethod == RegistrationMethod.Admin ? true : false);
            this.PayAndVerifyAmountAndFinish(this.GetGroupRegTotalFee(eventType));
        }
 private void AddAnotherPerson(RegistrationMethod registrationType, string regType)
 {
     RegisterMgr.VerifyHasAddAnotherPersonButton(true);
     RegisterMgr.ClickAddAnotherPerson();
     this.EnterCheckinAndProfileInfo(registrationType, regType);
 }
        /// <devdoc>
        ///     Called to register this attribute with the given context.  The context
        ///     contains the location where the registration inforomation should be placed.
        ///     it also contains such as the type being registered, and path information.
        ///
        ///     This method is called both for registration and unregistration.  The difference is
        ///     that unregistering just uses a hive that reverses the changes applied to it.
        /// </devdoc>
        /// <param name="context">
        ///     Contains the location where the registration inforomation should be placed.
        ///     It also contains other information such as the type being registered 
        ///     and path of the assembly.
        /// </param>
        public override void Register(RegistrationContext context)
        {
            Type t = context.ComponentType;
            context.Log.WriteLine(string.Format(Resources.Culture, Resources.Reg_NotifyPackage, t.Name, t.GUID.ToString("B")));

            Key packageKey = null;
            try
            {
                packageKey = context.CreateKey(RegKeyName(context));

                //use a friendly description if it exists.
                DescriptionAttribute attr = TypeDescriptor.GetAttributes(t)[typeof(DescriptionAttribute)] as DescriptionAttribute;
                if (attr != null && !String.IsNullOrEmpty(attr.Description)) {
                    packageKey.SetValue(string.Empty, attr.Description);
                }
                else {
                    packageKey.SetValue(string.Empty, t.AssemblyQualifiedName);
                }

                packageKey.SetValue("InprocServer32", context.InprocServerPath);
                packageKey.SetValue("Class", t.FullName);

                // If specified on the command line, let the command line option override
                if (context.RegistrationMethod != RegistrationMethod.Default)
                {
                    registrationMethod = context.RegistrationMethod;
                }

                // Select registration method
                switch (registrationMethod)
                {
                    case RegistrationMethod.Assembly:
                    case RegistrationMethod.Default:
                        packageKey.SetValue("Assembly", t.Assembly.FullName);
                        break;

                    case RegistrationMethod.CodeBase:
                        packageKey.SetValue("CodeBase", context.CodeBase);
                        break;
                }

                Key childKey = null;
                if (!useManagedResources)
                {
                    try
                    {
                        childKey = packageKey.CreateSubkey("SatelliteDll");

                        // Register the satellite dll
                        string satelliteDllPath;
                        if (SatellitePath != null)
                        {
                            // Use provided path
                            satelliteDllPath = context.EscapePath(SatellitePath);
                        }
                        else
                        {
                            // Default to package path
                            satelliteDllPath = context.ComponentPath;
                        }
                        childKey.SetValue("Path", satelliteDllPath);
                        childKey.SetValue("DllName", String.Format(CultureInfo.InvariantCulture, "{0}UI.dll", Path.GetFileNameWithoutExtension(t.Assembly.ManifestModule.Name)));
                    }
                    finally
                    {
                        if (childKey != null)
                            childKey.Close();
                    }
                }
            }
            finally
            {
                if (packageKey != null)
                    packageKey.Close();
            }
        }
        /// <include file='doc\ProvideObjectAttribute.uex' path='docs/doc[@for="Register"]' />
        /// <devdoc>
        ///     Called to register this attribute with the given context.  The context
        ///     contains the location where the registration inforomation should be placed.
        ///     it also contains such as the type being registered, and path information.
        ///
        ///     This method is called both for registration and unregistration.  The difference is
        ///     that unregistering just uses a hive that reverses the changes applied to it.
        /// </devdoc>
        public override void Register(RegistrationContext context)
        {
            context.Log.WriteLine(SR.GetString(SR.Reg_NotifyCreateObject, ObjectType.Name));

            using (Key childKey = context.CreateKey(CLSIDRegKey))
            {
                childKey.SetValue(string.Empty, ObjectType.FullName);
                childKey.SetValue("InprocServer32", context.InprocServerPath);
                childKey.SetValue("Class", ObjectType.FullName);

                // If specified on the command line, let the command line option override
                if (context.RegistrationMethod != RegistrationMethod.Default) {
                    registrationMethod = context.RegistrationMethod;
                }

            switch(registrationMethod) {
                case RegistrationMethod.Default:
                case RegistrationMethod.Assembly:
                    childKey.SetValue("Assembly", ObjectType.Assembly.FullName);
                    break;

                    case RegistrationMethod.CodeBase:
                        childKey.SetValue("CodeBase", context.CodeBase);
                        break;
                }

                childKey.SetValue("ThreadingModel", "Both");
            }
        }
Example #17
0
 public VsRegistrationContext(VsRegistryKey key, RegistrationMethod method)
 {
     m_key    = key;
     m_method = method;
 }