Beispiel #1
0
        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);
            }
        }
        public IList<ApplistItemView> AppList(MobileParam mobileParams, int tagId, int tagsubid, int startnum, int num, string clver, out string slver, out int totalCount)
        {
            var list = AppView.Repo.FindAll(s => s.Section == (SectionViewType)tagId);

            var filterList = new List<string>();
            if (IsShortcutMobileRequest(mobileParams))
            {
                if (IsQVGA(mobileParams)) filterList = AppQVGA.AppsList;
                else if (IsHVGA(mobileParams)) filterList = AppHVGA.AppsList;
            }

            var listItemList = new List<ApplistItemView>();
            if ((SectionViewType)tagId == SectionViewType.Game_Recommend)
            {
                #region For game repository
                // for game
                //var gameRecommendation = LoadGameRecommendFromJsonConfig();
                var gameRecommendation = new List<AppView>();
                gameRecommendation.ForEach(s =>
                {
                    var item = new ApplistItemView
                    {
                        AppNo = s.AppNo,
                        Name = s.Name,
                        Rate = 5.ToString(),
                        ReviewCount = 1000,
                        Version = s.Version.ToString(),
                        Price = 0,
                        Logos = new List<AppLogo> { new AppLogo { Id = GetLogoFileNameByAppNo(s.AppNo), Type = "1" } },
                        PlatformType = PlatformType.Java.ToString(),
                        PublishTime = s.PublishTime
                    };

                    var fullFileName = GetAppFileFullName(s.AppNo + ".jar");
                    if (File.Exists(fullFileName))
                    {
                        var info = new FileInfo(fullFileName);
                        item.FileSize = Math.Ceiling(info.Length / 1024d) + "Kb";
                    }

                    listItemList.Add(item);
                });
                #endregion
            }
            else
            {
                #region for c
                list.ForEach(s =>
                {
                    if (filterList.Contains(s.AppNo))
                    {
                        var item = new ApplistItemView
                        {
                            AppNo = s.AppNo,
                            Name = s.Name,
                            Rate = "5",
                            ReviewCount = 1000,
                            Version = s.Version.ToString(),
                            SummaryVersion = 10000.ToString(),
                            Price = 0,
                            Logos = new List<AppLogo> { new AppLogo { Id = GetLogoFileNameByAppNo(s.AppNo), Type = "1" } },
                            PlatformType = s.PlatformType.ToString(),
                            PublishTime = s.PublishTime
                        };
                        var fullFileName = GetAppFileFullName(GetAppFileName(mobileParams, s.AppNo));
                        if (File.Exists(fullFileName))
                        {
                            var info = new FileInfo(fullFileName);
                            item.FileSize = Math.Ceiling(info.Length / 1024d) + "Kb";
                        }

                        listItemList.Add(item);
                    }
                });
                #endregion
            }

            slver = clver;
            if (startnum > 0) startnum -= 1;
            totalCount = listItemList.Count;
            return listItemList.Skip(startnum).Take(num).ToList();
        }