Exemplo n.º 1
0
        /// <summary>
        /// Configures replication writebacks to Snowflake
        /// </summary>
        /// <param name="request"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public override Task <ConfigureReplicationResponse> ConfigureReplication(ConfigureReplicationRequest request,
                                                                                 ServerCallContext context)
        {
            Logger.SetLogPrefix("configure_replication");
            Logger.Info($"Configuring write for schema name {request.Schema.Name}...");

            var schemaJson = Replication.GetSchemaJson();
            var uiJson     = Replication.GetUIJson();

            try
            {
                var errors = new List <string>();
                if (!string.IsNullOrWhiteSpace(request.Form.DataJson))
                {
                    // check for config errors
                    var replicationFormData = JsonConvert.DeserializeObject <ConfigureReplicationFormData>(request.Form.DataJson);

                    errors = replicationFormData.ValidateReplicationFormData();
                }

                return(Task.FromResult(new ConfigureReplicationResponse
                {
                    Form = new ConfigurationFormResponse
                    {
                        DataJson = request.Form.DataJson,
                        Errors = { errors },
                        SchemaJson = schemaJson,
                        UiJson = uiJson,
                        StateJson = request.Form.StateJson
                    }
                }));
            }
            catch (Exception e)
            {
                Logger.Error(e, e.Message, context);
                return(Task.FromResult(new ConfigureReplicationResponse
                {
                    Form = new ConfigurationFormResponse
                    {
                        DataJson = request.Form.DataJson,
                        Errors = { e.Message },
                        SchemaJson = schemaJson,
                        UiJson = uiJson,
                        StateJson = request.Form.StateJson
                    }
                }));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Configures replication writebacks to Sisense
        /// </summary>
        /// <param name="request"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public override Task <ConfigureReplicationResponse> ConfigureReplication(ConfigureReplicationRequest request,
                                                                                 ServerCallContext context)
        {
            Logger.Info("Configuring write...");

            var schemaJson = Replication.GetSchemaJson();
            var uiJson     = Replication.GetUIJson();

            try
            {
                return(Task.FromResult(new ConfigureReplicationResponse
                {
                    Form = new ConfigurationFormResponse
                    {
                        DataJson = request.Form.DataJson,
                        Errors = { },
                        SchemaJson = schemaJson,
                        UiJson = uiJson,
                        StateJson = request.Form.StateJson
                    }
                }));
            }
            catch (Exception e)
            {
                Logger.Error(e.Message);
                return(Task.FromResult(new ConfigureReplicationResponse
                {
                    Form = new ConfigurationFormResponse
                    {
                        DataJson = request.Form.DataJson,
                        Errors = { e.Message },
                        SchemaJson = schemaJson,
                        UiJson = uiJson,
                        StateJson = request.Form.StateJson
                    }
                }));
            }
        }