Exemple #1
0
        private static async Task <NamedId <DomainId> > CreateProjectsSchemaAsync(PublishTemplate publish)
        {
            var schema =
                SchemaBuilder.Create("Projects")
                .AddString("Name", f => f
                           .Required()
                           .ShowInList()
                           .Hints("The name of your project."))
                .AddString("Description", f => f
                           .AsTextArea()
                           .Required()
                           .Hints("Describe your project."))
                .AddAssets("Image", f => f
                           .MustBeImage()
                           .Required()
                           .Hints("An image or screenshot for your project."))
                .AddString("Label", f => f
                           .AsTextArea()
                           .Hints("An optional label to categorize your project, e.g. 'Open Source'."))
                .AddString("Link", f => f
                           .Hints("An optional link to your project."))
                .AddNumber("Year", f => f
                           .Hints("The year, when you realized the project, used for sorting only."))
                .Build();

            await publish(schema);

            return(NamedId.Of(schema.SchemaId, schema.Name));
        }
Exemple #2
0
        private static ISchema GetRandomSchema()
        {
            long          fieldCount;
            SchemaBuilder schemaBuilder;

            schemaBuilder = SchemaBuilder.Create();

            schemaBuilder.AddField(string.Empty, typeof(Guid), false, true);

            lock (syncLock)
                fieldCount = Random.Next(MIN_FIELD_COUNT, MAX_FIELD_COUNT);

            if (fieldCount == INVALID_RANDOM_VALUE)
            {
                throw new SyncPremException();
            }

            for (long fieldIndex = 0; fieldIndex < fieldCount; fieldIndex++)
            {
                string fieldName = string.Format(FIELD_NAME, fieldIndex);

                schemaBuilder.AddField(fieldName, typeof(double), false, false);
            }

            return(schemaBuilder.Build());
        }
Exemple #3
0
        private static async Task <NamedId <DomainId> > CreateEducationSchemaAsync(PublishTemplate publish)
        {
            var schema =
                SchemaBuilder.Create("Education")
                .AddString("Degree", f => f
                           .Required()
                           .ShowInList()
                           .Hints("The degree you got or achieved."))
                .AddString("School", f => f
                           .Required()
                           .ShowInList()
                           .Hints("The school or university."))
                .AddAssets("Logo", f => f
                           .MustBeImage()
                           .Hints("The logo of the school or university."))
                .AddDateTime("From", f => f
                             .Required()
                             .Hints("The start date."))
                .AddDateTime("To", f => f
                             .Hints("The end date, keep empty if you still study there."))
                .Build();

            await publish(schema);

            return(NamedId.Of(schema.SchemaId, schema.Name));
        }
Exemple #4
0
        public async Task HandleAsync(CommandContext context, NextDelegate next)
        {
            await next(context);

            if (context.Command is CreateApp createApp && context.IsCompleted && createApp.Template == "custom")
            {
                var appId = NamedId.Of(createApp.AppId, createApp.Name);

                var publish = new Func <IAppCommand, Task>(command =>
                {
                    command.AppId = appId;

                    return(context.CommandBus.PublishAsync(command));
                });

                var schema =
                    SchemaBuilder.Create("Pages")
                    .AddString("Title", f => f
                               .Length(100)
                               .Required())
                    .AddString("Slug", f => f
                               .Length(100)
                               .Required()
                               .Disabled())
                    .AddString("Text", f => f
                               .Length(1000)
                               .Required()
                               .AsRichText())
                    .Build();

                await publish(schema);
            }
        }
        private static async Task <ISchema> GetRandomSchemaAsync(CancellationToken cancellationToken)
        {
            long          fieldCount;
            SchemaBuilder schemaBuilder;

            await SyncLock.WaitAsync(cancellationToken);

            try
            {
                schemaBuilder = SchemaBuilder.Create();

                schemaBuilder.AddField(string.Empty, typeof(Guid), false, true);

                fieldCount = Random.Next(MIN_FIELD_COUNT, MAX_FIELD_COUNT);

                if (fieldCount == INVALID_RANDOM_VALUE)
                {
                    throw new SyncPremException();
                }

                for (long fieldIndex = 0; fieldIndex < fieldCount; fieldIndex++)
                {
                    string fieldName = string.Format(FIELD_NAME, fieldIndex);

                    schemaBuilder.AddField(fieldName, typeof(double), false, false);
                }

                return(schemaBuilder.Build());
            }
            finally
            {
                SyncLock.Release();
            }
        }
