Пример #1
0
        public UnsubscribeAction SubscribedTo <TMessage, TKey>(TKey correlationId, Uri endpointUri)
            where TMessage : class, CorrelatedBy <TKey>
        {
            var info = new SubscriptionInformation(_clientId, _sequence.Next(), typeof(TMessage), correlationId.ToString(), endpointUri);

            return(SendAddSubscription(info));
        }
Пример #2
0
        public UnsubscribeAction SubscribedTo <TMessage>(Uri endpointUri)
            where TMessage : class
        {
            var info = new SubscriptionInformation(_clientId, _sequence.Next(), typeof(TMessage), endpointUri);

            return(SendAddSubscription(info));
        }
Пример #3
0
        private void Remove(SubscriptionInformation subscription)
        {
            if (!_subscriptions.Contains(subscription.SubscriptionId))
            {
                return;
            }

            _log.Debug("SubscriptionClient Remove: " + subscription);

            lock (_subscriptions)
            {
                if (!_subscriptions.Contains(subscription.SubscriptionId))
                {
                    return;
                }

                ClientSubscriptionInformation subscriptionInformation = _subscriptions[subscription.SubscriptionId];

                try
                {
                    subscriptionInformation.Unsubscribe();
                }
                catch (Exception ex)
                {
                    _log.Error("Error removing a subscription (object may have been disposed)", ex);
                }

                _subscriptions.Remove(subscriptionInformation.SubscriptionId);
            }
        }
        internal override void Parse()
        {
            XElement rootElements     = Document.Element(GetSchema() + GetSubscriptionParser);
            var      subscriptionItem = new SubscriptionInformation
            {
                AccountAdminLiveId =
                    (string)rootElements.Element(GetSchema() + "AccountAdminLiveEmailId"),
                SubscriptionId =
                    (string)rootElements.Element(GetSchema() + "SubscriptionId"),
                SubscriptionName =
                    (string)rootElements.Element(GetSchema() + "SubscriptionName"),
                ServiceAdminLiveId =
                    (string)rootElements.Element(GetSchema() + "ServiceAdminLiveEmailId"),
                CurrentCoreCount =
                    (int)rootElements.Element(GetSchema() + "CurrentCoreCount"),
                CurrentHostedServices =
                    (int)rootElements.Element(GetSchema() + "CurrentHostedServices"),
                CurrentStorageAccounts =
                    (int)rootElements.Element(GetSchema() + "CurrentStorageAccounts"),
                MaxCoreCount      = (int)rootElements.Element(GetSchema() + "MaxCoreCount"),
                MaxHostedServices =
                    (int)rootElements.Element(GetSchema() + "MaxHostedServices"),
                MaxStorageAccounts =
                    (int)rootElements.Element(GetSchema() + "MaxStorageAccounts"),
                SubscriptionStatus =
                    (SubscriptionStatus)
                    Enum.Parse(typeof(SubscriptionStatus),
                               rootElements.Element(GetSchema() + "SubscriptionStatus").Value)
            };

            CommandResponse = subscriptionItem;
        }
Пример #5
0
        public void BecauseOf()
        {
            var info    = new SubscriptionInformation(_clientId, 0, "", "", _dataUri);
            var message = new SubscriptionAdded {
                Subscription = info
            };

            var saga = new LegacySubscriptionClientSaga(_clientId);

            saga.Bus = new NullServiceBus();

            var data = new OldCacheUpdateRequest(_dataUri);

            saga.RaiseEvent(LegacySubscriptionClientSaga.OldCacheUpdateRequested, data);
            IEnumerable <LegacySubscriptionClientSaga> sagas = new List <LegacySubscriptionClientSaga>
            {
                saga
            };

            MockRepo.Stub(r => r.Where(s => s.CurrentState == LegacySubscriptionClientSaga.Active)).IgnoreArguments().Return(sagas);
            MockEndpointFactory.Expect(e => e.GetEndpoint(saga.Bus.Endpoint.Uri)).Return(saga.Bus.Endpoint);


            Service.Consume(message);
        }
