Пример #1
0
 public User(string nickName, string email, AccountType accountType, SubscriptionType subscriptionType)
 {
     UserName         = nickName;
     Email            = email;
     AccountType      = accountType;
     SubscriptionType = subscriptionType;
 }
Пример #2
0
        public async Task <User> SubscribeUserAsync(string email, SubscriptionTypeEnum subscriptionType)
        {
            User user = await this.FindByEmailAsync(email);

            if (user is null)
            {
                throw new ApiException((int)ErrorEnum.UserAlreadyExist, nameof(ErrorEnum.UserAlreadyExist));
            }

            SubscriptionType subscriptionTypeResult = await _subscriptionTypeService.GetSubscriptionTypeById((int)subscriptionType);

            if (user.UserSubscriptions != null)
            {
                throw new ApiException((int)ErrorEnum.UserAlreadyExist, nameof(ErrorEnum.UserAlreadyExist));
            }
            var result = await _subscriptionTypeService.AddUserSubscriptionType(new UserSubscriptionType
            {
                SubscriptionTypeId = subscriptionTypeResult.Id,
                UserId             = user.Id,
                CreateDateTime     = DateTime.Now,
                IsActive           = true
            });

            IdentityResult results = await _userManager.UpdateAsync(user);

            return(user);
        }
Пример #3
0
        public ActionResult Create()
        {
            SubscriptionType subType     = new SubscriptionType();
            List <Product>   productList = new List <Product>();
            HttpClient       client      = WebApiServiceLogic.CreateClient(ServiceType.CentralizeWebApi);
            var response = client.GetAsync("api/Product/All").Result;

            if (response.IsSuccessStatusCode)
            {
                var jsondata = response.Content.ReadAsStringAsync().Result;
                if (!String.IsNullOrEmpty(jsondata))
                {
                    productList = JsonConvert.DeserializeObject <List <Product> >(jsondata);
                }
                subType.Products = productList;
            }
            else
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                ModelState.AddModelError("", response.ReasonPhrase + " - " + obj.Message);
            }
            subType.ActivationMonth     = 1;
            TempData["ActivationMonth"] = LicenseSessionState.Instance.SubscriptionMonth;
            return(View(subType));
        }
        public Restaurant(string name, int openingHour, int closingHour,
                          SubscriptionType subscriptionType, ContractStatus contractStatus, PhoneNumberValue phoneNumber,
                          string imageUrl, Locality locality, GeographicLocation location, string description,
                          string descriptionEng)
        {
            CheckRule(new OpeningAndClosingHoursAreValid(openingHour, closingHour));
            CheckRule(new ConditionMustBeTrueRule(subscriptionType != SubscriptionType.Invalid,
                                                  "subscription must be valid"));
            CheckRule(new ConditionMustBeTrueRule(contractStatus != ContractStatus.Invalid,
                                                  "contract must be valid"));
            CheckRule(new ConditionMustBeTrueRule(phoneNumber != null,
                                                  "phone number be valid"));

            ImageUrl           = imageUrl;
            Locality           = locality;
            GeographicLocation = location;
            Description        = description;
            DescriptionEng     = descriptionEng;
            Name             = name;
            OpeningHour      = openingHour;
            ClosingHour      = closingHour;
            SubscriptionType = subscriptionType;
            ContractStatus   = contractStatus;
            State            = RestaurantState.Open;
            ExpirationDate   = subscriptionType.GetExpirationTime();
            PhoneNumber      = phoneNumber;
        }
        public void TestGetSubscriptionTypeWrongName()
        {
            String           subTypeName = "WrongSubscription";
            SubscriptionType subType     = subscriptionTypeService.GetSubscriptionTypeByName(subTypeName);

            Assert.IsNull(subType);
        }
Пример #6
0
        public List <SubscriptionType> GetSubscriptionTypes()
        {
            SubscriptionType        subscriptionType;
            List <SubscriptionType> subscriptionTypes = new List <SubscriptionType>();

            try
            {
                string        query   = "select * from \"subscription_type\";";
                NpgsqlCommand Command =
                    new NpgsqlCommand(query, connection.CreateConnection.npgsqlConnection);
                NpgsqlDataReader dataReader = Command.ExecuteReader();
                foreach (DbDataRecord dbDataRecord in dataReader)
                {
                    subscriptionType = new SubscriptionType(dbDataRecord["subscription_type_id"].ToString(),
                                                            dbDataRecord["type"].ToString(), dbDataRecord["price"].ToString());
                    subscriptionTypes.Add(subscriptionType);
                }
                dataReader.Close();
            }
            catch (PostgresException ex)
            {
                MessageBox.Show("DB error. \n" + Convert.ToString(ex));
            }
            return(subscriptionTypes);
        }
