Exemplo n.º 1
0
        /// <summary>
        /// 取消订阅
        /// </summary>
        /// <param name="instrument"></param>
        /// <returns></returns>
        public bool Unsubscribe(string instrument)
        {
            try
            {
                if (Instruments.Remove(instrument))
                {
                    var cmd = new UnsubscribeCommand(instrument);

                    var responseText = SendCmd(ODSCommandTags.Unsubscribe, cmd);
                    if (!string.IsNullOrEmpty(responseText))
                    {
                        var response = new UnsubscribeResponse();
                        response.Load(responseText);

                        return(response.Success);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }

            return(false);
        }
Exemplo n.º 2
0
        private static void Unsubscribe(UnsubscribeCommand unsubscribeMessage)
        {
            Console.WriteLine("Starting unsubscribe for: {0}, at: {1}", unsubscribeMessage.EmailAddress, DateTime.Now.TimeOfDay);
            var workflow = new UnsubscribeWorkflow(unsubscribeMessage.EmailAddress);

            workflow.Run();
            Console.WriteLine("Unsubscribe complete for: {0}, at: {1}", unsubscribeMessage.EmailAddress, DateTime.Now.TimeOfDay);
        }
Exemplo n.º 3
0
 public override void ProcessUnsubscribeCommand(UnsubscribeCommand cmd)
 {
     this.Session.AppendResponse(
         new ServerStatusResponse(cmd.Tag,
                                  ServerStatusResponseType.NO,
                                  "UNSUBSCRIBE is unsupportted yet")
         );
 }
Exemplo n.º 4
0
 public virtual void ProcessUnsubscribeCommand(UnsubscribeCommand cmd)
 {
     this.Session.AppendResponse(
         new ServerStatusResponse(cmd.Tag,
                                  ServerStatusResponseType.NO,
                                  "UNSUBSCRIBE State Error")
         );
 }
Exemplo n.º 5
0
 private void RaiseCommandExecutes()
 {
     StopPriceSourceCommand.RaiseCanExecuteChanged();
     StartPriceSourceCommand.RaiseCanExecuteChanged();
     SubscribeCommand.RaiseCanExecuteChanged();
     UnsubscribeCommand.RaiseCanExecuteChanged();
     SubscribeAllCommand.RaiseCanExecuteChanged();
     UnsubscribeAllCommand.RaiseCanExecuteChanged();
 }
        /// <summary>
        /// Отписка от оповещения по типу сообщения для сокета
        /// </summary>
        /// <param name="webSocket"></param>
        /// <param name="command"></param>
        public void UnsubscribeMessage(WebSocket webSocket, UnsubscribeCommand command)
        {
            if (!_connectionSockets.TryGetValue(webSocket, out var messageTypes))
            {
                return;
            }

            messageTypes.Remove(command.MessageType);
        }
        private void StartUnsubscribe(string emailAddress)
        {
            var unsubscribeCommand = new UnsubscribeCommand {
                EmailAddress = emailAddress
            };
            var message = new Message {
                Body = unsubscribeCommand
            };

            _unsubscribe.Send(message);
        }
        private static void StartUnsubscribe(string emailAddress)
        {
            var unsubscribeCommand = new UnsubscribeCommand
            {
                EmailAddress = emailAddress
            };
            var queue = MessageQueueFactory.CreateOutbound("unsubscribe", MessagePattern.FireAndForget);

            queue.Send(new Message
            {
                Body = unsubscribeCommand
            });
        }
Exemplo n.º 9
0
        private async void OnUnsubscribeCommand()
        {
            canSubscribe = true;
            SubscribeCommand.RaiseCanExecuteChanged();
            canUnsubscribe = false;
            UnsubscribeCommand.RaiseCanExecuteChanged();

            await hub.Invoke <int>("Unsubscribe", new object[] { ClientId });

            if (connection.State == ConnectionState.Connected)
            {
                connection.Stop();
            }
        }
Exemplo n.º 10
0
        private static void StartUnsubscribe(string emailAddress)
        {
            var unsubscribeCommand = new UnsubscribeCommand
            {
                EmailAddress = emailAddress
            };

            using (var queue = new msmq.MessageQueue(
                       ".\\private$\\sixeyed.messagequeue.unsubscribe"))
            {
                var message = new msmq.Message();
                message.BodyStream = unsubscribeCommand.ToJsonStream();
                message.Label      = unsubscribeCommand.GetMessageType();
                queue.Send(message);
            }
        }
Exemplo n.º 11
0
        public async Task RemoveSubscription(UnsubscribeCommand command)
        {
            await Lock.WaitAsync();

            try
            {
                int index = Subscriptions.FindIndex(s => s.ReferenceId == command.ReferenceId);

                if (index != -1)
                {
                    Subscriptions.RemoveAt(index);
                }
            }
            finally
            {
                Lock.Release();
            }
        }
Exemplo n.º 12
0
        private async void OnSubscribeCommand()
        {
            canSubscribe = false;
            SubscribeCommand.RaiseCanExecuteChanged();
            canUnsubscribe = true;
            UnsubscribeCommand.RaiseCanExecuteChanged();

            if (connection.State != ConnectionState.Connected)
            {
                await connection.Start();
            }

            try
            {
                await hub.Invoke <int>("Subscribe", new object[] { ClientId });
            }
            catch (Exception ex)
            {
                Message = ex.Message;
            }
        }
Exemplo n.º 13
0
        public ActionResult Unsubscribe(UnsubscribeCommand command)
        {
            try
            {
                const string queueAddress = @"HomeOffice\private$\msmq-test-tx";

                using (var msmq = new MessageQueue(queueAddress))
                {
                    var tx = new MessageQueueTransaction();
                    tx.Begin();
                    msmq.Send(command, tx);
                    tx.Commit();
                }
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
            }

            return(View("Unsubscribe"));
        }
Exemplo n.º 14
0
        public ActionResult Unsubscribe(UnsubscribeCommand command)
        {
            try
            {
                const string queueAddress = @"HomeOffice\private$\msmq-test";

                using (var msmq = new MessageQueue(queueAddress))
                {
                    for (int i = 0; i < 10; i++)
                    {
                        msmq.Send(command);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
            }

            return(View("Unsubscribe"));
        }
        public ActionResult Submit(string emailAddress)
        {
            //var workflow = new UnsubscribeWorkflow(emailAddress);
            //workflow.Run();
            var unsubscribeCommand = new UnsubscribeCommand
            {
                EmailAddress = emailAddress
            };

            using (var queue = new msmq.MessageQueue(".\\private$\\sixeyed.messagequeue.unsubscribe-tx"))
            {
                //var message = new msmq.Message(unsubscribeCommand);
                var message  = new msmq.Message();
                var jsonBody = JsonConvert.SerializeObject(unsubscribeCommand);
                message.BodyStream = new MemoryStream(Encoding.Default.GetBytes(jsonBody));
                var tx = new msmq.MessageQueueTransaction();
                tx.Begin();
                queue.Send(message, tx);
                tx.Commit();
            }
            return(View("Confirmation"));
        }
Exemplo n.º 16
0
        public VideoPageViewModel(string videoId, Func <IDataSource> getDataSource, IConnectionListener connectionListener)
        {
            Likes               = 0;
            Dislikes            = 0;
            VideoId             = videoId;
            IsLive              = false;
            _getDataSource      = getDataSource;
            _connectionListener = connectionListener;
            _connectionListener.Subscribe(this);
            _channelSubscribers = 0;
            _channelVideoCount  = 0;
            _qualityConverter   = new VideoQuality();

            _subscribeCommand   = new SubscribeCommand(_getDataSource, () => _channelId, InvalidateCommands);
            _unsubscribeCommand = new UnsubscribeCommand(_getDataSource, () => _channelId, InvalidateCommands);

            _likeCommand         = new RelayCommand(Like, CanLike);
            _dislikeCommand      = new RelayCommand(Dislike, CanLike);
            _addFavoritesCommand = new RelayCommand(AddFavorites);
            _videoQualityCommand = new RelayCommand(ChangeVideoQuality);

            LoadVideoQualities();
            LoadVideoItem(videoId);
        }
        /// <summary>
        /// Notify unsubscribe request
        /// </summary>
        /// <param name="obaUnsubscribe">
        /// The oba Unsubscribe.
        /// </param>
        /// <exception cref="FaultException">
        /// Error during executing the request
        /// </exception>
        public void Notify(ObaUnsubscribe obaUnsubscribe)
        {
            if (obaUnsubscribe == null)
            {
                const string ErrorMsg = "Bad client request. Null request recieved";
                Log.Warn(ErrorMsg);
                throw new FaultException(ErrorMsg, new FaultCode(BadRequest));
            }

            Guid   eventCorrelationId = obaUnsubscribe.CorrelationId;
            Guid   eventInstanceId    = obaUnsubscribe.EventInstanceId;
            string correlationTicket  = obaUnsubscribe.CorrelationTicket;
            string entityId           = obaUnsubscribe.EntityId;

            var request = obaUnsubscribe.Body;

            var context = new RequestContext {
                CorrelationId = eventCorrelationId, EventInstanceId = eventInstanceId, CorrelationTicket = correlationTicket, EntityId = entityId
            };

            if (request == null)
            {
                const string ErrorMsg         = "Bad client request. Null request recieved";
                const string ErrorMsgTemplate = "Request Context={0}; Error={1}";
                Log.Warn(ErrorMsgTemplate, context, ErrorMsg);
                throw new FaultException(string.Format(ErrorMsgTemplate, context, ErrorMsg), new FaultCode(BadRequest));
            }

            if (string.IsNullOrEmpty(entityId))
            {
                const string ErrorMsg         = "Bad client request. entity id is null or empty";
                const string ErrorMsgTemplate = "Request Context={0}; Error={1}";
                Log.Warn(ErrorMsgTemplate, context, ErrorMsg);
                throw new FaultException(string.Format(ErrorMsgTemplate, context, ErrorMsg), new FaultCode(BadRequest));
            }

            var hcpCommand = new UnsubscribeCommand {
                CorrelationTicket = correlationTicket, EventCorrelationId = eventCorrelationId, EventInstanceId = eventInstanceId, EmailAddress = entityId, RequestTimeUtc = request.DateTimeUtcUnsubscribed
            };

            switch (request.NotificationType)
            {
            // Unsubscribe All
            case NotificationType.UA:
                hcpCommand.IsUnsubscribeAll = true;
                break;

            // Targeted unsubscribe
            case NotificationType.TU:
                hcpCommand.IsUnsubscribeAll = false;
                hcpCommand.PublicationIds   = this.GetPublicationIds(context, request);
                break;

            // Unsupported command
            default:
                string       errorMsg         = string.Format("Bad client request. Unknown notification type: {0}", request.NotificationType);
                const string ErrorMsgTemplate = "Request Context={0}; Error={1}";
                Log.Warn(ErrorMsgTemplate, context, errorMsg);
                throw new FaultException(string.Format(ErrorMsgTemplate, context, errorMsg), new FaultCode(BadRequest));
            }

            try
            {
                Log.Verbose("Enqueuing Unsubscribe Request. Details: {0}", hcpCommand);
                this.hcpCommandsQueue.EnqueueCommand(hcpCommand);
                Log.Verbose("Unsubscribe Request Enqueued. Details: {0}", hcpCommand);
            }
            catch (Exception e)
            {
                Log.Error(e, "Error while calling hcp commands queue. Request Context={0}", context);
                throw new FaultException(string.Format("Internal Server Error. Request Context={0}", context), new FaultCode(ServerError));
            }
        }
Exemplo n.º 18
0
 private void InitializeCommands()
 {
     _subscribeCommand   = new SubscribeCommand(_getDataSource, () => _channelId, InvalidateCommands);
     _unsubscribeCommand = new UnsubscribeCommand(_getDataSource, () => _channelId, InvalidateCommands);
 }
Exemplo n.º 19
0
 public ActionResult Unsubscribe(UnsubscribeCommand command)
 {
     UnsubscriptionWorkflow.Run(command.EmailAddress);
     return(View("Unsubscribe"));
 }
 public async Task Unsubscribe([FromBody] UnsubscribeCommand command) => await mediator.Send(command);
Exemplo n.º 21
0
        public void UnsubscribeCommandTest()
        {
            var unsubscribeCommand = new UnsubscribeCommand();

            Assert.IsTrue(unsubscribeCommand.IsValid);
        }