public void SessionValidationController_ValidateRequest_KnownUserExpired_Test()
        {
            KnownUserFactory.Reset(false);
            KnownUserFactory.Configure(SharedSecreteEventKey);

            int    expectedPlaceInqueue  = 7810;
            Guid   expectedQueueId       = Guid.NewGuid();
            string placeInQueueEncrypted = Hashing.EncryptPlaceInQueue(expectedPlaceInqueue);
            long   unixTimestamp         =
                (long)(DateTime.UtcNow.AddMinutes(-4) - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds;

            string urlNoHash = "http://q.queue-it.net/inqueue.aspx?c=somecust&e=someevent&q=" + expectedQueueId +
                               "&p=" + placeInQueueEncrypted + "&ts=" + unixTimestamp + "&h=";
            Uri hashUri = new Uri(urlNoHash);

            string hash        = Hashing.GenerateMD5Hash(hashUri.AbsoluteUri, SharedSecreteEventKey);
            string querystring = "c=somecust&e=someevent&q=" + expectedQueueId +
                                 "&p=" + placeInQueueEncrypted + "&ts=" + unixTimestamp + "&h=" + hash;
            string url = urlNoHash + hash;

            HttpRequest httpRequest = new HttpRequest("inqueue.aspx", url, querystring);

            HttpContext.Current = new HttpContext(httpRequest, new HttpResponse(null));

            SessionValidationController.ValidateRequest(
                QueueFactory.CreateQueue("somecust", "someevent"));
        }
Пример #2
0
        public ActionResult Landing(string t)
        {
            IQueue queue = QueueFactory.CreateQueue("advanced");

            ViewBag.QueueUrl = queue.GetQueueUrl(t);

            return(View());
        }
Пример #3
0
        public void QueueFactory_GetLandingPageUrl_Test()
        {
            IQueue queue = QueueFactory.CreateQueue("customerid", "eventid");

            string actualLandingPageUrl = queue.GetLandingPageUrl();

            Assert.IsNull(actualLandingPageUrl);
        }
Пример #4
0
        static void Main(string[] args)
        {
            // Note! Database must be configured for memory optimized tables before queue creation

            // creating queue
            var factory = new QueueFactory(connectionString);

            factory.DeleteQueue("MyQueue");
            factory.CreateQueue("MyQueue");

            // connecting to queue
            var client = QueueClient.Create(connectionString, "MyQueue");

            // creating subscription
            client.CreateSubscription("MySubscription");

            // creating writer
            var writer = client.CreateWriter();

            // writing message to queue
            byte[] message = { 0x01, 0x02, 0x03 };
            var    id      = writer.Write(message);

            // writing batch of messages to queue
            byte[][] batch =
            {
                new byte[] { 0x01, 0x02, 0x03 },
                new byte[] { 0x01, 0x02, 0x04 },
                new byte[] { 0x01, 0x02, 0x05 },
            };

            var ids = writer.WriteMany(batch, true);

            writer.Close();

            // creating reader for subscription
            var reader = client.CreateReader("MySubscription");

            // reading 1000 messages from subscription
            var messages = reader.Read(1000);

            // making massages completed after handling
            reader.Complete();

            reader.Close();

            // another way to handle messages - using AutoReader
            AutoReading().Wait();

            // deleting subscription
            client.DeleteSubscription("MySubscription");

            // deleting queue
            factory.DeleteQueue("MyQueue");

            Console.ReadKey();
        }
Пример #5
0
        public void QueueFactory_CreateQueue_Constructor_Test()
        {
            string expectedCustomerId = "customerid";
            string expectedEventId    = "eventid";

            IQueue queue = QueueFactory.CreateQueue(expectedCustomerId, expectedEventId);

            Assert.AreEqual(expectedCustomerId, queue.CustomerId);
            Assert.AreEqual(expectedEventId, queue.EventId);
        }
Пример #6
0
        public void QueueFactory_GetLandingPageUrl_Configuration_Test()
        {
            string expectedLandingPageUrl = "http://www.mysplitpage.com/";

            IQueue queue = QueueFactory.CreateQueue("queue1");

            string actualLandingPageUrl = queue.GetLandingPageUrl();

            Assert.AreEqual(expectedLandingPageUrl, actualLandingPageUrl);
        }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            UriBuilder targetUrl = new UriBuilder(Request.Url);

            targetUrl.Path = "LinkTarget.aspx";

            IQueue queue = QueueFactory.CreateQueue("link");

            hlQueue.NavigateUrl = queue.GetQueueUrl(targetUrl.Uri.AbsoluteUri);
        }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IValidateResult result = SessionValidationController.ValidateRequest(
                QueueFactory.CreateQueue("ticketania", Request.QueryString["eventid"]));
            var accepted = result as AcceptedConfirmedResult;

            if (accepted != null)
            {
                accepted.Cancel();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // Never perform queue validation on error handling pages (e.g. Error.aspx) because it will cause users to get looped arround.
            // The recommended approach is to display a cancel link to users as shown below.

            string queueName = Request.QueryString["queuename"];

            IQueue queue = QueueFactory.CreateQueue(queueName);

            hlQueue.NavigateUrl = queue.GetCancelUrl(Request.QueryString["t"]);
        }
