static void Main(string[] args) { var client = new Client(IPAddress.Loopback, 8888); //// FilterBy = new FilterBy { Property = "Year", Value = 1861 }, //// OrderBy = new OrderBy { Property = "Author", Descending = false }, var filterBy = new FilterBy { Property = "Director", Value = "Steven Spielberg" }; var orderBy = new OrderBy { Property = "Grossing", Descending = true }; var movies = client.GetJson <Movie>(filterBy, orderBy); Console.WriteLine($"\r\nResponse:\r\n{movies}"); var songs = client.GetJson <Song>(); Console.WriteLine($"\r\nResponse:\r\n{songs}"); //var books = client.Get<Book>(); //Console.WriteLine($"\r\nResponse:\r\n{books.SerializeXml(true)}"); //var booksjs = client.GetJson<Book>(new OrderBy("Author")); //Console.WriteLine($"\r\nResponse:\r\n{booksjs}"); var books = client.Get <Book>(null, new OrderBy("Author")); Console.WriteLine(books.SerializeXml(true)); Console.ReadKey(); }
public string GetJson <T>(FilterBy filterBy, OrderBy orderBy) where T : Entity { var message = new Request { EntityType = typeof(T).Name, FilterBy = filterBy, OrderBy = orderBy, ResultAsJson = true, TimeToLive = 2 }; var reqest = message.Serialize(); Console.WriteLine($"\r\nSent:\r\n{message.Serialize(true)}"); var response = SendRequest(reqest); using (var file = File.OpenText($"{typeof(T).Name}sSchema.json")) using (var reader = new JsonTextReader(file)) { var schema = JSchema.Load(reader); var collection = JArray.Parse(response); Console.WriteLine($"Collection is {(collection.IsValid(schema) ? "" : "not ")}valid."); } return(response); }
public ViewResult Index(int page = 1, FilterBy filter = FilterBy.NoFilter, string substring = null) { ViewBag.substring = substring; ViewBag.filter = filter; var characters = repository.Characters .Where(FilterModels.Filters[filter]) .ToArray(); if (!string.IsNullOrEmpty(substring)) { characters = characters.Where(c => c.Name.Contains(substring)).ToArray(); } var charterersOnPage = characters .Skip((page - 1) * PageSize) .Take(PageSize) .Select(c => new CharacterViewModel { Character = c, VoteType = CartHelpers.GetVoteTypeForCharacter(c, cartProvider.GetCart(this)) }) .ToArray(); CharactersListViewModel model = new CharactersListViewModel { Characters = charterersOnPage, PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = characters.Length } }; return(View(model)); }
public void FindComputerWithLowestPriceAndVerify() { VerifyComputer computer = new VerifyComputer(_Driver); bool result = computer.MenuNavigation(_MenuNavigation); Assert.IsTrue(result, computer.GetLastError()); result = computer.FilterBy(FilterBy.DisplaySize(FilterConstants.DisplaySize.Size_15_16_inch)); Assert.IsTrue(result, computer.GetLastError()); result = computer.FilterBy(FilterBy.CPUType(FilterConstants.CPUType.Intel_Core_i5)); Assert.IsTrue(result, computer.GetLastError()); result = computer.FilterBy(FilterBy.StorageType(FilterConstants.StorageType.SSD)); Assert.IsTrue(result, computer.GetLastError()); result = computer.FindComputers(new PostFilter() { Rating = "5", Sort = SortOrder.LowestPrice }); Assert.IsTrue(result, computer.GetLastError()); Product actualResult = computer.GetComputerDetails(); Assert.IsNotNull(actualResult); Assert.AreEqual(computer.ExpectedResult.Name, actualResult.Name); Assert.AreEqual(computer.ExpectedResult.Price, actualResult.Price); }
public List <IGrouping <string, DataRow> > GetLocalGroups( FilterBy filterBy = null, OrderBy orderBy = null) { return(GetDataSubset(filterBy, orderBy ?? new BallotOrderBy()) .GroupBy(row => row.LocalCode()) .ToList()); }
internal static void FilterRosterList(FilterBy filterBy) { switch (filterBy) { case FilterBy.All: RMAddon.AllCrew = (from k in RMAddon.AllCrew select k).ToList(); break; case FilterBy.Assigned: RMAddon.AllCrew = (from k in RMAddon.AllCrew where k.Value.Status == ProtoCrewMember.RosterStatus.Assigned || (k.Value.Status == ProtoCrewMember.RosterStatus.Dead && k.Value.Type == ProtoCrewMember.KerbalType.Unowned) select k).ToList(); break; case FilterBy.Available: RMAddon.AllCrew = (from k in RMAddon.AllCrew where k.Value.Status == ProtoCrewMember.RosterStatus.Available select k).ToList(); break; case FilterBy.Dead: RMAddon.AllCrew = (from k in RMAddon.AllCrew where k.Value.Status == ProtoCrewMember.RosterStatus.Missing || (k.Value.Status == ProtoCrewMember.RosterStatus.Dead && k.Value.Type != ProtoCrewMember.KerbalType.Unowned) select k).ToList(); break; case FilterBy.Dispute: RMAddon.AllCrew = (from k in RMAddon.AllCrew where k.Value.Type == ProtoCrewMember.KerbalType.Tourist && k.Value.SalaryContractDispute select k).ToList(); break; case FilterBy.Frozen: RMAddon.AllCrew = (from k in RMAddon.AllCrew where k.Value.Status == ProtoCrewMember.RosterStatus.Dead && k.Value.Type == ProtoCrewMember.KerbalType.Unowned select k).ToList(); break; default: RMAddon.AllCrew = (from k in RMAddon.AllCrew select k).ToList(); break; } }
public IList <IGrouping <string, DataRow> > GetGroupedSubset( FilterBy filterBy = null) { return(GetDataSubset(filterBy, new OfficialsSort()) .GroupBy(row => row.OfficeKey()) .ToList()); }
public void CloneTest() { ElementConfiguration prototype = new ElementConfiguration(); prototype.ElementType = ElementType.Delegate; prototype.Id = "Test"; FilterBy filterBy = new FilterBy(); filterBy.Condition = "$(Name) == 'Test'"; prototype.FilterBy = filterBy; GroupBy groupBy = new GroupBy(); groupBy.By = ElementAttributeType.Access; prototype.GroupBy = groupBy; SortBy sortBy = new SortBy(); sortBy.By = ElementAttributeType.Name; prototype.SortBy = sortBy; ElementConfiguration clone = prototype.Clone() as ElementConfiguration; Assert.IsNotNull(clone, "Clone did not return an instance."); Assert.AreEqual(prototype.ElementType, clone.ElementType, "ElementType was not cloned correctly."); Assert.AreEqual(prototype.Id, clone.Id, "Id was not cloned correctly."); Assert.AreEqual(prototype.FilterBy.Condition, clone.FilterBy.Condition, "FilterBy was not cloned correctly."); Assert.AreEqual(prototype.GroupBy.By, clone.GroupBy.By, "GroupBy was not cloned correctly."); Assert.AreEqual(prototype.SortBy.By, clone.SortBy.By, "SortBy was not cloned correctly."); }
/// <summary> /// Gets a boolean indicating whether or not the file is a /// recognized source file. /// </summary> /// <param name="fileName">File to test.</param> /// <param name="extensions">Extension configurations.</param> /// <returns>A boolean indicating whehther or not the file is recognized.</returns> private static bool IsRecognizedFile(string fileName, ExtensionConfigurationCollection extensions) { bool isRecognizedFile = true; string extension = GetExtension(fileName); ExtensionConfiguration extensionConfiguration = null; foreach (ExtensionConfiguration extensionEntry in extensions) { if (extensionEntry.Name == extension) { extensionConfiguration = extensionEntry; break; } } if (extensionConfiguration != null && extensionConfiguration.FilterBy != null) { FilterBy filterBy = extensionConfiguration.FilterBy; FileFilter fileFilter = new FileFilter(filterBy.Condition); if (File.Exists(fileName)) { isRecognizedFile = fileFilter.IsMatch(new FileInfo(fileName)); } } return(isRecognizedFile); }
public IEnumerable <IGrouping <string, DataRow> > GetGroupedSubset( [CanBeNull] FilterBy filterBy = null, [CanBeNull] OrderBy orderBy = null) { return(GetDataSubset(filterBy, orderBy ?? new ElectionSort()) .GroupBy(row => row.OfficeKey()) .ToList()); }
private IQueryable <Thesis> SetFilterClause(IQueryable <Thesis> theses, FilterBy filterBy, string keyWord) { switch (filterBy) { case FilterBy.FacultyNumber: long number = 0; if (long.TryParse(keyWord, out number)) { theses = theses.Where(t => t.Student.FacultyNumber == number); } else { isKeyWordCorrect = false; } break; case FilterBy.EGN: long egn = 0; if (long.TryParse(keyWord, out egn)) { theses = theses.Where(t => t.Student.User.EGN == egn); } else { isKeyWordCorrect = false; } break; case FilterBy.StudentName: theses = theses.Where(t => t.Student.User.FirstName.Contains(keyWord) || t.Student.User.MiddleName.Contains(keyWord) || t.Student.User.LastName.Contains(keyWord)); break; case FilterBy.TeacherName: theses = theses.Where(t => t.Supervisor.User.FirstName.Contains(keyWord) || t.Supervisor.User.MiddleName.Contains(keyWord) || t.Supervisor.User.LastName.Contains(keyWord)); break; case FilterBy.Specialty: theses = theses.Where(t => t.Student.Specialty.Title.Contains(keyWord)); break; case FilterBy.Faculty: theses = theses.Where(t => t.Student.Specialty.Faculty.Title.Contains(keyWord)); break; case FilterBy.Thesis: theses = theses.Where(t => t.Title.Contains(keyWord)); break; case FilterBy.Description: theses = theses.Where(t => t.Description.Contains(keyWord)); break; } return(theses); }
public void CreateTest() { FilterBy filterBy = new FilterBy(); // // Verify default state // Assert.IsNull(filterBy.Condition, "Unexpected default value for Condition."); }
/// <summary>Sets the filter for this interrogator.</summary> /// <param name="filter">The filter.</param> public void SetFilter(FilterBy filter) { IQueryBuilder queryBuilder; if (!filterToQueryBuilder.TryGetValue(filter, out queryBuilder)) { Logger.LogMessage(new LogMessage("This filter is not supported by this Interrogator", Severity.Error)); } QueryBuilder = queryBuilder; }
public void ToStringTest() { FilterBy filterBy = new FilterBy(); filterBy.Condition = "$(Access) == 'Protected'"; string str = filterBy.ToString(); Assert.AreEqual("Filter by: $(Access) == 'Protected'", str, "Unexpected string representation."); }
/// <summary> /// Creates an element filter. /// </summary> /// <param name="filterBy">The filter by.</param> /// <returns>An element filter.</returns> private static IElementFilter CreateElementFilter(FilterBy filterBy) { IElementFilter filter = null; if (filterBy != null) { filter = new ElementFilter(filterBy.Condition); } return(filter); }
private static IEnumerable <T> FilterBy <T>(this IEnumerable <T> collection, FilterBy filter) { var value = filter.Value; if (typeof(T).GetProperty(filter.Property).PropertyType == typeof(int)) { value = int.Parse(filter.Value.ToString()); } return(collection.Where($"{filter.Property} = @0", value)); }
public List <IGrouping <string, DataRow> > GetOfficeGroups( FilterBy filterBy = null, OrderBy orderBy = null) { var offices = GetDataSubset(filterBy, orderBy ?? new BallotOrderBy()) .GroupBy(row => row.OfficeKey()); if (Elections.IsPrimaryElection(ElectionKey)) { offices = FilterUncontestedOffices(offices); } return(offices.ToList()); }
public void FilterJobs(string by, string value) { try { FilterBy filter = this.jobsPage.GetFilterByName(by); filter.SetValue(value); } catch (Exception ex) { TRAssert.Fail("Error while filtering jobs by : " + by, ex); } }
private static void DisplayRosterFilter() { GUILayout.BeginHorizontal(); GUILayout.Label("Kerbal Filter:", GUILayout.Width(90)); var isAll = FilteredBy == FilterBy.All; isAll = GUILayout.Toggle(isAll, "All", GUILayout.Width(50)); if (isAll) { FilteredBy = FilterBy.All; } var isAssign = FilteredBy == FilterBy.Assigned; isAssign = GUILayout.Toggle(isAssign, "Assigned", GUILayout.Width(80)); if (isAssign) { FilteredBy = FilterBy.Assigned; } var isAvail = FilteredBy == FilterBy.Available; isAvail = GUILayout.Toggle(isAvail, "Available", GUILayout.Width(80)); if (isAvail) { FilteredBy = FilterBy.Available; } var isDead = FilteredBy == FilterBy.Dead; isDead = GUILayout.Toggle(isDead, "Dead/Missing", GUILayout.Width(100)); if (isDead) { FilteredBy = FilterBy.Dead; } var isDispute = FilteredBy == FilterBy.Dispute; isDispute = GUILayout.Toggle(isDispute, "Dispute", GUILayout.Width(80)); if (isDispute) { FilteredBy = FilterBy.Dispute; } if (Api.InstalledMods.IsDfInstalled) { var isFrozen = FilteredBy == FilterBy.Frozen; isFrozen = GUILayout.Toggle(isFrozen, "Frozen", GUILayout.Width(80)); if (isFrozen) { FilteredBy = FilterBy.Frozen; } } GUILayout.EndHorizontal(); }
public IList <T> GetDataSubset(FilterBy filterBy = null, OrderBy orderBy = null) { IEnumerable <T> result = DataList; if (filterBy != null) { result = result.Where(filterBy.Filter); } if (orderBy != null) { result = result.OrderBy(row => row, orderBy); } return(result.ToList()); }
public IList <T> GetDataSubset(FilterBy filterBy = null, OrderBy orderBy = null) { var result = DataTable.Rows.OfType <T>(); if (filterBy != null) { result = result.Where(filterBy.Filter); } if (orderBy != null) { result = result.OrderBy(row => row, orderBy); } return(result.ToList()); }
public string GetXml <T>(FilterBy filterBy, OrderBy orderBy) where T : Entity { var message = new Request { EntityType = typeof(T).Name, FilterBy = filterBy, OrderBy = orderBy, TimeToLive = 2 }; var reqest = message.Serialize(); Console.WriteLine($"\r\nSent:\r\n{message.Serialize(true)}"); var response = SendRequest(reqest); return(response); }
protected void Filter() { if (!ShouldFilter()) { return; } var prop = GetPropertyInfo(FilterBy.ToLowerInvariant()); if (prop == null) { return; } var op = GetFilterOperation(); Operations = Operations.Where(x => SatisfyFilter(x, prop, FilterValue, op)); }
public void CloneTest() { ExtensionConfiguration extensionConfiguration = new ExtensionConfiguration(); extensionConfiguration.Name = "cs"; FilterBy filter = new FilterBy(); filter.Condition = "$(File.Name) != 'Test.cs'"; extensionConfiguration.FilterBy = filter; ExtensionConfiguration clone = extensionConfiguration.Clone() as ExtensionConfiguration; Assert.IsNotNull(clone, "Clone did not return a valid instance."); Assert.AreEqual(extensionConfiguration.Name, clone.Name); Assert.IsNotNull(clone.FilterBy, "FilterBy was not cloned."); Assert.AreEqual(extensionConfiguration.FilterBy.Condition, clone.FilterBy.Condition); }
public List <T> Get <T>(FilterBy filterBy, OrderBy orderBy) where T : Entity { var message = new Request { EntityType = typeof(T).Name, FilterBy = filterBy, OrderBy = orderBy, TimeToLive = 2 }; var reqest = message.Serialize(); Console.WriteLine($"\r\nSent:\r\n{message.SerializeXml(true)}"); var response = SendRequest(reqest); Console.WriteLine($"\r\nCollection is {(IsValidXml<T>(response) ? "" : "not ")}valid."); return(response.Deserialize <List <T> >()); }
public static IQueryable <BookListDTO> FilterBookList( this IQueryable <BookListDTO> books, FilterBy filterBy, string filterValue) { switch (filterBy) { case FilterBy.NoFilter: return(books); case FilterBy.Year: return(books.Where(b => b.YearPublished == int.Parse(filterValue))); case FilterBy.StarRating: return(books.Where(b => b.Star >= int.Parse(filterValue))); case FilterBy.Genres: return(books.Where(b => b.YearPublished == int.Parse(filterValue))); default: throw new InvalidEnumArgumentException(); } }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { foreach (DataGridViewCell cell in dataGridView1.SelectedCells) { int columnIndex = cell.ColumnIndex; int rowIndex = cell.RowIndex; if (columnIndex == 0) { filter = FilterBy.StudentID; } else if (columnIndex == 1) { filter = FilterBy.FirstName; } else if (columnIndex == 2) { filter = FilterBy.LastName; } StudentID = dataGridView1[0, rowIndex].Value.ToString(); dataGridView1.CurrentCell = dataGridView1[columnIndex, rowIndex]; } }
public IEnumerable <DropDownFilterValues> GetDropDownFilterValues(FilterBy option) { switch (option) { case QueryObjects.FilterBy.NoFilter: return(new List <DropDownFilterValues>()); case QueryObjects.FilterBy.Year: return(context.Books .Select(b => new DropDownFilterValues { Value = b.Year, Text = b.Year }).Distinct().ToList()); case QueryObjects.FilterBy.StarRating: return(FormVotesDropDown()); default: throw new ArgumentOutOfRangeException(nameof(option), option, null); } }
public void ArrangeProjectFilteredTest() { CodeConfiguration filterProjectConfig = CodeConfiguration.Default.Clone() as CodeConfiguration; // Set up the filter FilterBy filter = new FilterBy(); filter.Condition = "!($(File.Path) : '.Filtered.')"; ((ProjectHandlerConfiguration)filterProjectConfig.Handlers[0]).ProjectExtensions[0].FilterBy = filter; string filterProjectConfigFile = Path.Combine(Path.GetTempPath(), "FilterProjectConfig.xml"); try { filterProjectConfig.Save(filterProjectConfigFile); TestLogger logger = new TestLogger(); FileArranger fileArranger = new FileArranger(filterProjectConfigFile, logger); bool success = fileArranger.Arrange(_testFilteredProjectFile, null); Assert.IsTrue(success, "Expected file to be arranged succesfully."); Assert.IsTrue( logger.HasMessage(LogLevel.Verbose, "0 files written."), "Expected 0 files to be written - " + logger.ToString()); } finally { try { File.Delete(filterProjectConfigFile); } catch { } } }
public static int Main( string[] arguments ) { //Console.WindowWidth = 100; //Console.BufferWidth = 100; //Console.WindowHeight = Console.LargestWindowHeight - 1; //Console.BufferHeight = 1000; for (int i = 0; i < arguments.Length; i++) { string arg = arguments[i]; bool isOpt = false; while (arg.StartsWith("/") || arg.StartsWith("-")) { arg = arg.Substring(1); isOpt = true; } if (isOpt) { if (arg == "?" || arg.Equals("h", StringComparison.CurrentCultureIgnoreCase) || arg.Equals("help", StringComparison.CurrentCultureIgnoreCase)) { ShowUsage(); return 0; } else if (arg.Equals("v", StringComparison.CurrentCultureIgnoreCase) || arg.Equals("version", StringComparison.CurrentCultureIgnoreCase)) { ShowVersion(arg.Equals("version", StringComparison.CurrentCultureIgnoreCase)); return 0; } else if (arg.Equals("p", StringComparison.CurrentCultureIgnoreCase) || arg.Equals("pause", StringComparison.CurrentCultureIgnoreCase) || arg.Equals("pause-per-page", StringComparison.CurrentCultureIgnoreCase)) { pausePerPage = true; } else if (arg.Equals("pp", StringComparison.CurrentCultureIgnoreCase) || arg.Equals("pause-at-end", StringComparison.CurrentCultureIgnoreCase)) { pauseAtEnd = true; } else if (arg.Equals("no-wrap", StringComparison.CurrentCultureIgnoreCase)) { dontWrapOutput = true; } else if (arg.StartsWith("wrap", StringComparison.CurrentCultureIgnoreCase) || arg.StartsWith("width", StringComparison.CurrentCultureIgnoreCase)) { int pos = arg.IndexOfAny(new char[] { '=', ':' }); if (pos == -1) { Console.Error.WriteLine("invalid option: " + arg); return 1; } string tmp = arg.Substring(pos + 1).Trim(); int tmpWrap = 0; if (!int.TryParse(tmp, out tmpWrap)) { Console.Error.WriteLine("invalid option: " + arg); return 1; } width = Math.Max(20, tmpWrap); } else if (arg.Equals("no-indent", StringComparison.CurrentCultureIgnoreCase)) { envarIndentation = 0; } else if (arg.StartsWith("indent", StringComparison.CurrentCultureIgnoreCase)) { int pos = arg.IndexOfAny(new char[] { '=', ':' }); if (pos == -1) { Console.Error.WriteLine("invalid option: " + arg); return 1; } string tmp = arg.Substring(pos + 1).Trim(); int tmpIndent = 0; if (tmp.Equals("all", StringComparison.InvariantCultureIgnoreCase) || tmp.StartsWith("max", StringComparison.InvariantCultureIgnoreCase)) { envarIndentation = -1; } else if (int.TryParse(tmp, out tmpIndent)) { envarIndentation = tmpIndent; // Math.Max(0, tmpIndent); } else { Console.Error.WriteLine("invalid option: " + arg); return 1; } } else if (arg.StartsWith("align", StringComparison.CurrentCultureIgnoreCase)) { int pos = arg.IndexOfAny(new char[] { '=', ':' }); if (pos == -1) { Console.Error.WriteLine("invalid option: " + arg); return 1; } string tmp = arg.Substring(pos + 1).Trim(); if (tmp.StartsWith("l", StringComparison.CurrentCultureIgnoreCase)) { rightAligned = false; } else if (tmp.StartsWith("r", StringComparison.CurrentCultureIgnoreCase)) { rightAligned = true; } else { Console.Error.WriteLine("invalid option: " + arg); return 1; } } else if (arg.Equals("lower", StringComparison.CurrentCultureIgnoreCase) || arg.Equals("lower-case", StringComparison.CurrentCultureIgnoreCase)) { lowerKey = true; } else if (arg.Equals("upper", StringComparison.CurrentCultureIgnoreCase) || arg.Equals("upper-case", StringComparison.CurrentCultureIgnoreCase)) { lowerKey = false; } else if (arg.Equals("all", StringComparison.CurrentCultureIgnoreCase)) { showAll = true; } else if (arg.Equals("machine", StringComparison.CurrentCultureIgnoreCase)) { showMachine = true; showAll = false; } else if (arg.Equals("process", StringComparison.CurrentCultureIgnoreCase)) { showProcess = true; showAll = false; } else if (arg.Equals("user", StringComparison.CurrentCultureIgnoreCase)) { showUser = true; showAll = false; } else if (arg.Equals("name", StringComparison.CurrentCultureIgnoreCase)) { filterBy = FilterBy.name; } else if (arg.Equals("value", StringComparison.CurrentCultureIgnoreCase)) { filterBy = FilterBy.value; } else if (arg.Equals("regex", StringComparison.CurrentCultureIgnoreCase)) { use_regex = true; } else { Console.Error.WriteLine("unknown command: " + arg); return 2; } } else { filter = (filter + " " + arg).Trim(); } } StringBuilder s = new StringBuilder(); if (showAll) { // Show all.. s.AppendLine().Append(Text.WriteCenteredLine(" All Environment Variables ", '-')); ShowVariables(Environment.GetEnvironmentVariables(), s); } else { if (showMachine) { s.Append(Text.WriteCenteredLine(" Machine Environment Variables ", '-')); ShowVariables(Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Machine), s); } if (showProcess) { s.Append(Text.WriteCenteredLine(" Process Environment Variables ", '-')); ShowVariables(Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Process), s); } if (showUser) { s.Append(Text.WriteCenteredLine(" User Environment Variables ", '-')); ShowVariables(Environment.GetEnvironmentVariables(EnvironmentVariableTarget.User), s); } } // Write the results to the screen if (ConsoleEx.IsOutputRedirected || dontWrapOutput) { Console.Out.Write(s.ToString()); } else { int count = 0; if (pausePerPage) { string[] lines = s.ToString().Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); int h = Console.WindowHeight; for (int i = 0; i < lines.Length; i++) { if (count >= h - 1) { ConsoleEx.SimplePressAnyKey("Press any key to continue"); count = 0; } Console.Out.WriteLine(lines[i].TrimEnd()); count++; } } else { Console.Out.Write(s.ToString()); } if (pauseAtEnd && (!pausePerPage || count > 0)) { ConsoleEx.SimplePressAnyKey(); } } return 0; }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as Subscription; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (Identifier != null) { dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy()); } if (NameElement != null) { dest.NameElement = (Hl7.Fhir.Model.FhirString)NameElement.DeepCopy(); } if (StatusElement != null) { dest.StatusElement = (Code <Hl7.Fhir.Model.SubscriptionState>)StatusElement.DeepCopy(); } if (Topic != null) { dest.Topic = (Hl7.Fhir.Model.ResourceReference)Topic.DeepCopy(); } if (Contact != null) { dest.Contact = new List <Hl7.Fhir.Model.ContactPoint>(Contact.DeepCopy()); } if (EndElement != null) { dest.EndElement = (Hl7.Fhir.Model.Instant)EndElement.DeepCopy(); } if (ReasonElement != null) { dest.ReasonElement = (Hl7.Fhir.Model.FhirString)ReasonElement.DeepCopy(); } if (FilterBy != null) { dest.FilterBy = new List <Hl7.Fhir.Model.Subscription.FilterByComponent>(FilterBy.DeepCopy()); } if (Error != null) { dest.Error = new List <Hl7.Fhir.Model.CodeableConcept>(Error.DeepCopy()); } if (ChannelType != null) { dest.ChannelType = (Hl7.Fhir.Model.Coding)ChannelType.DeepCopy(); } if (EndpointElement != null) { dest.EndpointElement = (Hl7.Fhir.Model.FhirUrl)EndpointElement.DeepCopy(); } if (HeaderElement != null) { dest.HeaderElement = new List <Hl7.Fhir.Model.FhirString>(HeaderElement.DeepCopy()); } if (HeartbeatPeriodElement != null) { dest.HeartbeatPeriodElement = (Hl7.Fhir.Model.UnsignedInt)HeartbeatPeriodElement.DeepCopy(); } if (TimeoutElement != null) { dest.TimeoutElement = (Hl7.Fhir.Model.UnsignedInt)TimeoutElement.DeepCopy(); } if (ContentTypeElement != null) { dest.ContentTypeElement = (Hl7.Fhir.Model.Code)ContentTypeElement.DeepCopy(); } if (ContentElement != null) { dest.ContentElement = (Code <Hl7.Fhir.Model.Subscription.SubscriptionPayloadContent>)ContentElement.DeepCopy(); } return(dest); }
private IQueryable<Thesis> SetFilterClause(IQueryable<Thesis> theses, FilterBy filterBy, string keyWord) { switch (filterBy) { case FilterBy.FacultyNumber: long number = 0; if (long.TryParse(keyWord, out number)) { theses = theses.Where(t => t.Student.FacultyNumber == number); } else { isKeyWordCorrect = false; } break; case FilterBy.EGN: long egn = 0; if (long.TryParse(keyWord, out egn)) { theses = theses.Where(t => t.Student.User.EGN == egn); } else { isKeyWordCorrect = false; } break; case FilterBy.StudentName: theses = theses.Where(t => t.Student.User.FirstName.Contains(keyWord) || t.Student.User.MiddleName.Contains(keyWord) || t.Student.User.LastName.Contains(keyWord)); break; case FilterBy.TeacherName: theses = theses.Where(t => t.Supervisor.User.FirstName.Contains(keyWord) || t.Supervisor.User.MiddleName.Contains(keyWord) || t.Supervisor.User.LastName.Contains(keyWord)); break; case FilterBy.Specialty: theses = theses.Where(t => t.Student.Specialty.Title.Contains(keyWord)); break; case FilterBy.Faculty: theses = theses.Where(t => t.Student.Specialty.Faculty.Title.Contains(keyWord)); break; case FilterBy.Thesis: theses = theses.Where(t => t.Title.Contains(keyWord)); break; case FilterBy.Description: theses = theses.Where(t => t.Description.Contains(keyWord)); break; } return theses; }
public void SearchCriteria(FilterBy filterBy, Guid id) { EntityId = id; FilterBy = filterBy; }
protected bool _internalRequest = false; //if request comes from bbc servers or not public baseService(string connectionString, ISiteList siteList, IDnaDiagnostics dnaDiag) { if (ConfigurationManager.AppSettings["MaintenanceMode"] == "1") { throw new DnaWebProtocolException(ApiException.GetError(ErrorType.MaintenanceMode)); } _connectionString = connectionString; this.siteList = siteList; readerCreator = new DnaDataReaderCreator(connectionString, dnaDiag); dnaDiagnostic = dnaDiag; cacheManager = CacheFactory.GetCacheManager(); if (WebOperationContext.Current == null) { throw new Exception("Error creating web operation context object."); } WebFormat.getReturnFormat((WebOperationContext.Current.IncomingRequest.ContentType == null ? "" : WebOperationContext.Current.IncomingRequest.ContentType), ref outputContentType, ref format); if (format == WebFormat.format.UNKNOWN) { throw new DnaWebProtocolException(ApiException.GetError(ErrorType.UnknownFormat)); } itemsPerPage = QueryStringHelper.GetQueryParameterAsInt("itemsPerPage", 20); startIndex = QueryStringHelper.GetQueryParameterAsInt("startIndex", 0); try { sortBy = (SortBy)Enum.Parse(typeof(SortBy), QueryStringHelper.GetQueryParameterAsString("sortBy", "")); } catch { } try { sortDirection = (SortDirection)Enum.Parse(typeof(SortDirection), QueryStringHelper.GetQueryParameterAsString("sortDirection", "")); } catch { } string filter = QueryStringHelper.GetQueryParameterAsString("filterBy", ""); if (!String.IsNullOrEmpty(filter)) { try { filterBy = (FilterBy)Enum.Parse(typeof(FilterBy), filter); } catch { } } switch (filterBy) {//add parsing of filter by data here. case FilterBy.UserList: filterByData = QueryStringHelper.GetQueryParameterAsString("userList", ""); break; case FilterBy.PostsWithinTimePeriod: filterByData = QueryStringHelper.GetQueryParameterAsString("timeperiod", ""); break; } prefix = QueryStringHelper.GetQueryParameterAsString("prefix", ""); signOnType = QueryStringHelper.GetQueryParameterAsString("signOnType", "identity"); summaryLength= QueryStringHelper.GetQueryParameterAsInt("summaryLength", 256); if(!String.IsNullOrEmpty(QueryStringHelper.GetCookieValueAsString("BGUID", Guid.Empty.ToString()))) {//try for BGUID first try { bbcUidCookie = new Guid(QueryStringHelper.GetCookieValueAsString("BGUID", Guid.Empty.ToString())); } catch { bbcUidCookie = Guid.Empty; } } if(bbcUidCookie == Guid.Empty) { string cookie = QueryStringHelper.GetCookieValueAsString("BBC-UID", Guid.Empty.ToString()); bbcUidCookie = UidCookieDecoder.Decode(cookie, ConfigurationManager.AppSettings["SecretKey"]); } _iPAddress = QueryStringHelper.GetQueryParameterAsString("clientIP", ""); if (string.IsNullOrEmpty(_iPAddress)) { _iPAddress = QueryStringHelper.GetHeaderValueAsString("REMOTE_ADDR", ""); } _internalRequest = (QueryStringHelper.GetQueryParameterAsString("_bbc_", "") == "1"); debugDnaUserId = ""; #if DEBUG debugDnaUserId = QueryStringHelper.GetQueryParameterAsString("d_identityuserid", ""); if (debugDnaUserId.Length == 0) { debugDnaUserId = QueryStringHelper.GetCookieValueAsString("DNADEBUGUSER", ""); } if (debugDnaUserId.Length > 0) { debugDnaUserId = debugDnaUserId.Replace("ID-",""); } #endif }
private static int GetPages(IThesesSystemData data, string action, int id = 0, string keyWord = null, FilterBy filterBy = FilterBy.All) { int pageNumber = 0; switch (action) { case "StorageIndex": if (keyWord == null) { pageNumber = (int)Math.Ceiling((double)data.Theses.All().Where(t => t.IsComplete).Count() / GlobalConstants.ELEMENTS_PER_PAGE); break; } switch (filterBy) { case FilterBy.All: pageNumber = (int)Math.Ceiling((double)data.Theses.All().Where(t => t.IsComplete).Count() / GlobalConstants.ELEMENTS_PER_PAGE); break; case FilterBy.FacultyNumber: long number = 0; if (long.TryParse(keyWord, out number)) { pageNumber = (int)Math.Ceiling((double)data.Theses.All() .Where(t => t.IsComplete && t.Student.FacultyNumber == number) .Count() / GlobalConstants.ELEMENTS_PER_PAGE); } else { pageNumber = (int)Math.Ceiling((double)data.Theses.All().Where(t => t.IsComplete).Count() / GlobalConstants.ELEMENTS_PER_PAGE); } break; case FilterBy.EGN: long egn = 0; if (long.TryParse(keyWord, out egn)) { pageNumber = (int)Math.Ceiling((double)data.Theses.All() .Where(t => t.IsComplete && t.Student.User.EGN == egn) .Count() / GlobalConstants.ELEMENTS_PER_PAGE); } else { pageNumber = (int)Math.Ceiling((double)data.Theses.All().Where(t => t.IsComplete).Count() / GlobalConstants.ELEMENTS_PER_PAGE); } break; case FilterBy.StudentName: pageNumber = (int)Math.Ceiling((double)data.Theses.All() .Where(t => t.IsComplete && (t.Student.User.FirstName.Contains(keyWord) || t.Student.User.MiddleName.Contains(keyWord) || t.Student.User.LastName.Contains(keyWord))) .Count() / GlobalConstants.ELEMENTS_PER_PAGE); break; case FilterBy.TeacherName: pageNumber = (int)Math.Ceiling((double)data.Theses.All() .Where(t => t.IsComplete && (t.Supervisor.User.FirstName.Contains(keyWord) || t.Supervisor.User.MiddleName.Contains(keyWord) || t.Supervisor.User.LastName.Contains(keyWord))) .Count() / GlobalConstants.ELEMENTS_PER_PAGE); break; case FilterBy.Specialty: pageNumber = (int)Math.Ceiling((double)data.Theses.All() .Where(t => t.IsComplete && (t.Student.Specialty.Title.Contains(keyWord))) .Count() / GlobalConstants.ELEMENTS_PER_PAGE); break; case FilterBy.Faculty: pageNumber = (int)Math.Ceiling((double)data.Theses.All() .Where(t => t.IsComplete && (t.Student.Specialty.Faculty.Title.Contains(keyWord))) .Count() / GlobalConstants.ELEMENTS_PER_PAGE); break; case FilterBy.Thesis: pageNumber = (int)Math.Ceiling((double)data.Theses.All() .Where(t => t.IsComplete && (t.Title.Contains(keyWord))) .Count() / GlobalConstants.ELEMENTS_PER_PAGE); break; case FilterBy.Description: pageNumber = (int)Math.Ceiling((double)data.Theses.All() .Where(t => t.IsComplete && (t.Description.Contains(keyWord))) .Count() / GlobalConstants.ELEMENTS_PER_PAGE); break; } break; case "UserVerification": pageNumber = (int)Math.Ceiling((double)data.Users.All().Where(u => !u.IsVerified).Count() / GlobalConstants.ELEMENTS_PER_PAGE); break; case "IdeaThemes": pageNumber = (int)Math.Ceiling((double)data.ThesisThemes.All().Count() / GlobalConstants.ELEMENTS_PER_PAGE); break; case "TutorialIndex": pageNumber = (int)Math.Ceiling((double)data.ThesisTutorials.All().Count() / GlobalConstants.ELEMENTS_PER_PAGE); break; case "SpecialtySpecialtyProfile": pageNumber = (int)Math.Ceiling((double)data.Students.All().Where(s => s.SpecialtyId == id).Count() / GlobalConstants.ELEMENTS_PER_PAGE); break; default: pageNumber = 0; break; } return pageNumber; }