示例#1
0
        public void RunApplication(string[] args)
        {
			SetupCommandLine cmdLine = new SetupCommandLine();
			try
			{
				cmdLine.Parse(args);

				using (PersistenceScope scope = new PersistenceScope(PersistenceContextType.Update))
				{
					((IUpdateContext)PersistenceScope.CurrentContext).ChangeSetRecorder.OperationName = GetType().FullName;

					// import authority tokens
					AuthorityTokenImporter tokenImporter = new AuthorityTokenImporter();
					IList<AuthorityToken> allTokens = tokenImporter.ImportFromPlugins((IUpdateContext)PersistenceScope.CurrentContext);


					// create the sys admin group, which has all tokens assigned by default
					string[] tokenStrings = CollectionUtils.Map<AuthorityToken, string, List<string>>(allTokens,
					                                                                                  t => t.Name).ToArray();
                    AuthorityGroupDefinition adminGroupDef = new AuthorityGroupDefinition(cmdLine.SysAdminGroup, cmdLine.SysAdminGroup, false,
				                                                                          tokenStrings);
					AuthorityGroupImporter groupImporter = new AuthorityGroupImporter();

					IList<AuthorityGroup> groups = 
						groupImporter.Import(new AuthorityGroupDefinition[] { adminGroupDef }, (IUpdateContext)PersistenceScope.CurrentContext);

					// find the admin group entity that was just created
					AuthorityGroup adminGroup = CollectionUtils.SelectFirst(groups,
					                                                        g => g.Name == cmdLine.SysAdminGroup);

					// create the "sa" user
					CreateSysAdminUser(adminGroup, cmdLine, PersistenceScope.CurrentContext, Console.Out);

					// optionally import other default authority groups defined in other plugins
					if (cmdLine.ImportDefaultAuthorityGroups)
					{
						groupImporter.ImportFromPlugins((IUpdateContext) PersistenceScope.CurrentContext);
					}

					scope.Complete();
				}
			}
			catch (CommandLineException e)
			{
				Console.WriteLine(e.Message);
				cmdLine.PrintUsage(Console.Out);
			}
        }
示例#2
0
		public void RunApplication(string[] args)
		{
			var cmdLine = new SetupCommandLine();
			try
			{
				cmdLine.Parse(args);

				using (var scope = new PersistenceScope(PersistenceContextType.Update))
				{
					((IUpdateContext)PersistenceScope.CurrentContext).ChangeSetRecorder.OperationName = GetType().FullName;

					// import authority tokens
					var tokenImporter = new AuthorityTokenImporter();
					var allTokens = tokenImporter.ImportFromPlugins((IUpdateContext)PersistenceScope.CurrentContext);
					var tokenStrings = CollectionUtils.Map<AuthorityToken, string, List<string>>(allTokens, t => t.Name).ToArray();

					// import built-in groups
					var builtInAuthorityGroups = new[]
					{
						GetSysAdminGroupDefinition(tokenStrings),
						BuiltInAuthorityGroups.SystemAccounts
					};

					var groupImporter = new AuthorityGroupImporter();
					var groups = groupImporter.Import(builtInAuthorityGroups, (IUpdateContext)PersistenceScope.CurrentContext);

					// create the "sa" user
					var adminGroup = CollectionUtils.SelectFirst(groups, g => g.Name == BuiltInAuthorityGroups.Administrators.Name);
					CreateSysAdminUser(adminGroup, cmdLine, PersistenceScope.CurrentContext, Console.Out);

					// optionally import other default authority groups defined in other plugins
					if (cmdLine.ImportDefaultAuthorityGroups)
					{
						groupImporter.ImportFromPlugins((IUpdateContext)PersistenceScope.CurrentContext);
					}

					scope.Complete();
				}
			}
			catch (CommandLineException e)
			{
				Console.WriteLine(e.Message);
				cmdLine.PrintUsage(Console.Out);
			}
		}
示例#3
0
		public ImportAuthorityGroupsResponse ImportAuthorityGroups(ImportAuthorityGroupsRequest request)
		{
			Platform.CheckForNullReference(request, "request");
			Platform.CheckMemberIsSet(request.AuthorityGroups, "AuthorityGroups");

			if (request.AuthorityGroups.Count > 0)
			{
				var importer = new AuthorityGroupImporter();
				importer.Import(
					CollectionUtils.Map(request.AuthorityGroups,
										(AuthorityGroupDetail g) =>
											new AuthorityGroupDefinition(g.Name, g.Description, g.DataGroup,
												CollectionUtils.Map(g.AuthorityTokens, (AuthorityTokenSummary s) => s.Name).ToArray())),
					(IUpdateContext)PersistenceContext);

			}

			return new ImportAuthorityGroupsResponse();
		}
		public ImportAuthorityGroupsResponse ImportAuthorityGroups(ImportAuthorityGroupsRequest request)
		{
			Platform.CheckForNullReference(request, "request");
			Platform.CheckMemberIsSet(request.AuthorityGroups, "AuthorityGroups");

			if (request.AuthorityGroups.Count > 0)
			{
				var importer = new AuthorityGroupImporter();
				importer.Import(
					CollectionUtils.Map(request.AuthorityGroups, (AuthorityGroupDetail g) => GetAuthorityGroupDefinition(g)),
					(IUpdateContext)PersistenceContext);

			}

			return new ImportAuthorityGroupsResponse();
		}