Пример #6
0
        private UnsubscribeAction SendAddSubscription(SubscriptionInformation info)
        {
            if (_ignoredSubscriptions.Contains(info.MessageName))
            {
                return(() => true);
            }

            var add = new AddSubscription(info);

            ClientSubscriptionInformation clientInfo = _mapper.Transform(info);

            if (clientInfo.Unsubscribe == null)
            {
                clientInfo.Unsubscribe = () => true;
            }

            lock (_subscriptions)
            {
                _subscriptions.Add(clientInfo.SubscriptionId, clientInfo);
            }

            _subscriptionServiceEndpoint.Send(add);
            return(() =>
            {
                var remove = new RemoveSubscription(info, _sequence.Next());

                _subscriptionServiceEndpoint.Send(remove);

                return true;
            });
        }
Пример #7
0
        private void RemoveSubscriptionFromView(SubscriptionInformation subscription)
        {
            if (!subscriptionView.Nodes.ContainsKey(subscription.EndpointUri.ToString()))
            {
                return;
            }

            TreeNode endpointNode = subscriptionView.Nodes[subscription.EndpointUri.ToString()];

            string messageName = subscription.MessageName;

            if (!endpointNode.Nodes.ContainsKey(messageName))
            {
                return;
            }

            TreeNode messageNode = endpointNode.Nodes[messageName];

            messageNode.Remove();

            if (endpointNode.Nodes.Count == 0)
            {
                endpointNode.Remove();
            }
        }
Пример #8
0
        private static string GetDescription(SubscriptionInformation subscription)
        {
            var parts = subscription.MessageName.Split(',');
            var d     = parts.Length > 0 ? parts[0] : subscription.MessageName;
            var dd    = d.Split('.');

            string description = dd[dd.Length - 1];

            var gs = subscription.MessageName.Split('`');

            if (gs.Length > 1)
            {
                var generics = new Queue <string>(gs.Reverse().Skip(1).Reverse());

                while (generics.Count > 0)
                {
                    var g   = generics.Dequeue();
                    var gg  = g.Split('.');
                    var ggg = gg.Length > 0 ? gg[gg.Length - 1] : g;

                    description = string.Format("{0}<{1}>", ggg, description);
                }
            }

            if (!string.IsNullOrEmpty(subscription.CorrelationId))
            {
                description += " (" + subscription.CorrelationId + ")";
            }
            return(description);
        }
 public RedirectInformation(int requestId, Status status, RedirectRequest request, List <Transaction> payment, SubscriptionInformation subscription)
 {
     this.requestId    = requestId;
     this.status       = status;
     this.request      = request;
     this.payment      = payment;
     this.subscription = subscription;
 }
Пример #10
0
    private TreeNode AddSubscriptionToView(SubscriptionInformation subscription)
    {
        TreeNode endpointNode;

        if (!subscriptionTree.Nodes.ContainsKey(subscription.EndpointUri.ToString()))
        {
            endpointNode      = new TreeNode(subscription.EndpointUri.ToString());
            endpointNode.Name = subscription.EndpointUri.ToString();

            subscriptionTree.Nodes.Add(endpointNode);
        }
        else
        {
            endpointNode = subscriptionTree.Nodes[subscription.EndpointUri.ToString()];
        }

        string messageName = subscription.MessageName;

        var parts = subscription.MessageName.Split(',');
        var d     = parts.Length > 0 ? parts[0] : subscription.MessageName;
        var dd    = d.Split('.');

        string description = dd[dd.Length - 1];

        if (!string.IsNullOrEmpty(subscription.CorrelationId))
        {
            description += " (" + subscription.CorrelationId + ")";
        }

        TreeNode messageNode;

        if (!endpointNode.Nodes.ContainsKey(messageName))
        {
            messageNode = new TreeNode(description);

            if (messageName.StartsWith("MassTransit"))
            {
                messageNode.ForeColor = Color.DimGray;
            }

            messageNode.Name = messageName;

            endpointNode.Nodes.Add(messageNode);
        }
        else
        {
            messageNode = endpointNode.Nodes[messageName];
            if (messageNode.Text != description)
            {
                messageNode.Text = description;
            }
        }

        return(messageNode);
    }
        /// <inheritdoc/>
        public ISubscriptionInfo GetSubscriptionInfo()
        {
            var environment  = new Lazy <string>(SelectEnvironment, true);
            var subscription = new Lazy <Task <ISubscription> >(
                () => SelectSubscriptionAsync(environment.Value), true);
            var region = new Lazy <Task <string> >(
                () => SelectRegion(subscription.Value), true);
            var info = new SubscriptionInformation(environment,
                                                   subscription, region);

            return(info);
        }
