public void FilterGroupTest() { FilterGroup group = new FilterGroup(); Assert.Equal(group.Operate, FilterOperate.And); Assert.NotEqual(group.Rules, null); Assert.NotEqual(group.Groups, null); }
public RegexMatches(FilterGroup parent_group, Regex regex) : base(parent_group) { m0 = regex.Match(parent_group.Text); if (!m0.Success) return; Reset(); }
public void Test_GetEntitiesByFilterGroup_EmptyGroup() { using (LogGroup logGroup = LogGroup.Start("Testing a simple query with the PropertyFilter.", NLog.LogLevel.Debug)) { TestUser user = new TestUser(); user.ID = Guid.NewGuid(); user.FirstName = "Test"; user.LastName = "User"; user.Username = "******"; TestRole role = new TestRole(); role.ID = Guid.NewGuid(); role.Name = "Test role"; user.Roles = new TestRole[]{role}; DataAccess.Data.Saver.Save(role); DataAccess.Data.Saver.Save(user); ReferenceFilter filter = (ReferenceFilter)DataAccess.Data.CreateReferenceFilter(); filter.PropertyName = "Roles"; filter.ReferencedEntityID = role.ID; filter.ReferenceType = role.GetType(); filter.AddType(typeof(TestUser)); PropertyFilter filter2 = (PropertyFilter)DataAccess.Data.CreatePropertyFilter(); filter2.PropertyName = "Username"; filter2.PropertyValue = user.Username; filter2.AddType(typeof(TestUser)); FilterGroup filterGroup = new FilterGroup(); // Leave empty by not adding filters //filterGroup.Add(filter); //filterGroup.Add(filter2); IEntity[] found = (IEntity[])DataAccess.Data.Indexer.GetEntities(filterGroup); Assert.IsNotNull(found, "Null value returned"); if (found != null) { Assert.IsTrue(found.Length > 0, "No results found."); if (found.Length > 0) { TestUser foundUser = (TestUser)found[0]; Assert.IsNotNull(foundUser, "foundUser == null"); Assert.AreEqual(user.ID, foundUser.ID, "The IDs don't match."); } } } }
public void GetExpressionTest() { IQueryable<TestEntity> source = Entities.AsQueryable(); //空条件 Expression<Func<TestEntity, bool>> predicate = FilterHelper.GetExpression<TestEntity>(); Assert.True(source.Where(predicate).SequenceEqual(source)); //单条件,属性不存在 FilterRule rule = new FilterRule("Name1", "5", FilterOperate.EndsWith); FilterRule rule1 = rule; Assert.Throws<InvalidOperationException>(() => FilterHelper.GetExpression<TestEntity>(rule1)); //单条件 rule = new FilterRule("Name", "5", FilterOperate.EndsWith); predicate = FilterHelper.GetExpression<TestEntity>(rule); Assert.True(source.Where(predicate).SequenceEqual(source.Where(m => m.Name.EndsWith("5")))); //二级条件 rule = new FilterRule("Name.Length", 5, FilterOperate.Greater); predicate = FilterHelper.GetExpression<TestEntity>(rule); Assert.True(source.Where(predicate).SequenceEqual(source.Where(m => m.Name.Length > 5))); //多条件,异常 Assert.Throws<InvalidOperationException>(() => new FilterGroup { Rules = new List<FilterRule> { rule, new FilterRule("IsDeleted", true) }, Operate = FilterOperate.Equal }); //多条件 FilterGroup group = new FilterGroup { Rules = new List<FilterRule> { rule, new FilterRule("IsDeleted", true) }, Operate = FilterOperate.And }; predicate = FilterHelper.GetExpression<TestEntity>(group); Assert.True(source.Where(predicate).SequenceEqual(source.Where(m => m.Name.Length > 5 && m.IsDeleted))); //条件组嵌套 DateTime dt = DateTime.Now; group = new FilterGroup { Rules = new List<FilterRule> { new FilterRule("AddDate", dt, FilterOperate.Greater) }, Groups = new List<FilterGroup> { group }, Operate = FilterOperate.Or }; predicate = FilterHelper.GetExpression<TestEntity>(group); Assert.True(source.Where(predicate).SequenceEqual(source.Where(m => m.AddDate > dt || m.Name.Length > 5 && m.IsDeleted))); }
public JsonMatches(FilterGroup parent_group, string json_path, bool trim_quotation) : base(parent_group) { json_path = Regex.Replace(json_path, @"\s+", ""); //json_path = Regex.Escape(json_path); json_path = Regex.Replace(json_path, @"\.", @"\."); //json_path = Regex.Replace(json_path, @"\[\*\]", @"[\d+]"); json_path = Regex.Replace(json_path, @"\[", @"\["); json_path = Regex.Replace(json_path, @"\]", @"\]"); json_path = Regex.Replace(json_path, @"\*", @".*?"); json_path = @"^" + json_path + @"$"; json_path_regex = new Regex(json_path, RegexOptions.IgnoreCase); //jt0 = new Newtonsoft.Json.Linq.JObject(parent_group.Text); Reset(); this.trim_quotation = trim_quotation; }
public AgileMatches(FilterGroup parent_group, string xpath) : base(parent_group) { HtmlAgilityPack.HtmlNodeCollection ns = null; //if (parent_group is AgileFilterGroup) //{ // ns = ((AgileFilterGroup)parent_group).HtmlNode.SelectNodes(Xpath); //} //else //{ HtmlAgilityPack.HtmlDocument d = new HtmlAgilityPack.HtmlDocument(); d.LoadHtml(parent_group.Text); ns = d.DocumentNode.SelectNodes(xpath); //} if (ns == null) return; node_enum = ns.AsEnumerable<HtmlAgilityPack.HtmlNode>().GetEnumerator(); }
/// <summary> /// Creates Windows filters /// </summary> /// <param name="group">The groups to create the filters for</param> /// <returns>Windows filters</returns> private static IEnumerable <string> CreateWindowsFilters(FilterGroup group) { if (group.HasFlag(FilterGroup.SystemFiles)) { yield return(FilterGroups.CreateWildcardFilter(@"*/I386*")); yield return(FilterGroups.CreateWildcardFilter(@"*/Internet Explorer/")); yield return(FilterGroups.CreateWildcardFilter(@"*/Microsoft*/RecoveryStore*")); yield return(FilterGroups.CreateWildcardFilter(@"*/Microsoft*/Windows/*.edb")); yield return(FilterGroups.CreateWildcardFilter(@"*/Microsoft*/Windows/*.log")); yield return(FilterGroups.CreateWildcardFilter(@"*/Microsoft*/Windows/Cookies*")); yield return(FilterGroups.CreateWildcardFilter(@"*/MSOCache*")); yield return(FilterGroups.CreateWildcardFilter(@"*/NTUSER*")); yield return(FilterGroups.CreateWildcardFilter(@"*/RECYCLER/")); yield return(FilterGroups.CreateWildcardFilter(@"*UsrClass.dat*")); yield return(FilterGroups.CreateWildcardFilter(@"?:/hiberfil.sys")); yield return(FilterGroups.CreateWildcardFilter(@"?:/pagefile.sys")); yield return(FilterGroups.CreateWildcardFilter(@"?:/swapfile.sys")); yield return(FilterGroups.CreateWildcardFilter(@"?:/System Volume Information/")); yield return(FilterGroups.CreateWildcardFilter(@"?:/Windows/Installer*")); yield return(FilterGroups.CreateWildcardFilter(@"?:/Windows/Temp*")); yield return(FilterGroups.CreateWildcardFilter(@"*/ntuser.dat*")); foreach (var s in GetWindowsRegistryFilters() ?? new string[0]) { // If this path refers to the root of a drive, then prepend it with "?:" since that's how Duplicati's root path matching works. if (s.StartsWith(@"\", StringComparison.Ordinal) || s.StartsWith("/", StringComparison.Ordinal)) { yield return("?:" + s); } else { yield return(s); } } } if (group.HasFlag(FilterGroup.OperatingSystem)) { yield return(FilterGroups.CreateWildcardFilter(@"?:/Config.Msi*")); // https://github.com/duplicati/duplicati/issues/2886 yield return(FilterGroups.CreateWildcardFilter(@"*/Recent/")); yield return(FilterGroups.CreateWildcardFilter(@"?:/autoexec.bat")); yield return(Environment.GetFolderPath(Environment.SpecialFolder.System)); yield return(Environment.GetFolderPath(Environment.SpecialFolder.SystemX86)); yield return(Environment.GetFolderPath(Environment.SpecialFolder.Windows)); yield return(Environment.GetFolderPath(Environment.SpecialFolder.Recent)); var windir = Environment.GetFolderPath(Environment.SpecialFolder.Windows); if (!string.IsNullOrWhiteSpace(windir)) { yield return(windir); // Also exclude "C:\Windows.old\" yield return(windir.TrimEnd('\\', '/') + ".old"); } } if (group.HasFlag(FilterGroup.CacheFiles)) { yield return(FilterGroups.CreateWildcardFilter(@"*/AppData/Local/AMD/DxCache/")); // Appears to be a shader cache folder for AMD video card drivers yield return(FilterGroups.CreateWildcardFilter(@"*/AppData/Local/Apple Computer/Mobile Sync/")); yield return(FilterGroups.CreateWildcardFilter(@"*/AppData/Local/Comms/UnistoreDB/")); // Looks like storage about music / pictures for universal store apps yield return(FilterGroups.CreateWildcardFilter(@"*/AppData/Local/ElevatedDiagnostics/")); // Seems to be used by sfc tool and Windows troubleshooting yield return(FilterGroups.CreateWildcardFilter(@"*/AppData/Local/Microsoft/VSCommon/*SQM*")); // SQM appears to be 'service quality management', and it looks like these files report things about Visual Studio installation: https://stackoverflow.com/questions/23050561/what-permissions-policies-are-needed-to-support-loaduserprofile-true-for-new-app yield return(FilterGroups.CreateWildcardFilter(@"*/AppData/Local/Microsoft/Windows/Explorer/")); // Stores icon and thumbnail caches yield return(FilterGroups.CreateWildcardFilter(@"*/AppData/Local/Microsoft/Windows/INetCache/")); // yield return(FilterGroups.CreateWildcardFilter(@"*/AppData/Local/Microsoft/Windows/UPPS/")); // Not sure what this one is, but seems to be a common one to fail to backup: http://support.wdc.com/knowledgebase/answer.aspx?ID=17969&lang=en yield return(FilterGroups.CreateWildcardFilter(@"*/AppData/Local/Microsoft/Windows/WebCache*")); yield return(FilterGroups.CreateWildcardFilter(@"*/AppData/Local/Microsoft/Windows Store/")); yield return(FilterGroups.CreateWildcardFilter(@"*/AppData/Local/Packages/")); // https://superuser.com/questions/490925/explain-windows-8-windows-store-appdata-packages-and-what-to-backup yield return(FilterGroups.CreateWildcardFilter(@"*/Application Data/Apple Computer/Mobile Sync/")); yield return(FilterGroups.CreateWildcardFilter(@"*/Application Data/Application Data*")); yield return(FilterGroups.CreateWildcardFilter(@"*/Dropbox/Dropbox.exe.log")); // Dropbox log file, which may be kept open by Dropbox while it is running yield return(FilterGroups.CreateWildcardFilter(@"*/Dropbox/QuitReports/")); yield return(FilterGroups.CreateWildcardFilter(@"*/Google/Chrome/User Data/Default/Cookies")); yield return(FilterGroups.CreateWildcardFilter(@"*/Google/Chrome/User Data/Default/Cookies-journal")); yield return(FilterGroups.CreateWildcardFilter(@"*/Local Settings/History/")); yield return(FilterGroups.CreateWildcardFilter(@"*/OneDrive/.849C9593-D756-4E56-8D6E-42412F2A707B")); // This looks like a hidden cache file for the OneDrive service: https://onedrive.uservoice.com/forums/262982-onedrive/suggestions/10059663-get-rid-of-undeleteable-849c9593-d756-4e56-8d6e yield return(FilterGroups.CreateWildcardFilter(@"*/Safari/Library/Caches/")); yield return(FilterGroups.CreateWildcardFilter(@"*/Temporary Internet Files/")); yield return(FilterGroups.CreateWildcardFilter(@"*/Thumbs.db")); yield return(Environment.GetFolderPath(Environment.SpecialFolder.History)); yield return(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)); yield return(Environment.GetFolderPath(Environment.SpecialFolder.Cookies)); } if (group.HasFlag(FilterGroup.TemporaryFiles)) { yield return(FilterGroups.CreateWildcardFilter(@"*/$RECYCLE.BIN/")); yield return(FilterGroups.CreateWildcardFilter(@"*.tmp")); yield return(FilterGroups.CreateWildcardFilter(@"*.tmp/")); yield return(FilterGroups.CreateWildcardFilter(@"*/AppData/Local/Temp*")); yield return(FilterGroups.CreateWildcardFilter(@"*/AppData/Temp*")); yield return(FilterGroups.CreateWildcardFilter(@"*/Local Settings/Temp*")); yield return(FilterGroups.CreateWildcardFilter(@"?:/Windows/Temp*")); } if (group.HasFlag(FilterGroup.Applications)) { yield return(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)); yield return(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)); yield return(Environment.GetFolderPath(Environment.SpecialFolder.AdminTools)); yield return(Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles)); yield return(Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFilesX86)); yield return(Environment.GetFolderPath(Environment.SpecialFolder.CommonAdminTools)); } }
/// <summary> /// 初始化一个<see cref="EntityRoleInputDtoBase{TRoleKey}"/>类型的新实例 /// </summary> protected EntityRoleInputDtoBase() { FilterGroup = new FilterGroup(); }
/// <summary> /// Gets the list of alternate aliases which can refer to this group. /// </summary> /// <param name="group">Filter group</param> /// <returns>Group aliases</returns> public static IEnumerable <string> GetAliases(FilterGroup group) { return(FilterGroups.filterGroupAliases.Where(pair => pair.Value == group).Select(pair => pair.Key)); }
public override FilterMatchCollection Matches(FilterGroup parent_group) { return new AgileMatches(parent_group, Xpath); }
private void CutoffSlope_Changed(object sender, RoutedPropertyChangedEventArgs <double> e) { FilterGroup.ChangeCutoffSlope((float)slider_cutoffSlope.Value); }
public FilterGroup Barn() { var barn = new FilterGroup() { Name = GrunndataPersonFilterConst.BarnName, BelongsTo = (int)FilterBelonging.Preg, IsCustome = true, Type = FilterDisplayTypes.Children }; int previousAlder = -1; string previousFilter = ""; foreach (var alder in QuantifyAge.Quants.Keys) { if (previousAlder == -1) { barn.Items.Add(GrunndataFilterItem.GetFilterItem(GrunndataPersonFilterConst.HarBarn, GrunndataPersonFilterConst.HarBarn, GrunndataPersonFilterConst.BarnName, filterString: "barn/any()", displayName: "Har barn")); previousAlder = alder; previousFilter = QuantifyAge.Quants[alder]; continue; } var name = $"{previousAlder} til {alder}"; barn.Items.Add(GrunndataFilterItem.GetFilterItem(name, GrunndataPersonFilterConst.HarBarn + previousFilter, GrunndataPersonFilterConst.BarnName, filterString: $"barn/any(t: t eq '{previousFilter}')", displayName: "Har barn i alder " + name)); previousAlder = alder; previousFilter = QuantifyAge.Quants[alder]; } barn.Items.Add(GrunndataFilterItem.GetFilterItem("Fra og med" + previousAlder, GrunndataPersonFilterConst.HarBarn + previousFilter, GrunndataPersonFilterConst.BarnName, filterString: $"barn/any(t: t eq '{previousFilter}')", displayName: "Har barn eldre enn " + previousAlder)); barn.Items.Add(GrunndataFilterItem.GetFilterItem(GrunndataPersonFilterConst.HarIkkeBarn, GrunndataPersonFilterConst.HarIkkeBarn, GrunndataPersonFilterConst.BarnName, filterString: "not barn/any()", displayName: "Har ikke barn")); var foreldrerettGroupName = "Foreldrerett for barn"; var foreldrerettGroup = new FilterGroup() { BelongsTo = (int)FilterBelonging.Preg, Name = foreldrerettGroupName, IsCustome = true }; var noforeldrerettGroupName = "Ikke foreldrerett for barn"; var noforeldrerettGroup = new FilterGroup() { BelongsTo = (int)FilterBelonging.Preg, Name = noforeldrerettGroupName, IsCustome = true }; previousAlder = -1; previousFilter = ""; foreach (var alder in QuantifyAge.Quants.Keys) { if (previousAlder == -1) { foreldrerettGroup.Items.Add(GrunndataFilterItem.GetFilterItem("I alle aldere", foreldrerettGroupName, foreldrerettGroupName, filterString: "barnForeldrerett/any()", displayName: "Har foreldreansvar")); noforeldrerettGroup.Items.Add(GrunndataFilterItem.GetFilterItem("I alle aldere", noforeldrerettGroupName, noforeldrerettGroupName, filterString: "barnUtenForeldrerett/any()", displayName: "Har ikke foreldreansvar")); previousAlder = alder; previousFilter = QuantifyAge.Quants[alder]; continue; } var name = $"{previousAlder} til {alder}"; foreldrerettGroup.Items.Add(GrunndataFilterItem.GetFilterItem(name, foreldrerettGroupName + previousFilter, foreldrerettGroupName, filterString: $"barnForeldrerett/any(t: t eq '{previousFilter}')", displayName: "Har foreldreansvar for barn i alder " + name)); noforeldrerettGroup.Items.Add(GrunndataFilterItem.GetFilterItem(name, noforeldrerettGroupName + previousFilter, noforeldrerettGroupName, filterString: $"barnUtenForeldrerett/any(t: t eq '{previousFilter}')", displayName: "Har ikke foreldreansvar for barn i alder " + name)); previousAlder = alder; previousFilter = QuantifyAge.Quants[alder]; } foreldrerettGroup.Items.Add(GrunndataFilterItem.GetFilterItem($"Alder fra og med {previousAlder}", foreldrerettGroupName, foreldrerettGroupName, filterString: $"barnForeldrerett/any(t: t eq '{previousFilter}')")); noforeldrerettGroup.Items.Add(GrunndataFilterItem.GetFilterItem($"Alder fra og med {previousAlder}", noforeldrerettGroupName, noforeldrerettGroupName, filterString: $"barnUtenForeldrerett/any(t: t eq '{previousFilter}')")); barn.Groups.Add(foreldrerettGroup); barn.Groups.Add(noforeldrerettGroup); foreldrerettGroup.Items.ForEach(i => _flatReferenceDic.Add(i.UniqueValue, i)); noforeldrerettGroup.Items.ForEach(i => _flatReferenceDic.Add(i.UniqueValue, i)); barn.Items.ForEach(i => _flatReferenceDic.Add(i.UniqueValue, i)); return(barn); }
//public static System.Diagnostics.Stopwatch Watch = new System.Diagnostics.Stopwatch(); void parse(Capture parent_capture, FilterGroup parent_filter_group, Filter filter) { foreach (FilterMatch fm in filter.Matches(parent_filter_group)) { for (int group_i = 0; group_i < fm.Groups.Count; group_i++) { FilterGroup fg = fm.Groups[group_i]; if (DisplayMode) SourceForm.This.AddCaptureLabel(fg.Index, fg.Length, filter.Level, group_i, filter.GetGroupRawNameByIndex(group_i), fm.Groups.Count); Capture gc = null; string output_gn = filter.GetGroupNameByIndex(group_i); if (output_gn != null) {//it is named group //get named groups gc = new Capture(output_gn, fg.Text, fg.Index, filter.group_name2child_filters_group_names[output_gn]); parent_capture.AddChildGroupCapture(gc); } string grn = filter.GetGroupRawNameByIndex(group_i); foreach (Filter child_f in filter.Next) { if (grn != child_f.InputGroupName) continue; if (gc != null)//it is output(named) group parse(gc, fg, child_f); else parse(parent_capture, fg, child_f); } } } }
/// <summary> /// 获取指定实体的数据权限过滤表达式 /// </summary> /// <typeparam name="T">实体类型</typeparam> /// <param name="operation">数据权限操作</param> /// <param name="group">传入的查询条件组,为空时则只返回数据权限过滤器</param> /// <returns>实体的数据权限过滤表达式</returns> public Expression <Func <T, bool> > GetDataFilter <T>(DataAuthOperation operation, FilterGroup group = null) { Expression <Func <T, bool> > exp = m => true; if (group != null) { exp = FilterService.GetExpression <T>(group); } //从缓存中查找当前用户的角色与实体T的过滤条件 ClaimsPrincipal user = CurrentUser; if (user == null) { return(exp); } IDataAuthCache dataAuthCache = DataAuthCache; if (dataAuthCache == null) { return(exp); } // 要判断数据权限功能,先要排除没有执行当前功能权限的角色,判断剩余角色的数据权限 ScopedDictionary scopedDict = ScopedDictionary; string[] roleNames = user.Identity.GetRoles(); if (scopedDict?.Function != null) { roleNames = scopedDict.DataAuthValidRoleNames; } string typeName = typeof(T).GetFullNameWithModule(); Expression <Func <T, bool> > subExp = null; foreach (string roleName in roleNames) { FilterGroup subGroup = dataAuthCache.GetFilterGroup(roleName, typeName, operation); if (subGroup == null) { continue; } subExp = subExp == null?FilterService.GetExpression <T>(subGroup) : subExp.Or(FilterService.GetExpression <T>(subGroup)); } if (subExp != null) { if (group == null) { return(subExp); } exp = subExp.And(exp); } return(exp); }
/// <summary> /// Creates the filter control. /// </summary> /// <param name="parentControl">The parent control.</param> /// <param name="filter">The filter.</param> /// <param name="filteredEntityTypeName">Name of the filtered entity type.</param> /// <param name="setSelection">if set to <c>true</c> [set selection].</param> /// <param name="rockContext">The rock context.</param> private void CreateFilterControl(Control parentControl, DataViewFilter filter, string filteredEntityTypeName, bool setSelection, RockContext rockContext) { try { if (filter.ExpressionType == FilterExpressionType.Filter) { var filterControl = new FilterField(); parentControl.Controls.Add(filterControl); filterControl.DataViewFilterGuid = filter.Guid; filterControl.ID = string.Format("ff_{0}", filterControl.DataViewFilterGuid.ToString("N")); filterControl.FilteredEntityTypeName = filteredEntityTypeName; if (filter.EntityTypeId.HasValue) { var entityTypeCache = Rock.Web.Cache.EntityTypeCache.Read(filter.EntityTypeId.Value, rockContext); if (entityTypeCache != null) { filterControl.FilterEntityTypeName = entityTypeCache.Name; } } filterControl.Expanded = filter.Expanded; if (setSelection) { try { filterControl.SetSelection(filter.Selection); } catch (Exception ex) { this.LogException(new Exception("Exception setting selection for DataViewFilter: " + filter.Guid, ex)); } } filterControl.DeleteClick += filterControl_DeleteClick; } else { var groupControl = new FilterGroup(); parentControl.Controls.Add(groupControl); groupControl.DataViewFilterGuid = filter.Guid; groupControl.ID = string.Format("fg_{0}", groupControl.DataViewFilterGuid.ToString("N")); groupControl.FilteredEntityTypeName = filteredEntityTypeName; groupControl.IsDeleteEnabled = parentControl is FilterGroup; if (setSelection) { groupControl.FilterType = filter.ExpressionType; } groupControl.AddFilterClick += groupControl_AddFilterClick; groupControl.AddGroupClick += groupControl_AddGroupClick; groupControl.DeleteGroupClick += groupControl_DeleteGroupClick; foreach (var childFilter in filter.ChildFilters) { CreateFilterControl(groupControl, childFilter, filteredEntityTypeName, setSelection, rockContext); } } } catch (Exception ex) { this.LogException(new Exception("Exception creating FilterControl for DataViewFilter: " + filter.Guid, ex)); } }
/// <summary> /// Creates the filter control. /// </summary> /// <param name="parentControl">The parent control.</param> /// <param name="filter">The filter.</param> /// <param name="reportEntityType">Type of the report entity.</param> /// <param name="filteredEntityTypeName">Name of the filtered entity type.</param> /// <param name="setSelection">if set to <c>true</c> [set selection].</param> /// <param name="selectedDataFieldGuids">The selected data field guids.</param> /// <param name="configurableDataFieldGuids">The configurable data field guids.</param> /// <param name="rockContext">The rock context.</param> private void CreateFilterControl( Control parentControl, DataViewFilter filter, EntityType reportEntityType, bool setSelection, List <Guid> selectedDataFieldGuids, List <Guid> configurableDataFieldGuids, List <Guid> togglableDataFieldGuids, RockContext rockContext) { try { var filteredEntityTypeName = EntityTypeCache.Read(reportEntityType).Name; if (filter.ExpressionType == FilterExpressionType.Filter) { var filterControl = new FilterField(); filterControl.FilterMode = FilterMode.SimpleFilter; bool filterIsVisible = selectedDataFieldGuids.Contains(filter.Guid); bool filterIsConfigurable = configurableDataFieldGuids.Contains(filter.Guid); bool showCheckbox = togglableDataFieldGuids.Contains(filter.Guid) || !filterIsConfigurable; filterControl.Visible = filterIsVisible; parentControl.Controls.Add(filterControl); filterControl.DataViewFilterGuid = filter.Guid; filterControl.HideFilterCriteria = !filterIsConfigurable; filterControl.ID = string.Format("ff_{0}", filterControl.DataViewFilterGuid.ToString("N")); filterControl.FilteredEntityTypeName = filteredEntityTypeName; if (filter.EntityTypeId.HasValue) { var entityTypeCache = Rock.Web.Cache.EntityTypeCache.Read(filter.EntityTypeId.Value, rockContext); if (entityTypeCache != null) { filterControl.FilterEntityTypeName = entityTypeCache.Name; } } filterControl.Expanded = true; filterControl.ShowCheckbox = filterIsVisible && showCheckbox; var reportEntityTypeCache = EntityTypeCache.Read(reportEntityType); var reportEntityTypeModel = reportEntityTypeCache.GetEntityType(); var filterEntityType = EntityTypeCache.Read(filter.EntityTypeId ?? 0); var component = Rock.Reporting.DataFilterContainer.GetComponent(filterEntityType.Name); if (component != null) { string selectionUserPreference = null; bool? checkedUserPreference = null; if (setSelection && filterIsVisible && filterIsConfigurable) { selectionUserPreference = this.GetUserPreference(string.Format("{0}_{1}_Selection", GetReportDataKeyPrefix(), filterControl.DataViewFilterGuid.ToString("N"))); } else if (setSelection && filterIsVisible && !filterIsConfigurable) { checkedUserPreference = this.GetUserPreference(string.Format("{0}_{1}_Checked", GetReportDataKeyPrefix(), filterControl.DataViewFilterGuid.ToString("N"))).AsBooleanOrNull(); } if (checkedUserPreference.HasValue) { filterControl.SetCheckBoxChecked(checkedUserPreference.Value); } if (filterIsVisible && !filterIsConfigurable) { // not configurable so just label it with the selection summary filterControl.Label = component.FormatSelection(reportEntityTypeModel, filter.Selection); } else if (component is Rock.Reporting.DataFilter.PropertyFilter) { // a configurable property filter var propertyFilter = component as Rock.Reporting.DataFilter.PropertyFilter; if (setSelection) { var selection = filter.Selection; if (!string.IsNullOrWhiteSpace(selectionUserPreference)) { selection = propertyFilter.UpdateSelectionFromUserPreferenceSelection(selection, selectionUserPreference); } selection = propertyFilter.UpdateSelectionFromPageParameters(selection, this); try { filterControl.SetSelection(selection); } catch (Exception ex) { this.LogException(new Exception("Exception setting selection for DataViewFilter: " + filter.Guid, ex)); } } } else { if (setSelection) { var selection = filter.Selection; if (!string.IsNullOrWhiteSpace(selectionUserPreference)) { selection = selectionUserPreference; } if (component is Rock.Reporting.DataFilter.IUpdateSelectionFromPageParameters) { selection = (component as Rock.Reporting.DataFilter.IUpdateSelectionFromPageParameters).UpdateSelectionFromPageParameters(selection, this); } filterControl.SetSelection(selection); try { filterControl.SetSelection(selection); } catch (Exception ex) { this.LogException(new Exception("Exception setting selection for DataViewFilter: " + filter.Guid, ex)); } } // a configurable data filter filterControl.Label = component.GetTitle(reportEntityTypeModel); } } } else { var groupControl = new FilterGroup(); parentControl.Controls.Add(groupControl); groupControl.DataViewFilterGuid = filter.Guid; groupControl.ID = string.Format("fg_{0}", groupControl.DataViewFilterGuid.ToString("N")); groupControl.FilteredEntityTypeName = filteredEntityTypeName; groupControl.IsDeleteEnabled = false; groupControl.HidePanelHeader = true; if (setSelection) { groupControl.FilterType = filter.ExpressionType; } foreach (var childFilter in filter.ChildFilters) { CreateFilterControl(groupControl, childFilter, reportEntityType, setSelection, selectedDataFieldGuids, configurableDataFieldGuids, togglableDataFieldGuids, rockContext); } } } catch (Exception ex) { this.LogException(new Exception("Exception creating FilterControl for DataViewFilter: " + filter.Guid, ex)); } }
Tuple <Point3DCollection, Point3DCollection> GetDepthData(MultiSourceFrame frame) { byte[] array = null; // filter background with bodyIndex using (BodyIndexFrame bodyIndexFrame = frame.BodyIndexFrameReference.AcquireFrame()) { if (bodyIndexFrame != null) { var description = bodyIndexFrame.FrameDescription; array = new byte[description.Width * description.Height]; bodyIndexFrame.CopyFrameDataToArray(array); } } var depthFrameReference = frame.DepthFrameReference; var depthFrame = depthFrameReference.AcquireFrame(); if (depthFrame == null) { return(null); } int height = depthFrame.FrameDescription.Height; int width = depthFrame.FrameDescription.Width; CameraSpacePoint[] depth2xyz = new CameraSpacePoint[height * width]; CameraSpacePoint shoulderPos = new CameraSpacePoint(); BBox box = new BBox(); Point3DCollection result = new Point3DCollection(); using (var bodyFrame = frame.BodyFrameReference.AcquireFrame()) { if (frame != null) { var bodies = new Body[bodyFrame.BodyFrameSource.BodyCount]; bodyFrame.GetAndRefreshBodyData(bodies); foreach (var body in bodies) { if (body != null) { if (body.IsTracked) { // Find the joints Joint thumbRight = body.Joints[JointType.ThumbRight]; Joint thumbLeft = body.Joints[JointType.ThumbLeft]; // Tip Joint tipRight = body.Joints[JointType.HandTipRight]; Joint tipLeft = body.Joints[JointType.HandTipLeft]; Joint handRight = body.Joints[JointType.HandRight]; Joint handLeft = body.Joints[JointType.HandLeft]; // elbow Joint elbowLeft = body.Joints[JointType.ElbowLeft]; // shoulder shoulderPos = body.Joints[JointType.ShoulderLeft].Position; tipLeft.Position = FilterGroup.GetFilter(FilterGroup.Description.Fingertip).Filter(tipLeft.Position); handLeft.Position = FilterGroup.GetFilter(FilterGroup.Description.Hand).Filter(handLeft.Position); thumbLeft.Position = FilterGroup.GetFilter(FilterGroup.Description.ThumbTip).Filter(thumbLeft.Position); elbowLeft.Position = FilterGroup.GetFilter(FilterGroup.Description.Elbow).Filter(elbowLeft.Position); result = new Point3DCollection { Parser3DPoint.FromCameraSpaceToPoint3D(handLeft.Position), Parser3DPoint.FromCameraSpaceToPoint3D(tipLeft.Position), Parser3DPoint.FromCameraSpaceToPoint3D(thumbLeft.Position), Parser3DPoint.FromCameraSpaceToPoint3D(elbowLeft.Position) }; //box.Extend(Parser3DPoint.FromCameraSpaceToPoint3D(shoulderPos)); box.Extend(Parser3DPoint.FromCameraSpaceToPoint3D(elbowLeft.Position)); box.Extend(Parser3DPoint.FromCameraSpaceToPoint3D(handLeft.Position)); box.Extend(Parser3DPoint.FromCameraSpaceToPoint3D(tipLeft.Position)); box.Extend(Parser3DPoint.FromCameraSpaceToPoint3D(thumbLeft.Position)); var vector = new Vector3D { X = tipRight.Position.X - handRight.Position.X, Y = tipRight.Position.Y - handRight.Position.Y, Z = tipRight.Position.Z - handRight.Position.Z }; vector.Normalize(); var tipR = tipRight.Position; } } } } } ushort[] depthFrameData = new ushort[height * width]; depthFrame.CopyFrameDataToArray(depthFrameData); var radius = 0.08f; // Process depth frame data... cM.MapDepthFrameToCameraSpace(depthFrameData, depth2xyz); for (int i = 0; i < depthFrameData.Length; i++) { //filter everything around the box if (array[i] == 255 || (box.GetMaxPoint().Z + radius) < depth2xyz[i].Z || (box.GetMaxPoint().Y + radius) < depth2xyz[i].Y || (box.GetMaxPoint().X + radius) < depth2xyz[i].X || (box.GetMinPoint().Z - radius) > depth2xyz[i].Z || (box.GetMinPoint().Y - radius) > depth2xyz[i].Y || (box.GetMinPoint().X - radius) > depth2xyz[i].X ) { depth2xyz[i].Z = -10000; } } /* * var boxCloud = new Point3DCollection * { * box.GetMinPoint(), * box.GetMaxPoint() * }; * * renderer.CreatePointCloud(boxCloud, Brushes.DeepPink,false, 0.0235f); */ return(new Tuple <Point3DCollection, Point3DCollection>(Parser3DPoint.FromCameraSpaceToPoint3DCollection(depth2xyz, height * width), result)); }
public async Task GetFootnote() { var release = new Release(); var subject = new Subject(); var filter = new Filter { Label = "Test filter 1" }; var filterGroup = new FilterGroup { Filter = filter, Label = "Test filter group 1" }; var filterItem = new FilterItem { Label = "Test filter item 1", FilterGroup = filterGroup }; var indicator = new Indicator { Label = "Test indicator 1", IndicatorGroup = new IndicatorGroup() }; var footnote = new Footnote { Content = "Test footnote", Releases = new List <ReleaseFootnote> { new ReleaseFootnote { Release = release }, }, Subjects = new List <SubjectFootnote> { new SubjectFootnote { Subject = subject } }, Filters = new List <FilterFootnote> { new FilterFootnote { Filter = filter } }, FilterGroups = new List <FilterGroupFootnote> { new FilterGroupFootnote { FilterGroup = filterGroup } }, FilterItems = new List <FilterItemFootnote> { new FilterItemFootnote { FilterItem = filterItem } }, Indicators = new List <IndicatorFootnote> { new IndicatorFootnote { Indicator = indicator } }, }; var contextId = Guid.NewGuid().ToString(); await using (var statisticsDbContext = InMemoryStatisticsDbContext(contextId)) await using (var contentDbContext = InMemoryApplicationDbContext(contextId)) { await statisticsDbContext.AddAsync(release); await statisticsDbContext.AddAsync(footnote); await statisticsDbContext.SaveChangesAsync(); await contentDbContext.AddAsync(new Content.Model.Release { Id = release.Id }); await contentDbContext.SaveChangesAsync(); } await using (var statisticsDbContext = InMemoryStatisticsDbContext(contextId)) await using (var contentDbContext = InMemoryApplicationDbContext(contextId)) { var service = SetupFootnoteService(statisticsDbContext, contentDbContext: contentDbContext); var result = await service.GetFootnote(release.Id, footnote.Id); Assert.True(result.IsRight); Assert.Equal(footnote.Id, result.Right.Id); Assert.Equal("Test footnote", result.Right.Content); Assert.Single(result.Right.Releases); Assert.Equal(release.Id, result.Right.Releases.First().ReleaseId); Assert.Single(result.Right.Subjects); Assert.Equal(subject.Id, result.Right.Subjects.First().SubjectId); Assert.Single(result.Right.Filters); Assert.Equal(filter.Id, result.Right.Filters.First().Filter.Id); Assert.Equal(filter.Label, result.Right.Filters.First().Filter.Label); Assert.Single(result.Right.FilterGroups); Assert.Equal(filterGroup.Id, result.Right.FilterGroups.First().FilterGroup.Id); Assert.Equal(filterGroup.Label, result.Right.FilterGroups.First().FilterGroup.Label); Assert.Single(result.Right.FilterItems); Assert.Equal(filterItem.Id, result.Right.FilterItems.First().FilterItem.Id); Assert.Equal(filterItem.Label, result.Right.FilterItems.First().FilterItem.Label); Assert.Single(result.Right.Indicators); Assert.Equal(indicator.Id, result.Right.Indicators.First().Indicator.Id); Assert.Equal(indicator.Label, result.Right.Indicators.First().Indicator.Label); } }
public async Task CopyFootnotes() { var release = new Release(); var amendment = new Release(); var subject = new Subject(); var filter = new Filter { Label = "Test filter 1" }; var filterGroup = new FilterGroup { Filter = filter, Label = "Test filter group 1" }; var filterItem = new FilterItem { Label = "Test filter item 1", FilterGroup = filterGroup }; var indicator = new Indicator { Label = "Test indicator 1", IndicatorGroup = new IndicatorGroup() }; var footnote1 = new Footnote { Content = "Test footnote 1", Releases = new List <ReleaseFootnote> { new ReleaseFootnote { Release = release }, }, Subjects = new List <SubjectFootnote> { new SubjectFootnote { Subject = subject } }, Filters = new List <FilterFootnote> { new FilterFootnote { Filter = filter } }, FilterGroups = new List <FilterGroupFootnote> { new FilterGroupFootnote { FilterGroup = filterGroup } }, FilterItems = new List <FilterItemFootnote> { new FilterItemFootnote { FilterItem = filterItem } }, Indicators = new List <IndicatorFootnote> { new IndicatorFootnote { Indicator = indicator } } }; var footnote2 = new Footnote { Content = "Test footnote 2", Releases = new List <ReleaseFootnote> { new ReleaseFootnote { Release = release }, }, Subjects = new List <SubjectFootnote> { new SubjectFootnote { Subject = subject } }, Filters = new List <FilterFootnote>(), FilterGroups = new List <FilterGroupFootnote>(), FilterItems = new List <FilterItemFootnote>(), Indicators = new List <IndicatorFootnote>() }; var contextId = Guid.NewGuid().ToString(); await using (var statisticsDbContext = InMemoryStatisticsDbContext(contextId)) await using (var contentDbContext = InMemoryApplicationDbContext(contextId)) { await statisticsDbContext.AddRangeAsync(release, amendment); await statisticsDbContext.AddRangeAsync(footnote1, footnote2); await statisticsDbContext.SaveChangesAsync(); await contentDbContext.AddRangeAsync(new Content.Model.Release { Id = release.Id }, new Content.Model.Release { Id = amendment.Id }); await contentDbContext.SaveChangesAsync(); } await using (var statisticsDbContext = InMemoryStatisticsDbContext(contextId)) await using (var contentDbContext = InMemoryApplicationDbContext(contextId)) { var footnoteRepository = new Mock <IFootnoteRepository>(Strict); footnoteRepository .Setup(s => s.GetFootnotes(release.Id)) .Returns(new List <Footnote> { footnote1, footnote2 }); var newFootnote1 = new Footnote { Id = Guid.NewGuid(), Releases = new List <ReleaseFootnote> { new ReleaseFootnote { ReleaseId = amendment.Id } } }; var newFootnote2 = new Footnote { Id = Guid.NewGuid(), Releases = new List <ReleaseFootnote> { new ReleaseFootnote { ReleaseId = amendment.Id } } }; footnoteRepository .Setup(s => s.GetFootnote(newFootnote1.Id)) .ReturnsAsync(newFootnote1); footnoteRepository .Setup(s => s.GetFootnote(newFootnote2.Id)) .ReturnsAsync(newFootnote2); var guidGenerator = new Mock <IGuidGenerator>(); guidGenerator .SetupSequence(s => s.NewGuid()) .Returns(newFootnote1.Id) .Returns(newFootnote2.Id); var service = SetupFootnoteService( statisticsDbContext, contentDbContext, footnoteRepository: footnoteRepository.Object, guidGenerator: guidGenerator.Object); var result = await service.CopyFootnotes(release.Id, amendment.Id); Assert.True(result.IsRight); Assert.Equal(2, result.Right.Count); Assert.Contains(newFootnote1, result.Right); Assert.Contains(newFootnote2, result.Right); MockUtils.VerifyAllMocks(footnoteRepository); } await using (var statisticsDbContext = InMemoryStatisticsDbContext(contextId)) { var newFootnotesFromDb = statisticsDbContext .Footnote .Include(f => f.Filters) .Include(f => f.FilterGroups) .Include(f => f.FilterItems) .Include(f => f.Releases) .Include(f => f.Subjects) .Include(f => f.Indicators) .Where(f => f.Releases. FirstOrDefault(r => r.ReleaseId == amendment.Id) != null) .OrderBy(f => f.Content) .ToList(); Assert.Equal(2, newFootnotesFromDb.Count); AssertFootnoteDetailsCopiedCorrectly(footnote1, newFootnotesFromDb[0]); AssertFootnoteDetailsCopiedCorrectly(footnote2, newFootnotesFromDb[1]); } void AssertFootnoteDetailsCopiedCorrectly(Footnote originalFootnote, Footnote newFootnote) { Assert.Equal(newFootnote.Content, originalFootnote.Content); Assert.Equal( originalFootnote .Filters .SelectNullSafe(f => f.FilterId) .ToList(), newFootnote .Filters .SelectNullSafe(f => f.FilterId) .ToList()); Assert.Equal( originalFootnote .FilterGroups .SelectNullSafe(f => f.FilterGroupId) .ToList(), newFootnote .FilterGroups .SelectNullSafe(f => f.FilterGroupId) .ToList()); Assert.Equal( originalFootnote .FilterItems .SelectNullSafe(f => f.FilterItemId) .ToList(), newFootnote .FilterItems .SelectNullSafe(f => f.FilterItemId) .ToList()); Assert.Equal( originalFootnote .Subjects .SelectNullSafe(f => f.SubjectId) .ToList(), newFootnote .Subjects .SelectNullSafe(f => f.SubjectId) .ToList()); Assert.Equal( originalFootnote .Indicators .SelectNullSafe(f => f.IndicatorId) .ToList(), newFootnote .Indicators .SelectNullSafe(f => f.IndicatorId) .ToList()); } }
/// <summary> /// Creates the filter control. /// </summary> /// <param name="parentControl">The parent control.</param> /// <param name="filter">The filter.</param> /// <param name="setSelection">if set to <c>true</c> [set selection].</param> /// <param name="rockContext">The rock context.</param> private void CreateFilterControl(Control parentControl, DataViewFilter filter, bool setSelection, RockContext rockContext) { try { if (filter.ExpressionType == FilterExpressionType.Filter) { var filterControl = new FilterField(); parentControl.Controls.Add(filterControl); filterControl.DataViewFilterGuid = filter.Guid; filterControl.ID = string.Format("ff_{0}", filterControl.DataViewFilterGuid.ToString("N")); // Remove the 'Other Data View' Filter as it doesn't really make sense to have it available in this scenario filterControl.ExcludedFilterTypes = new string[] { typeof(Rock.Reporting.DataFilter.OtherDataViewFilter).FullName }; filterControl.FilteredEntityTypeName = ITEM_TYPE_NAME; if (filter.EntityTypeId.HasValue) { var entityTypeCache = Rock.Web.Cache.EntityTypeCache.Read(filter.EntityTypeId.Value, rockContext); if (entityTypeCache != null) { filterControl.FilterEntityTypeName = entityTypeCache.Name; } } filterControl.Expanded = filter.Expanded; if (setSelection) { try { filterControl.SetSelection(filter.Selection); } catch (Exception ex) { this.LogException(new Exception("Exception setting selection for DataViewFilter: " + filter.Guid, ex)); } } filterControl.DeleteClick += filterControl_DeleteClick; } else { var groupControl = new FilterGroup(); parentControl.Controls.Add(groupControl); groupControl.DataViewFilterGuid = filter.Guid; groupControl.ID = string.Format("fg_{0}", groupControl.DataViewFilterGuid.ToString("N")); groupControl.FilteredEntityTypeName = ITEM_TYPE_NAME; groupControl.IsDeleteEnabled = parentControl is FilterGroup; if (setSelection) { groupControl.FilterType = filter.ExpressionType; } groupControl.AddFilterClick += groupControl_AddFilterClick; groupControl.AddGroupClick += groupControl_AddGroupClick; groupControl.DeleteGroupClick += groupControl_DeleteGroupClick; foreach (var childFilter in filter.ChildFilters) { CreateFilterControl(groupControl, childFilter, setSelection, rockContext); } } } catch (Exception ex) { this.LogException(new Exception("Exception creating FilterControl for DataViewFilter: " + filter.Guid, ex)); } }
/// <summary> /// Creates OSX filters /// </summary> /// <param name="group">The groups to create the filters for</param> /// <returns>OSX filters</returns> private static IEnumerable <string> CreateOSXFilters(FilterGroup group) { if (group.HasFlag(FilterGroup.SystemFiles)) { yield return(FilterGroups.CreateWildcardFilter(@"/.vol/")); yield return(FilterGroups.CreateWildcardFilter(@"/dev/")); yield return(FilterGroups.CreateWildcardFilter(@"/net/")); yield return(FilterGroups.CreateWildcardFilter(@"/afs/")); yield return(FilterGroups.CreateWildcardFilter(@"/automount/")); yield return(FilterGroups.CreateWildcardFilter(@"/cores/")); yield return(FilterGroups.CreateWildcardFilter(@"/Network/")); yield return(FilterGroups.CreateWildcardFilter(@"*.fseventsd")); yield return(FilterGroups.CreateWildcardFilter(@"*.dbfseventsd")); yield return(FilterGroups.CreateWildcardFilter(@"/private/Network/")); yield return(FilterGroups.CreateWildcardFilter(@"/private/var/automount/")); yield return(FilterGroups.CreateWildcardFilter(@"/private/var/db/dhcpclient/")); yield return(FilterGroups.CreateWildcardFilter(@"/private/var/db/fseventsd/")); yield return(FilterGroups.CreateWildcardFilter(@"/private/var/folders/")); yield return(FilterGroups.CreateWildcardFilter(@"/private/var/run/")); yield return(FilterGroups.CreateWildcardFilter(@"/private/var/spool/postfix/")); yield return(FilterGroups.CreateWildcardFilter(@"/private/var/vm/")); foreach (var p in GetOSXExcludeFiles() ?? new string[0]) { yield return(p); } } if (group.HasFlag(FilterGroup.OperatingSystem)) { yield return(FilterGroups.CreateWildcardFilter(@"/Previous Systems*")); yield return(FilterGroups.CreateWildcardFilter(@"/mach.sym")); yield return(FilterGroups.CreateWildcardFilter(@"/mach_kernel")); yield return(FilterGroups.CreateWildcardFilter(@"/bin/")); yield return(FilterGroups.CreateWildcardFilter(@"/sbin/")); yield return(FilterGroups.CreateWildcardFilter(@"*/Library/Logs/")); yield return(FilterGroups.CreateWildcardFilter(@"/Network/")); yield return(FilterGroups.CreateWildcardFilter(@"/System/")); yield return(FilterGroups.CreateWildcardFilter(@"/Volumes/")); } if (group.HasFlag(FilterGroup.CacheFiles)) { yield return(FilterGroups.CreateWildcardFilter(@"*/Application Support/Google/Chrome/Default/Cookies")); yield return(FilterGroups.CreateWildcardFilter(@"*/Application Support/Google/Chrome/Default/Cookies-journal")); yield return(FilterGroups.CreateWildcardFilter(@"*/Library/Caches/")); yield return(FilterGroups.CreateWildcardFilter(@"*/Library/Calendars/*/Info.plist")); yield return(FilterGroups.CreateWildcardFilter(@"*/Library/Calendars/Calendar Cache")); yield return(FilterGroups.CreateWildcardFilter(@"*/Library/Cookies/com.apple.appstore.plist")); yield return(FilterGroups.CreateWildcardFilter(@"*/Library/Cookies/Cookies.binarycookies")); yield return(FilterGroups.CreateWildcardFilter(@"*/backups.backupdb/")); yield return(FilterGroups.CreateWildcardFilter(@"*/iP* Software Updates/")); yield return(FilterGroups.CreateWildcardFilter(@"*/iPhoto Library/iPod Photo Cache*")); yield return(FilterGroups.CreateWildcardFilter(@"*/iTunes/Album Artwork/Cache/")); yield return(FilterGroups.CreateWildcardFilter(@"*/Library/Application Support/SyncServices/")); yield return(FilterGroups.CreateWildcardFilter(@"*/Library/Mail/*/Info.plist")); yield return(FilterGroups.CreateWildcardFilter(@"*/Library/Mail/AvailableFeeds/")); yield return(FilterGroups.CreateWildcardFilter(@"*/Library/Mail/Envelope Index")); yield return(FilterGroups.CreateWildcardFilter(@"*/Library/Mirrors/")); yield return(FilterGroups.CreateWildcardFilter(@"*/Library/PubSub/Database/")); yield return(FilterGroups.CreateWildcardFilter(@"*/Library/PubSub/Downloads/")); yield return(FilterGroups.CreateWildcardFilter(@"*/Library/PubSub/Feeds/")); yield return(FilterGroups.CreateWildcardFilter(@"*/Library/Safari/HistoryIndex.sk")); yield return(FilterGroups.CreateWildcardFilter(@"*/Library/Safari/Icons.db")); yield return(FilterGroups.CreateWildcardFilter(@"*/Library/Safari/WebpageIcons.db")); yield return(FilterGroups.CreateWildcardFilter(@"*/Library/Saved Application State/")); yield return(FilterGroups.CreateWildcardFilter(@"/System/Library/Extensions/Caches/")); yield return(FilterGroups.CreateWildcardFilter(@"*MobileBackups/")); yield return(FilterGroups.CreateWildcardFilter(@"*.hotfiles.btree*")); yield return(FilterGroups.CreateWildcardFilter(@"*.Spotlight-*/")); yield return(FilterGroups.CreateWildcardFilter(@"/Desktop DB")); yield return(FilterGroups.CreateWildcardFilter(@"/Desktop DF")); } if (group.HasFlag(FilterGroup.TemporaryFiles)) { yield return(FilterGroups.CreateWildcardFilter(@"/private/tmp/")); yield return(FilterGroups.CreateWildcardFilter(@"/private/var/tmp/")); yield return(FilterGroups.CreateWildcardFilter(@"*/Microsoft User Data/Entourage Temp/")); yield return(FilterGroups.CreateWildcardFilter(@"/tmp/")); yield return(FilterGroups.CreateWildcardFilter(@"/var/")); yield return(FilterGroups.CreateWildcardFilter(@"*.Trash*")); yield return(FilterGroups.CreateWildcardFilter(@"*/Network Trash Folder/")); yield return(FilterGroups.CreateWildcardFilter(@"*/Trash/")); yield return(FilterGroups.CreateWildcardFilter(@"*/lost+found/")); yield return(FilterGroups.CreateWildcardFilter(@"*/VM Storage")); } if (group.HasFlag(FilterGroup.Applications)) { yield return(FilterGroups.CreateWildcardFilter(@"/Applications/")); yield return(FilterGroups.CreateWildcardFilter(@"/Library/")); yield return(FilterGroups.CreateWildcardFilter(@"/usr/")); yield return(FilterGroups.CreateWildcardFilter(@"/opt/")); } }
override public FilterMatchCollection Matches(FilterGroup parent_group) { return(new AgileMatches(parent_group, Xpath)); }
public override FilterMatchCollection Matches(FilterGroup group) { return new JsonMatches(group, JsonPath, TrimQuotation); }
public override FilterMatchCollection Matches(FilterGroup group) { return new RegexMatches(group, Regex); }
/// <summary> /// Perform parsing. /// </summary> /// <param name="text">text that is to be parsed with the tree</param> /// <returns>Zero Capture that the tree of CroupCapture's starts from</returns> public Capture Parse(string text) { //if (parsable_object == null) // throw new Exception("The input parsable_object is null"); //string text = parsable_object.ToString(); Capture capture0 = new Capture(ROOT_INPUT_GROUP_NAME, text, 0, group_name2child_filters_group_names0[ROOT_INPUT_GROUP_NAME]); FilterGroup fg = new FilterGroup(null, 0, text); foreach (Filter f in RootFilters) parse(capture0, fg, f); return capture0; }
public static Select MergeJpListQuery(FieldConfig config, Select select, List <StatusDTO> statuses, string cultureCode) { var query = select.Query; foreach (StatusDTO status in statuses) { switch (status.action) { case "paging": { int number; // string value (it could be number or "all") int.TryParse(status.data.number, out number); select.PageSize = number; select.PageIndex = status.data.currentPage; break; } case "filter": { if (status.type == "textbox" && status.data != null && !string.IsNullOrEmpty(status.name) && !string.IsNullOrEmpty(status.data.value)) { var names = status.name.Split(','); if (names.Length == 1) { query.AddRule(FieldConfigUtils.CreateFilterRule(config, cultureCode, status.name, OperatorEnum.START_WITH, new StringRuleValue(status.data.value) )); } else { var group = new FilterGroup() { Condition = ConditionEnum.OR }; foreach (var n in names) { group.AddRule(FieldConfigUtils.CreateFilterRule(config, cultureCode, n, OperatorEnum.START_WITH, new StringRuleValue(status.data.value) )); } query.FilterGroups.Add(group); } } else if ((status.type == "checkbox-group-filter" || status.type == "button-filter-group" || status.type == "combined") && status.data != null && !string.IsNullOrEmpty(status.name)) { if (status.data.filterType == "pathGroup" && status.data != null && status.data.pathGroup != null && status.data.pathGroup.Count > 0 && status.data.pathGroup[0] != "*") { query.AddRule(FieldConfigUtils.CreateFilterRule(config, cultureCode, status.name, OperatorEnum.IN, status.data.pathGroup.Select(s => new StringRuleValue(s)) )); } } else if (status.type == "filter-select" && status.data != null && !string.IsNullOrEmpty(status.name)) { if (status.data.filterType == "path" && !string.IsNullOrEmpty(status.data.path) && (status.data.path != "*")) { query.AddRule(FieldConfigUtils.CreateFilterRule(config, cultureCode, status.name, OperatorEnum.EQUAL, new StringRuleValue(status.data.path) )); } } else if (status.type == "autocomplete" && status.data != null && !string.IsNullOrEmpty(status.data.path) && !string.IsNullOrEmpty(status.data.value)) { var names = status.data.path.Split(','); if (names.Length == 1) { query.AddRule(FieldConfigUtils.CreateFilterRule(config, cultureCode, status.data.path, OperatorEnum.START_WITH, new StringRuleValue(status.data.value) )); } else { var group = new FilterGroup() { Condition = ConditionEnum.OR }; foreach (var n in names) { group.AddRule(FieldConfigUtils.CreateFilterRule(config, cultureCode, n, OperatorEnum.START_WITH, new StringRuleValue(status.data.value) )); } query.FilterGroups.Add(group); } } break; } case "sort": { select.Sort.Clear(); select.Sort.Add(FieldConfigUtils.CreateSortRule(config, cultureCode, status.data.path, status.data.order == "desc" )); break; } } } return(select); }
public string ChangeGroup(string oldgroupname, string newgroupname, string type) { if (oldgroupname == null || oldgroupname == "") { return("Ошибка в данных"); } if (type == null || type == "") { return("Ошибка в данных"); } if (newgroupname == null || newgroupname == "") { return("Название не может быть пустым"); } FilterGroup group = SaveEquip.GetGroup(oldgroupname); if (group == null) { return("Ошибка данных"); } switch (type) { case "well": if (group.CurValues != Values.Location) { return("Ошибка данных"); } bool checkwell = SaveEquip.CheckGroup(2, newgroupname); if (checkwell == false) { return("Такое название уже есть"); } SaveEquip.ChangeGroup(Values.Location, oldgroupname, newgroupname, SaveEquip.Accounts[User.Identity.Name].Name); //SaveEquip.ChangeGroup(SaveEquip.Accounts[User.Identity.Name].Name, SaveEquip.LocationsFile, oldgroupname, newgroupname); break; case "type": if (group.CurValues != Values.Type) { return("Ошибка данных"); } bool checktype = SaveEquip.CheckGroup(1, newgroupname); if (checktype == false) { return("Такое название уже есть"); } SaveEquip.ChangeGroup(Values.Type, oldgroupname, newgroupname, SaveEquip.Accounts[User.Identity.Name].Name); //SaveEquip.ChangeGroup(SaveEquip.Accounts[User.Identity.Name].Name, SaveEquip.TypeFile, oldgroupname, newgroupname); break; case "maker": if (group.CurValues != Values.Maker) { return("Ошибка данных"); } bool checkmaker = SaveEquip.CheckGroup(3, newgroupname); if (checkmaker == false) { return("Такое название уже есть"); } SaveEquip.ChangeGroup(Values.Maker, oldgroupname, newgroupname, SaveEquip.Accounts[User.Identity.Name].Name); //SaveEquip.ChangeGroup(SaveEquip.Accounts[User.Identity.Name].Name, SaveEquip.MakerFile, oldgroupname, newgroupname); break; } return(""); }
static void Main(string[] args) { Console.OutputEncoding = Encoding.Unicode; try { SkroutzRequest skroutzRequest = new SkroutzRequest(new Credentials { ClientId = "", ClientSecret = "" }); dynamic result = null; #region CATEGORY Category category = new Category(skroutzRequest); //List All Categories. result = category.ListAllCategories().Result.categories.printReflected(); //Retrieve only fields Id and Code, of Category with Id: 1442. result = category.RetrieveSingleCategory(1442, x => x.Code, x => x.Id).Result.Category.printReflected(); //Retrieve the Parent Category, of Category with Id: 1442. result = category.RetrieveTheParentOfCategory(1442).Result.Category.printReflected(); //Retrieve the Root Category. result = category.RetrieveTheRootCategory().Result.Category.printReflected(); //List children Categories, of Category with Id: 252. result = category.ListChildrenCategoriesOfCategory(252).Result.categories.printReflected(); //List Category specifications, of Category with Id: 40. result = category.ListCategorysSpecifications(40).Result.specifications.printReflected(); //List Category specifications, of Category with Id: 40 and include Group information. result = category.ListCategorysSpecificationsGroup(40).Result.groups.printReflected(); //List Category's Manufacturers, of Category with Id: 25. result = category.ListCategorysManufactures(25).Result.manufacturers.printReflected(); //List Category's Manufacturers, of Category with Id: 25 and order results by Name. result = category.ListCategorysManufactures(25, OrderByNamePop.name).Result.manufacturers.printReflected(); //List Category's Manufacturers, of Category with Id: 25 and order results by Popularity Asceding. result = category.ListCategorysManufactures(25, OrderByNamePop.popularity, OrderDir.asc).Result.manufacturers.printReflected(); //List Category's Favorites, of Category with Id: 40. //[Important] User token is required or else exception is thrown. //result = category.ListCategorysFavorites(40).Result; #endregion #region SKU Sku sku = new Sku(skroutzRequest); //List SKU's, of Category with Id: 40. result = sku.ListSKUsOfSpecificCategory(40).Result.skus.printReflected(); //List SKU's, of Category with Id: 40 and order results by Popularity. result = sku.ListSKUsOfSpecificCategory(40, OrderByPrcPopRating.popularity).Result.skus.printReflected(); //List SKU's, of Category with Id: 40 and order results by Rating Descending. result = sku.ListSKUsOfSpecificCategory(40, OrderByPrcPopRating.rating, OrderDir.desc).Result.skus.printReflected(); //List SKU's, of Category with Id: 40 and keyword equal to iphone. result = sku.ListSKUsOfSpecificCategory(40, searchKeyword: "iphone").Result.skus.printReflected(); //List SKU's, of Category with Id: 40 and manufacturerIds 28, 2. result = sku.ListSKUsOfSpecificCategory(40, manufacturerIds: new int[] { 28, 2 }).Result.skus.printReflected(); //List SKU's, of Category with Id: 40 and filter Ids 355559, 6282. result = sku.ListSKUsOfSpecificCategory(40, filterIds: new int[] { 355559, 6282 }).Result.skus.printReflected(); //Retrieve SKU with SKUid: 3690169. result = sku.RetrieveSingleSKU(3690169).Result.sku.printReflected(); //Retrieve similar SKU's of SKUid: 3034682. result = sku.RetrieveSimilarSKUs(3034682).Result.skus.printReflected(); //Retrieve SKU's products of SKUid: 3783654. result = sku.RetrieveSKUsProducts(3783654).Result.products.printReflected(); //Retrieve SKU's Reviews of SKUid: 3690169. result = sku.RetrieveSKUsReviews(3690169).Result.reviews.printReflected(); #endregion #region PRODUCT Product product = new Product(skroutzRequest); //Retrieve Product with ProductId: 12176638. result = product.RetrieveSingleProduct(12176638).Result.Product.printReflected(); //Search for Products with ShopId: 670 and ShopUniqueId : 220004386. result = product.SearchForProducts(670, "220004386").Result.products.printReflected(); #endregion #region SHOP Shop shop = new Shop(skroutzRequest); //Retrieve Shop with ShopId: 452. var singleShop = shop.RetrieveSingleShop(452).Result.shop; //Print additional info. singleShop.printReflected(); singleShop.PaymentMethods.printReflected(); singleShop.Shipping.printReflected(); singleShop.ExtraInfo.printReflected(); //Retrieve Shop Reviews of ShopId: 452. result = shop.RetrieveShopReview(452).Result.Reviews.printReflected(); //List Shop Locations of ShopId: 452. result = shop.ListShopLocations(452).Result.Locations.printReflected(); //Retrieve Shop Location of ShopId: 452 and LocationId: 2500. result = shop.RetrieveSingleShopLocation(452, 2500).Result.Locations.printReflected(); #endregion #region MANUFACTURER Manufacturer manufacturer = new Manufacturer(skroutzRequest); //List Manufacturers result = manufacturer.ListManufacturers().Result.manufacturers.printReflected(); //Retrieve Manufacturer with ManufacturerId: 12907. result = manufacturer.RetrieveSingleManufacturer(12907).Result.Manufacturer.printReflected(); //Retrieve Manufacturer Categories with ManufacturerId: 356. Retrieve the first 10 results. result = manufacturer.RetrieveManufacturerCategories(356, page: 1, per: 10).Result.categories.printReflected(); //Retrieve Manufacturer Categories with ManufacturerId: 356 and order results by Manufacturer name. result = manufacturer.RetrieveManufacturerCategories(356, OrderByNamePop.name).Result.categories.printReflected(); //Retrieve Manufacturer Categories with ManufacturerId: 356 and order results by Popularity Asceding. result = manufacturer.RetrieveManufacturerCategories(356, OrderByNamePop.popularity, OrderDir.asc).Result.categories.printReflected(); //Retrieve Manufacturer SKU's with ManufacturerId: 356. result = manufacturer.RetrieveManufacturerSKUs(356).Result.skus.printReflected(); //Retrieve Manufacturer SKU's with ManufacturerId: 356 and order results by Price. result = manufacturer.RetrieveManufacturerSKUs(356, OrderByPrcPop.price).Result.skus.printReflected(); //Retrieve Manufacturer SKU's with ManufacturerId: 356 and order results by Popularity Asceding. result = manufacturer.RetrieveManufacturerSKUs(356, OrderByPrcPop.popularity, OrderDir.asc).Result.skus.printReflected(); #endregion #region SEARCH Search search = new Search(skroutzRequest); //Query with less than 2 characters //[Important] Exception is thrown if query is less than 2 characters. result = search.SearchQuery("a").Result; //Query that doesn't match anything result = search.SearchQuery("asdf").Result.Categories; //Query with more results when written in another language result = search.SearchQuery("%CE%B9%CF%80%CE%B7%CE%BF%CE%BD%CE%B5").Result.Categories.printReflected(); //Probably misspelled query result = search.SearchQuery("ipone").Result.Categories.printReflected(); //Query matching many categories result = search.SearchQuery("iphone").Result.Categories.printReflected(); //Query with strong hints for a specific category match result = search.SearchQuery("Tablets").Result.Categories.printReflected(); //Query with strong hints for a specific manufacturer match result = search.SearchQuery("apple").Result.Categories.printReflected(); //Query with strong hints for a specific SKU match result = search.SearchQuery("nikon+1+j2").Result.Categories.printReflected(); //Query that matches SKUS from a single category result = search.SearchQuery("samsung+galaxy+s5+16GB").Result.Categories.printReflected(); //Query with results when parts of the query are omitted result = search.SearchQuery("wrong+iphone").Result.Categories.printReflected(); #endregion #region FLAG Flag flag = new Flag(skroutzRequest); //Retrieve All Flags. result = flag.RetrieveAllFlags().Result.flags.printReflected(); #endregion #region FILTER GROUP FilterGroup filterGroup = new FilterGroup(skroutzRequest); //List Filter Groups of Category with CategoryId: 40. result = filterGroup.ListFilterGroups(40).Result.filter_groups.printReflected(); #endregion } catch (AggregateException aggregateException) { aggregateException.Handle(ex => { SkroutzException skroutzException = ex.InnerException as SkroutzException; if (skroutzException != null) { Console.WriteLine($"Status code: {skroutzException.StatusCode}"); foreach (Error error in skroutzException.SkroutzError.Errors) { Console.WriteLine($"Error code: {error.Code}"); foreach (string errorMessage in error.Messages) { Console.WriteLine($"Error message: {errorMessage}"); } } return(true); } return(false); }); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadLine(); }
internal void Deconstruct(out string groupName, out FilterGroup selectedFilter) { groupName = GroupName; selectedFilter = SelectedFilter; }
private void MinimumCuttoff_Changed(object sender, RoutedPropertyChangedEventArgs <double> e) { FilterGroup.ChangeMinimumCutoff((float)slider_minCutoff.Value); }
void groupControl_DeleteGroupClick(object sender, EventArgs e) { FilterGroup groupControl = sender as FilterGroup; groupControl.Parent.Controls.Remove(groupControl); }
private bool BuildForGroup(FilterGroup filterGroup, out (string property, object query) resultQuery)
private static string GetFilterItemCacheKey(FilterGroup filterGroup, string filterItemLabel, StatisticsDbContext context) { return(typeof(FilterItem).Name + "_" + (filterGroup.Id == null ? context.Entry(filterGroup).Property(e => e.Id).CurrentValue : filterGroup.Id) + "_" + filterItemLabel.ToLower().Replace(" ", "_")); }
private static bool IsFilterGroupTotal(FilterGroup group) { return(IsEqualToIgnoreCase(group.Label, "Total")); }