public UserInteractUIServiceTest()
        {
            realRedisService = new RedisService();
            userInteractUIService = new UserInteractUIService(realRedisService);
            EntityMapping.Config();
            realRedisService.FlushAll();

            configID = realRedisService.Add<PushConfig>(new PushConfig {
                AllowedPeriodFrom = DateTime.Now,
                AllowedPeriodTo = DateTime.Now.AddSeconds(10000),
                DelaySeconds = 123,
                ExecuteTimes = 2,
                FailGotoActionId = 1,
                SuccessGotoActionId =1,
                IntervalSeconds = 60
            });

            configID2 = realRedisService.Add<PushConfig>(new PushConfig
            {
                AllowedPeriodFrom = DateTime.Now,
                AllowedPeriodTo = DateTime.Now.AddSeconds(1000),
                DelaySeconds = 321,
                ExecuteTimes = 20,
                FailGotoActionId = 10,
                SuccessGotoActionId = 10,
                IntervalSeconds = 600
            });
        }
Esempio n. 2
0
        public void Same_model_to_save_twice_will_update_the_existed_values()
        {
            var app = new App();

            app.Id    = "Same_model_to_save_twice_will_update_the_existed_values";
            app.Name  = "SameAppToSaveTwice";
            app.Price = 111;

            using (var redis = new RedisService())
            {
                var exited = redis.Get <App>(app.Id);
                redis.Delete <App>(exited);

                redis.Add <App>(app);

                app.Name = "Name1";
                redis.Add <App>(app);

                var getApp = redis.Get <App>(app.Id);

                Assert.NotEmpty(getApp.Name);

                redis.Delete <App>(exited);
            }
        }
        public void Same_model_to_save_twice_will_update_the_existed_values()
        {
            var app = new App();
            app.Id = "Same_model_to_save_twice_will_update_the_existed_values";
            app.Name = "SameAppToSaveTwice";
            app.Price = 111;

            using (var redis = new RedisService())
            {
                var exited = redis.Get<App>(app.Id);
                redis.Delete<App>(exited);

                redis.Add<App>(app);

                app.Name = "Name1";
                redis.Add<App>(app);

                var getApp = redis.Get<App>(app.Id);

                Assert.NotEmpty(getApp.Name);

                redis.Delete<App>(exited);

            }
        }
Esempio n. 4
0
        public AppProject SetupAppList(AppProject appProject, out App app)
        {
            appProject = new AppProject();
            var appProjectId = RedisService.Add <AppProject>(appProject);

            app = new App();
            var appId = RedisService.Add <App>(app);

            AppSettingsForAppList appSetting = new AppSettingsForAppList()
            {
                Id             = appId,
                CreateDateTime = DateTime.Now
            };

            CustomProperty prop = new CustomProperty()
            {
                Id    = AppConfigKey.OS_ATTR_ID,
                Value = AppConfigKey.OS_ATTR_VALUE
            };

            RedisService.AddCustomPropertyFor <App, CustomProperty>(app.Id, prop);

            var lcdDetails = AppStoreUIService.GetElementDetailList(AppConfigKey.LCD_ATTR_ID);

            foreach (var lcd in lcdDetails)
            {
                SetLCD(app.Id, lcd.Value.ToString());
            }

            AppStoreUIService.SetAppForAppList <AppProject>(appProjectId, appSetting);

            return(appProject);
        }
