public override ActionResult AppAdd(string appProjectId, bool? IsUpdate)
        {
            AppProject appProject = new AppProject();

            ViewData["AllIntegrators"] = new SelectList(RedisService.GetAllSubModelsByType<DesignCompany, Integrator>(UserAccessDataControlService.GetCurrentDesignCompanyId()).OrderBy(s => s.Name), "Id", "Name");

            if (!string.IsNullOrWhiteSpace(appProjectId))
            {
                appProject = RedisService.Get<AppProject>(appProjectId);
            }
            if (IsUpdate.GetValueOrDefault())
            {
                var appParams = appProject.AppNo.Split('_');
                if (appParams != null && appParams.Length >= 4)
                {
                    ViewData["Local"] = appParams[appParams.Length - 2];
                    ViewData["Operator"] = appParams[appParams.Length - 1];
                }
            }
            else
            {
                ViewData["Local"] = string.Empty;
                ViewData["Operator"] = string.Empty;
            }
            ViewData["AllElements"] = GetAllAttributes();
            ViewData["IsUpdate"] = IsUpdate.GetValueOrDefault();
            ViewData["AllDesignCompanies"] = new SelectList(UserAccessDataControlService.GetDesignCompaniesByUser(Membership.GetUser().UserName), "Id", "Name");
            return View(appProject);
        }
        public List<AnnouncementView> GetAllAnnouncements(string announcementType)
        {
            var announcementListView = new List<AnnouncementView>();
            var announcements = new List<Announcement>();
            if(announcementType.Equals("Global"))
            {
                announcements=  GetGlobalAnnouncements(false);
                //announcements = GetAllAnnouncements().FindAll(x=>x.AppId.IsNullOrEmpty() && x.AppColumnId.IsNullOrEmpty());
            }else{
                announcements = GetAllAnnouncements().FindAll(x => !x.AppId.IsNullOrEmpty() || !x.AppColumnId.IsNullOrEmpty());
            }

            foreach (var item in announcements)
            {
                var announcementDetail = EntityMapping.Auto<Announcement, AnnouncementView>(item);
                var appDetail = new App();
                var projectDetail = new AppProject();
                if (!item.AppId.IsNullOrEmpty())
                {
                    appDetail = RedisService.Get<App>(item.AppId);
                    if (appDetail != null)
                        projectDetail = RedisService.Get<AppProject>(appDetail.AppProjectId);
                }
                var columnDetail = RedisService.Get<AppColumn>(item.AppColumnId);
                announcementDetail.AppName = appDetail != null ? appDetail.Name : "";
                announcementDetail.ProjectName = projectDetail != null ? projectDetail.Name : "";
                announcementDetail.AppLogo = projectDetail != null ? projectDetail.LogoFile == null ? "" : projectDetail.LogoFile : "";
                announcementDetail.ColumnName = columnDetail != null ? columnDetail.Name : "";

                announcementListView.Add(announcementDetail);
            }

            return announcementListView;
        }
        public void AppDetailInternalTest_Param_Is_Null()
        {
            App app = default(App);
            AppProject appProject = default(AppProject);

            var test = appSotresWapUISerivces.AppDetailInternal(app, appProject);
            Assert.Null(test);

            app = new App();
            appProject = new AppProject();

            test = appSotresWapUISerivces.AppDetailInternal(app, appProject);
            Assert.Null(test);
        }
        public void AppDetailInternalTest_Normal()
        {
            var source = new App
            {
                Id = "1002",
                AppNo = "21001",
                AppProjectId = "403",
                CategoryId = "1",
                Name = "乱舞三国",
                CurrentVer = "10004",
                CreateDateTime = new DateTime(2012, 12, 12),
                IsHide = 0,
                Summary = "独立包",
                Drive = null,
                Activity = null,
                StorageName = "StorageName",
                EnglishName = "new app 1",
                CategoryName = "游戏",
                OrderNumber = 0,
                PlatformType = 4,
                Price = 0.0,
                Rank = 0,
                ReviewCount = 0,
                Status = 1,
                SummaryVer = 0,
                UseGreaterVersion = false
            };

            AppProject appProject = new AppProject { AppNo="TestAppNo", CreateDateTime=DateTime.Now, Creator="TestCreator", CurrentVersion=159, Id="TestAppProjectId", LogoFile="TestLogoFile",
                ModuleName="TestModuleName", Name="TestProjectName", PackageName="TestPackageName", Rate=2, ReviewCount=3};

            EntityMapping.ResetMapper();
            EntityMapping.Config();
            Bootstrapper.ConfigueInjection();

            var test = appSotresWapUISerivces.AppDetailInternal(source, appProject);

            Assert.Equal(source.Summary, test.Summary);
            Assert.Equal(source.AppNo, test.AppNo);
            Assert.Equal(appProject.Creator, test.Company);
        }
        public override ActionResult AppAdd(AppProject model, HttpPostedFileBase LogoFile)
        {
            var local = Request.Form["Local"];
            var operators = Request.Form["Operator"];

            if (!string.IsNullOrEmpty(Request.Form["DesignCompanyName"]) && !string.IsNullOrEmpty(model.Name) && !string.IsNullOrEmpty(local) && !string.IsNullOrEmpty(operators))
            {
                var appNo = string.Format("{0}_{1}_{2}_{3}", Request.Form["DesignCompanyName"].Trim(), model.Name.Trim(), local.Trim(), operators.Trim());
                if (IsMatched(appNo))
                {
                    model.AppNo = appNo.ToLower();
                    var acitionResult = base.AppAdd(model, LogoFile);
                    var designCompanyId = UserAccessDataControlService.GetCurrentDesignCompanyId(true);
                    UserAccessDataControlService.AddAppProjectToDesignCompany(model.Id, designCompanyId);
                    RedisService.SetEntryInHash<string>(CacheKeys.OTA_BATCH_FOR_DESIGN_COMPANY, model.AppNo, designCompanyId.MakeSureNotNull());
                    return acitionResult;
                }

            }
            TempData["errorMsg"] = string.Format("所有输入都是必须的,并且必须是英文字符与数字!");
            if (!string.IsNullOrEmpty(Request.Form["IsUpdate"]))
            {
                return RedirectToAction("AppAdd", new { appProjectId = model.Id, IsUpdate = true });
            }
            else
            {
                return RedirectToAction("AppAdd");
            }
        }
        public void AppColumn_And_AppProject_Test()
        {
            #region generate App Project and AppColumn
            AppProject appProject = new AppProject();
            appProject.Name = "10010";
            appProject.Id = "10010";
            appProject.CreateDateTime = DateTime.Now.AddSeconds(-3);
            appProject.CurrentVersion = 10010;

            AppColumn appColumn = new AppColumn();
            appColumn.Name = "10020";
            appColumn.Id = "10020";
            appColumn.CreateDateTime = DateTime.Now.AddDays(3);
            appColumn.CurrentVersion = 10011;
            #endregion
            Service.Add<AppProject>(appProject);
            Service.Add<AppColumn>(appColumn);

            #region App settings
            App app = new App();
            app.Id = "10002";
            app.Name = "App2";
            app.Price = 10.55;
            app.CreateDateTime = new DateTime(2011, 11, 23, 1, 1, 1);

            App app1 = new App();
            app1.Id = "10001";
            app1.Name = "App1";
            app1.Price = 25.88;
            app1.CreateDateTime = new DateTime(2011, 12, 1, 1, 1, 1);
            #endregion

            #region Element Settings

            Element ele = new Element();
            ele.Id = "1";
            ele.Name = "分辨率";
            ele.Type = (int)ElementType.多选列表;
            Service.Add<Element>(ele);

            Element ele2 = new Element();
            ele2.Id = "2";
            ele2.Name = "CustomProperty";
            ele2.Type = (int)ElementType.多选列表;
            ele2.IsQueriable = true;
            Service.Add<Element>(ele2);

            Element ele5 = new Element();
            ele5.Id = "3";
            ele5.Name = "Resolution";
            ele5.Type = (int)ElementType.多选列表;
            ele5.IsQueriable = true;
            Service.Add<Element>(ele5);

            Element ele4 = new Element();
            ele4.Id = "4";
            ele4.Name = "IsTouchable";
            ele4.Type = (int)ElementType.输入框;
            ele4.IsQueriable = true;
            Service.Add<Element>(ele4);

            ElementDetail elementDetail1 = new ElementDetail();
            elementDetail1.ElementId = "2";
            elementDetail1.Value = "CustomPropertyValue1";

            ElementDetail elementDetail2 = new ElementDetail();
            elementDetail2.ElementId = "2";
            elementDetail2.Value = "CustomPropertyValue2";

            Element ele3 = new Element();
            ele3.Id = "3";
            ele3.Name = "IntCustomProperty";
            ele3.Type = (int)ElementType.输入框;
            ele3.IsQueriable = true;
            Service.Add<Element>(ele3);

            ElementDetail elementDetail3 = new ElementDetail();
            elementDetail3.ElementId = "3";
            elementDetail3.Value = 3.6;
            #endregion

            #region customProperty settings
            CustomProperty customProperty = new CustomProperty();
            customProperty.Id = ele2.Name;
            customProperty.Value = new List<string>() { elementDetail1.Value.ToString(), elementDetail2.Value.ToString() };
            customProperty.IsQueriable = ele2.IsQueriable;

            CustomProperty customProperty2 = new CustomProperty();
            customProperty2.Id = ele3.Name;
            customProperty2.Value = elementDetail3.Value;
            customProperty2.IsQueriable = ele3.IsQueriable;

            CustomProperty customProperty3 = new CustomProperty();
            customProperty3.Id = ele3.Name;
            customProperty3.Value = elementDetail3.Value;
            customProperty3.IsQueriable = ele3.IsQueriable;

            CustomProperty resolutionProperty = new CustomProperty();
            resolutionProperty.Id = ele5.Name;
            resolutionProperty.Value = new List<string>() { "240*320", "320*480" };

            CustomProperty isTouchableProperty = new CustomProperty();
            isTouchableProperty.Id = ele4.Name;
            isTouchableProperty.Value = true;
            #endregion

            customProperty.IsQueriable = true;
            Service.AddCustomPropertyFor<AppList, CustomProperty>(appProject.Id, customProperty);
            Dictionary<string, string> applistConditions = new Dictionary<string, string>();
            applistConditions.Add("CustomProperty", "CustomPropertyValue2");

            var appProjectOrigin = CloneHelper.DeepClone<AppProject>(appProject);
            appProject.CreateDateTime = DateTime.Now.AddDays(1);
            appProject.CurrentVersion++; // make sure bump version number when upate applist
            Service.UpdateWithRebuildIndex<AppProject>(appProjectOrigin, appProject);

            var appColumnOrigin = CloneHelper.DeepClone<AppColumn>(appColumn);
            appColumn.CreateDateTime = DateTime.Now.AddDays(1);
            appColumn.CurrentVersion++; // make sure bump version number when upate applist
            Service.UpdateWithRebuildIndex<AppColumn>(appColumnOrigin, appColumn);

            AppSettingsForAppList customApp1 = new AppSettingsForAppList();
            customApp1.Id = app1.Id;
            customApp1.ScoreForSort = 2;
            customApp1.CustomProperties = new Dictionary<string, object>();
            customApp1.CustomProperties.Add("Name", "NewApp1");
            customApp1.CustomProperties.Add("Price", 2.3);
            customApp1.CustomProperties.Add("CustomProperty", "newValueFromAppListSettings");
            AppSettingsForAppList customApp2 = new AppSettingsForAppList();
            customApp2.Id = app.Id;
            customApp2.ScoreForSort = 1;
            customApp2.CustomProperties = new Dictionary<string, object>();
            customApp2.CustomProperties.Add("Name", "NewApp2");
            customApp2.CustomProperties.Add("Price", 3.2);

            AppStoreSvc.SetAppForAppList<AppProject>("10010", customApp1);
            AppStoreSvc.SetAppForAppList<AppProject>("10010", customApp2);

            AppSettingsForAppList customApp3 = new AppSettingsForAppList();
            customApp3.Id = "10001";
            customApp3.CustomProperties = new Dictionary<string, object>();
            AppStoreSvc.SetAppForAppList<AppColumn>("10020", customApp3);

            #region
            Service.DeleteWithCustomProperties<App, CustomProperty>("10001");
            Service.DeleteWithCustomProperties<App, CustomProperty>("10002");
            Service.DeleteWithCustomProperties<AppProject, CustomProperty>(appProject.Id);
            Service.DeleteWithCustomProperties<AppColumn, CustomProperty>(appColumn.Id);
            Service.Delete<Element>(ele);
            Service.Delete<Element>(ele2);
            Service.Delete<Element>(ele3);
            Service.Delete<Element>(ele4);
            Service.Delete<Element>(ele5);
            Service.Delete<AppProject>(appProject);
            Service.Delete<AppColumn>(appColumn);
            #endregion
        }
        public void get_tag_list_test_normal()
        {
            #region Generate Data
            string lcd = "320x480";

            #region app and tags

            var sortedTags = new List<Tag>();
            var tag1 = new Tag()
            {
                Id = "1",
                Name = "工具",
                OrderNumber = 4
            };
            var tag2 = new Tag()
            {
                Id = "2",
                Name = "娱乐",
                OrderNumber = 6
            };

             var tagIds = new List<string>{
                "1",
                "2"
            };

             var tagIdsSortedByOrderNumber = new List<string> { "2", "1" };

             sortedTags.Add(tag2);
             sortedTags.Add(tag1);

            App app1 = new App()
            {
                AppNo = "1",
                AppProjectId = "1",
                //ClientLogos="",
                CurrentVer = "1",
                Id = "1",
                Name = "app1",
                Price = 0.0,
                Rank = 3,
                ReviewCount = 3

            };
            App app2 = new App()
            {
                AppNo = "2",
                AppProjectId = "2",
                //ClientLogos="",
                CurrentVer = "2",
                Id = "2",
                Name = "app2",
                Price = 0.0,
                Rank = 4,
                ReviewCount = 4

            };
            App app3 = new App()
            {
                AppNo = "3",
                AppProjectId = "3",
                //ClientLogos="",
                CurrentVer = "3",
                Id = "3",
                Name = "app3",
                Price = 0.0,
                Rank = 4,
                ReviewCount = 4

            };
            App app4 = new App()
            {
                AppNo = "4",
                AppProjectId = "4",
                //ClientLogos="",
                CurrentVer = "4",
                Id = "4",
                Name = "app4",
                Price = 0.0,
                Rank = 5,
                ReviewCount = 5

            };
            App app5 = new App()
            {
                AppNo = "5",
                AppProjectId = "5",
                //ClientLogos="",
                CurrentVer = "5",
                Id = "5",
                Name = "app5",
                Price = 0.0,
                Rank = 5,
                ReviewCount = 1

            };
            App app6 = new App()
            {
                AppNo = "6",
                AppProjectId = "6",
                //ClientLogos="",
                CurrentVer = "6",
                Id = "6",
                Name = "app6",
                Price = 0.0,
                Rank = 2,
                ReviewCount = 4

            };
            #endregion
            var AppIds = new List<string>()
            {
                "1","2","3","4","5","6"
            };
            var topThreeAppIdsForT1 = new List<string>()
            {
                "1","2","3"
            };
            var topThreeAppIdsForT2 = new List<string>()
            {
                "4","5","6"
            };

            var apps = new List<App>();
            apps.Add(app1);
            apps.Add(app2);
            apps.Add(app3);

            #region Version
            var version1 = new AppVersion()
            {
                Id = "1",
                VersionName = "v1",
                FileSize = 5,
                FileUrl = "FileUrl1",
            };
            var version2 = new AppVersion()
            {
                Id = "2",
                VersionName = "v2",
                FileSize = 5,
                FileUrl = "FileUrl2",
            };
            var version3 = new AppVersion()
            {
                Id = "3",
                VersionName = "v3",
                FileSize = 5,
                FileUrl = "FileUrl3",
            };
            var version4 = new AppVersion()
            {
                Id = "4",
                VersionName = "v4",
                FileSize = 5,
                FileUrl = "FileUrl4",
            };
            var version5 = new AppVersion()
            {
                Id = "5",
                VersionName = "v5",
                FileSize = 5,
                FileUrl = "FileUrl5",
            };
            var version6 = new AppVersion()
            {
                Id = "6",
                VersionName = "v6",
                FileSize = 5,
                FileUrl = "FileUrl6",
            };

            #endregion

            #region App Project
            var appProject1 = new AppProject()
            {
                AppNo = "1",
                Id = "1",
                LogoFile = "LogoFile1",
                Name = "app project1",
                Rate = 1,
                ReviewCount = 1
            };
            var appProject2 = new AppProject()
            {
                AppNo = "2",
                Id = "2",
                LogoFile = "LogoFile2",
                Name = "app project2",
                Rate = 2,
                ReviewCount = 2
            };
            var appProject3 = new AppProject()
            {
                AppNo = "3",
                Id = "3",
                LogoFile = "LogoFile3",
                Name = "app project3",
                Rate = 3,
                ReviewCount = 3
            };
            var appProject4 = new AppProject()
            {
                AppNo = "4",
                Id = "4",
                LogoFile = "LogoFile4",
                Name = "app project4",
                Rate = 4,
                ReviewCount = 4
            };
            var appProject5 = new AppProject()
            {
                AppNo = "5",
                Id = "5",
                LogoFile = "LogoFile5",
                Name = "app project5",
                Rate = 5,
                ReviewCount = 5
            };
            var appProject6 = new AppProject()
            {
                AppNo = "6",
                Id = "6",
                LogoFile = "LogoFile6",
                Name = "app project6",
                Rate = 6,
                ReviewCount = 6
            };
            #endregion

            #endregion

            //_appStoreUIServiceMock.Setup(s => s.GetTagsByTagCategory(It.IsAny<string>())).Returns(tags);
            _appStoreUIServiceMock.Setup(s => s.GetAppIdsByTag("1")).Returns(AppIds);
            _appStoreUIServiceMock.Setup(s => s.GetAppIdsByTag("2")).Returns(AppIds);
            _appStoreUIServiceMock.Setup(s => s.GetAppIdsByTag("3")).Returns(AppIds);
            _redisServiceMock2.Setup(s => s.GetSortedIdsByProperty<App>(It.IsAny<List<string>>(), It.IsAny<string>(), 1, 3, true)).Returns(topThreeAppIdsForT2);
            _redisServiceMock.Setup(s => s.GetValuesByIds<App>(It.IsAny<List<string>>(), false)).Returns(apps);
            _redisServiceMock.Setup(s => s.GetValuesByIds<Element>(It.IsAny<List<string>>(), false)).Returns(new List<Element>());
            _redisServiceMock.Setup(s => s.Get<AppProject>("1")).Returns(appProject1);
            _redisServiceMock.Setup(s => s.Get<AppProject>("2")).Returns(appProject2);
            _redisServiceMock.Setup(s => s.Get<AppProject>("3")).Returns(appProject3);

            _redisServiceMock.Setup(s => s.GetAllSubModelIdsByType<TagCategory, TagInTagCategory>("2")).Returns(tagIds);
            _redisServiceMock2.Setup(s => s.GetSortedIdsByProperty<Tag>(tagIds, "OrderNumber", 0, 0, true)).Returns(tagIdsSortedByOrderNumber);
            _redisServiceMock.Setup(s => s.GetValuesByIds<Tag>(tagIdsSortedByOrderNumber, false)).Returns(sortedTags);

            _redisServiceMock2.Setup(s => s.GetIntersectIdsByPropertyFromSets(It.IsAny<List<string>>(), It.IsAny<List<string>>())).Returns(AppIds);
            _appStoreUIServiceMock.Setup(s => s.GetTagIdByName("Valid")).Returns("1");
            _appStoreUIServiceMock.Setup(s => s.GetAppIdsByTag("1")).Returns(AppIds);
            _redisServiceMock2.Setup(s => s.GetFilteredIdsByPropertyFromSets<App>(It.IsAny<List<string>>(), It.IsAny<string>())).Returns(AppIds);

            _appStoreUIServiceMock.Setup(s => s.GetCurrentVersionForApp("1")).Returns(version1);
            _appStoreUIServiceMock.Setup(s => s.GetCurrentVersionForApp("2")).Returns(version2);
            _appStoreUIServiceMock.Setup(s => s.GetCurrentVersionForApp("3")).Returns(version3);

            _appStoreUIServiceMock.Setup(s => s.GetAppIdsByTagNames(It.IsAny<List<string>>())).Returns(topThreeAppIdsForT1);
            List<WapTagListItem> resultList = appStoresWapUIService.GetTagList(lcd,"2");

            Assert.Equal(resultList.Count, 2);
            Assert.Equal(resultList[1].TagId, "1");
            Assert.Equal(resultList[0].TagAppList.Count, 3);
            Assert.Equal(resultList[0].TagName, "娱乐");
        }
        public void AppList_return_data_to_client_successfully()
        {
            var columns = new Dictionary<string, string>();
            columns.Add("1", "1");

            Dictionary<string, object> customProperties = new Dictionary<string, object>();
            customProperties["7"] = "240x320";

            var deviceModel = new DeviceModel()
            {
                ModelName = "MTK_6252",
                CustomProperties = customProperties,
                Columns = columns
            };
            AppProject appProj = new AppProject()
            {
                Id = "1",
                AppNo = "1",
                Name = "New APP 1"
            };

            var namevalues = new NameValueCollection();
            namevalues[MobileParam.Key_Resolution] = "240x320";
            _requestRepoMock.Setup<NameValueCollection>(m => m.Header).Returns(namevalues);
            MobileParam mobileParam = new MobileParam(requestRepo);

            _appStoreUIServiceMock.Setup(m => m.GetDeviceModelByRequest(mobileParam)).Returns(deviceModel);

            App app = new App() { Id = "1", Name = "APP1", AppProjectId = "1", CurrentVer = "1", Status = 1 };
            _appStoreUIServiceMock.Setup(m => m.GetAppsFromAppList<AppColumn>("1")).Returns(new List<App> { app });
            _redisServiceMock.Setup(m => m.Get<AppProject>("1")).Returns(appProj);

            var settings = new AppSettingsForAppList();
            settings.CustomProperties = new Dictionary<string, object>();
            settings.CustomProperties.Add("Name", "testName");
            _redisServiceMock.Setup(m => m.GetSubModel<AppColumn, AppSettingsForAppList>(It.IsAny<string>(), It.IsAny<string>(), false)).Returns(settings);

            AppVersion version = new AppVersion { Id = "1", FileSize = 123, PublishDateTime = DateTime.Now.AddDays(-1) };
            _appStoreUIServiceMock.Setup(m => m.GetCurrentVersionForApp("1")).Returns(version);

            AppColumn column = new AppColumn()
            {
                Id = "1",
                ClientId = 1,
                CurrentVersion = 1,
                Name = "Applications"
            };
            _redisServiceMock.Setup<List<AppColumn>>(m => m.GetValuesByIds<AppColumn>(new List<string>() { "1" }, true)).Returns(new List<AppColumn>() { column });

            AppStoreService appStoreService = new AppStoreService(fileService, redisService, appStoreUIService, new FullTextSearchService(redisService), new IMEICacheService(redisService));
            string slver = string.Empty;
            int totalCount = 0;
            var result = appStoreService.AppList(mobileParam, 1, 1, 0, 0, "0", out slver, out totalCount);

            Assert.Equal(1, result.Count);
            Assert.Equal("testName", result[0].Name);
        }
        public void CheckAppList_return_data_to_client_successfully()
        {
            var columns = new Dictionary<string, string>();
            columns.Add("1", "1");

            Dictionary<string, object> customProperties = new Dictionary<string, object>();
            customProperties["7"] = "240x320";

            var deviceModel = new DeviceModel()
            {
                ModelName = "MTK_6252",
                CustomProperties = customProperties,
                Columns = columns
            };
            AppProject appProj = new AppProject()
            {
                Id = "1",
                AppNo = "1",
                Name = "New APP 1"
            };

            var namevalues = new NameValueCollection();
            namevalues[MobileParam.Key_Resolution] = "240x320";
            _requestRepoMock.Setup<NameValueCollection>(m => m.Header).Returns(namevalues);
            MobileParam mobileParam = new MobileParam(requestRepo);

            _appStoreUIServiceMock.Setup(m => m.GetDeviceModelByRequest(mobileParam)).Returns(deviceModel);

            App app = new App() { Id = "1", Name = "APP1", AppProjectId = "1", CurrentVer = "1" };
            _appStoreUIServiceMock.Setup(m => m.GetAppsFromAppList<AppColumn>("1")).Returns(new List<App> { app });
            _redisServiceMock.Setup(m => m.Get<AppProject>("1")).Returns(appProj);

            AppVersion version = new AppVersion { Id = "1", FileSize = 123 };
            _appStoreUIServiceMock.Setup(m => m.GetCurrentVersionForApp("1")).Returns(version);

            AppColumn column = new AppColumn()
            {
                Id = "1",
                ClientId = 1,
                CurrentVersion = 1,
                Name = "Applications"
            };
            _redisServiceMock.Setup<List<AppColumn>>(m => m.GetValuesByIds<AppColumn>(new List<string>() { "1" }, true)).Returns(new List<AppColumn>() { column });

            AppStoreService appStoreService = new AppStoreService(fileService, redisService, appStoreUIService, new FullTextSearchService(redisService),new IMEICacheService(redisService));
            var result = appStoreService.CheckAppList("1~0", mobileParam);

            Assert.Equal(1, result.Count);
        }
        public void AppListByTagIds_return_data_to_client_successfully()
        {
            AppProject appProj = new AppProject()
            {
                Id = "1",
                AppNo = "1",
                Name = "New App Porj"
            };
            App app1 = new App() { Id = "1", Name = "app1", AppProjectId = "1", CurrentVer = "1", Status = 1, DownloadTimes = 8 };
            App app2 = new App() { Id = "2", Name = "app2", AppProjectId = "1", CurrentVer = "1", Status = 1, DownloadTimes = 10 };

            var tag1 = new Tag() { Id = "1", Name = "a" };
            var tag2 = new Tag() { Id = "2", Name = "b" };
            var tag3 = new Tag() { Id = "3", Name = "c" };
            _redisServiceMock.Setup<Tag>(m => m.Get<Tag>("1")).Returns(tag3);
            _redisServiceMock.Setup<Tag>(m => m.Get<Tag>("2")).Returns(tag2);
            _redisServiceMock.Setup<Tag>(m => m.Get<Tag>("3")).Returns(tag3);
            _appStoreUIServiceMock.Setup(m => m.GetAppIdsByTagNames(It.IsAny<List<string>>())).Returns(new List<string> { app1.Id, app2.Id });
            _redisServiceMock2.Setup(m => m.GetSortedIdsByProperty<App>(It.IsAny<List<string>>(), "DownloadTimes", 0, 0, true)).Returns(new List<string> { app2.Id, app1.Id });
            _redisServiceMock.Setup(m => m.GetValuesByIds<App>(It.IsAny<List<string>>(), false)).Returns(new List<App>());

            var namevalues = new NameValueCollection();
            namevalues[MobileParam.Key_Resolution] = "240x320";
            _requestRepoMock.Setup<NameValueCollection>(m => m.Header).Returns(namevalues);
            MobileParam mobileParam = new MobileParam(requestRepo);

            AppStoreService appStoreService = new AppStoreService(fileService, redisService, appStoreUIService, new FullTextSearchService(redisService), new IMEICacheService(redisService));
            int totalCount = 0;
            var result = appStoreService.GetAppListByTagIds(mobileParam, 0, 0, out totalCount, "1;2;3");
            Assert.Equal(2, totalCount);
        }
        public void AppListByTags_return_data_to_client_successfully()
        {
            var columns = new Dictionary<string, string>();
            columns.Add("1", "1");

            Dictionary<string, object> customProperties = new Dictionary<string, object>();
            customProperties["7"] = "240x320";

            AppProject appProj = new AppProject()
            {
                Id = "1",
                AppNo = "1",
                Name = "New APP 1"
            };

            var namevalues = new NameValueCollection();
            namevalues[MobileParam.Key_Resolution] = "240x320";
            _requestRepoMock.Setup<NameValueCollection>(m => m.Header).Returns(namevalues);
            MobileParam mobileParam = new MobileParam(requestRepo);

            App app = new App() { Id = "1", Name = "APP1", AppProjectId = "1", CurrentVer = "1", Status = 1, DownloadTimes = 8 };
            App app2 = new App() { Id = "2", Name = "APP2", AppProjectId = "1", CurrentVer = "1", Status = 1, DownloadTimes = 10, Summary = "Top" };
            _appStoreUIServiceMock.Setup(m => m.GetAppsFromAppList<AppColumn>("1")).Returns(new List<App> { app });
            _redisServiceMock.Setup(m => m.Get<AppProject>("1")).Returns(appProj);
            _redisServiceMock.Setup(m => m.GetValuesByIds<App>(It.IsAny<List<string>>(), false)).Returns(new List<App>());

            AppVersion version = new AppVersion { Id = "1", FileSize = 123, PublishDateTime = DateTime.Now.AddDays(-1) };
            _appStoreUIServiceMock.Setup(m => m.GetCurrentVersionForApp("1")).Returns(version);
            AppVersion version2 = new AppVersion { Id = "2", FileSize = 321, PublishDateTime = DateTime.Now.AddDays(-1) };
            _appStoreUIServiceMock.Setup(m => m.GetCurrentVersionForApp("2")).Returns(version2);

            _appStoreUIServiceMock.Setup(m => m.GetAppIdsByTagNames(It.IsAny<List<string>>())).Returns(new List<string> { app.Id, app2.Id });

            _redisServiceMock2.Setup(m => m.GetSortedIdsByProperty<App>(It.IsAny<List<string>>(), "DownloadTimes", 0, 0, true)).Returns(new List<string> { app2.Id, app.Id });

            AppStoreService appStoreService = new AppStoreService(fileService, redisService, appStoreUIService, new FullTextSearchService(redisService),new IMEICacheService(redisService));
            string slver = string.Empty;
            int totalCount = 0;
            var result = appStoreService.GetAppListByTags(mobileParam, 0, 0, out totalCount, "a;b;c;Live");

            Assert.Equal(2, totalCount);
        }
        private string PrepareInternalProjectData()
        {
            AppProject appProject = new AppProject { PackageName = "pp" };
            var appProjectId = redis.Add<AppProject>(appProject);

            App app = new App { Name = "App1", Summary = "App1 summary", Status = 1, CurrentVer = "1", AppProjectId = appProjectId.Replace("AppProject:", string.Empty) };
            var appId = redis.Add<App>(app);

            App app2 = new App { Name = "App2", Status = 1, CurrentVer = "1", AppProjectId = appProjectId.Replace("AppProject:", string.Empty) };
            var appId2 = redis.Add<App>(app2);

            appStoreUIRealService.SetAppForAppList<AppProject>(appProjectId, new AppSettingsForAppList { Id = appId.Replace("App:", string.Empty) });
            appStoreUIRealService.SetAppForAppList<AppProject>(appProjectId, new AppSettingsForAppList { Id = appId2.Replace("App:", string.Empty) });

            appStoreUIRealService.AddTagForApp("Live", appId);
            appStoreUIRealService.AddTagForApp("Valid", appId);
            appStoreUIRealService.AddTagForApp("game", appId);
            var projectTagId = appStoreUIRealService.AddTagForApp("G7", appId);

            appStoreUIRealService.AddTagForApp("Live", appId2);
            appStoreUIRealService.AddTagForApp("Valid", appId2);
            appStoreUIRealService.AddTagForApp("game", appId2);

            return projectTagId;
        }
        public void add_tag_for_appProject_then_get_appProject_by_tag()
        {
            appStoreUIRealService.RedisService2.FlushAll();

            App app = new App { Name = "app1" };
            var appId = redis.Add<App>(app);

            AppProject appProject = new AppProject { AppNo = "232323", Name = "appProject1" };
            var appProjectId = redis.Add<AppProject>(appProject);

            appStoreUIRealService.SetAppForAppList<AppProject>(appProjectId, new AppSettingsForAppList { Id = appId });

            var tagId = appStoreUIRealService.AddTagForAppProject("Utility", appProjectId);
            var appProjects = appStoreUIRealService.GetAppProjectsByTag(tagId);
            Assert.Equal(1, appProjects.Count);

            var tags = appStoreUIRealService.GetTagsByAppProject(appProjectId);
            Assert.Equal(1, tags.Count);

            var apps = appStoreUIRealService.GetAppsByTag(tagId);
            Assert.Equal(1, apps.Count);

            tags = appStoreUIRealService.GetTagsByApp(appId);
            Assert.Equal(1, tags.Count);

            appStoreUIRealService.DeleteTagFromAppProject(tagId, appProjectId);
            apps = appStoreUIRealService.GetAppsByTag(tagId);
            Assert.Equal(0, apps.Count);

            tags = appStoreUIRealService.GetTagsByApp(appId);
            Assert.Equal(0, tags.Count);

            appProjects = appStoreUIRealService.GetAppProjectsByTag(tagId);
            Assert.Equal(0, appProjects.Count);

            tags = appStoreUIRealService.GetTagsByAppProject(appProjectId);
            Assert.Equal(0, tags.Count);
        }
        //[RedisFact]
        public void search_applist_by_app_name_test()
        {
            AppProject appProj = new AppProject()
            {
                Id = "201",
                AppNo = "452",
                Name = "New APP sanguo"
            };
            redis.Add<AppProject>(appProj);

            App app = new App();
            app.Id = "100052";
            app.Name = "三国";
            app.Price = 10.55;
            app.Status = 1;
            app.AppProjectId = "201";
            app.AppNo = "452";
            app.CurrentVer = "14";
            app.CreateDateTime = new DateTime(2011, 11, 23, 1, 1, 1);
            redis.Add<App>(app);

            var namevalues = new NameValueCollection();
            namevalues[MobileParam.Key_Resolution] = "240x320";
            _requestRepoMock.Setup<NameValueCollection>(m => m.Header).Returns(namevalues);
            MobileParam mobileParam = new MobileParam(requestRepo);

            AppVersion version = new AppVersion { Id = "14", FileSize = 123 };
            redis.SetSubModel<App, AppVersion>("100052", version);

            var elementD = new ElementDetail();
            elementD.ElementId = "4";
            elementD.Value = "Android";
            elementD.Status = 1;
            redis.Add<ElementDetail>(elementD);
            CustomProperty c = new CustomProperty();
            c.Id = "4";
            c.Value = "Android";
            redis.AddCustomPropertyFor<App, CustomProperty>("100052", c);

            _fullTextSearchServiceMock.Setup(s => s.SearchAppIdsByDesc("三国")).Returns(new List<string>());

            appStoreUIRealService.AddTagForApp("Live", "100052");
            appStoreUIRealService.AddTagForApp("Valid", "100052");
            int totalCount = 0;
            var returnResult = appStoreRealService.SearchAndroidAppListByName(mobileParam, 0, 1, out totalCount, "三国");
            Assert.Equal(returnResult[0].Name, "New APP sanguo");
        }
 private void SetTestVersionToUpdateList(string appVer, List<AppUpdateListItemView> appUpdateListItems, AppProject appProject, App app, AppUpdateListItemView appView)
 {
     if (app.UseGreaterVersion)
     {
         if (HasGreaterVersion(app.CurrentTestVersion, appVer))
         {
             var testVersion = AppStoreUIService.GetCurrentTestVersionForApp(app.Id);
             if (testVersion != null)
             {
                 AddAppUpdateListItem(appUpdateListItems, appProject, app, appView, testVersion);
             }
         }
     }
     else
     {
         if (!app.CurrentTestVersion.EqualsOrdinalIgnoreCase(appVer))
         {
             var testVersion = AppStoreUIService.GetCurrentTestVersionForApp(app.Id);
             if (testVersion != null)
             {
                 AddAppUpdateListItem(appUpdateListItems, appProject, app, appView, testVersion);
             }
         }
     }
 }
        public void GetAppDownloadUrl_return_redirectUrl_to_client_successfully()
        {
            AppProject appProj = new AppProject()
            {
                Id = "1",
                AppNo = "1",
                Name = "New APP 1",
            };
            _appStoreUIServiceMock.Setup(m => m.GetAppProjectByAppNo("1")).Returns(appProj);

            var namevalues = new NameValueCollection();
            namevalues[MobileParam.Key_Resolution] = "240x320";
            _requestRepoMock.Setup<NameValueCollection>(m => m.Header).Returns(namevalues);
            MobileParam mobileParam = new MobileParam(requestRepo);

            App app = new App() { Id = "1", Name = "APP1", AppProjectId = "1", CurrentVer = "1", Status = 1 };
            _appStoreUIServiceMock.Setup(m => m.GetMatchedAppByRequest<AppProject>("1", mobileParam)).Returns(app);
            _redisServiceMock.Setup(s => s.Get<App>("1")).Returns(app);

            AppVersion version = new AppVersion { Id = "1", FileSize = 123, PublishDateTime = DateTime.Now.AddDays(-1) };
            _appStoreUIServiceMock.Setup(m => m.GetCurrentVersionForApp("1")).Returns(version);

            AppStoreService appStoreService = new AppStoreService(fileService, redisService, appStoreUIService, new FullTextSearchService(redisService), new IMEICacheService(redisService));
            string slver = string.Empty;
            EntityMapping.Config();
            var result = appStoreService.GetAppDownloadUrl("1", mobileParam, 0);

            Assert.NotEmpty(result);
        }
 private static void AddAppUpdateListItem(List<AppUpdateListItemView> appUpdateListItems, AppProject appProject, App app, AppUpdateListItemView appView, AppVersion currentVersion)
 {
     appView.Id = app.Id;
     appView.AppNo = appProject.AppNo;
     appView.DownloadUrl = FILE_PREFIX + currentVersion.FileUrl;
     appView.Drive = app.Drive;
     appView.IsHide = app.IsHide;
     appView.StorageName = app.StorageName;
     appView.UpdateTip = currentVersion.Tip;
     appView.UpdateType = currentVersion.UpdateTypeId;
     appView.Version = currentVersion.Id;
     appView.VersionName = currentVersion.VersionName;
     appView.ApkName = appProject.PackageName;
     appView.FileSize = currentVersion.FileSize;
     appUpdateListItems.Add(appView);
 }
 public override ActionResult AppAdd(AppProject model, HttpPostedFileBase LogoFile)
 {
     return base.AppAdd(model, LogoFile);
 }
        internal AppView AppDetailInternal(App app, AppProject appProject)
        {
            var appView = default(AppView);

            if (appProject != null && app != null && !app.Id.IsNullOrEmpty() && !appProject.Id.IsNullOrEmpty())
            {
                appView = EntityMapping.Auto<App, AppView>(app);
                appView.ApkName = appProject.PackageName;
                appView.AppNo = app.AppNo;
                appView.Company = appProject.Creator;
                appView.Rate = appProject.Rate.ToString();
                appView.DownloadTimes = app.DownloadTimes;
                //image
                var imgInfos = app.ScreenShot;
                appView.ImageCount = imgInfos.Count;
                appView.ImageList = new List<string>();
                imgInfos.ForEach(i => appView.ImageList.Add(i.Id + i.Extension));
                appView.LogoFileName = AppStoreService.GetSingleAppImageUrl(app.Logo.Id);
                appView.ScreenShots = new List<string>();
                foreach (var i in appView.ImageList)
                {
                    appView.ScreenShots.Add(AppStoreService.GetSingleAppImageUrl(i));
                }

                var appVersion = default(AppVersion);
                appVersion = AppStoreUIService.GetCurrentVersionForApp(app.Id);

                if (appVersion != null && appView != null)
                {
                    var pkgInfo = AppStoreUIService.GetApkInfoForApp(app.Id, appVersion.Id, false);
                    if (pkgInfo != null)
                    {
                        appView.MinSDKVersion = SingletonBase<AndroidVersionRepository>.Instance.GetVersionByAPILevel(pkgInfo.MinSDKVersion);
                    }
                    appView.Version = appVersion.Id;
                    appView.VersionName = appVersion.VersionName;
                    appView.PublishTime = appVersion.PublishDateTime;
                    appView.FileSize = appVersion.FileSize;
                    appView.DownloadUrl = (FILE_PREFIX + appVersion.FileUrl).ToFileServerUrlAPP();

                }
            }

            return appView;
        }
        public AppWebView AppDetailInternal(App app, AppProject appProject)
        {
            var appWebView = default(AppWebView);

            if (appProject != null && app != null && !app.Id.IsNullOrEmpty() && !appProject.Id.IsNullOrEmpty())
            {
                appWebView = AppDetailInternalWithOutRecommend(appWebView, app, appProject);

                var recommends = RedisService.GetAllSubModelsByType<App, AppRecommend>(app.Id);
                List<AppWebView> Apps = new List<AppWebView>();
                appWebView.RecommendApps = Apps;

                appWebView.TagCategory = "应用";
                var tagList = AppStoreUIService.GetTagsByTagCategory(ConfigKeys.TAGGROUPID_GAME.ConfigValue());
                foreach (var tag in tagList)
                {
                   var appids = AppStoreUIService.GetAppIdsByTag(tag.Id);
                   if (appids.Contains("App:" + app.Id))
                   {
                       appWebView.TagCategory = "游戏";
                       break;
                   }
                }

                var num = 1;// 单行最多取7个
                foreach (var item in recommends)
                {
                    var recommendApp = RedisService.Get<App>(item.Id);
                    if (recommendApp!=null)
                    {
                        var appproject = RedisService.Get<AppProject>(recommendApp.AppProjectId);
                        AppWebView webview = new AppWebView ();
                        webview = AppDetailInternalWithOutRecommend(webview, recommendApp, appproject);
                        appWebView.RecommendApps.Add(webview);
                    }
                    if (num>6)
                    {
                        break;
                    }
                    num += 1;
                }

            }

            return appWebView;
        }