Пример #10
0
        public void QueueFactory_GetLandingPageUrl_TargetUrl_Test()
        {
            string expectedTarget         = "http://target.url/?someprop=somevalue&another=value";
            string expectedLandingPageUrl = "http://www.mysplitpage.com/?t=" + HttpUtility.UrlEncode(expectedTarget);

            IQueue queue = QueueFactory.CreateQueue("queue1");

            string actualLandingPageUrl = queue.GetLandingPageUrl(expectedTarget);

            Assert.AreEqual(expectedLandingPageUrl, actualLandingPageUrl);
        }
Пример #11
0
        public void QueueFactory_CreateQueue_Constructor_Configuration_Named_Test()
        {
            QueueFactory.Reset();

            string expectedCustomerId = "queue1customerid";
            string expectedEventId    = "queue1eventid";

            IQueue queue = QueueFactory.CreateQueue("queue1");

            Assert.AreEqual(expectedCustomerId, queue.CustomerId);
            Assert.AreEqual(expectedEventId, queue.EventId);
        }
Пример #12
0
        //
        // GET: /Link/

        public ActionResult Index()
        {
            UriBuilder targetUrl = new UriBuilder(Request.Url);

            targetUrl.Path = "/Link/Target";

            IQueue queue = QueueFactory.CreateQueue("link");

            ViewBag.QueueUrl = queue.GetQueueUrl(targetUrl.Uri.AbsoluteUri);

            return(View());
        }
Пример #13
0
        public void QueueFactory_GetCancelUrl_Ssl_Test()
        {
            string expectedCustomerId = "customerid";
            string expectedEventId    = "eventid";

            string expectedCancelUrl =
                "https://" + expectedCustomerId + ".queue-it.net/cancel.aspx?c=" + expectedCustomerId + "&e=" + expectedEventId;

            IQueue queue = QueueFactory.CreateQueue(expectedCustomerId, expectedEventId);

            string actualQueueUrl = queue.GetCancelUrl(sslEnabled: true);

            Assert.AreEqual(expectedCancelUrl, actualQueueUrl);
        }
Пример #14
0
        public void QueueFactory_GetQueueUrl_Test()
        {
            string expectedCustomerId = "customerid";
            string expectedEventId    = "eventid";

            string expectedQueueUrl =
                "http://" + expectedCustomerId + ".queue-it.net/?c=" + expectedCustomerId + "&e=" + expectedEventId;

            IQueue queue = QueueFactory.CreateQueue(expectedCustomerId, expectedEventId);

            string actualQueueUrl = queue.GetQueueUrl();

            Assert.IsTrue(actualQueueUrl.StartsWith(expectedQueueUrl));
        }
Пример #15
0
        public void QueueFactory_GetCancelUrl_DomainAlias_Test()
        {
            string expectedCustomerId = "customerid";
            string expectedEventId    = "eventid";

            string expectedCancelUrl =
                "http://vent.queue-it.net/cancel.aspx?c=" + expectedCustomerId + "&e=" + expectedEventId;

            IQueue queue = QueueFactory.CreateQueue(expectedCustomerId, expectedEventId);

            string actualQueueUrl = queue.GetCancelUrl(domainAlias: "vent.queue-it.net");

            Assert.AreEqual(expectedCancelUrl, actualQueueUrl);
        }