Esempio n. 5
0
        public App SetupApp(BaiduAppDetail appItem, AppProject appProject, App app)
        {
            var originalApp  = CloneHelper.DeepClone <App>(app);
            var originalApp2 = RedisService.Get <App>(app.Id);

            app.AppNo             = appProject.AppNo;
            app.AppProjectId      = appProject.Id;
            app.UseGreaterVersion = true;
            ClientImageInfo lg = new ClientImageInfo
            {
                BelongsToAppId = app.Id,
                FileUrl        = Path.Combine(LogoDirRoot, GetFileNameFromUri(GetDownloadUrl(appItem.IconUrl))),
                TypeId         = AppConfigKey.CLIENT_IMAGE_TYPE_ID
            };

            RedisService.Add <ClientImageInfo>(lg);
            app.ClientLogos = new List <ClientImageInfo>
            {
                lg
            };

            ImageInfo lg2 = new ImageInfo
            {
                BelongsToAppId = app.Id,
                FileUrl        = Path.Combine(LogoDirRoot, GetFileNameFromUri(GetDownloadUrl(appItem.IconUrl)))
            };

            RedisService.Add <ImageInfo>(lg2);
            app.Logo = lg2;

            app.Name          = appItem.Name;
            app.OrderNumber   = appItem.Score;
            app.DownloadTimes = appItem.Score;
            app.Status        = 1;
            var screenShotlist = GetScreenShotlist(appItem);

            foreach (var s in screenShotlist)
            {
                ImageInfo ss = new ImageInfo
                {
                    BelongsToAppId = app.Id,
                    FileUrl        = Path.Combine(ScreenshotDirRoot, GetFileNameFromUri(GetDownloadUrl(s)))
                };
                RedisService.Add <ImageInfo>(ss);
                app.ScreenShot.Add(ss);
            }
            app.PlatformType = AppConfigKey.PLATFORM_TYPE_ID.ConfigValue().ToInt32();
            app.Summary      = appItem.Summary.Replace("<br/>", string.Empty).Replace("<br>", string.Empty);
            var changeLog = appItem.ChangeLog.Replace("<br/>", string.Empty).Replace("<br>", string.Empty).Replace("NULL", string.Empty);

            app.Summary = string.Format("{0}\r\n{1}", app.Summary, changeLog);
            RedisService.UpdateWithRebuildIndex <App>(originalApp2, app);

            return(app);
        }
Esempio n. 6
0
        public void update_model_should_throw_exception_if_they_have_differentIds()
        {
            using (var redis = new RedisService())
            {
                var app = new App();
                app.Id   = "update_model_should_throw_exception_if_they_have_differentIds";
                app.Name = "test_update";

                redis.Delete <App>(app);

                redis.Add <App>(app);

                //change the property
                var newApp = new App();
                newApp.Id = "new_update_model_should_throw_exception_if_they_have_differentIds";

                var ex = Assert.Throws <ArgumentException>(() => redis.UpdateWithRebuildIndex <App>(app, newApp));
                Assert.True(ex.Message.Contains("different"));

                redis.Delete <App>(app);
            }
        }
Esempio n. 7
0
        public void update_model_should_throw_exception_if_they_have_differentIds()
        {
            using (var redis = new RedisService())
            {
                var app = new App();
                app.Id = "update_model_should_throw_exception_if_they_have_differentIds";
                app.Name = "test_update";

                redis.Delete<App>(app);

                redis.Add<App>(app);

                //change the property
                var newApp = new App();
                newApp.Id = "new_update_model_should_throw_exception_if_they_have_differentIds";

                var ex = Assert.Throws<ArgumentException>(() => redis.UpdateWithRebuildIndex<App>(app, newApp));
                Assert.True(ex.Message.Contains("different"));

                redis.Delete<App>(app);

            }
        }
