Exemplo n.º 1
0
		private ElementFilter<ClientCompanyColumnName, ClientCompany, ClientCompaniesListFilter> BuildFilter(ClientCompaniesListFilter filter)
		{
			var companyActiveStatus = ClientCompanyStatus.Active.ToString();
			var companyInactiveStatus = ClientCompanyStatus.Inactive.ToString();

			IEnumerable<string> filterStatuses = new[] { companyActiveStatus, companyInactiveStatus };
			if (filter.FilterByActiveStatus || filter.FilterByInactiveStatus)
			{
				if (!filter.FilterByActiveStatus)
				{
					filterStatuses = filterStatuses.Where(e => e != companyActiveStatus);
				}

				if (!filter.FilterByInactiveStatus)
				{
					filterStatuses = filterStatuses.Where(e => e != companyInactiveStatus);
				}
			}

			return ShorFilter.AddFilter<ClientCompanyColumnName, ClientCompany, ClientCompaniesListFilter>(f => !string.IsNullOrWhiteSpace(f.CompanyName), c => c.CompanyName.ToUpper().Contains(filter.CompanyName.ToUpper())).
					AddFilter(f => !string.IsNullOrWhiteSpace(f.CompanyId), c => c.CompanyId.ToUpper().Contains(filter.CompanyId.ToUpper())).
					AddFilter(f => true, c => filterStatuses.Contains(c.StatusId)).
					AddFilter(f => filter.IsWholesaleChannel, c => c.Profile.IsWholesale).
					AddFilter(f => filter.IsLender, c => c.Profile.IsLender).
					AddOrders(ClientCompanyColumnName.CompanyNameOrder, c => c.CompanyName).
					AddOrders(ClientCompanyColumnName.CompanyIdOrder, c => c.CompanyId).
					AddOrders(ClientCompanyColumnName.Status, c => c.StatusId);
		}
Exemplo n.º 2
0
 public static InventorySlot GetWardSlot()
 {
     var wardIds = new[] { 2049, 2045, 2301, 2302, 2303, 3711, 1408, 1409, 1410, 1411, 3932, 3340, 2043 };
     return
         wardIds.Where(Items.CanUseItem)
             .Select(i => Program.Player.InventoryItems.First(slot => slot.Id == (ItemId)i))
             .FirstOrDefault();
 }
Exemplo n.º 3
0
        public void AsCached_CachesScalarData()
        {
            var data = new[] { new { Te2st = "value" } }.ToList();
            var query = data.Where(item => item.Te2st == "value").AsQueryable().AsCached();

            query.Count();

            data.Clear();

            Assert.AreEqual(1, query.Count());
        }
Exemplo n.º 4
0
        public void AsCached_NotifysInvalidatonAfterGet()
        {
            var invalidatorMock = new Mock<Invalidator>();

            var data = new[] { new { Test = "value" } }.ToList();
            var query = data.Where(item => item.Test == "value").AsQueryable();

            query.AsCached().ToArray();
            query.AsCached(invalidatorMock.Object).ToArray();

            invalidatorMock.Verify(mock => mock.OnCacheHit(It.IsAny<Container>(), It.IsAny<IQueryable>(), It.IsAny<string>(), It.IsAny<object>()), Times.Once);
        }
