public void OnGUI()
        {
            EditorGUILayout.Space();

            sandboxType = (SandboxType)EditorGUILayout.EnumPopup("Windows Sandbox Type:", sandboxType, GUILayout.ExpandWidth(true));
            EditorGUILayout.Space();

            EditorGUI.BeginDisabledGroup(sandboxType == SandboxType.Retail);
            ExporterWindow.exportationOptions.CustomWindowsSandbox = EditorGUILayout.TextField("Custom Sandbox Name", ExporterWindow.exportationOptions.CustomWindowsSandbox);
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.Space();

            keepGeneratorOpen = EditorGUILayout.Toggle("Keep Generator Open:", keepGeneratorOpen);
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            GUILayout.Label("Important: You Must Run Unity As Administrator", EditorStyles.centeredGreyMiniLabel);
            EditorGUILayout.Space();
            Tools.DrawGuiBox(new Rect(2, 115, 496, 252), Color.white);
            scrollPosLog = EditorGUILayout.BeginScrollView(scrollPosLog, GUILayout.ExpandWidth(true), GUILayout.Height(250));
            foreach (var log in this.logs)
            {
                var bold = log.StartsWith("*");
                GUILayout.Label(bold ? log.Remove(0, 1) : log, bold ? (EditorStyles.boldLabel) : EditorStyles.label);
            }
            EditorGUILayout.EndScrollView();
            EditorGUILayout.Space();
            if (GUILayout.Button("Switch Local Windows Sandbox"))
            {
                SwitchSandbox();
            }
            EditorGUILayout.Space();
        }
Exemplo n.º 2
0
        public async Task AddSandboxAsync(string sandboxKey, SandboxType sandboxType)
        {
            await DeleteSandboxesAsync(sandboxKey).ConfigureAwait(false);

            switch (sandboxType)
            {
            case SandboxType.Minimal:
                await CopySandboxAsync(
                    _databaseNameBuilder.MinimalDatabase,
                    _databaseNameBuilder.SandboxNameForKey(sandboxKey))
                .ConfigureAwait(false);

                break;

            case SandboxType.Sample:
                await CopySandboxAsync(
                    _databaseNameBuilder.SampleDatabase,
                    _databaseNameBuilder.SandboxNameForKey(sandboxKey))
                .ConfigureAwait(false);

                break;

            default:
                throw new Exception("Unhandled SandboxType provided");
            }
        }
Exemplo n.º 3
0
 public void AddSandbox(string sandboxKey, SandboxType sandboxType)
 {
     _sandboxes.Add(
         new Sandbox
     {
         Key = sandboxKey, SandboxType = sandboxType
     });
 }
Exemplo n.º 4
0
            protected override void Arrange()
            {
                const int         VendorId    = 444;
                const SandboxType SandboxType = SandboxType.Minimal;

                var defaultApplicationCreator = A.Fake <IDefaultApplicationCreator>();

                var application = new Application {
                    ApplicationName = "Application.ApplicationName"
                };

                application.CreateApplicationEducationOrganization(111);
                application.CreateApplicationEducationOrganization(222);
                application.CreateApplicationEducationOrganization(333);

                A.CallTo(
                    () =>
                    defaultApplicationCreator.FindOrCreateUpdatedDefaultSandboxApplication(VendorId, SandboxType))
                .Returns(application);

                ApiClient apiClient = new ApiClient {
                    Name = "ApiClient.Name"
                };

                var clientAppRepo = A.Fake <IClientAppRepo>();
                var user          = new User {
                    Vendor = new Vendor {
                        VendorId = VendorId
                    }
                };

                var sandboxClientCreateModel = new SandboxInitializationModel
                {
                    Name        = "SandboxInitializationModel.Name",
                    SandboxType = SandboxType
                };

                A.CallTo(
                    () => clientAppRepo.SetupDefaultSandboxClient(
                        sandboxClientCreateModel.Name,
                        sandboxClientCreateModel.SandboxType,
                        null,
                        null,
                        user.UserId,
                        application.ApplicationId)).Returns(apiClient);

                var clientAppConfigValueProviderRepo = A.Fake <IConfigValueProvider>();

                var sandboxProvisioner = A.Fake <ISandboxProvisioner>();

                var creator = new ClientCreator(clientAppConfigValueProviderRepo, clientAppRepo, defaultApplicationCreator, sandboxProvisioner);

                _apiClient = creator.CreateNewSandboxClient(sandboxClientCreateModel, user);
            }
