/// <summary> /// Login handler /// </summary> /// <param name="ssoTicket">the sso ticket</param> /// <returns></returns> public bool TryLogin(string ssoTicket) { UserDao.Login(out playerData, ssoTicket); if (playerData == null) { return(false); } log = LogManager.GetLogger(Assembly.GetExecutingAssembly(), $"Player {playerData.Name}"); log.Debug($"Player {playerData.Name} has logged in"); UserSettingsDao.CreateOrUpdate(out settings, playerData.Id); PlayerManager.Instance.AddPlayer(this); playerData.PreviousLastOnline = playerData.LastOnline; playerData.LastOnline = DateTime.Now; UserDao.Update(playerData); Subscription = SubscriptionDao.GetSubscription(playerData.Id); Messenger = new Messenger(this); Messenger.SendStatus(); Authenticated = true; Send(new AuthenticationOKComposer()); Send(new ActivityPointNotificationComposer()); Send(new AvailabilityStatusComposer()); Send(new UserRightsMessageComposer(IsSubscribed ? 2 : 0, playerData.Rank)); return(true); }
public void Load() { Subscriptions = CatalogueDao.GetSubscriptionData(); Gifts = SubscriptionDao.GetSubscriptionGifts() .Select(x => new SubscriptionGift(x, CatalogueManager.Instance.GetItem(x.SaleCode))) .OrderBy(x => x.Data.DurationRequirement) .ToList(); }
/// <summary> /// Count the membership days when user logs on/off /// </summary> public void CountMemberDays() { if (player.IsSubscribed) { Data.SubscriptionAge += (long)DateTime.Now.Subtract(Data.SubscriptionAgeLastUpdated).TotalSeconds; Data.SubscriptionAgeLastUpdated = DateTime.Now; SubscriptionDao.SaveSubscriptionAge(player.Details.Id, Data.SubscriptionAge, Data.SubscriptionAgeLastUpdated); } }
/// <summary> /// Extend club days by months /// </summary> public void AddMonths(int months) { DateTime startTime; if (player.IsSubscribed) { startTime = Data.ExpireDate; } else { startTime = DateTime.Now; } if (Data == null) { var nextGiftDate = DateTime.Now; switch (ValueManager.Instance.GetString("club.gift.interval.type")) { case "MONTH": nextGiftDate = nextGiftDate.AddMonths(ValueManager.Instance.GetInt("club.gift.interval")); break; case "DAY": nextGiftDate = nextGiftDate.AddDays(ValueManager.Instance.GetInt("club.gift.interval")); break; } Data = new SubscriptionData { SubscribedDate = DateTime.Now, ExpireDate = startTime.AddMonths(months), UserId = player.Details.Id, GiftDate = nextGiftDate }; SubscriptionDao.UpdateSubscription(Data); } else { Data.ExpireDate = startTime.AddMonths(months); SubscriptionDao.SaveSubscriptionExpiry(player.Details.Id, Data.ExpireDate); } Update(); }
private (string Title, List <Article> Articles) SubscribeFeed(string feed, string appId) { var result = this.fetcher.Fetch(feed); if (result == default) { return(result); } using (var connection = this.helper.GetDbConnection()) { #region 插入 feed var feedDao = new FeedDao(connection); var feedId = feed.Md5(); var feedEntity = feedDao.GetFeed(feedId); if (feedEntity == null) { feedEntity = new Rss.Common.Entities.Feed { Id = feedId, Url = feed, Title = result.Title }; feedDao.InsertFeed(feedEntity); } #endregion #region 订阅 var subscriptionDao = new SubscriptionDao(connection); var subscription = subscriptionDao.GetSubscription(appId, feedId); if (subscription == null) { subscription = new Subscription { AppId = appId, FeedId = feedId }; subscriptionDao.InsertSubscription(subscription); } #endregion } return(result); }
public void Handle(Player player, Request request) { var subscriptionGift = SubscriptionManager.Instance.GetGift(request.ReadString()); if (player.IsSubscribed) { player.Subscription.Refresh(); } if (subscriptionGift == null || !player.IsSubscribed || player.Subscription.Data.GiftsRedeemable <= 0) { return; } if (!subscriptionGift.IsGiftRedeemable(player.Subscription.Data.SubscriptionAge)) { return; } player.Subscription.Data.GiftsRedeemable--; SubscriptionDao.SaveGiftsRedeemable(player.Details.Id, player.Subscription.Data.GiftsRedeemable); CatalogueManager.Instance.Purchase(player.Details.Id, subscriptionGift.CatalogueItem.Data.Id, 1, string.Empty, DateUtil.GetUnixTimestamp(), isClubGift: true); }
public Messenger(int userId) { subscription = SubscriptionDao.GetSubscription(userId); FriendRequestsEnabled = MessengerDao.GetAcceptsFriendRequests(userId); LoadMessengerData(userId); }
public void Load() { this.Data = SubscriptionDao.GetSubscription(player.Details.Id); }
/// <summary> /// Refresh subscription data object /// </summary> public void Refresh() { SubscriptionDao.Refresh(Data); }