Exemplo n.º 5
0
        public static MiningQuery CompileQuerys(string question)
        {
            var scopequery = default(MiningQuery);

            var querys = new Dictionary<string, IEnumerable<string>>();
            var expression = string.Empty;
            var match = default(Match);

            question = question?.ToLower();

            //  Welche Informationsobjekte sollen gefunden werden?
            var scopes = new[]
            {
                "rezept"
            };
            var contextscopes = scopes.Where(scope => question.Contains(scope)).Concat(question.Split(' ').First().GetPluralSynonyms());
            if (contextscopes.Any())
            {
                scopequery = new MiningQuery {
                    Target = MiningConstants.PropertyTag,
                    Expressions = contextscopes
                };

                //  Kontext = Rezept
                if(contextscopes.Any(scope => scope == "rezept"))
                {
                    var parameter = default(string);

                    //  Suchfaktor "Zutat"
                    expression = "mit.*";
                    match = Regex.Match(question, expression);
                    parameter = match != null && match.Success ? Regex.Replace(match.Value, "mit ", string.Empty) : parameter;

                    var zutaten = Regex.Split(parameter, "(und|oder|,)").Where(token => !Regex.IsMatch(token, "(und|oder|,)")).Select(token => token.Trim());
                    if(zutaten != null)
                    {
                        foreach(var zutat in zutaten)
                        {
                            var synonyms = zutat.GetPluralSynonyms();

                            var q = querys.ContainsKey("zutat") ? querys["zutat"] : new List<string>();
                            q = q.Concat(synonyms.Select(synonym => $".*?{synonym}.*?").Distinct());
                            querys["zutat"] = q;
                        }
                    }
                }
            }

            return scopequery;
        }
        public static IEnumerable<string> AllBut(params string[] exclude)
        {
            var names = new []
                            {
                                ProductName.AgedBrie,
                                ProductName.ConjuredManaCake,
                                ProductName.DexterityVest,
                                ProductName.MongooseElixir,
                                ProductName.BackStagePasses.Tafkal80Etc,
                                ProductName.Sulfuras.HandOfRagnaros
                            };

            return names.Where(x => exclude.All(y => y != x));
        }
Exemplo n.º 7
0
        public void DoIt()
        {
            // Ex. 1
            {
                var ints = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
                var superbClasses = new List<SuperbClass>();

                for (var i = 0; i < ints.Length; i++)
                {
                    if (ints[i] % 2 == 0)
                    {
                        var superbClass = new SuperbClass { SuperbInt = ints[i] };
                        superbClasses.Add(superbClass);
                    }
                }

                var superbLinqClasses =
                    ints
                        .Where(i => i % 2 == 0)
                        .Select(i => new SuperbClass { SuperbInt = i });
            }

            // Ex. 2
            {
                var ints = new[] {1, 2, 3, 4, 5, 6, 7, 8, 9};
                var skip = true;
                var list = new List<int>();

                for (var i = 0; i < ints.Length; i++)
                {
                    if (ints[i]%3 == 0)
                    {
                        if (skip)
                        {
                            skip = false;
                            continue;
                        }

                        if (list.Count > 1)
                            break;

                        list.Add(ints[i]);
                    }
                }

                var myLinqList = ints.Where(i => i%3 == 0).Skip(1).Take(2);
            }
        }
Exemplo n.º 8
0
        private string GetAreaType(string result)
        {
            var descriptionIndex = result.IndexOf('(');
            var contentsIndex = result.IndexOf('[');
            var dimensionsIndex = result.IndexOf('{');
            var indices = new[] { descriptionIndex, contentsIndex, dimensionsIndex };
            var validIndices = indices.Where(i => i >= 0);

            if (validIndices.Any() == false)
                return result;

            var firstIndex = validIndices.Min();
            var areaType = result.Substring(0, firstIndex);

            return areaType;
        }
Exemplo n.º 9
0
        public IList<Product> GetProducts()
        {
            var products = new[]
                               {
                                   new Product {Id = 1, Name = "Apples"},
                                   new Product {Id = 2, Name = "Oranges"},
                                   new Product {Id = 3, Name = "Bananas"},
                                   new Product {Id = 4, Name = "Pineapples"},
                                   new Product {Id = 5, Name = "Puppies"},
                                   new Product {Id = 6, Name = "Mongoose"},
                                   new Product {Id = 7, Name = "Ponies"},
                                   new Product {Id = 8, Name = "Monkeys"}
                               };

            return products.Where(prod => !HideProductIds.Contains(prod.Id)).ToList();
        }