Пример #7
0
        public List <SubscriptionType> GetSubscriptionTypes()
        {
            var types = new List <SubscriptionType>
            {
                new SubscriptionType()
                {
                    ID           = new Guid("{148B5E30-C81A-4ff8-B749-C46BAE340093}"),
                    Name         = Resource.WhatsNewSubscriptionName,
                    NotifyAction = Actions.SendWhatsNew,
                    Single       = true
                }
            };

            var astype = new SubscriptionType()
            {
                ID           = new Guid("{A4FFC01F-BDB5-450e-88C4-03FED17D67C5}"),
                Name         = Resource.AdministratorNotifySenderTypeName,
                NotifyAction = Actions.SendWhatsNew,
                Single       = false
            };

            types.Add(astype);

            return(types);
        }
Пример #8
0
 public Subscription(string deviceid, SubscriptionType type, string url, int userId)
 {
     this.type     = type;
     this.url      = url;
     this.userId   = userId;
     this.deviceid = deviceid;
 }
Пример #9
0
        public bool CreateSubscriptionAddToCart(SubscriptionType type)
        {
            SubscriptionTypeLogic typeLOgic = new SubscriptionTypeLogic();
            SubscriptionType      subType   = typeLOgic.CreateSubscriptionWithProduct(type);

            if (subType == null && String.IsNullOrEmpty(typeLOgic.ErrorMessage))
            {
                ErrorMessage = typeLOgic.ErrorMessage;
            }
            else
            {
                CartItem item = new CartItem()
                {
                    SubscriptionTypeId = subType.Id,
                    DateCreated        = DateTime.Now.Date,
                    Quantity           = 1,
                    UserId             = type.CreatedBy,
                    Price = subType.Price
                };
                CartLogic logic  = new CartLogic();
                var       status = logic.CreateCartItem(item);
                if (!status)
                {
                    ErrorMessage = logic.ErrorMessage;
                }
            }
            return(String.IsNullOrEmpty(ErrorMessage));
        }
Пример #10
0
 public Subscription(string deviceid, SubscriptionType type, string url, int userId)
 {
     this.type = type;
     this.url = url;
     this.userId = userId;
     this.deviceid = deviceid;
 }
Пример #11
0
        public MemberInfo SelectMember(int id)
        {
            AddParameter("@p_ID", id);

            using (MySqlDataReader reader = ExecuteReader("Member_Sel"))
            {
                ID = id;
                if (reader.Read())
                {
                    regNumber        = reader.GetString(0);
                    Name             = reader.GetString(1);
                    Address          = reader.GetString(2);
                    Mobile           = reader.GetString(3);
                    HomeTP           = reader.GetString(4);
                    Email            = reader.GetString(5);
                    Amount           = reader.GetInt32(6);
                    paymentType      = (PaymentType)reader.GetInt32(7);
                    bank             = (Banks)reader.GetInt32(8);
                    subscriptionType = (SubscriptionType)reader.GetInt32(9);
                    nameInMag        = reader.GetString(10);
                    numOfMagazine    = reader.GetInt32(11);
                    Note             = reader[12] == DBNull.Value?"": reader[12].ToString();
                }
            }


            return(this);
        }
        public void AddSubscriptionType(SubscriptionType subscriptionType)
        {
            logger.logInfo("Attempting to add a new subscription type ... ");

            var validationResult = Validation.Validate <SubscriptionType>(subscriptionType);

            if (!validationResult.IsValid)
            {
                String message = "Invalid fields for subscription type " + subscriptionType.SubscriptionTypeName;
                logger.logError(message);
                throw new ValidationException(message);
            }

            SubscriptionType oldSubscriptionType = GetSubscriptionTypeByName(subscriptionType.SubscriptionTypeName);

            if (oldSubscriptionType != null)
            {
                String message = "Subscription Type " + subscriptionType.SubscriptionTypeName + " is already registered.";
                logger.logError(message);
                throw new DuplicateException(message);
            }

            DataMapperFactoryMethod.GetCurrentFactory().SubscriptionTypeFactory.AddSubscriptionType(subscriptionType);
            logger.logInfo("Add subscription type operation ended.");
        }
Пример #13
0
        public async Task <BaseAudioticaResponse> SubscribeAsync(
            SubscriptionType plan,
            SubcriptionTimeFrame timeFrame,
            AudioticaStripeCard card,
            string coupon = null)
        {
            var creditCardData = new Dictionary <string, string>
            {
                { "name", card.Name },
                { "number", card.Number },
                { "expMonth", card.ExpMonth.ToString() },
                { "expYear", card.ExpYear.ToString() },
                { "cvc", card.Cvc }
            };

            // plan id and coupon are passed in url query
            var planId = plan == SubscriptionType.Silver ? "autc_silver" : "autc_gold";

            planId += "_" + timeFrame.ToString().ToLower();
            var url = string.Format(SubscribePath, planId, coupon);

            var resp = await PostAsync <LoginData>(url, creditCardData);

            if (resp.Success)
            {
                await SaveLoginStateAsync(resp);
            }

            return(resp);
        }
Пример #14
0
        private static ISubscriptionRequest CreateAuthorizeDotNetSubscriptionRequest(SubscriptionRegistration registrationInformation)
        {
            // Subscription information
            SubscriptionType selectedSubscriptionType = registrationInformation.AvailableSubscriptionTypes.First(st => st.SubscriptionTypeId == registrationInformation.SelectedSubscriptionTypeId);

            return(CreateAuthorizeDotNetSubscriptionRequest(registrationInformation.CreditCard, selectedSubscriptionType));
        }
