internal EntityColumnFilter(EntityColumn column, string groupName, FilterCondition condition, FilterComparison comparison) { this.Column = column; this.Comparison = comparison; this.Condition = condition; this.GroupName = groupName; }
public FileNameFilterSettings(SerializationInfo info, StreamingContext context) : base(info, context) { condition__ = (FilterCondition)info.GetInt32("Condition"); value__ = info.GetString("Value"); regularExpression__ = info.GetBoolean("ExpressRegularExpression"); }
protected internal void Filter( EntityColumn column, string @group = "Default", FilterCondition condition = FilterCondition.Default, FilterComparison comparison = FilterComparison.Default) { this.Filterables.Add(new EntityColumnFilter(column, @group, condition, comparison)); }
protected internal void Filter( IEnumerable<EntityColumn> columns, string @group = "Default", FilterCondition condition = FilterCondition.Default, FilterComparison comparison = FilterComparison.Default) { this.Filterables.AddRange(columns.Select(c => new EntityColumnFilter(c, @group, condition, comparison))); }
private void buttonAdd_Click(object sender, EventArgs e) { FilterCondition filtercondition = new FilterCondition(); filtercondition.filterAttributeType = FilterAttributeTypeFromString((string)this.comboBoxAttribute.SelectedItem); filtercondition.filterRelationType = FilterRelationTypeFromString((string)this.comboBoxCondition.SelectedItem); filtercondition.Value = this.textBoxValue.Text; filtercondition.Enable = true; this.filterContext.FilterConditionSet.Add(filtercondition); RefreshList(); }
/// <summary> /// 如果给定的FilterCondition是列表类型,则取出这个列表 /// </summary> /// <param name="fc"></param> /// <returns></returns> public static List<int> GetListValues(FilterCondition fc) { JArray source = fc.Value<JArray>(); List<int> values = new List<int>(); source.ToList<JToken>().ForEach(delegate(JToken x) { values.Add(x.Value<int>()); }); return values; }
private Dictionary <string, Condition> ToConditions(DynamoDBEntryConversion conversion, IEnumerable <string> epochAttributes) { var dic = new Dictionary <string, Condition>(); foreach (var kvp in Conditions) { string name = kvp.Key; FilterCondition fc = kvp.Value; bool convertToEpochSeconds = epochAttributes != null && epochAttributes.Contains(name); Condition condition = fc.ToCondition(conversion, convertToEpochSeconds, name); dic[name] = condition; } return(dic); }
public FilterDefinition <T> GetFromFilterType <T>(FilterDefinition <T> fd, FilterCondition s) { FilterDefinition <T> nfd = GetFromCompareType <T>(s); switch (s.FilterType) { case TableFilterType.OR: return(fd | nfd); case TableFilterType.AND: return(fd & nfd); default: return(fd & nfd); } }
private List<KHTHReturn> GetKeHoachThucHien(FilterCondition filter) { List<KHTHReturn> listKHTH = new List<KHTHReturn>(); using (TKTDSXEntities dc = new TKTDSXEntities()) { listKHTH = dc.GetKeHoachThucHien(filter.SystemId, filter.SelectedCapDo, filter.SelectedGiaTriCapDo, filter.SelectedCongDoan, filter.sDateFrom, filter.sDateTo).ToList<KHTHReturn>(); } return listKHTH; }
/// <summary> /// 转换成SQL语句 /// </summary> /// <returns>Select SQL语句</returns> public override string ToSQL() { if (PageCount == 0) { return(base.ToSQL()); } else { //判断元数据是否被签出 var stringBuilder = new StringBuilder(); var orderbyCondition = OrderByCondition.ToSQL(); var rowNumber = string.Format("ROW_NUMBER() Over({0}) as row_num", orderbyCondition); stringBuilder.Append(string.Format("SELECT * FROM (SELECT {0},{1} FROM {2}", SelectList.ToSQL(), rowNumber, From.ToSQL())); foreach (SqlElement element in MainFromItem.ChildCollection) { if (element is InnerJoinItem && (element as InnerJoinItem).IsExtendItem) { stringBuilder.Append((element as InnerJoinItem).ToSQLEx()); } } var joinCondition = JoinCondition.ToSQL(); if (!string.IsNullOrWhiteSpace(joinCondition)) { stringBuilder.AppendFormat("WHERE {0} ", joinCondition); } var filterCondition = FilterCondition.ToSQL(); if (!string.IsNullOrWhiteSpace(filterCondition)) { if (string.IsNullOrWhiteSpace(joinCondition)) { stringBuilder.AppendFormat(" WHERE {0} ", filterCondition); } else { stringBuilder.AppendFormat(" AND {0} ", filterCondition); } } if (PageCount > 0) { stringBuilder.AppendFormat(") as tabledata WHERE row_num BETWEEN ({0}-1)*{1}+1 AND ({0}-1)*{1}+{1}", PageIndex, PageCount); } return(stringBuilder.ToString()); } }
public bool FilerRecords(object o) { double res; bool checkNumeric = double.TryParse(FilterText, out res); var item = o as Employees; if (item != null && FilterText.Equals("")) { return(true); } else { if (item != null) { if (checkNumeric && !FilterOption.Equals("All Columns")) { if (FilterCondition == null || FilterCondition.Equals("Contains") || FilterCondition.Equals("StartsWith") || FilterCondition.Equals("EndsWith")) { FilterCondition = "Equals"; } bool result = MakeNumericFilter(item, FilterOption, FilterCondition); return(result); } else if (FilterOption.Equals("All Columns")) { if (item.Name.ToLower().Contains(FilterText.ToLower()) || item.Title.ToLower().Contains(FilterText.ToLower()) || item.Salary.ToString().ToLower().Contains(FilterText.ToLower()) || item.EmployeeID.ToString().ToLower().Contains(FilterText.ToLower()) || item.Gender.ToLower().Contains(FilterText.ToLower())) { return(true); } return(false); } else { if (FilterCondition == null || FilterCondition.Equals("Equals") || FilterCondition.Equals("LessThan") || FilterCondition.Equals("GreaterThan") || FilterCondition.Equals("NotEquals")) { FilterCondition = "Contains"; } bool result = MakeStringFilter(item, FilterOption, FilterCondition); return(result); } } } return(false); }
/// <summary> /// 得到值 /// </summary> /// <param name="filter"></param> /// <param name="conversionType"></param> /// <returns></returns> private static Expression ChangeTypeToExpression(FilterCondition filter, Type conversionType) { var constant = Expression.Constant(true); if (filter.Operator == FilterOperator.In) { return(Expression.Constant(filter.Value)); } var value = filter.Value.AsTo(conversionType); if (value == null) { return(constant); } return(Expression.Constant(value, conversionType)); }
/// <summary> /// 转换成SQL语句 /// </summary> /// <returns>Select SQL语句</returns> public override string ToSQL() { if (TopSize <= 0) { return(base.ToSQL()); } else { //判断元数据是否被签出 var stringBuilder = new StringBuilder(); stringBuilder.Append(string.Format("SELECT TOP {0} {1} FROM {2}", TopSize, SelectList.ToSQL(), From.ToSQL())); foreach (SqlElement element in MainFromItem.ChildCollection) { if (element is InnerJoinItem && (element as InnerJoinItem).IsExtendItem) { stringBuilder.Append((element as InnerJoinItem).ToSQLEx()); } } var joinCondition = JoinCondition.ToSQL(); if (!string.IsNullOrWhiteSpace(joinCondition)) { stringBuilder.AppendFormat("WHERE {0} ", joinCondition); } var filterCondition = FilterCondition.ToSQL(); if (!string.IsNullOrWhiteSpace(filterCondition)) { if (string.IsNullOrWhiteSpace(joinCondition)) { stringBuilder.AppendFormat(" WHERE {0} ", filterCondition); } else { stringBuilder.AppendFormat(" AND {0} ", filterCondition); } } var orderbyCondition = OrderByCondition.ToSQL(); if (!string.IsNullOrWhiteSpace(orderbyCondition)) { stringBuilder.AppendFormat(" ORDER BY {0}", orderbyCondition); } return(stringBuilder.ToString()); } }
private List<ThongKeLaoDong> GetThongKeLaoDong(FilterCondition f) { var listLaoDong = new List<ThongKeLaoDong>(); using (TKTDSXEntities dc = new TKTDSXEntities()) { try { listLaoDong = dc.GetThongKeLaoDong(f.SystemId, f.SelectedCapDo, f.SelectedGiaTriCapDo, f.SelectedCongDoan, f.sDateFrom, f.sDateTo).ToList<ThongKeLaoDong>(); } catch (Exception ex) { Console.Write(ex.Message); } return listLaoDong; } } //end function - GetThongKeLaoDong
public Form GetForm(string name) { var filters = new FilterCondition[] { new FilterCondition("FormName", name, FilterCondition.FilterOperator.Equals) }; var forms = m_store.Select <SQLForm>(filters, true); var f = forms.FirstOrDefault(); if (f == null) { return(null); } return(ConvertSQLForm(f)); }
public ArrayList GetKeHoachThucHien(FilterCondition filter) { ArrayList listKhTh = new ArrayList(); using (TKTDSXEntities dc = new TKTDSXEntities()) { string dtFrom = string.Format("{0}-{1}-{2}", filter.DateFrom.Year, filter.DateFrom.Month, filter.DateFrom.Day); string dtTo = string.Format("{0}-{1}-{2}", filter.DateFrom.Year, filter.DateFrom.Month, filter.DateFrom.Day); try { var listRaw = dc.GetKeHoachThucHien(filter.SystemId, filter.SelectedCapDo, filter.SelectedGiaTriCapDo, filter.SelectedCongDoan, dtFrom, dtTo).ToList <KHTHReturn>(); //Header ArrayList lineHeader = new ArrayList(); lineHeader.Add("Data"); for (int i = 0; i < listRaw.Count; i++) { lineHeader.Add(listRaw[i].CONGDOAN.ToString()); } listKhTh.Add(lineHeader); //KeHoach ArrayList lineKeHoach = new ArrayList(); lineKeHoach.Add("KeHoach"); for (int y = 0; y < listRaw.Count; y++) { lineKeHoach.Add(listRaw[y].KEHOACH.ToString()); } listKhTh.Add(lineKeHoach); //ThucHien ArrayList lineThucHien = new ArrayList(); lineThucHien.Add("ThucHien"); for (int y = 0; y < listRaw.Count; y++) { lineThucHien.Add(listRaw[y].THUCHIEN.ToString()); } listKhTh.Add(lineThucHien); } catch { //do nothing } } return(listKhTh); }
private void StartWork_Click(object sender, EventArgs e) { try { int selected = ListView.SelectedIndices[0]; DateTime datetime = new DateTime(Program.Current_Date.Year, Program.Current_Date.Month, Program.Current_Date.Day, DateTime.Parse(ListView.Items[selected].SubItems[0].Text).Hour, DateTime.Parse(ListView.Items[selected].SubItems[0].Text).Minute, DateTime.Parse(ListView.Items[selected].SubItems[0].Text).Second); //MessageBox.Show(ListView.Items[selected].SubItems[0].Text.ToString()); //MessageBox.Show(datetime.ToString()); DateModel selected_client_date = new DateModel(); List <DateModel> date_List = date.List("Get_Id", datetime); selected_client_date = date_List.Single(); //MessageBox.Show(datetime.ToString()); FilterCondition filter1 = new FilterCondition(); filter1.Field = "Personal_Id"; filter1.Value = Current_Id; filter1.Type = ConditionType.Equal; FilterCondition filter2 = new FilterCondition(); filter2.Field = "Date_Id"; filter2.Value = selected_client_date.Id.ToString(); filter2.Type = ConditionType.Equal; List <FilterCondition> filt = new List <FilterCondition>(); filt.Add(filter1); filt.Add(filter2); List <ProcModel> collection = proc.List(filt); long Id = collection.Single().Client_Id; long Proc_Id = collection.Single().Id; // MessageBox.Show(Id.ToString()); DoctorStartWork F = new DoctorStartWork(this, Id, Proc_Id); F.Show(); this.Hide(); } catch { MessageBox.Show("Ничего не выбрано"); } this.Refresh_list(); }
/// <summary> /// Set cột lọc cho lưới /// </summary> /// <param name="gridView">Lưới</param> /// <param name="columnName">Cột cần set</param> /// <param name="findFilterColumns">Danh sách cột filter(cách nhau bằng dấu chấm phẩy(;)</param> /// <param name="searchMode">Kiểu tìm kiếm</param> public static void SetFindFilterColumns( this GridView gridView, string columnName, string findFilterColumns = "*", FilterCondition searchMode = FilterCondition.Default) { if (gridView.Columns[columnName] != null) { var columnEdit = gridView.Columns[columnName].ColumnEdit; if (columnEdit is RepositoryItemSearchLookUpEdit) { RepositoryItemSearchLookUpEdit lookUpEdit = columnEdit.CastTo <RepositoryItemSearchLookUpEdit>(); lookUpEdit.View.OptionsFind.FindFilterColumns = findFilterColumns; lookUpEdit.View.OptionsFind.HighlightFindResults = true; lookUpEdit.View.OptionsFind.Condition = searchMode; } } }
/// <summary> /// Add the notification to the wrap data grid. /// </summary> /// <param name="filter">Filter condition.</param> private void AddNotification(FilterCondition filter) { string notificationText = WrapDataGridPageSmall.GetNotificationMessage(filter); if (this.notificationArea != null && this.notification != null) { this.RemoveNotification(); if (!string.IsNullOrEmpty(notificationText)) { this.notification.Text = notificationText; if (this.WrapDataGrid != null) { this.WrapDataGrid.AddChild(this.notificationArea); } } } }
void Button_Delete_Click(object sender, EventArgs e) { TreeNode Node = filterControl.tViewFilters.SelectedNode; if (Node == null) { return; } string Msg = "你确定要删除条件 ‘" + Node.Text + "’ 吗?"; if (DialogResult.Yes == MessageBox.Show(Msg, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) { FilterCondition filterCondition = Node.Tag as FilterCondition; Source.DataFilter.FilterConditions.Remove(filterCondition); Node.Remove(); } }
private List<CountStatus> CountStatusChuyen(FilterCondition f) { var listCountStatus = new List<CountStatus>(); using (TKTDSXEntities dc = new TKTDSXEntities()) { try { listCountStatus = dc.CountTrangThaiChuyen(f.SystemId, f.SelectedCapDo, f.SelectedGiaTriCapDo, f.SelectedCongDoan, f.sDateFrom, f.sDateTo).ToList<CountStatus>(); } catch (Exception ex) { Console.Write(ex.Message); } } return listCountStatus; }
public void TestGetItem() { using (SQLServerClientService sqlBase = SQLServerClientService.GetInstance(conn1)) { FilterCondition filter = new FilterCondition("id", TableCompareType.EQ, ID1); Data result = new Data() { ID = ID1, Name = "Name1", Aliase = null }; Data obj = sqlBase.GetItem <Data>(tableName, filter); Assert.AreEqual(result.ID, obj.ID); Assert.AreEqual(result.Name, obj.Name); Assert.AreEqual(result.Aliase, obj.Aliase); } }
public bool UpdateItem <T>(string tableName, FilterCondition filter, string column, object value) { string sql; StringBuilder cols = new StringBuilder(); string where = tableUtils.FilterConditionToWhere(filter); DynamicParameters param = tableUtils.FilterConditionToParam(filter); string nName = tableUtils.GenUniqParam(column); cols.Append(string.Format("{0} = @{1}", column, nName)); param.Add(nName, value); tableUtils.ResetUniqParam(); sql = string.Format("UPDATE {0} SET {1} WHERE {2};", tableName, cols, where); return(conn.Execute(sql, param, transaction) > 0); }
public List <T> GetItemListBySearchStr <T>(List <T> list, FilterCondition condition) { if (list == null) { return(new List <T>()); } return(list.FindAll(d => { object val = ReflectionCommon.GetValue(d, condition.Key); if (val == null) { return false; } return condition.GetRegexValue().IsMatch(val.ToString()); })); }
public List <T> GetItemWild <T>(string tableName, FilterCondition filter) { List <T> list = new List <T>(); if (filter.Value == null) { return(new List <T>()); } RedisValue rValue = new RedisValue(filter.Value.ToString()); foreach (var h in db.HashScan(tableName, rValue)) { list.Add(DataConvert.StringToObject <T>(h.Value)); } return(list); }
public void LoadEditFilterCondition_ForFilterCondition_ReturnActionResult() { // Arrange InitializeLoadEditFilter(); var controller = new FilterController(); var filterCondition = new FilterCondition() { FilterGroupID = FilterGroupId }; // Act var result = controller.LoadEditFilterCondition(FilterGroupId) as PartialViewResult; // Assert result.ShouldSatisfyAllConditions( () => result.ShouldNotBeNull(), () => result.ViewName.ShouldBe(PartialsModalsEditFilter)); }
public void EditFilterCondition_ForSaveError_ReturnActionResult() { // Arrange InitializeEditFilter(); var controller = new FilterController(); var filterCondition = new FilterCondition() { FilterConditionID = FilterGroupId }; // Act var result = controller.EditFilterCondition(filterCondition) as JsonResult; // Assert result.ShouldSatisfyAllConditions( () => result.ShouldNotBeNull(), () => result.Data.ShouldNotBeNull()); }
private List<ChiPhiSanXuat> GetChiPhiSanXuat(FilterCondition f) { var listChiPhi = new List<ChiPhiSanXuat>(); using (TKTDSXEntities dc = new TKTDSXEntities()) { try { listChiPhi = dc.GETCHIPHISANXUAT(f.SystemId, f.SelectedCapDo, f.SelectedGiaTriCapDo, f.SelectedCongDoan, f.sDateFrom, f.sDateTo).ToList<ChiPhiSanXuat>(); } catch (Exception ex) { Console.Write(ex.Message); } } return listChiPhi; }
protected override Expression <Func <Conversation, bool> > Is(FilterCondition condition) { List <int> values = MatchValue(condition); if (values == null) { return(t => !t.DepartmentId.HasValue); } else { var predicate = PredicateBuilder.New <Conversation>(); foreach (int value in values) { predicate.Or(t => t.DepartmentId.HasValue && t.DepartmentId.Value == value); } return(predicate); } }
private int?MatchValue(FilterCondition condition) { int?value = default(int); if (condition.Value == "@Me") { value = GetUserId(); } else if (condition.Value == "Blank") { value = null; } else { value = int.Parse(condition.Value); } return(value); }
protected bool CheckCommonFilter() { bool res = true; try { int num = Filter.Conditions.Count; for (int i = 0; i < num; i++) { FilterCondition fcond = Filter.Conditions[i]; res = res && CheckCondition(fcond); } } catch (Exception ex) { Logger.LogWrite("ListManager.CheckCommonFilter(): " + ex.Message); res = true; } return(res); }
/// <summary> /// 得到值 /// </summary> /// <param name="filter"></param> /// <param name="conversionType"></param> /// <returns></returns> private static Expression ChangeTypeToExpression(FilterCondition filter, Type conversionType) { var constant = Expression.Constant(true); if (conversionType.Name != typeof(string).Name && filter.Operator == FilterOperator.Like) { throw new AppException("此{conversionType.Name}类型不支持Like,只有{typeof(string).Name}才支持Like!!!"); } var value = filter.Value.AsTo(conversionType); if (value == null) { return(constant); } return(Expression.Constant(value, conversionType)); }
private List <int> MatchValue(FilterCondition condition) { List <int> values = new List <int>(); if (condition.Value == "@My Department") { values = GetMyDepartments().ToList(); } else if (condition.Value == "Blank") { return(null); } else { values.Add(int.Parse(condition.Value)); } return(values); }
public JObject FilterToQuery(JObject ctx, FilterCondition filter) { JObject jr = new JObject(); if (filter.CompareType == TableCompareType.STREE) { if (filter.Value is IEnumerable <FilterCondition> ) { JArray js = new JArray(); IEnumerable <FilterCondition> ls = filter.Value as IEnumerable <FilterCondition>; foreach (FilterCondition f in ls) { JObject jn = FilterToQuery(ctx, f); if (jn == null) { continue; } js.Add(jn); } jr.Add(filter.Key, js); } else { if (filter.Value == null) { jr.Add(filter.Key, null); } else { FilterCondition nf = (FilterCondition)filter.Value; JObject jn = FilterToQuery(ctx, nf); jr.Add(filter.Key, jn); } } } else { jr = FilterToCompare(ctx, filter); } return(jr); }
/// <summary> /// 转换成SQL语句 /// </summary> /// <returns>Select SQL语句</returns> public override string ToSQL() { var stringBuilder = new StringBuilder(); stringBuilder.Append(string.Format("(SELECT {0} FROM {1} ", SelectList.ToSQL(), From.ToSQL())); foreach (SqlElement element in MainFromItem.ChildCollection) { if (element is InnerJoinItem && (element as InnerJoinItem).IsExtendItem) { stringBuilder.Append((element as InnerJoinItem).ToSQLEx()); } } var joinCondition = JoinCondition.ToSQL(); if (!string.IsNullOrWhiteSpace(joinCondition)) { stringBuilder.AppendFormat("WHERE {0} ", joinCondition); } var filterCondition = FilterCondition.ToSQL(); if (!string.IsNullOrWhiteSpace(filterCondition)) { if (string.IsNullOrWhiteSpace(joinCondition)) { stringBuilder.AppendFormat("WHERE {0} ", filterCondition); } else { stringBuilder.AppendFormat("AND {0} ", filterCondition); } } var orderbyCondition = OrderByCondition.ToSQL(); if (!string.IsNullOrWhiteSpace(orderbyCondition)) { stringBuilder.AppendFormat("ORDER BY {0}", orderbyCondition); } stringBuilder.AppendFormat(") {0}", TableAlias); return(stringBuilder.ToString()); }
private static Expression GetExpression( Expression exp1, Expression exp2, Expression exp3, FilterCondition condition) { switch (condition.Comparison) { case Comparison.Eq: switch (condition.Type) { case FilterType.Boolean: case FilterType.Numeric: case FilterType.List: return(Expression.Equal(exp1, exp2)); case FilterType.String: return(Expression.Call(exp1, "Contains", new Type[0], exp2)); case FilterType.Date: return(Expression.And( Expression.GreaterThanOrEqual(exp1, exp2), Expression.LessThanOrEqual(exp1, exp3))); default: throw new ArgumentOutOfRangeException(); } case Comparison.Gt: if (condition.Type == FilterType.Date) { return(Expression.GreaterThanOrEqual(exp1, exp3)); } return(Expression.GreaterThan(exp1, exp2)); case Comparison.Lt: if (condition.Type == FilterType.Date) { return(Expression.LessThanOrEqual(exp1, exp2)); } return(Expression.LessThan(exp1, exp2)); default: throw new ArgumentOutOfRangeException(); } }
internal static string GetFilterMethodName(FilterCondition filterCondition) { string methodName; switch (filterCondition) { case FilterCondition.StartsWith: methodName = "StartsWith"; break; case FilterCondition.EndsWith: methodName = "EndsWith"; break; case FilterCondition.Contains: methodName = "Contains"; break; default: methodName = "StartsWith"; break; } return methodName; }
CriteriaOperator PrepareFilter(string searchString, FilterCondition condition) { switch (condition) { case FilterCondition.Contains: return GroupOperator.Or(new FunctionOperator(FunctionOperatorType.Contains, "Subject", searchString), new FunctionOperator(FunctionOperatorType.Contains, "Location", searchString)); case FilterCondition.StartsWith: return GroupOperator.Or(new FunctionOperator(FunctionOperatorType.StartsWith, new OperandProperty("Subject"), searchString), new FunctionOperator(FunctionOperatorType.StartsWith, new OperandProperty("Location"), searchString)); case FilterCondition.Like: return GroupOperator.Or(new FunctionOperator(FunctionOperatorType.Contains, new OperandProperty("Subject"), searchString), new FunctionOperator(FunctionOperatorType.Contains, new OperandProperty("Location"), searchString)); case FilterCondition.Default: return GroupOperator.Or(new FunctionOperator(FunctionOperatorType.Contains, new OperandProperty("Subject"), searchString), new FunctionOperator(FunctionOperatorType.Contains, new OperandProperty("Location"), searchString)); case FilterCondition.Equals: return GroupOperator.Or(new BinaryOperator("Subject", searchString, BinaryOperatorType.Equal), new BinaryOperator("Location", searchString, BinaryOperatorType.Equal)); default: return null; } }
public SchedulerSearchInfo(string t, FilterCondition condition) { text = t; FilterCondition = condition; }
/// <summary> /// Adds a condition /// </summary> /// <param name="attributeName"></param> /// <param name="filterCondition"></param> protected void AddCondition(string attributeName, FilterCondition filterCondition) { Conditions[attributeName] = filterCondition; }
/// <summary> /// Gets the notification message to be shown for a filter condition. /// </summary> /// <param name="filter">Filter condition for the message.</param> /// <returns>Returns the message to be shown in notification area.</returns> private static string GetNotificationMessage(FilterCondition filter) { string notificationText = "The list is filtered to show: "; switch (filter) { case FilterCondition.Past: notificationText = string.Empty; break; case FilterCondition.PastTwoMonths: notificationText += " Past 2 months medications"; break; case FilterCondition.PastSixMonths: notificationText += " Past 6 months medications"; break; case FilterCondition.Current: notificationText = string.Empty; break; } return notificationText; }
public void SaveFilterCondition(int moduleId, FilterCondition filterCondition) { ModuleController.Instance.UpdateModuleSetting(moduleId, FilterConditionSetting, filterCondition.ToString()); }
/// <summary> /// Adds a condition for a specified attribute. /// /// If a condition for the attribute already exists, /// it will be replaced with the new condition. /// </summary> /// <param name="attributeName">Target attribute name</param> /// <param name="condition">Condition to be added</param> public void AddCondition(string attributeName, Condition condition) { Conditions[attributeName] = new FilterCondition(condition); }
//public static DynamicSqlParam[] ToSqlParams(FilterConditions filters, IDynamicParamConverter converter) //{ // List<DynamicSqlParam> list = new List<DynamicSqlParam>(); // foreach (FilterCondition condition in filters.Conditions) // { // Comparison comparison = condition.Comparison; // string field = condition.Field; // if (converter != null) // { // if (converter.FieldMap.ContainsKey(field)) // { // field = converter.FieldMap[field]; // if (string.IsNullOrEmpty(field)) // { // continue; // } // } // else if (converter.Converters.ContainsKey(field)) // { // list.AddRange(converter.Converters[field](condition)); // continue; // } // } // FilterType type = condition.Type; // object obj2 = condition.Value<object>(); // DynamicSqlFilter item = DynamicSqlParam.CreateFilter(); // item.Name = field; // if (obj2 is JValue) // { // JValue value2 = obj2 as JValue; // object obj3 = value2.Value; // switch (value2.Type) // { // case JTokenType.Integer: // obj3 = Convert.ToInt32(obj3); // break; // case JTokenType.Float: // obj3 = Convert.ToDecimal(obj3); // break; // case JTokenType.String: // obj3 = Convert.ToString(obj3); // break; // case JTokenType.Boolean: // obj3 = Convert.ToBoolean(obj3); // break; // case JTokenType.Date: // obj3 = Convert.ToDateTime(obj3); // break; // default: // throw new NotSupportedException("未支持的JTokenType" + value2.Type); // } // item.Value = obj3; // switch (comparison) // { // case Comparison.Eq: // item.Operation = Operation.Equal; // break; // case Comparison.Gt: // item.Operation = Operation.GreaterThan; // break; // case Comparison.Lt: // item.Operation = Operation.LessThan; // break; // } // if (obj3 is string) // { // item.Operation = Operation.Like; // } // } // else if (obj2 is JArray) // { // item.Operation = Operation.List; // JArray source = obj2 as JArray; // List<int> values = new List<int>(); // source.ToList<JToken>().ForEach(delegate(JToken x) // { // values.Add(x.Value<int>()); // }); // item.Value = values; // } // list.Add(item); // } // return list.ToArray(); //} //public static DynamicSqlParam[] ToSqlParams(FilterConditions filters, Func<string, string> fieldMap) //{ // List<DynamicSqlParam> list = new List<DynamicSqlParam>(); // foreach (FilterCondition condition in filters.Conditions) // { // Comparison comparison = condition.Comparison; // string field = condition.Field; // if (fieldMap != null) // { // field = fieldMap(field); // if (string.IsNullOrEmpty(field)) // { // continue; // } // } // FilterType type = condition.Type; // object obj2 = condition.Value<object>(); // DynamicSqlFilter item = DynamicSqlParam.CreateFilter(); // item.Name = field; // if (obj2 is JValue) // { // JValue value2 = obj2 as JValue; // object obj3 = value2.Value; // switch (value2.Type) // { // case JTokenType.Integer: // obj3 = Convert.ToInt32(obj3); // break; // case JTokenType.Float: // obj3 = Convert.ToDecimal(obj3); // break; // case JTokenType.String: // obj3 = Convert.ToString(obj3); // break; // case JTokenType.Boolean: // obj3 = Convert.ToBoolean(obj3); // break; // case JTokenType.Date: // obj3 = Convert.ToDateTime(obj3); // break; // default: // throw new NotSupportedException("未支持的JTokenType" + value2.Type); // } // item.Value = obj3; // switch (comparison) // { // case Comparison.Eq: // item.Operation = Operation.Equal; // break; // case Comparison.Gt: // item.Operation = Operation.GreaterThan; // break; // case Comparison.Lt: // item.Operation = Operation.LessThan; // break; // } // if (obj3 is string) // { // item.Operation = Operation.Like; // } // } // else if (obj2 is JArray) // { // item.Operation = Operation.List; // JArray source = obj2 as JArray; // List<int> values = new List<int>(); // source.ToList<JToken>().ForEach(delegate(JToken x) // { // values.Add(x.Value<int>()); // }); // item.Value = values; // } // list.Add(item); // } // return list.ToArray(); //} //public static List<DynamicSqlParam> ToSqlParams(StoreReadDataEventArgs e, IDynamicParamConverter converter, bool autoGenerateSort = true) //{ // List<DynamicSqlParam> list = new List<DynamicSqlParam>(); // if (!string.IsNullOrEmpty(e.Parameters["filter"])) // { // list.AddRange(ToSqlParams(new FilterConditions(e.Parameters["filter"]), converter)); // } // List<DynamicSqlParam> collection = ToSqlParams(e.Sort, converter.FieldMap).ToList<DynamicSqlParam>(); // if (autoGenerateSort && (collection.Count <= 0)) // { // DynamicSqlSorter item = DynamicSqlParam.CreateSorter(); // item.Direction = Xinchen.DbUtils.Direction.ASC; // item.Name = MapField(converter, "Id"); // collection.Add(item); // } // list.AddRange(collection); // return list; //} /// <summary> /// 将给定的Ext.Net过滤器转换为可供转换为Sql语句的过滤器 /// </summary> /// <param name="filterCondition"></param> /// <param name="field"></param> /// <returns></returns> static SqlFilter ConvertToFilter(FilterCondition filterCondition, string field) { object valueObject = filterCondition.Value<object>(); SqlFilter filter = new SqlFilter(); var comparison = filterCondition.Comparison; filter.Name = field; if (valueObject is JValue) { JValue jValue = valueObject as JValue; object jValueObject = jValue.Value; switch (jValue.Type) { case JTokenType.Integer: jValueObject = Convert.ToInt32(jValueObject); break; case JTokenType.Float: jValueObject = Convert.ToDecimal(jValueObject); break; case JTokenType.String: jValueObject = Convert.ToString(jValueObject); break; case JTokenType.Boolean: jValueObject = Convert.ToBoolean(jValueObject); break; case JTokenType.Date: jValueObject = Convert.ToDateTime(jValueObject); break; default: throw new NotSupportedException("未支持的JTokenType" + jValue.Type); } filter.Value = jValueObject; switch (comparison) { case Comparison.Eq: filter.Operation = Operation.Equal; break; case Comparison.Gt: filter.Operation = Operation.GreaterThan; break; case Comparison.Lt: filter.Operation = Operation.LessThan; break; } if (jValueObject is string) { filter.Operation = Operation.Like; } } else if (valueObject is JArray) { filter.Operation = Operation.List; JArray source = valueObject as JArray; List<int> values = new List<int>(); source.ToList<JToken>().ForEach(delegate(JToken x) { values.Add(x.Value<int>()); }); filter.Value = values; } return filter; }
/// <summary> /// Adds a condition /// </summary> /// <param name="attributeName"></param> /// <param name="comparisonOperator"></param> /// <param name="values"></param> protected void AddCondition(string attributeName, ComparisonOperator comparisonOperator, List<DynamoDBEntry> values) { Conditions[attributeName] = new FilterCondition(comparisonOperator, values); }