Exemplo n.º 10
0
        public IEnumerable<Cell> NeighbourCells(int width, int height)
        {
            var cells = new[]
                            {
                                new Cell(X - 1, Y - 1),
                                new Cell(X - 1, Y),
                                new Cell(X - 1, Y + 1),
                                new Cell(X, Y - 1),
                                new Cell(X, Y + 1),
                                new Cell(X + 1, Y - 1),
                                new Cell(X + 1, Y),
                                new Cell(X + 1, Y + 1),
                            };

            return cells.Where(c =>
                               c.X >= 0 && c.X < width &&
                               c.Y >= 0 && c.Y < height);
        }
        public void TestStartsWithOperatorString()
        {
            const string f = "f";
            var source = new[]
                             {
                                 new TestSource {String = "foo", Int = 1}, new TestSource {String = "bar", Int = 2},
                                 new TestSource {String = "baz", Int = 3}, new TestSource {String = "fii", Int = 4},
                                 new TestSource {String = "fuu", Int = 5}, new TestSource {String = "zap", Int = 6},
                                 new TestSource {String = "faa", Int = 7}
                             };

            var expectedResultList = source.Where(t => t.String.StartsWith(f)).ToList();

            var filter = new FilterSetting { OperatorName = FilterOperators.StartsWithOperator, PropertyPath = "String", Value = f };

            var result = _builder.Filter(source.AsQueryable(), new[] { filter });

            TestUtil.AssertModels(expectedResultList, result.ToList());
        }
        public void correct_iquerable_should_be_returned()
        {
            var source = new[]
            {
                new DummyDocument
                {
                    Id = 1,
                    Name = "First",
                    Count = 2
                },
                new DummyDocument
                {
                    Id = 2,
                    Name = "Middle",
                    Count = 3
                },
                new DummyDocument
                {
                    Id = 3,
                    Name = "Last",
                    Count = 3
                },
                new DummyDocument
                {
                    Id = 4,
                    Name = "Last",
                    Count = 4
                }
            }
                .AsQueryable();

            var filterList = new List<FilterByRequest>()
            {
                new FilterByRequest("name", "Last"),
                new FilterByRequest("count", "3"),
            };

            var filteredData = source.DynamicFiltering(filterList);
            var expectedFilteredData = source.Where(document => document.Id == 3);
            filteredData.SequenceEqual(expectedFilteredData).Should().BeTrue();
        }
        public void OneInactiveUser()
        {
            // Arrange
            IEnumerable<User> users = new[]
            {
                new User {Id = 1, FirstName = "User1", LastName = "User1", Email = "*****@*****.**", IsActive = true},
                new User {Id = 2, FirstName = "User2", LastName = "User2", Email = "*****@*****.**", IsActive = true},
                new User {Id = 3, FirstName = "User3", LastName = "User3", Email = "*****@*****.**", IsActive = false}
            };

            ApplicationDbContext dbContext = new Mock<ApplicationDbContext>("Test")
                .SetupDbContextData(x => x.Users, users)
                .Build();

            // Act
            InactiveUsersQuery query = new InactiveUsersQuery(dbContext);
            IEnumerable<User> result = query.Execute();

            // Assert
            CollectionAssert.AreEqual(users.Where(x => x.IsActive == false).ToArray(), result.ToArray());
        }