Пример #15
0
 public DataLoaderTestSchema(IServiceProvider services, QueryType query, SubscriptionType subscriptionType)
     : base(services)
 {
     Query        = query; //runs with parallel execution strategy
     Mutation     = query; //runs with serial execution strategy
     Subscription = subscriptionType;
 }
        public void OneTimeSetUp()
        {
            userRepository         = new InMemoryUserRepository();
            subscriptionRepository = new InMemorySubscriptionRepository();
            loginRepository        = new InMemoryLoginRepository();
            subscriptionType       = new SubscriptionType(1, "s", 8, 1, 1, 1, 1, 1, 1, "s");
            var user   = new User(-1, "1", "1", false, UserType.User);
            var userId = userRepository.Create(user);
            var sub    = new Subscription(-1, 1, userId, DateTime.Now.AddMonths(-8).AddDays(-1), 1, true)
            {
                Type = subscriptionType
            };

            subscriptionRepository.Create(sub);
            PasswordHashing.CreatePasswordHash("test", out var hash, out var salt);
            var login = new Login(-1, hash, salt, "*****@*****.**", userId);

            loginRepository.Create(login);

            user   = new User(-1, "1", "1", false, UserType.Staff);
            userId = userRepository.Create(user);
            login  = new Login(-1, hash, salt, "*****@*****.**", userId);
            loginRepository.Create(login);

            user   = new User(-1, "1", "1", false, UserType.User);
            userId = userRepository.Create(user);
            sub    = new Subscription(-1, 1, userId, DateTime.Now.AddMonths(-7).AddDays(-10), 1, true)
            {
                Type = subscriptionType
            };
            subscriptionRepository.Create(sub);
            login = new Login(-1, hash, salt, "*****@*****.**", userId);
            loginRepository.Create(login);
        }
Пример #17
0
 public KeyValuePair <long, DateTime> CreateNewSubscription(long clientID, long courseID, long eduLevelID, long gradeID, long termID, string key)
 {
     lock (_clientsLock)
     {
         long          id         = GetId();
         DateTime      now        = DateTime.Now;
         KeyValidation validation = new Keys().CheckKey(key);
         if (validation != KeyValidation.Invalid)
         {
             SubscriptionType type = (validation == KeyValidation.ValidFullYear) ? SubscriptionType.Year : SubscriptionType.Term;
             if (_clients.Exists(x => x.ID == clientID))
             {
                 _clients.Find(x => x.ID == clientID).ActiveSubscriptions.Add(new Subscription
                 {
                     ID                 = id,
                     ClientID           = clientID,
                     CourseID           = courseID,
                     EduLevelID         = eduLevelID,
                     GradeID            = gradeID,
                     TermID             = termID,
                     SubscriptionType   = type,
                     ExpirationDateTime = now,
                     Key                = key
                 });
                 return(new KeyValuePair <long, DateTime>(id, now));
             }
         }
         return(new KeyValuePair <long, DateTime>());
     }
 }
        private SubscriptionType GetSubscriptionTypeByString(string subscriptionType)
        {
            SubscriptionType getSubscriptionType = TipezeNyumbaUnitOfWork.Repository <SubscriptionType>()
                                                   .Get(u => u.type == subscriptionType);

            return(getSubscriptionType);
        }