Пример #12
0
        public void Update(SubscriptionInformation si)
        {
            Add(new Endpoint(si.EndpointUri));

            Items[si.EndpointUri].Messages.Update(new Message(si.MessageName)
            {
                ClientId       = si.ClientId,
                CorrelationId  = si.CorrelationId,
                SequenceNumber = si.SequenceNumber,
                SubscriptionId = si.SubscriptionId,
                EndpointUri    = si.EndpointUri
            });
        }
Пример #13
0
 public void Bind(SubscriptionInformation subscriptionInformation)
 {
     if (subscriptionInformation != null)
     {
         tbEndpoint.Text = subscriptionInformation.EndpointUri.ToString();
         tbClientId.Text = subscriptionInformation.ClientId.ToString();
         tbCorrelationId.Text = subscriptionInformation.CorrelationId;
         tbMessageName.Text =  subscriptionInformation.MessageName;
         tbSequenceNumber.Text =  subscriptionInformation.SequenceNumber.ToString();
         tbSubscriptionId.Text = subscriptionInformation.SubscriptionId.ToString();
     }
     else
         Clear();
 }
        public void Removing_a_subscription_twice_should_not_have_a_negative_impact()
        {
            Guid clientId = CombGuid.Generate();

            var subscription = new SubscriptionInformation(clientId, 1, typeof(PingMessage), RemoteBus.Endpoint.Uri);

            LocalControlBus.Endpoint.Send(new AddSubscription(subscription));
            Thread.Sleep(250);

            LocalControlBus.Endpoint.Send(new RemoveSubscription(subscription));
            LocalControlBus.Endpoint.Send(new RemoveSubscription(subscription));
            Thread.Sleep(250);

            PipelineViewer.Trace(LocalBus.OutboundPipeline);
        }
Пример #15
0
 public void Bind(SubscriptionInformation subscriptionInformation)
 {
     if (subscriptionInformation != null)
     {
         tbEndpoint.Text       = subscriptionInformation.EndpointUri.ToString();
         tbClientId.Text       = subscriptionInformation.ClientId.ToString();
         tbCorrelationId.Text  = subscriptionInformation.CorrelationId;
         tbMessageName.Text    = subscriptionInformation.MessageName;
         tbSequenceNumber.Text = subscriptionInformation.SequenceNumber.ToString();
         tbSubscriptionId.Text = subscriptionInformation.SubscriptionId.ToString();
     }
     else
     {
         Clear();
     }
 }
Пример #16
0
        public void Removing_a_subscription_twice_should_not_have_a_negative_impact()
        {
            Guid clientId  = CombGuid.Generate();
            Uri  clientUri = new Uri("loopback://localhost/monster_beats");

            var subscription = new SubscriptionInformation(clientId, 1, typeof(PingMessage), RemoteBus.Endpoint.Address.Uri);

            LocalControlBus.Endpoint.Send(new AddSubscriptionClient(clientId, clientUri, clientUri));
            LocalControlBus.Endpoint.Send(new AddSubscription(subscription));
            LocalBus.ShouldHaveRemoteSubscriptionFor <PingMessage>();

            LocalControlBus.Endpoint.Send(new RemoveSubscription(subscription));
            LocalControlBus.Endpoint.Send(new RemoveSubscription(subscription));

            LocalBus.ShouldNotHaveSubscriptionFor <PingMessage>();
        }
Пример #17
0
        private TreeNode AddSubscriptionToView(SubscriptionInformation subscription)
        {
            TreeNode endpointNode;

            if (!subscriptionView.Nodes.ContainsKey(subscription.EndpointUri.ToString()))
            {
                endpointNode      = new TreeNode(subscription.EndpointUri.ToString());
                endpointNode.Name = subscription.EndpointUri.ToString();

                subscriptionView.Nodes.Add(endpointNode);
            }
            else
            {
                endpointNode = subscriptionView.Nodes[subscription.EndpointUri.ToString()];
            }

            string messageName = subscription.MessageName;

            string description = GetDescription(subscription);

            TreeNode messageNode;

            if (!endpointNode.Nodes.ContainsKey(messageName))
            {
                messageNode = new TreeNode(description);

                if (messageName.StartsWith("MassTransit"))
                {
                    messageNode.ForeColor = Color.DimGray;
                }

                messageNode.Name = messageName;
                messageNode.Tag  = subscription;

                endpointNode.Nodes.Add(messageNode);
            }
            else
            {
                messageNode = endpointNode.Nodes[messageName];
                if (messageNode.Text != description)
                {
                    messageNode.Text = description;
                }
            }

            return(messageNode);
        }