Exemplo n.º 14
0
        public static void CaseOne()
        {
            List<CardTemplate> HandCards_BoardCards = MainLists.HandCards_BoardCards;

            int X_Config_Drop = ValueReader.ValueIgnorer.GetXDrop;

            //card is X drop and hand contains "x - 1 drop" and "x - 2 drop"
            if (ValueReader.ValueIgnorer.IgnoreValueIfCardIsX_DropEtc
                &&
                HandCards_BoardCards.Any(x => new NeutralMinion(x).minionBoardCard != null && x.Cost == X_Config_Drop)
                &&
                HandCards_BoardCards.Any(x => new NeutralMinion(x).minionBoardCard != null && x.Cost == X_Config_Drop - 1)
                &&
                HandCards_BoardCards.Any(x => new NeutralMinion(x).minionBoardCard != null && x.Cost == X_Config_Drop - 2)
                && !Combos.alreadyFoundOneCombo)
            {
                Combos.alreadyFoundOneCombo = true;
                //add BEST x - 1 drop and x - 2 drop
                var bestXDrop =
                        HandCards_BoardCards.Where(x => new NeutralMinion(x).minionBoardCard != null && x.Cost == X_Config_Drop).
                            OrderBy(x => new NeutralMinion(x).thisCardValue).Last();
                var bestX_1Drop =
                        HandCards_BoardCards.Where(x => new NeutralMinion(x).minionBoardCard != null && x.Cost == X_Config_Drop - 1).
                            OrderBy(x => new NeutralMinion(x).thisCardValue).Last();
                var bestX_2Drop =
                        HandCards_BoardCards.Where(x => new NeutralMinion(x).minionBoardCard != null && x.Cost == X_Config_Drop - 2).
                            OrderBy(x => new NeutralMinion(x).thisCardValue).Last();

                var bestDrops = new[] { bestXDrop, bestX_1Drop, bestX_2Drop };

                foreach (var drop in bestDrops.Where(x => !MainLists.chosenCards.Contains(BoardToMulliganCard(x))))
                {
                    string dropAsString = drop.Id.ToString();
                    MainLists.chosenCards.Add(CardTemplate.StringToCard(dropAsString));
                    MainLists.blackList.Add(drop.Id.ToString());
                }
            }
        }
        public void TestOrAndCombination()
        {
            var source = new[]
                             {
                                 new TestSource {String = "foo", Int = 1}, new TestSource {String = "bar", Int = 2},
                                 new TestSource {String = "baz", Int = 3}, new TestSource {String = "fii", Int = 4},
                                 new TestSource {String = "baz", Int = 5}, new TestSource {String = "fuu", Int = 6},
                                 new TestSource {String = "zap", Int = 7}, new TestSource {String = "faa", Int = 8}
                             };

            var expectedResultList = source.Where(t => t.String.StartsWith("f") && (t.String.EndsWith("i") || t.String.EndsWith("a"))).ToList();

            var startsWithFilter = new FilterSetting { OperatorName = FilterOperators.StartsWithOperator, PropertyPath = "String", Value = "f" };
            var endsWith1Filter = new FilterSetting { OperatorName = FilterOperators.EndsWithOperator, PropertyPath = "String", Value = "i" };
            var endsWith2Filter = new FilterSetting { OperatorName = FilterOperators.EndsWithOperator, PropertyPath = "String", Value = "a" };

            var orFilter = new FilterSetting { OrConnectedFilters = new List<FilterSetting> { endsWith1Filter, endsWith2Filter } };

            var result = _builder.Filter(source.AsQueryable(), new[] { startsWithFilter, orFilter });

            TestUtil.AssertModels(expectedResultList, result.ToList());
        }
        public void TestIdioticWayToSpecifyOrFilters()
        {
            var source = new[]
                             {
                                 new TestSource {String = "foo", Int = 1}, new TestSource {String = "bar", Int = 2},
                                 new TestSource {String = "baz", Int = 3}, new TestSource {String = "fii", Int = 4},
                                 new TestSource {String = "baz", Int = 5}, new TestSource {String = "fuu", Int = 6},
                                 new TestSource {String = "zap", Int = 7}
                             };

            var expectedResultList = source.Where(t => t.String == "foo" || t.String == "bar" || t.String == "zap").ToList();

            var fooFilter = new FilterSetting { OperatorName = FilterOperators.EqualsOperator, PropertyPath = "String", Value = "foo" };
            var barFilter = new FilterSetting { OperatorName = FilterOperators.EqualsOperator, PropertyPath = "String", Value = "bar" };
            var zapFilter = new FilterSetting { OperatorName = FilterOperators.EqualsOperator, PropertyPath = "String", Value = "zap" };

            var zapOrContiner = new FilterSetting {OrConnectedFilters = new List<FilterSetting> {zapFilter}};
            var barOrContainer = new FilterSetting
                                     {
                                         OrConnectedFilters =
                                             new List<FilterSetting>
                                                 {
                                                     new FilterSetting
                                                         {OrConnectedFilters = new List<FilterSetting> {barFilter}}
                                                 }
                                     };
            var fooOrContainer = new FilterSetting
                                     {
                                         OrConnectedFilters =
                                             new List<FilterSetting>
                                                 {
                                                     new FilterSetting
                                                         {
                                                             OrConnectedFilters =
                                                                 new List<FilterSetting>
                                                                     {
                                                                         new FilterSetting
                                                                             {
                                                                                 OrConnectedFilters =
                                                                                     new List<FilterSetting> {fooFilter}
                                                                             }
                                                                     }
                                                         }
                                                 }
                                     };

            var orFilter = new FilterSetting { OrConnectedFilters = new List<FilterSetting> { fooOrContainer, barOrContainer, zapOrContiner } };

            var result = _builder.Filter(source.AsQueryable(), new[] { orFilter });

            TestUtil.AssertModels(expectedResultList, result.ToList());
        }
        public void TestInOperatorEnumerale()
        {
            var value = new[] {"foo", "baz"};
            var source = new[]
                             {
                                 new TestSource {String = "foo", Int = 1}, new TestSource {String = "bar", Int = 2},
                                 new TestSource {String = "baz", Int = 3}, new TestSource {String = "fii", Int = 4},
                                 new TestSource {String = "baz", Int = 5}, new TestSource {String = "fuu", Int = 6},
                                 new TestSource {String = "zap", Int = 7}
                             };

            var expectedResultList = source.Where(t => value.Contains(t.String)).ToList();

            var filter = new FilterSetting { OperatorName = FilterOperators.InOperator, PropertyPath = "String", Value = value };

            var result = _builder.Filter(source.AsQueryable(), new[] { filter });

            TestUtil.AssertModels(expectedResultList, result.ToList());
        }
        public void TestInOperatorString()
        {
            const string value = "goosfraba";
            var source = new[]
                             {
                                 new TestSource {String = "oos", Int = 1}, new TestSource {String = "fra", Int = 2},
                                 new TestSource {String = "ba", Int = 3}, new TestSource {String = "fii", Int = 4},
                                 new TestSource {String = "goos", Int = 5}, new TestSource {String = "osfra", Int = 6},
                                 new TestSource {String = "faa", Int = 7}
                             };

            var expectedResultList = source.Where(t => value.Contains(t.String)).ToList();

            var filter = new FilterSetting { OperatorName = FilterOperators.InOperator, PropertyPath = "String", Value = value };

            var result = _builder.Filter(source.AsQueryable(), new[] { filter });

            TestUtil.AssertModels(expectedResultList, result.ToList());
        }
 public static UnitTestElementId CreateId(IUnitTestElementIdFactory elementIdFactory, IUnitTestProvider provider, BehaviorElement behaviorElement, string fieldName)
 {
     var result = new[] { behaviorElement.Id, fieldName };
     var id = result.Where(s => !string.IsNullOrEmpty(s)).AggregateString(".");
     return elementIdFactory.Create(provider, new PersistentProjectId(behaviorElement.GetProject()), id);
 }
