Exemple #1
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);
        }
        private void SetLCD(string appId, string lcd)
        {
            var existedLcdSettings = RedisService.GetCustomPropertyFrom <App, CustomProperty>(appId, "2");

            if (existedLcdSettings != null)
            {
                var valJSON = existedLcdSettings.Value as JArray;

                List <string> val = null;
                if (valJSON != null)
                {
                    val = new List <string>();
                    foreach (var v in valJSON)
                    {
                        AddUniqueItemToList(val, v.ToString());
                    }
                }


                if (val != null)
                {
                    AddUniqueItemToList(val, lcd);
                }
                else
                {
                    val = new List <string> {
                        lcd
                    };
                }
                existedLcdSettings.Value = val;
                RedisService.AddCustomPropertyFor <App, CustomProperty>(appId, existedLcdSettings);
            }
            else
            {
                CustomProperty cp = new CustomProperty
                {
                    Id    = "2",
                    Value = new List <string> {
                        lcd
                    }
                };
                RedisService.AddCustomPropertyFor <App, CustomProperty>(appId, cp);
            }

            Console.WriteLine(string.Format("Set lcd [{0}] for App ID [{1}]", lcd, appId));
        }
        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);
        }