Пример #18
0
        private void Add(SubscriptionInformation sub)
        {
            if (IgnoreIfLocalEndpoint(sub.EndpointUri))
            {
                return;
            }

            _log.Debug("SubscriptionClient Add: " + sub);

            Type messageType = Type.GetType(sub.MessageName);

            if (messageType == null)
            {
                _log.InfoFormat("Unknown message type {0}, unable to add subscription", sub.MessageName);
                return;
            }

            lock (_subscriptions)
            {
                if (_subscriptions.Contains(sub.SubscriptionId))
                {
                    return;
                }

                ClientSubscriptionInformation clientInfo = _mapper.Transform(sub);

                UnsubscribeAction unsubscribe;

                Type correlatedByType = GetCorrelatedByType(sub.CorrelationId, messageType);
                if (correlatedByType != null)
                {
                    unsubscribe = AddCorrelationSubscription(correlatedByType, sub.CorrelationId, messageType, sub.EndpointUri);
                }
                else
                {
                    unsubscribe = (UnsubscribeAction)GetType()
                                  .GetMethod("AddToClients", _bindingFlags)
                                  .MakeGenericMethod(messageType).Invoke(this, new[] { sub.EndpointUri });
                }

                clientInfo.Unsubscribe = unsubscribe;

                _subscriptions[sub.SubscriptionId] = clientInfo;
            }
        }
Пример #19
0
        public void OnSubscriptionRemoved(SubscriptionRemoved message)
        {
            long messageNumber = Interlocked.Increment(ref _lastMessageNumber);

            var subscription = new SubscriptionInformation(_peerId, messageNumber, message.MessageName, message.CorrelationId,
                                                           message.EndpointUri);

            subscription.SubscriptionId = message.SubscriptionId;

            var remove = new RemoveSubscription(subscription);

            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("RemoveSubscription: {0}, {1}", subscription.MessageName, subscription.SubscriptionId);
            }

            _endpoint.Send(remove, SetSendContext);
        }
        /// <summary>
        /// Set subscription property data.
        /// </summary>
        /// <param name="data">Subscription data</param>
        /// <returns>RedirectInformation current instance.</returns>
        public RedirectInformation SetSubscription(object data)
        {
            if (data != null)
            {
                if (data.GetType() == typeof(JObject))
                {
                    data = new SubscriptionInformation((JObject)data);
                }

                if (!(data.GetType() == typeof(SubscriptionInformation)))
                {
                    data = null;
                }
            }

            subscription = (SubscriptionInformation)data;

            return(this);
        }
        public override void BecauseOf()
        {
            var info = new SubscriptionInformation(_clientId, 0, "", "", _dataUri);
            var message = new SubscriptionAdded {Subscription = info};

            var saga = new LegacySubscriptionClientSaga(_clientId);
            saga.Bus = new NullServiceBus();

            var data = new OldCacheUpdateRequest(_dataUri);

            saga.RaiseEvent(LegacySubscriptionClientSaga.OldCacheUpdateRequested, data);
            IEnumerable<LegacySubscriptionClientSaga> sagas = new List<LegacySubscriptionClientSaga>
                                                              {
                                                                  saga
                                                              };

            MockRepo.Stub(r => r.Where(s => s.CurrentState == LegacySubscriptionClientSaga.Active)).IgnoreArguments().Return(sagas);
            MockEndpointFactory.Expect(e => e.GetEndpoint(saga.Bus.Endpoint.Uri)).Return(saga.Bus.Endpoint);


            Service.Consume(message);
        }
        public void RemoveSubscription(Guid clientId, string messageName, string correlationId, Uri endpointUri)
        {
            var subscription = new SubscriptionInformation(clientId, 0, messageName, correlationId, endpointUri);

            _subscriptionServiceEndpoint.Send(new RemoveSubscription(subscription));
        }
Пример #23
0
 /// <summary>
 /// Process the response and sets the subscription information from the HTTP Body
 /// </summary>
 protected override void ResponseCallback(HttpWebResponse webResponse)
 {
     SubscriptionInformation = Parse(webResponse, BaseParser.GetSubscriptionParser);
     SitAndWait.Set();
 }
 public GetSubscriptionParser(XDocument document) : base(document)
 {
     CommandResponse = new SubscriptionInformation();
 }