Пример #19
0
        /// <summary>
        /// Occurs on charge exception.
        /// </summary>
        /// <param name="ex">Exception.</param>
        /// <param name="userId">User Id.</param>
        /// <param name="subscriptionType">subscription type.</param>
        /// <param name="token">Charge token.</param>
        /// <param name="user">User.</param>
        /// <param name="charge">Charge.</param>
        private void OnChargeException(
            Exception ex,
            int userId,
            SubscriptionType subscriptionType,
            string token,
            User user,
            Stripe.StripeCharge charge,
            ChargeException.ChargeFailureReason?reason = null)
        {
            StringBuilder   chargeFailureDetails = new StringBuilder();
            FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);

            chargeFailureDetails.AppendLine(ex.Message).AppendLine();
            chargeFailureDetails.AppendLine("------------------------------------------------------------------").AppendLine();
            chargeFailureDetails.AppendLine(string.Format("Subscription type: {0}", Enum.GetName(typeof(SubscriptionType), subscriptionType)));
            chargeFailureDetails.AppendLine(string.Format("Stripe token: {0}", token));
            chargeFailureDetails.AppendLine("------------------------------------------------------------------").AppendLine();

            if (charge != null)
            {
                chargeFailureDetails.AppendLine(string.Format("Charge failure code: {0}", charge.FailureCode));
                chargeFailureDetails.AppendLine(string.Format("Charge failure message: {0}", charge.FailureMessage));
                chargeFailureDetails.AppendLine("------------------------------------------------------------------").AppendLine();
            }

            chargeFailureDetails.AppendLine(string.Format("Version: {0}, User: {1} <{2}>", fvi.FileVersion, user != null ? user.Name : "?", user != null ? user.Email : "?")).AppendLine();
            chargeFailureDetails.AppendLine("------------------------------------------------------------------").AppendLine();
            chargeFailureDetails.AppendLine(ex.StackTrace);

            throw new ChargeException(reason.HasValue ? reason.Value : ChargeException.ChargeFailureReason.InternalError, userId, subscriptionType, user, charge != null ?
                                      new ChargeException.ChargeInfo(charge.FailureCode, charge.FailureMessage) : null, chargeFailureDetails.ToString());
        }
        private SubscriptionType GetSubscriptionTypeById(int id)
        {
            SubscriptionType getSubscriptionType = TipezeNyumbaUnitOfWork.Repository <SubscriptionType>()
                                                   .Get(u => u.subscriptionID == id);

            return(getSubscriptionType);
        }
        public object RenderGroupItemSubscriptions(Guid itemId, Guid subItemId, Guid subscriptionTypeId)
        {
            try
            {
                SubscriptionType type = null;

                var productSubscriptionManager = WebItemManager.Instance[itemId].Context.SubscriptionManager as IProductSubscriptionManager;

                ISubscriptionManager subscriptionManager = productSubscriptionManager;

                if (productSubscriptionManager.GroupByType == GroupByType.Modules)
                {
                    subscriptionManager = WebItemManager.Instance[subItemId].Context.SubscriptionManager;
                }

                var subscriptionTypes = subscriptionManager.GetSubscriptionTypes();
                if (subscriptionTypes != null && subscriptionTypes.Count != 0)
                {
                    type = (from s in subscriptionTypes
                            where s.ID.Equals(subscriptionTypeId)
                            select s).Single <SubscriptionType>();
                }

                var result = new { Status = 1, ItemId = itemId, SubItemId = subItemId, TypeId = subscriptionTypeId, Objects = new List <object>() };

                if (type.Single || type.CanSubscribe)
                {
                    return(result);
                }

                if (type.IsEmptySubscriptionType != null && type.IsEmptySubscriptionType(itemId, subItemId, subscriptionTypeId))
                {
                    return(result);
                }

                if (type.GetSubscriptionObjects == null)
                {
                    return(result);
                }

                var typeObjects = type.GetSubscriptionObjects(itemId, subItemId, subscriptionTypeId);
                if (typeObjects == null || typeObjects.Count == 0)
                {
                    return(result);
                }

                typeObjects.Sort((s1, s2) => String.Compare(s1.Name, s2.Name, true));

                foreach (var subscription in typeObjects)
                {
                    result.Objects.Add(new { Id = subscription.ID, Name = HttpUtility.HtmlEncode(subscription.Name), Url = String.IsNullOrEmpty(subscription.URL) ? "" : subscription.URL });
                }

                return(result);
            }
            catch (Exception e)
            {
                return(new { Status = 0, Message = e.Message.HtmlEncode() });
            }
        }
Пример #22
0
 /// <summary>
 /// Argument Constructor
 /// </summary>
 /// <param name="security">Contains Symbol information</param>
 /// <param name="provider">Market Data Provider details</param>
 /// <param name="marketDataType">Type of Market Data to subscribe</param>
 /// <param name="subscriptionType">Subscription category e.g. Subscribe, Un-Subscribe</param>
 public SubscriptionRequest(Security security, MarketDataProvider provider, MarketDataType marketDataType, SubscriptionType subscriptionType)
 {
     _security         = security;
     _provider         = provider;
     _marketDataType   = marketDataType;
     _subscriptionType = subscriptionType;
 }
Пример #23
0
 /// <summary>
 /// Create a new subscription item passing in the recurrentItem
 /// </summary>
 /// <param name="recurrentItem">The item for the subscription</param>
 /// <param name="period">The period attribute specifies how frequently
 /// you will charge the customer for the subscription</param>
 /// <param name="type">
 /// The type attribute identifies the type of subscription that you are creating.
 /// The valid values for this attribute are merchant and google,
 /// and this specifies who handles the recurrences.
 /// </param>
 public Subscription(IShoppingCartItem recurrentItem, AutoGen.DatePeriod period,
                     SubscriptionType type)
 {
     this.RecurrentItem = recurrentItem;
     this.Period        = period;
     this.Type          = type;
 }
Пример #24
0
 public Subscription(SubscriptionType type, string[] deviceGuids, string[] eventNames, Action<object> callback)
 {
     Type = type;
     DeviceGuids = deviceGuids;
     EventNames = eventNames;
     Callback = callback;
 }
Пример #25
0
        public MemberInfo SelectMemberbyRegNumber(string index)
        {
            AddParameter("@p_regNumber", index);

            using (MySqlDataReader reader = ExecuteReader("Member_SelRegNumber"))
            {
                if (reader.Read())
                {
                    regNumber        = reader.GetString(0);
                    Name             = reader.GetString(1);
                    Address          = reader.GetString(2);
                    Mobile           = reader.GetString(3);
                    HomeTP           = reader.GetString(4);
                    Email            = reader.GetString(5);
                    Amount           = reader.GetInt32(6);
                    paymentType      = (PaymentType)reader.GetInt32(7);
                    bank             = (Banks)reader.GetInt32(8);
                    subscriptionType = (SubscriptionType)reader.GetInt32(9);
                    nameInMag        = reader.GetString(10);
                    ID            = reader.GetInt32(11);
                    numOfMagazine = reader.GetInt32(12);
                    Note          = reader.GetString(13);
                }
            }


            return(this);
        }