Exemplo n.º 20
0
        public static void CaseThree()
        {
            List<CardTemplate> HandCards_BoardCards = MainLists.HandCards_BoardCards;

            if (ValueReader.ValueIgnorer.IgnoreValueIf_244_AndCoin &&
                ValueReader.ValueIgnorer.HandContains224(HandCards_BoardCards) &&
                !alreadyFoundOneCombo)
            {
                alreadyFoundOneCombo = true;
                var best2Drop =
                        HandCards_BoardCards.Where(x => new NeutralMinion(x).minionBoardCard != null && x.Cost == 2).
                            OrderBy(x => new NeutralMinion(x).thisCardValue).Last();
                var bestOther2Drop =
                        HandCards_BoardCards.Where(x => x.Id.ToString() != best2Drop.Id.ToString() &&
                            new NeutralMinion(x).minionBoardCard != null && x.Cost == 2).
                                OrderBy(x => new NeutralMinion(x).thisCardValue).Last();
                var best4Drop =
                        HandCards_BoardCards.Where(x => new NeutralMinion(x).minionBoardCard != null && x.Cost == 4).
                            OrderBy(x => new NeutralMinion(x).thisCardValue).Last();

                var bestDrops = new[] { best2Drop, bestOther2Drop, best4Drop };

                if (ValueReader.ValueIgnorer.OnlyAddIfNoBadEffect && !bestDrops.All(CardEffects.HasBadEffect))
                {
                    foreach (var drop in bestDrops.Where(x => !MainLists.chosenCards.Contains(BoardToMulliganCard(x))))
                    {
                        string dropAsString = drop.Id.ToString();
                        MainLists.chosenCards.Add(CardTemplate.StringToCard(dropAsString));
                        MainLists.blackList.Add(drop.Id.ToString());
                    }
                }
            }
        }