Exemple #6
0
        private static async Task <NamedId <DomainId> > CreatePostsSchemaAsync(Func <ICommand, Task> publish)
        {
            var schema =
                SchemaBuilder.Create("Posts")
                .AddString("Title", f => f
                           .Length(100)
                           .Required()
                           .ShowInList()
                           .Hints("The title of the post."))
                .AddString("Text", f => f
                           .AsRichText()
                           .Length(100)
                           .Required()
                           .Hints("The text of the post."))
                .AddString("Slug", f => f
                           .Disabled()
                           .Label("Slug (Autogenerated)")
                           .Hints("Autogenerated slug that can be used to identity the post."))
                .WithScripts(DefaultScripts.GenerateSlug)
                .Build();

            await publish(schema);

            return(NamedId.Of(schema.SchemaId, schema.Name));
        }
        private static async Task <NamedId <Guid> > CreatePagesSchemaAsync(Func <ICommand, Task> publish)
        {
            var schema =
                SchemaBuilder.Create("Pages")
                .AddString("Title", f => f
                           .Length(100)
                           .Required()
                           .ShowInList()
                           .Hints("The title of the page."))
                .AddString("Text", f => f
                           .AsRichText()
                           .Length(100)
                           .Required()
                           .Hints("The text of the page."))
                .AddString("Slug", f => f
                           .Disabled()
                           .Label("Slug (Autogenerated)")
                           .Hints("Autogenerated slug that can be used to identity the page."))
                .Build();

            await publish(schema);

            var schemaId = NamedId.Of(schema.SchemaId, schema.Name);

            await publish(new ConfigureScripts
            {
                SchemaId     = schemaId.Id,
                ScriptCreate = SlugScript,
                ScriptUpdate = SlugScript
            });

            return(schemaId);
        }
        private static Task CreateApiResourcesSchemaAsync(Func <ICommand, Task> publish, NamedId <DomainId> scopeId)
        {
            var schema =
                SchemaBuilder.Create("API Resources")
                .AddString("Name", f => f
                           .Unique()
                           .Required()
                           .ShowInList()
                           .Hints("The unique name of the API."))
                .AddString("Display Name", f => f
                           .Localizable()
                           .Hints("The display name of the API."))
                .AddString("Description", f => f
                           .Localizable()
                           .Hints("The description name of the API."))
                .AddBoolean("Disabled", f => f
                            .AsToggle()
                            .Hints("Enable or disable the API."))
                .AddReferences("Scopes", f => f
                               .WithSchemaId(scopeId.Id)
                               .Hints("The scopes for this API."))
                .AddTags("User Claims", f => f
                         .Hints("List of accociated user claims that should be included when this resource is requested."))
                .Build();

            return(publish(schema));
        }
        private static Task CreateIdentityResourcesSchemaAsync(Func <ICommand, Task> publish)
        {
            var schema =
                SchemaBuilder.Create("Identity Resources")
                .AddString("Name", f => f
                           .Unique()
                           .Required()
                           .ShowInList()
                           .Hints("The unique name of the identity information."))
                .AddString("Display Name", f => f
                           .Localizable()
                           .Hints("The display name of the identity information."))
                .AddString("Description", f => f
                           .Localizable()
                           .Hints("The description name of the identity information."))
                .AddBoolean("Required", f => f
                            .AsToggle()
                            .Hints("Specifies whether the user can de-select the scope on the consent screen."))
                .AddBoolean("Disabled", f => f
                            .AsToggle()
                            .Hints("Enable or disable the scope."))
                .AddBoolean("Emphasize", f => f
                            .AsToggle()
                            .Hints("Emphasize the API scope for important scopes."))
                .AddTags("User Claims", f => f
                         .Hints("List of accociated user claims that should be included when this resource is requested."))
                .Build();

            return(publish(schema));
        }
