コード例 #1
0
        private int AddNewVersionForApp(int newVersionCount, TencentAppStoreModel.AppListItem app, App a)
        {
            newVersionCount++;

            #region Checked TYD App
            var tags = AppStoreUIService.GetTagsByApp(a.Id);
            // if the app has "TYD手动维护" tag, skip it.
            if (tags.FindIndex(x => (x.Name == AppConfigKey.TAG_TYD_SKIP) || (x.Id == AppConfigKey.TAG_TYD_SKIP_ID)) != -1)
            {
                LogHelper.WriteInfo(string.Format("TYD手动维护 -- {0}, skipped", app.name), ConsoleColor.Yellow);

                return(newVersionCount);
            }

            LogHelper.WriteInfo(string.Format("Has new version for app, name {0}, downloading...", app.name), ConsoleColor.Yellow);
            #endregion

            #region Set up App Version
            AppInfo appInfo = DowloadAppInfoAndResources(app.appid.ToString());

            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()
                    };
                    var originalApp            = RedisService.Get <App>(a.Id);
                    AndroidPackageView apkInfo = FileService.GetAndroidPackageInfomation(fi.FullName);
                    apkInfo.Id = ver.Id;
                    if (a.Status == 0)
                    {
                        RedisService.UpdateWithRebuildIndex <App>(originalApp, a);
                        LogHelper.WriteInfo(string.Format("This App {0} status is invaild", a.Name), ConsoleColor.Gray);
                    }

                    RedisService.SetSubModel <App, AppVersion>(a.Id, ver);
                    RedisService.SetSubModel <App, AndroidPackageView>(a.Id, apkInfo);
                    AppStoreUIService.SetAppCurrentTestVersion(a.Id, ver.Id);
                    AppStoreUIService.PublishAppVersion(a.Id);
                }
            }

            #endregion

            #region Set up tags
            if (a.Status != 0)
            {
                AppStoreUIService.AddTagForApp("Valid", a.Id);
            }
            AppStoreUIService.AddTagForApp(appInfo.category, a.Id);
            AddMarketTag(appInfo.category, a.Id);
            AppStoreUIService.AddTagForApp("From_tencent", a.Id);
            AppStoreUIService.AddTagForApp("Live", a.Id);
            #endregion

            return(newVersionCount);
        }
コード例 #2
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);
        }