Exemplo n.º 21
0
		private ElementFilter<ClientCompanyColumnName, ClientUser, ClientUserPipelineFilter> BuildFilter(ClientUserPipelineFilter filter)
		{
			#region filter by statuses prepair

			var clientActiveStatus = ClientUserStatus.Active.ToString();
			var clientInactiveStatus = ClientUserStatus.Inactive.ToString();
			var clientTerminatedStatus = ClientUserStatus.Terminated.ToString();

			IEnumerable<string> filterStatuses = new[] { clientActiveStatus, clientInactiveStatus, clientTerminatedStatus };
			if (filter.IsActive || filter.IsInactive || filter.IsTerminated)
			{
				if (!filter.IsActive)
				{
					filterStatuses = filterStatuses.Where(e => e != clientActiveStatus);
				}

				if (!filter.IsInactive)
				{
					filterStatuses = filterStatuses.Where(e => e != clientInactiveStatus);
				}

				if (!filter.IsTerminated)
				{
					filterStatuses = filterStatuses.Where(e => e != clientTerminatedStatus);
				}
			}

			#endregion filter by statuses prepair

			#region filter role prepair

			IEnumerable<RoleFilterMapper> roleFilterMappers = new List<RoleFilterMapper>
			{
				new RoleFilterMapper{RoleType = RoleType.ClientAdmin, Value = filter.IsClientAdmin},
				new RoleFilterMapper{RoleType = RoleType.SuperUser, Value = filter.IsSuperUser},
				new RoleFilterMapper{RoleType = RoleType.Underwriter, Value = filter.IsUnderwriter},
				new RoleFilterMapper{RoleType = RoleType.Processor, Value = filter.IsProcessor},
				new RoleFilterMapper{RoleType = RoleType.LoanOfficer, Value = filter.IsLoanOfficer},
				new RoleFilterMapper{RoleType = RoleType.CSR, Value = filter.IsCSR},
				new RoleFilterMapper{RoleType = RoleType.JuniorUW, Value = filter.IsJuniorUW},
				new RoleFilterMapper{RoleType = RoleType.CloserFunder, Value = filter.IsCloserFunder},
				new RoleFilterMapper{RoleType = RoleType.OperationsManager, Value = filter.IsOperationsManager},
				new RoleFilterMapper{RoleType = RoleType.OrderAdmin, Value = filter.IsOrderAdmin},
				new RoleFilterMapper{RoleType = RoleType.UserAdministrator, Value = filter.IsUserAdministrator},
			};

			var rolesForCurrentCriteries = new List<RoleType>();

			if (_securityContext.CurrentUser.Roles.Select(r => r.RoleType).All(r => r == RoleType.DvsSuperAdmin || r == RoleType.DvsAdmin))
			{
				rolesForCurrentCriteries.AddRange(roleFilterMappers.Select(m => m.RoleType));
			}
			else if (_securityContext.CurrentUser.Roles.Select(r => r.RoleType).Any(r => r == RoleType.UserAdministrator || r == RoleType.SuperUser || r == RoleType.ClientAdmin))
			{
				var currentCompany = _securityContext.CurrentClientUser.Company;

				if (currentCompany.Profile.IsLender || currentCompany.Profile.IsOtherBusinessType)
				{
					rolesForCurrentCriteries.AddRange(roleFilterMappers.Select(m => m.RoleType));
				}
				else if (currentCompany.Profile.IsBroker)
				{
					var exceptRoles = new[] { RoleType.OperationsManager, RoleType.JuniorUW };
					rolesForCurrentCriteries.AddRange(roleFilterMappers.Select(m => m.RoleType).Where(r => !exceptRoles.Contains(r)));
				}
				else if (currentCompany.Profile.IsAppraiserManagementCompany)
				{
					rolesForCurrentCriteries.Add(RoleType.SuperUser);
					rolesForCurrentCriteries.Add(RoleType.OrderAdmin);
					rolesForCurrentCriteries.Add(RoleType.ClientAdmin);
					rolesForCurrentCriteries.Add(RoleType.UserAdministrator);
				}
			}

			roleFilterMappers = roleFilterMappers.Where(m => rolesForCurrentCriteries.Contains(m.RoleType));

			var rolesTypeContainer = roleFilterMappers.Select(e => (int)e.RoleType);
			if (roleFilterMappers.Any(r => r.Value))
			{
				foreach (var roleFilterMapper in roleFilterMappers)
				{
					RoleFilterMapper mapper = roleFilterMapper;
					if (!mapper.Value)
						rolesTypeContainer = rolesTypeContainer.Where(e => e != (int)mapper.RoleType);
				}
			}

			#endregion filter role prepair

			#region Client company users

			var clientCompaniesUsers = roleFilterMappers.Select(m => m.RoleType);

			#endregion Client company users

			return
				ShorFilter.AddFilter<ClientCompanyColumnName, ClientUser, ClientUserPipelineFilter>(f => !string.IsNullOrWhiteSpace(f.CompanyName), c => c.Company.CompanyName.ToUpper().Contains(filter.CompanyName.ToUpper())).
					AddFilter(f => !string.IsNullOrWhiteSpace(f.BranchNamePart), c => c.Branch.Name.ToUpper().Contains(filter.BranchNamePart.ToUpper())).
					AddFilter(f => !string.IsNullOrWhiteSpace(f.LastName), c => c.User.LastName.ToUpper().Contains(filter.LastName.ToUpper())).
					AddFilter(f => true, c => filterStatuses.Contains(c.StatusId)).
					AddQueryFilter(f => true, q => q.Where(c => c.User.Roles.Any(r => rolesTypeContainer.Contains(r.Id)))).
					AddFilter(f => _securityContext.CurrentUser.Roles.Select(r => r.RoleType).Any(clientCompaniesUsers.Contains), c => c.Company.Id == _securityContext.CurrentClientUser.Company.Id).
					AddOrders(ClientCompanyColumnName.LastNameOrder, c => c.User.LastName).
					AddOrders(ClientCompanyColumnName.FirstNameOrder, c => c.User.FirstName).
					AddOrders(ClientCompanyColumnName.Company, c => c.Company.CompanyName).
					AddOrders(ClientCompanyColumnName.Branch, c => c.Branch.Name).
					AddOrders(ClientCompanyColumnName.RoleOrder, c => c.User.Roles.FirstOrDefault().DisplayName).
					AddOrders(ClientCompanyColumnName.StatusOrder, c => c.StatusId);
		}