Пример #16
0
        public void QueueFactory_GetQueueUrl_TargetUrl_Test()
        {
            string expectedCustomerId = "customerid";
            string expectedEventId    = "eventid";
            string expectedTarget     = "http://target.url/?someprop=somevalue&another=value";

            string expectedQueueUrl = "&t=" + HttpUtility.UrlEncode(expectedTarget);

            IQueue queue = QueueFactory.CreateQueue(expectedCustomerId, expectedEventId);

            string actualQueueUrl = queue.GetQueueUrl(expectedTarget);

            Assert.IsTrue(actualQueueUrl.Contains(expectedQueueUrl));
        }
Пример #17
0
        public void QueueFactory_GetQueueUrl_LayoutName_Test()
        {
            string expectedCustomerId = "customerid";
            string expectedEventId    = "eventid";
            string expectedLayoutName = "Some Other Layout";

            string expectedQueueUrl = "&l=" + HttpUtility.UrlEncode(expectedLayoutName);

            IQueue queue = QueueFactory.CreateQueue(expectedCustomerId, expectedEventId);

            string actualQueueUrl = queue.GetQueueUrl(layoutName: expectedLayoutName);

            Assert.IsTrue(actualQueueUrl.Contains(expectedQueueUrl));
        }
Пример #18
0
        public void QueueFactory_GetQueueUrl_Version_Test()
        {
            string expectedCustomerId = "customerid";
            string expectedEventId    = "eventid";
            string expectedVersion    = "c" + typeof(Queue).Assembly.GetName().Version.ToString();

            string expectedQueueUrl = "&ver=" + expectedVersion;

            IQueue queue = QueueFactory.CreateQueue(expectedCustomerId, expectedEventId);

            string actualQueueUrl = queue.GetQueueUrl();

            Assert.IsTrue(actualQueueUrl.Contains(expectedQueueUrl));
        }
Пример #19
0
        public void QueueFactory_GetQueueUrl_Culture_Test()
        {
            string expectedCustomerId = "customerid";
            string expectedEventId    = "eventid";
            string expectedCulture    = "en-US";

            string expectedQueueUrl =
                "&cid=" + expectedCulture;

            IQueue queue = QueueFactory.CreateQueue(expectedCustomerId, expectedEventId);

            string actualQueueUrl = queue.GetQueueUrl(language: new CultureInfo(expectedCulture));

            Assert.IsTrue(actualQueueUrl.Contains(expectedQueueUrl));
        }
Пример #20
0
        public void QueueFactory_GetQueueUrl_DomainAlias_Test()
        {
            string expectedCustomerId  = "customerid";
            string expectedEventId     = "eventid";
            string expectedDomainAlias = "my.queue.url";

            string expectedQueueUrl =
                "http://" + expectedDomainAlias + "/";

            IQueue queue = QueueFactory.CreateQueue("customerId", "eventId");

            string actualQueueUrl = queue.GetQueueUrl(domainAlias: expectedDomainAlias);

            Assert.IsTrue(actualQueueUrl.StartsWith(expectedQueueUrl));
        }
Пример #21
0
        public void QueueFactory_GetLandingPageUrl_IncludeTargetUrl_Test()
        {
            string expectedTarget         = "http://target.url/?someprop=somevalue&another=value";
            string expectedLandingPageUrl = "http://www.mysplitpage.com/?t=" + HttpUtility.UrlEncode(expectedTarget);

            HttpContext.Current = new HttpContext(
                new HttpRequest("", expectedTarget, "someprop=somevalue&another=value"),
                new HttpResponse(null));

            IQueue queue = QueueFactory.CreateQueue("queue1");

            string actualLandingPageUrl = queue.GetLandingPageUrl(true);

            Assert.AreEqual(expectedLandingPageUrl, actualLandingPageUrl);
        }
