public ActionResult JoinCourse(JoinCourseViewModel model)
        {
            if (ModelState.IsValid)
            {
                Course course = _coursesContent.GetCourseByNiceUrl(model.CourseNiceUrl);
                if (course == null)
                {
                    return(HttpNotFound());
                }

                string username = User.Identity.Name;
                if (model.BillingInfo != null)
                {
                    var user = _users.GetByUsername(username);
                    user.BillingInfo = Mapper.Map(model.BillingInfo, user.BillingInfo);
                    _users.UpdateUser(user);
                }

                SubscriptionStatus status = _subscriptions.JoinCourse(username, course.Id);

                if (status == SubscriptionStatus.Active)
                {
                    IPublishedContent coursesPage = _coursesContent.GetCoursePublishedContentByNiceUrl(model.CourseNiceUrl);
                    return(Redirect(coursesPage.Url));
                }
                else
                {
                    return(RedirectToAction(nameof(AwaitingPayment), new { courseNiceUrl = model.CourseNiceUrl }));
                }
            }

            return(JoinCourse(model.CourseNiceUrl));
        }
Esempio n. 2
0
        private void SubscriptionWorker_SubscriptionStatusChanged(object sender, SubscriptionStatusUpdatedEventArgs e)
        {
            if (e.Status != SubscriptionStatus.Subscribed)
            {
                OnStatusChanged(SubscriptionWorker.SubscriptionStatusToString(e.Status));
            }
            else
            {
                OnStatusChanged("");
            }
            if (e.Status == SubscriptionStatus.Accepted || e.Status == SubscriptionStatus.Subscribed)
            {
                if (!Config.IsDbConfigAvailable())
                {
                    OnStatusChanged("Logic error: subscribed, but without config");
                }
                else
                {
                    Log.Trace("Starting db");
                    StartDbWorker();
                }
            }
            if (e.Status == SubscriptionStatus.WaitingForAuthorization && lastStatus != SubscriptionStatus.WaitingForAuthorization)
            {
                Log.Info("Deauthorization, clearing DB config and restarting");
                Config.ResetDbSettings();
                Config.Save(LocalSettingsConfigProvider.Instance);
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                Restart();
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            }
            lastStatus = e.Status;
        }
Esempio n. 3
0
        public NotificationSubscriptionResponse UnsubscribeFromNotifications(string emailAddress)
        {
            try
            {
                NotificationSubscription subscription = Repository.Query <NotificationSubscription>(Query.Where("EmailAddress") == emailAddress).FirstOrDefault();
                string             uuid   = string.Empty;
                SubscriptionStatus status = SubscriptionStatus.NotFound;
                if (subscription != null)
                {
                    subscription.IsActive = false;
                    subscription          = Repository.Save(subscription);
                    uuid   = subscription.Uuid;
                    status = SubscriptionStatus.NotActive;
                }

                return(new NotificationSubscriptionResponse {
                    Success = true, SubscriptionStatus = status, Uuid = uuid
                });
            }
            catch (Exception ex)
            {
                return(new NotificationSubscriptionResponse {
                    Success = false, Message = ex.Message
                });
            }
        }
Esempio n. 4
0
 public void Subscribe()
 {
     lock (iSubscriptionStatusLock)
     {
         iSubscriptionStatus = SubscriptionStatus.eSubscribing;
     }
     CpProxySubscribe(iHandle);
 }
 public void SetStatus(SubscriptionStatus status)
 {
     if (status != this.subscription.Status)
     {
         subscription.Status = status;
         session.ClientEventEnqueue(new ClientEvent { Subscription = subscription, Type = ClientEventType.SubscriptionUpdate, Timestamp = DateTime.Now });
     }
 }
Esempio n. 6
0
 public void Unsubscribe()
 {
     lock (iSubscriptionStatusLock)
     {
         iSubscriptionStatus = SubscriptionStatus.eNotSubscribed;
     }
     CpProxyUnsubscribe(iHandle);
 }