Exemplo n.º 22
0
 public string QueryString(string conditions, string order, string limit, string offset)
 {
     IEnumerable<string> clauses = new[] { conditions, order, limit, offset };
     clauses = clauses.Where(s => !string.IsNullOrEmpty(s));
     return string.Join(" ", clauses);
 }
 public static UnitTestElementId CreateId(MSpecUnitTestProvider provider, ContextElement contextElement, string fieldType, string fieldName)
 {
     var result = new[] { contextElement.Id, fieldType, fieldName };
     var id = result.Where(s => !string.IsNullOrEmpty(s)).AggregateString(".");
     return new UnitTestElementId(provider, new PersistentProjectId(contextElement.GetProject()), id);
 }
        public void TestPropertyPathFiltering()
        {
            const string foo = "foo";
            var source = new[]
                             {
                                 new TestSource{ Inner = new InnerType{Complex = new TestSource {String = "foo", Int = 1}}}, 
                                 new TestSource{ Inner = new InnerType{Complex = new TestSource {String = "bar", Int = 2}}},
                                 new TestSource{ Inner = new InnerType{Complex = new TestSource {String = "baz", Int = 3}}}, 
                                 new TestSource{ Inner = new InnerType{Complex = new TestSource {String = "foo", Int = 4}}},
                                 new TestSource{ Inner = new InnerType{Complex = new TestSource {String = "foo", Int = 5}}}, 
                                 new TestSource{ Inner = new InnerType{Complex = new TestSource {String = "zap", Int = 6}}},
                                 new TestSource{ Inner = new InnerType{Complex = new TestSource {String = "foo", Int = 7}}}
                             };

            var expectedResultList = source.Where(t => t.Inner.Complex.String == foo).ToList();

            var filter = new FilterSetting { OperatorName = FilterOperators.EqualsOperator, PropertyPath = "Inner.Complex.String", Value = foo };

            var result = _builder.Filter(source.AsQueryable(), new[] { filter });

            TestUtil.AssertModels(expectedResultList, result.ToList());
        }
		/// <summary>
		/// 	Проверяем, что одна и та же тема по write присуствует только в одном экземпляре
		/// </summary>
		/// <remarks>
		/// </remarks>
		private void CheckThatThemaForOneGroupIsFormedInOnePlace() {
			IDictionary<string, string> checkedout = new Dictionary<string, string>();
			foreach (var p in Context.EcoProcessIndex.All) {
				foreach (var t in p.ThemaRefs.Where(x => x.IsWrite)) {
					var keys = new[] {t.Code, t.Code + "A", t.Code + "B"};
					if (t.Group.IsNotEmpty()) {
						keys = new[] {t.Code, t.Code + t.Group};
					}
					var proceed = true;
					foreach (var key in keys.Where(checkedout.ContainsKey)) {
						AddError(ErrorLevel.Error,
						         "Процесс " + p.Code + " дублирует ввод по форме " + key + ", определенный в форме" + checkedout[key],
						         "ER_EPINTEG_1");
						proceed = false;
					}
					if (proceed) {
						checkedout[t.Code + t.Group] = p.Code;
					}
				}
			}
		}