Exemplo n.º 5
0
        public void SetupKeySecret(string name, SandboxType sandboxType, string key, string secret, int userId, int applicationId)
        {
            using (var context = _contextFactory.CreateContext())
            {
                var client = CreateApiClient(context, userId, name, sandboxType, key, secret);

                AddApplicationEducationOrganizations(context, applicationId, client);

                context.SaveChanges();
            }
        }
Exemplo n.º 6
0
        private ApiClient CreateApiClient(
            IUsersContext context,
            int userId,
            string name,
            SandboxType sandboxType,
            string key,
            string secret)
        {
            var attachedUser = context.Users.Find(userId);

            return(attachedUser.AddSandboxClient(name, sandboxType, key, secret));
        }
Exemplo n.º 7
0
        public ApiClient SetupDefaultSandboxClient(string name, SandboxType sandboxType, string key, string secret, int userId, int applicationId)
        {
            using (var context = _contextFactory.CreateContext())
            {
                _logger.Debug($"Creating API Client");
                var client = CreateApiClient(context, userId, name, sandboxType, key, secret);

                _logger.Debug($"Adding Education Organization to client");
                AddApplicationEducationOrganizations(context, applicationId, client);

                context.SaveChanges();

                return(client);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Create a new sandbox client
        /// </summary>
        /// <param name="name">The visible name of the sandbox</param>
        /// <param name="sandboxType">Empty, Minimal, Populated</param>
        /// <param name="key">optional parameter, value is created randomly if it is null or empty. Both Key and Secret are required if providing either.</param>
        /// <param name="secret">optional parameter, value is created randomly if it is null or empty. Both Key and Secret are required if providing either.</param>
        /// <returns>ApiClient information about the created sandbox</returns>
        public ApiClient AddSandboxClient(string name, SandboxType sandboxType, string key, string secret)
        {
            var client = new ApiClient(true)
            {
                Name = name, IsApproved = true, UseSandbox = true, SandboxType = sandboxType
            };

            if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(secret))
            {
                client.Key    = key;
                client.Secret = secret;
            }

            ApiClients.Add(client);
            return(client);
        }
Exemplo n.º 9
0
 public void AddSandbox(string sandboxKey, SandboxType sandboxType)
 => AddSandboxAsync(sandboxKey, sandboxType).WaitSafely();
        /// <summary>
        /// Look for an existing default application for this particular sandbox type.  Also, make sure that all
        /// Local Education Agency associations are updated.
        /// </summary>
        /// <param name="vendorId"></param>
        /// <param name="sandboxType"></param>
        /// <returns></returns>
        public Application FindOrCreateUpdatedDefaultSandboxApplication(int vendorId, SandboxType sandboxType)
        {
            using (var context = _usersContextFactory.CreateContext())
            {
                var vendor = context.Vendors
                             .Where(x => x.VendorId == vendorId)
                             .Include(x => x.Applications.Select <Application, ICollection <ApplicationEducationOrganization> >(a => a.ApplicationEducationOrganizations))
                             .Single();

                var defaultAppName  = _configuration.GetSection("DefaultApplicationName").Value ?? "Default Sandbox Application";
                var applicationName = defaultAppName + " " + sandboxType;
                var application     = GetApplication(context, vendor, applicationName);

                context.SaveChanges();
                return(application);
            }
        }
Exemplo n.º 11
0
 public Task AddSandboxAsync(string sandboxKey, SandboxType sandboxType) => throw new NotImplementedException();