Esempio n. 7
0
 public Subscription(Guid id, SubscriptionStatus status, Period trialPeriod, Period period, bool cancellingAtPeriodEnd, SubscriptionPlanReference planReference, BillingReference billingReference)
 {
     Id                    = id;
     Status                = status;
     TrialPeriod           = trialPeriod;
     Period                = period;
     CancellingAtPeriodEnd = cancellingAtPeriodEnd;
     PlanReference         = planReference;
     BillingReference      = billingReference;
 }
Esempio n. 8
0
 public virtual void MarkProvisioned()
 {
     if (Status != SubscriptionStatus.Provisioned)
     {
         Status = SubscriptionStatus.Provisioned;
         DomainEvents.Raise(new SubscriptionProvisioned {
             AccountCode = Account.Code, ProductCode = ProductCode
         });
     }
 }
Esempio n. 9
0
 public SubscriptionWorker(string hubUrl, int delay = 15000)
 {
     this.hubUrl        = hubUrl;
     this.delay         = delay;
     originalDelay      = delay;
     lastStatus         = SubscriptionStatus.None;
     subscriptionWorker = new BackgroundWorker();
     subscriptionWorker.WorkerSupportsCancellation = true;
     subscriptionWorker.DoWork += ReadingWorker_DoWork;
 }
