private static List <ISearchableEntity> GetSampleSearchEntities(ModuleFeature feature) { var searchEntities = new List <ISearchableEntity>(); if (feature.TypeId == DTO.ModuleFeatureType.PlanningAnalytics) { var analytics = MockAnalyticGenerator.GetSampleAnalytics(); var entities = analytics.Cast <ISearchableEntity>(); searchEntities.AddRange(entities); } else { foreach (FeatureSearchGroup searchGroup in feature.SearchGroups) { for (int id = 0; id < searchGroup.ItemCount; id++) { ISearchableEntity entity = GetSearchEntity(feature, id); if (entity != null) { entity.SearchGroupKey = searchGroup.SearchGroupKey; searchEntities.Add(entity); } } } } return(searchEntities); }
public Expression <Func <T, bool> > CreateExpression <T>(ISearchableEntity entity, ParameterExpression expressionParameter, MemberExpression memberExpression) { return(Expression.Lambda <Func <T, bool> >( Expression.Equal( left: memberExpression, right: Expression.Constant(value: entity.ValueToSearch, type: entity.ValueType)), expressionParameter)); }
private void OnSelectedEntityChanged(ISearchableEntity entity) { SelectedAnalytic = entity as DisplayEntities.Analytic; SelectedPriceRoutine = entity as DisplayEntities.Pricing; this.RaisePropertyChanged("IsEntitySelected"); this.RaisePropertyChanged("SelectedENtity"); }
private void PublishChangeNotification(ISearchableEntity sourceEntity, FeatureSearchGroup destSearchGroup) { var notifier = PriceExpertApplication.Current.Container.Get <EventAggregator>(); //EventAggregator notifier = ((EventAggregator)App.Current.Resources["EventManager"]); var data = new SearchGroupsUpdatedEvent(sourceEntity, destSearchGroup); notifier.Publish(data); }
private ISearchableEntity ConvertEntityValuesToPreciseTypes(ISearchableEntity entityToPrepare) { var convertTypeMethod = _convertTypeToPrecise.PreciseTypeConfiguration[entityToPrepare.ValueType]; entityToPrepare.ValueToSearch = convertTypeMethod(entityToPrepare.ValueToSearch); if (entityToPrepare.AdditionalValue != null) { entityToPrepare.AdditionalValue = convertTypeMethod(entityToPrepare.AdditionalValue); } return(entityToPrepare); }
public DataObject GetDataObject(FrameworkElement draggedElement) { DataObject data = null; ISearchableEntity entity = draggedElement.DataContext as ISearchableEntity; if (entity != null) { data = new DataObject(DataFormats.StringFormat, entity); } return(data); }
public PricingEverydayResultsViewModel(ISearchableEntity entity) { _priceRoutine = entity; _views.Add(new PricingView("Summary")); _views.Add(new PricingView("Warnings")); _views.Add(new PricingView("Price Change")); _views.Add(new PricingView("Mark-Up Change")); _views.Add(new PricingView("Price List")); _views.Add(new PricingView("Competition")); //_views.Add(new PricingView("Value Driver Groups")); _views.Add(new PricingView("Edited")); _views.Add(new PricingView("Excluded")); }
private void AssignOwningSearchGroupId(ISearchableEntity entity) { if (entity.SearchGroupId > 0) { entity.OwningSearchGroupId = entity.SearchGroupId; } else { //Find the corresponding entity that is assigned to its owning search group. ISearchableEntity owningItem = SearchableEntities.FirstOrDefault(item => item.Id == entity.Id && item.SearchGroupId > 0); if (owningItem != null) { entity.OwningSearchGroupId = owningItem.SearchGroupId; } } }
public IdentityViewModel(ISearchableEntity entity) { Analytic = entity as Display.Analytic; //SelectedAnalytic = (Domain.Analytic)entity; ////Tags2 = SelectedAnalytic.Tags; //Tags = new ReactiveList<Domain.Tag>(){ // new Domain.Tag{Value="tag-ut"} //}; //this.WhenAny(x => x.SelectedAnalytic, x => x).Subscribe( a => { // TagsToSuggest = ((HomeSearchViewModel)MainViewModel.SubModuleCache[Domain.SubModuleType.Search]).Tags.Select(t => new Domain.Tag { Value = t.ToString() }).ToList(); // //TagsToSuggest = SelectedAnalytic.Tags.Select(t => new Domain.Tag { Value = t.ToString() }).ToList(); // SelectedTags.Clear(); // SelectedTags.AddRange( SelectedAnalytic.Tags.Select(t => new Domain.Tag { Value = t.ToString() })); // }); }
public Expression <Func <T, bool> > CreateExpression <T>(ISearchableEntity entity, ParameterExpression expressionParameter, MemberExpression memberExpression) { if (entity.ValueType != typeof(string)) { //Stupid rider cant understand string interpolation throw new ArgumentException(string.Format( "Search using contains strategy is supported only for {0} type, not for type {1}." , new object[] { typeof(string).Name, entity.ValueType.Name })); } var containsMethodInfo = typeof(string).GetMethod(name: "Contains", types: new[] { typeof(string) }); var constant = Expression.Constant(value: entity.ValueToSearch, type: entity.ValueType); var expressionMethodCall = Expression.Call(memberExpression, containsMethodInfo, constant); return(Expression.Lambda <Func <T, bool> >( expressionMethodCall, expressionParameter)); }
public Expression <Func <T, bool> > CreateSearchClause <T>(ISearchableEntity entity) { var searchHandler = _expressionPreparersBaseOnStrategy.SingleOrDefault(x => x.SearchStrategy == entity.SearchStrategy); if (searchHandler == null) { throw new InvalidOperationException( string.Format("Search by {0} strategy is not actualy supported", entity.SearchStrategy)); } entity = ConvertEntityValuesToPreciseTypes(entity); var expressionParameter = Expression.Parameter(typeof(T)); return(searchHandler.CreateExpression <T>(entity, expressionParameter, Expression.Property(expressionParameter, entity.ColumnNameToSearchBy))); }
public bool IsValidDropOperation(IDataObject obj, FrameworkElement target) { bool isValid = false; var targetSearchGroup = target.DataContext as FeatureSearchGroup; if (targetSearchGroup != null && targetSearchGroup.CanSearchKeyChange && obj.GetDataPresent(DataFormats.StringFormat, true)) { ISearchableEntity sourceEntity = obj.GetData(DataFormats.StringFormat) as ISearchableEntity; if (sourceEntity != null) { isValid = (sourceEntity.SearchGroupKey != targetSearchGroup.SearchGroupKey); } } return(isValid); }
//General Functions #region General Functions //public static string ToSafeUrl(this string s) //{ // s = s.Convert_Chuoi_Khong_Dau(); // s = Regex.Replace(s, @"[^a-zA-Z0-9]", "-"); // s = Regex.Replace(s, @"-{2,}", "-"); // return s; // //return s.Replace(" - ", "-") // // .Replace(" ", "-").Replace("--", "-"); // //return s.Replace("\\", "-").Replace("/", "_").Replace("+", "-") // // .Replace(",", "-").Replace(".", "-").Replace("%", "-") // // .Replace(" ", "-"); // //return Regex.Replace(s, @"[^\w\s-]", "-"); //} //public static string Convert_Chuoi_Khong_Dau(this string s) //{ // Regex regex = new Regex(@"\p{IsCombiningDiacriticalMarks}+"); // string strFormD = s.Normalize(NormalizationForm.FormD); // return regex.Replace(strFormD, String.Empty).Replace('\u0111', 'd').Replace('\u0110', 'D'); //} #endregion #region ISearchableEntity public static string GoIndexSearchable(this UrlHelper Url, ISearchableEntity entity, string modelName) { //var url = Url.GoIndex(); //var type = GetTypeModelName(modelName); //if (type != null) //{ // //var model = Convert.ChangeType(entity, type); // var model = entity; // var methodName = "GoIndex_" + modelName; // url = typeof(UrlUlti).GetMethod(methodName) // .Invoke(null, new object[] { Url, model }) as string; //} var model = entity; var methodName = "GoIndex_" + modelName; var url = typeof(UrlUlti).GetMethod(methodName) .Invoke(null, new object[] { Url, model }) as string; return(url); }
/// <summary> /// Factory method for getting searchable entities. /// </summary> /// <param name="feature"></param> /// <returns>A concrete instance that implements ISearchableEntity.</returns> private static ISearchableEntity GetSearchEntity(ModuleFeature feature, int id) { ISearchableEntity result = null; switch (feature.TypeId) { case DTO.ModuleFeatureType.PlanningAnalytics: result = MockAnalyticGenerator.GetSampleAnalytic(id); break; case DTO.ModuleFeatureType.PlanningEverydayPricing: result = MockPricingEverydayGenerator.GetSamplePricingEveryday(id); break; case DTO.ModuleFeatureType.PlanningPromotionPricing: result = GetSamplePricingPromotion(id); break; case DTO.ModuleFeatureType.PlanningKitPricing: result = GetSamplePricingKits(id); break; case DTO.ModuleFeatureType.AdministrationUserMaintenance: result = GetSampleUser(id); break; default: break; } if (result != null) { result.Id = id; } return(result); }
public Expression <Func <T, bool> > CreateExpression <T>(ISearchableEntity entity, ParameterExpression expressionParameter, MemberExpression memberExpression) { if (entity.AdditionalValue == null || entity.ValueToSearch == null) { throw new ArgumentException("Search by range requires not empty values"); } if (entity.ValueToSearch.GetType() != entity.AdditionalValue.GetType()) { throw new ArgumentException("Search by range with parameters of different type is not supported"); } var firstExpression = Expression.GreaterThanOrEqual( memberExpression, Expression.Constant(entity.ValueToSearch, entity.ValueType)); var secondExpression = Expression.LessThanOrEqual( memberExpression, Expression.Constant(entity.AdditionalValue, entity.ValueType)); return(Expression.Lambda <Func <T, bool> >( Expression.AndAlso(firstExpression, secondExpression), expressionParameter)); }
public Expression <Func <T, bool> > CreateExpression <T>( ISearchableEntity entity, ParameterExpression parameterExpression, MemberExpression memberExpression) { if (!(entity.ValueToSearch is IList)) { throw new ArgumentException("Type of value to search by is wrong."); } var valueConvertedToList = (IList)entity.ValueToSearch; if (valueConvertedToList.Count == 0) { return(null); } if (valueConvertedToList.Count == 1) { var normalExpressionHandler = new ExpressionHandlerNormal(); return(normalExpressionHandler.CreateExpression <T>(entity, parameterExpression, memberExpression)); } return(null); }
private bool CopyOrEditCanExecute(ISearchableEntity entity) { bool result = (entity != null); return(result); }
private void OnSelectedEntityChanged(ISearchableEntity entity) { _selectedEntity = entity; this.RaisePropertyChanged("IsDetailDisplayed"); }
public PricingEverydayResultsMarkupChangeViewModel(ISearchableEntity entity) { _priceRoutine = entity; }
public PricingEverydayResultsValueDriverGroupsViewModel(ISearchableEntity entity) { _priceRoutine = entity; }
public FilterViewModel(ISearchableEntity entity) { _entity = entity; //SelectedAnalytic = (Domain.Analytic)entity; ////List of filter types //FilterTypes = Enum.GetValues(typeof(Domain.FilterType)).Cast<Domain.FilterType>().ToList(); ////FilterTypes = SelectedAnalytic.Filters.Select(x => x.Type).Distinct().ToList(); ////selected filter type default it on first load //SelectedType = Domain.FilterType.VendorCode; ////filtered list of filter items based on type //EventManager.GetEvent<Domain.FilterType>() // .Subscribe(ftype => // { // var ttype = string.Empty; // switch (ftype) // { // case Domain.FilterType.VendorCode: // ttype = "VendorCode"; // break; // case Domain.FilterType.IsKit: // ttype = "IsKit"; // break; // case Domain.FilterType.OnSale: // ttype = "OnSale"; // break; // case Domain.FilterType.Category: // ttype = "Category"; // break; // case Domain.FilterType.DiscountType: // ttype = "DiscountType"; // break; // case Domain.FilterType.StatusType: // ttype = "StatusType"; // break; // case Domain.FilterType.ProductType: // ttype = "ProductType"; // break; // case Domain.FilterType.StockClass: // ttype = "StockClass"; // break; // default: // break; // } // //update selected analytic with changes for that type // //var filterItems = SelectedAnalytic.Filters // // .Where(x => x.Type == ttype) // // .SelectMany(y => y.Items).ToList(); // //filterItems = FilterItems; // var type = Enum.GetName(typeof(Domain.FilterType), ftype); // var filterItems = SelectedAnalytic.Filters.Where(fs => fs.Type == type) // .SelectMany(x => x.Items.Where(t => t.Type == SelectedType)).ToList(); // //FilterItems.SuppressChangeNotifications(); // FilterItems.Clear(); // for (int i = 0; i < filterItems.Count; i++) // { // FilterItems.Add(filterItems[i]); // } // var selectedObservable = this.WhenAnyObservable(x => x.FilterItems.ItemChanged) // .Where(x => x.PropertyName == "IsSelected"); // //.Select(_ => FilterItems.Any(x => x.IsSelected)); // selectedObservable.Subscribe(x => // { // Console.WriteLine("test"); // }); // //.ToProperty(this, x => x.SelectedFilterItems) // SelectedFilterItems = FilterItems.CreateDerivedCollection(i => i, x => x.IsSelected); // //.Select(f => new FilterItemViewModel { Code = f.Code, Description = f.Description, IsSelected = f.IsSelected}).ToList(); // //selectedItems.Changed.Subscribe(x => { // // Console.WriteLine("test"); // //}); // this.WhenAnyValue(vm => vm.SelectedFilterItems).Subscribe(selected => { // Console.WriteLine("test"); // }); // this.WhenAnyObservable(vm => vm.SelectedFilterItems.ItemChanged).Subscribe(selected => // { // Console.WriteLine("test"); // }); // FilterItems.ItemChanged.Subscribe(x => { // Console.WriteLine("t"); // }); // }); }
public SearchGroupsUpdatedEvent(ISearchableEntity sourceEntity, FeatureSearchGroup destinationSearchGroup) { SourceEntity = sourceEntity; DestinationSearchGroup = destinationSearchGroup; }
public PricingEverydayResultsPriceListViewModel(ISearchableEntity entity) { _priceRoutine = entity; }
public PricingIdentityViewModel(ISearchableEntity entity) { _priceRoutine = entity; }