public async Task <ICoverageAnalysisResult> AnalyseCoverage(Config config) { var memberIdsToNames = new Dictionary <string, string>(); var baseTempDirectory = TempDirectory.Create(); long memberId = 0; long GenerateMemberId() => ++ memberId; try { var copiedTestAssemblyFilePaths = CopyTestAssembliesToTempDirectories( config.TestAssemblyFilePaths, baseTempDirectory) .ToList(); using (var workspace = MSBuildWorkspaceFactory.Create()) { var solution = await workspace.OpenSolutionAsync(config.SolutionFilePath); await InstrumentThenCompileMultipleProjects( solution.Projects.Where(p => Filtering.ShouldMutateProject(p, config)), config, baseTempDirectory, copiedTestAssemblyFilePaths, GenerateMemberId, memberIdsToNames); var result = new CoverageAnalysisResult(); for (int testAssemblyIndex = 0; testAssemblyIndex < config.TestAssemblyFilePaths.Length; ++testAssemblyIndex) { var copiedTestAssemblyFilePath = copiedTestAssemblyFilePaths[testAssemblyIndex]; var numTests = testFinder.FindTests(new[] { copiedTestAssemblyFilePath }).Length; var runResult = testRunner.RunAllTestsAndAnalyseCoverage( testAssemblyFilePaths: new [] { copiedTestAssemblyFilePath }, memberIdsToNames: memberIdsToNames, onAnalysingTestCase: (test, index) => eventListener.BeginCoverageAnalysisOfTestCase(test, index, numTests)); if (runResult.Status != TestRunStatus.AllTestsPassed) { return(CoverageAnalysisResult.Error(runResult.Error)); } var originalTestAssemblyFilePath = config.TestAssemblyFilePaths[testAssemblyIndex]; result = result.WithCoveredMembers(runResult.MembersAndCoveringTests, originalTestAssemblyFilePath); } return(result); } } finally { Directory.Delete(baseTempDirectory, recursive: true); } }
public static string loadCustomView(int viewID, int REPORT_TYPEID) { Dictionary <string, string> result = new Dictionary <string, string>() { { "saved", "false" }, { "viewID", viewID.ToString() }, { "customFilter", "" }, { "error", "" } }; bool saved = false; string errorMsg = string.Empty; try { DataTable dt = new DataTable(); if (viewID > 0) { dt = Filtering.LoadReportViews(viewID, REPORT_TYPEID); } foreach (DataRow row in dt.Rows) { result["Report Parameters"] = row["ReportParameters"].ToString(); result["Report Levels"] = row["ReportLevels"].ToString(); } } catch (Exception ex) { result["error"] = ex.Message + " " + ex.StackTrace; LogUtility.LogException(ex); } result["saved"] = saved.ToString(); result["error"] = errorMsg; return(JsonConvert.SerializeObject(result, Newtonsoft.Json.Formatting.None)); }
public async Task <IEnumerable <IVehicleMake> > GetAll(Filtering filters, Sorting sorting, Paging paging) { IQueryable <VehicleMakeEntity> vehicles = dbSet; if (filters.ShouldApplyFilters()) { vehicles = vehicles.Where(m => m.Name.Contains(filters.FilterBy) || m.Abbreviation.Contains(filters.FilterBy)); } paging.TotalCount = vehicles.Count(); switch (sorting.SortBy) { case "name_desc": vehicles = vehicles.OrderByDescending(v => v.Name); break; case "Abrv": vehicles = vehicles.OrderBy(v => v.Abbreviation); break; case "abrv_desc": vehicles = vehicles.OrderByDescending(v => v.Abbreviation); break; default: vehicles = vehicles.OrderBy(v => v.Name); break; } return(await vehicles.Skip(paging.ItemsToSkip).Take(paging.NumberOfObjectsPerPage).ProjectTo <VehicleMake>(_mapperConfiguration).ToListAsync()); }
public override void Extract(Filtering.FilteredResult fr, ref KnxPort meta) { switch (Path) { case AttributePath.Installation: meta.MetaData[AttributeName] = fr.ComObjects.Select(row => row.ParentDevice.Building.Parent.Parent.Name).Where(row => !string.IsNullOrWhiteSpace(row)).FirstOrDefault(); break; case AttributePath.Building: meta.MetaData[AttributeName] = fr.ComObjects.Select(row => row.ParentDevice.Building.Parent.Name).Where(row => !string.IsNullOrWhiteSpace(row)).FirstOrDefault(); break; case AttributePath.Room: meta.MetaData[AttributeName] = fr.ComObjects.Select(row => row.ParentDevice.Building.Name).Where(row => !string.IsNullOrWhiteSpace(row)).FirstOrDefault(); break; case AttributePath.GroupAddressName: meta.MetaData[AttributeName] = fr.GroupAddress.Ref.Name; break; case AttributePath.ObjectName: meta.MetaData[AttributeName] = fr.ComObjects.Select(row => (row["Name"].Value ?? row["Text"].Value).ToString()).FirstOrDefault(); break; case AttributePath.DeviceName: meta.MetaData[AttributeName] = fr.ComObjects.Select(row => row.ParentDevice.Name).Where(row => !string.IsNullOrWhiteSpace(row)).FirstOrDefault(); break; case AttributePath.ProductName: meta.MetaData[AttributeName] = fr.ComObjects.Select(row => row.ParentDevice.Product.Text).Where(row => !string.IsNullOrWhiteSpace(row)).FirstOrDefault(); break; default: break; } }
public async Task <IActionResult> GetAll(Guid userId, int pageNumber = 0, int pageSize = 10, string?search = null /*, string sort = null*/) { IFiltering filtering = new Filtering { FilterValue = search }; //ISorting sorting = new Sorting //{ // SortOrder = sort //}; IPaging paging = new Paging { PageNumber = pageNumber, PageSize = pageSize, TotalPages = 0 }; var allProjects = await projectService.GetAllAsync(userId, paging, filtering); var mapProjects = mapper.Map <IEnumerable <ProjectViewModel> >(allProjects); return(Ok(new { projects = mapProjects, totalPages = paging.TotalPages })); }
public static string DeleteView(int viewID, int REPORT_TYPEID) { Dictionary <string, string> result = new Dictionary <string, string>() { { "deleted", "false" }, { "error", "" } }; bool deleted = false; string errorMsg = string.Empty; try { if (viewID > 0) { deleted = Filtering.DeleteReportView(viewID, REPORT_TYPEID, out errorMsg); } } catch (Exception ex) { LogUtility.LogException(ex); deleted = false; } result["deleted"] = deleted.ToString(); result["error"] = errorMsg; return(JsonConvert.SerializeObject(result, Newtonsoft.Json.Formatting.None)); }
public response GetFilteredExtended(string _sort, string _order, string _filter, string _limit) { try { try { string newFilter = Filtering.GenerateFilterFromJsonObject(typeof(Proces), _filter, authenticatedUserId, connectionString); _filter = String.IsNullOrWhiteSpace(newFilter) && !_filter.IsValidJson() ? _filter : String.IsNullOrWhiteSpace(newFilter) ? null : newFilter; } catch { } DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "PROCESEsp_select", new object[] { new MySqlParameter("_SORT", _sort), new MySqlParameter("_ORDER", _order), new MySqlParameter("_FILTER", _filter), new MySqlParameter("_LIMIT", _limit) }); List <ProcesExtended> aList = new List <ProcesExtended>(); MySqlDataReader r = da.ExecuteSelectQuery(); while (r.Read()) { /* * ProcesExtended pe = new ProcesExtended(new Proces(authenticatedUserId, connectionString, (IDataRecord)r)); * aList.Add(pe); */ aList.Add(new ProcesExtended(new Proces(authenticatedUserId, connectionString, r))); } r.Close(); r.Dispose(); da.CloseConnection(); return(new response(true, JsonConvert.SerializeObject(aList.ToArray(), CommonFunctions.JsonSerializerSettings), aList.ToArray(), null, null)); } catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new List <Error>() { new Error(exp) })); } }
protected IEnumerable <ReportMaterialModel> GetEntities(Filtering filtering) { var fromDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); var toDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)); GetFilters(filtering, ref fromDate, ref toDate); var result = new List <ReportMaterialModel>(); var materials = materialDeliveryRspManager.GetEntities(o => o.CreateDate.Date >= fromDate && o.CreateDate.Date <= toDate).ToList(); foreach (var materialGroup in materials.GroupBy(o => o.Materials)) { var amount = materialGroup.Sum(o => o.Amount); result.Add(new ReportMaterialModel() { Id = materialGroup.Key.Id, materialName = materialGroup.Key.Name, materialNumber = materialGroup.Key.Number, amount = amount, price = (amount * materialGroup.Key.Price).ToString("N2") + " EUR", }); } return(result); }
public List<PropertySummary> FullSearchV1(List<SearchParameter> searchParameters, Ordering order, Filtering filter) { Check.If(searchParameters).IsNotNull(); return _searchRepository.Search(searchParameters, order, filter).Select(SearchResultFactory.BuildPropertySummary).ToList(); }
public List<SearchResult> Search(List<SearchParameter> searchParameters, Ordering order, Filtering filter) { Check.If(searchParameters).IsNotNull(); return _searchRepository.Search(searchParameters, order, filter).Select(SearchResultFactory.BuildSearchResult).ToList(); }
private void GetFilters(Filtering filtering, ref DateTime fromDate, ref DateTime toDate, ref int? employeeId) { foreach (var compositeFilter in filtering.Filters) { foreach (var filter in compositeFilter.Filters) { switch (filter.Field.ToLower()) { case "fromdate": DateTime.TryParse(filter.Value, out fromDate); break; case "todate": DateTime.TryParse(filter.Value, out toDate); break; case "employeeid": int temp; if(Int32.TryParse(filter.Value, out temp)) { employeeId = temp; } break; default: break; } } } }
public IActionResult Get([FromQuery] Filtering filtering, [FromQuery] PagingDto pagingDto) { var outComeIQ = (IQueryable <OutCome>) this._context.OutComes .Include(c => c.User) .Include(c => c.OutComeType); if (filtering.MaxAmount != null) { outComeIQ = outComeIQ.Where(c => c.Amount <= filtering.MaxAmount); } if (filtering.MinAmount != null) { outComeIQ = outComeIQ.Where(c => c.Amount >= filtering.MaxAmount); } if (filtering.Type != null) { outComeIQ = outComeIQ.Where(c => c.OutComeTypeId == filtering.Type); } if (filtering.UserId != null) { outComeIQ = outComeIQ.Where(c => c.UserId == filtering.UserId); } if (filtering.FromDate != null) { outComeIQ = outComeIQ.Where(c => c.Date >= filtering.FromDate); } if (filtering.ToDate != null) { outComeIQ = outComeIQ.Where(c => c.Date <= filtering.ToDate); } var total = outComeIQ.Count(); var outComes = outComeIQ.Skip((pagingDto.Page - 1) * pagingDto.RowCount).Take(pagingDto.RowCount).ToList(); return(Ok(new { data = _mapper.Map <OutComeDto[]>(outComes), total })); }
public response GetFiltered(string _sort, string _order, string _filter, string _limit) { try { try { string newFilter = Filtering.GenerateFilterFromJsonObject(typeof(SedintaPortal), _filter, authenticatedUserId, connectionString); _filter = newFilter == null ? _filter : newFilter; } catch { } DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "SEDINTE_PORTALsp_select", new object[] { new MySqlParameter("_SORT", _sort), new MySqlParameter("_ORDER", _order), new MySqlParameter("_FILTER", _filter), new MySqlParameter("_LIMIT", _limit) }); List <SedintaPortal> aList = new List <SedintaPortal>(); MySqlDataReader r = da.ExecuteSelectQuery(); while (r.Read()) { SedintaPortal a = new SedintaPortal(authenticatedUserId, connectionString, (IDataRecord)r); aList.Add(a); } r.Close(); r.Dispose(); da.CloseConnection(); return(new response(true, JsonConvert.SerializeObject(aList.ToArray(), CommonFunctions.JsonSerializerSettings), aList.ToArray(), null, null)); } catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new System.Collections.Generic.List <Error>() { new Error(exp) })); } }
static void RepeatableTest(int imageSizeStep, int testRepeats, int numberOfTests) { List <string> lines = new List <string>(numberOfTests * 9); for (int i = 1; i <= numberOfTests; i++) { for (int f = 3; f <= 21; f += 2) { StringBuilder builder = new StringBuilder(); builder.Append($"{ i * imageSizeStep };{ f };"); for (int l = 0; l < testRepeats; l++) { Graymap graymap = Generator.HorizontalStripes(i * imageSizeStep, i * imageSizeStep, new int[] { 0, 255 }, imageSizeStep / 5); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); Filtering.ApplyFilter(graymap, GraymapLibrary.Filters.Generator.GetGaussianBlur(f)); stopwatch.Stop(); builder.Append($"{ stopwatch.ElapsedMilliseconds };"); Console.WriteLine($"Blur size: { f.ToString("D2") } | Image size: { i * imageSizeStep } | Regular iteration: { stopwatch.ElapsedMilliseconds }ms"); } lines.Add(builder.ToString().Substring(0, builder.ToString().Length - 1)); } } File.WriteAllLines("regular.csv", lines.ToArray()); //======================================================================================================================= lines = new List <string>(numberOfTests * 9); for (int i = 1; i <= numberOfTests; i++) { for (int f = 3; f <= 21; f += 2) { StringBuilder builder = new StringBuilder(); builder.Append($"{ i * imageSizeStep };{ f };"); for (int l = 0; l < testRepeats; l++) { Graymap graymap = Generator.HorizontalStripes(i * imageSizeStep, i * imageSizeStep, new int[] { 0, 255 }, imageSizeStep / 4); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); Filtering.ApplyFilterParallel(graymap, GraymapLibrary.Filters.Generator.GetGaussianBlur(f)); stopwatch.Stop(); builder.Append($"{ stopwatch.ElapsedMilliseconds };"); Console.WriteLine($"Blur size: { f.ToString("D2") } | Image size: { i * imageSizeStep } | Parallel iteration: { stopwatch.ElapsedMilliseconds }ms"); } lines.Add(builder.ToString().Substring(0, builder.ToString().Length - 1)); } } File.WriteAllLines("parallel.csv", lines.ToArray()); }
public void Filtering_Set( [Values(true, false)] bool item0, [Values(true, false)] bool item1, [Values(true, false)] bool item2, [Values(true, false)] bool item3, [Values(true, false)] bool item4, [Range(0, 4, 1)] int index, [Values(true, false)] bool itemNew) { ObservableCollection <Item> items = new ObservableCollection <Item>( new[] { new Item(item0), new Item(item1), new Item(item2), new Item(item3), new Item(item4) } ); Filtering <Item> filtering = items.Filtering(item => item.IsActive); filtering.ValidateConsistency(); items[index] = new Item(itemNew); filtering.ValidateConsistency(); }
public void TestWhereIndexed() { IEnumerable <string> actual = Filtering.WhereIndexed(); IEnumerable <string> expected = new string[] { "five", "six", "seven", "eight", "nine" }; CollectionAssert.AreEqual(actual.ToList(), expected.ToList(), "You failed!"); }
public void TestWhere01() { IEnumerable <int> actual = Filtering.Where01(); IEnumerable <int> expected = new int[] { 4, 1, 3, 2, 0 }; CollectionAssert.AreEqual(actual.ToList(), expected.ToList(), "You failed!"); }
public async Task <IEnumerable <IVehicleModel> > GetVehicleModelsAsync(Filtering filters, Sorting sorting, Paging paging) { IEnumerable <IVehicleModel> query = await _vehicleModelRepository.GetAll(filters, sorting, paging); return(query.ToList()); }
public void OnGet() { SnortContext db = HttpContext.RequestServices.GetService(typeof(SnortContext)) as SnortContext; if (StaticData.sensors == null) { StaticData.sensors = SensorTable.GetSensors(db.GetConnection()); } if (StaticData.alerts == null) { StaticData.alerts = AlertMapper.ResolveAlerts(0, ref StaticData.signatureStrings, db.GetConnection()); } alerts = StaticData.alerts; if (HttpContext.Request.Query.Count > 0) { Filtering.applyFilter(ref alerts, HttpContext.Request.Query); filtered = true; } protocols = Stats.ByProtocol(alerts); protocols_source = Stats.ByProtocolSource(alerts); ; }
public async Task <ActionResult <Person> > CreateRecord([FromBody] string personString) { //filter the raw text from the input and make a person object Person pers = Filtering.CreatePersonFromString(personString); //check if the person we got from the body is properly formatted if (pers.FavoriteColor == null) { _logger.LogWarning("CreateRecord() call failed to create a new person record due to improperly formatted person"); return(BadRequest("Attempt to create new record failed")); } else { if (!personExists(pers)) { _context.Add(pers); } else { _logger.LogWarning("CreateRecord() tried to add duplicate person"); return(BadRequest("Attempt to create new record failed")); } //sanity check that the db updated if (await _context.SaveChangesAsync() > 0) { return(pers); } else { _logger.LogWarning("CreateRecord() call failed"); return(BadRequest("Attempt to create new record failed")); } } }
public void Filtering_Change( [Values(true, false)] bool item0, [Values(true, false)] bool item1, [Values(true, false)] bool item2, [Values(true, false)] bool item3, [Values(true, false)] bool item4, [Range(0, 4, 1)] int index, [Values(true, false)] bool newValue) { ObservableCollection <Item> items = new ObservableCollection <Item>( new[] { new Item(item0), new Item(item1), new Item(item2), new Item(item3), new Item(item4) } ); Filtering <Item> filtering = items.Filtering(item => item.IsActive).IsNeededFor(consumer); filtering.ValidateConsistency(); items[index].IsActive = newValue; filtering.ValidateConsistency(); consumer.Dispose(); }
private void OnOpenImageButtonClick(object sender, EventArgs e) { var oldFilterButtonEnabled = FilterButton.Enabled; var oldFilterAgainButtonEnabled = FilterAgainButton.Enabled; FilterButton.Enabled = false; FilterAgainButton.Enabled = false; ElapsedTimeLabel.Text = string.Empty; var openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() != DialogResult.OK) { FilterButton.Enabled = oldFilterButtonEnabled; FilterAgainButton.Enabled = oldFilterAgainButtonEnabled; return; } //Open the browsed image and display it _openedFilePath = openFileDialog.FileName; var originalImage = new Bitmap(_openedFilePath); _imageMatrix = Filtering.ImageToMatrix(originalImage); DisplayImage(_imageMatrix, OriginalPictureBox); FilterButton.Enabled = true; }
public response ExportExcel(string _sort, string _order, string _filter, string _limit) { try { try { string newFilter = Filtering.GenerateFilterFromJsonObject(typeof(Proces), _filter, authenticatedUserId, connectionString); _filter = String.IsNullOrWhiteSpace(newFilter) && !_filter.IsValidJson() ? _filter : String.IsNullOrWhiteSpace(newFilter) ? null : newFilter; } catch { } DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "PROCESEsp_export_excel", new object[] { new MySqlParameter("_SORT", _sort), new MySqlParameter("_ORDER", _order), new MySqlParameter("_FILTER", _filter), new MySqlParameter("_LIMIT", _limit) }); DataTable toReturn = new DataTable(); MySqlDataReader r = da.ExecuteSelectQuery(); toReturn.Load(r); r.Close(); r.Dispose(); da.CloseConnection(); return(new response(true, JsonConvert.SerializeObject(toReturn, CommonFunctions.JsonSerializerSettings), toReturn, null, null)); } catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new List <Error>() { new Error(exp) })); } }
/// <summary> /// Display the given image on the given PictureBox object /// </summary> /// <param name="imageMatrix"> /// 2D array that contains the image /// </param> /// <param name="pictureBox"> /// PictureBox object to display the image on it /// </param> public static void DisplayImage(byte[,] imageMatrix, PictureBox pictureBox) { var bitmap = Filtering.MatrixToImage(imageMatrix, PixelFormat.Format24bppRgb); pictureBox.Image = bitmap; pictureBox.SizeMode = PictureBoxSizeMode.Normal; }
public Spider(Frontier frontier, Index index, Filtering.Filter filter, Action<Index> callback) { this.frontier = frontier; this.index = Index.CreateEmptyCopy(index); this.filter = filter; this.callback = callback; }
public void CheckWithDelayFilter() { var channelCount = 3; var impulseResponses = new double[][] { new double[] { 0.0, 0.0, 0.0, 1.0 }, new double[] { 0.0, 0.0, 1.0 }, new double[] { 0.0, 0.0, 0.0, 0.0, 1.0 } }; var delaySampleCounts = new int[] { 3, 2, 4 }; var dftLength = 1024; var sv = SteeringVector.FromImpulseResponse(impulseResponses, dftLength); Assert.AreEqual(dftLength / 2 + 1, sv.Length); for (var ch = 0; ch < channelCount; ch++) { var expected = Filtering.CreateFrequencyDomainDelayFilter(dftLength, delaySampleCounts[ch]); for (var w = 0; w < dftLength / 2 + 1; w++) { Assert.AreEqual(expected[w].Real, sv[w][ch].Real, 1.0E-6); Assert.AreEqual(expected[w].Imaginary, sv[w][ch].Imaginary, 1.0E-6); } } }
private void GetFilters(Filtering filtering, ref DateTime fromDate, ref DateTime toDate, ref int?employeeId) { foreach (var compositeFilter in filtering.Filters) { foreach (var filter in compositeFilter.Filters) { switch (filter.Field.ToLower()) { case "fromdate": DateTime.TryParse(filter.Value, out fromDate); break; case "todate": DateTime.TryParse(filter.Value, out toDate); break; case "employeeid": int temp; if (Int32.TryParse(filter.Value, out temp)) { employeeId = temp; } break; default: break; } } } }
protected Params GetParams(string filteringQuery, int sortingClassId, string sortingMemberCode, string sortingDirection, int?pagingSkip, int?pagingTake) { Filtering filtering = null; if (!string.IsNullOrEmpty(filteringQuery)) { filtering = new Filtering(filteringQuery); } Sorting sorting = null; if (!string.IsNullOrEmpty(sortingMemberCode) && !string.IsNullOrEmpty(sortingDirection)) { IDomainManager domainManager = this.GetService <IDomainManager>(); Member member = domainManager.GetMemberByClassIdAndCodeInlcudingParent(sortingClassId, sortingMemberCode); DataType dataType = domainManager.GetDataType((int)member.PropertyDataTypeId); sorting = new Sorting(dataType.StorageDataType, member.Id, sortingDirection); } Paging paging = null; if (pagingSkip != null && pagingTake != null) { paging = new Paging(pagingSkip, pagingTake); } return(new Params(filtering, sorting, paging)); }
public List <FileComparison> FilterFiles() { var filtering = new Filtering(Files); filters.Aggregate(filtering, (acc, filter) => filter.Apply(acc)); return(filtering.FilteredFiles()); }
public Params Create(string filteringQuery = null, int?sortingMemberId = null, string sortingDirection = null, int?pagingSkip = null, int?pagingTake = null) { Filtering filtering = null; if (!string.IsNullOrEmpty(filteringQuery)) { filtering = new Filtering(filteringQuery); } Sorting sorting = null; if (sortingMemberId != null && !string.IsNullOrEmpty(sortingDirection)) { IDomainManager domainManager = this.requestHandler.GetService <IDomainManager>(); Member member = domainManager.GetMember((int)sortingMemberId); DataType dataType = domainManager.GetDataType((int)member.PropertyDataTypeId); sorting = new Sorting(dataType.StorageDataType, member.Id, sortingDirection); } Paging paging = null; if (pagingSkip != null && pagingTake != null) { paging = new Paging(pagingSkip, pagingTake); } return(new Params(filtering, sorting, paging)); }
public void CheckTimeDomainSignal(int dftLength) { for (var delaySampleCount = 0; delaySampleCount < dftLength; delaySampleCount++) { var filter = Filtering.CreateFrequencyDomainDelayFilter(dftLength, delaySampleCount); var timeDomainSignal = new Complex[dftLength]; timeDomainSignal[0] = filter[0]; for (var w = 1; w < dftLength / 2; w++) { timeDomainSignal[w] = filter[w]; timeDomainSignal[dftLength - w] = filter[w].Conjugate(); } timeDomainSignal[dftLength / 2] = filter[dftLength / 2]; Fourier.Inverse(timeDomainSignal, FourierOptions.AsymmetricScaling); for (var t = 0; t < dftLength; t++) { if (t == delaySampleCount) { Assert.AreEqual(1.0, timeDomainSignal[t].Real, 1.0E-6); Assert.AreEqual(0.0, timeDomainSignal[t].Imaginary, 1.0E-6); } else { Assert.AreEqual(0.0, timeDomainSignal[t].Real, 1.0E-6); Assert.AreEqual(0.0, timeDomainSignal[t].Imaginary, 1.0E-6); } } } }
public void Filtering_Move( [Values(true, false)] bool item0, [Values(true, false)] bool item1, [Values(true, false)] bool item2, [Values(true, false)] bool item3, [Values(true, false)] bool item4, [Range(0, 4, 1)] int oldIndex, [Range(0, 4, 1)] int newIndex) { ObservableCollection <Item> items = new ObservableCollection <Item>( new[] { new Item(item0), new Item(item1), new Item(item2), new Item(item3), new Item(item4) } ); Filtering <Item> filtering = items.Filtering(item => item.IsActive).For(consumer); filtering.ValidateInternalConsistency(); items.Move(oldIndex, newIndex); filtering.ValidateInternalConsistency(); consumer.Dispose(); }
private void loadGridData() { DataTable dt = null; if (_refreshData || Session["dtMD_Contract"] == null) { dt = MasterData.ContractList_Get(includeArchive: true); HttpContext.Current.Session["dtMD_Contract"] = dt; } else { dt = (DataTable)HttpContext.Current.Session["dtMD_Contract"]; } _dtContractType = MasterData.ContractTypeList_Get(includeArchive: false); _dtCRReportViews = Filtering.LoadReportViews(-1, 2); if (dt != null) { this.DCC = dt.Columns; Page.ClientScript.RegisterArrayDeclaration("_dcc", JsonConvert.SerializeObject(DCC, Newtonsoft.Json.Formatting.None)); InitializeColumnData(ref dt); dt.AcceptChanges(); using (DataTable dtTemp = dt.DefaultView.ToTable(true, new string[] { "ContractTypeID", "ContractType" })) { if (dtTemp != null) { ddlQF.DataSource = dtTemp; ddlQF.DataTextField = "ContractType"; ddlQF.DataValueField = "ContractTypeID"; ddlQF.DataBind(); } ListItem item = ddlQF.Items.FindByValue(_qfContractTypeID.ToString()); if (item != null) { item.Selected = true; } } if (_qfContractTypeID != 0 && dt != null && dt.Rows.Count > 0) { dt.DefaultView.RowFilter = string.Format(" ContractTypeID = {0}", _qfContractTypeID.ToString()); dt = dt.DefaultView.ToTable(); } int count = dt.Rows.Count; count = count > 0 ? count - 1 : count; //need to subtract the empty row spanRowCount.InnerText = count.ToString(); } if (_export && dt != null && CanView) { exportExcel(dt); } grdMD.DataSource = dt; grdMD.DataBind(); }
public async Task <IActionResult> Get([FromQuery] Filtering filtering, [FromQuery] Sorting sorting, [FromQuery] Paging paging) { paging.PageSize = 5; var models = await Service.GetVehicleModelsAsync(filtering, sorting, paging); return(Ok(models)); }
public void PopulatePersons_Given_0_Person_Strings_Produces_0_Person_Objects() { string[] people = { }; List <Person> populated = (List <Person>)Filtering.PopulatePersons(people); Assert.Empty(populated); }
/// <summary> /// Внедрение конструктора. Пример использования паттернов Dependecy Injection /// </summary> /// <param name="repository"></param> public CategoryService(Models.Repositories.ICategoryRepository repository, Filtering.IFilterFactory<Models.Category> filterFactory) { ///Guard Condition if (repository == null) throw new ArgumentNullException("Repository is null!"); if (filterFactory == null) throw new ArgumentNullException("Filtering Factory is null!"); this.categoryRepository = repository; this.filterFactory = filterFactory; }
/// <summary> /// Внедрение конструктора. Пример использования паттернов Dependecy Injection /// </summary> /// <param name="repository"></param> public AccountService(Models.Repositories.IAccountRepository repository, Filtering.IFilterFactory<Models.User> filterFactory) { ///Guard Condition if (repository == null) throw new ArgumentNullException("Repository is null!"); if (filterFactory == null) throw new ArgumentNullException("Filtering Factory is null!"); this.repository = repository; this.filterFactory = filterFactory; }
/// <summary> /// Внедрение конструктора. Пример использования паттернов Dependecy Injection /// </summary> /// <param name="repository"></param> public OrderService(IOrderRepository _orderRepository, Filtering.IFilterFactory<Models.Order> filterFactory) { ///Guard Condition if (_orderRepository == null) throw new ArgumentNullException("Repository is null!"); if (filterFactory == null) throw new ArgumentNullException("Filtering Factory is null!"); this.orderRepository = _orderRepository; this.filterFactory = filterFactory; }
protected IEnumerable<SalaryModel> GetEntities(Filtering filtering) { var fromDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); var toDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)); GetFilters(filtering, ref fromDate, ref toDate); var result = SalaryHelper.GetSalary(termsManager, employeeRateRspManager, employeeManager, fromDate, toDate); return result; }
/// <summary> /// Внедрение конструктора. Пример использования паттернов Dependecy Injection /// </summary> /// <param name="repository"></param> public EventService(IEventRepository _eventRepository, Filtering.IFilterFactory<Models.Event> filterFactory) { ///Guard Condition if (_eventRepository == null) throw new ArgumentNullException("Repository is null!"); if (filterFactory == null) throw new ArgumentNullException("Filtering Factory is null!"); this.eventRepository = _eventRepository; this.filterFactory = filterFactory; }
/// <summary> /// Внедрение конструктора. Пример использования паттернов Dependecy Injection /// </summary> /// <param name="repository"></param> public CommentService(ICommentsRepository _commentsRepository, Filtering.IFilterFactory<Models.Comment> filterFactory) { ///Guard Condition if (_commentsRepository == null) throw new ArgumentNullException("Repository is null!"); if (filterFactory == null) throw new ArgumentNullException("Filtering Factory is null!"); this.commentsRepository = _commentsRepository; this.filterFactory = filterFactory; }
public List<SearchResult> Search(List<SearchParameter> searchParameters, Ordering order, Filtering filter) { Check.If(searchParameters).IsNotNull(); var applications = _searchRepository.Search(searchParameters, order, filter); return applications.GenerateStatuses(_statusGeneratorFactory, _pipelinePositionGenerator) .Select(SearchResultFactory.BuildSearchResult) .ToList(); }
protected IEnumerable<WorkHoursModel> GetEntities(Filtering filtering) { var fromDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); var toDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)); int? employeeId = null; GetFilters(filtering, ref fromDate, ref toDate, ref employeeId); var result = WorkHoursHelper.GetWorkHours(termsManager, employeeRateRspManager, employeeManager, fromDate, toDate, employeeId); return result.OrderByDescending(o => o.date); }
public override void Extract(Filtering.FilteredResult fr, ref KnxPort meta) { base.Extract(fr, ref meta); var result = meta.MetaData[AttributeName]; if (!string.IsNullOrWhiteSpace(result)) { var splits = result.Split(' '); if (splits.Length < SkipWords + TakeWords) return; meta.MetaData[AttributeName] = string.Join(" ", splits.Skip(SkipWords).Take(TakeWords)); } }
/// <summary> /// Внедрение конструктора. Пример использования паттернов Dependecy Injection /// </summary> /// <param name="partnerRepository"></param> public PatherService(IPartnerRepository partnerRepository, IAccountRepository accountRepository, ICategoryRepository categoryRepository, Filtering.IFilterFactory<Models.Partner> filterFactory) { ///Guard Condition if (partnerRepository == null) throw new ArgumentNullException("Repository is null!"); if (filterFactory == null) throw new ArgumentNullException("Filtering Factory is null!"); this.partnerRepository = partnerRepository; this.accountRepository = accountRepository; this.categoryRepository = categoryRepository; this.filterFactory = filterFactory; }
public static IQueryable<Property> Filter(this IQueryable<Property> source, Filtering filter) { Check.If(source).IsNotNull(); switch (filter) { case Filtering.Available: return source.Available(); case Filtering.Let: return source.Let(); default: return source; } }
public List<Property> Search(List<SearchParameter> searchParameters, Ordering order, Filtering filter) { var properties = from property in _propertiesContext.Properties.Active() .Include(x => x.Landlord) .Include(x => x.PropertyDetails) .Include(x => x.PropertyPhotos) select property; properties = _searchQueryFactory.GetQueries() .Aggregate(properties, (current, query) => query.BuildSearchQuery(searchParameters, current)); return properties.OrderProperties(order).Filter(filter).ToList().FilterByArea(searchParameters.AreaOrDefault()).ToList(); }
public static IQueryable<Application> Filter(this IQueryable<Application> source, Filtering filter) { Check.If(source).IsNotNull(); switch (filter) { case Filtering.Live: return source.Live(); case Filtering.NotLive: return source.ActiveNotLive(); default: return source; } }
public override void Extract(Filtering.FilteredResult fr, ref KnxPort meta) { base.Extract(fr, ref meta); var result = meta.MetaData[AttributeName]; if (!string.IsNullOrWhiteSpace(result)) { var idx = result.IndexOf(Mark, StringComparison.InvariantCultureIgnoreCase); if (idx >= 0) { if (UntilMark) meta.MetaData[AttributeName] = result.Substring(0, idx); else if (result.Length > idx + Mark.Length) meta.MetaData[AttributeName] = result.Substring(idx + Mark.Length); } } }
/// <summary> /// Внедрение конструктора. Пример использования паттернов Dependecy Injection /// </summary> /// <param name="repository"></param> public ProductService(IProductRepository repository, IAccountRepository repositoryAccounts, IPartnerRepository repositoryPartners, ICategoryRepository categoryRepository, Filtering.IFilterFactory<Models.Product> filterFactory) { ///Guard Condition if (repository == null) throw new ArgumentNullException("Product repository is null!"); if (repositoryPartners == null) throw new ArgumentNullException("Partner repository is null!"); if (filterFactory == null) throw new ArgumentNullException("Filtering Factory is null!"); this.productRepository = repository; this.accountRepository = repositoryAccounts; this.partnerRepository = repositoryPartners; this.categoryRepository = categoryRepository; this.filterFactory = filterFactory; }
public List<Application> Search(List<SearchParameter> searchParameters, Ordering order, Filtering filter) { var applications = from application in _applicationsContext.Applications.Filter(filter).Active() .Include(x => x.Customers) .Include(x => x.Customers.Select(c => c.Addresses)) .Include(x => x.Customers.Select(c => c.Emails)) .Include(x => x.Customers.Select(c => c.Names)) .Include(x => x.Customers.Select(c => c.TelephoneNumbers)) .Include(x => x.Properties) .Include(x => x.Requirements) select application; applications = _searchQueryFactory.GetQueries() .Aggregate(applications, (current, query) => query.BuildSearchQuery(searchParameters, current)); return applications.OrderApplications(order).ToList(); }
private void GetFilters(Filtering filtering, ref DateTime fromDate, ref DateTime toDate) { foreach (var compositeFilter in filtering.Filters) { foreach (var filter in compositeFilter.Filters) { switch (filter.Field.ToLower()) { case "fromdate": DateTime.TryParse(filter.Value, out fromDate); break; case "todate": DateTime.TryParse(filter.Value, out toDate); break; default: break; } } } }
public static void StartAndWait(Frontier frontier, Index index, Filtering.Filter filter, int pagecount) { int count = (int)Math.Ceiling(pagecount / (double)SPIDER_PAGE_COUNT); Spider[] spiders = new Spider[count]; Thread[] threads = new Thread[count]; for (int i = 0; i < count; i++) { Spider sp = spiders[i] = new Spider(frontier, index, filter, ind => { Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Merging Index of {0}", ind.SiteCount); Console.ForegroundColor = ConsoleColor.Gray; lock (index) { index.MergeIn(ind); } }); threads[i] = new Thread(() => sp.Run()); threads[i].Start(); } for (int i = 0; i < count; i++) threads[i].Join(); }
protected IEnumerable<ReportMaterialModel> GetEntities(Filtering filtering) { var fromDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); var toDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)); GetFilters(filtering, ref fromDate, ref toDate); var result = new List<ReportMaterialModel>(); var materials = materialDeliveryRspManager.GetEntities(o => o.CreateDate.Date >= fromDate && o.CreateDate.Date <= toDate).ToList(); foreach(var materialGroup in materials.GroupBy(o => o.Materials)) { var amount = materialGroup.Sum(o => o.Amount); result.Add(new ReportMaterialModel() { Id = materialGroup.Key.Id, materialName = materialGroup.Key.Name, materialNumber = materialGroup.Key.Number, amount = amount, price = (amount * materialGroup.Key.Price).ToString("N2") + " EUR", }); } return result; }
/// <summary> /// Получение комментариев на заданной странице с заданными фильтрами. /// </summary> /// <param name="page">Номер страницы</param> /// <param name="pageSize">Размер страницы</param> /// <param name="fieldFilters">Список фильтров</param> /// <param name="sortFilter">Порядок сортировки</param> /// <returns></returns> public CommentCollectionViewModel GetComments(int page, int pageSize, List<Filtering.FieldFilter> fieldFilter = null, Filtering.SortFilter sortFilter = null) { IEnumerable<CommentViewModel> comments; int total; if (fieldFilter != null && sortFilter != null) { var newSortFilter = new SortFilter() { SortOrder = sortFilter.SortOrder }; var expression = filterFactory.GetFilterExpression(fieldFilter); comments = commentsRepository.Get(page, pageSize, expression, newSortFilter).Select(Convert); total = commentsRepository.Count(expression); } else { comments = commentsRepository.Get(page, pageSize, x => true).Select(Convert); total = commentsRepository.Count(x => true); } var pageInfo = new PageInfo() { PageNumber = page, PageSize = pageSize, TotalItems = total }; return new CommentCollectionViewModel() { Comments = comments, PageInfo = pageInfo }; }
private int GetFilters(Filtering filtering) { var orderId = 0; foreach (var compositeFilter in filtering.Filters) { foreach (var filter in compositeFilter.Filters) { switch (filter.Field.ToLower()) { case "orderid": int.TryParse(filter.Value, out orderId); break; default: break; } } } return orderId; }
/// <summary> /// Получение партнеров на заданной странице с заданными фильтрами. /// </summary> /// <param name="page">Номер страницы</param> /// <param name="pageSize">Размер страницы</param> /// <param name="fieldFilters">Список фильтров</param> /// <param name="sortFilter">Порядок сортировки</param> /// <returns></returns> public PartnerCollectionViewModel GetPartners(int page, int pageSize, List<Filtering.FieldFilter> fieldFilters = null, Filtering.SortFilter sortFilter = null) { IEnumerable<PartnerViewModel> partners; int total; if (fieldFilters != null && sortFilter != null) { var newSortFilter = new SortFilter() { SortOrder = sortFilter.SortOrder }; var expression = filterFactory.GetFilterExpression(fieldFilters); partners = partnerRepository.Get(page, pageSize, expression, newSortFilter).Select(ConvertFromPartnerToPartnerViewModel); total = partnerRepository.Count(expression); } else { partners = partnerRepository.Get(page, pageSize, x => true).Select(ConvertFromPartnerToPartnerViewModel); total = partnerRepository.Count(x => true); } var pageInfo = new PageInfo() { PageNumber = page, PageSize = pageSize, TotalItems = total }; return new PartnerCollectionViewModel() { Partners = partners, PageInfo = pageInfo }; }
void ResizeProgressChanged(object sender, Filtering.FilterProgressEventArgs e) { progress.Progress = e.Progress; if (ProgressChanged != null) ProgressChanged(this, progress); }
public override void Extract(Filtering.FilteredResult fr, ref KnxPort meta) { if (fr.GroupAddress.Ref.ToString() == GroupAddress) meta.MetaData[AttributeName] = Value; }
protected IEnumerable<ReportPositionsModel> GetEntities(Filtering filtering) { var orderId = GetFilters(filtering); var result = new List<ReportPositionsModel>(); if(orderId != 0) { //TODO discuss with customer - take positions where proccessed amount not null (but take with 0) var termPositions = termPositionsManager.GetEntities(o => !o.DeleteDate.HasValue && o.Terms.OrderId == orderId && o.ProccessedAmount.HasValue).ToList(); var id = 0; foreach(var termPosition in termPositions) { //positions if (termPosition.ProccessedAmount.Value > 0) { id++; result.Add(PositionsToModel(id, termPosition.Positions, termPosition.ProccessedAmount.Value, termPosition.Terms.Date)); } //materials foreach(var material in termPosition.TermPositionMaterialRsps.Where(o => !o.DeleteDate.HasValue && o.Amount.HasValue)) { id++; var amount = material.Amount.Value; if(material.Materials.MaterialAmountTypes == MaterialAmountTypes.Meter) { if (material.Materials.Length != 0) { amount = amount / (double)material.Materials.Length.Value; } else { //todo } } result.Add(new ReportPositionsModel() { Id = id, amount = material.Amount.Value, description = material.Materials.Name, number = material.Materials.Number, createDate = termPosition.Terms.Date, amountType = material.Materials.MaterialAmountTypeString, price = material.Materials.Price.ToString("N2") + " EUR", totalPrice = CalculationHelper.CalculatePositionPrice(material.Materials.Price, amount, PaymentTypes.Standard).ToString("N2") + " EUR" }); } } //material positions without terms var materialPositionsWithoutTerms = positionsManager.GetEntities(o => o.OrderId == orderId && !o.DeleteDate.HasValue && !o.TermId.HasValue && o.MaterialId.HasValue && o.IsMaterialPosition).ToList(); foreach (var position in materialPositionsWithoutTerms) { id++; result.Add(PositionsToModel(id, position, position.Amount, position.ChangeDate /*todo check*/)); } //extra costs var termCosts = termCostsManager.GetEntities(o => !o.DeleteDate.HasValue && o.Terms.OrderId == orderId).ToList(); foreach (var termCost in termCosts) { id++; result.Add(new ReportPositionsModel() { Id = id, amount = 1, description = termCost.Name, createDate = termCost.ChangeDate/*todo check*/, amountType = "Pauschal", price = termCost.Price.ToString("N2") + " EUR", totalPrice = CalculationHelper.CalculatePositionPrice(termCost.Price, 1, PaymentTypes.Standard).ToString("N2") + " EUR" }); } } return result.OrderBy(o => o.createDate); }