Esempio n. 10
0
        /// <summary>
        /// Stops regular updates of data
        /// </summary>
        public void Stop()
        {
            lock (_subscriptionDataLock)
            {
                // set status
                Status = SubscriptionStatus.Idle;

                // stop the timer
                StopTimer();
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Starts regular updates of data
        /// </summary>
        public void Start()
        {
            lock (_subscriptionDataLock)
            {
                // set status
                Status = SubscriptionStatus.Running;

                // stop the timer
                StartTimer();
            }
        }
Esempio n. 12
0
 /// <summary>
 /// Initialize a new instance of this type.
 /// </summary>
 public MessageStatus(string pattern, MessageSendResult result)
 {
     Pattern                = pattern;
     Timestamp              = result.Timestamp;
     MessageType            = MessageTypes[result.AssociatedMessage.GetType()];
     MessageId              = result.AssociatedMessage.Id;
     ChannelUri             = result.ChannelUri;
     StatusCode             = result.StatusCode;
     NotificationStatus     = result.NotificationStatus;
     DeviceConnectionStatus = result.DeviceConnectionStatus;
     SubscriptionStatus     = result.SubscriptionStatus;
 }
Esempio n. 13
0
 /// <summary>
 /// Initialize a new instance of this type.
 /// </summary>
 public MessageStatus(string pattern, MessageSendResult result)
 {
     Pattern = pattern;
     Timestamp = result.Timestamp;
     MessageType = MessageTypes[result.AssociatedMessage.GetType()];
     MessageId = result.AssociatedMessage.Id;
     ChannelUri = result.ChannelUri;
     StatusCode = result.StatusCode;
     NotificationStatus = result.NotificationStatus;
     DeviceConnectionStatus = result.DeviceConnectionStatus;
     SubscriptionStatus = result.SubscriptionStatus;
 }
Esempio n. 14
0
        private void cmdSubscribe_Click(object sender, System.EventArgs e)
        {
            string emailAddress = txtEmail.Text;

            if (emailAddress == null || emailAddress == string.Empty)
            {
                AddErrorMessage(Translate("/bvnetwork/sendmail/subscribe/errornoemail"));
                return;
            }

            emailAddress = emailAddress.Trim();

            EPiMailEngine  engine        = new EPiMailEngine();
            ArrayList      resultArray   = new ArrayList();
            EmailAddresses importedItems = new EmailAddresses();

            foreach (ListItem itm in this.chkNewsLetterLists.Items)
            {
                if (itm.Selected)
                {
                    // Check that the user does not belong to the groups
                    // already.
                    RecipientList list = RecipientList.Load(Convert.ToInt32(itm.Value));

                    SubscriptionStatus status = new SubscriptionStatus();
                    status.RecipientListName = list.Name;

                    //Load and check if the email typed by the user exists.
                    EmailAddress emailItem = EmailAddress.Load(list.Id, emailAddress);
                    if (emailItem == null)
                    {
                        // Create it, and save it. It is automatically
                        // added to the WorkItems collection
                        emailItem = list.CreateEmailAddress(emailAddress);
                        // Save
                        emailItem.Save();
                        status.SubscriptionResult = true;
                    }
                    else
                    {
                        // Already subscribes
                        status.SubscriptionResult = true;
                        status.Message            = Translate("/bvnetwork/sendmail/subscribe/alreadysubscribe");
                    }

                    resultArray.Add(status);
                }
            }

            // Done adding, now show the result
            rptResult.DataSource = resultArray;
            rptResult.DataBind();
        }
Esempio n. 15
0
        public void Subscribe()
        {
            lock (iSubscriptionStatusLock)
            {
                iSubscriptionStatus = SubscriptionStatus.eSubscribing;
            }
            int ret = CpProxySubscribe(iHandle);

            if (ret == -1)
            {
                throw new SubscriptionException();
            }
        }
Esempio n. 16
0
 protected void ReportEvent(System.Action aCallback)
 {
     lock (iSubscriptionStatusLock)
     {
         if (iSubscriptionStatus == SubscriptionStatus.eSubscribing)
         {
             iSubscriptionStatus = SubscriptionStatus.eSubscribed;
         }
         if (iSubscriptionStatus == SubscriptionStatus.eSubscribed && aCallback != null)
         {
             aCallback();
         }
     }
 }
        public static SubscriptionPrice GetPriceCalculator(SubscriptionStatus status)
        {
            switch (status)
            {
            case SubscriptionStatus.Initialization: return(new InitializationPrice());

            case SubscriptionStatus.Subscription:   return(new SubscriptionPrice());

            case SubscriptionStatus.Conversion:     return(new ConversionPrice());

            case SubscriptionStatus.Termination:    return(new TerminationPrice());
            }
            return(null);
        }
        public ActionResult JoinCourse(string courseNiceUrl)
        {
            Course course = _coursesContent.GetCourseByNiceUrl(courseNiceUrl);

            if (course == null)
            {
                return(HttpNotFound());
            }

            string             username           = User.Identity.Name;
            SubscriptionStatus subscriptionStatus = _subscriptions.GetSubscriptionStatus(username, course.Id);

            if (subscriptionStatus == SubscriptionStatus.Active)
            {
                IPublishedContent coursesPage = _coursesContent.GetCoursePublishedContentByNiceUrl(courseNiceUrl);
                return(Redirect(coursesPage.Url));
            }
            else if (subscriptionStatus == SubscriptionStatus.AwaitingPayment)
            {
                return(RedirectToAction(nameof(AwaitingPayment), new { courseNiceUrl = courseNiceUrl }));
            }

            JoinCourseViewModel viewModel = new JoinCourseViewModel
            {
                CourseName          = course.Title,
                CoursePrice         = course.Price,
                RequiresBillingInfo = _courses.IsPaidCourse(course)
            };

            if (viewModel.RequiresBillingInfo)
            {
                User user = _users.GetByUsername(username);
                viewModel.BillingInfo = Mapper.Map <BillingInfoViewModel>(user.BillingInfo);
            }

            IPublishedContent legalPage = Umbraco.TypedContentAtRoot().DescendantsOrSelf(nameof(LegalContent)).FirstOrDefault();
            int licenseAgreement        = legalPage.GetPropertyValue <int>(nameof(LegalContent.LicenseTerms));

            if (licenseAgreement != default(int))
            {
                IPublishedContent licenseAgreementPage = Umbraco.TypedContent(licenseAgreement);
                viewModel.LicenseTermsUrl = licenseAgreementPage.Url;
            }



            return(View(viewModel));
        }
Esempio n. 19
0
        public static string GetSubscriptionStatus(SubscriptionStatus value)
        {
            switch (value)
            {
            case SubscriptionStatus.NotAvailable:
                return(fxcore2.Constants.SubscriptionStatuses.Disable);

            case SubscriptionStatus.Available:
                return(fxcore2.Constants.SubscriptionStatuses.Tradable);

            case SubscriptionStatus.ViewOnly:
                return(fxcore2.Constants.SubscriptionStatuses.ViewOnly);
            }

            throw new ArgumentOutOfRangeException("value");
        }
Esempio n. 20
0
        private void cmdUnsubscribe_Click(object sender, System.EventArgs e)
        {
            string emailAddress = txtEmail.Text;

            if (emailAddress == null || emailAddress == string.Empty)
            {
                AddErrorMessage(Translate("/bvnetwork/sendmail/unsubscribe/errornoemail"));
                return;
            }

            emailAddress = emailAddress.Trim();
            EPiMailEngine engine      = new EPiMailEngine();
            ArrayList     resultArray = new ArrayList();

            EmailAddresses importedItems = new EmailAddresses();

            foreach (ListItem itm in this.chkNewsLetterLists.Items)
            {
                if (itm.Selected)
                {
                    //Load the selected recipient list
                    RecipientList list = RecipientList.Load(Convert.ToInt32(itm.Value));

                    SubscriptionStatus status = new SubscriptionStatus();
                    status.RecipientListName = list.Name;
                    //load user email address
                    EmailAddress emailItem = EmailAddress.Load(list.Id, emailAddress);
                    if (emailItem != null)
                    {
                        //Delete the user from the list, and show a confirm message
                        emailItem.Delete();
                        status.SubscriptionResult = true;
                        status.Message            = Translate("/bvnetwork/sendmail/unsubscribe/recipientremoved");
                    }
                    else
                    {
                        status.SubscriptionResult = false;
                        status.Message            = Translate("/bvnetwork/sendmail/unsubscribe/nosubscriptionfound");
                    }
                    //add the result to the array list.
                    resultArray.Add(status);
                }
            }
            // Done adding, now show the result
            rptResult.DataSource = resultArray;
            rptResult.DataBind();
        }
 private void InitializeStatusCodes(HttpWebResponse response)
 {
     if (response == null)
     {
         StatusCode             = HttpStatusCode.InternalServerError;
         NotificationStatus     = NotificationStatus.NotApplicable;
         DeviceConnectionStatus = DeviceConnectionStatus.NotApplicable;
         SubscriptionStatus     = SubscriptionStatus.NotApplicable;
     }
     else
     {
         StatusCode             = response.StatusCode;
         NotificationStatus     = response.GetNotificationStatus();
         DeviceConnectionStatus = response.GetDeviceConnectionStatus();
         SubscriptionStatus     = response.GetSubscriptionStatus();
     }
 }
        public DiscordEmbed BuildStatus(SubscriptionStatus status)
        {
            var contentBuilder = new StringBuilder();

            contentBuilder.Append($"**Elon Twitter:** {status.ElonTwitter.ConvertToYesNo()}\r\n");
            contentBuilder.Append($"**SpaceX Twitter:** {status.SpaceXTwitter.ConvertToYesNo()}\r\n");
            contentBuilder.Append($"**SpaceXFleet Twitter:** {status.SpaceXFleetTwitter.ConvertToYesNo()}\r\n");
            contentBuilder.Append($"**Flickr:** {status.Flickr.ConvertToYesNo()}\r\n");
            contentBuilder.Append($"**Launches:** {status.Launches.ConvertToYesNo()}\r\n");
            contentBuilder.Append($"**Reddit:** {status.Reddit.ConvertToYesNo()}");

            return(new DiscordEmbedBuilder
            {
                Title = "Notifications status",
                Description = contentBuilder.ToString(),
                Color = new DiscordColor(Constants.EmbedColor)
            });
        }
Esempio n. 23
0
        /// <summary>
        /// Retrieves the localized status type string.
        /// </summary>
        /// <param name="statusType">The subscription status type.</param>
        /// <returns>Localized Operation Type string.</returns>
        private string GetStatusType(SubscriptionStatus statusType)
        {
            switch (statusType)
            {
            case SubscriptionStatus.Active:
                return(Resources.SubscriptionStatusTypeActive);

            case SubscriptionStatus.Deleted:
                return(Resources.SubscriptionStatusTypeDeleted);

            case SubscriptionStatus.None:
                return(Resources.SubscriptionStatusTypeNone);

            case SubscriptionStatus.Suspended:
                return(Resources.SubscriptionStatusTypeSuspended);

            default:
                return(string.Empty);
            }
        }
Esempio n. 24
0
        public dtoBaseSubscription(Boolean isAccepted, Boolean isEnabled, Boolean isResponsabile)
        {
            if (!isAccepted && !isEnabled)
            {
                Status = SubscriptionStatus.waiting;
            }
            else if (!isEnabled)
            {
                Status = SubscriptionStatus.blocked;
            }
            else
            {
                Status = SubscriptionStatus.activemember;
            }

            if (isResponsabile)
            {
                Status |= SubscriptionStatus.responsible;
            }
        }
Esempio n. 25
0
        public void Should_allow_valid_transition_for_2_entities(
            IEvent @event,
            UserStatus userStatusFrom,
            UserStatus userStatusTo,
            SubscriptionStatus subscriptionStatusFrom,
            SubscriptionStatus subscriptionStatusTo)
        {
            IMobStator <User, UserSubscription> mobStator = GetMobStatorForTwoEntities();

            var user = new User {
                Status = userStatusFrom
            };
            var subscription = new UserSubscription {
                Status = subscriptionStatusFrom
            };
            var result = mobStator.Go(@event, Tuple.Create(user, subscription));

            Assert.Equal(userStatusTo, user.Status);
            Assert.Equal(subscriptionStatusTo, subscription.Status);
            Assert.True(result.Success);
        }
Esempio n. 26
0
        /// <summary>
        /// Gets the current status of a subscription
        /// </summary>
        /// <param name="topic">The topic to check the subscription for.</param>
        /// <returns>The current status of the subscription</returns>
        public SubscriptionStatus GetSubscriptionsStatus(string topic)
        {
            SubscriptionStatus status = SubscriptionStatus.DoesNotExist;

            // if its live, return active
            if (subscriptions.ContainsKey(topic))
            {
                status = SubscriptionStatus.Active;
            }


            pendingSubscriptions.SingleOrDefault <KeyValuePair <int, Subscription> >(pair => pair.Value.Topic.Equals(topic, StringComparison.Ordinal));

            // if its pending, return pending.
            //if (pendingSubscriptions.SingleOrDefault<KeyValuePair<int, Subscription>>(pair => pair.Value.Topic.Equals(topic, StringComparison.Ordinal)) != null)
            //{
            //    status = SubscriptionStatus.Pending;
            // }

            return(status);
        }
Esempio n. 27
0
        private void InitializeCommunityFilters(ModuleCommunityManagement module, Int32 idCommunity, List <Int32> unavailableIdUsers)
        {
            View.OrderAscending = true;
            View.OrderUsersBy   = OrderUsersBy.SurnameAndName;
            Int32 idDefaultProfileType       = 0;
            Int32 idDefaultRole              = 0;
            long  idDefaultAgency            = 0;
            SubscriptionStatus defaultStatus = SubscriptionStatus.activemember;
            SearchProfilesBy   defaultSearch = SearchProfilesBy.Contains;

            //if (module.Administration || module.Manage)
            //{
            View.LoadRolesTypes(Service.GetAvailableSubscriptionsIdRoles(idCommunity, unavailableIdUsers), idDefaultRole);
            View.LoadAvailableSubscriptionsStatus(Service.GetAvailableSubscriptionsStatus(idCommunity, unavailableIdUsers), defaultStatus);
            if (View.ShowSubscriptionsFilterByProfile)
            {
                View.LoadProfileTypes(Service.GetAvailableProfileTypes(idCommunity, View.SelectedIdRole, View.SelectedSubscriptionStatus), idDefaultProfileType);
                if (View.SelectedIdProfileType == (int)UserTypeStandard.Employee)
                {
                    View.LoadAgencies(Service.GetAvailableAgencies(idCommunity, View.SelectedIdRole, View.SelectedSubscriptionStatus), idDefaultAgency, UserSelectionType.CommunityUsers);
                }
            }
            else if (HasEmployeeUsers(UserSelectionType.CommunityUsers) && (module.Administration || module.Manage))
            {
                View.LoadAgencies(Service.GetAvailableAgencies(idCommunity, View.SelectedIdRole, View.SelectedSubscriptionStatus), idDefaultAgency, UserSelectionType.CommunityUsers);
            }
            View.LoadSearchProfilesBy(GetSearchByItems(module), defaultSearch, UserSelectionType.CommunityUsers);

            dtoUserFilters filter = View.GetCurrentUserFilters;

            View.SearchUserFilters = filter;
            View.InitializeWordSelector(Service.GetAvailableSubsriptionStartLetter(filter, View.UnavailableIdUsers));
            ModuleProfileManagement pMmodule = ModuleProfileManagement.CreatePortalmodule(UserContext.UserTypeID);

            SetDefaultColumns(filter.IdRole, filter.IdProfileType, module.Administration || module.Manage, pMmodule, filter.Status);
            View.LoadSubscriptions(new List <dtoSubscriptionProfileItem <dtoBaseProfile> >());
            //}
            //else
            //    View.NoPermission();
        }
Esempio n. 28
0
        public AllSubscriptionModel getAllSubscription()
        {
            ENDPOINT = body.getQueryFindAllSubscription(_PUBLIC_KEY);
            string content = _request.Execute(
                ENDPOINT,
                "GET",
                _auxiliars.ConvertToBase64(_PUBLIC_KEY),
                PARAMETER);
            SubscriptionStatus   status       = JsonConvert.DeserializeObject <SubscriptionStatus>(content);
            AllSubscriptionModel subscription = new AllSubscriptionModel();

            if (status.status)
            {
                subscription = JsonConvert.DeserializeObject <AllSubscriptionModel>(content);
            }
            else
            {
                subscription.status  = false;
                subscription.message = status.message;
            }
            return(subscription);
        }
        private void HandleData(KrakenMessageEventArgs eventArgs, SubscriptionStatus subscription)
        {
            var dataType = subscription.Subscription.Name;

            if (dataType == SubscribeOptionNames.Ticker)
            {
                var tickerMessage = TickerMessage.CreateFromString(eventArgs.RawContent, subscription);
                TickerReceived.InvokeAll(this, new TickerEventArgs(subscription.ChannelId.Value, subscription.Pair, tickerMessage));
            }
            if (dataType == SubscribeOptionNames.OHLC)
            {
                var ohlcMessage = OhlcMessage.CreateFromString(eventArgs.RawContent);
                OhlcReceived.InvokeAll(this, new OhlcEventArgs(subscription.ChannelId.Value, subscription.Pair, ohlcMessage));
            }
            if (dataType == SubscribeOptionNames.Trade)
            {
                var tradeMessage = TradeMessage.CreateFromString(eventArgs.RawContent);
                TradeReceived.InvokeAll(this, new TradeEventArgs(subscription.ChannelId.Value, subscription.Pair, tradeMessage));
            }
            if (dataType == SubscribeOptionNames.Spread)
            {
                var spreadMessage = SpreadMessage.CreateFromString(eventArgs.RawContent);
                SpreadReceived.InvokeAll(this, new SpreadEventArgs(subscription.ChannelId.Value, subscription.Pair, spreadMessage));
            }
            if (dataType == SubscribeOptionNames.Book)
            {
                if (eventArgs.RawContent.Contains(@"""as"":") && eventArgs.RawContent.Contains(@"""bs"":"))
                {
                    var bookSnapshotMessage = BookSnapshotMessage.CreateFromString(eventArgs.RawContent);
                    BookSnapshotReceived.InvokeAll(this, new KrakenDataEventArgs <BookSnapshotMessage>(eventArgs.ChannelId.Value, subscription.Pair, bookSnapshotMessage));
                }
                if (eventArgs.RawContent.Contains(@"""a"":") || eventArgs.RawContent.Contains(@"""b"":"))
                {
                    var bookUpdateMessage = BookUpdateMessage.CreateFromString(eventArgs.RawContent);
                    BookUpdateReceived.InvokeAll(this, new KrakenDataEventArgs <BookUpdateMessage>(eventArgs.ChannelId.Value, subscription.Pair, bookUpdateMessage));
                }
            }
        }
Esempio n. 30
0
        public OperationResult <SubscriptionEntity> Save(string email, SubscriptionStatus status, DateTime subscribDateUtc, DateTime?confirmDateUtc, DateTime?cancelDateUtc)
        {
            var result = EngineContext.Current.Resolve <OperationResult <SubscriptionEntity> >();

            var subscription = Get(email, true, false);

            if (subscription == null)
            {
                subscription = new SubscriptionEntity {
                    IsEnabled = true,
                    Email     = email
                };
            }

            subscription.Status          = status;
            subscription.SubscribDateUtc = subscribDateUtc;
            subscription.ConfirmDateUtc  = confirmDateUtc;
            subscription.CancelDateUtc   = cancelDateUtc;

            result += Save(subscription, false);

            return(result.With(subscription));
        }
        private void SynchronizeSubscriptions(SubscriptionStatus currentStatus)
        {
            lock (Subscriptions)
            {
                if (currentStatus.ChannelId == null || !currentStatus.ChannelId.HasValue)
                {
                    logger.LogWarning("SubscriptionStatus has no channelID");
                    // no channelID --> error?
                    return;
                }

                // handle unsubscribe
                var channelIdValue = currentStatus.ChannelId.Value;
                if (currentStatus.Status == "unsubscribed")
                {
                    if (!Subscriptions.ContainsKey(channelIdValue))
                    {
                        return;
                    }

                    Subscriptions.Remove(channelIdValue);
                    logger.LogDebug("Subscription for {channelID} successfully removed", channelIdValue);
                    return;
                }

                // handle subscription
                var value = channelIdValue;
                if (Subscriptions.ContainsKey(value))
                {
                    Subscriptions[value] = currentStatus;
                }
                else
                {
                    Subscriptions.Add(value, currentStatus);
                }
            }
        }
Esempio n. 32
0
        public string SubscriptionStatusToString(SubscriptionStatus status)
        {
            var text = "Unknown";

            switch (status)
            {
            case SubscriptionStatus.Accepted:
                text = "Device accepted";
                break;

            case SubscriptionStatus.Error:
                text = ErrorString;
                break;

            case SubscriptionStatus.Subscribed:
                text = "Already subscribed";
                break;

            case SubscriptionStatus.WaitingForAuthorization:
                text = "Waiting for device authorization";
                break;
            }
            return(text);
        }
Esempio n. 33
0
 public void Subscribe()
 {
     lock (iSubscriptionStatusLock)
     {
         iSubscriptionStatus = SubscriptionStatus.eSubscribing;
     }
     CpProxySubscribe(iHandle);
 }
Esempio n. 34
0
        /// <summary>
        /// Starts regular updates of data
        /// </summary>
        public void Start()
        {
            lock (_subscriptionDataLock)
            {
                // set status
                Status = SubscriptionStatus.Running;

                // stop the timer
                StartTimer();
            }
        }
Esempio n. 35
0
 public static SubscriptionStatus CreateSubscriptionStatus(int subscriptionStatusID)
 {
     SubscriptionStatus subscriptionStatus = new SubscriptionStatus();
     subscriptionStatus.SubscriptionStatusID = subscriptionStatusID;
     return subscriptionStatus;
 }
        private void ResponseComments_Test(HttpStatusCode httpStatusCode, PushNotificationStatus pushNotificationStatus, DeviceConnectionStatus deviceConnectionStatus, SubscriptionStatus subscriptionStatus, string value)
        {
            var result = new PushNotificationSendResult()
            {
                HttpStatusCode = httpStatusCode,
                PushNotificationStatus = pushNotificationStatus,
                DeviceConnectionStatus = deviceConnectionStatus,
                PushNotificationSubscriptionStatus = subscriptionStatus,
            };

            Assert.AreEqual(result.Comments, value);
        }
Esempio n. 37
0
        /// <summary>
        /// Stops regular updates of data
        /// </summary>
        public void Stop()
        {
            lock (_subscriptionDataLock)
            {
                // set status
                Status = SubscriptionStatus.Idle;

                // stop the timer
                StopTimer();
            }
        }
Esempio n. 38
0
 public void Subscribe()
 {
     lock (iSubscriptionStatusLock)
     {
         iSubscriptionStatus = SubscriptionStatus.eSubscribing;
     }
     int ret = CpProxySubscribe(iHandle);
     if (ret == -1)
     {
         throw new SubscriptionException();
     }
 }
        ///// <summary>
        ///// Gets or sets the subscription items.
        ///// </summary>
        //[DataMember(Name = "subscription_items", IsRequired = false)]
        //public SubscriptionItemResponseList SubscriptionItems { set; get; }


        #endregion

        public SubscriptionResponse()
        {
            this.SignupDate = DateTime.MinValue.ToUniversalTime();
            this.ServiceResult = new ServiceResult();
            this.Status = SubscriptionStatus.ConfigurationError;
            //this.SubscriptionItems = new SubscriptionItemResponseList();
        }
Esempio n. 40
0
 public void Unsubscribe()
 {
     lock (iSubscriptionStatusLock)
     {
         iSubscriptionStatus = SubscriptionStatus.eNotSubscribed;
     }
     CpProxyUnsubscribe(iHandle);
 }
Esempio n. 41
0
 protected void ReportEvent(System.Action aCallback)
 {
     lock (iSubscriptionStatusLock)
     {
         if (iSubscriptionStatus == SubscriptionStatus.eSubscribing)
         {
             iSubscriptionStatus = SubscriptionStatus.eSubscribed;
         }
         if (iSubscriptionStatus == SubscriptionStatus.eSubscribed && aCallback != null)
         {
             aCallback();
         }
     }
 }
 private void InitializeStatusCodes(HttpWebResponse response)
 {
     if (response == null)
     {
         StatusCode = HttpStatusCode.InternalServerError;
         NotificationStatus = NotificationStatus.NotApplicable;
         DeviceConnectionStatus = DeviceConnectionStatus.NotApplicable;
         SubscriptionStatus = SubscriptionStatus.NotApplicable;
     }
     else
     {
         StatusCode = response.StatusCode;
         NotificationStatus = response.GetNotificationStatus();
         DeviceConnectionStatus = response.GetDeviceConnectionStatus();
         SubscriptionStatus = response.GetSubscriptionStatus();
     }
 }
Esempio n. 43
0
 public void AddToSubscriptionStatuses(SubscriptionStatus subscriptionStatus)
 {
     base.AddObject("SubscriptionStatuses", subscriptionStatus);
 }