Пример #25
0
 	public AddSubscription(SubscriptionInformation subscription)
         : base(subscription)
     {
     }
Пример #26
0
        public void OnAuthentication(string authenticationTicket)
        {
            AuthTicket = authenticationTicket;

            PlayerData playerData;

            if (!PlayerLoader.TryGetData(this, out playerData))
            {
                Dispose();
                return;
            }

            _playerData = playerData;

            //todo: code ban check

            _playerData.InitializeData();

            SendMessage(new AuthenticationOkMessageComposer());
            SendMessage(new AvatarEffectsMessageComposer(_playerData.GetEffectManagement().GetAllEffects));
            SendMessage(new NavigatorSettingsMessageComposer(_playerData.HomeRoom));
            SendMessage(new FavouriteRoomsMessageComposer(_playerData.FavouriteRoomIds));
            SendMessage(new FigureSetIdsMessageComposer(_playerData.GetClothingManagement().ClothingParts));
            SendMessage(new UserRightsMessageComposer(_playerData.Rank));
            SendMessage(new AvailabilityStatusMessageComposer());
            SendMessage(new AchievementScoreMessageComposer(_playerData.AchievementScore));
            SendMessage(new BuildersClubMembershipMessageComposer());
            SendMessage(new CfhTopicsInitMessageComposer());
            SendMessage(new BadgeDefinitionsMessageComposer(Sahara.GetServer().GetGameManager().GetAchievementManager().Achievements));
            SendMessage(new SoundSettingsMessageComposer(_playerData.ClientVolumes, _playerData.ChatPreference, _playerData.AllowMessengerInvites, _playerData.FocusPreference, (int)_playerData.GetMessenger().MessengerBarState));

            if (!string.IsNullOrEmpty(_playerMachineId) && _playerData.MachineId != _playerMachineId)
            {
                using (var mysqlConnection = Sahara.GetServer().GetMySql().GetConnection())
                {
                    mysqlConnection.OpenConnection();
                    mysqlConnection.SetQuery("UPDATE `users` SET `machine_id` = @machineId WHERE `id` = @id LIMIT 1");
                    mysqlConnection.AddParameter("machineId", _playerMachineId);
                    mysqlConnection.AddParameter("id", _playerData.PlayerId);
                    mysqlConnection.RunQuery();
                    mysqlConnection.CloseConnection();
                }

                _playerData.MachineId = _playerMachineId;
            }

            PermissionGroup permissionGroup;

            if (Sahara.GetServer().GetGameManager().GetPermissionManager().TryGetPermissionGroup(_playerData.Rank, out permissionGroup))
            {
                if (!string.IsNullOrEmpty(permissionGroup.PermissionBadge) && !_playerData.GetBadgeManagement().HasBadge(permissionGroup.PermissionBadge))
                {
                    _playerData.GetBadgeManagement().GiveBadge(permissionGroup.PermissionBadge, true);
                }
            }

            SubscriptionInformation subscriptionInformation = null;

            if (Sahara.GetServer().GetGameManager().GetSubscriptionManager().TryGetSubscriptionInformation(_playerData.VipRank, out subscriptionInformation))
            {
                if (!string.IsNullOrEmpty(subscriptionInformation.Badge) && !_playerData.GetBadgeManagement().HasBadge(subscriptionInformation.Badge))
                {
                    _playerData.GetBadgeManagement().GiveBadge(subscriptionInformation.Badge, true);
                }
            }

            if (_playerData.GetPermissionManagement().HasPermission("mod_tickets"))
            {
            }
        }