Пример #26
0
        public static AudioBook GetNewAudioBook(ApplicationContext db, AudioBookInputViewModel inputModel)
        {
            AudioBook book = new AudioBook
            {
                BookName        = inputModel.BookName,
                Author          = inputModel.Author,
                ReadingTime     = inputModel.ReadingTime,
                ContentFilePath = inputModel.ContentFilePath,
                CoverFilePath   = inputModel.CoverFilePath,
                Description     = inputModel.Description
            };

            ICollection <Genre> genres = GetGenresList(db, inputModel.GenresList);

            foreach (Genre g in genres)
            {
                book.Genres.Add(g);
            }
            SubscriptionType type = db.SubscriptionTypes.FirstOrDefault(s => s.Name == inputModel.SubscriptionType);

            if (type == null)
            {
                return(null);
            }
            book.SubscriptionType = type;
            return(book);
        }
Пример #27
0
        public SubscriptionInfo GetSubscriberForAssignment(SubscriptionType type, OperationContext context)
        {
            lock (_mutex)
            {
                if (_subscriptionLoadBalancer.IsValid)
                {
                    string firstselectedClientId = null;
                    string selectedClient        = null;
                    while (true)
                    {
                        selectedClient = _subscriptionLoadBalancer.GetNext();

                        //breaks the loop
                        if (firstselectedClientId != null && string.Compare(selectedClient, firstselectedClientId, true) == 0)
                        {
                            return(null);
                        }

                        if (firstselectedClientId == null)
                        {
                            firstselectedClientId = selectedClient;
                        }
                        ClientSubscriptionManager clientManager = _subscriptions[selectedClient];

                        if (clientManager.IsActive)
                        {
                            return(clientManager.GetNextAvailableSubscription(type));
                        }
                    }
                }
            }
            return(null);
        }
Пример #28
0
        public static AudioBook GetUpdatedAudioBook(ApplicationContext db, AudioBookInputViewModel inputModel)
        {
            AudioBook book = db.AudioBooks.Find(inputModel.Id);

            if (book == null)
            {
                return(null);
            }
            book.BookName        = inputModel.BookName;
            book.Author          = inputModel.Author;
            book.ReadingTime     = inputModel.ReadingTime;
            book.ContentFilePath = inputModel.ContentFilePath;
            book.CoverFilePath   = inputModel.CoverFilePath;
            book.Description     = inputModel.Description;
            book.Genres.Clear();
            ICollection <Genre> genres = GetGenresList(db, inputModel.GenresList);

            foreach (Genre g in genres)
            {
                book.Genres.Add(g);
            }
            SubscriptionType type = db.SubscriptionTypes.FirstOrDefault(s => s.Name == inputModel.SubscriptionType);

            if (type == null)
            {
                return(null);
            }
            book.SubscriptionType = type;
            return(book);
        }
Пример #29
0
        public static TextBook GetNewTextBook(ApplicationContext db, TextBookInputViewModel inputModel)
        {
            TextBook book = new TextBook
            {
                BookName        = inputModel.BookName,
                Author          = inputModel.Author,
                Pages           = inputModel.Pages,
                ContentFilePath = inputModel.ContentFilePath,
                CoverFilePath   = inputModel.CoverFilePath,
                Description     = inputModel.Description
            };

            ICollection <Genre> genres = inputModel.GenresList.Trim().Split().Select(s => db.Genres.FirstOrDefault(g => g.Name == s)).ToList();

            foreach (Genre g in genres)
            {
                book.Genres.Add(g);
            }
            SubscriptionType type = db.SubscriptionTypes.FirstOrDefault(s => s.Name == inputModel.SubscriptionType);

            if (type == null)
            {
                return(null);
            }
            book.SubscriptionType = type;
            return(book);
        }
Пример #30
0
 public Subscription(Guid customerId, DateTime start, SubscriptionType type, PricingPlan pricingPlan)
 {
     CustomerId  = customerId;
     Start       = start;
     Type        = type;
     PricingPlan = pricingPlan;
 }
 /// <summary>
 /// Create a new subscription item passing in the recurrentItem
 /// </summary>
 /// <param name="recurrentItem">The item for the subscription</param>
 /// <param name="period">The period attribute specifies how frequently 
 /// you will charge the customer for the subscription</param>
 /// <param name="type">
 /// The type attribute identifies the type of subscription that you are creating. 
 /// The valid values for this attribute are merchant and google, 
 /// and this specifies who handles the recurrences.
 /// </param>
 public Subscription(IShoppingCartItem recurrentItem, AutoGen.DatePeriod period,
     SubscriptionType type)
 {
     this.RecurrentItem = recurrentItem;
       this.Period = period;
       this.Type = type;
 }