Пример #22
0
        public void execute_tasks_1_worker_100_Iterations()
        {
            int          itterationCount = 100;
            const string queueName       = "execute_tasks_1_worker_100_Iterations";
            int          workerscount    = 1;
            var          executer        = new MockBehaviorTaskExecution();
            var          queue           = QueueFactory.CreateQueue(workerscount, executer, queueName);

            for (int i = 1; i <= itterationCount; i++)
            {
                queue.AddTask(QueueTask.Create(0, i.ToString()));
            }
            WaitTast(100);
            Assert.AreEqual(itterationCount.ToString(), executer.ExecutionTaskCount.ToString());
        }
Пример #23
0
        /// <summary>
        /// When overridden it provides full control of generating the validation result.
        /// E.g. by looking up the Customer and Event ID in a database
        /// </summary>
        /// <param name="filterContext">The Action Executing Filter Context</param>
        /// <returns>The validation result</returns>
        /// <example>
        /// <code>
        /// protected override IValidateResult ValidateRequest(ActionExecutingContext filterContext)
        /// {
        ///    var model = db.QueueLookup(filterContext);
        ///    return SessionValidationController.ValidateRequest(model.CustomerId, model.EventId);
        /// }
        /// </code>
        /// </example>
        protected virtual IValidateResult ValidateRequest(ActionExecutingContext filterContext)
        {
            if (!string.IsNullOrEmpty(this._queueName))
            {
                return(SessionValidationController.ValidateRequest(
                           QueueFactory.CreateQueue(this._queueName), this._includeTargetUrl, this._sslEnabled, this._domainAlias));
            }
            if (!string.IsNullOrEmpty(this._customerId) && !string.IsNullOrEmpty(this._eventId))
            {
                return(SessionValidationController.ValidateRequest(
                           this._customerId, this._eventId, this._includeTargetUrl, this._sslEnabled, this._domainAlias));
            }

            return(SessionValidationController.ValidateRequest(this._includeTargetUrl, this._sslEnabled, this._domainAlias));
        }
Пример #24
0
        public void QueueFactory_GetQueueUrl_IncludeTarget_Test()
        {
            string expectedCustomerId = "customerid";
            string expectedEventId    = "eventid";
            string expectedTarget     = "http://target.url/?someprop=somevalue&another=value";

            string expectedQueueUrl = "&t=" + HttpUtility.UrlEncode(expectedTarget);

            KnownUserFactory.Configure(urlProviderFactory: () => new MockKnownUserUrlProvicer(expectedTarget));

            IQueue queue = QueueFactory.CreateQueue(expectedCustomerId, expectedEventId);

            string actualQueueUrl = queue.GetQueueUrl(includeTargetUrl: true);

            Assert.IsTrue(actualQueueUrl.Contains(expectedQueueUrl));
        }
Пример #25
0
        public void QueueFactory_GetCancelUrl_Configure_Test()
        {
            QueueFactory.Configure(hostDomain: "testq.queue-it.net");

            string expectedCustomerId = "customerid";
            string expectedEventId    = "eventid";

            string expectedCancelUrl =
                "http://" + expectedCustomerId + ".testq.queue-it.net/cancel.aspx?c=" + expectedCustomerId + "&e=" + expectedEventId;

            IQueue queue = QueueFactory.CreateQueue(expectedCustomerId, expectedEventId);

            string actualQueueUrl = queue.GetCancelUrl();

            Assert.AreEqual(expectedCancelUrl, actualQueueUrl);
        }
Пример #26
0
        public void QueueFactory_GetCancelUrl_ConfigurationSection_Named_Test()
        {
            QueueFactory.Reset();

            string expectedCustomerId = "queue1customerid";
            string expectedEventId    = "queue1eventid";

            string expectedCancelUrl =
                "https://queue.mala.dk/cancel.aspx?c=" + expectedCustomerId + "&e=" + expectedEventId + "&r=http%3a%2f%2fwww.mysplitpage.com%2f";

            IQueue queue = QueueFactory.CreateQueue("queue1");

            string actualQueueUrl = queue.GetCancelUrl();

            Assert.AreEqual(expectedCancelUrl, actualQueueUrl);
        }
