/// <summary> /// Creates a condition node that is a logical conjunction ("AND") or disjunction ("OR") /// of a collection of subconditions. /// </summary> /// <param name="conditionType">The SearchConditionType of the condition node. /// Must be either AndCondition or OrCondition.</param> /// <param name="simplyfy">TRUE to logically simplify the result, if possible; /// then the result will not necessarily to be of the specified kind. FALSE if the result should /// have exactly the prescribed structure. An application that plans to execute a query based on the /// condition tree would typically benefit from setting this parameter to TRUE. </param> /// <param name="conditionNodes">Array of subconditions</param> /// <returns>New SearchCondition based on the operation</returns> public static SearchCondition CreateAndOrCondition(SearchConditionType conditionType, bool simplyfy, params SearchCondition[] conditionNodes) { // Same as the native "IConditionFactory:MakeAndOr" method IConditionFactory nativeConditionFactory = (IConditionFactory) new ConditionFactoryCoClass(); ICondition result = null; try { // List <ICondition> conditionList = new List <ICondition>(); foreach (SearchCondition c in conditionNodes) { conditionList.Add(c.NativeSearchCondition); } IEnumUnknown subConditions = new EnumUnknownClass(conditionList.ToArray()); HRESULT hr = nativeConditionFactory.MakeAndOr(conditionType, subConditions, simplyfy, out result); if (!CoreErrorHelper.Succeeded((int)hr)) { Marshal.ThrowExceptionForHR((int)hr); } } finally { if (nativeConditionFactory != null) { Marshal.ReleaseComObject(nativeConditionFactory); } } return(new SearchCondition(result)); }
public static SearchCondition CreateAndOrCondition(SearchConditionType conditionType, bool simplify, params SearchCondition[] conditionNodes) { ICondition result = null; var nativeConditionFactory = (IConditionFactory) new ConditionFactoryCoClass(); try { var conditions = new List <ICondition>(); if (conditionNodes != null) { conditions.AddRange(conditionNodes.Select(c => c.SearchConditionNative)); } IEnumUnknown subConditions = new EnumUnknown <ICondition>(conditions); var hr = nativeConditionFactory.MakeAndOr((CONDITION_TYPE)conditionType, subConditions, simplify, out result); if (HRESULT.Failed(hr)) { throw ShellException.FromHRESULT(hr); } } finally { Marshal.ReleaseComObject(nativeConditionFactory); } return(new SearchCondition(result)); }
/// <summary> /// Creates a condition node that is a logical conjunction ("AND") or disjunction ("OR") /// of a collection of subconditions. /// </summary> /// <param name="conditionType">The SearchConditionType of the condition node. /// Must be either AndCondition or OrCondition.</param> /// <param name="simplyfy">TRUE to logically simplify the result, if possible; /// then the result will not necessarily to be of the specified kind. FALSE if the result should /// have exactly the prescribed structure. An application that plans to execute a query based on the /// condition tree would typically benefit from setting this parameter to TRUE. </param> /// <param name="conditionNodes">Array of subconditions</param> /// <returns>New SearchCondition based on the operation</returns> public static SearchCondition CreateAndOrCondition(SearchConditionType conditionType, bool simplyfy, params SearchCondition[] conditionNodes) { // Same as the native "IConditionFactory:MakeAndOr" method IConditionFactory nativeConditionFactory = (IConditionFactory)new ConditionFactoryCoClass(); ICondition result = null; try { // List<ICondition> conditionList = new List<ICondition>(); foreach (SearchCondition c in conditionNodes) conditionList.Add(c.NativeSearchCondition); IEnumUnknown subConditions = new EnumUnknownClass(conditionList.ToArray()); HRESULT hr = nativeConditionFactory.MakeAndOr(conditionType, subConditions, simplyfy, out result); if (!CoreErrorHelper.Succeeded((int)hr)) Marshal.ThrowExceptionForHR((int)hr); } finally { if (nativeConditionFactory != null) Marshal.ReleaseComObject(nativeConditionFactory); } return new SearchCondition(result); }
/// <summary> /// Метод поиска по имени объекта /// </summary> /// <param name="searchConditionType">Параметр условия поиска, значение Enum указывает по какому критерию будет поиск</param> /// <param name="searchOperatorType">Оператор операции поиска</param> /// <param name="name">Имя объекта</param> /// <param name="address">Относительный адрес API сервиса (опциональное значение)</param> /// <returns></returns> public async Task <List <Result> > SearchObjectAsync(SearchConditionType searchConditionType, SearchOperatorType searchOperatorType, string name, string address = @"api/objects/search") { var findObject = MakeFindObject(searchConditionType, searchOperatorType, name); var results = await Request(findObject, address); return(results); }
protected IEnumerable <SearchCondition> BuildWhatConditions( [NotNull] string toSearchWhat, SearchWhatFlags searchWhatMethod, [NotNull] string dbField, bool useFullText) { CodeContracts.ArgumentNotNull(toSearchWhat, "toSearchWhat"); CodeContracts.ArgumentNotNull(dbField, "dbField"); toSearchWhat = toSearchWhat.Replace("'", "''").Trim(); var conditions = new List <SearchCondition>(); string conditionSql = string.Empty; SearchConditionType conditionType = SearchConditionType.AND; if (searchWhatMethod == SearchWhatFlags.AnyWords) { conditionType = SearchConditionType.OR; } var wordList = new List <string> { toSearchWhat }; if (searchWhatMethod == SearchWhatFlags.AllWords || searchWhatMethod == SearchWhatFlags.AnyWords) { wordList = toSearchWhat.Replace(@"""", string.Empty).Split(' ').Where(x => x.IsSet()).Select(x => x.Trim()).ToList(); } if (useFullText) { var list = new List <SearchCondition>(); list.AddRange( wordList.Select( word => new SearchCondition { Condition = @"""{0}""".FormatWith(word), ConditionType = conditionType })); conditions.Add( new SearchCondition { Condition = "CONTAINS ({1}, N' {0} ')".FormatWith(list.BuildSql(false), dbField), ConditionType = conditionType }); } else { conditions.AddRange( wordList.Select( word => new SearchCondition { Condition = "{1} LIKE N'%{0}%'".FormatWith(word, dbField), ConditionType = conditionType })); } return(conditions); }
protected IEnumerable <SearchCondition> BuildWhoConditions( [NotNull] string toSearchFromWho, SearchWhatFlags searchFromWhoMethod, bool searchDisplayName) { CodeContracts.ArgumentNotNull(toSearchFromWho, "toSearchFromWho"); toSearchFromWho = toSearchFromWho.Replace("'", "''").Trim(); var conditions = new List <SearchCondition>(); string conditionSql = string.Empty; SearchConditionType conditionType = SearchConditionType.AND; if (searchFromWhoMethod == SearchWhatFlags.AnyWords) { conditionType = SearchConditionType.OR; } var wordList = new List <string> { toSearchFromWho }; if (searchFromWhoMethod == SearchWhatFlags.AllWords || searchFromWhoMethod == SearchWhatFlags.AnyWords) { wordList = toSearchFromWho.Replace(@"""", string.Empty).Split(' ').Where(x => x.IsSet()).Select(x => x.Trim()).ToList(); } foreach (string word in wordList) { int userId; if (int.TryParse(word, out userId)) { conditionSql = "c.UserID IN ({0})".FormatWith(userId); } else { if (searchFromWhoMethod == SearchWhatFlags.ExactMatch) { conditionSql = "(c.Username IS NULL AND b.{1} = N'{0}') OR (c.Username = N'{0}')".FormatWith( word, searchDisplayName ? "DisplayName" : "Name"); } else { conditionSql = "(c.Username IS NULL AND b.{1} LIKE N'%{0}%') OR (c.Username LIKE N'%{0}%')".FormatWith( word, searchDisplayName ? "DisplayName" : "Name"); } } conditions.Add(new SearchCondition { Condition = conditionSql, ConditionType = conditionType }); } return(conditions); }
/// <summary> /// Закрытый метод создания объекта поиска по имени объекта /// </summary> /// <param name="searchConditionType">Параметр условия поиска, значение Enum указывает по какому критерию будет поиск</param> /// <param name="searchOperatorType">Оператор операции поиска</param> /// <param name="name">Имя объекта</param> /// <returns>Список объектов FindObject</returns> private FindObject MakeFindObject(SearchConditionType searchConditionType, SearchOperatorType searchOperatorType, string name) { var searchOperatorTypeInt = (int?)searchOperatorType; var searchConditionTypeInt = (int?)searchConditionType; var findObject = new FindObject { Conditions = new Condition[] { new Condition { Type = searchConditionTypeInt, Operator = searchOperatorTypeInt, Value = name } }, Filters = new Filter[] {} }; return(findObject); }
/// <summary> /// Закрытый метод создания объекта поиска по атрибуту объекта /// </summary> /// <param name="attributeId">значение для поиска</param> /// <param name="searchConditionType">Параметр условия поиска, значение Enum указывает по какому критерию будет поиск</param> /// <param name="searchOperatorType">Оператор операции поиска</param> /// <returns>Список объектов FindObject</returns> private FindObject MakeFindObject(string attributeId, SearchConditionType searchConditionType, SearchOperatorType searchOperatorType) { var searchOperatorTypeInt = (int?)searchOperatorType; var searchConditionTypeInt = (int?)searchConditionType; var findObject = new FindObject { Conditions = new Condition[] { new Condition { Type = searchConditionTypeInt, Operator = searchOperatorTypeInt, Attribute = attributeId } }, Filters = new Filter[] {} }; return(findObject); }
/// <summary> /// Displaies the data set. /// </summary> /// <returns>The data set.</returns> /// <param name="stateType">State type.</param> /// <param name="key">Key.</param> /// <param name="value">Value.</param> private void DisplayDataSet(SearchConditionType stateType, int key, string value) { #if UNITY_IOS key = key - 1; #endif switch (stateType) { case SearchConditionType.Order: if (key == 0) { _orderAPIThrow = "1"; _orderNative.transform.GetChild(1).gameObject.GetComponent <Text> ().text = value; } else { var order = CommonModelHandle.GetByNameBaseData(value, CurrentProfSettingStateType.UserSort); _orderAPIThrow = order.id; _orderNative.transform.GetChild(1).gameObject.GetComponent <Text> ().text = order.name; } break; case SearchConditionType.Gender: if (key == 0) { _sexAPIThrow = ""; _genderNative.transform.GetChild(1).GetComponent <Text> ().text = value; } else { var gender = CommonModelHandle.GetByNameBaseData(value, CurrentProfSettingStateType.Gender); _sexAPIThrow = gender.id; _genderNative.transform.GetChild(1).GetComponent <Text> ().text = value; } break; case SearchConditionType.AgeHigh: _ageHighAPIThrow = value; _ageToNative.transform.GetChild(1).gameObject.GetComponent <Text> ().text = value; break; case SearchConditionType.AgeLow: _ageLowAPIThrow = value; _ageFromNative.transform.GetChild(1).gameObject.GetComponent <Text> ().text = value; break; case SearchConditionType.TallHigh: _heightToAPIThrow = value; _heightToNative.transform.GetChild(1).gameObject.GetComponent <Text> ().text = value; break; case SearchConditionType.TallLow: _heightFromAPIThrow = value; _heightFromNative.transform.GetChild(1).gameObject.GetComponent <Text> ().text = value; break; case SearchConditionType.BodyType: if (key == 0) { _bodyTypeAPIThrow = ""; _bodyTypeNative.transform.GetChild(0).gameObject.SetActive(false); _bodyTypeNative.transform.GetChild(1).GetComponent <Text> ().text = "指定しない"; } else { _bodyTypeAPIThrow = value; _bodyTypeNative.transform.GetChild(0).gameObject.SetActive(false); _bodyTypeNative.transform.GetChild(1).GetComponent <Text> ().text = value; } break; case SearchConditionType.IsImage: if (key == 0) { _isImageAPIThrow = ""; _isImageNative.transform.GetChild(0).gameObject.SetActive(false); _isImageNative.transform.GetChild(1).GetComponent <Text> ().text = "指定しない"; } else { if ((key - 1) == 0) { _isImageAPIThrow = "0"; } else { _isImageAPIThrow = (key - 1).ToString(); } _isImageNative.transform.GetChild(0).gameObject.SetActive(false); _isImageNative.transform.GetChild(1).GetComponent <Text> ().text = value; } break; case SearchConditionType.Radius: if (key == 0) { _radiusAPIThrow = ""; _radiusNative.transform.GetChild(0).gameObject.SetActive(false); _radiusNative.transform.GetChild(1).GetComponent <Text> ().text = "指定しない"; } else { var r = CommonModelHandle.GetByNameBaseData(value, CurrentProfSettingStateType.Radius); if (r != null) { _radiusAPIThrow = r.id; _radiusNative.transform.GetChild(0).gameObject.SetActive(false); _radiusNative.transform.GetChild(1).GetComponent <Text> ().text = value; } else { _radiusAPIThrow = ""; _radiusNative.transform.GetChild(0).gameObject.SetActive(false); _radiusNative.transform.GetChild(1).GetComponent <Text> ().text = "指定しない"; } } break; } }
/// <summary> /// Natives the picker button. /// ネイティブピッカー用のボタン処理。 /// </summary> /// <returns>The picker button.</returns> /// <param name="stateType">State type.</param> public void NativePickerButton(string state) { SearchConditionType stateType = (SearchConditionType)System.Enum.Parse(typeof(SearchConditionType), state); string [] itemList = { "" }; List <string> list = new List <string> (); #if UNITY_IOS list.Add(""); #endif switch (stateType) { case SearchConditionType.Order: var order = CommonModelHandle.GetNameMaster(CurrentProfSettingStateType.UserSort); foreach (var o in order) { list.Add(o.name); } break; case SearchConditionType.Gender: list.Add("指定しない"); list.Add("女性"); list.Add("男性"); break; case SearchConditionType.AgeHigh: case SearchConditionType.AgeLow: for (int i = 18; i <= 100; i++) { list.Add(i.ToString()); } break; case SearchConditionType.TallHigh: case SearchConditionType.TallLow: for (int i = 110; i <= 220; i++) { list.Add(i.ToString()); } break; case SearchConditionType.BodyType: var bodyType = CommonModelHandle.GetNameMaster(AppStartLoadBalanceManager._gender, CurrentProfSettingStateType.BodyType); list.Add("指定しない"); foreach (var b in bodyType) { list.Add(b.name); } break; case SearchConditionType.IsImage: list.Add("指定しない"); list.Add("画像なし"); list.Add("画像あり"); break; case SearchConditionType.Radius: list.Add("指定しない"); foreach (var radius in InitDataApi._httpCatchData.result.radius) { list.Add(radius.name); } break; } if (list.Count > 0) { itemList = list.ToArray(); NativePicker.Instance.ShowCustomPicker(toScreenRect(_drawRect), itemList, 0, (long val) => { for (int i = 0; i < list.Count; i++) { if ((int)val == i) { DisplayDataSet(stateType, i, list[i]); break; } } Debug.Log("ピッカーの値。 " + val); }, () => { Debug.Log("ピッカーをキャンセルにした場合。"); }); } }
/// <summary> /// Метод поиска объекта по атрибуту в определнной группе объектов /// </summary> /// <param name="objectId">Id класса объекта для поиска</param> /// <param name="attibuteId">значение для поиска</param> /// <param name="filterTypes">Фильтр типа(по родительскому каталогу или по Id класса объекта)</param> /// <param name="searchCondition">Параметр условия поиска, значение Enum указывает по какому критерию будет поиск</param> /// <param name="searchOperatorType">Оператор операции поиска</param> /// <param name="address">Относительный адрес API сервиса (опциональное значение)</param> /// <returns>Список объектов Result</returns> public async Task <List <Result> > SearchObjectAsync(string objectId, string attibuteId, FilterTypes filterTypes, SearchConditionType searchCondition, SearchOperatorType searchOperatorType, string address = @"api/objects/search") { var findObject = MakeFindObject(objectId, attibuteId, filterTypes, searchCondition, searchOperatorType); var results = await Request(findObject, address); return(results); }
/// <summary> /// Закрытый метод создания объекта поиска по аттрибуту в определнной группе объектов /// </summary> /// <param name="objecteId">Id объекта для фильтра значения</param> /// <param name="attributeId">значение для поиска</param> /// <param name="filterTypes">Фильтр типа(по родительскому каталогу или по Id класса объекта)</param> /// <param name="searchConditionType">Параметр условия поиска, значение Enum указывает по какому критерию будет поиск</param> /// <param name="searchOperatorType">Оператор операции поиска</param> /// <returns>Список объектов FindObject</returns> private FindObject MakeFindObject(string objectId, string attributeId, FilterTypes filterTypes, SearchConditionType searchConditionType, SearchOperatorType searchOperatorType) { var newFindObject = new FindObject(); var findObject = new FindObject { Filters = new Filter[] { new Filter() { Type = (int)filterTypes, Value = objectId } }, Conditions = new Condition[] { new Condition { Type = (int?)searchConditionType, Operator = (int?)searchOperatorType, Attribute = attributeId } } }; return(findObject); }
/// <summary> /// Основной метод обновления данных по атрибуту /// </summary> /// <param name="existedAttributeId">Значение которое необходимо изменить</param> /// <param name="newValue">Значение на которое необходимо изменить</param> /// <param name="newVsearchConditionTypealue">Значение на которое необходимо изменить</param> /// <param name="searchOperatorType">Значение на которое необходимо изменить</param> /// <param name="address">Относительный адрес API сервиса (опциональное значение)</param> /// <returns>Список объектов Result</returns> public async Task <List <UpdateResult> > UpdateAttributeAsync(string existedAttributeId, string newValue, SearchConditionType searchConditionType, SearchOperatorType searchOperatorType, string address = @"api/objects") { var existedObjects = await search.SearchObjectAsync(existedAttributeId, searchConditionType, searchOperatorType, address); List <UpdateResult> results = new List <UpdateResult>(); foreach (var @object in existedObjects) { var sortedattributes = SortingAttributes(@object, existedAttributeId, newValue); results.AddRange(await SendRequestAsync(address, @object.ObjectId, sortedattributes)); } return(results); }