Пример #32
0
        private async Task Unsubscribe(IEnumerable <TKey> ids, SubscriptionType subscribe, Action <Serie <TKey, TEntry> > callback)
        {
            IDictionary <TKey, List <Action <Serie <TKey, TEntry> > > > single;

            switch (subscribe)
            {
            case SubscriptionType.LatestPerCollection:
                single = _latestCallbacksForSingle;
                break;

            case SubscriptionType.AllFromCollections:
                single = _allCallbacksForSingle;
                break;

            default:
                throw new ArgumentException(nameof(subscribe));
            }

            var removedSubscriptions = RemoveSubscriptionsFromLatest(ids, callback, single);

            if (removedSubscriptions.Count > 0)
            {
                try
                {
                    await OnUnsubscribed(removedSubscriptions, subscribe).ConfigureAwait(false);
                }
                catch (Exception)
                {
                    AddSubscriptionsToLatest(ids, callback, single);

                    throw;
                }
            }
        }
Пример #33
0
 public List <UserRosterItem> GetRosterItems(string userName, SubscriptionType subscriptionType)
 {
     lock (syncRoot)
     {
         return(GetRosterItems(userName).FindAll(i => { return i.Subscribtion == subscriptionType; }));
     }
 }
Пример #34
0
 public Subscription(SubscriptionType type, string[] deviceGuids, string[] eventNames, Action<object> callback, DateTime timestamp)
 {
     Type = type;
     DeviceGuids = deviceGuids;
     EventNames = eventNames;
     Callback = callback;
     Timestamp = timestamp;
 }
Пример #35
0
 public Task<BaseAudioticaResponse> SubscribeAsync(
     SubscriptionType plan, 
     SubcriptionTimeFrame timeFrame, 
     AudioticaStripeCard card, 
     string coupon = null)
 {
     throw new NotImplementedException();
 }
Пример #36
0
 public SubscriberInfo(string userName, string email, string firstName, string lastName, SubscriptionType subscriptionType)
 {
     this.UserName = userName;
      this.Email = email;
      this.FirstName = firstName;
      this.LastName = lastName;
      this.SubscriptionType = subscriptionType;
 }
Пример #37
0
 /// <summary>
 /// Initializes a new subscription model with a SubscriptionType and modelId.
 /// </summary>
 /// <param name="type"></param>
 /// <param name="modelId"></param>
 public Subscription(SubscriptionType type, string modelId)
 {
     _modelId = modelId;
     SubscriptionType = type;
     SubscriptionId = SubscriptionType == SubscriptionType.Cloud
                      ? "CLOUD:" + modelId
                      : "USER:" + modelId;
 }
Пример #38
0
 public SqsReadConfiguration(SubscriptionType subscriptionType)
 {
     SubscriptionType = subscriptionType;
     MessageRetentionSeconds = JustSayingConstants.DEFAULT_RETENTION_PERIOD;
     ErrorQueueRetentionPeriodSeconds = JustSayingConstants.MAXIMUM_RETENTION_PERIOD;
     VisibilityTimeoutSeconds = JustSayingConstants.DEFAULT_VISIBILITY_TIMEOUT;
     RetryCountBeforeSendingToErrorQueue = JustSayingConstants.DEFAULT_HANDLER_RETRY_COUNT;
 }
Пример #39
0
 public Subscription(
     Type messageType,
     SubscriptionType subscriptionType,
     IEnumerable<ApplicationEndpoints> applicationEndpointsList)
     : base(messageType, applicationEndpointsList)
 {
     this.Type = subscriptionType;
 }
Пример #40
0
 public Subscription(string eventName, Action<ITextArgs> action, SubscriptionType subscriptionType = SubscriptionType.All, uint limit = 0, bool confirm = false)
 {
     this.Event = eventName.ToLower();
     this.Callback = action;
     this.SubscriptionType = subscriptionType;
     this.Counter = 0;
     this.Limit = limit;
     this.Confirm = confirm;
 }
Пример #41
0
 public Subscription(string eventName, SubscriptionType subscriptionType = SubscriptionType.All, uint limit = 0, bool confirm = false)
 {
     this.Event = eventName.ToLower();
     this.SubscriptionType = subscriptionType;
     this.Counter = 0;
     this.Limit = limit;
     this.IsPrimitive = true;
     this.Confirm = confirm;
 }
Пример #42
0
 public Listener(string topic, Action<IMessage> action, SubscriptionType subscriptionType = SubscriptionType.All, uint limit = 0, bool confirm = false)
 {
     this.Topic = topic.ToLower();
     this.Callback = action;
     this.SubscriptionType = subscriptionType;
     this.Counter = 0;
     this.Limit = limit;
     this.Confirm = confirm;
 }
Пример #43
0
 public Listener(string topic, SubscriptionType subscriptionType = SubscriptionType.All, uint limit = 0, bool confirm = false)
 {
     this.Topic = topic.ToLower();
     this.SubscriptionType = subscriptionType;
     this.Counter = 0;
     this.Limit = limit;
     this.IsPrimitive = true;
     this.Confirm = confirm;
 }