Пример #27
0
        /// <summary>
        /// Handle when delivered
        /// </summary>
        /// <param name="poBox">POBox reference</param>
        /// <param name="subscription">subscription </param>
        /// <returns>True if successfull, else false</returns>
        private bool DoDelivered(POBox poBox, Subscription subscription)
        {
            bool         result    = false;
            POBoxService poService = new POBoxService();

            log.Debug("  calling the PO Box server to get subscription state");
            log.Debug("  domainID: " + subscription.DomainID);
            log.Debug("  fromID:   " + subscription.FromIdentity);
            log.Debug("  SubID:    " + subscription.MessageID);

            // Resolve the PO Box location for the inviter
            Uri poUri = DomainProvider.ResolvePOBoxLocation(subscription.DomainID, subscription.FromIdentity);

            if (poUri != null)
            {
                poService.Url = poUri.ToString() + poServiceLabel;
                log.Debug("  connecting to the Post Office Service : " + poService.Url);
            }
            else
            {
                log.Debug("  Could not resolve the PO Box location for: " + subscription.FromIdentity);
                return(result);
            }

            try
            {
                WebState webState =
                    new WebState(
                        subscription.DomainID,
                        subscription.SubscriptionCollectionID,
                        subscription.ToIdentity);

                webState.InitializeWebClient(poService, subscription.DomainID);
            }
            catch (NeedCredentialsException)
            {
                log.Debug("  no credentials - back to sleep");
                return(result);
            }

            try
            {
                SubscriptionInformation subInfo =
                    poService.GetSubscriptionInfo(
                        subscription.DomainID,
                        subscription.FromIdentity,
                        subscription.MessageID,
                        subscription.SubscriptionCollectionID);

                switch (subInfo.Status)
                {
                case POBoxStatus.Success:
                {
                    log.Debug("  subInfo.FromName: " + subInfo.FromName);
                    log.Debug("  subInfo.ToName: " + subInfo.ToName);
                    log.Debug("  subInfo.State: " + subInfo.State.ToString());
                    log.Debug("  subInfo.Disposition: " + subInfo.Disposition.ToString());

                    if (subInfo.Disposition == ( int )SubscriptionDispositions.Accepted)
                    {
                        log.Debug("  creating collection...");

                        // Check to make sure the collection proxy doesn't already exist.
                        if (poBox.StoreReference.GetCollectionByID(subscription.SubscriptionCollectionID) == null)
                        {
                            SubscriptionDetails details = new SubscriptionDetails();
                            details.DirNodeID   = subInfo.DirNodeID;
                            details.DirNodeName = subInfo.DirNodeName;

                            subscription.SubscriptionRights = (Access.Rights)subInfo.AccessRights;
                            subscription.AddDetails(details);
                            poBox.Commit(subscription);

                            // create slave stub
                            subscription.ToMemberNodeID = subInfo.ToNodeID;
                            subscription.CreateSlave(poBox.StoreReference);
                        }

                        // acknowledge the message which removes the originator's subscription.
                        SubscriptionMsg subMsg   = subscription.GenerateSubscriptionMessage();
                        POBoxStatus     wsStatus = poService.AckSubscription(subMsg);
                        if ((wsStatus == POBoxStatus.Success) ||
                            (wsStatus == POBoxStatus.AlreadyAccepted))
                        {
                            // done with the subscription - move to local subscription to the ready state
                            log.Debug("  moving subscription to ready state.");
                            subscription.SubscriptionState = SubscriptionStates.Ready;
                            poBox.Commit(subscription);
                            result = true;
                        }
                        else
                        {
                            log.Debug("  failed acknowledging a subscription");
                            log.Debug("  status = {0}", wsStatus.ToString());
                            log.Debug("  deleting the local subscription");

                            poBox.Commit(poBox.Delete(subscription));
                            result = true;
                        }
                    }
                    break;
                }

                case POBoxStatus.AlreadyAccepted:
                {
                    log.Debug("  the subscription has already been accepted by another client.");
                    result = CreateCollectionProxy(poBox, subscription);
                    break;
                }

                case POBoxStatus.InvalidState:
                {
                    log.Debug("  invalid state");
                    break;
                }

                default:
                {
                    log.Debug("  server error = {0}. Deleting subscription.", subInfo.Status.ToString());
                    poBox.Commit(poBox.Delete(subscription));
                    result = true;
                    break;
                }
                }
            }
            catch (Exception e)
            {
                log.Error("  DoDelivered failed with an exception");
                log.Error(e.Message);
                log.Error(e.StackTrace);
            }

            return(result);
        }
Пример #28
0
 private void NotifySubscriptionRemoved(SubscriptionInformation subscription)
 {
     Bus.Publish(new SubscriptionRemoved {
         Subscription = subscription
     });
 }
Пример #29
0
		public RemoveSubscription(SubscriptionInformation subscription)
			: base(subscription)
		{
		}
