public static void Run() { //FirstMember TypeFilter filt = new TypeFilter(DbElementTypeInstance.NOZZLE); DbElement nozz1 = filt.FirstMember(Example.Instance.mEqui); DbElementType type = nozz1.GetElementType(); //NextMember DbElement nozz2 = filt.Next(nozz1); //NextMember DbElement[] members = filt.Members(Example.Instance.mEqui); //parent TypeFilter filt2 = new TypeFilter(DbElementTypeInstance.SITE); DbElement site = filt2.Parent(nozz1); type = site.GetElementType(); //Valid AndFilter andFilt4 = new AndFilter(); andFilt4.Add(new TypeFilter(DbElementTypeInstance.EQUIPMENT)); andFilt4.Add(new TrueFilter()); bool valid = andFilt4.Valid(Example.Instance.mEqui); // attribute true AttributeTrueFilter filt1 = new AttributeTrueFilter(DbAttributeInstance.ISNAME); //should be true for named element bool named = filt1.Valid(Example.Instance.mEqui); //for first member it is also true named = filt1.Valid(Example.Instance.mEqui.FirstMember()); //Element type at or below BelowOrAtType filt3 = new BelowOrAtType(DbElementTypeInstance.EQUIPMENT); bool below = filt3.ScanBelow(Example.Instance.mEqui); }
public void IsMatchCombinations(bool expectedMatch, bool[] states) { Filter<object>[] filters = GenericCollectionUtils.ConvertAllToArray<bool, Filter<object>>(states, delegate(bool state) { return state ? (Filter<object>)new AnyFilter<object>() : new NoneFilter<object>(); }); AndFilter<object> combinator = new AndFilter<object>(filters); Assert.AreEqual(expectedMatch, combinator.IsMatch(0)); }
public void TestAndFilter() { ContainsFilter left1 = new ContainsFilter(ConnectorAttributeBuilder.Build("foo", "bar")); ContainsFilter right1 = new ContainsFilter(ConnectorAttributeBuilder.Build("foo2", "bar2")); AndFilter v1 = new AndFilter(left1, right1); AndFilter v2 = (AndFilter)CloneObject(v1); ContainsFilter left2 = (ContainsFilter)v2.Left; ContainsFilter right2 = (ContainsFilter)v2.Right; Assert.AreEqual(left1.GetAttribute(), left2.GetAttribute()); Assert.AreEqual(right1.GetAttribute(), right2.GetAttribute()); }
private static void MakeFilters() { NodeClassFilter dlFilter = new NodeClassFilter(typeof(DefinitionList)); HasAttributeFilter searchListFilter = new HasAttributeFilter("id", "searchList"); poiListFilter = new AndFilter(new HasParentFilter(searchListFilter, false), dlFilter); poiFilter = new NodeClassFilter(typeof(DefinitionListBullet)); tasteFilter = new HasAttributeFilter("class", "score1"); environmentFilter = new HasAttributeFilter("class", "score2"); serviceFilter = new HasAttributeFilter("class", "score3"); averageFilter = new HasAttributeFilter("class", "average"); commentFilter = new AndFilter(new HasAttributeFilter("class", "B"), new HasAttributeFilter("module", "list-readreview")); HasAttributeFilter nameFilterByParent = new HasAttributeFilter("class", "shopname"); nameFilter = new AndFilter(new HasParentFilter(nameFilterByParent, false), new HasAttributeFilter("class", "BL")); addressFilter = new HasAttributeFilter("class", "address"); tagsFilter = new HasAttributeFilter("class", "tags"); }
public OrganizationId GetOrganizationIdFromOrgNameOrAcceptedDomain(string domainName) { QueryFilter filter = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, AcceptedDomainSchema.DomainName, domainName), new ComparisonFilter(ComparisonOperator.NotEqual, AcceptedDomainSchema.AcceptedDomainType, AcceptedDomainType.ExternalRelay) }); ADRawEntry[] array = base.FindADRawEntryWithDefaultFilters <AcceptedDomain>(null, QueryScope.SubTree, filter, null, 1, new PropertyDefinition[] { ADObjectSchema.OrganizationId }); if (array == null || array.Count <ADRawEntry>() < 1) { return(null); } return((OrganizationId)array[0][ADObjectSchema.OrganizationId]); }
public static void ThrowIfImportedTPDsKeyIdIsNotUnique(IConfigurationSession session, string keyIdBeingImported, string keyIdTypeBeingImported, out object failureTarget) { RmsUtil.ThrowIfParameterNull(session, "session"); RmsUtil.ThrowIfStringParameterNullOrEmpty(keyIdBeingImported, "keyIdBeingImported"); RmsUtil.ThrowIfStringParameterNullOrEmpty(keyIdTypeBeingImported, "keyIdTypeBeingImported"); failureTarget = null; QueryFilter filter = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, RMSTrustedPublishingDomainSchema.KeyId, keyIdBeingImported), new ComparisonFilter(ComparisonOperator.Equal, RMSTrustedPublishingDomainSchema.KeyIdType, keyIdTypeBeingImported) }); if (RmsUtil.TPDExists(session, filter)) { failureTarget = keyIdBeingImported; throw new DuplicateTPDKeyIdException(keyIdTypeBeingImported, keyIdBeingImported); } }
private ITestFilter GetFilter(TestFilter filter) { var nUnitFilter = new AndFilter(); if (filter.names != null && filter.names.Length > 0) { nUnitFilter.Add(new SimpleNameFilter(filter.names)); } if (filter.categories != null && filter.categories.Length > 0) { nUnitFilter.Add(new CategoryFilter(filter.categories)); } if (filter.objects != null && filter.objects.Length > 0) { nUnitFilter.Add(new OrFilter(filter.objects.Where(o => o is TestName).Select(o => new NameFilter(o as TestName)).ToArray())); } return(nUnitFilter); }
public void TestNestedAndFilters() { var filter = new AndFilter( new CategoryFilter("Dummy"), new PropertyFilter("Priority", "High")); Assert.That(filter.Match(_dummyFixture)); Assert.That(filter.IsExplicitMatch(_dummyFixture)); Assert.False(filter.Match(_anotherFixture)); Assert.False(filter.IsExplicitMatch(_anotherFixture)); Assert.False(filter.Match(_yetAnotherFixture)); Assert.False(filter.IsExplicitMatch(_yetAnotherFixture)); Assert.False(filter.Match(_explicitFixture)); Assert.False(filter.IsExplicitMatch(_explicitFixture)); }
// 获得当前用户同级部门的用户 public IList <CV_PM_WECHAT_USER_DEPARTMENT> GetUserDepartmentbyparentId(int parentID) { long totalRecords = 0; IList <CV_PM_WECHAT_USER_DEPARTMENT> entities = null; AndFilter af = new AndFilter(); MatchingFilter mf = new MatchingFilter(); mf.AddGreatThan("ParentID", parentID); af.AddFilter(mf); Sort sort = new Sort(); sort.OrderBy("UserGuid", Sort.Direction.ASC); entities = cV_PM_WECHAT_USER_DEPARTMENTDAO.Find(0, -1, af, sort, out totalRecords); return(entities); }
public static string parseHtml(string url) { string result = ""; string HtmlString = HttpGet(url, ""); //进行解析 Parser parser = Parser.CreateParser(HtmlString, "utf-8"); //筛选要查找的对象 这里查找td,封装成过滤器 NodeFilter filter = new AndFilter(new TagNameFilter("p"), new HasParentFilter(new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("class", "t_news_txt")))); //将过滤器导入筛选,得到对象列表 NodeList nodes = parser.Parse(filter); for (int i = 0; i < nodes.Size(); i++) { INode textnode = nodes[i]; result += (result == "" ? "" : "\r\n") + textnode.ToPlainTextString().Replace(""", "\""); } return(result); }
internal static List <string> GetMrsServers(IConfigurationSession session, Guid mdbGuid) { DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(mdbGuid, null, null, FindServerFlags.None); if (databaseInformation.ServerSite == null) { throw new UnableToDetermineMDBSitePermanentException(mdbGuid); } MrsTracer.Common.Debug("MDB '{0}' ({1}) found to belong to Site: '{2}'", new object[] { databaseInformation.DatabaseName, mdbGuid, databaseInformation.ServerSite }); ServerVersion serverVersion = MailboxReplicationServiceClient.minRequiredVersion; QueryFilter filter = new AndFilter(new QueryFilter[] { new BitMaskAndFilter(ServerSchema.CurrentServerRole, 4UL), new ComparisonFilter(ComparisonOperator.NotEqual, ActiveDirectoryServerSchema.IsOutOfService, true), new ComparisonFilter(ComparisonOperator.GreaterThanOrEqual, ServerSchema.VersionNumber, serverVersion.ToInt()), new ComparisonFilter(ComparisonOperator.Equal, ServerSchema.ServerSite, databaseInformation.ServerSite.DistinguishedName) }); Server[] array = session.Find <Server>(null, QueryScope.SubTree, filter, null, 0); if (array == null || array.Length == 0) { MrsTracer.Common.Error("No Client Access servers running an appropriate version of Exchange 2010 (or later) were found in site '{0}'.", new object[] { databaseInformation.ServerSite.ToString() }); throw new ErrorNoCASServersInSitePermanentException(databaseInformation.ServerSite.ToString(), serverVersion.ToString()); } List <string> list = new List <string>(array.Length); foreach (Server server in array) { string fqdn = server.Fqdn; if (!string.IsNullOrEmpty(fqdn)) { list.Add(fqdn); } } return(list); }
public bool Run(byte[] testAssembly, string template, string testClassName, string testMethodName = null) { var asm = Assembly.Load(testAssembly); try { TestSourceFactory.Init(template); } catch (InvalidOperationException ex) { ErrorMessage = ex.Message; return(false); } var runner = new NUnitTestAssemblyRunner(new DefaultTestAssemblyBuilder()); runner.Load(asm, new Dictionary <string, object>()); var listener = new CustomListener(); ITestResult result; ITestFilter filter; string str = string.Empty; if (string.IsNullOrEmpty(testMethodName)) { result = runner.Run(listener, new ClassNameFilter(testClassName)); filter = new ClassNameFilter(testClassName); } else { result = runner.Run(listener, new AndFilter(new ClassNameFilter(testClassName), new MethodNameFilter(testMethodName))); filter = new AndFilter(new ClassNameFilter(testClassName), new MethodNameFilter(testMethodName)); } ErrorMessage = listener.Message; return(result.ResultState.Status != TestStatus.Failed); }
private TreeNode CreateAndFilterNode(IVideoFilter ifilter) { AndFilter filter = ifilter as AndFilter; TreeNode node = new TreeNode("AND"); foreach (IVideoFilter sub_filter in filter.SubFilters) { FilterNodeCreator node_creator; if (!node_creator_map_.TryGetValue(sub_filter.GetType(), out node_creator)) { node_creator = CreateUnknownFilterNode; } node.Nodes.Add(node_creator(sub_filter)); } return(node); }
private bool LegacyDNIsUnique(string legacyDN) { QueryFilter filter = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.LegacyExchangeDN, legacyDN), new ComparisonFilter(ComparisonOperator.NotEqual, ADObjectSchema.Id, this.DataObject.Id) }); base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.RootOrgGlobalCatalogSession, typeof(ADRecipient), filter, null, true)); ADRecipient[] array = base.RootOrgGlobalCatalogSession.Find(null, QueryScope.SubTree, filter, null, 1); bool flag = 0 == array.Length; if (VariantConfiguration.InvariantNoFlightingSnapshot.CmdletInfra.ServiceAccountForest.Enabled && base.CurrentOrganizationId != OrganizationId.ForestWideOrgId) { array = base.PartitionOrRootOrgGlobalCatalogSession.Find(null, QueryScope.SubTree, filter, null, 1); flag = (flag && 0 == array.Length); } return(flag); }
protected override TokenTarget CreateOnCacheMiss(string key, ref bool shouldAdd) { TargetUriViaSCP.Tracer.TraceDebug <string>((long)this.GetHashCode(), "TargetUriViaSCP: cache miss for: {0}", key); QueryFilter filter = new AndFilter(new QueryFilter[] { ExchangeScpObjects.DomainToApplicationUriKeyword.Filter, new TextFilter(ADServiceConnectionPointSchema.Keywords, "Domain=" + key, MatchOptions.FullString, MatchFlags.IgnoreCase) }); ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 76, "CreateOnCacheMiss", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Sharing\\Authentication\\TargetUriViaSCP.cs"); ADServiceConnectionPoint[] array = topologyConfigurationSession.Find <ADServiceConnectionPoint>(topologyConfigurationSession.GetAutoDiscoverGlobalContainerId(), QueryScope.SubTree, filter, null, 0); if (array == null || array.Length == 0) { TargetUriViaSCP.Tracer.TraceError <string>((long)this.GetHashCode(), "TargetUriViaSCP: found no SCP object for domain: {0}", key); return(null); } if (array.Length > 1) { TargetUriViaSCP.Tracer.TraceError <string>((long)this.GetHashCode(), "TargetUriViaSCP: found more than one SCP object for: {0}", key); return(null); } ADServiceConnectionPoint adserviceConnectionPoint = array[0]; if (adserviceConnectionPoint.ServiceBindingInformation == null || adserviceConnectionPoint.ServiceBindingInformation.Count == 0) { TargetUriViaSCP.Tracer.TraceError <ADObjectId>((long)this.GetHashCode(), "TargetUriViaSCP: found no value in ServiceBindingInformation in: {0}", adserviceConnectionPoint.Id); return(null); } if (adserviceConnectionPoint.ServiceBindingInformation.Count > 1) { TargetUriViaSCP.Tracer.TraceError <ADObjectId>((long)this.GetHashCode(), "TargetUriViaSCP: found more than one value in ServiceBindingInformation in: {0}", adserviceConnectionPoint.Id); return(null); } string text = adserviceConnectionPoint.ServiceBindingInformation[0]; if (!Uri.IsWellFormedUriString(text, UriKind.Absolute)) { TargetUriViaSCP.Tracer.TraceError <string>((long)this.GetHashCode(), "TargetUriViaSCP: value in ServiceBindingInformation is not well-formed URI: {0}", text); return(null); } TargetUriViaSCP.Tracer.TraceError <string, string>((long)this.GetHashCode(), "TargetUriViaSCP: ApplicationUri for domain {0} is {1}", key, text); return(new TokenTarget(new Uri(text, UriKind.Absolute))); }
private TestFilter GetTerm() { TestFilter primitive = GetPrimitive(); if (token != "+" && token != "-") { return(primitive); } AndFilter andFilter = new AndFilter(primitive); while (token == "+" || token == "-") { string text = token; GetToken(); primitive = GetPrimitive(); andFilter.Add((text == "-") ? new NotFilter(primitive) : primitive); } return(andFilter); }
public static ADUser FindFirstUserOrMoveRequestLinkedToDatabase(ADObjectId databaseId) { QueryFilter queryFilter = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, ADUserSchema.MailboxMoveTargetMDB, databaseId), new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.RecipientType, RecipientType.UserMailbox) }); QueryFilter queryFilter2 = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, ADUserSchema.MailboxMoveTargetMDB, databaseId), new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.RecipientType, RecipientType.MailUser) }); QueryFilter queryFilter3 = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, ADMailboxRecipientSchema.Database, databaseId), new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.RecipientType, RecipientType.UserMailbox) }); QueryFilter queryFilter4 = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, ADUserSchema.ArchiveDatabaseRaw, databaseId), new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.RecipientType, RecipientType.UserMailbox) }); QueryFilter queryFilter5 = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, ADUserSchema.ArchiveDatabaseRaw, databaseId), new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.RecipientType, RecipientType.MailUser) }); QueryFilter queryFilter6 = new OrFilter(new QueryFilter[] { queryFilter3, queryFilter4, queryFilter5, queryFilter, queryFilter2 }); queryFilter6 = new AndFilter(new QueryFilter[] { queryFilter6, PartitionDataAggregator.CreateMonitoringMailboxFilter() }); return(PartitionDataAggregator.FindFirstMatchingRecipientObject <ADUser>(queryFilter6, true, true, true, ConsistencyMode.PartiallyConsistent, true, true)); }
internal static void ValidateNoDuplicates(DomainContentConfig domain, IConfigurationSession session, Task.TaskErrorLoggingDelegate errorWriter) { string domain2 = domain.DomainName.Domain; QueryFilter filter = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.NotEqual, ADObjectSchema.Guid, domain.Guid), new OrFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, EdgeDomainContentConfigSchema.DomainName, domain2), new ComparisonFilter(ComparisonOperator.Equal, EdgeDomainContentConfigSchema.DomainName, "*." + domain2) }) }); DomainContentConfig[] array = session.Find <DomainContentConfig>(session.GetOrgContainerId().GetDescendantId(domain.ParentPath), QueryScope.SubTree, filter, null, 1); if (array.Length > 0) { errorWriter(new DuplicateRemoteDomainException(domain2), ErrorCategory.ResourceExists, domain); } }
private List <DbElement> GetElements(DbElement root, AndFilter filter) { List <DbElement> dbElementList = new List <DbElement>(); IEnumerator enumerator = new DBElementCollection(root, (BaseFilter)filter).GetEnumerator(); try { while (enumerator.MoveNext()) { DbElement current = (DbElement)enumerator.Current; dbElementList.Add(current); } } finally { (enumerator as IDisposable)?.Dispose(); } return(dbElementList); }
// Token: 0x060019C3 RID: 6595 RVA: 0x0006CA10 File Offset: 0x0006AC10 internal static QueryFilter ManagedByFilterBuilder(SinglePropertyFilter filter) { QueryFilter result; if (filter is ComparisonFilter) { ComparisonFilter comparisonFilter = (ComparisonFilter)filter; if (comparisonFilter.ComparisonOperator == ComparisonOperator.Equal) { result = new OrFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, ADGroupSchema.RawManagedBy, comparisonFilter.PropertyValue), new ComparisonFilter(ComparisonOperator.Equal, ADGroupSchema.CoManagedBy, comparisonFilter.PropertyValue) }); } else { if (comparisonFilter.ComparisonOperator != ComparisonOperator.NotEqual) { throw new ADFilterException(DirectoryStrings.ExceptionUnsupportedOperatorForProperty(comparisonFilter.Property.Name, comparisonFilter.ComparisonOperator.ToString())); } result = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.NotEqual, ADGroupSchema.RawManagedBy, comparisonFilter.PropertyValue), new ComparisonFilter(ComparisonOperator.NotEqual, ADGroupSchema.CoManagedBy, comparisonFilter.PropertyValue) }); } } else { if (!(filter is ExistsFilter)) { throw new ADFilterException(DirectoryStrings.ExceptionUnsupportedFilterForPropertyMultiple(filter.Property.Name, filter.GetType(), typeof(ComparisonFilter), typeof(ExistsFilter))); } ExistsFilter existsFilter = (ExistsFilter)filter; result = new OrFilter(new QueryFilter[] { new ExistsFilter(ADGroupSchema.RawManagedBy), new ExistsFilter(ADGroupSchema.CoManagedBy) }); } return(result); }
public AcceptedDomain GetAcceptedDomainByDomainName(string domainName) { QueryFilter filter = new AndFilter(new QueryFilter[] { ADObject.ObjectClassFilter("msExchAcceptedDomain"), new ComparisonFilter(ComparisonOperator.Equal, AcceptedDomainSchema.DomainName, domainName) }); AcceptedDomain[] array = base.Find <AcceptedDomain>(null, QueryScope.SubTree, filter, null, 2); if (array == null || array.Length == 0) { return(null); } if (array.Length == 2) { throw new ADOperationException(DirectoryStrings.DuplicatedAcceptedDomain(domainName, array[0].Id.ToDNString(), array[1].Id.ToDNString())); } return(array[0]); }
/// <summary> /// 第二种页面:数据格式为文本 /// </summary> /// <returns></returns> public static string[] GetDataFromText(string link) { //定义一个数组存放需要的解析数据 string[] tempData = new string[6]; try { //过滤条件:添加第二次筛选条件 NodeFilter secondFilter = new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("class", "nrl")); NodeList secondNodeList = GetNodeList(link, secondFilter); //获取目标div标签的子节点 secondNodeList = secondNodeList.ElementAt(0).Children; //开始解析需要的数据项 TableTag targetTable = (TableTag)secondNodeList[0]; //获取表中的所有行 TableRow[] tr = targetTable.Rows; //标题 tempData[0] = tr[0].ToPlainTextString().Trim(); //文章来源及更新时间 string temp = tr[1].ToPlainTextString().Trim(); int index1 = temp.IndexOf(':'); int index2 = temp.LastIndexOf(':'); tempData[1] = temp.Substring(index1 + 1, 3); temp = temp.Substring(index2 + 1).Trim(); int year, month, date; year = temp.LastIndexOf('年'); month = temp.LastIndexOf('月'); date = temp.LastIndexOf('日'); tempData[2] = temp.Substring(0, year) + "-" + temp.Substring(year + 1, month - year - 1) + temp.Substring(month + 1, date - month - 1); //网址 tempData[3] = link; //水位表 TableColumn[] tc = tr[3].Columns; tempData[4] = tc[0].ChildAt(2).ToHtml(); } catch (Exception ex) { Console.WriteLine("第二层解析出错啦" + ex.Message); tempData[5] = "failed"; } return(tempData); }
// Token: 0x06001214 RID: 4628 RVA: 0x00038DB8 File Offset: 0x00036FB8 private static Server[] GetMailboxServers(ITopologyConfigurationSession configSession, bool localSiteOnly, LogMessageDelegate logger) { QueryFilter queryFilter = new AndFilter(new QueryFilter[] { new BitMaskAndFilter(ServerSchema.CurrentServerRole, 2UL), new ComparisonFilter(ComparisonOperator.NotEqual, ActiveDirectoryServerSchema.IsOutOfService, true), new ExistsFilter(ActiveDirectoryServerSchema.HostedDatabaseCopies) }); QueryFilter filter; if (PhysicalResourceLoadBalancing.IsDatacenter) { if (localSiteOnly) { ADSite localSite = configSession.GetLocalSite(); queryFilter = QueryFilter.AndTogether(new QueryFilter[] { queryFilter, new ComparisonFilter(ComparisonOperator.Equal, ServerSchema.ServerSite, localSite.Id) }); } QueryFilter mailboxServerVersionFilter = PhysicalResourceLoadBalancing.GetMailboxServerVersionFilter(); filter = QueryFilter.AndTogether(new QueryFilter[] { queryFilter, mailboxServerVersionFilter }); } else { filter = queryFilter; } PhysicalResourceLoadBalancing.LogVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(configSession, typeof(Server), filter, null, false), logger); Server[] array = configSession.Find <Server>(null, QueryScope.SubTree, filter, null, 0); if (array == null || array.Length == 0) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoServerForDatabaseException("Can not find any available mailbox server."), logger); throw new NoServersForDatabaseException("Can not find any mailbox server in local site"); } PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbGeneralTrace(string.Format("Retrieved {0} mailbox servers.", array.Length)), logger); return(array); }
private static MiniServer GetOneMailboxServerForASite(ADObjectId adSiteId, int versionNumber, bool needsExactVersionMatch) { ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.NonCacheSessionFactory.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 145, "GetOneMailboxServerForASite", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\SystemConfiguration\\ConfigurationCache\\ServersCache.cs"); QueryFilter queryFilter; if (needsExactVersionMatch) { queryFilter = new ComparisonFilter(ComparisonOperator.Equal, ServerSchema.VersionNumber, versionNumber); } else { queryFilter = new ComparisonFilter(ComparisonOperator.GreaterThanOrEqual, ServerSchema.VersionNumber, versionNumber); } QueryFilter filter; if (adSiteId != null) { QueryFilter queryFilter2 = new ComparisonFilter(ComparisonOperator.Equal, ServerSchema.ServerSite, adSiteId); filter = new AndFilter(new QueryFilter[] { queryFilter2, ServersCache.MailboxServerRoleFilter, ServersCache.ServerOnlineFilter, queryFilter }); } else { filter = new AndFilter(new QueryFilter[] { ServersCache.MailboxServerRoleFilter, ServersCache.ServerOnlineFilter, queryFilter }); } MiniServer[] array = topologyConfigurationSession.Find <MiniServer>(null, QueryScope.SubTree, filter, null, 1, null); if (array != null && array.Length > 0) { return(array[0]); } throw new ServerHasNotBeenFoundException(versionNumber, string.Empty, needsExactVersionMatch, (adSiteId != null) ? adSiteId.Name : string.Empty); }
private QueryFilter BuildQueryFilter() { QueryFilter queryFilter = GetModernAttachmentsCommand.findFilterHasAttachment; if (this.itemCreationTimeStart != ExDateTime.MinValue) { ComparisonFilter comparisonFilter = new ComparisonFilter(ComparisonOperator.GreaterThanOrEqual, ItemSchema.ReceivedTime, this.itemCreationTimeStart); queryFilter = new AndFilter(new QueryFilter[] { queryFilter, comparisonFilter }); } if (this.itemCreationTimeEnd != ExDateTime.MaxValue) { ComparisonFilter comparisonFilter2 = new ComparisonFilter(ComparisonOperator.LessThanOrEqual, ItemSchema.ReceivedTime, this.itemCreationTimeEnd); queryFilter = new AndFilter(new QueryFilter[] { queryFilter, comparisonFilter2 }); } if (!string.IsNullOrEmpty(this.request.ItemFromStart)) { ComparisonFilter comparisonFilter3 = new ComparisonFilter(ComparisonOperator.GreaterThanOrEqual, ItemSchema.SentRepresentingDisplayName, this.request.ItemFromStart); queryFilter = new AndFilter(new QueryFilter[] { queryFilter, comparisonFilter3 }); } if (!string.IsNullOrEmpty(this.request.ItemFromEnd)) { ComparisonFilter comparisonFilter4 = new ComparisonFilter(ComparisonOperator.LessThanOrEqual, ItemSchema.SentRepresentingDisplayName, this.request.ItemFromEnd); queryFilter = new AndFilter(new QueryFilter[] { queryFilter, comparisonFilter4 }); } return(queryFilter); }
public static List <UMServer> GetCompatibleUMRpcServers(ADObjectId site, UMDialPlan dialPlan, ITopologyConfigurationSession session) { List <UMServer> list = new List <UMServer>(); if (CommonConstants.UseDataCenterCallRouting) { QueryFilter filter = new AndFilter(new QueryFilter[] { CommonUtil.GetCompatibleServersWithRole(VersionEnum.Compatible, ServerRole.UnifiedMessaging), new ComparisonFilter(ComparisonOperator.Equal, ServerSchema.ServerSite, site) }); IEnumerable <Server> enumerable = session.FindPaged <Server>(null, QueryScope.SubTree, filter, null, 0); foreach (Server dataObject in enumerable) { list.Add(new UMServer(dataObject)); } return(list); } return(Utility.GetCompatibleUMRpcServerList(dialPlan, session)); }
protected QueryFilter BuildQueryFilter() { List <ComparisonFilter> list = new List <ComparisonFilter>(); Guid externalDirectoryOrganizationId = ServiceLocator.Current.GetService <IAuthenticationProvider>().GetExternalDirectoryOrganizationId(base.CurrentOrganizationId); list.Add(new ComparisonFilter(ComparisonOperator.Equal, Schema.Utilities.GetSchemaPropertyDefinition("OrganizationQueryDefinition"), externalDirectoryOrganizationId)); foreach (Tuple <PropertyInfo, QueryParameter> tuple in Schema.Utilities.GetProperties <QueryParameter>(base.GetType())) { PropertyInfo item = tuple.Item1; QueryParameter item2 = tuple.Item2; if (item != null && item2 != null) { item2.AddFilter(list, item.GetValue(this)); } } AndFilter result = new AndFilter(list.ToArray()); base.Diagnostics.Checkpoint("BuildQueryFilter"); return(result); }
// 获得当前同级部门 public IList <CV_PM_WECHAT_DEPARTMENT> GetSameLevelDepartment(int parentID) { long totalRecords = 0; IList <CV_PM_WECHAT_DEPARTMENT> entities = null; AndFilter af = new AndFilter(); MatchingFilter mf = new MatchingFilter(); mf.AddGreatEqualThan("ParentID", parentID); //if (Guid.Empty != DepartmentGuid) // mf.AddMatching("DepartmentGuid", DepartmentGuid); af.AddFilter(mf); Sort sort = new Sort(); sort.OrderBy("DepartmentGuid", Sort.Direction.ASC); entities = cV_PM_WECHAT_DEPARTMENTDAO.Find(0, -1, af, sort, out totalRecords); return(entities); }
public ExchangeConfigurationUnit[] FindSharedConfiguration(SharedConfigurationInfo sharedConfigInfo, bool enabledSharedOrgOnly) { if (!base.SessionSettings.IsGlobal && base.ConfigScope != ConfigScopes.AllTenants) { throw new NotSupportedException("FindEnabledSharedConfiguration cannot be invoked on non Global sessions"); } if (sharedConfigInfo == null) { throw new ArgumentNullException("sharedConfigInfo"); } QueryFilter filter = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, OrganizationSchema.SharedConfigurationInfo, sharedConfigInfo), new ComparisonFilter(ComparisonOperator.Equal, ExchangeConfigurationUnitSchema.OrganizationStatus, OrganizationStatus.Active), new ComparisonFilter(ComparisonOperator.Equal, OrganizationSchema.ImmutableConfiguration, true), new ComparisonFilter(ComparisonOperator.Equal, OrganizationSchema.EnableAsSharedConfiguration, enabledSharedOrgOnly) }); return(base.Find <ExchangeConfigurationUnit>(null, QueryScope.SubTree, filter, null, 0)); }
public void PrecedenceTest() { CategoryExpression expr = new CategoryExpression("A + B | C + -D,E,F"); OrFilter orFilter = (OrFilter)expr.Filter; AndFilter andFilter = (AndFilter)orFilter.Filters[0]; CategoryFilter catFilter = (CategoryFilter)andFilter.Filters[0]; Assert.AreEqual(catFilter.Categories, new string[] { "A" }); catFilter = (CategoryFilter)andFilter.Filters[1]; Assert.AreEqual(catFilter.Categories, new string[] { "B" }); andFilter = (AndFilter)orFilter.Filters[1]; catFilter = (CategoryFilter)andFilter.Filters[0]; Assert.AreEqual(catFilter.Categories, new string[] { "C" }); NotFilter notFilter = (NotFilter)andFilter.Filters[1]; catFilter = (CategoryFilter)notFilter.BaseFilter; Assert.AreEqual(catFilter.Categories, new string[] { "D", "E", "F" }); }
public Hashtable GetVolumeWithinElement(string elementname, Hashtable dbtypeArray, Boolean completelycover) { //DbElementType[] dbtypes = new DbElementType[] { DbElementTypeInstance.PSPOOL }; string samplerow = ((string)dbtypeArray[1.0]); List<DbElementType> dbtypeslist = new List<DbElementType>(); foreach (var item in dbtypeArray.Keys) { dbtypeslist.Add(DbElementType.GetElementType(dbtypeArray[item].ToString())); } DbElementType[] dbtypes = dbtypeslist.ToArray(); DbElement Outfit_Elements = MDB.CurrentMDB.GetFirstWorld(Aveva.Pdms.Database.DbType.Design); DBElementCollection result_collection = null; TypeFilter filter = new TypeFilter(dbtypes); AndFilter finalfilter = new AndFilter(); InVolumeFilter volfilter = new InVolumeFilter(CurrentElement.Element,dbtypes, true); finalfilter.Add(filter); finalfilter.Add(volfilter); result_collection = new DBElementCollection(Outfit_Elements, finalfilter); Hashtable resultHs = new Hashtable(); double idx = 1.0; foreach (DbElement item in result_collection) { resultHs.Add(idx, item.GetAsString(DbAttributeInstance.NAME)); idx = idx + 1.0; } return resultHs; }
private static List <ADUser> InternalGetOrganizationMailboxesByCapability(IRecipientSession session, OrganizationCapability capability, QueryFilter optionalFilter) { EnumValidator.ThrowIfInvalid <OrganizationCapability>(capability, "capability"); if (session == null) { throw new ArgumentNullException("session"); } List <ADUser> list = new List <ADUser>(); QueryFilter queryFilter = new AndFilter(new QueryFilter[] { OrganizationMailbox.OrganizationMailboxFilterBase, new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.RawCapabilities, capability) }); if (optionalFilter != null) { queryFilter = QueryFilter.AndTogether(new QueryFilter[] { queryFilter, optionalFilter }); } ADObjectId rootId; QueryScope scope; OrganizationMailbox.GetQueryParameters(session, out rootId, out scope); ADPagedReader <ADRecipient> adpagedReader = session.FindPaged(rootId, scope, queryFilter, new SortBy(ADObjectSchema.WhenCreated, SortOrder.Ascending), 0); if (adpagedReader != null) { foreach (ADRecipient adrecipient in adpagedReader) { ADUser aduser = adrecipient as ADUser; if (aduser != null) { list.Add(aduser); } } } return(list); }
private static bool IsReminderSearchFolderForO12(DefaultFolderContext context, SearchFolderCriteria currentCriteria, out bool isUpToDate) { isUpToDate = false; ExTraceGlobals.DefaultFoldersTracer.TraceDebug <SearchFolderCriteria>(-1L, "RemindersSearchFolderValidation::IsReminderSearchFolderForO12. We are checking currentCriteria on the folder we found. currentCriteria = {0}.", currentCriteria); QueryFilter[] o12RemindersSearchFolderExclusionList = RemindersSearchFolderValidation.GetO12RemindersSearchFolderExclusionList(currentCriteria); if (o12RemindersSearchFolderExclusionList == null) { return(false); } foreach (QueryFilter queryFilter in o12RemindersSearchFolderExclusionList) { ComparisonFilter comparisonFilter = queryFilter as ComparisonFilter; if (comparisonFilter == null || comparisonFilter.ComparisonOperator != ComparisonOperator.NotEqual || !comparisonFilter.Property.Equals(InternalSchema.ParentItemId) || !(comparisonFilter.PropertyValue is StoreId)) { return(false); } } AndFilter andFilter = currentCriteria.SearchQuery as AndFilter; SearchFolderCriteria searchFolderCriteria = RemindersSearchFolderValidation.CreateRemindersQueryForO12(context, o12RemindersSearchFolderExclusionList); AndFilter andFilter2 = (AndFilter)searchFolderCriteria.SearchQuery; if (andFilter == null || andFilter.FilterCount != 2 || andFilter.FilterCount != andFilter2.FilterCount || currentCriteria.FolderScope.Length != searchFolderCriteria.FolderScope.Length) { return(false); } for (int j = 0; j < currentCriteria.FolderScope.Length; j++) { if (!currentCriteria.FolderScope[j].Equals(searchFolderCriteria.FolderScope[j])) { return(false); } } if (!andFilter.Filters[1].Equals(andFilter2.Filters[1])) { return(false); } AndFilter andFilter3 = (AndFilter)andFilter2.Filters[0]; isUpToDate = (o12RemindersSearchFolderExclusionList.Length == andFilter3.FilterCount); return(true); }
public static TestFilter FromXml(string xmlText) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlText); XmlNode topNode = doc.FirstChild; if (topNode.Name != "filter") throw new Exception("Expected filter element at top level"); // Initially, an empty filter TestFilter result = TestFilter.Empty; bool isEmptyResult = true; XmlNodeList testNodes = topNode.SelectNodes("tests/test"); XmlNodeList includeNodes = topNode.SelectNodes("include/category"); XmlNodeList excludeNodes = topNode.SelectNodes("exclude/category"); if (testNodes.Count > 0) { SimpleNameFilter nameFilter = new SimpleNameFilter(); foreach (XmlNode testNode in topNode.SelectNodes("tests/test")) nameFilter.Add(testNode.InnerText); result = nameFilter; isEmptyResult = false; } if (includeNodes.Count > 0) { //CategoryFilter includeFilter = new CategoryFilter(); //foreach (XmlNode includeNode in includeNodes) // includeFilter.AddCategory(includeNode.InnerText); // Temporarily just look at the first element XmlNode includeNode = includeNodes[0]; TestFilter includeFilter = new CategoryExpression(includeNode.InnerText).Filter; if (isEmptyResult) result = includeFilter; else result = new AndFilter(result, includeFilter); isEmptyResult = false; } if (excludeNodes.Count > 0) { CategoryFilter categoryFilter = new CategoryFilter(); foreach (XmlNode excludeNode in excludeNodes) categoryFilter.AddCategory(excludeNode.InnerText); TestFilter excludeFilter = new NotFilter(categoryFilter); if (isEmptyResult) result = excludeFilter; else result = new AndFilter(result, excludeFilter); isEmptyResult = false; } return result; }
private void queryOddsPerRQ1() { if (Request["scheduletypeid"] != null && Request["scheduleid"] != null && Request["companyids"] != null) { DataTable dt = new DataTable(); dt.Columns.Add("rqy", typeof(double)); dt.Columns.Add("rqz", typeof(double)); dt.Columns.Add("rqs", typeof(double)); dt.Columns.Add("totalCount", typeof(int)); SeoWebSite.BLL.odds_rq odds_rqbll = new SeoWebSite.BLL.odds_rq(); string[] companyidarray = Request.Form["companyids"].Split(','); string scheduleid = Request.Form["scheduleid"]; List<int> companyidList = new List<int>(); foreach (string companyid in companyidarray) { companyidList.Add(Convert.ToInt32(companyid)); List<string> whereStrList = new List<string>(); string[] paramArr = { companyid, scheduleid }; string s = webClientBLL.GetRemoteHtml("odds/detail.aspx?companyID={0}&scheduleid={1}", paramArr); if (string.IsNullOrEmpty(s)) { continue; } Parser parser = Parser.CreateParser(s, "utf-8"); AndFilter andFilter = new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("bgColor", "#bbbbbb")); NodeList tableList = parser.ExtractAllNodesThatMatch(andFilter); parser = Parser.CreateParser(s, "utf-8"); NodeList h3tag = parser.ExtractAllNodesThatMatch(new TagNameFilter("h3")); string year = h3tag[0].ToPlainTextString().Remove(5); if (tableList.Count == 3) { AndFilter andFilter1 = new AndFilter(new TagNameFilter("tr"), new HasAttributeFilter("class", "ts1")); NodeList list = tableList[0].Children.ExtractAllNodesThatMatch(andFilter1); for (int i = 0; i < list.Count; i++) { NodeList tdList = list[i].Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableColumn)); string pankou = CommonHelper.GoalCnToGoal(tdList[1].ToPlainTextString()); if (!string.IsNullOrEmpty(pankou)) { whereStrList.Add("e.home=" + tdList[0].ToPlainTextString() + " and e.pankou=" + pankou + " and e.away=" + tdList[2].ToPlainTextString()); } } } if (whereStrList.Count > 0) { DataTable dt1 = odds_rqbll.queryCompanyOddsPer1(Convert.ToInt32(Request.Form["scheduletypeid"]), Convert.ToInt32(Request.Form["scheduleid"]), Convert.ToInt32(companyid),whereStrList); if (dt1 != null && dt1.Rows.Count > 0 && Convert.ToInt32(dt1.Rows[0]["totalCount"]) > 0) { dt.ImportRow(dt1.Rows[0]); } } } DataTable data = new DataTable(); data.Columns.Add("id", typeof(int)); data.Columns.Add("name", typeof(string)); data.Columns.Add("rqyper", typeof(float)); data.Columns.Add("rqzper", typeof(float)); data.Columns.Add("rqsper", typeof(float)); data.Columns.Add("diffper", typeof(float)); data.Columns.Add("suggest", typeof(int)); DataRow dr = data.NewRow(); dr["id"] = 1; dr["name"] = "赔率支持平均"; dr["rqyper"] = dt.Compute("avg(rqy)", "1=1"); dr["rqzper"] = dt.Compute("avg(rqz)", "1=1"); dr["rqsper"] = dt.Compute("avg(rqs)", "1=1"); dr["diffper"] = Convert.ToInt32(dt.Compute("avg(rqy)", "1=1")) - Convert.ToInt32(dt.Compute("avg(rqs)", "1=1")); dr["suggest"] = 25; data.Rows.Add(dr); dr = data.NewRow(); dr["id"] = 2; dr["name"] = "赔率支持最大"; dr["rqyper"] = dt.Compute("max(rqy)", "1=1"); dr["rqzper"] = dt.Compute("avg(rqz)", "1=1"); dr["rqsper"] = dt.Compute("max(rqs)", "1=1"); dr["diffper"] = Convert.ToInt32(dt.Compute("max(rqy)", "1=1")) - Convert.ToInt32(dt.Compute("max(rqs)", "1=1")); dr["suggest"] = 40; data.Rows.Add(dr); double ycount = Convert.ToDouble(dt.Compute("count(rqy)", "rqy > rqs")); double scount = Convert.ToDouble(dt.Compute("count(rqy)", "rqy < rqs")); dr = data.NewRow(); dr["id"] = 3; dr["name"] = "公司支持数量"; dr["rqyper"] = ycount / (ycount + scount) * 100; dr["rqzper"] = 0; dr["rqsper"] = scount / (ycount + scount) * 100; dr["diffper"] = ycount / (ycount + scount) * 100 - scount / (ycount + scount) * 100; dr["suggest"] = 80; data.Rows.Add(dr); responseText = "{success:true,data:" + JArray.FromObject(data) + "}"; } }
private void getOdds3in1() { SeoWebSite.BLL.odds_rq odds_rqbll = new SeoWebSite.BLL.odds_rq(); WebClientBLL webClientBLL = new WebClientBLL(); try { if (Request["scheduleid"] != null && Request["companyid"] != null) { string scheduleid = Request.Form["scheduleid"]; string[] companyid_Array = Request.Form["companyid"].Split(','); DataTable dt = new DataTable(); dt.Columns.Add("scheduleid", typeof(int)); dt.Columns.Add("companyid", typeof(int)); dt.Columns.Add("aaa", typeof(double)); dt.Columns.Add("aab", typeof(double)); dt.Columns.Add("aac", typeof(double)); dt.Columns.Add("aba", typeof(double)); dt.Columns.Add("abb", typeof(double)); dt.Columns.Add("abc", typeof(double)); dt.Columns.Add("baa", typeof(double)); dt.Columns.Add("bab", typeof(double)); dt.Columns.Add("bac", typeof(double)); dt.Columns.Add("bba", typeof(double)); dt.Columns.Add("bbb", typeof(double)); dt.Columns.Add("bbc", typeof(double)); dt.Columns.Add("caa", typeof(double)); dt.Columns.Add("cab", typeof(double)); dt.Columns.Add("cac", typeof(double)); dt.Columns.Add("cba", typeof(double)); dt.Columns.Add("cbb", typeof(double)); dt.Columns.Add("cbc", typeof(double)); dt.Columns.Add("aaa1", typeof(string)); dt.Columns.Add("aab1", typeof(string)); dt.Columns.Add("aac1", typeof(string)); dt.Columns.Add("aba1", typeof(string)); dt.Columns.Add("abb1", typeof(string)); dt.Columns.Add("abc1", typeof(string)); dt.Columns.Add("baa1", typeof(string)); dt.Columns.Add("bab1", typeof(string)); dt.Columns.Add("bac1", typeof(string)); dt.Columns.Add("bba1", typeof(string)); dt.Columns.Add("bbb1", typeof(string)); dt.Columns.Add("bbc1", typeof(string)); foreach (string companyid in companyid_Array) { string[] paramArr = { companyid, scheduleid }; string s = webClientBLL.GetRemoteHtml("odds/detail.aspx?companyID={0}&scheduleid={1}", paramArr); Parser parser = Parser.CreateParser(s, "utf-8"); AndFilter andFilter = new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("bgColor", "#bbbbbb")); NodeList tableList = parser.ExtractAllNodesThatMatch(andFilter); parser = Parser.CreateParser(s, "utf-8"); //NodeList h3tag = parser.ExtractAllNodesThatMatch(new TagNameFilter("h3")); //string year = h3tag[0].ToPlainTextString().Remove(5); if (tableList.Count == 3) { DataRow dr = dt.NewRow(); dr["scheduleid"] = scheduleid; dr["companyid"] = companyid; NodeList tdList; string pankou; #region 让球盘 AndFilter andFilter1 = new AndFilter(new TagNameFilter("tr"), new HasAttributeFilter("class", "ts1")); NodeList list = tableList[0].Children.ExtractAllNodesThatMatch(andFilter1); if (list.Count > 0) { tdList = list[list.Count - 1].Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableColumn));//初盘 pankou = CommonHelper.GoalCnToGoal(tdList[1].ToPlainTextString()); double per1 = 0, per2 = 0, per3 = 0; double per4 = 0, per5 = 0, per6 = 0; if (!string.IsNullOrEmpty(pankou)) { dr["aaa"] = tdList[0].ToPlainTextString(); dr["aab"] = pankou; dr["aac"] = tdList[2].ToPlainTextString(); DataSet ds = odds_rqbll.queryCompanyOddsCount(companyid, tdList[0].ToPlainTextString(), pankou, tdList[2].ToPlainTextString(), Convert.ToInt32(Request.Form["scheduleType"]), "Chupan"); if (Convert.ToDouble(ds.Tables[0].Rows[0][3]) > 0) { per1 = Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][0]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100); per2 = Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][1]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100); per3 = Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][2]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100); dr["aaa1"] = ds.Tables[0].Rows[0][0].ToString() + "(" + Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][0]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100) + "%)"; dr["aab1"] = ds.Tables[0].Rows[0][1].ToString() + "(" + Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][1]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100) + "%)"; dr["aac1"] = ds.Tables[0].Rows[0][2].ToString() + "(" + Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][2]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100) + "%)"; } } tdList = list[0].Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableColumn));//终盘 pankou = CommonHelper.GoalCnToGoal(tdList[1].ToPlainTextString()); if (!string.IsNullOrEmpty(pankou)) { dr["aba"] = tdList[0].ToPlainTextString(); dr["abb"] = pankou; dr["abc"] = tdList[2].ToPlainTextString(); DataSet ds = odds_rqbll.queryCompanyOddsCount(companyid, tdList[0].ToPlainTextString(), pankou, tdList[2].ToPlainTextString(), Convert.ToInt32(Request.Form["scheduleType"]), "Zhongpan"); if (Convert.ToDouble(ds.Tables[0].Rows[0][3]) > 0) { per4 = Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][0]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100); per5 = Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][1]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100); per6 = Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][2]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100); dr["aba1"] = ds.Tables[0].Rows[0][0].ToString() + "(<font color=" + (per4 > per1 ? "red" : "green") + ">" + Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][0]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100) + "%</font>)"; dr["abb1"] = ds.Tables[0].Rows[0][1].ToString() + "(<font color=" + (per5 > per2 ? "red" : "green") + ">" + Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][1]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100) + "%</font>)"; dr["abc1"] = ds.Tables[0].Rows[0][2].ToString() + "(<font color=" + (per6 > per3 ? "red" : "green") + ">" + Math.Round(Convert.ToDouble(ds.Tables[0].Rows[0][2]) / Convert.ToDouble(ds.Tables[0].Rows[0][3]) * 100) + "%</font>)"; } } } #endregion #region 标准盘 list = tableList[1].Children.ExtractAllNodesThatMatch(andFilter1); if (list.Count > 0) { tdList = list[list.Count - 1].Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableColumn)); dr["baa"] = tdList[0].ToPlainTextString(); dr["bab"] = tdList[1].ToPlainTextString(); dr["bac"] = tdList[2].ToPlainTextString(); tdList = list[0].Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableColumn));//终盘 dr["bba"] = tdList[0].ToPlainTextString(); dr["bbb"] = tdList[1].ToPlainTextString(); dr["bbc"] = tdList[2].ToPlainTextString(); } #endregion #region 大小盘 list = tableList[2].Children.ExtractAllNodesThatMatch(andFilter1); if (list.Count > 0) { tdList = list[list.Count - 1].Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableColumn)); pankou = CommonHelper.BallSizeToBall(tdList[1].ToPlainTextString()); if (!string.IsNullOrEmpty(pankou)) { dr["caa"] = tdList[0].ToPlainTextString(); dr["cab"] = pankou; dr["cac"] = tdList[2].ToPlainTextString(); } tdList = list[0].Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.TableColumn)); pankou = CommonHelper.BallSizeToBall(tdList[1].ToPlainTextString()); if (!string.IsNullOrEmpty(pankou)) { dr["cba"] = tdList[0].ToPlainTextString(); dr["cbb"] = pankou; dr["cbc"] = tdList[2].ToPlainTextString(); } } #endregion dt.Rows.Add(dr); } } if (dt.Rows.Count > 0) { DataRow dr1 = dt.NewRow(); #region 亚洲盘统计 List<double> pankouList1 = new List<double>(); List<double> homefcList1 = new List<double>(); List<double> awayfcList1 = new List<double>(); List<double> pankouList2 = new List<double>(); List<double> homefcList2 = new List<double>(); List<double> awayfcList2 = new List<double>(); foreach (DataRow dr in dt.Rows) { if (dr["aab"] != DBNull.Value && !pankouList1.Contains(Convert.ToDouble(dr["aab"]))) { pankouList1.Add(Convert.ToDouble(dr["aab"])); } if (dr["abb"] != DBNull.Value && !pankouList2.Contains(Convert.ToDouble(dr["abb"]))) { pankouList2.Add(Convert.ToDouble(dr["abb"])); } } foreach (decimal item in pankouList2) { if (dt.Select("aab=" + item).Count() > 1) { double fc = Convert.ToDouble(dt.Compute("Var(aaa)", "aab=" + item)); homefcList1.Add(fc); fc = Convert.ToDouble(dt.Compute("Var(aac)", "aab=" + item)); awayfcList1.Add(fc); } if (dt.Select("abb=" + item).Count() > 1) { double fc = Convert.ToDouble(dt.Compute("Var(aba)", "abb=" + item)); homefcList2.Add(fc); fc = Convert.ToDouble(dt.Compute("Var(abc)", "abb=" + item)); awayfcList2.Add(fc); } } dr1["aaa"] = Convert.ToDouble(dt.Compute("Avg(aaa)", "1=1")); dr1["aac"] = Convert.ToDouble(dt.Compute("Avg(aac)", "1=1")); dr1["aaa1"] = homefcList1.Average(); dr1["aac1"] = awayfcList1.Average(); dr1["aba"] = Convert.ToDouble(dt.Compute("Avg(aba)", "1=1")); dr1["abc"] = Convert.ToDouble(dt.Compute("Avg(abc)", "1=1")); dr1["aba1"] = "<font color=" + (homefcList2.Average() > homefcList1.Average() ? "red" : "green") + ">" + homefcList2.Average() + "</font>"; dr1["abc1"] = "<font color=" + (awayfcList2.Average() > awayfcList1.Average() ? "red" : "green") + ">" + awayfcList2.Average() + "</font>"; #endregion dr1["baa"] = Convert.ToDouble(dt.Compute("Avg(baa)", "1=1")); dr1["bab"] = Convert.ToDouble(dt.Compute("Avg(bab)", "1=1")); dr1["bac"] = Convert.ToDouble(dt.Compute("Avg(bac)", "1=1")); dr1["bba"] = Convert.ToDouble(dt.Compute("Avg(bba)", "1=1")); dr1["bbb"] = Convert.ToDouble(dt.Compute("Avg(bbb)", "1=1")); dr1["bbc"] = Convert.ToDouble(dt.Compute("Avg(bbc)", "1=1")); dr1["baa1"] = Convert.ToDouble(dt.Compute("Var(baa)", "1=1")); dr1["bab1"] = Convert.ToDouble(dt.Compute("Var(bab)", "1=1")); dr1["bac1"] = Convert.ToDouble(dt.Compute("Var(bac)", "1=1")); dr1["bba1"] = "<font color=" + (Convert.ToDouble(dt.Compute("Var(bba)", "1=1")) > Convert.ToDouble(dr1["baa1"]) ? "red" : "green") + ">" + Convert.ToDouble(dt.Compute("Var(bba)", "1=1")) + "</font>"; dr1["bbb1"] = "<font color=" + (Convert.ToDouble(dt.Compute("Var(bbb)", "1=1")) > Convert.ToDouble(dr1["bab1"]) ? "red" : "green") + ">" + Convert.ToDouble(dt.Compute("Var(bbb)", "1=1")) + "</font>"; dr1["bbc1"] = "<font color=" + (Convert.ToDouble(dt.Compute("Var(bbc)", "1=1")) > Convert.ToDouble(dr1["bac1"]) ? "red" : "green") + ">" + Convert.ToDouble(dt.Compute("Var(bbc)", "1=1")) + "</font>"; dt.Rows.Add(dr1); } JObject result = new JObject(); result.Add(new JProperty("success", true)); result.Add(new JProperty("totlalCount", dt.Rows.Count)); result.Add(new JProperty("data", JArray.FromObject(dt))); JsonStr = result.ToString(); } else { JsonStr = "{success:false,message:'请求数据异常!'}"; } } catch (Exception e) { JsonStr = "{success:false,message:'" + e.Message + "'}"; } }