public void Test_Empty() { var sc = new SearchCondition<object>(); Assert.AreEqual(0, sc.Values.Length); Assert.AreEqual(SearchConditionTest.None, sc.Test); Assert.IsTrue(sc.IsEmpty); }
public int GetCount(SearchCondition sc) { if (!string.IsNullOrEmpty(sc.flag)) { switch (sc.flag) { case "member": return GetCountByM(sc); case "member_track": return GetCountByTrack(sc); case "member_contact": return GetCountByContact(sc); case "member_introducer": return GetCountByIntroducer(sc); case "es_fina_pay": return GetCountByEFP(sc); default: return -1; } } else { return -1; } }
public HttpResponseMessage getme(SearchCondition model) { int em = 0; DAL.Implement.MemberDal.SearchCondition sc = new MemberDal.SearchCondition(); sc.address = model.address; sc.aftersales = model.aftersales; sc.city = model.city; sc.classx = model.classx; sc.country = model.country; sc.field = model.field; sc.flag = model.flag; sc.keyword = model.keyword; sc.memo = model.memo; sc.province = model.province; sc.size = model.size < 30 ? model.size : 30; sc.start = model.start; sc.tracktype = model.tracktype; string[] kstr = model.keyword.ToString().Split(','); sc.keywords = kstr; string str = "[]"; if (ValidateSign(Regex.Replace(model.keyword, ",", string.Empty), model.flag, model.field, Convert.ToDateTime(model.timestamp), model.sign)) { str = _dal.GetList(sc, out em).Replace("\r", string.Empty).Replace("\n", string.Empty); } //str = _dal.GetList(sc, out em).Replace("\r", string.Empty).Replace("\n", string.Empty); //string str = _dal.GetList(sc, out em); HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json") }; return result; }
public HttpResponseMessage GetCount(SearchCondition sc) { int count = 0; switch (sc.pattern) { case "0": TXLDal.SearchCondition tsc = new TXLDal.SearchCondition(); tsc.keyword = sc.keyword; tsc.size = sc.size; tsc.start = sc.start; tsc.status = sc.status; tsc.d = sc.d; tsc.dm = sc.dm; tsc.e = sc.e; tsc.i = sc.i; tsc.p = sc.p; tsc.r = sc.r; tsc.eid = sc.eid; tsc.pn = sc.pn; tsc.depid = sc.depid; count = _dal.GetCount(tsc); break; //case "1": // count = _dal.GetCount(sc.id); // break; default: count = _dal.GetCount(sc.keyword, sc.field, sc.start, sc.size) ; break; } HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(count.ToString(), Encoding.GetEncoding("UTF-8"), "application/json") }; return result; }
public HttpResponseMessage Get(SearchCondition sc) { string json = "[]"; switch (sc.pattern) { case "0": TXLDal.SearchCondition tsc = new TXLDal.SearchCondition(); tsc.keyword = sc.keyword; tsc.size = sc.size; tsc.start = sc.start; tsc.status = sc.status; tsc.d = sc.d; tsc.e = sc.e; tsc.dm = sc.dm; tsc.i = sc.i; tsc.p = sc.p; tsc.r = sc.r; tsc.eid = sc.eid; tsc.pn = sc.pn; tsc.depid = sc.depid; json = _dal.Get(tsc).Replace("\r", string.Empty).Replace("\n", string.Empty); break; //case "1": // json = _dal.Get(sc.id).Replace("\r", string.Empty).Replace("\n", string.Empty); // break; default: json = _dal.Get(sc.keyword, sc.field, sc.start, sc.size).Replace("\r", string.Empty).Replace("\n", string.Empty); break; } HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(json, Encoding.GetEncoding("UTF-8"), "application/json") }; return result; }
private static SelectStatement CreateSelectFromLevelQuery(IEntity rootEntity, DbRelation recursiveRelation, SearchCondition leafFilter, int level, LevelQuerySelectList itemsToSelect) { if (level > Settings.GenericHierarchicalQueryExecutorMaxLevel) throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, Messages.GenericHierarchicalQueryExecutor_MaxLevelReachedFormat, Settings.GenericHierarchicalQueryExecutorMaxLevel)); // Target level table must be child table because that is the table which is used in leafFilter. // If leaf filter is used then the we must ensure that proper table name is used for target table. IDbTable targetLevelTable; if (leafFilter != null && !leafFilter.IsEmpty) targetLevelTable = recursiveRelation.Child; else targetLevelTable = rootEntity.Table.Clone("L" + level); SelectStatement selectFromTargetLevel = new SelectStatement(targetLevelTable); CreateSelectListItems(itemsToSelect, targetLevelTable, selectFromTargetLevel); if (leafFilter != null && !leafFilter.IsEmpty) selectFromTargetLevel.Where.Add(leafFilter); IDbTable prevLevel = targetLevelTable; for (int parentLevel = level - 1; parentLevel >= 0; parentLevel--) { IDbTable nextLevel = rootEntity.Table.Clone("L" + parentLevel); DbRelation joinLevels = JoinLevelsInSubTree(prevLevel, nextLevel, recursiveRelation); selectFromTargetLevel.Relations.Add(joinLevels, false, false); prevLevel = nextLevel; } IDbTable subTreeRoot = prevLevel; foreach (IDbColumn rootPkPart in subTreeRoot.PrimaryKey) selectFromTargetLevel.Where.Add(rootPkPart, rootEntity.GetField(rootPkPart)); return selectFromTargetLevel; }
public override SearchCondition GetParsingTree() { // *** TODO Value.AddLeadingWhitespace(); var sc = new SearchCondition(); sc.Stack.AddLast(Value); return sc; }
private static void AppendWhere(SearchCondition where, DbmsType dbms, StringBuilder output, DbParameterCollection parameters) { bool hasFilter = (where != null) && !where.IsEmpty; if (hasFilter) { output.Append(" WHERE "); where.Render(dbms, output, parameters); } }
public static WhereClause Create(SearchCondition sc) { var wh = new WhereClause(); wh.Stack.AddLast(Keyword.Create("WHERE")); wh.Stack.AddLast(Whitespace.Create()); wh.Stack.AddLast(sc); return wh; }
public static SearchConditionBrackets Create(SearchCondition sc) { var scb = new SearchConditionBrackets(); scb.Stack.AddLast(new BracketOpen()); scb.Stack.AddLast(sc); scb.Stack.AddLast(new BracketClose()); return scb; }
public static SearchCriteria AddCriteria(this SearchCriteria searchCriteria, string field, SearchCondition condition, string comparisonValue, bool? isNumeric = null) { if (searchCriteria.Criteria == null) { searchCriteria.Criteria = new List<Criteria>(); } searchCriteria.Criteria.Add(new Criteria { ComparisonValue = comparisonValue, Condition = condition, Field = field, IsNumeric = isNumeric}); return searchCriteria; }
public DataTable getDataTable(PaginationObj paginationObj, int schoolId, SearchCondition condition) { string sql = "select pr.id,pr.student_id,old_table.name,old_table.grade,old_table.sex, " + @" pr.red,pr.blue,pr.green,pr.yellow,rc.cn_name,pr.update_at,pr.print_count " + @" from pts_result pr " + @" inner join inside_student old_table on pr.student_id = old_table.id " + @" inner join result_const rc on pr.color = rc.color " + @" where old_table.school = " + schoolId + SearchCondictionStr.getString(condition); return BaseDao.getTableInfo(sql); }
public static string getString(SearchCondition condition) { string temp = " "; string upadateAt = ""; if (!String.IsNullOrWhiteSpace(condition.State)) { string state = " and old_table.state=" + condition.State; temp += state; } if (!String.IsNullOrWhiteSpace(condition.Name)) { string name = " and old_table.name like '%" + condition.Name + "%' "; temp += name; } if (!String.IsNullOrWhiteSpace(condition.Grade)) { string grade = " and old_table.grade= " + condition.Grade; temp += grade; } if (!String.IsNullOrWhiteSpace(condition.Sex)) { string sex = " and old_table.sex=" + condition.Sex; temp += sex; } if (!String.IsNullOrWhiteSpace(condition.TimeBegin) && !String.IsNullOrWhiteSpace(condition.TimeEnd)) { upadateAt = " and CONVERT(VARCHAR(10),old_table.update_at,120) between '" + condition.TimeBegin + "' and '" + condition.TimeEnd + "' "; } else if (!String.IsNullOrWhiteSpace(condition.TimeBegin)) { upadateAt = " and CONVERT(VARCHAR(10),old_table.update_at,120)='" + condition.TimeBegin + "' "; } else if (!String.IsNullOrWhiteSpace(condition.TimeEnd)) { upadateAt = " and CONVERT(VARCHAR(10),old_table.update_at,120)='" + condition.TimeEnd + "' "; } else { } temp += upadateAt; return temp; }
public void AppendCondition(SearchCondition sc, string opstring) { var cond = this.FindDescendant<SearchCondition>(); this.Stack.Remove(cond); SearchConditionBrackets br1 = SearchConditionBrackets.Create(sc); SearchConditionBrackets br2 = SearchConditionBrackets.Create(cond); var op = LogicalOperator.Create(opstring); cond = SearchCondition.Create(br1, op, SearchCondition.Create(false, br2)); this.Stack.AddLast(cond); }
public ObjectSearchResults FindObjectsByClass(string className) { var vault = this.VaultService.Vault.Value; int classId = GetClassId(className); /* find all files with the specified class */ var searchCondition = new SearchCondition(); searchCondition.ConditionType = MFConditionType.MFConditionTypeEqual; searchCondition.Expression.DataPropertyValuePropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass; searchCondition.TypedValue.SetValue(MFDataType.MFDatatypeLookup, classId); return Find(searchCondition); }
public ObjectSearchResults FindObjectsByObjectType(string objectType) { var vault = this.VaultService.Vault.Value; int objectTypeId = GetObjectTypeId(objectType); /* find all files with the specified object type */ var searchCondition = new SearchCondition(); searchCondition.ConditionType = MFConditionType.MFConditionTypeEqual; searchCondition.Expression.DataStatusValueType = MFStatusType.MFStatusTypeObjectTypeID; searchCondition.TypedValue.SetValue(MFDataType.MFDatatypeLookup, objectTypeId); return Find(searchCondition); }
public static string buildPaginationString(string tableName, PaginationObj paginationObj, int schoolId, SearchCondition condition) { return "select * from " + " (select old_table.*, ROW_NUMBER() over(order by update_at) as row_num from " + tableName + " old_table " + " where old_table.school=" + schoolId + SearchCondictionStr.getString(condition) + " ) new_table " + " where new_table.row_num between " + ((paginationObj.PageNum - 1) * paginationObj.NumPerPage + 1) + " and " + paginationObj.PageNum * paginationObj.NumPerPage; }
protected void DoContinue(object sender, EventArgs e) { this.TimeCondition = new SearchCondition() { TimeFrom = this.timeFrom.Value, TimeTo = this.timeTo.Value }; this.views.ActiveViewIndex = 1; WhereSqlClauseBuilder where = ConditionMapping.GetWhereSqlClauseBuilder(this.TimeCondition); string[] ids = TimeRangeDataSource.QueryGuidsByCondition(where); this.postVal.Value = MCS.Web.Library.Script.JSONSerializerExecute.Serialize(ids); this.lblCount.InnerText = ids.Length.ToString("#,##0"); this.btnRecalc.Visible = ids.Length > 0; //this.grid.InitialData = new TimeRangeDataSource().Query(0, 0, builder, "CREATE_TIME", ref total); }
public static string GetString(SearchCondition aSearchCondition) { string lRet = ""; switch (aSearchCondition) { case SearchCondition.KNULL: lRet = ""; break; case SearchCondition.AND: lRet = "与"; break; case SearchCondition.OR: lRet = "或"; break; } return lRet; }
public void Test_Clone() { var sc = new SearchCondition<object>(); var x = new object(); var y = new object(); sc.Between(x, y); sc.SortDesc(3); var copy = (SearchCondition<object>)sc.Clone(); Assert.AreEqual(sc.Test, copy.Test); Assert.AreEqual(sc.Values.Length, copy.Values.Length); Assert.AreEqual(sc.Values[0], copy.Values[0]); Assert.AreEqual(sc.Values[1], copy.Values[1]); Assert.AreEqual(sc.SortDirection, copy.SortDirection); Assert.AreEqual(sc.SortPosition, copy.SortPosition); Assert.IsFalse(ReferenceEquals(sc.Values, copy.Values)); }
/// <summary> /// Searches metadata in document /// </summary> public static void SearchMetadata(string filePath, string propertyName, SearchCondition searchCondition) { try { //ExStart:DocumentSearchAPI filePath = Common.MapSourceFilePath(filePath); MetadataPropertyCollection properties = SearchFacade.ScanDocument(filePath, propertyName, searchCondition); foreach (MetadataProperty property in properties) { Console.WriteLine("{0} : {1}", property.Name, property.Value); } //ExEnd:DocumentSearchAPI } catch (Exception exp) { Console.WriteLine("Exception occurred: " + exp.Message); } }
public HttpResponseMessage Get(SearchCondition sc) { CommProductDal.SearchCondition csc = new CommProductDal.SearchCondition(); string[] kstr = { }; if (!string.IsNullOrEmpty(sc.keywords)) { kstr = sc.keywords.ToString().Split(','); } if (!string.IsNullOrEmpty(sc.typenames)) { string[] tstr = sc.typenames.ToString().Split(','); csc.typenames = tstr; } csc.keywords = kstr; csc.size = sc.size; csc.start = sc.start; string json = _dal.Get(csc); HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(json, Encoding.GetEncoding("UTF-8"), "application/json") }; return result; }
public static Search SimpleSearch(string property, SearchCondition op, string value) { IList<SearchCriteria> criterias = new List<SearchCriteria> { new SearchCriteria { Combinator = SearchCombinator.And, Criteria = new List<Criteria> { new Criteria { Field = property, Condition = op, ComparisonValue = value, }, } } }; var search = new Search { SearchFields = new SearchFields { Combinator = SearchCombinator.And, Criterias = criterias }, SearchOptions = new SearchOptions() }; return search; }
public HttpResponseMessage getCount(SearchCondition model) { DAL.Implement.MemberDal.SearchCondition sc = new MemberDal.SearchCondition(); sc.address = model.address; sc.aftersales = model.aftersales; sc.city = model.city; sc.classx = model.classx; sc.country = model.country; sc.field = model.field; sc.flag = model.flag; sc.keyword = model.keyword; sc.memo = model.memo; sc.province = model.province; sc.tracktype = model.tracktype; int str = 0; if (ValidateSign(model.keyword, model.flag, model.field,Convert.ToDateTime(model.timestamp),model.sign)) { str = _dal.GetCount(sc); } //int str = _dal.GetCount(sc); HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(str.ToString(), Encoding.GetEncoding("UTF-8"), "application/json") }; return result; }
protected override List <ServerSwitchRecord> GetingItems(ParkDataContext parking, SearchCondition search) { if (search is ServerSwitchRecordSearchCondition) { ServerSwitchRecordSearchCondition condition = search as ServerSwitchRecordSearchCondition; IQueryable <ServerSwitchRecord> result = parking.ServerSwitchRecord; if (condition.ParkID > 0) { result = result.Where(s => s.ParkID == condition.ParkID); } if (condition.RecordDateTimeRange != null) { result = result.Where(s => s.SwitchDateTime >= condition.RecordDateTimeRange.Begin); result = result.Where(s => s.SwitchDateTime <= condition.RecordDateTimeRange.End); } if (condition.SMSStatus.HasValue) { result = result.Where(s => s.SMSStatus == condition.SMSStatus.Value); } return(result.ToList()); } return(new List <ServerSwitchRecord>()); }
/// <summary> /// 构建Solr检索选项,派生类可根据需要进行重写 /// </summary> /// <param name="condition"></param> /// <returns></returns> protected virtual QueryOptions BuildQueryOptions(SearchCondition condition) { QueryOptions queryOptions = new QueryOptions(); #region 搜索关键字 if (String.IsNullOrEmpty(condition.KeyWord)) { condition.KeyWord = "*:*"; } #endregion 搜索关键字 #region 分页信息 if (condition.PagingInfo == null) { condition.PagingInfo = new PagingInfo() { PageSize = 24, PageNumber = 1 }; } queryOptions.Rows = condition.PagingInfo.PageSize >= 0 ? condition.PagingInfo.PageSize : 24; queryOptions.Start = condition.PagingInfo.PageNumber > 1 ? queryOptions.Rows * (condition.PagingInfo.PageNumber - 1) : 0; #endregion 分页信息 #region 排序信息 if (condition.SortItems != null && condition.SortItems.Count > 0) { List <SortOrder> sortList = new List <SortOrder>(); foreach (SortItem sortItem in condition.SortItems) { if (sortItem.SortType == SortOrderType.ASC) { SortOrder sortOrder = new SortOrder(sortItem.SortKey, Order.ASC); sortList.Add(sortOrder); } else { SortOrder sortOrder = new SortOrder(sortItem.SortKey, Order.DESC); sortList.Add(sortOrder); } } queryOptions.OrderBy = sortList.ToArray(); } #endregion 排序信息 #region 一般过滤条件 if (condition.Filters != null && condition.Filters.Count > 0) { foreach (FilterBase filter in condition.Filters) { if (filter is RangeFilter) { RangeFilter rf = filter as RangeFilter; if (!string.IsNullOrWhiteSpace(rf.From) || !string.IsNullOrWhiteSpace(rf.To)) { queryOptions.FilterQueries.Add(new SolrQueryByRange <string>(rf.Field, rf.From, rf.To, rf.Inclusive, rf.Inclusive)); } } else if (filter is FieldFilter) { FieldFilter ff = filter as FieldFilter; if (!string.IsNullOrWhiteSpace(ff.Value)) { queryOptions.FilterQueries.Add(new SolrQueryByField(ff.Field, ff.Value)); } } } } #endregion 一般过滤条件 #region 杂过滤条件计算 AbstractSolrQuery expressiongResult = ComputerExpression(condition.FilterExpression); if (expressiongResult != null) { queryOptions.FilterQueries.Add(expressiongResult); } #endregion 杂过滤条件计算 return(queryOptions); }
/// <summary> /// Adds a property value search condition to the collection. /// </summary> /// <param name="searchBuilder">The <see cref="MFSearchBuilder"/> to add the condition to.</param> /// <param name="propertyDef">The property to search by.</param> /// <param name="dataType">The data type of the property definition (not checked).</param> /// <param name="value">The value to search for.</param> /// <param name="conditionType">What type of search to execute.</param> /// <param name="parentChildBehavior">Whether to accept matches to parent/child values as well.</param> /// <param name="dataFunctionCall">An expression for modifying how the results of matches are evaluated.</param> /// <param name="indirectionLevels">The indirection levels (from the search object) to access the property to match.</param> /// <returns></returns> private static MFSearchBuilder AddPropertyValueSearchCondition ( this MFSearchBuilder searchBuilder, int propertyDef, MFDataType dataType, object value, MFConditionType conditionType, MFParentChildBehavior parentChildBehavior = MFParentChildBehavior.MFParentChildBehaviorNone, PropertyDefOrObjectTypes indirectionLevels = null, DataFunctionCall dataFunctionCall = null ) { // Sanity. if (null == searchBuilder) { throw new ArgumentNullException(nameof(searchBuilder)); } // Create the search condition. var searchCondition = new SearchCondition { ConditionType = conditionType }; // Set up the property value expression. searchCondition.Expression.SetPropertyValueExpression ( propertyDef, parentChildBehavior, dataFunctionCall ); // If we have any indirection levels then use them. if (null != indirectionLevels) { // If any indirection level points at a value list then it will except. // Show a nicer error message here. foreach (PropertyDefOrObjectType indirectionLevel in indirectionLevels) { var objectTypeId = indirectionLevel.ID; if (indirectionLevel.PropertyDef) { // If it's a property def then find the object type. PropertyDef indirectionLevelPropertyDef; try { indirectionLevelPropertyDef = searchBuilder .Vault .PropertyDefOperations .GetPropertyDef(indirectionLevel.ID); } catch { indirectionLevelPropertyDef = null; } // Does it exist? if (null == indirectionLevelPropertyDef) { throw new ArgumentException($"An indirection level references a property definition with ID {indirectionLevel.ID}, but this property definition could not be found.", nameof(indirectionLevel)); } // Is it a list-based one? if (false == indirectionLevelPropertyDef.BasedOnValueList) { throw new ArgumentException($"The indirection level for property {indirectionLevel.ID} does not reference a lookup-style property definition.", nameof(indirectionLevel)); } // Record the object type id. objectTypeId = indirectionLevelPropertyDef.ValueList; } // Is it an object type (fine) or a value list (not fine)? { ObjType indirectionLevelObjectType; try { indirectionLevelObjectType = searchBuilder .Vault .ValueListOperations .GetValueList(objectTypeId); } catch { indirectionLevelObjectType = null; } // Does it exist? if (null == indirectionLevelObjectType) { throw new ArgumentException($"An indirection level references a value list with ID {objectTypeId}, but this value list could not be found.", nameof(indirectionLevel)); } // If it's not a real object type then throw. if (false == indirectionLevelObjectType.RealObjectType) { throw new ArgumentException($"An indirection level references an value list with ID {objectTypeId}, but this list does not refer to an object type (cannot be used with value lists).", nameof(indirectionLevel)); } } } // Set the indirection levels. searchCondition.Expression.IndirectionLevels = indirectionLevels; } // Was the value null? if (null == value) { searchCondition.TypedValue.SetValueToNULL(dataType); } else { searchCondition.TypedValue.SetValue(dataType, value); } // Add the search condition to the collection. searchBuilder.Conditions.Add(-1, searchCondition); // Return the search builder for chaining. return(searchBuilder); }
public void Issue_49() { using (var client = GetClient <ImapClient>()) { var msg = client.SearchMessages(SearchCondition.Subject("aenetmail").And(SearchCondition.Subject("#49"))).Select(x => x.Value).FirstOrDefault(); msg.ShouldBe(); msg.AlternateViews.FirstOrDefault(x => x.ContentType.Contains("html")).Body.ShouldBe(); } }
public override void DoLoginedHandlerWork(HttpContext context) { Message jsonMessage; jsonMessage = new Message() { Result = false, TxtMessage = "权限验证失败,可能原因:\n1、数据中心通讯失败。\n2、系统管理员未与您分配对应操作权限。" }; //获取操作类型AType:ADD,EDIT,DELETE string AjaxType = context.Request.QueryString["AType"] == null ? string.Empty : context.Request.QueryString["AType"].ToString().ToUpper(); View_ValveControl Info; WCFServiceProxy <IValveControl> proxy = null; WCFServiceProxy <IMeterManage> proxyMeter = null; try { switch (AjaxType) { case "QUERY": CommonSearch <View_ValveControl> InfoSearch = new CommonSearch <View_ValveControl>(); string Where = "1=1 "; Where += "AND CompanyID='" + loginOperator.CompanyID + "' "; if (context.Request.Form["TWhere"] != null && context.Request.Form["TWhere"].ToString().Trim() != string.Empty) { Where += context.Request.Form["TWhere"].ToString(); } SearchCondition sCondition = new SearchCondition() { TBName = "View_ValveControl", TFieldKey = "UserID", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = "RegisterDate Desc", TWhere = Where }; List <View_ValveControl> list = InfoSearch.GetList(ref sCondition, context); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <View_ValveControl>(list, sCondition.TTotalCount) }; break; //开阀 case "KAIFA": if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "fmcz_kf")) { proxyMeter = new WCFServiceProxy <IMeterManage>(); proxy = new WCFServiceProxy <IValveControl>(); string reason = ""; if (context.Request.Form["Reason"] != null && context.Request.Form["Reason"].ToString().Trim() != string.Empty) { reason = context.Request.Form["Reason"].ToString().Trim(); } if (context.Request.Form["strNo"] != null && context.Request.Form["strNo"].ToString().Trim() != string.Empty) { string strNo = context.Request.Form["strNo"]; string[] arrNo = strNo.Split(','); for (int i = 0; i < arrNo.Length; i++) { IoT_Meter meter = proxyMeter.getChannel.GetMeterByNo(arrNo[i]); proxy.getChannel.TurnOn(meter, reason, loginOperator.Name); } } jsonMessage = new Message() { Result = true, TxtMessage = "操作成功" }; } break; //关阀 case "GUANFA": if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "fmcz_gf")) { proxyMeter = new WCFServiceProxy <IMeterManage>(); proxy = new WCFServiceProxy <IValveControl>(); string reason = ""; if (context.Request.Form["Reason"] != null && context.Request.Form["Reason"].ToString().Trim() != string.Empty) { reason = context.Request.Form["Reason"].ToString().Trim(); } if (context.Request.Form["strNo"] != null && context.Request.Form["strNo"].ToString().Trim() != string.Empty) { string strNo = context.Request.Form["strNo"]; string[] arrNo = strNo.Split(','); for (int i = 0; i < arrNo.Length; i++) { IoT_Meter meter = proxyMeter.getChannel.GetMeterByNo(arrNo[i]); proxy.getChannel.TurnOff(meter, reason, loginOperator.Name); } } jsonMessage = new Message() { Result = true, TxtMessage = "操作成功" }; } break; case "UNDO": if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "fmcz_cx")) { Info = new CommonModelFactory <View_ValveControl>().GetModelFromContext(context); proxy = new WCFServiceProxy <IValveControl>(); proxy.getChannel.Undo(Info.TaskID, Info.Context); jsonMessage = new Message() { Result = true, TxtMessage = "操作成功" }; } break; default: jsonMessage = new Message() { Result = false, TxtMessage = "操作未定义。" }; break; } } catch (Exception ex) { jsonMessage = new Message() { Result = false, TxtMessage = ex.Message }; } finally { if (proxy != null) { proxy.CloseChannel(); } } context.Response.Write(JSon.TToJson <Message>(jsonMessage)); }
protected override List <Product> GetingItems(System.Data.Linq.DataContext dc, SearchCondition search) { DataLoadOptions opt = new DataLoadOptions(); opt.LoadWith <Product>(p => p.Category); dc.LoadOptions = opt; IQueryable <Product> ret = dc.GetTable <Product>(); if (search is ProductSearchCondition) { ProductSearchCondition con = search as ProductSearchCondition; if (con.ProductIDS != null && con.ProductIDS.Count > 0) { ret = ret.Where(item => con.ProductIDS.Contains(item.ID)); } if (!string.IsNullOrEmpty(con.Name)) { ret = ret.Where(item => item.Name.Contains(con.Name)); } if (!string.IsNullOrEmpty(con.BarCode)) { ret = ret.Where(item => item.BarCode.Contains(con.BarCode)); } if (!string.IsNullOrEmpty(con.CategoryID)) { ret = ret.Where(item => item.CategoryID == con.CategoryID); } if (!string.IsNullOrEmpty(con.Specification)) { ret = ret.Where(item => item.Specification.Contains(con.Specification)); } } return(ret.ToList()); }
protected virtual List <TInfo> GetingItems(DataContext dc, SearchCondition search) { //如果要实现这个功能,子类一定要重写这个方法 return(dc.GetTable <TInfo>().ToList()); }
public static DataTable ExecuteDataTable(this SQLHelper sqlHelper, string sql, SearchCondition cnd) { SearchCondition authCnd = FormulaHelper.CreateAuthDataFilter(); #region 处理@参数 List <SqlParameter> pList = new List <SqlParameter>(); for (int i = authCnd.Items.Count - 1; i >= 0; i--) { var item = authCnd.Items[i]; if (item.Field.StartsWith("@")) { authCnd.Items.RemoveAt(i); pList.Add(new SqlParameter(item.Field, item.Value)); } } for (int i = cnd.Items.Count - 1; i >= 0; i--) { var item = cnd.Items[i]; if (item.Field.StartsWith("@")) { cnd.Items.RemoveAt(i); pList.Add(new SqlParameter(item.Field, item.Value)); } } #endregion string orderby = ""; int index = sql.LastIndexOf("order by", StringComparison.CurrentCultureIgnoreCase); if (index > 0) { orderby = sql.Substring(index); sql = sql.Substring(0, index); } if (authCnd.Items.Count > 0) { sql = string.Format("select * from ({0}) sourceTable1 {1}", sql, authCnd.GetWhereString()); } sql = string.Format("select * from ({0}) sourceTable {1} {2}", sql, cnd.GetWhereString(), orderby); DataTable dt = sqlHelper.ExecuteDataTable(sql, pList.ToArray(), CommandType.Text); return(dt); }
/// <summary> /// 转换Solr返回的检索文档,需要派生类进行实现 /// </summary> /// <param name="solrQueryResult">Solr检索返回的文档结果</param> /// <param name="condition">查询条件</param> /// <returns>对外返回查询结果数据</returns> protected abstract Result TransformSolrQueryResult(ISolrQueryResults <Record> solrQueryResult, SearchCondition condition);
public override void DoLoginedHandlerWork(HttpContext context) { Message jsonMessage; jsonMessage = new Message() { Result = false, TxtMessage = "权限验证失败,可能原因:\n1、数据中心通讯失败。\n2、系统管理员未与您分配对应操作权限。" }; //获取操作类型AType:ADD,EDIT,DELETE string AjaxType = context.Request.QueryString["AType"] == null ? string.Empty : context.Request.QueryString["AType"].ToString().ToUpper(); IoT_Street Info; WCFServiceProxy <IStreetManage> proxy = null; try { switch (AjaxType) { case "QUERY": CommonSearch <IoT_Street> InfoSearch = new CommonSearch <IoT_Street>(); string Where = "1=1 "; Where += "AND CompanyID='" + loginOperator.CompanyID + "' "; if (context.Request.Form["TWhere"] != null && context.Request.Form["TWhere"].ToString().Trim() != string.Empty) { Where += context.Request.Form["TWhere"].ToString(); } SearchCondition sCondition = new SearchCondition() { TBName = "IoT_Street", TFieldKey = "ID", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = "ID ASC", TWhere = Where }; List <IoT_Street> list = InfoSearch.GetList(ref sCondition, context); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <IoT_Street>(list, sCondition.TTotalCount) }; break; case "ADD": if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "jqgl_tjjd")) { Info = new CommonModelFactory <IoT_Street>().GetModelFromContext(context); Info.CompanyID = loginOperator.CompanyID; proxy = new WCFServiceProxy <IStreetManage>(); jsonMessage = proxy.getChannel.Add(Info); } break; case "EDIT": if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "jqgl_bjjd")) { Info = new CommonModelFactory <IoT_Street>().GetModelFromContext(context); proxy = new WCFServiceProxy <IStreetManage>(); jsonMessage = proxy.getChannel.Edit(Info); } break; case "DELETE": if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "jqgl_scjd")) { Info = new CommonModelFactory <IoT_Street>().GetModelFromContext(context); proxy = new WCFServiceProxy <IStreetManage>(); jsonMessage = proxy.getChannel.Delete(Info); } break; default: jsonMessage = new Message() { Result = false, TxtMessage = "操作未定义。" }; break; } } catch (Exception ex) { jsonMessage = new Message() { Result = false, TxtMessage = ex.Message }; } finally { if (proxy != null) { proxy.CloseChannel(); } } context.Response.Write(JSon.TToJson <Message>(jsonMessage)); }
protected abstract QueryResultList <TEntity> GetingItems(SearchCondition search);
/// <summary> /// 删除主子表 /// </summary> /// <param name="keyValue">主键</param> /// <param name="bLogicDelete"></param> public void Delete(string keyValue, bool bLogicDelete) { using (DbTransactionScope <SYS_BarcodeSettingMainInfo> dbtran = base.CreateTransactionScope()) { try { if (bLogicDelete) { //逻辑删除v //UPDATE字段 Hashtable hash = new Hashtable(); hash.Add("字段名", "修改后的值"); this.Update(keyValue, hash, dbtran.Transaction); //UPDATE 对象 SYS_BarcodeSettingMainInfo info = this.FindByID(keyValue, dbtran.Transaction); info.F_DeleteMark = false; info.F_DeleteTime = DateTime.Now; this.Update(info, keyValue, dbtran.Transaction); //获取所有的子表信息 SearchCondition c = new SearchCondition(); c.AddCondition("F_ParentId", keyValue, SqlOperator.Equal); List <SYS_BarcodeSettingDetailInfo> details = SYS_BarcodeSettingDetail.Instance.Find(c.BuildConditionSql()); foreach (SYS_BarcodeSettingDetailInfo d in details) { d.F_DeleteMark = false; d.F_DeleteTime = DateTime.Now; SYS_BarcodeSettingDetail.Instance.Update(d, d.F_Id, dbtran.Transaction); } //sql方式update string sql = "UPDATE Sys_VouchType WHERE F_Id = @F_ParentId"; Hashtable parms = new Hashtable(); parms.Add("F_Id(参数名,不需要@)", keyValue); base.ExecuteNonQuery(sql, parms, dbtran.Transaction); sql = "UPDATE SYS_BarcodeSettingDetail WHERE F_VouchId = @F_ParentId"; base.ExecuteNonQuery(sql, parms, dbtran.Transaction); } else { //物理删除 //删除 SYS_BarcodeSettingDetail SearchCondition condition = new SearchCondition(); condition.AddCondition("F_ParentId", keyValue, SqlOperator.Equal); SYS_BarcodeSettingDetail.Instance.DeleteByCondition(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty), dbtran.Transaction); //删除 SYS_BarcodeSettingMain this.Delete(keyValue, dbtran.Transaction); } dbtran.Commit(); } catch (Exception e) { dbtran.RollBack(); throw e; } } }
public OrderDateCleanUp(SearchCondition sc) { _sc = sc; }
/// <summary> ///审核单据 /// </summary> /// <param name="date">审核日期</param> /// <param name="Id">审核单据</param> /// <param name="user">审核人</param> public string Audit(string date, string user, string Id, List <PI_BodyInfo> stockinfo) { using (DbTransactionScope <PI_HeadInfo> dbtran = base.CreateTransactionScope()) { try { SearchCondition condition = new SearchCondition(); condition.AddCondition("F_Id", Id, SqlOperator.Equal); PI_HeadInfo head = PI_Head.Instance.FindSingle(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty), dbtran.Transaction); if (head.F_Status == 1) { return("单据已被审核"); } else { Hashtable hash = new Hashtable(); hash.Add("F_Status", 1); hash.Add("F_VeriDate", date); hash.Add("F_Verify", user); PI_Head.Instance.Update(Id, hash, dbtran.Transaction); dbtran.Commit(); return("单据审核成功"); #region 审核后入库 //using (DbTransactionScope<PI_HeadInfo> dbtran = base.CreateTransactionScope()) //{ // try // { // //查询所有库存信息 // List<Sys_StockInfo> stockList = BLLFactory<Sys_Stock>.Instance.GetAll(); // //查询主表信息 // PI_HeadInfo hinfo = BLLFactory<PI_Head>.Instance.FindByID(Id); // foreach (PI_BodyInfo item in stockinfo) // { // //判断是否入库 // PI_BodyInfo binfo = BLLFactory<PI_Body>.Instance.FindByID(item.F_Id); // if (binfo.F_AlreadyOperatedNum == "") // { // binfo.F_AlreadyOperatedNum = "0"; // } // if (int.Parse(binfo.F_AlreadyOperatedNum) > 0) // { // return "该单据已入库,不能重复执行入库操作"; // } // if (binfo.F_WarehouseId==""||binfo.F_CargoPositionId=="") // { // return "该单据中仓库或仓位为空,审核未通过"; // } // Sys_StockInfo stock = stockList.Find(u => u.F_WarehouseId == binfo.F_WarehouseId && u.F_CargoPositionId == binfo.F_CargoPositionId && u.F_GoodsId == binfo.F_GoodsId&&u.F_Batch==binfo.F_SerialNum); // if (stock == null) // { // item.IsHave = false; // } // else // { // item.IsHave = true; // item.StockID = stock.F_Id; // item.StockNumber = stock.F_Number; // } // //查询库存表是否存在该仓库中的产品 // //没有 // if (!item.IsHave) // { // //新添加一条数据 库存表 // Sys_StockInfo entity = new Sys_StockInfo(); // entity.F_Id = Guid.NewGuid().ToString(); // entity.F_CargoPositionId = item.F_CargoPositionId; // entity.F_CargoPositionName = item.F_CargoPositionName; // entity.F_WarehouseId = item.F_WarehouseId; // entity.F_WarehouseName = item.F_WarehouseName; // entity.F_GoodsName = item.F_FullName; // entity.F_Batch = item.F_SerialNum; // entity.F_GoodsId = item.F_GoodsId; // entity.F_SpecifModel = item.F_SpecifModel; // entity.F_SellingPrice = item.F_SellingPrice; // entity.F_PurchasePrice = item.F_PurchasePrice; // entity.F_Unit = item.F_Unit; // entity.F_Number = item.F_InStockNum; // Sys_Stock.Instance.Insert(entity, dbtran.Transaction); // //更新审核状态 // string sql = string.Format("update PI_Head set F_Status=1,F_VeriDate='{0}',F_Verify='{1}' where F_Id='{2}'", date, user, Id); // Hashtable hash = new Hashtable(); // base.ExecuteNonQuery(sql, hash, dbtran.Transaction); // //添加入库履历 入库履历 // Sys_InRecordsInfo inRec = new Sys_InRecordsInfo(); // inRec.F_Id = Guid.NewGuid().ToString(); // inRec.F_WarehouseId = item.F_WarehouseId; // inRec.F_Vendor = hinfo.F_Vendor; // inRec.F_VendorName = hinfo.F_VendorName; // inRec.F_Contacts = hinfo.F_Contacts; // inRec.F_TelePhone = hinfo.F_TelePhone; // inRec.F_Verify = user; // inRec.F_Maker = hinfo.F_Maker; // inRec.F_VeriDate = DateTime.Now; // inRec.F_EnCode = item.F_OrderNo; // inRec.F_Batch = item.F_SerialNum; // inRec.F_WarehouseName = item.F_WarehouseName; // inRec.F_GoodsName = item.F_FullName; // inRec.F_GoodsId = item.F_GoodsId; // inRec.F_CargoPositionId = item.F_CargoPositionId; // inRec.F_CargoPositionName = item.F_CargoPositionName; // inRec.F_SpecifModel = item.F_SpecifModel; // inRec.F_SellingPrice = item.F_SellingPrice; // inRec.F_PurchasePrice = item.F_PurchasePrice; // inRec.F_Unit = item.F_Unit; // inRec.F_InStockNum = item.F_InStockNum; // inRec.F_CreatorTime = DateTime.Now; // Sys_InRecords.Instance.Insert(inRec, dbtran.Transaction); // //添加 库存履历 // Sys_StockHistoryInfo instock = new Sys_StockHistoryInfo(); // instock.F_Id = Guid.NewGuid().ToString(); // instock.F_WarehouseId = item.F_WarehouseId; // instock.F_Vendor = hinfo.F_Vendor; // instock.F_VendorName = hinfo.F_VendorName; // instock.F_Contacts = hinfo.F_Contacts; // instock.F_TelePhone = hinfo.F_TelePhone; // instock.F_Verify = user; // instock.F_Maker = hinfo.F_Maker; // instock.F_VeriDate = DateTime.Now; // instock.F_EnCode = item.F_OrderNo; // instock.F_Batch = item.F_SerialNum; // instock.F_WarehouseName = item.F_WarehouseName; // instock.F_BllCategory = "入库"; // instock.F_GoodsName = item.F_FullName; // instock.F_GoodsId = item.F_GoodsId; // instock.F_CargoPositionId = item.F_CargoPositionId; // instock.F_CargoPositionName = item.F_CargoPositionName; // instock.F_SpecifModel = item.F_SpecifModel; // instock.F_SellingPrice = item.F_SellingPrice; // instock.F_PurchasePrice = item.F_PurchasePrice; // instock.F_Unit = item.F_Unit; // instock.F_OperationNum = item.F_InStockNum; // instock.F_CreatorTime = DateTime.Now; // Sys_StockHistory.Instance.Insert(instock, dbtran.Transaction); // //更新子表入库状态 // hash = new Hashtable(); // hash.Add("F_AlreadyOperatedNum", 1); // PI_Body.Instance.Update(item.F_Id, hash, dbtran.Transaction); // //更新主表入库状态 // hash = new Hashtable(); // hash.Add("F_State", 1); // PI_Head.Instance.Update(item.F_HId, hash, dbtran.Transaction); // } // else // { // //更新前库存数量 // Hashtable hash = new Hashtable(); // hash.Add("F_Number", item.StockNumber + item.F_InStockNum); // Sys_Stock.Instance.Update(item.StockID, hash, dbtran.Transaction); // for (int i = 0; i < stockinfo.Count; i++) // { // if (stockinfo[i].StockID == item.StockID) // { // stockinfo[i].StockNumber += item.F_InStockNum; // } // } // //更新审核状态 // string sql = string.Format("update PI_Head set F_Status=1,F_VeriDate='{0}',F_Verify='{1}' where F_Id='{2}'", date, user, Id); // hash = new Hashtable(); // base.ExecuteNonQuery(sql, hash, dbtran.Transaction); // //更新子表入库状态 // hash = new Hashtable(); // hash.Add("F_AlreadyOperatedNum", 1); // PI_Body.Instance.Update(item.F_Id, hash, dbtran.Transaction); // //更新主表入库状态 // hash = new Hashtable(); // hash.Add("F_State", 1); // PI_Head.Instance.Update(item.F_HId, hash, dbtran.Transaction); // //添加履历 // Sys_InRecordsInfo inRec = new Sys_InRecordsInfo(); // inRec.F_Id = Guid.NewGuid().ToString(); // inRec.F_WarehouseId = item.F_WarehouseId; // inRec.F_EnCode = item.F_OrderNo; // inRec.F_Batch = item.F_SerialNum; // inRec.F_Vendor = hinfo.F_Vendor; // inRec.F_VendorName = hinfo.F_VendorName; // inRec.F_Contacts = hinfo.F_Contacts; // inRec.F_TelePhone = hinfo.F_TelePhone; // inRec.F_Verify = user; // inRec.F_Maker = hinfo.F_Maker; // inRec.F_VeriDate = DateTime.Now; // inRec.F_WarehouseName = item.F_WarehouseName; // inRec.F_GoodsName = item.F_FullName; // inRec.F_GoodsId = item.F_GoodsId; // inRec.F_CargoPositionId = item.F_CargoPositionId; // inRec.F_CargoPositionName = item.F_CargoPositionName; // inRec.F_SpecifModel = item.F_SpecifModel; // inRec.F_SellingPrice = item.F_SellingPrice; // inRec.F_PurchasePrice = item.F_PurchasePrice; // inRec.F_Unit = item.F_Unit; // inRec.F_InStockNum = item.F_InStockNum; // inRec.F_CreatorTime = DateTime.Now; // Sys_InRecords.Instance.Insert(inRec, dbtran.Transaction); // //添加库存履历 // Sys_StockHistoryInfo instock = new Sys_StockHistoryInfo(); // instock.F_Id = Guid.NewGuid().ToString(); // instock.F_WarehouseId = item.F_WarehouseId; // instock.F_EnCode = item.F_OrderNo; // instock.F_Batch = item.F_SerialNum; // instock.F_Vendor = hinfo.F_Vendor; // instock.F_VendorName = hinfo.F_VendorName; // instock.F_Contacts = hinfo.F_Contacts; // instock.F_TelePhone = hinfo.F_TelePhone; // instock.F_Verify = user; // instock.F_Maker = hinfo.F_Maker; // instock.F_VeriDate = DateTime.Now; // instock.F_WarehouseName = item.F_WarehouseName; // instock.F_BllCategory = "入库"; // instock.F_GoodsName = item.F_FullName; // instock.F_GoodsId = item.F_GoodsId; // instock.F_CargoPositionId = item.F_CargoPositionId; // instock.F_CargoPositionName = item.F_CargoPositionName; // instock.F_SpecifModel = item.F_SpecifModel; // instock.F_SellingPrice = item.F_SellingPrice; // instock.F_PurchasePrice = item.F_PurchasePrice; // instock.F_Unit = item.F_Unit; // instock.F_OperationNum = item.F_InStockNum; // instock.F_CreatorTime = DateTime.Now; // Sys_StockHistory.Instance.Insert(instock, dbtran.Transaction); // } // } // dbtran.Commit(); // return "单据审核成功"; // } // catch (Exception ex) // { // dbtran.RollBack(); // return "操作失败"; // throw ex; // } //} #endregion } } catch (Exception ex) { dbtran.RollBack(); return("操作失败"); throw ex; } } }
public Task <Category> FindItem(SearchCondition condition) { throw new NotImplementedException(); }
public ModifyDataForm(rasterTable ts, DataGridView dg, SearchCondition sc) { InitializeComponent(); this._selecData = ts; InitForm(ts); }
public Task <List <Category> > ListAll(SearchCondition condition, OrderCondition orderitems) { throw new NotImplementedException(); }
protected override List <InventoryCheckRecord> GetingItems(System.Data.Linq.DataContext dc, SearchCondition search) { IQueryable <InventoryCheckRecord> ret = dc.GetTable <InventoryCheckRecord>(); List <InventoryCheckRecord> items = ret.ToList(); return(items); }
public InStockNotice_HeadInfo Save(InStockNotice_HeadInfo info, List <InStockNotice_BodyInfo> BInfo) { using (DbTransactionScope <InStockNotice_HeadInfo> dbtran = base.CreateTransactionScope()) { try { if (string.IsNullOrEmpty(info.F_EnCode)) { string orderNo = "INOT" + DateTime.Now.ToString("yyyyMMdd"); Hashtable hash = new Hashtable(); hash.Add("Prefix", orderNo); DataTable dt = base.StorePorcToDataTable("SYS_GENERATE_SN", hash, null, dbtran.Transaction); string SN = dt.Rows[0][0].ToString(); info.F_EnCode = SN; } else { //判断当前单据是否已经审核 var head = this.FindByID(info.F_Id, dbtran.Transaction); if (head != null && head.F_Status == 1) { throw new ApplicationException("单据已经审核!"); } } info.F_Status = 0; info.F_Verifier = ""; info.F_Veridate = null; //添加主表 InStockNotice_Head.Instance.InsertUpdate(info, info.F_Id, dbtran.Transaction); //删除子表 SearchCondition condition = new SearchCondition(); condition.AddCondition("F_HeadId", info.F_Id, SqlOperator.Equal); InStockNotice_Body.Instance.DeleteByCondition(condition.BuildConditionSql().Replace("Where (1=1) AND ", string.Empty), dbtran.Transaction); //循环添加子表 foreach (InStockNotice_BodyInfo item in BInfo) { item.F_CreatorTime = DateTime.Now; item.F_CreatorUserId = info.F_CreatorUserId; item.F_Id = Guid.NewGuid().ToString(); item.F_HeadId = info.F_Id; string orderNo = "INOTB" + DateTime.Now.ToString("yyyyMMdd"); Hashtable hash = new Hashtable(); hash.Add("Prefix", orderNo); DataTable dt = base.StorePorcToDataTable("SYS_GENERATE_SN", hash, null, dbtran.Transaction); string SN = dt.Rows[0][0].ToString(); item.F_EnCode = SN; //InStockNotice_Body.Instance.Insert(item, dbtran.Transaction); } InStockNotice_Body.Instance.InsertRange(BInfo, dbtran.Transaction); dbtran.Commit(); return(info); } catch (Exception ex) { dbtran.RollBack(); throw ex; } } }
/// <summary> /// 异步根据条件从视图获取DataTable /// </summary> /// <typeparam name="D">BLL类型</typeparam> /// <param name="condition">过滤条件 对象为空时,返回所有集合</param> /// <param name="pager">分页对象 对象为空时,则不分页</param> /// <returns></returns> protected virtual Task <DataTable> FindToDataTableAsync <D>(string viewName, string sortField, bool isDescending = false, SearchCondition condition = null, PagerInfo pager = null) where D : BaseBLL <BaseEntity> { return(Task.Run(() => { DataTable dt = null; if (pager == null) { dt = BLLFactory <D> .Instance.FindByView(viewName, BuilderConditionStr(condition)); } else { dt = BLLFactory <D> .Instance.FindByViewWithPager(viewName, BuilderConditionStr(condition), sortField, isDescending, pager); } return dt; })); }
private void btnSearch_Click(object sender, EventArgs e) { advanceCondition = null;//必须重置查询条件,否则可能会使用高级查询条件了 BindData(); }
public void Search() { using (var imap = GetClient <ImapClient>()) { var result = imap.SearchMessages( //"OR ((UNDELETED) (FROM \"david\") (SENTSINCE \"01-Jan-2000 00:00:00\")) (TO \"andy\")" SearchCondition.Undeleted().And(SearchCondition.From("david"), SearchCondition.SentSince(new DateTime(2000, 1, 1))).Or(SearchCondition.To("andy")) ); result.Length.ShouldBeInRange(1, int.MaxValue); result.First().Value.Subject.ShouldNotBeNullOrEmpty(); result = imap.SearchMessages(new SearchCondition { Field = SearchCondition.Fields.Text, Value = "asdflkjhdlki2uhiluha829hgas" }); result.Length.ShouldBe(0); } }
static SearchCondition GetSearchCondition() { return(SearchCondition.From(readMessagesFilterAccount).And(SearchCondition.Unseen())); }
public static DataTable ExecuteDataTable(this SQLHelper sqlHelper, string sql, BaseQueryBuilder qb, bool dealOrderby = true) { string orderby = ""; if (dealOrderby) { int index = sql.LastIndexOf(" order by", StringComparison.CurrentCultureIgnoreCase); if (index > 0) { orderby = sql.Substring(index + " order by".Length); sql = sql.Substring(0, index); } } SearchCondition authCnd = FormulaHelper.CreateAuthDataFilter(); #region 处理@参数 List <SqlParameter> pList = new List <SqlParameter>(); for (int i = authCnd.Items.Count - 1; i >= 0; i--) { var item = authCnd.Items[i]; if (item.Field.StartsWith("@")) { authCnd.Items.RemoveAt(i); pList.Add(new SqlParameter(item.Field, item.Value)); } } for (int i = qb.Items.Count - 1; i >= 0; i--) { var item = qb.Items[i]; if (item.Field.StartsWith("@")) { qb.Items.RemoveAt(i); pList.Add(new SqlParameter(item.Field, item.Value)); } } #endregion if (authCnd.Items.Count > 0) { sql = string.Format("select * from ({0}) sourceTable1 {1}", sql, authCnd.GetWhereString()); } sql = string.Format("select {2} from ({0}) sourceTable {1}", sql, qb.GetWhereString(), qb.Fields); string[] qbSortFields = qb.SortField.Split(','); string[] qbSortOrders = qb.SortOrder.Split(','); for (int i = 0; i < qbSortFields.Length; i++) { qbSortFields[i] += " " + qbSortOrders[i]; } string qbOrderBy = string.Join(",", qbSortFields); if (orderby == "" || !qb.DefaultSort) { orderby = qbOrderBy; } if (qb.PageSize == 0) { DataTable dt = sqlHelper.ExecuteDataTable(sql + " order by " + orderby, pList.ToArray(), CommandType.Text); qb.TotolCount = dt.Rows.Count; return(dt); } else { object totalCount = sqlHelper.ExecuteScalar(string.Format("select count(1) from ({0}) tableCount", sql), pList.ToArray(), CommandType.Text); qb.TotolCount = Convert.ToInt32(totalCount); int start = qb.PageIndex * qb.PageSize + 1; int end = start + qb.PageSize - 1; sql = string.Format(@"select * from (select tempTable1.*, Row_number() over(order by {1}) as RowNumber from ({0}) tempTable1) tmpTable2 where RowNumber between {2} and {3}", sql, orderby, start, end); return(sqlHelper.ExecuteDataTable(sql, pList.ToArray(), CommandType.Text)); } }
/// <summary> /// 真正的检索方法,需要派生类进行实现 /// </summary> /// <param name="condition">查询条件</param> /// <returns>检索结果</returns> protected override Result GetSearchResult(SearchCondition condition) { ISolrOperations <Record> solr = ServiceLocator.Current.GetInstance <ISolrOperations <Record> >(); return(GetSearchResult(condition, solr)); }
public override void DoLoginedHandlerWork(HttpContext context) { Message jsonMessage; jsonMessage = new Message() { Result = false, TxtMessage = "权限验证失败,可能原因:\n1、数据中心通讯失败。\n2、系统管理员未与您分配对应操作权限。" }; string AjaxType = context.Request.QueryString["AType"] == null ? string.Empty : context.Request.QueryString["AType"].ToString().ToUpper(); //context.Response.Write(AjaxType); //context.Response.End(); ADContext Info = new ADContext(); WCFServiceProxy <IADContextDAL> proxy = null; Info = new CommonModelFactory <ADContext>().GetModelFromContext(context); proxy = new WCFServiceProxy <IADContextDAL>(); try { switch (AjaxType) {//查询用户 case "QUERY": CommonSearch <ADContext> InfoSearch = new CommonSearch <ADContext>(); string Where = "1=1 "; Where += "AND CompanyID='" + loginOperator.CompanyID + "' "; if (context.Request.Form["TWhere"] != null && context.Request.Form["TWhere"].ToString().Trim() != string.Empty) { Where += context.Request.Form["TWhere"].ToString(); } SearchCondition sCondition = new SearchCondition() { TBName = "ADContext", TFieldKey = "AC_ID", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = "AC_ID desc", TWhere = Where }; List <ADContext> list = InfoSearch.GetList(ref sCondition, context); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <ADContext>(list, sCondition.TTotalCount) }; break; //广告主题列表 case "QUERYVIEW": CommonSearch <ADContext> InfoSearchView = new CommonSearch <ADContext>(); Where = "1=1 "; Where += "AND CompanyID='" + loginOperator.CompanyID + "' "; if (context.Request.Form["TWhere"] != null && context.Request.Form["TWhere"].ToString().Trim() != string.Empty) { Where += context.Request.Form["TWhere"].ToString(); } sCondition = new SearchCondition() { TBName = "ADContext", TFieldKey = "AC_ID", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = " AC_ID desc", TWhere = Where }; List <ADContext> listView = InfoSearchView.GetList(ref sCondition, context); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <ADContext>(listView, sCondition.TTotalCount) }; break; //广告主题列表 case "QUERYVIEWLIST": CommonSearch <ADContext> InfoSearchView2 = new CommonSearch <ADContext>(); Where = "1=1 and State != 0 "; Where += "AND CompanyID='" + loginOperator.CompanyID + "' "; if (context.Request.Form["TWhere"] != null && context.Request.Form["TWhere"].ToString().Trim() != string.Empty) { Where += context.Request.Form["TWhere"].ToString(); } sCondition = new SearchCondition() { TBName = "ADContext", TFieldKey = "AC_ID", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = " AC_ID desc", TWhere = Where }; List <ADContext> listView2 = InfoSearchView2.GetList(ref sCondition, context); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <ADContext>(listView2, sCondition.TTotalCount) }; break; //添加主题广告 case "ADD": Info.CompanyID = base.loginOperator.CompanyID; Info.State = 0; Info.CreateDate = DateTime.Now; jsonMessage = proxy.getChannel.Add(Info); break; case "EDIT": Info.CompanyID = base.loginOperator.CompanyID; jsonMessage = proxy.getChannel.Edit(Info); break; //删除信息 case "DELCONTENT": jsonMessage = proxy.getChannel.Delete((int)Info.AC_ID); break; //草稿->可发布 case "UPDATEOK": jsonMessage = proxy.getChannel.UpadteAdStatus(Info.AC_ID, 1); break; //可发布-> 草稿 case "UPDATENO": jsonMessage = proxy.getChannel.UpadteAdStatus(Info.AC_ID, 0); break; default: jsonMessage = new Message() { Result = false, TxtMessage = "1.操作未定义!" + AjaxType }; break; } } catch (Exception ex) { jsonMessage = new Message() { Result = false, TxtMessage = ex.Message }; } finally { if (proxy != null) { proxy.CloseChannel(); } } context.Response.Write(JSon.TToJson <Message>(jsonMessage)); }
void dlg_ConditionChanged(SearchCondition condition) { advanceCondition = condition; BindData(); }
protected static FR_L3ABDA_GAAfAS_1256_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L3ABDA_GAAfAS_1256 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L3ABDA_GAAfAS_1256_Array(); #region Check ABDA Catalog Subscription string catalogITL = EnumUtils.GetEnumDescription(EPublicCatalogs.ABDA); var sbsCatalog = ORM_CMN_PRO_SubscribedCatalog.Query.Search(Connection, Transaction, new ORM_CMN_PRO_SubscribedCatalog.Query() { CatalogCodeITL = catalogITL, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).FirstOrDefault(); if (sbsCatalog == null) { return(returnValue); } #endregion var searchCondition = Parameter.SearchCondition; if (!searchCondition.Contains("*")) { searchCondition = String.Format("*{0}*", searchCondition); } string query = new QueryBuilder <Product>() .From(0) .Size(10000) .Query(q => q .Bool(b => b .Must(m => m .QueryString(qs => qs.Fields( new string[] { SearchCondition.GetFiledName(ProductField.NAME), SearchCondition.GetFiledName(ProductField.CODE) }) .Query(SearchCondition.GetConditionForSearchText(Parameter.SearchCondition))) ) ) ) .Sort(s => s .Field(SearchCondition.GetFiledName(ProductField.NAME), PlainElastic.Net.SortDirection.asc)) .BuildBeautified(); var ProductService = CatalogServiceFactory.GetProductService(); ProductQueryRequest request = new ProductQueryRequest() { CatalogCode = catalogITL }; SearchResult <Product> res = ProductService.QueryProducts(request, query); var retrievedProducts = res.Documents.ToList(); var abdaProducts = new List <L3ABDA_GAAfAS_1256>(); foreach (var product in retrievedProducts) { abdaProducts.Add(new L3ABDA_GAAfAS_1256() { ProductITL = product.ProductITL, ProductNumber = product.Code, ProductName = product.Name }); } returnValue.Result = abdaProducts.ToArray(); return(returnValue); #endregion UserCode }
protected override List <WorkStationInfo> GetingItems(ParkDataContext parking, SearchCondition search) { if (search is WorkstationSearchCondition) { WorkstationSearchCondition con = search as WorkstationSearchCondition; IQueryable <WorkStationInfo> result = parking.WorkStation.AsQueryable(); if (con.DeptID != null) { result = result.Where(w => w.DeptID == con.DeptID); } result = result.OrderBy(w => w.StationID); return(result.ToList()); } else { return(new List <WorkStationInfo>()); } }
/// <summary> /// Performs search and populates the returned raw data into the internal search service dataset. /// </summary> /// <param name="query">Text to search</param> /// <param name="pageIndex">Zero-based page index</param> /// <param name="pageSize">Page size</param> /// <param name="numberOfResults">Total number of search results</param> private void SearchInternal(string query, int pageIndex, int pageSize, out int numberOfResults) { var documentCondition = new DocumentSearchCondition(null, mCultureName, mDefaultCulture, mCombineWithDefaultCulture); var condition = new SearchCondition(documentCondition: documentCondition); var searchExpression = SearchSyntaxHelper.CombineSearchCondition(query, condition); var parameters = new SearchParameters { SearchFor = searchExpression, Path = "/%", ClassNames = null, CurrentCulture = mCultureName, DefaultCulture = mDefaultCulture, CombineWithDefaultCulture = mCombineWithDefaultCulture, CheckPermissions = false, SearchInAttachments = false, User = MembershipContext.AuthenticatedUser, SearchIndexes = mSearchIndexNames.Join(";"), StartingPosition = pageIndex * pageSize, NumberOfResults = 0, NumberOfProcessedResults = 100, DisplayResults = pageSize }; // Search and save results mRawResults = SearchHelper.Search(parameters); numberOfResults = parameters.NumberOfResults; }
public Task <int> Count(SearchCondition conditions) { throw new NotImplementedException(); }
/// <summary> /// ������ƷSearch��� /// </summary> /// <param name="searchCondition">Search Condition</param> /// <param name="componentGroup">�������ƷSearch���</param> public static void Cache(SearchCondition searchCondition, Merchandise componentGroup) { if (Utility.IsSubAgent && searchCondition is TourSearchCondition) CachedSubTours[searchCondition] = componentGroup; else CachedMerchandises[searchCondition] = componentGroup; }
/// <summary> /// ɾ��ָ������ƷSearch��� /// </summary> /// <param name="searchCondition"></param> /// <param name="componentGroup"></param> public static bool Remove(SearchCondition searchCondition, Merchandise componentGroup) { KeyValuePair<SearchCondition, Merchandise> item = new KeyValuePair<SearchCondition, Merchandise>(searchCondition, componentGroup); if (CachedMerchandises.Contains(item)) { CachedMerchandises.Remove(item); return true; } else { return false; } }
/// <summary> /// ɾ��ָ������ƷSearch��� /// </summary> /// <param name="searchCondition"></param> /// <returns></returns> public static bool Remove(SearchCondition searchCondition) { if (CachedMerchandises.Keys.Contains(searchCondition)) { CachedMerchandises.Remove(searchCondition); return true; } else { return false; } }
/// <summary> /// ����Search Condition���һ������ƷSearch��� /// </summary> /// <param name="searchCondition">Search Condition</param> /// <returns>�������ƷSearch���</returns> public static Merchandise FindB2BTour(SearchCondition searchCondition) { Merchandise result = null; if (searchCondition != null) { foreach (SearchCondition key in CachedSubTours.Keys) { if (key.Equals(searchCondition)) { result = CachedSubTours[key]; break; } } } return result; }
private ObjectSearchResults Find(SearchCondition searchCondition) { var vault = this.VaultService.Vault.Value; var searchConditions = new SearchConditions(); searchConditions.Add(-1, searchCondition); var objectSearchResults = vault.ObjectSearchOperations.SearchForObjectsByConditionsEx( searchConditions, MFSearchFlags.MFSearchFlagLookInAllVersions | MFSearchFlags.MFSearchFlagDisableRelevancyRanking, false, MaxResultCount: 100000, SearchTimeoutInSeconds: Int32.MaxValue); return objectSearchResults; }