Beispiel #1
0
 public bool RequireNotification(User user, AppUpdateType type) {
     if (Status == AppTrackStatus.Owned) {
         return user.NotifyOnOwnedUpdate && type == AppUpdateType.NewRelease;
     }
     else {
         return (user.NotifyOnWishFree && type == AppUpdateType.PriceFree) ||
             (user.NotifyOnWishPriceDrop && type == AppUpdateType.PriceDecrease) ||
             (user.NotifyOnWishUpdate && type == AppUpdateType.NewRelease);
     }
 }
Beispiel #2
0
        private AppUpdateOptions(AppUpdateType appUpdateType, bool allowAssetPackDeletion)
        {
            const string appUpdateOptionsClassName =
                PlayCoreConstants.PlayCorePackagePrefix + "appupdate.AppUpdateOptions";

            using (var appUpdateOptionsClass = new AndroidJavaClass(appUpdateOptionsClassName))
            {
                var builder = appUpdateOptionsClass.CallStatic <AndroidJavaObject>(
                    "newBuilder", (int)appUpdateType);
                builder.Call <AndroidJavaObject>("setAllowAssetPackDeletion",
                                                 allowAssetPackDeletion);
                _javaAppUpdateOptions = builder.Call <AndroidJavaObject>("build");
                if (_javaAppUpdateOptions == null)
                {
                    throw new NullReferenceException("Play Core returned null AppUpdateOptions");
                }
            }
        }
Beispiel #3
0
        private ICollection<TrackingApp> RetrieveTrackingApps(AppUpdateType updateType, int size = 9) {
            AppListQuery appQuery = new AppListQuery() {
                UpdateType = updateType,
                PageIndex = 1,
                PageSize = size
            };
            appQuery = Repository.App.Search(appQuery);

            if (User.Identity.IsAuthenticated) {
                AppTrackQuery trackQuery = new AppTrackQuery() {
                    PageIndex = 1,
                    PageSize = appQuery.Result.Count,
                    User = CurrentUser.Id,
                    RelatedApps = appQuery.Result.Select(a => a.Id)
                };
                ICollection<AppTrack> tracks = Repository.AppTrack.Retrieve(trackQuery).Result;

                return new TrackingAppQuery(appQuery, tracks).Result;
            }
            else {
                return appQuery.Result.Select(a => new TrackingApp(a, null)).ToArray();
            }
        }
Beispiel #4
0
        static UpdateNotifier() {
            // 初始化模板
            IEnumerable<AppUpdateType> values = new AppUpdateType[] { 
                AppUpdateType.NewRelease, 
                AppUpdateType.PriceDecrease, 
                AppUpdateType.PriceFree
            };

            string templateDirectory = 
                Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "MailTemplate");
            templates = 
                values.ToDictionary(t => t, t => File.ReadAllText(Path.Combine(templateDirectory, t + ".htm")));
        }
Beispiel #5
0
 public static bool IsValidUpdate(AppUpdateType type) {
     return type != AppUpdateType.New &&
         type != AppUpdateType.Revoke;
 }
Beispiel #6
0
 public static IHtmlString UpdateType(this HtmlHelper helper, AppUpdateType type) {
     string text;
     string className;
     switch (type) {
         case AppUpdateType.New:
             text = "新近上架";
             className = "new-added";
             break;
         case AppUpdateType.AddToPing:
             text = "加入系统";
             className = "new-added";
             break;
         case AppUpdateType.PriceIncrease:
             text = "价格上涨";
             className = "price-increase";
             break;
         case AppUpdateType.PriceDecrease:
             text = "特价销售";
             className = "price-decrease";
             break;
         case AppUpdateType.PriceFree:
             text = "限时免费";
             className = "price-free";
             break;
         case AppUpdateType.NewRelease:
             text = "版本更新";
             className = "new-release";
             break;
         case AppUpdateType.Revoke:
             text = "应用下架";
             className = "off-sale";
             break;
         default:
             text = "未知状态";
             className = "unknown";
             break;
     }
     return helper.Raw("<em class=\"app-update-entry " + className + "\">" + text + "</em>");
 }