Пример #30
0
		public RemoveSubscription(SubscriptionInformation subscription, long sequenceNumber)
			: base(subscription)
		{
			Subscription.SequenceNumber = sequenceNumber;
		}
Пример #31
0
        public override RedirectInformation Collect(CollectRequest collectRequest)
        {
            try
            {
                this._action = "/collect";

                string request = Serializer.JsonSerializer.SerializeObject(collectRequest);

                var node = JsonConvert.DeserializeXmlNode(request, "payload");

                XElement collect = new XElement(p2p + "collect", XElement.Parse(node.OuterXml));

                string response = this.CallWebService(collect);

                response = Regex.Replace(response, @"(\s*)""@(.*)"":", @"$1""$2"":", RegexOptions.IgnoreCase);
                JObject res = JObject.Parse(response);

                if (res["ns1:collectResponse"]["collectResult"]["payment"] != null)
                {
                    var transaction = res["ns1:collectResponse"]["collectResult"]["payment"]["transaction"];
                    res["ns1:collectResponse"]["collectResult"]["payment"] = null;
                    var data = res["ns1:collectResponse"]["collectResult"];
                    RedirectInformationSOAP redirectInformationSOAP = JsonConvert.DeserializeObject <RedirectInformationSOAP>(data.ToString(), Serializer.JsonSerializer.Settings);

                    if (transaction.Type.ToString() == "Object")
                    {
                        List <TransactionSOAP> transactions    = new List <TransactionSOAP>();
                        TransactionSOAP        transactionSOAP = JsonConvert.DeserializeObject <TransactionSOAP>(transaction.ToString());
                        transactions.Add(transactionSOAP);
                        redirectInformationSOAP.Payment = transactions;
                    }
                    else
                    {
                        List <TransactionSOAP> transactions = new List <TransactionSOAP>();
                        TransactionSOAP        transactionSOAP;
                        foreach (var item in transaction.Children())
                        {
                            transactionSOAP = JsonConvert.DeserializeObject <TransactionSOAP>(item.ToString());
                            transactions.Add(transactionSOAP);
                        }
                        redirectInformationSOAP.Payment = transactions;
                    }

                    List <Transaction> paymentTransaction = new List <Transaction>();
                    foreach (var tSOAP in redirectInformationSOAP.Payment)
                    {
                        Transaction T = new Transaction(tSOAP.Status, tSOAP.Reference, tSOAP.InternalReference, tSOAP.PaymentMethod, tSOAP.PaymentMethodName, tSOAP.IssuerName, tSOAP.Amount, tSOAP.Authorization, tSOAP.Receipt, tSOAP.Franchise, tSOAP.Refunded, tSOAP.ProcessorFields.item);
                        paymentTransaction.Add(T);
                    }

                    RedirectInformation redirectInformation = new RedirectInformation(redirectInformationSOAP.RequestId, redirectInformationSOAP.Status, redirectInformationSOAP.Request, paymentTransaction, null);

                    return(redirectInformation);
                }
                else if (res["ns1:collectResponse"]["collectResult"]["subscription"] != null)
                {
                    var data = res["ns1:getRequestInformationResponse"]["getRequestInformationResult"];
                    RedirectInformationSOAP    redirectInformationSOAP    = JsonConvert.DeserializeObject <RedirectInformationSOAP>(data.ToString());
                    SubscriptionInfomationSOAP subscriptionInfomationSOAP = redirectInformationSOAP.Subscription;
                    SubscriptionInformation    subscriptionInformation    = new SubscriptionInformation(subscriptionInfomationSOAP.Type, subscriptionInfomationSOAP.Status, subscriptionInfomationSOAP.Instrument.item);
                    RedirectInformation        redirectInformation        = new RedirectInformation(redirectInformationSOAP.RequestId, redirectInformationSOAP.Status, redirectInformationSOAP.Request, null, subscriptionInformation);

                    return(redirectInformation);
                }
                else
                {
                    var data = res["ns1:collectResponse"]["collectResult"];
                    return(JsonConvert.DeserializeObject <RedirectInformation>(data.ToString()));
                }
            }
            catch (Exception ex)
            {
                Status status = new Status("ERROR", "WR", PlacetoPayException.ReadException(ex), (DateTime.Now).ToString("yyyy-MM-ddTHH\\:mm\\:sszzz"));
                RedirectInformation redirectInformation = new RedirectInformation(0, status, null, null, null);

                return(redirectInformation);
            }
        }