public ActionResult SetDefaultSettings() { var id = Request.Form["IntegratorId"]; //var appProject = RedisService.Get<AppProject>(appProjectId); if (Request.Form.Keys != null) { var index = 0; foreach (var key in Request.Form.Keys) { if (RedisService.IsExist<Element>(key.ToString())) { if (string.IsNullOrWhiteSpace(Request.Form[key.ToString()])) { TempData["errorMsg"] = string.Format("请将信息填充完整!"); return RedirectToAction("SetDefaultSettings", new { id = id }); } CustomProperty prop = new CustomProperty() { Id = key.ToString(), Value = Request.Form[key.ToString()] }; var listValue = Request.Form[key.ToString()].Split(',').ToList(); if (listValue.Count >= 2) { prop.Value = listValue; } if (prop.Value != null && !string.IsNullOrWhiteSpace(prop.Value.ToString())) { //RedisService.AddCustomPropertyFor<DeviceModel, CustomProperty>(AppProjectId, prop); var creatorId = "DefaultSettings:Creator:" + id; RedisService.SetEntryInHash<CustomProperty>(creatorId, "CustomProperty:" + prop.Id, prop); } index++; } } if (GetCountOfValidElement() > index) { TempData["errorMsg"] = string.Format("请将信息填充完整!"); return RedirectToAction("SetDefaultSettings", new { id = id }); } } return RedirectToAction("IntegratorList"); }
private void SetDefaultSettingsForIntegrator(Integrator model) { var creatorId = "DefaultSettings:Creator:" + model.Id; var elements = RedisService.GetValuesByIds<Element>(RedisService.GetAllActiveModelIds<Element>()).FilterByUIMode<Element>(GetFilterByCurrentMode("OTA")); if (elements != null) { foreach (var element in elements) { var prop = new CustomProperty { Id = element.Id }; var elementDetails = GetElementDetailList(element.Id).Where(x => x.Status == 1).ToList(); if (element.Type == (int)ElementType.单选按钮 || element.Type == (int)ElementType.多选列表) { if (elementDetails.Any()) { prop.Value = !element.Name.Equals(OTAConfigKeys.IsAutoDownload.ToString()) ? elementDetails[0].Value : elementDetails[1].Value; } } else { prop.Value = "优化了系统,修改了部分bug。"; } RedisService.SetEntryInHash<CustomProperty>(creatorId, "CustomProperty:" + prop.Id, prop); } } }
public override ActionResult AppBranchAdd(FormCollection parameters) { var appProject = RedisService.Get<AppProject>(parameters["appProjectId"]); var defaultProperties = SetDefaultSettingsToView(appProject.Creator); if (defaultProperties.Count < 1) { TempData["errorMsg"] = string.Format("请先添加该型号的默认配置信息!"); return RedirectToAction("AppBranchAdd", new { appProjectId = parameters["appProjectId"] }); } if (string.IsNullOrWhiteSpace(parameters["AppName"])) { TempData["errorMsg"] = string.Format("版本号不能为空!"); return RedirectToAction("AppBranchAdd", new { appProjectId = parameters["appProjectId"] }); } App app = new App(); string appName = parameters["AppName"].Trim(); Regex rx = new Regex(@"^[v|V].*"); if (!rx.IsMatch(appName)) { TempData["errorMsg"] = string.Format("版本号前面带v!"); return RedirectToAction("AppBranchAdd", new { appProjectId = parameters["appProjectId"] }); } try { Version version = new Version(appName.TrimStart(new char[] { 'v', 'V' }).Trim()); } catch { TempData["errorMsg"] = string.Format("版本号输入不符合规则!"); return RedirectToAction("AppBranchAdd", new { appProjectId = parameters["appProjectId"] }); } var appList = UIService.GetAppsFromAppList<AppProject>(parameters["appProjectId"]); foreach (var a in appList) { if (a.Name.ToUpper().Trim().Equals(appName.ToUpper().Trim())) { TempData["errorMsg"] = string.Format("已经添加过版本号【{0}】,版本号不能重复!", appName); return RedirectToAction("AppBranchAdd", new { appProjectId = parameters["appProjectId"] }); } } var elementIdNameMapping = GetElementIdNameMapping(); var apps = this.UIService.GetAppsFromAppList<AppProject>(appProject.Id); app.Name = ConfigHelper.IsOTAMode() ? appName : string.Format("{0}({1})", appProject.Name, appName); app.CreateDateTime = DateTime.Now; app.AppProjectId = parameters["appProjectId"]; app.AppNo = appProject.AppNo; var appId = RedisService.Add<App>(app); if (string.IsNullOrEmpty(appId)) { TempData["errorMsg"] = string.Format("Please check if there is duplicate name."); return RedirectToAction("AppBranchList", new { appProjectId = parameters["appProjectId"] }); } var properties = apps.Count > 0 ? apps[0].CustomProperties : defaultProperties; foreach (var propertie in properties) { if (propertie.Value == null || !elementIdNameMapping.ContainsKey(propertie.Key)) { continue; } CustomProperty prop = new CustomProperty() { Id = propertie.Key.ToString(), Value = !elementIdNameMapping[propertie.Key].ToString().Contains(OTAConfigKeys.OTAUpdateContent.ToString()) ? propertie.Value.ToString() : defaultProperties[propertie.Key].ToString() }; if (prop.Value != null && !string.IsNullOrWhiteSpace(prop.Value.ToString())) { RedisService.AddCustomPropertyFor<App, CustomProperty>(appId, prop); } } AppSettingsForAppList appSetting = new AppSettingsForAppList() { Id = appId, CreateDateTime = DateTime.Now }; UIService.SetAppForAppList<AppProject>(parameters["appProjectId"], appSetting); return RedirectToAction("AppBranchList", new { appProjectId = parameters["appProjectId"] }); }
public override ActionResult AppBranchEdit(App model) { #region Validation var elementIdNameMapping = GetElementIdNameMapping(); var isUpdateAll = Request.Form["isUpdateAll"].ToString().Contains("True") ? true : false; var index = 1; var tipIsNull = false; foreach (var formkey in Request.Form.Keys) { if (index > 4) { if (elementIdNameMapping[formkey.ToString()].ToString().Contains(OTAConfigKeys.OTAUpdateContent.ToString())) tipIsNull = Request.Form[formkey.ToString()].ToString().Trim().IsNullOrEmpty(); } index++; } var integrated = isUpdateAll ? Request.Form.Count == Convert.ToInt32(Request.Form["AttributeCount"]) + 4 || Request.Form.Count == Convert.ToInt32(Request.Form["AttributeCount"]) + 4 - 1 : !tipIsNull; if (!integrated) { TempData["errorMsg"] = string.Format("请将信息填充完整!"); if (isUpdateAll) return RedirectToAction("AppBranchEdit", new { appProjectId = model.AppProjectId }); return RedirectToAction("AppBranchEdit", new { AppId = model.Id, appProjectId = model.AppProjectId }); } #endregion var apps = new List<App> { model }; if (isUpdateAll) { apps = this.UIService.GetAppsFromAppList<AppProject>(model.AppProjectId); } foreach (var app in apps) { var appCustomProperties = RedisService.GetAllSubModelsByType<App, CustomProperty>(app.Id); foreach (var p in appCustomProperties) { if (!elementIdNameMapping.Keys.Contains(p.Id)) continue; if (!elementIdNameMapping[p.Id].Contains(OTAConfigKeys.OTAUpdateContent.ToString()) && isUpdateAll) RedisService.DeleteCustomPropertyFor<App, CustomProperty>(app.Id, p); } if (Request.Form.Keys != null) { foreach (var key in Request.Form.Keys) { if (RedisService.IsExist<Element>(key.ToString())) { if (string.IsNullOrWhiteSpace(Request.Form[key.ToString()]) || (elementIdNameMapping[key.ToString()].Contains(OTAConfigKeys.OTAUpdateContent.ToString()) && isUpdateAll)) continue; CustomProperty prop = new CustomProperty() { Id = key.ToString(), Value = Request.Form[key.ToString()] }; var listValue = Request.Form[key.ToString()].Split(',').ToList(); if (listValue.Count >= 2) { prop.Value = listValue; } if (prop.Value != null && !string.IsNullOrWhiteSpace(prop.Value.ToString())) { RedisService.AddCustomPropertyFor<App, CustomProperty>(app.Id, prop); } } } } } return RedirectToAction("AppBranchList", new { appProjectId = model.AppProjectId }); }
public void AppStoreIntergrationTest() { Redis.AddItemToQueue<string>("qlist1", "task"); var waitResult = Redis.RetrieveItemFromQueue<string>("qlist1"); Console.WriteLine(waitResult); #region App Add & Get 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); Redis.Add<App>(app); PrintDebug("app id:10001 added"); Redis.Add<App>(app1); PrintDebug("app id:10002 added"); PrintDebug("Get app info for id:10001 : " + Redis.Get<App>("10001").Name); Console.WriteLine("Get one page of app : " + Redis.GetValuesByIds<App>(Redis.GetPagedModelIds<App>(1, 2)).Count); Console.WriteLine("Get one page of app sorted by price: " + Redis.GetValuesByIds<App>(Redis.GetPagedModelIds<App>(1, 2, "Price", true)).Count); #endregion #region App Element settings Element ele = new Element(); ele.Id = "1"; ele.Name = "分辨率"; ele.Type = (int)ElementType.多选列表; Redis.Add<Element>(ele); ElementDetail eleDetl = new ElementDetail(); eleDetl.Id = "2"; eleDetl.Value = "176x220"; eleDetl.ElementId = "1"; Redis.Add<ElementDetail>(eleDetl); ElementDetail eleDetl1 = new ElementDetail(); eleDetl1.Id = "3"; eleDetl1.Value = "240x320"; eleDetl1.ElementId = "1"; Redis.Add<ElementDetail>(eleDetl1); ElementDetail eleDetl2 = new ElementDetail(); eleDetl2.Id = "4"; eleDetl2.Value = "240x400"; eleDetl2.ElementId = "1"; Redis.Add<ElementDetail>(eleDetl2); var collection = Redis.GetValuesByIds<Element>(Redis.GetAllActiveModelIds<Element>()); PrintDebug("Element count: " + collection.Count + " " + Redis.GetAllCount<Element>()); if (collection.Count > 0) { PrintDebug("Element name: " + collection[0].Name); } var collection2 = AppStoreSvc.GetElementDetailList("1"); PrintDebug("ElementDetail count for Element[1]: " + collection2.Count); var originModel = CloneHelper.DeepClone<Element>(ele); ele.Name = "resolution"; Redis.UpdateWithRebuildIndex<Element>(originModel, ele); PrintDebug("Element name: " + Redis.Get<Element>("1").Name); if (Redis.Get<Element>("1") == null) { PrintDebug("Element[1] deleted."); } #endregion #region App Dynamic Property #region Element Settings Element ele2 = new Element(); ele2.Id = "2"; ele2.Name = "CustomProperty"; ele2.Type = (int)ElementType.多选列表; ele2.IsQueriable = true; Redis.Add<Element>(ele2); Element ele5 = new Element(); ele5.Id = "3"; ele5.Name = "Resolution"; ele5.Type = (int)ElementType.多选列表; ele5.IsQueriable = true; Redis.Add<Element>(ele5); Element ele4 = new Element(); ele4.Id = "4"; ele4.Name = "IsTouchable"; ele4.Type = (int)ElementType.输入框; ele4.IsQueriable = true; Redis.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; Redis.Add<Element>(ele3); ElementDetail elementDetail3 = new ElementDetail(); elementDetail3.ElementId = "3"; elementDetail3.Value = 3.6; #endregion // Set up dynamic value for App 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; Redis.AddCustomPropertyFor<App, CustomProperty>("10001", customProperty); Redis.AddCustomPropertyFor<App, CustomProperty>("10001", customProperty2); Redis.AddCustomPropertyFor<App, CustomProperty>("10001", resolutionProperty); Redis.AddCustomPropertyFor<App, CustomProperty>("10001", isTouchableProperty); resolutionProperty.Value = new List<string>() { "320*480" }; Redis.AddCustomPropertyFor<App, CustomProperty>("10002", resolutionProperty); isTouchableProperty.Value = false; Redis.AddCustomPropertyFor<App, CustomProperty>("10002", isTouchableProperty); PrintDebug("add App's custom property: " + Redis.GetCustomPropertyFrom<App, CustomProperty>("10001", "CustomProperty").Id); Dictionary<string, string> newConditions = new Dictionary<string, string>(); newConditions.Add("Resolution", "320*480"); newConditions.Add("IsTouchable", bool.TrueString); newConditions.Add("CustomProperty", "CustomPropertyValue2"); PrintDebug("found app by dynamic property : " + Redis.FindIdsByConditions<App>(newConditions).Count); PrintDebug("found app by dynamic property (double value) : " + Redis.FindIdsByValueRange<App>("IntCustomProperty", 3.58, 3.62).Count); PrintDebug("find Custom Properties count for app[10001] : " + Redis.GetModelWithCustomProperties<App, CustomProperty>("10001").CustomProperties.Count); var originalCustomProperty = CloneHelper.DeepClone<CustomProperty>(customProperty); customProperty.IsQueriable = false; Redis.UpdateCustomPropertyFor<App, CustomProperty>("10001", originalCustomProperty, customProperty); PrintDebug("found app by dynamic property [CustomProperty:CustomPropertyValue2] after set IsQueriable to false : " + Redis.FindIdsByConditions<App>(newConditions).Count); //AppStoreSvc.DeleteCustomPropertyForApp("10001", customProperty); //PrintDebug("delete App's CustomProperty: " + (AppStoreSvc.GetCustomPropertyForApp("10001", "CustomProperty") == null)); #endregion #region Find app By a certain Value Range List<App> apps = Redis.GetValuesByIds<App>(Redis.FindIdsByValueRange<App>("Price", 10.56, 25.88)); PrintDebug("found app num by 10.56<= Price <=25.88 : " + apps.Count); apps = Redis.GetValuesByIds<App>(Redis.FindIdsByValueRange<App>("CreateDateTime", new DateTime(2011, 11, 23, 1, 1, 1), new DateTime(2011, 12, 1, 1, 1, 1))); PrintDebug("found app num by CreateDate : " + apps.Count); #endregion #region Fuzzy Find App apps = Redis.GetValuesByIds <App>(Redis.FuzzyFindIdsByCondition<App>("N*e", "App?")); PrintDebug("found app num by N*e like App? " + apps.Count); #endregion #region Complex Find App List<string> appIdsByValueRange = Redis.FindIdsByValueRange<App>("Price", 10.55, 25.88); List<string> appIdsByDateValueRange = Redis.FindIdsByValueRange<App>("CreateDateTime", new DateTime(2011, 11, 23, 1, 1, 1), new DateTime(2011, 12, 1, 1, 1, 1)); // Intersect means AND, Union mean OR List<App> finalResult = Redis.GetValuesByIds<App>((appIdsByValueRange.Intersect<string>(appIdsByDateValueRange).ToList())); PrintDebug("found app num by complex conditions " + finalResult.Count); #endregion #region App Version AppVersion appVer = new AppVersion(); appVer.Id = "10000"; appVer.FileUrl = "C:\a"; appVer.PublishDateTime = DateTime.Now; AppStoreSvc.AddAppVersion("10001", appVer); appVer.FileUrl = "E:\\"; AppStoreSvc.AddAppVersion("10001", appVer); AppStoreSvc.SetAppCurrentTestVersion("10001", "10000"); PrintDebug("added version num : " + AppStoreSvc.GetCurrentTestVersionForApp("10001").Id); PrintDebug("app current version : " + Redis.Get<App>("10001").CurrentTestVersion); var appCopy = CloneHelper.DeepClone<App>(app); app.Name = "App3"; Redis.UpdateWithRebuildIndex<App>(appCopy, app); PrintDebug("App name updated to " + Redis.Get<App>("10002").Name); #endregion #region Category Category c1 = new Category(); c1.Id = "1"; c1.Name = "游戏"; c1.ParentId = "0"; c1.status = "1"; Redis.Add<Category>(c1); Category csub1 = new Category(); csub1.Id = "2"; csub1.Name = "益智游戏"; csub1.ParentId = "1"; csub1.status = "1"; Redis.Add<Category>(csub1); PrintDebug("Sub Category count for Category[0] : " + AppStoreSvc.GetCategoryList("0").Count); #endregion #region App list AppList applist1 = new AppList(); applist1.Name = "10010"; applist1.Id = "10010"; applist1.CreateDateTime = DateTime.Now.AddSeconds(-3); applist1.CurrentVersion = 10010; AppList applist2 = new AppList(); applist2.Name = "10020"; applist2.Id = "10020"; applist2.CreateDateTime = DateTime.Now.AddDays(3); applist2.CurrentVersion = 10011; Redis.Add<AppList>(applist1); Redis.Add<AppList>(applist2); PrintDebug("two app lists added."); customProperty.IsQueriable = true; Redis.AddCustomPropertyFor<AppList, CustomProperty>(applist1.Id, customProperty); Dictionary<string, string> applistConditions = new Dictionary<string, string>(); applistConditions.Add("CustomProperty", "CustomPropertyValue2"); PrintDebug("found applist by dynamic property : " + Redis.FindIdsByConditions<AppList>(applistConditions).Count); var applist1Origin = CloneHelper.DeepClone<AppList>(applist1); applist1.CreateDateTime = DateTime.Now.AddDays(1); applist1.CurrentVersion++; // make sure bump version number when upate applist Redis.UpdateWithRebuildIndex<AppList>(applist1Origin, applist1); PrintDebug("app list updated :" + Redis.Get<AppList>("10010").Name); 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<AppList>("10010", customApp1); AppStoreSvc.SetAppForAppList<AppList>("10010", customApp2); var appsFromList1 = AppStoreSvc.GetAppsFromAppList<AppList>("10010"); PrintDebug("App count for AppList[10010] : " + appsFromList1.Count); var app1FromAppList1 = AppStoreSvc.GetAppFromAppList<AppList>("10010", "10001"); PrintDebug("Get App[10001]'s price From AppList[10010] : " + app1FromAppList1.Price); PrintDebug("Get App[10001]'s CustomProperty From AppList[10010] : " + app1FromAppList1.CustomProperties["CustomProperty"]); NameValueCollection headers = new NameValueCollection(); headers.Add("Resolution", "240*320"); headers.Add("IsTouchable", "1"); RequestHeadersMock.Setup(s => s.Header).Returns(headers); MobileParam requestParams = new MobileParam(RequestHeadersMock.Object); var matchedApp = AppStoreSvc.GetMatchedAppByRequest<AppList>("10010", requestParams); //PrintDebug("Matched app in applist[10010]: " + matchedApp.Id); AppSettingsForAppList customApp3 = new AppSettingsForAppList(); customApp3.Id = "10001"; customApp3.CustomProperties = new Dictionary<string, object>(); AppStoreSvc.SetAppForAppList<AppList>("10020", customApp3); List<string> appIdsUnion = AppStoreSvc.GetAppIdsByUnionAppList<AppList>("10010", "10020"); PrintDebug("Union applist1 and applist2, App count : " + appIdsUnion.Count); List<string> appIdsDiff = AppStoreSvc.GetAppIdsByDiffAppList<AppList>("10010", "10020"); PrintDebug("Diff applist1 and applist2, App count : " + appIdsDiff.Count); #endregion #region Device Model DeviceModel tyd1 = new DeviceModel() { Id = "天奕达HWQP", ModelName = "天奕达HWQP", CreateDateTime = DateTime.Now }; Redis.Add<DeviceModel>(tyd1); CustomProperty criteria1 = new CustomProperty() { Id = "Resolution", Value = "240*320", IsQueriable = false }; CustomProperty criteria2 = new CustomProperty() { Id = "IsTouchable", Value = true, IsQueriable = false }; PrintDebug("add device model : " + tyd1.ModelName); Redis.AddCustomPropertyFor<DeviceModel, CustomProperty>(tyd1.Id, criteria1); Redis.AddCustomPropertyFor<DeviceModel, CustomProperty>(tyd1.Id, criteria2); PrintDebug("add search criterias for device model : " + tyd1.ModelName); tyd1 = Redis.GetModelWithCustomProperties<DeviceModel, CustomProperty>("天奕达HWQP"); PrintDebug("search by DeviceModel[天奕达HWQP]: " + AppStoreSvc.GetAppsForDeviceModel(tyd1).Count); //PrintDebug("Get Device Model By Request parameters : " + AppStoreSvc.GetDeviceModelByRequest(requestParams).ModelName); #endregion #region Clean up Redis.DeleteWithCustomProperties<App, CustomProperty>("10001"); Redis.DeleteWithCustomProperties<App, CustomProperty>("10002"); Redis.DeleteWithCustomProperties<AppList, CustomProperty>(applist1.Id); Redis.DeleteWithCustomProperties<AppList, CustomProperty>(applist2.Id); Redis.Delete<Category>(c1); Redis.Delete<Category>(csub1); Redis.Delete<Element>(ele); Redis.Delete<Element>(ele2); Redis.Delete<Element>(ele3); Redis.Delete<Element>(ele4); Redis.Delete<Element>(ele5); Redis.Delete<ElementDetail>(eleDetl); Redis.Delete<ElementDetail>(eleDetl1); Redis.Delete<ElementDetail>(eleDetl2); Redis.Delete<DeviceModel>(tyd1); if (Redis.KeyFuzzyFind("*").Count == 0) { PrintDebug("App Count: " + Redis.GetAllCount<App>()); PrintDebug("All cleaned up."); } else { PrintDebug("Still useless keys left."); } #endregion }
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 DeviceModel_Test() { DeviceModel tyd1 = new DeviceModel() { Id = "天奕达HWQP", ModelName = "天奕达HWQP", CreateDateTime = DateTime.Now }; Service.Add<DeviceModel>(tyd1); CustomProperty criteria1 = new CustomProperty() { Id = "Resolution", Value = "240*320", IsQueriable = false }; CustomProperty criteria2 = new CustomProperty() { Id = "IsTouchable", Value = true, IsQueriable = false }; Service.AddCustomPropertyFor<DeviceModel, CustomProperty>(tyd1.Id, criteria1); Service.AddCustomPropertyFor<DeviceModel, CustomProperty>(tyd1.Id, criteria2); #region Clean up Service.Delete<DeviceModel>(tyd1); #endregion }
public void App_Dynamic_Property_Test() { #region Element Settings 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 Set up dynamic value for App 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; Service.AddCustomPropertyFor<App, CustomProperty>("10008", customProperty); Service.AddCustomPropertyFor<App, CustomProperty>("10008", customProperty2); Service.AddCustomPropertyFor<App, CustomProperty>("10008", resolutionProperty); Service.AddCustomPropertyFor<App, CustomProperty>("10008", isTouchableProperty); resolutionProperty.Value = new List<string>() { "320*480" }; Service.AddCustomPropertyFor<App, CustomProperty>("10007", resolutionProperty); isTouchableProperty.Value = false; Service.AddCustomPropertyFor<App, CustomProperty>("10007", isTouchableProperty); Dictionary<string, string> newConditions = new Dictionary<string, string>(); newConditions.Add("Resolution", "320*480"); newConditions.Add("IsTouchable", bool.TrueString); newConditions.Add("CustomProperty", "CustomPropertyValue2"); var originalCustomProperty = CloneHelper.DeepClone<CustomProperty>(customProperty); customProperty.IsQueriable = false; Service.UpdateCustomPropertyFor<App, CustomProperty>("10008", originalCustomProperty, customProperty); //AppStoreSvc.DeleteCustomPropertyForApp("10001", customProperty); #endregion }
//[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"); }