Esempio n. 8
0
        private AppProject AddNewApp(TencentAppStoreModel.AppListItem app, AppProject appProject, AppInfo appInfo)
        {
            try
            {
                #region Set up Applist
                appProject = new AppProject();
                var appProjectId = RedisService.Add <AppProject>(appProject);
                App ap           = new App();
                var appId        = RedisService.Add <App>(ap);
                AppSettingsForAppList appSetting = new AppSettingsForAppList()
                {
                    Id             = appId,
                    CreateDateTime = DateTime.Now
                };
                CustomProperty prop = new CustomProperty()
                {
                    Id    = AppConfigKey.OS_ATTR_ID,
                    Value = AppConfigKey.OS_ATTR_VALUE
                };
                RedisService.AddCustomPropertyFor <App, CustomProperty>(ap.Id, prop);


                var lcdDetails = AppStoreUIService.GetElementDetailList(AppConfigKey.LCD_ATTR_ID);
                foreach (var lcd in lcdDetails)
                {
                    SetLCD(ap.Id, lcd.Value.ToString());
                }

                AppStoreUIService.SetAppForAppList <AppProject>(appProjectId, appSetting);
                #endregion

                #region Set up app project
                var originalAppProject = CloneHelper.DeepClone <AppProject>(appProject);
                appProject.AppNo       = "tencent_" + app.appid;
                appProject.Creator     = app.cpname;
                appProject.LogoFile    = GetFileNameFromUri(appInfo.logo);
                appProject.Name        = appInfo.name;
                appProject.PackageName = appInfo.packageName;
                appProject.Rate        = appInfo.star.ToFloat();
                RedisService.UpdateWithRebuildIndex <AppProject>(originalAppProject, appProject);
                #endregion

                #region Set up App
                var originalApp  = CloneHelper.DeepClone <App>(ap);
                var originalApp2 = RedisService.Get <App>(ap.Id);

                ap.AppNo             = appProject.AppNo;
                ap.AppProjectId      = appProject.Id;
                ap.UseGreaterVersion = true;
                ClientImageInfo lg = new ClientImageInfo
                {
                    BelongsToAppId = ap.Id,
                    FileUrl        = Path.Combine(LogoDirRoot, GetFileNameFromUri(appInfo.logo)),
                    TypeId         = "1"
                };
                RedisService.Add <ClientImageInfo>(lg);
                ap.ClientLogos = new List <ClientImageInfo>
                {
                    lg
                };

                ImageInfo lg2 = new ImageInfo
                {
                    BelongsToAppId = ap.Id,
                    FileUrl        = Path.Combine(LogoDirRoot, GetFileNameFromUri(appInfo.logo))
                };
                RedisService.Add <ImageInfo>(lg2);
                ap.Logo = lg2;

                ap.Name          = appInfo.name;
                ap.OrderNumber   = appInfo.downnum;
                ap.DownloadTimes = appInfo.downnum;
                ap.Status        = 1;
                foreach (var s in appInfo.images)
                {
                    ImageInfo ss = new ImageInfo
                    {
                        BelongsToAppId = ap.Id,
                        FileUrl        = Path.Combine(ScreenshotDirRoot, GetFileNameFromUri(s))
                    };
                    RedisService.Add <ImageInfo>(ss);
                    ap.ScreenShot.Add(ss);
                }
                ap.PlatformType = AppConfigKey.PLATFORM_TYPE_ID.ConfigValue().ToInt32();
                ap.Summary      = appInfo.detail.Replace("<br/>", string.Empty).Replace("<br>", string.Empty);
                RedisService.UpdateWithRebuildIndex <App>(originalApp2, ap);
                #endregion

                #region Set up App Version
                if (!string.IsNullOrEmpty(appInfo.apkurl))
                {
                    FileInfo fi = new FileInfo(Path.Combine(APK_Folder_Base, GetFileNameFromUri(appInfo.apkurl)));

                    if (fi != null && fi.Exists)
                    {
                        AppVersion ver = new AppVersion
                        {
                            FileSize        = (int)fi.Length,
                            FileUrl         = GetFileNameFromUri(appInfo.apkurl),
                            PublishDateTime = appInfo.updatetime,
                            Status          = 1,
                            VersionName     = appInfo.apkver,
                            Id = appInfo.versionCode.ToString()
                        };
                        RedisService.SetSubModel <App, AppVersion>(ap.Id, ver);
                        AppStoreUIService.SetAppCurrentTestVersion(appId, ver.Id);
                        AppStoreUIService.PublishAppVersion(appId);

                        AndroidPackageView apkInfo = FileService.GetAndroidPackageInfomation(fi.FullName);
                        apkInfo.Id = ver.Id;
                        RedisService.SetSubModel <App, AndroidPackageView>(ap.Id, apkInfo);
                    }
                }
                #endregion

                #region Set up tags
                if (appInfo.type.StartsWith("soft", StringComparison.OrdinalIgnoreCase))
                {
                    AppStoreUIService.AddTagForAppProject(AppConfigKey.TAG_SOFTWARE, appProject.Id);
                    AppStoreUIService.AddTagForAppProject(AppConfigKey.TAG_TOT_10_SOFTWARE, appProject.Id);
                }
                else
                {
                    AppStoreUIService.AddTagForAppProject(AppConfigKey.TAG_GAME, appProject.Id);
                    AppStoreUIService.AddTagForAppProject(AppConfigKey.TAG_TOT_10_GAMES, appProject.Id);
                }
                AppStoreUIService.AddTagForAppProject(AppConfigKey.TAG_LATEST, appProject.Id);
                AppStoreUIService.AddTagForAppProject(appInfo.category, appProject.Id);
                AddMarketTag(appInfo.category, ap.Id);
                AppStoreUIService.AddTagForApp("Live", ap.Id);
                AppStoreUIService.AddTagForApp("Valid", ap.Id);
                AppStoreUIService.AddTagForAppProject("From_tencent", appProject.Id);
                #endregion
            }
            catch (Exception ex)
            {
                LogHelper.WriteError(ex.Message + ex.StackTrace);
                LogHelper.WriteInfo(string.Format("This AppProject {0} will delete, appProjectId is {1}", appProject.Name, appProject.Id));
                AppProjectDelete(appProject.Id);
            }
            return(appProject);
        }