Пример #27
0
        public void QueueFactory_GetCancelUrl_ConfigurationSection_Test()
        {
            QueueFactory.Reset();

            string expectedCustomerId = "defaultcustomerid";
            string expectedEventId    = "defaulteventid";

            string expectedCancelUrl =
                "http://" + expectedCustomerId + ".queue-it.net/cancel.aspx?c=" + expectedCustomerId + "&e=" + expectedEventId;

            IQueue queue = QueueFactory.CreateQueue();

            string actualQueueUrl = queue.GetCancelUrl();

            Assert.AreEqual(expectedCancelUrl, actualQueueUrl);
        }
Пример #28
0
        public void QueueFactory_GetCancelUrl_LandingPage_Test()
        {
            string expectedCustomerId = "customerid";
            string expectedEventId    = "eventid";
            string expectedTarget     = "http://target.url/?someprop=somevalue&another=value";

            string expectedCancelUrl =
                "http://" + expectedCustomerId + ".queue-it.net/cancel.aspx?c=" + expectedCustomerId + "&e=" + expectedEventId +
                "&r=" + HttpUtility.UrlEncode(expectedTarget);

            IQueue queue = QueueFactory.CreateQueue(expectedCustomerId, expectedEventId);

            string actualQueueUrl = queue.GetCancelUrl(expectedTarget);

            Assert.AreEqual(expectedCancelUrl, actualQueueUrl);
        }
Пример #29
0
        public void Test_Get_Queue()
        {
            // var context = new QueueDBContext();
            var queue_one   = QueueFactory.CreateQueue(2, new MockTaskExecuter(), QueueNameOne);
            var queue_two   = QueueFactory.CreateQueue(3, new MockTaskExecuter(), QueueNameTwo);
            var queue_three = QueueFactory.CreateQueue(4, new MockTaskExecuter(), QueueNameThree);


            QueueManager.Kernal.RegistrateQueue(queue_one);
            QueueManager.Kernal.RegistrateQueue(queue_two);
            QueueManager.Kernal.RegistrateQueue(queue_three);


            Assert.AreEqual(queue_one, QueueManager.Kernal[QueueNameOne]);
            Assert.AreEqual(queue_two, QueueManager.Kernal[QueueNameTwo]);
            Assert.AreEqual(queue_three, QueueManager.Kernal[QueueNameThree]);
        }
        /// <summary>
        /// Queue validation
        /// </summary>
        /// <remarks>
        /// Please be aware that this this implementation is not done on error handling pages (e.g. Error.aspx) which will cause users to get looped arround.
        /// </remarks>
        private void QueueITValidation()
        {
            try
            {
                this._result = SessionValidationController.ValidateRequest(QueueFactory.CreateQueue("advanced"));
                var enqueue = this._result as EnqueueResult;

                // Check if user must be enqueued (new users)
                if (enqueue != null)
                {
                    if (QueueIsHealthy(enqueue.Queue))     //Is Queue-it service online for my queue?
                    {
                        Response.Redirect(enqueue.RedirectUrl);
                    }
                }

                // This part checks if user has been through the queue and persists the users queue details for later tracking
                var accepted = this._result as AcceptedConfirmedResult;
                if (accepted != null)
                {
                    if (!accepted.IsInitialValidationRequest)
                    {
                        return;     // data has already been persisted
                    }
                    PersistModel model = new PersistModel(
                        accepted.Queue.CustomerId,
                        accepted.Queue.EventId,
                        accepted.KnownUser.QueueId,
                        accepted.KnownUser.PlaceInQueue,
                        accepted.KnownUser.TimeStamp);

                    model.Persist();     //Persist users queue details
                }
            }
            catch (ExpiredValidationException ex)
            {
                // Known user has has expired - Show error page and use GetCancelUrl to get user back in the queue
                Response.Redirect("Error.aspx?queuename=advanced&t=" + HttpUtility.UrlEncode(ex.KnownUser.OriginalUrl));
            }
            catch (KnownUserValidationException ex)
            {
                // The known user url or hash is not valid - Show error page and use GetCancelUrl to get user back in the queue
                Response.Redirect("Error.aspx?queuename=advanced&t=" + HttpUtility.UrlEncode((ex.InnerException as KnownUserException).OriginalUrl));
            }
        }