Ejemplo n.º 1
0
        /// <summary>
        /// Configures the subscription name when consuming form Azure ServiceBus topic.
        /// Not applicable when consuming from Azure ServiceBus queue.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="subscriptionName"></param>
        /// <returns></returns>
        public static RequestResponseBuilder SubscriptionName(this RequestResponseBuilder builder, string subscriptionName)
        {
            AssertIsTopicForSubscriptionName(builder.Settings);

            builder.Settings.SetSubscriptionName(subscriptionName);
            return(builder);
        }
Ejemplo n.º 2
0
        public static RequestResponseBuilder ReplyToQueue(this RequestResponseBuilder builder, string queue, Action <RequestResponseBuilder> builderConfig)
        {
            var b = builder.ReplyToQueue(queue);

            builderConfig(b);
            return(b);
        }
        /// <summary>
        /// Checkpoint every N-th processed message.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="numberOfMessages"></param>
        /// <returns></returns>
        public static RequestResponseBuilder CheckpointEvery(this RequestResponseBuilder builder, int numberOfMessages)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.Settings.Properties[CheckpointSettings.CheckpointCount] = numberOfMessages;
            return(builder);
        }
        /// <summary>
        /// Configures the Kafka consumer group.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="group"></param>
        /// <returns></returns>
        public static RequestResponseBuilder Group(this RequestResponseBuilder builder, string group)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.Settings.SetGroup(group);
            return(builder);
        }
        /// <summary>
        /// Checkpoint after T elapsed time.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="duration"></param>
        /// <returns></returns>
        public static RequestResponseBuilder CheckpointAfter(this RequestResponseBuilder builder, TimeSpan duration)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.Settings.Properties[CheckpointSettings.CheckpointDuration] = duration;
            return(builder);
        }
Ejemplo n.º 6
0
        public static RequestResponseBuilder ReplyToQueue(this RequestResponseBuilder builder, string queue)
        {
            if (builder is null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (queue is null)
            {
                throw new ArgumentNullException(nameof(queue));
            }

            builder.Settings.Topic = queue;
            builder.Settings.SetKind(PathKind.Queue);
            return(builder);
        }
        /// <summary>
        /// Configures the subscription name when consuming form Azure ServiceBus topic.
        /// Not applicable when consuming from Azure ServiceBus queue.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="subscriptionName"></param>
        /// <returns></returns>
        public static RequestResponseBuilder SubscriptionName(this RequestResponseBuilder builder, string subscriptionName)
        {
            if (builder is null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (subscriptionName is null)
            {
                throw new ArgumentNullException(nameof(subscriptionName));
            }

            AssertIsTopicForSubscriptionName(builder.Settings);

            builder.Settings.SetSubscriptionName(subscriptionName);
            return(builder);
        }
        public void BuildsProperSettings()
        {
            // arrange
            var topic    = "topic";
            var timeout  = TimeSpan.FromSeconds(16);
            var settings = new RequestResponseSettings();

            // act
            var subject = new RequestResponseBuilder(settings);

            subject.DefaultTimeout(timeout);
            subject.ReplyToTopic(topic);

            // assert
            settings.Timeout.Should().Be(timeout);
            settings.Topic.Should().Be(topic);
        }
Ejemplo n.º 9
0
        public static RequestResponseBuilder ReplyToQueue(this RequestResponseBuilder builder, string queue, Action <RequestResponseBuilder> builderConfig)
        {
            if (builder is null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (queue is null)
            {
                throw new ArgumentNullException(nameof(queue));
            }
            if (builderConfig is null)
            {
                throw new ArgumentNullException(nameof(builderConfig));
            }

            var b = builder.ReplyToQueue(queue);

            builderConfig(b);
            return(b);
        }
Ejemplo n.º 10
0
        public void ResendMobileCode(Account account)
        {
            string verificationCode = VerificationCodeGenerator.GenerateNewVerificationCode();
            bool isSuccessful = false;
            if (!Configuration.IsMobileMock)
            {
                var helper = new RequestResponseBuilder();
                string url =
                    string.Format(
                        Configuration.MobileVerificationBaseUrl +
                        Configuration.MobileVerificationFormat,
                        account.Mobile, verificationCode);

                WebRequest request = helper.CreateRequest<WebRequest>(url, null);
                string responseString;

                WebResponse response = helper.GetResponse(request, out responseString);

                if (response != null && !string.IsNullOrEmpty(responseString))
                {
                    isSuccessful = true;
                }
            }
            else
            {
                verificationCode = "123456";
                isSuccessful = true;
            }

            if (isSuccessful)
            {
                ICodeVerificationDataProvider codeVerificationDataProvider =
                    CodeVerificationDataProviderFactory.CreateCodeVerificationDataProvider();
                if (codeVerificationDataProvider.Remove(account.AccountId, Type))
                {
                    codeVerificationDataProvider.SaveNewCode(account.AccountId, verificationCode, Type);
                }
            }
        }
Ejemplo n.º 11
0
 public bool Validate(string challenge, string ipAddress, string response)
 {
     if (challenge == "test" && response == "test")
         return true;
     try
     {
         string postValue = string.Format("privatekey={0}&remoteip={1}&challenge={2}&response={3}",
                                          Configuration.ReCaptchaPrivateKey, ipAddress, challenge, response);
         using (var connector = new RequestResponseBuilder())
         {
             WebRequest request = connector.CreateRequest<HttpWebRequest>(Configuration.ReCaptchaUrl, postValue,
                                                                          "POST");
             string responsesString;
             connector.GetResponse(request, out responsesString);
             if (!string.IsNullOrEmpty(responsesString) && responsesString.Contains("true"))
                 return true;
         }
     }
     catch (Exception ex)
     {
         Logger.LogException(ex, Source, "SendRegistrationEmail", Severity.Major);
     }
     return false;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Checkpoint after T elapsed time.
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="duration"></param>
 /// <returns></returns>
 public static RequestResponseBuilder CheckpointAfter(this RequestResponseBuilder builder, TimeSpan duration)
 {
     builder.Settings.Properties[CheckpointSettings.CheckpointDuration] = duration;
     return(builder);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Checkpoint every N-th processed message.
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="numberOfMessages"></param>
 /// <returns></returns>
 public static RequestResponseBuilder CheckpointEvery(this RequestResponseBuilder builder, int numberOfMessages)
 {
     builder.Settings.Properties[CheckpointSettings.CheckpointCount] = numberOfMessages;
     return(builder);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Configures the Kafka consumer group.
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="group"></param>
 /// <returns></returns>
 public static RequestResponseBuilder Group(this RequestResponseBuilder builder, string group)
 {
     builder.Settings.SetGroup(group);
     return(builder);
 }
Ejemplo n.º 15
0
 public static RequestResponseBuilder ReplyToQueue(this RequestResponseBuilder builder, string queue)
 {
     builder.Settings.Topic = queue;
     builder.Settings.SetKind(PathKind.Queue);
     return(builder);
 }