Пример #44
0
 public Listener(string topic, MethodInfo action, Type parameter, SubscriptionType subscriptionType = SubscriptionType.All, uint limit = 0, bool confirm = false)
 {
     this.Topic = topic.ToLower();
     this.mi = action;
     this.Type = parameter;
     this.SubscriptionType = subscriptionType;
     this.Counter = 0;
     this.Limit = limit;
     this.Confirm = confirm;
 }
 /// <summary>
 /// Adds a subscription
 /// </summary>
 /// <param name="type"></param>
 /// <param name="objectId"></param>
 public void AddSubscription(SubscriptionType type, string objectId)
 {
     var sub = new Subscription {SubscriptionType = type, ModelId = objectId};
     switch (type)
     {
         case SubscriptionType.Cloud:
             if (SubscribedClouds.Contains(sub)) return;
             SubscribedClouds.Add(sub);
             break;
         case SubscriptionType.User:
             if (SubscribedUsers.Contains(sub)) return;
             SubscribedUsers.Add(sub);
             break;
     }
 }
 /// <summary>
 /// This returns monitoring information for all commands pending for all subscriptions using this Distributor.
 /// </summary>
 /// <param name="connection">The connection to run the command on.</param>
 /// <param name="filterpublisher">To limit the result set to a single Publisher, specify filterpublisher.</param>
 /// <param name="filterpublisherdb">To limit the result set to a single Publisher Database, specify filterpublisherdb.</param>
 /// <param name="filterpublication">To limit the result set to a single Publication, specify filterpublisher.</param>
 /// <param name="filtersubscriber">To limit the result set to a single Subscriber, specify filtersubscriber.</param>
 /// <param name="filtersubscriberdb">To limit the result set to a single Subscription Database, specify filtersubscriberdb.</param>
 /// <param name="filtersubscriptiontype">The type of subscription to filter.</param>
 /// <returns>This returns monitoring information for all commands pending for all subscriptions using this Distributor.</returns>
 /// <remarks>See <a href="http://technet.microsoft.com/en-us/library/ms189452.aspx">MSDN</a></remarks>
 public static IEnumerable<PendingTransactionalCommands> ListPendingTransactionalCommands(this SqlConnection connection, 
     string filterpublisher = null, string filterpublisherdb = null, string filterpublication = null, 
     string filtersubscriber = null, string filtersubscriberdb = null, 
     SubscriptionType filtersubscriptiontype = SubscriptionType.Push)
 {
     return connection.Query<PendingTransactionalCommands>("sp_replmonitorsubscriptionpendingcmds",
         new
         {
             publisher = new DbString { Value = filterpublisher, IsAnsi = true, Length = 128 },
             publisher_db = new DbString { Value = filterpublisherdb, IsAnsi = true, Length = 128 },
             publication = new DbString { Value = filterpublication, IsAnsi = true, Length = 128 },
             subscriber = new DbString { Value = filtersubscriber, IsAnsi = true, Length = 128 },
             subscriber_db = new DbString { Value = filtersubscriberdb, IsAnsi = true, Length = 128 },
             subscription_type = filtersubscriptiontype
         },
         commandType: CommandType.StoredProcedure
     );
 }
Пример #47
0
		/// <summary>
		/// Initializes a new SubscriptionMessage for the specified message type
		/// that indicates whether to add or remove a subscription.
		/// </summary>
		/// <param name="typeName"></param>
		/// <param name="subscriptionType"></param>
        public SubscriptionMessage(string typeName, SubscriptionType subscriptionType)
        {
            TypeName = typeName;
            SubscriptionType = subscriptionType;
        }
Пример #48
0
 public virtual List<UserRosterItem> GetRosterItems(Jid rosterJid, SubscriptionType subscriptionType)
 {
     return GetRosterItems(rosterJid).FindAll(i => { return i.Subscribtion == subscriptionType; });
 }
Пример #49
0
 /// <summary>
 /// Allow stanzas by subscription type
 /// </summary>
 /// <param name="subType"></param>
 /// <param name="Order"></param>
 /// <param name="stanza">stanzas you want to block</param>
 /// <returns></returns>
 public Item AllowBySubscription(SubscriptionType subType, int Order, Stanza stanza)
 {
     return new Item(Action.allow, Order, CSS.IM.XMPP.protocol.iq.privacy.Type.subscription, subType.ToString(), stanza);
 }
Пример #50
0
        private void Subscribe(string name, SubscriptionType subscriptionType, uint limit = 0)
        {
            ThrowIfPrimitive();
            var subscription = new Subscription(name, subscriptionType, limit);
            this.AddBinding(subscription);

            if (this.IsConnected)
            {
                Send(this.AsTextArgs(new XSubscriptions
                {
                    Event = name.ToLower()
                }, Constants.Events.PubSub.Subscribe), () => { subscription.IsBound = true; });
            }
        }
Пример #51
0
 private void Subscribe(string name, Action<ITextArgs> callback, Action<ITextArgs> confirmCallback, SubscriptionType subscriptionType, uint limit = 0)
 {
     ThrowIfPrimitive();
     var subscription = new Subscription(name.ToLower(), callback, subscriptionType, limit, true);
     this.AddBinding(subscription);
     AddConfirmCallback(confirmCallback, subscription.Event);
     if (this.IsConnected)
     {
         Send(this.AsTextArgs(new XSubscriptions { Event = name.ToLower(), Confirm = true}, Constants.Events.PubSub.Subscribe), () => subscription.IsBound = true);
     }
 }