Exemplo n.º 26
0
        static void Main(string[] args)
        {
            var wc = new System.Net.WebClient();
            var path = Path.GetTempFileName();
            wc.DownloadFile("https://docs.google.com/spreadsheets/d/1mLbhSh-STB1OYTK0mmWJM2Wle_9zJemqV88EpnuOC3w/pub?output=csv", path);
            wc.Dispose();

            CsvParser parser = new CsvParser(new StreamReader(path, Encoding.UTF8));

            parser.Configuration.HasHeaderRecord = true;  // ヘッダ行は無い
            parser.Configuration.RegisterClassMap<IAInfoMap>();

            CsvReader reader = new CsvReader(parser);
            List<IAInfo> list = reader.GetRecords<IAInfo>().ToList();
            parser.Dispose();
            reader.Dispose();

            File.Delete(path);

            var filename = System.IO.Directory.GetCurrentDirectory() + "/IATableList.txt";

            //書き込むファイルが既に存在している場合は、上書きする
            var sw = new StreamWriter(
                filename,
                false,
                Encoding.UTF8);

            sw.WriteLine("namespace ImprovementArsenalPlugin");
            sw.WriteLine("{");
            sw.WriteLine("\tpublic partial class IATable");
            sw.WriteLine("\t{");
            sw.WriteLine("\t\tpublic static IATable[] List = new IATable[] {");

            foreach (IAInfo record in list)
            {
                string value = "\t\t\tnew IATable { Equip = \"" + record.装備 + "\", Days = new string[] {";
                var days = new[] {
                    new { WeekDay = nameof(record.日), Enable = record.日 },
                    new { WeekDay = nameof(record.月), Enable = record.月 },
                    new { WeekDay = nameof(record.火), Enable = record.火 },
                    new { WeekDay = nameof(record.水), Enable = record.水 },
                    new { WeekDay = nameof(record.木), Enable = record.木 },
                    new { WeekDay = nameof(record.金), Enable = record.金 },
                    new { WeekDay = nameof(record.土), Enable = record.土 },
                };
                value += string.Join(",", days.Where(x => "○".Equals(x.Enable)).Select(x => '"' + x.WeekDay + '"'));

                value += "}, ShipName = \"" + record.艦娘 + "\"},";

                sw.WriteLine(value);
            }

            sw.WriteLine("\t\t};");
            sw.WriteLine("\t}");
            sw.WriteLine("}");

            //閉じる
            sw.Close();

            Process.Start(filename);
        }
Exemplo n.º 27
0
        public void Invalidate_InvalidatesCache()
        {
            var data = new[] { new { Test = "value" } }.ToList();
            var query = data.Where(item => item.Test == "value").AsQueryable().AsCached();

            query.ToList();

            data.Clear();

            query.Invalidate();

            Assert.AreEqual(0, query.Count());
        }
Exemplo n.º 28
0
        public void MoreReadable()
        {
            var people = new[] {"Pavel", "", "Yuriy", null, "Michail", "Aleksey", "Dasha", "Irina"}
                .Where(name => !string.IsNullOrEmpty(name));
            var girls = people
                .Where(name => name[name.Length - 1] == 'a');

            Assert.AreEqual(girls, new[] {"Dasha", "Irina"});
        }