Exemple #10
0
        private static async Task <NamedId <DomainId> > CreateExperienceSchemaAsync(PublishTemplate publish)
        {
            var schema =
                SchemaBuilder.Create("Experience")
                .AddString("Position", f => f
                           .Required()
                           .ShowInList()
                           .Hints("Your position in this job."))
                .AddString("Company", f => f
                           .Required()
                           .ShowInList()
                           .Hints("The company or organization you worked for."))
                .AddAssets("Logo", f => f
                           .MustBeImage()
                           .Hints("The logo of the company or organization you worked for."))
                .AddDateTime("From", f => f
                             .Required()
                             .Hints("The start date."))
                .AddDateTime("To", f => f
                             .Hints("The end date, keep empty if you still work there."))
                .Build();

            await publish(schema);

            return(NamedId.Of(schema.SchemaId, schema.Name));
        }
        private static async Task <NamedId <DomainId> > CreateApiScopesSchemaAsync(Func <ICommand, Task> publish)
        {
            var schema =
                SchemaBuilder.Create("API Scopes")
                .AddString("Name", f => f
                           .Unique()
                           .Required()
                           .ShowInList()
                           .Hints("The unique name of the API scope."))
                .AddString("Display Name", f => f
                           .Localizable()
                           .Hints("The display name of the API scope."))
                .AddString("Description", f => f
                           .Localizable()
                           .Hints("The description name of the API scope."))
                .AddBoolean("Disabled", f => f
                            .AsToggle()
                            .Hints("Enable or disable the scope."))
                .AddBoolean("Emphasize", f => f
                            .AsToggle()
                            .Hints("Emphasize the API scope for important scopes."))
                .AddTags("User Claims", f => f
                         .Hints("List of accociated user claims that should be included when this resource is requested."))
                .Build();

            await publish(schema);

            return(NamedId.Of(schema.SchemaId, schema.Name));
        }
 private static async Task <NamedId <DomainId> > CreatePostsSchemaAsync(PublishTemplate publish)
 {
     var schema =
         SchemaBuilder.Create("Posts")
         .AddString("Title", f => f
                    .Properties(p => p with
     {
         MaxLength = 100
     })
 public Task RunAsync(PublishTemplate publish)
 {
     var schema =
         SchemaBuilder.Create("Blogs")
         .AddString("Title", f => f
                    .Properties(p => p with
     {
         MaxLength = 100
     })
        private Task CreateSettingsSchemaAsync(Func <ICommand, Task> publish)
        {
            var schema =
                SchemaBuilder.Create("Settings").Singleton()
                .AddString("Site Name", f => f
                           .Localizable()
                           .Hints("The name of your website."))
                .AddAssets("Logo", f => f
                           .MustBeImage()
                           .Hints("Logo that is rendered in the header."))
                .AddString("Footer Text", f => f
                           .Localizable()
                           .Hints("The optional footer text."))
                .AddString("PrivacyPolicyUrl", f => f
                           .Localizable()
                           .Hints("The link to your privacy policies."))
                .AddString("LegalUrl", f => f
                           .Localizable()
                           .Hints("The link to your legal information."))
                .AddString("Email Confirmation Text", f => f
                           .AsTextArea()
                           .Localizable()
                           .Hints("The text for the confirmation email."))
                .AddString("Email Confirmation Subject", f => f
                           .AsTextArea()
                           .Localizable()
                           .Hints("The subject for the confirmation email."))
                .AddString("Email Password Reset Text", f => f
                           .AsTextArea()
                           .Localizable()
                           .Hints("The text for the password reset email."))
                .AddString("Email Password Reset Subject", f => f
                           .AsTextArea()
                           .Localizable()
                           .Hints("The subject for the password reset email."))
                .AddString("Terms of Service Url", f => f
                           .Localizable()
                           .Hints("The link to your tems of service."))
                .AddString("Bootstrap Url", f => f
                           .Hints("The link to a custom bootstrap theme."))
                .AddString("Styles Url", f => f
                           .Hints("The link to a stylesheet."))
                .AddString("SMTP From", f => f
                           .Hints("The SMTP sender address."))
                .AddString("SMTP Server", f => f
                           .Hints("The smpt server."))
                .AddString("SMTP Username", f => f
                           .Hints("The username for your SMTP server."))
                .AddString("SMTP Password", f => f
                           .Hints("The password for your SMTP server."))
                .AddString("Google Analytics Id", f => f
                           .Hints("The id to your google analytics account."))
                .Build();

            return(publish(schema));
        }
        private static Task CreateClientsSchemaAsync(Func <ICommand, Task> publish)
        {
            var schema =
                SchemaBuilder.Create("Clients")
                .AddString("Client Id", f => f
                           .Unique()
                           .Required()
                           .Hints("Unique id of the client."))
                .AddString("Client Name", f => f
                           .Localizable()
                           .Hints("Client display name (used for logging and consent screen)."))
                .AddString("Client Uri", f => f
                           .Localizable()
                           .Hints("URI to further information about client (used on consent screen)."))
                .AddAssets("Logo", f => f
                           .MustBeImage()
                           .Hints("URI to client logo (used on consent screen)."))
                .AddBoolean("Require Consent", f => f
                            .AsToggle()
                            .Hints("Specifies whether a consent screen is required."))
                .AddBoolean("Disabled", f => f
                            .AsToggle()
                            .Hints("Enable or disable the client."))
                .AddBoolean("Allow Offline Access", f => f
                            .AsToggle()
                            .Hints("Gets or sets a value indicating whether to allow offline access."))
                .AddTags("Allowed Grant Types", f => f
                         .WithAllowedValues("implicit", "hybrid", "authorization_code", "client_credentials")
                         .Hints("Specifies the allowed grant types."))
                .AddTags("Client Secrets", f => f
                         .Hints("Client secrets - only relevant for flows that require a secret."))
                .AddTags("Allowed Scopes", f => f
                         .Hints("Specifies the api scopes that the client is allowed to request."))
                .AddTags("Redirect Uris", f => f
                         .Hints("Specifies allowed URIs to return tokens or authorization codes to"))
                .AddTags("Post Logout Redirect Uris", f => f
                         .Hints("Specifies allowed URIs to redirect to after logout."))
                .AddTags("Allowed Cors Origins", f => f
                         .Hints("Gets or sets the allowed CORS origins for JavaScript clients."))
                .Build();

            return(publish(schema));
        }
Exemple #16
0
        public Task RunAsync(PublishTemplate publish)
        {
            var schema =
                SchemaBuilder.Create("Blogs")
                .AddString("Title", f => f
                           .Length(100)
                           .Required())
                .AddString("Slug", f => f
                           .Length(100)
                           .Required()
                           .Disabled())
                .AddString("Text", f => f
                           .Length(1000)
                           .Required()
                           .AsRichText())
                .Build();

            return(publish(schema));
        }
Exemple #17
0
        private static async Task <NamedId <DomainId> > CreateSkillsSchemaAsync(PublishTemplate publish)
        {
            var command =
                SchemaBuilder.Create("Skills")
                .AddString("Name", f => f
                           .Required()
                           .ShowInList()
                           .Hints("The name of the skill."))
                .AddString("Experience", f => f
                           .AsDropDown("Beginner", "Advanced", "Professional", "Expert")
                           .Required()
                           .ShowInList()
                           .Hints("The level of experience."))
                .Build();

            await publish(command);

            return(NamedId.Of(command.SchemaId, command.Name));
        }
Exemple #18
0
        private static async Task <NamedId <DomainId> > CreateBasicsSchemaAsync(PublishTemplate publish)
        {
            var command =
                SchemaBuilder.Create("Basics")
                .Singleton()
                .AddString("First Name", f => f
                           .Required()
                           .ShowInList()
                           .Hints("Your first name."))
                .AddString("Last Name", f => f
                           .Required()
                           .ShowInList()
                           .Hints("Your last name."))
                .AddAssets("Image", f => f
                           .MustBeImage()
                           .Hints("Your profile image."))
                .AddString("Profession", f => f
                           .AsTextArea()
                           .Required()
                           .Hints("Describe your profession."))
                .AddString("Summary", f => f
                           .AsTextArea()
                           .Hints("Write a short summary about yourself."))
                .AddString("Legal Terms", f => f
                           .AsTextArea()
                           .Hints("The terms to fulfill legal requirements."))
                .AddString("Github Link", f => f
                           .Hints("An optional link to your Github account."))
                .AddString("Blog Link", f => f
                           .Hints("An optional link to your Blog."))
                .AddString("Twitter Link", f => f
                           .Hints("An optional link to your Twitter account."))
                .AddString("LinkedIn Link", f => f
                           .Hints("An optional link to your LinkedIn  account."))
                .AddString("Email Address", f => f
                           .Hints("An optional email address to contact you."))
                .Build();

            await publish(command);

            return(NamedId.Of(command.SchemaId, command.Name));
        }
 private static async Task <NamedId <DomainId> > CreateBasicsSchemaAsync(PublishTemplate publish)
 {
     var command =
         SchemaBuilder.Create("Basics")
         .Singleton()
         .AddString("First Name", f => f
                    .Required()
                    .ShowInList()
                    .Hints("Your first name."))
         .AddString("Last Name", f => f
                    .Required()
                    .ShowInList()
                    .Hints("Your last name."))
         .AddAssets("Image", f => f
                    .Properties(p => p with
     {
         ExpectedType = AssetType.Image,
         MaxItems     = 1,
         MinItems     = 1
     })
        private Task CreateApiResourcesSchemaAsync(Func <ICommand, Task> publish)
        {
            var schema =
                SchemaBuilder.Create("API Resources")
                .AddString("Name", f => f
                           .Required()
                           .ShowInList()
                           .Hints("The unique name of the API."))
                .AddString("Display Name", f => f
                           .Localizable()
                           .Hints("The display name of the API."))
                .AddString("Description", f => f
                           .Localizable()
                           .Hints("The description name of the API."))
                .AddTags("User Claims", f => f
                         .Hints("List of accociated user claims that should be included when this resource is requested."))
                .Build();

            return(publish(schema));
        }
Exemple #21
0
        private static async Task <NamedId <DomainId> > CreatePublicationsSchemaAsync(PublishTemplate publish)
        {
            var command =
                SchemaBuilder.Create("Publications")
                .AddString("Name", f => f
                           .Required()
                           .ShowInList()
                           .Hints("The name or title of your publication."))
                .AddAssets("Cover", f => f
                           .MustBeImage()
                           .Hints("The cover of your publication."))
                .AddString("Description", f => f
                           .Hints("Describe the content of your publication."))
                .AddString("Link", f => f
                           .Hints("Optional link to your publication."))
                .Build();

            await publish(command);

            return(NamedId.Of(command.SchemaId, command.Name));
        }
        public async Task HandleAsync(CommandContext context, NextDelegate next)
        {
            await next(context);

            if (context.Command is CreateApp createApp && context.IsCompleted && createApp.Template == "custom")
            {
                var appId = NamedId.Of(createApp.AppId, createApp.Name);

                var publish = new Func <IAppCommand, Task>(command =>
                {
                    command.AppId = appId;

                    return(context.CommandBus.PublishAsync(command));
                });

                var schema =
                    SchemaBuilder.Create("Pages")
                    .AddString("Title", f => f
                               .Properties(p => p with
                {
                    MaxLength = 100
                })
        private static Task CreateAuthenticationSchemeSchemaAsync(Func <ICommand, Task> publish)
        {
            var schema =
                SchemaBuilder.Create("Authentication Schemes")
                .AddString("Provider", f => f
                           .AsDropDown("Facebook", "Google", "Microsoft", "Twitter")
                           .Unique()
                           .Required()
                           .ShowInList()
                           .Hints("The name and type of the provider."))
                .AddString("Client Id", f => f
                           .Required()
                           .ShowInList()
                           .Hints("The client id that you must configure at the external provider."))
                .AddString("Client Secret", f => f
                           .Required()
                           .Hints("The client secret that you must configure at the external provider."))
                .AddTags("Scopes", f => f
                         .Hints("Additional scopes you want from the provider."))
                .Build();

            return(publish(schema));
        }
Exemple #24
0
        public static ISchema CreateSchema(IEnumerable <DocumentNode> documents)
        {
            var schemaBuilder = new SchemaBuilder();

            schemaBuilder.AddDirectiveType <FilterableDirectiveType>();
            schemaBuilder.AddDirectiveType <FilteringDirectiveType>();
            schemaBuilder.AddDirectiveType <SortableDirectiveType>();
            schemaBuilder.AddDirectiveType <SortingDirectiveType>();
            schemaBuilder.AddDirectiveType <OperationDirectiveType>();
            schemaBuilder.AddDirectiveType <PagingDirectiveType>();
            schemaBuilder.AddDirectiveType <TypeNameDirectiveType>();

            schemaBuilder.AddDirectiveType <RelationshipDirectiveType>();

            schemaBuilder.ModifyOptions(o => o.StrictValidation = false);
            schemaBuilder.Use(next => next);

            foreach (DocumentNode?document in documents)
            {
                schemaBuilder.AddDocument(document);
            }

            return(schemaBuilder.Create());
        }
Exemple #25
0
        protected override async Task PreExecuteAsyncInternal(IAsyncContext asyncContext, RecordConfiguration configuration, CancellationToken cancellationToken)
        {
            SchemaBuilder schemaBuilder;
            ISchema       schema;

            string line;

            string[] fieldNames;

            if ((object)asyncContext == null)
            {
                throw new ArgumentNullException(nameof(asyncContext));
            }

            if ((object)configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            this.AssertValidConfiguration();

            schemaBuilder = SchemaBuilder.Create();

            await TextWriter.WriteLineAsync("Enter list of schema field names separated by pipe character: ");

            line = await TextReader.ReadLineAsync();

            if (!SolderFascadeAccessor.DataTypeFascade.IsNullOrEmpty(line))
            {
                fieldNames = line.Split('|');

                if ((object)fieldNames == null || fieldNames.Length <= 0)
                {
                    await TextWriter.WriteLineAsync("List of schema field names was invalid; using default (blank).");

                    schemaBuilder.AddField(string.Empty, typeof(string), false, true);
                }
                else
                {
                    for (long fieldIndex = 0; fieldIndex < fieldNames.Length; fieldIndex++)
                    {
                        string fieldName;

                        fieldName = fieldNames[fieldIndex];

                        if ((fieldName ?? string.Empty).Trim() == string.Empty)
                        {
                            continue;
                        }

                        schemaBuilder.AddField(fieldName, typeof(string), false, true);
                    }

                    await TextWriter.WriteLineAsync(string.Format("Building KEY schema: '{0}'", string.Join(" | ", fieldNames)));
                }
            }

            if (!asyncContext.LocalState.TryGetValue(this, out IDictionary <string, object> localState))
            {
                localState = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase);
                asyncContext.LocalState.Add(this, localState);
            }

            schema = schemaBuilder.Build();

            if ((object)schema == null)
            {
                throw new SyncPremException(nameof(schema));
            }

            localState.Add(Constants.ContextComponentScopedSchema, schema);
        }
        private async Task CreateUsersSchemaAsync(Func <ICommand, Task> publish)
        {
            var schema =
                SchemaBuilder.Create("Users")
                .AddString("Username", f => f
                           .Required()
                           .ShowInList()
                           .Hints("The unique username to login."))
                .AddString("Email", f => f
                           .Pattern(@"^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\\\.[a-zA-Z0-9-]+)*$", "Must be an email address.")
                           .Required()
                           .ShowInList()
                           .Hints("The unique email to login."))
                .AddString("Phone Number", f => f
                           .Hints("Phone number of the user."))
                .AddTags("Roles", f => f
                         .Hints("The roles of the user."))
                .AddJson("Claims", f => f
                         .Hints("The claims of the user."))
                .AddBoolean("Email Confirmed", f => f
                            .AsToggle()
                            .Hints("Indicates if the email is confirmed."))
                .AddBoolean("Phone Number Confirmed", f => f
                            .AsToggle()
                            .Hints("Indicates if the phone number is confirmed."))
                .AddBoolean("LockoutEnabled", f => f
                            .AsToggle()
                            .Hints("Toggle on to lock out the user."))
                .AddDateTime("Lockout End Date Utc", f => f
                             .AsDateTime()
                             .Disabled()
                             .Hints("Indicates when the lockout ends."))
                .AddTags("Login Keys", f => f
                         .Disabled()
                         .Hints("Login information for querying."))
                .AddJson("Logins", f => f
                         .Disabled()
                         .Hints("Login information."))
                .AddJson("Tokens", f => f
                         .Disabled()
                         .Hints("Login tokens."))
                .AddNumber("Access Failed Count", f => f
                           .Disabled()
                           .Hints("The number of failed login attempts."))
                .AddString("Password Hash", f => f
                           .Disabled()
                           .Hints("The hashed password."))
                .AddString("Normalized Email", f => f
                           .Disabled()
                           .Hints("The normalized email for querying."))
                .AddString("Normalized Username", f => f
                           .Disabled()
                           .Hints("The normalized user name for querying."))
                .AddString("Security Stamp", f => f
                           .Disabled()
                           .Hints("Internal security stamp"))
                .Build();

            await publish(schema);

            var schemaId = NamedId.Of(schema.SchemaId, schema.Name);

            await publish(new ConfigureScripts
            {
                SchemaId     = schemaId.Id,
                ScriptCreate = NormalizeScript,
                ScriptUpdate = NormalizeScript
            });
        }
Exemple #27
0
        protected override async Task PreExecuteAsyncInternal(IAsyncContext asyncContext, RecordConfiguration configuration, CancellationToken cancellationToken)
        {
            SchemaBuilder   schemaBuilder;
            ISchema         schema;
            IList <ISchema> schemas;

            IAsyncEnumerable <IAdoNetStreamingResult> results;
            IAsyncEnumerator <IAdoNetStreamingResult> resultz;

            IAsyncEnumerable <IPayload> records;
            IAsyncEnumerator <IPayload> recordz;

            IEnumerable <DbParameter> dbParameters;

            if ((object)asyncContext == null)
            {
                throw new ArgumentNullException(nameof(asyncContext));
            }

            if ((object)configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            this.AssertValidConfiguration();

            AdoNetConnectorSpecificConfiguration fsConfig = this.Configuration.StageSpecificConfiguration;

            this.SourceUnitOfWork = fsConfig.GetUnitOfWork();

            if (fsConfig.PreExecuteCommand != null &&
                !SolderFascadeAccessor.DataTypeFascade.IsNullOrWhiteSpace(fsConfig.PreExecuteCommand.CommandText))
            {
                dbParameters = fsConfig.PreExecuteCommand.GetDbDataParameters(this.SourceUnitOfWork);

                results = this.SourceUnitOfWork.ExecuteResultsAsync(fsConfig.PreExecuteCommand.CommandType ?? CommandType.Text,
                                                                    fsConfig.PreExecuteCommand.CommandText,
                                                                    dbParameters, cancellationToken);

                if ((object)results == null)
                {
                    throw new SyncPremException(nameof(results));
                }

                await results.ForceAsyncEnumeration(cancellationToken);                 // force execution
            }

            // execute schema only
            if (fsConfig.ExecuteCommand != null &&
                !SolderFascadeAccessor.DataTypeFascade.IsNullOrWhiteSpace(fsConfig.ExecuteCommand.CommandText))
            {
                dbParameters = fsConfig.ExecuteCommand.GetDbDataParameters(this.SourceUnitOfWork);

                results = this.SourceUnitOfWork.ExecuteSchemaResultsAsync(fsConfig.ExecuteCommand.CommandType ?? CommandType.Text,
                                                                          fsConfig.ExecuteCommand.CommandText,
                                                                          dbParameters, cancellationToken);

                if ((object)results == null)
                {
                    throw new SyncPremException(nameof(results));
                }

                resultz = results.GetEnumerator();

                if ((object)resultz == null)
                {
                    throw new SyncPremException(nameof(resultz));
                }

                schemas = new List <ISchema>();

                while (await resultz.MoveNext(cancellationToken))
                {
                    IAdoNetStreamingResult result = resultz.Current;

                    records = result.AsyncRecords;

                    if ((object)records == null)
                    {
                        throw new SyncPremException(nameof(results));
                    }

                    recordz = records.GetEnumerator();

                    if ((object)recordz == null)
                    {
                        throw new SyncPremException(nameof(recordz));
                    }

                    schemaBuilder = SchemaBuilder.Create();

                    while (await recordz.MoveNext(cancellationToken))
                    {
                        IPayload record = recordz.Current;

                        string fieldName;
                        Type   fieldType;
                        bool   isKey;
                        bool   isNullable;

                        fieldName  = (string)record[nameof(DbColumn.ColumnName)];
                        fieldType  = (Type)record[nameof(DbColumn.DataType)];
                        isKey      = (bool?)record[nameof(DbColumn.IsKey)] ?? false;
                        isNullable = (bool?)record[nameof(DbColumn.AllowDBNull)] ?? true;

                        // TODO ensure nullable type
                        schemaBuilder.AddField(fieldName, fieldType, isNullable, isKey);
                    }

                    schema = schemaBuilder.Build();

                    if ((object)schema == null)
                    {
                        throw new SyncPremException(nameof(schema));
                    }

                    schemas.Add(schema);
                }

                if (!asyncContext.LocalState.TryGetValue(this, out IDictionary <string, object> localState))
                {
                    localState = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase);
                    asyncContext.LocalState.Add(this, localState);
                }

                localState.Add(Constants.ContextComponentScopedSchema, schemas);
            }
        }
        protected override void PreExecuteInternal(ISyncContext context, RecordConfiguration configuration)
        {
            SchemaBuilder schemaBuilder;
            ISchema       schema;
            IEnumerable <TTextualFieldSpec> headers;
            TTextualSpec spec;

            if ((object)context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if ((object)configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            this.AssertValidConfiguration();

            TTextualConnectorSpecificConfiguration fsConfig = this.Configuration.StageSpecificConfiguration;

            spec = fsConfig.TextualConfiguration.MapToSpec();

            if ((object)spec == null)
            {
                throw new SyncPremException(nameof(spec));
            }

            this.TextualReader = this.CreateTextualReader(new StreamReader(File.Open(fsConfig.TextualFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)), spec);

            headers = this.TextualReader.ReadHeaderFields();

            if ((object)headers == null)
            {
                throw new SyncPremException(nameof(headers));
            }

            if (!context.LocalState.TryGetValue(this, out IDictionary <string, object> localState))
            {
                localState = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase);
                context.LocalState.Add(this, localState);
            }

            schemaBuilder = SchemaBuilder.Create();

            headers.ForceEnumeration();

            foreach (TTextualFieldSpec header in spec.TextualHeaderSpecs)
            {
                schemaBuilder.AddField(header.FieldTitle, header.FieldType.ToClrType(), header.IsFieldRequired, header.IsFieldIdentity);
            }

            schema = schemaBuilder.Build();

            if ((object)schema == null)
            {
                throw new SyncPremException(nameof(schema));
            }

            localState.Add(Constants.ContextComponentScopedSchema, schema);
        }
Exemple #29
0
        public static void Create(string geodatabasePath)
        {
            // Create a File Geodatabase with the given path
            Geodatabase weatherGDB = SchemaBuilder.CreateGeodatabase(new FileGeodatabaseConnectionPath(new Uri(geodatabasePath)));

            // This static helper routine creates a FieldDescription for a GlobalID field with default values
            FieldDescription globalIDFieldDescription = FieldDescription.CreateGlobalIDField();

            // This static helper routine creates a FieldDescription for an ObjectID field with default values
            FieldDescription objectIDFieldDescription = FieldDescription.CreateObjectIDField();

            // Create a FieldDescription for the minimal temperature field
            FieldDescription minTempFieldDescription = new FieldDescription("Min", FieldType.Double)
            {
                AliasName = "Minimum temperatuur"
            };

            // Create a FieldDescription for the maximum temperature field
            FieldDescription maxTempFieldDescription = new FieldDescription("Max", FieldType.Double)
            {
                AliasName = "Maximum temperatuur"
            };

            // This static helper routine creates a string field
            FieldDescription weatherTypeFieldDescription = FieldDescription.CreateStringField("WeatherType", 512);

            weatherTypeFieldDescription.AliasName = "Weertype";

            // This static helper routine creates a string field
            FieldDescription dayOfWeekFieldDescription = FieldDescription.CreateStringField("Day", 25);

            dayOfWeekFieldDescription.AliasName = "Dag van de week";

            // Assemble a list of all of our field descriptions
            List <FieldDescription> fieldDescriptions = new List <FieldDescription>()
            {
                globalIDFieldDescription,
                objectIDFieldDescription,
                dayOfWeekFieldDescription,
                minTempFieldDescription,
                maxTempFieldDescription,
                weatherTypeFieldDescription
            };

            // Create a TableDescription object to describe the table to create
            TableDescription tableDescription = new TableDescription("Vooruitzichten", fieldDescriptions);

            // Create a SchemaBuilder object
            SchemaBuilder schemaBuilder = new SchemaBuilder(weatherGDB);

            // Add the creation of the weatherforecast featureclass to our list of DDL tasks
            schemaBuilder.Create(tableDescription);

            // Execute the DDL
            bool success = schemaBuilder.Build();

            // Inspect error messages, and show an error.
            if (!success)
            {
                IReadOnlyList <string> errorMessages = schemaBuilder.ErrorMessages;
                foreach (string errorMessage in errorMessages)
                {
                    MessageBox.Show($"Fout bij het aanmaken {errorMessage}");
                }
            }
        }
        protected override async void OnClick()
        {
            var selectedLayer = MapView.Active.GetSelectedLayers().FirstOrDefault();

            if (selectedLayer == null || !(selectedLayer is FeatureLayer))
            {
                MessageBox.Show("You have to select a feature layer.  The selected layer's database connection is then used to create the new FeatureClass.");
                return;
            }
            var selectedFeatureLayer = selectedLayer as FeatureLayer;

            await QueuedTask.Run(() =>
            {
                var selectedLayerTable = selectedFeatureLayer.GetTable();

                var testName = $@"Point{DateTime.Now:HHmmss}";
                var hasZ     = false;
                var hasM     = false;
                // Create a ShapeDescription object
                var shapeDescription = new ShapeDescription(GeometryType.Point, SpatialReferences.WebMercator)
                {
                    HasM = hasM,
                    HasZ = hasZ
                };
                var objectIDFieldDescription = new ArcGIS.Core.Data.DDL.FieldDescription("ObjectID", FieldType.OID);
                var stringFieldDescription   = new ArcGIS.Core.Data.DDL.FieldDescription("TheString", FieldType.String);
                var intFieldDescription      = new ArcGIS.Core.Data.DDL.FieldDescription("TheInteger", FieldType.Integer);
                var dblFieldDescription      = new ArcGIS.Core.Data.DDL.FieldDescription("TheDouble", FieldType.Double)
                {
                    Precision = 9,
                    Scale     = 5
                };
                var dateFieldDescription = new ArcGIS.Core.Data.DDL.FieldDescription("TheDate", FieldType.Date);

                using (var geoDb = selectedLayerTable.GetDatastore() as Geodatabase)
                {
                    var fcName = $@"{testName}";
                    try
                    {
                        // Assemble a list of all of our field descriptions
                        var fieldDescriptions = new List <ArcGIS.Core.Data.DDL.FieldDescription>()
                        {
                            objectIDFieldDescription,
                            stringFieldDescription,
                            intFieldDescription,
                            dblFieldDescription,
                            dateFieldDescription
                        };
                        // Create a FeatureClassDescription object to describe the feature class
                        // that we want to create
                        var fcDescription =
                            new FeatureClassDescription(fcName, fieldDescriptions, shapeDescription);

                        // Create a SchemaBuilder object
                        SchemaBuilder schemaBuilder = new SchemaBuilder(geoDb);

                        // Add the creation of the new feature class to our list of DDL tasks
                        schemaBuilder.Create(fcDescription);

                        // Execute the DDL
                        bool success = schemaBuilder.Build();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show($@"Exception: {ex}");
                    }
                }
            });
        }