Пример #52
0
 /// <summary>
 /// Block stanzas by subscription type
 /// </summary>
 /// <param name="subType"></param>
 /// <param name="Order"></param>
 /// <param name="stanza">stanzas you want to block</param>
 /// <returns></returns>
 public Item BlockBySubscription(SubscriptionType subType, int Order, Stanza stanza)
 {
     return new Item(Action.deny, Order, XMPPProtocol.Protocol.iq.privacy.Type.subscription, subType.ToString(), stanza);
 }
Пример #53
0
        public PlatformApplication SubscribeTo(
            Type messageType,
            string fromApplication = "*",
            SubscriptionType subscriptionType = SubscriptionType.RoundRobin)
        {
            this.ThrowIfReadOnly();

            if (messageType != null)
            {
                this.Subscriptions = this.Subscriptions.Concat(
                    new[] { new Subscription(messageType, fromApplication, subscriptionType) })
                    .ToList()
                    .AsReadOnly();
            }

            return this;
        }
Пример #54
0
            public Subscription(
                Type messageType,
                string fromApplication,
                SubscriptionType subscriptionType)
            {
                CodeContract.ArgumentNotNull("messageType", messageType);
                CodeContract.ArgumentNotNullOrWhitespace("fromApplication", fromApplication);

                this.MessageType = messageType;
                this.FromApplication = fromApplication;
                this.SubscriptionType = subscriptionType;
            }
Пример #55
0
        internal static Subscription UpdateOrInsertSubscription(string deviceid, SubscriptionType type, string url, int userId)
        {
            using (SqlConnection connection = new SqlConnection(Globals.SqlConnectionString))
            {
                connection.Open();
                using (SqlTransaction sqlTransaction = connection.BeginTransaction())
                {
                    // Open the connection in a try/catch block.
                    // Create and execute the DataReader, writing the result
                    // set to the console window.
                    try
                    {
                        // Create the Command and Parameter objects.
                        using (SqlCommand command = new SqlCommand(Subscription.UpdateSubscriptionCommandString, connection, sqlTransaction))
                        {
                            command.Parameters.AddWithValue("@deviceid", deviceid);
                            command.Parameters.AddWithValue("@subscriptionType", type);
                            command.Parameters.AddWithValue("@pushUrl", url);
                            command.Parameters.AddWithValue("@userId", userId);

                            int result = command.ExecuteNonQuery();

                            if (result > 0)
                            {
                                sqlTransaction.Commit();

                                return new Subscription(deviceid, type, url, userId);
                            }
                            else
                            {
                                return Subscription.Subscribe(deviceid, type, url, userId, sqlTransaction, connection);
                            }
                        }
                    }
                    catch (Exception)
                    {
                        sqlTransaction.Rollback();
                    }
                    finally
                    {
                        UserService.Instance.RemoveUserFromCache(userId);
                        connection.Close();
                    }
                }
            }

            return null;
        }
Пример #56
0
 /// <summary>
 ///   Allow stanzas by subscription type
 /// </summary>
 /// <param name="subType"> </param>
 /// <param name="Order"> </param>
 /// <param name="stanza"> stanzas you want to block </param>
 /// <returns> </returns>
 public Item AllowBySubscription(SubscriptionType subType, int Order, Stanza stanza)
 {
     return new Item(Action.allow, Order, Type.subscription, subType.ToString(), stanza);
 }
 public IEnumerable<PendingTransactionalCommands> ListPendingTransactionalCommands(string connectionstringname, string publisher = null, string publisherdb = null, string publication = null, string subscriber = null, string subscriberdb = null, SubscriptionType subscriptiontype = SubscriptionType.Pull)
 {
     using (var c = GetOpenConnection(connectionstringname))
         return c.ListPendingTransactionalCommands(publisher, publisherdb, publication, subscriber, subscriberdb, subscriptiontype);
 }
Пример #58
0
 /// <summary>
 ///   Block stanzas by subscription type
 /// </summary>
 /// <param name="subType"> </param>
 /// <param name="Order"> </param>
 /// <param name="stanza"> stanzas you want to block </param>
 /// <returns> </returns>
 public Item BlockBySubscription(SubscriptionType subType, int Order, Stanza stanza)
 {
     return new Item(Action.deny, Order, Type.subscription, subType.ToString(), stanza);
 }
Пример #59
0
		public List<UserRosterItem> GetRosterItems(string userName, SubscriptionType subscriptionType)
		{
			lock (syncRoot)
			{
				return GetRosterItems(userName).FindAll(i => { return i.Subscribtion == subscriptionType; });
			}
		}
Пример #60
0
 internal override void InternalSubscribeAllowedSet(SubscriptionType value)
 {
     throw new PeerToPeerException(SR.GetString(SR.Collab_SubscribeLocalContactFailed));
 }