private AppView AppDetailInternal(MobileParam mobileParams, Func<AppProject> getAppProjectAction) { var appView = default(AppView); var appProject = getAppProjectAction(); if (appProject != null) { var app = AppStoreUIService.GetMatchedAppByRequest<AppProject>(appProject.Id, mobileParams); if (!IsPublishableApp(app, mobileParams)) return null; appView = EntityMapping.Auto<App, AppView>(app); appView.AppNo = app.AppNo; appView.Company = appProject.Creator; //image var imgInfos = app.ScreenShot; appView.ImageCount = imgInfos.Count; appView.ImageList = new List<string>(); appView.ImageUrls = new List<string>(); imgInfos.ForEach(i => { appView.ImageList.Add(i.Id + i.Extension); if (!i.FileUrl.IsNullOrEmpty()) { appView.ImageUrls.Add(i.FileUrl.GetImageRelativeUrlByAbsoluteUrl().ToFileServerUrlAPP()); } }); appView.LogoFileName = GetSingleAppImageUrl(app.Logo.Id); appView.ScreenShots = new List<string>(); appView.DownloadTimes = app.DownloadTimes; appView.ApkName = appProject.PackageName; appView.ReviewCount = appProject.ReviewCount; appView.Rate = appProject.Rate.ToString(); var logoInfo = new List<AppLogo>(); foreach (var l in app.ClientLogos) { var logo = new AppLogo { Type = l.TypeId }; if (!string.IsNullOrWhiteSpace(l.TypeId)) { logo.Id = string.Format("C{0}{1}", l.Id, l.Extension); if (!l.FileUrl.IsNullOrEmpty()) logo.Url = l.FileUrl.GetImageRelativeUrlByAbsoluteUrl().ToFileServerUrlAPP(); logoInfo.Add(logo); } } appView.Icon = logoInfo; foreach (var i in appView.ImageList) { appView.ScreenShots.Add(GetSingleAppImageUrl(i)); } appView.ScreenShots = appView.ScreenShots.Take(3).ToList(); var appVersion = default(AppVersion); if (HasTestableVersionForAppStore(app, mobileParams)) { appView.Version = app.CurrentTestVersion; appVersion = AppStoreUIService.GetCurrentTestVersionForApp(app.Id); } else if (HasPublishableVersion(app)) { appView.Version = app.CurrentVer; appVersion = AppStoreUIService.GetCurrentVersionForApp(app.Id); } else { appView = null; } if (appVersion != null && appView != null) { var pkgInfo = AppStoreUIService.GetApkInfoForApp(app.Id, appVersion.Id, false); if (pkgInfo != null) { appView.MinSDKVersion = GetMiniSDKByAPILevel(pkgInfo.MinSDKVersion); appView.MD5 = pkgInfo.MD5; } SetVersionInfoForApp(appView, appVersion, mobileParams); } } return appView; }
private void SetAppInAppList(MobileParam mobileParams, List<ApplistItemView> appListItems, AppColumn c, List<App> apps) { foreach (var a in apps) { if (!IsPublishableApp(a, mobileParams)) continue; ApplistItemView appListItem = new ApplistItemView(); var appProject = RedisService.Get<AppProject>(a.AppProjectId); if (appProject == null) { // log it and continue LogHelper.Error(string.Format("App project is null. App name is :{0}, id is {1}, app no is {2}. app proj id is {3}", a.Name, a.Id, a.AppNo, a.AppProjectId)); continue; } appListItem.AppNo = appProject.AppNo; appListItem.Name = appProject.Name; if (c != null) { var appSettings = RedisService.GetSubModel<AppColumn, AppSettingsForAppList>(c.Id, a.Id); if (appSettings != null && appSettings.CustomProperties != null && appSettings.CustomProperties.ContainsKey("Name")) appListItem.Name = appSettings.CustomProperties["Name"].ToString(); } var logoInfo = new List<AppLogo>(); foreach (var l in a.ClientLogos) { var logo = new AppLogo { Type = l.TypeId }; if (!string.IsNullOrWhiteSpace(l.TypeId)) { logo.Id = "C" + l.Id + l.Extension; // attension here: // the url was issued, or, there will be lots of connection for downloading the image if (!l.FileUrl.IsNullOrEmpty()) logo.Url = l.FileUrl.GetImageRelativeUrlByAbsoluteUrl().ToFileServerUrlAPP(); logoInfo.Add(logo); } } appListItem.Logos = logoInfo; appListItem.ServerLogo = GetSingleAppImageUrl(a.Logo.Id); appListItem.Price = (float)a.Price; bool hasValidVersion = false; if (HasTestableVersionForAppStore(a, mobileParams)) { var testVersion = AppStoreUIService.GetCurrentTestVersionForApp(a.Id); if (testVersion != null) { appListItem.FileSize = testVersion.FileSize.ToString(); appListItem.PublishTime = testVersion.PublishDateTime; appListItem.Version = a.CurrentTestVersion; appListItem.DownloadUrl = (FILE_PREFIX + testVersion.FileUrl).ToFileServerUrlAPP(); hasValidVersion = true; } } else if (HasPublishableVersion(a)) { var appVersion = AppStoreUIService.GetCurrentVersionForApp(a.Id); if (appVersion != null) { appListItem.FileSize = appVersion.FileSize.ToString(); appListItem.PublishTime = appVersion.PublishDateTime; appListItem.Version = a.CurrentVer; appListItem.DownloadUrl = (FILE_PREFIX + appVersion.FileUrl).ToFileServerUrlAPP(); hasValidVersion = true; } } if (!hasValidVersion) { continue; } appListItem.SummaryVersion = a.SummaryVer.ToString(); // There are no rate and review count for now. appListItem.Rate = appProject.Rate.ToString(); appListItem.ReviewCount = appProject.ReviewCount; appListItem.PlatformType = ((PlatformType)a.PlatformType).ToString(); appListItem.ApkName = appProject.PackageName; appListItem.Summary = a.Summary; appListItem.Activity = a.Activity; appListItem.DownloadTimes = a.DownloadTimes; appListItems.Add(appListItem); } }