public void GetFileInfo(DirectoryInfo DirectoryInfo, ref FileFolderInfo items)
 {
     if (!SelectedFilter.Contains("*.*"))
     {
         foreach (System.IO.FileInfo directoryinfo in DirectoryInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly).Where(s => SelectedFilter.Split('|')[1].Contains(s.Extension.ToLower())).Where(s => !AvoidedFilePaths.Contains(s.FullName)))
         {
             if ((directoryinfo.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden && directoryinfo.Extension != "")
             {
                 items.FileFolders.Add(new FileFolderInfo
                 {
                     Name         = directoryinfo.Name,
                     Path         = directoryinfo.FullName,
                     DateModified = directoryinfo.LastWriteTime,
                     IsFile       = true
                 });
             }
         }
     }
     else
     {
         foreach (System.IO.FileInfo directoryinfo in DirectoryInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly).Where(s => !AvoidedFilePaths.Contains(s.FullName)))
         {
             if ((directoryinfo.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden && directoryinfo.Extension != "")
             {
                 items.FileFolders.Add(new FileFolderInfo
                 {
                     Name         = directoryinfo.Name,
                     Path         = directoryinfo.FullName,
                     DateModified = directoryinfo.LastWriteTime,
                     IsFile       = true
                 });
             }
         }
     }
 }
        private bool FilterContains(object obj)
        {
            ProductVM product = obj as ProductVM;

            if (SelectedFilter.Contains("Alle Artikel"))
            {
                return(true);
            }
            if (SelectedFilter.Contains("Kein Bestand"))
            {
                if (product.Quantity.Value == 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            if (SelectedFilter.Contains("Bestand unter Mindestmenge"))
            {
                if (product.Quantity.Value <= 5 && product.Quantity.Value >= 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
        private void OnDuplicateFilter()
        {
            var newFilter = SelectedFilter.GetDuplicate();

            MainViewModel.Instance.Filters.Add(newFilter);
            MainViewModel.Instance.SelectedFilter = newFilter;
        }
Example #4
0
        public static string GetSortByFieldBasedOnEnumForProductQuery(SelectedFilter filter)
        {
            var sortById = (filter != null && filter.SortById > 0) ? filter.SortById : (int)Enums.SortBy.StoresCount;

            switch (sortById)
            {
            case 2:
            {
                return("SpecialPrice ASC");
            }

            case 3:
            {
                return("SpecialPrice DESC");
            }

            case 4:
            {
                return("Name ASC");
            }

            case 5:    //NameDESC
            {
                return("Name DESC");
            }

            //stores count.
            default:
            case 1:
            {
                return("StoresCount DESC");
            }
            }
        }
Example #5
0
        public async Task <int> SaveDataMarketListInProgres()
        {
            //var response = await GetRequestValues<SelectedFilter>();
            string requestStr = await this.Request.Content.ReadAsStringAsync();

            var a = System.Web.HttpUtility.ParseQueryString(requestStr);

            var response = new SelectedFilter
            {
                filterId    = int.Parse(a.Get("filterId")),
                filterValue = bool.Parse(a.Get("filterValue"))
            };


            var check         = response.filterValue;
            var FilterValueId = response.filterId;
            int _FilterId     = 6;
            int _GroupId;
            int _datamartId;

            using (SqlConnection con = new SqlConnection("Data Source=192.168.33.201;Initial Catalog=DataMarketConfiguration;User ID=msalagean;Password=pttsr8Ly"))
            {
                con.Open();
                //string queryFilterId = string.Format("select FilterId from FilterValues where FilterValueId={0}", FilterValueId);
                //SqlCommand com = new SqlCommand(queryFilterId, con);
                //_FilterId = Convert.ToInt32(com.ExecuteScalar());


                string     queryGroupId = string.Format("select GroupId from Filters where FilterId='{0}'", _FilterId);
                SqlCommand com1         = new SqlCommand(queryGroupId, con);
                _GroupId = Convert.ToInt32(com1.ExecuteScalar());


                string     querydatamartId = string.Format("select DatamartId from Groups where GroupId={0}", _GroupId);
                SqlCommand com2            = new SqlCommand(querydatamartId, con);
                _datamartId = Convert.ToInt32(com2.ExecuteScalar());
            }
            if (check)
            {
                using (SqlConnection con = new SqlConnection("Data Source=192.168.33.201;Initial Catalog=DataMarketListInProgress;User ID=msalagean;Password=pttsr8Ly"))
                {
                    con.Open();
                    string        tableName = string.Format("ListInProgress_{0}", /*userId,*/ _datamartId);
                    StringBuilder query     = new StringBuilder("If not exists ");
                    query.AppendFormat("select 1 from DataMarketListInProgrees.TABLES where table_name ='{0}') CREATE TABLE '{0}' (FilterValueId int NOT NULL, FilterId int NOT NULL, GroupId int NOT NULL,AddedDate date )", tableName);
                    query.AppendFormat("INSERT INTO '{0}' (FilterValueId, FilterId, GroupId, AddedDate) ", tableName);
                    var AddedDate = DateTime.Now.Date;
                    query.AppendFormat("VALUES ({0}" + FilterValueId + "','" + _FilterId + "','" + _GroupId + "','" + AddedDate + "')", tableName);
                    SqlCommand com = new SqlCommand(query.ToString(), con);
                    com.ExecuteNonQuery();
                }
            }
            //else
            //{

            // }


            return(response.filterId);
        }
Example #6
0
        private void UpdateFilteredPrototypes()
        {
            int inF = 0;

            for (int p = 0; p < Prototypes.Count; ++p)
            {
                if (!SelectedFilter.Test(Prototypes[p].Source))
                {
                    continue;
                }
                if (inF < FilteredPrototypes.Count)
                {
                    if (FilteredPrototypes[inF] != Prototypes[p])
                    {
                        while (inF >= FilteredPrototypes.Count)
                        {
                            FilteredPrototypes.RemoveAt(inF);
                        }
                    }
                }
                if (inF >= FilteredPrototypes.Count)
                {
                    FilteredPrototypes.Add(Prototypes[p]);
                }
                ++inF;
            }
        }
Example #7
0
 public AvailableFilterViewModel(FilterCategory category)
     : base(category)
 {
     FilterName = "";
     SelectedFilter.Add(new Filter {
         Catgegory = FilterCategoryId.available, Id = "0"
     });
     VisualState       = FilterVisualStates.NORMAL;
     AppliedInfoString = Pici.Resources.Find(category.Id.ToString());
 }
Example #8
0
 public void Filter()
 {
     if (SelectedFilter == null)
     {
         return;
     }
     foreach (var item in Items)
     {
         item.IsSelected = SelectedFilter.FilterExpression(item);
     }
 }
        public void OnIsCheckedChanged(object sender, bool e)
        {
            var item = sender as FilterSelectionItemViewModel;

            if (item.IsChecked)
            {
                SelectedFilter.Add(item.Filter);
            }
            else
            {
                SelectedFilter.Remove(item.Filter);
            }
        }
        private SelectedFilter GetFilter()
        {
            var filter = new SelectedFilter();

            filter.StartDate = Convert.ToDateTime(Request.Params["filter[StartDate]"]);
            filter.EndDate   = Convert.ToDateTime(Request.Params["filter[EndDate]"]).AddDays(1);
            filter.UserId    = Request.Params["filter[Employee]"].ToInt32();
            filter.Quality   = Request.Params["filter[Quality]"].ParseIntegerToEnum <Quality>();
            filter.Quantity  = Request.Params["filter[Quantity]"].ParseIntegerToEnum <Quantity>();
            filter.PrintType = (PrintType)Request.Params["filter[PrintType]"].ParseEnum <PrintType>();

            return(filter);
        }
Example #11
0
        private void OnRemoveConnection()
        {
            IMessageVisualizer messageVisualizer = Resolve <IMessageVisualizer>();

            if (SelectedFilter != null &&
                messageVisualizer.Show("Delete Existing Connection",
                                       "Are you sure you want to delete " + SelectedFilter.Name,
                                       MessageButtons.YesNo) == MessageResult.Yes)
            {
                Filters.Remove(SelectedFilter);
                SelectedFilter.Dispose();
                SelectedFilter = null;
            }
        }
        /// <summary>
        /// Processes the <paramref name="inputImage"/>.
        /// </summary>
        /// <param name="inputImage">Image to process.</param>
        /// <returns>Processed image.</returns>
        public override Image Process(Image inputImage)
        {
            if (inputImage == null)
            {
                throw new ArgumentNullException(nameof(inputImage));
            }

            if (SelectedFilter == null)
            {
                return(inputImage);
            }

            ConfigureFilter();
            return(SelectedFilter.Process(inputImage));
        }
Example #13
0
        /// <summary>
        /// The selected filter for the search.
        /// </summary>
        /// <param name="Field"></param>
        /// <param name="Key"></param>
        /// <returns></returns>
        public SelectedFilter GetSelectedFilter(string Field, string Key)
        {
            SelectedFilter selectedFilter = null;

            SearchFilter[] configuredFilters = SearchFilterHelper.Current.SearchConfig.SearchFilters;
            SearchFilter   configuredFilter  = configuredFilters.SingleOrDefault(filter => filter.field == Field);

            if (configuredFilter != null)
            {
                SimpleValue value = configuredFilter.Values.SimpleValue.SingleOrDefault(simpleValue => simpleValue.key == Key);
                if (value != null)
                {
                    selectedFilter = new SelectedFilter(configuredFilter, value);
                }
            }
            return(selectedFilter);
        }
Example #14
0
        public async Task <ActionResult <MasterFilter> > PostSelectedFilter(int id, SelectedFilter selectedFilter)
        {
            var masterFilter = _context.MasterFilter.FirstOrDefault(m => m.Id == id);

            if (masterFilter == null)
            {
                return(NotFound());
            }
            else
            {
                selectedFilter.MasterFilterId = id;
                _context.SelectedFilter.Add(selectedFilter);
                await _context.SaveChangesAsync();

                return(CreatedAtAction("GetMasterFilter", new { id = selectedFilter.Id }, selectedFilter));
            }
        }
        private void OnSearch()
        {
            DefaultView = CollectionViewSource.GetDefaultView(DefaultView);
            if (TextVisiblity == Visibility.Visible)
            {
                if (SelectedFilter.Equals("Šifri"))
                {
                    DefaultView.Filter =
                        w => ((Drink)w).SifraPica.ToUpper().Contains(TextSearch.ToUpper());
                }
                else if (SelectedFilter.Equals("Nazivu"))
                {
                    DefaultView.Filter =
                        w => ((Drink)w).NazivPica.ToUpper().Contains(TextSearch.ToUpper());
                }
            }
            else if (DigitVisibility == Visibility.Visible)
            {
                try
                {
                    Double kolicina = Double.Parse(NumberSearch);

                    DefaultView.Filter =
                        w => ((Drink)w).AcutelPrice == kolicina;
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Greska : {ex.Message}");
                }
            }
            else if (ComboVisiblity == Visibility.Visible)
            {
                if (SelectedFilter.Equals("Tipu"))
                {
                    DefaultView.Filter =
                        w => ((Drink)w).TipPica.ToString().Contains(SelectedEnum);
                }
                else
                {
                    DefaultView.Filter =
                        w => ((Drink)w).Poreklo.ToString().Contains(SelectedEnum);
                }
            }

            DefaultView.Refresh();
        }
Example #16
0
        public void CreateFilter()
        {
            Func <int, double, List <double> >        filterFunction = null;
            Func <List <double>, int, List <double> > windowFunction = null;

            switch (SelectedFilter.Substring(1, 2))
            {
            case "F0":
                filterFunction = Filter.LowPassFilter;
                break;

            case "F1":
                filterFunction = Filter.MidPassFilter;
                break;

            case "F2":
                filterFunction = Filter.HighPassFilter;
                break;
            }
            switch (SelectedWindow.Substring(1, 2))
            {
            case "O0":
                windowFunction = Filter.RectangularWindow;
                break;

            case "O1":
                windowFunction = Filter.HammingWindow;
                break;

            case "O2":
                windowFunction = Filter.HanningWindow;
                break;

            case "O3":
                windowFunction = Filter.BlackmanWindow;
                break;
            }
            SampledSignal signal = new SampledSignal();

            signal.PointsY = Filter.CreateFilterSignal(M, K, filterFunction, windowFunction);
            signal.Name    = FilterName + " - F";
            SignalCreator.AddSignal(signal);
        }
Example #17
0
        private async Task LoadPururinPageAsync(int value, bool delete = true)
        {
            SettingsController.Save();
            if (PururinPageLoading)
            {
                return;
            }
            PururinPageLoading = true;
            NextPururinPage    = NextPururinPage + value;
            PururinLoadedPage  = PururinLoadedPage + value;
            if (_Pururin.Count > 0 && delete)
            {
                _Pururin.Clear();
            }
            PururinView.Instance.ScrollViewer.ScrollToTop();
            var searchquery = SettingsController.Settings.Pururin.SearchQuery;
            List <HentaiModel> i;

            if (string.IsNullOrEmpty(searchquery))
            {
                i =
                    await Pururin.GetLatestAsync(
                        $"http://pururin.us/browse/{SelectedFilter.ToLower().Replace(" ", "-")}?page={PururinLoadedPage}");
            }
            else
            {
                i = await Pururin.GetLatestAsync(
                    $"http://pururin.us/search/more?q={searchquery.Replace(" ", "+")}&p={PururinLoadedPage}");
            }
            foreach (var hentaiModel in i)
            {
                if (FavoritesController.FavoriteMd5s.Contains(hentaiModel.Md5))
                {
                    hentaiModel.Favorite = true;
                }
                _Pururin.Add(hentaiModel);
                await Task.Delay(10);
            }
            PururinPageLoading = false;
        }
Example #18
0
        public void CreateFilter()
        {
            List <double> XSamples = new List <double>();
            List <double> YSamples = SelectedFilter.FilterOperation(M_FilterRow, F0_CutOffFrequency, Fp_SamplingFrequency);

            YSamples = SelectedWindow.WindowOperation(YSamples, M_FilterRow);

            for (int i = 0; i < YSamples.Count; i++)
            {
                XSamples.Add(i);
            }

            SignalData signalData = new SignalData(0)
            {
                ConversionSamplesX = XSamples,
                ConversionSamplesY = YSamples
            };

            SelectedTab.SignalData  = signalData;
            SelectedTab.IsScattered = true;
            SelectedTab.DrawCharts();
        }
Example #19
0
 public DigitalFilterVM()
     : base(null)
 {
     FilterName = "";
     SelectedFilter.Add(new Filter {
         Catgegory = FilterCategoryId.medium, Id = "ebook"
     });
     SelectedFilter.Add(new Filter {
         Catgegory = FilterCategoryId.medium, Id = "ejournal"
     });
     SelectedFilter.Add(new Filter {
         Catgegory = FilterCategoryId.medium, Id = "article"
     });
     SelectedFilter.Add(new Filter {
         Catgegory = FilterCategoryId.medium, Id = "bookchapter"
     });
     SelectedFilter.Add(new Filter {
         Catgegory = FilterCategoryId.medium, Id = "bookreview"
     });
     VisualState       = FilterVisualStates.NORMAL;
     AppliedInfoString = Pici.Resources.Find(FilterCategoryId.digital.ToString());
 }
Example #20
0
 public void ExecuteLoadHighestEpisode(object parameter)
 {
     SelectedFilter.LoadHighest();
 }
Example #21
0
        public static string GetSearchCatalogueQuery(this IGenericRepository <Product> productRepository, SelectedFilter filter, string productFilter, List <int> branchIdList,
                                                     int?priceRangeFrom, int?priceRangeTo, int?pageStart, int?pageSize)
        {
            var query = @"WITH ProductCTE AS 
                    (
                     Select ParentCategoryId, CategoryId, Category.Name AS SubCategoryName, ProductId, Product.Name as Name, Product.PictureName, Max(Price) AS Price
                               From Product
                                            Inner Join Category ON Category.CategoryId = Product.Category
                                            LEFT Join Pricing ON Pricing.Product = Product.ProductId
                                            LEFT JOIN Manufacturer ON Product.Manufacturer = Manufacturer.ManufacturerId
                                             WHERE ( NOT ((1 = [Product].[IsDeleted]) AND ([Product].[IsDeleted] IS NOT NULL))) 
                                                                                         
                                                                                          {PricingFilter}     
                                                                                          {BrandFilter}                                                          
		                                                                                  AND (1 = [Product].[Published]) AND
                                                                            ([Product].Name LIKE '{productNameFilter}'
                                                                                OR [Product].MetaKeywords LIKE '{productNameFilter}'    
                                                                                OR [Product].MetaTitle LIKE '{productNameFilter}'     
                                                                                OR Manufacturer.Name LIKE '{productNameFilter}')																 
                    GROUP BY ParentCategoryId, CategoryId,  Category.Name , ProductId, Product.Name,Product.PictureName
                    )
                    ,
                    BranchCTE AS
                    (
	                    SELECT DISTINCT Pricing.Product Product, Count(Branch) StoresCount, Min(SpecialPrice) SpecialPrice 
                        FROM Pricing 
	                    Inner Join ProductCTE ON Pricing.Product = ProductCTE.ProductId
                        
	                    WHERE Branch IN ({branchIdListFilter})
                        {SpecialPricingFilter}
                        AND [Pricing].[IsDeleted] IS NULL OR [Pricing].[IsDeleted] =0
	                    Group BY Pricing.Product
                    )
                , Results AS 
					(
                    Select ParentCategoryId, CategoryId AS SubCategoryId, SubCategoryName, ProductId, Name,PictureName, Price, ISNULL(StoresCount,0) StoresCount
                    , ISNULL(SpecialPrice,0) SpecialPrice
                    FROM ProductCTE
                    LEFT JOIN BranchCTE ON ProductCTE.ProductId = BranchCTE.Product
                    {PriceLowToHighFilterClause} 
                    )                    
                    {GetRowNumberQuery}
                    "
                        .FormatWith(new
            {
                //TODO:Check for list count in this method as well, and then join.
                productNameFilter    = "%" + productFilter + "%",
                branchIdListFilter   = branchIdList.Count > 0 ? string.Join(",", branchIdList) : "0",
                SpecialPricingFilter = " AND [Pricing].[Price] >= {priceRangeFrom} AND [Pricing].[Price] <= {priceRangeTo}".FormatWith(new { priceRangeFrom, priceRangeTo }),
                PricingFilter        = " AND [Pricing].[SpecialPrice] >= {priceRangeFrom} AND [Pricing].[SpecialPrice] <= {priceRangeTo}".FormatWith(new { priceRangeFrom, priceRangeTo }),
                BrandFilter          = (filter != null && filter.SelectedBrandList != null && filter.SelectedBrandList.Count > 0) ? " AND [Product].[Manufacturer] IN ( " +
                                       string.Join(",", filter.SelectedBrandIdList) + " )" : "",
                GetRowNumberQuery          = ProductHelper.GetRowNumberQuery(GetSortByFieldBasedOnEnumForProductQuery(filter), pageStart, pageSize),
                PriceLowToHighFilterClause = (filter != null && filter.SortById > 0 && filter.SortById < 4) ? " WHERE SpecialPrice > 0 " : ""
            });

            return(query);
        }
Example #22
0
        public static string GetProductsQuery(this IGenericRepository <Product> productRepository, SelectedFilter filter, int[] categoryIdList, List <int> branchIdList,
                                              int?priceRangeFrom, int?priceRangeTo, int?pageStart, int?pageSize, int?userId)
        {
            var query = @"   
                    WITH ProductCTE AS 
                    (
                     Select ParentCategoryId, CategoryId, Category.Name AS SubCategoryName, ProductId, Product.Name as Name,Product.PictureName, Max(Price) AS Price
                               From Product
                                            Inner Join Category ON Category.CategoryId = Product.Category
                                            LEFT Join Pricing ON Pricing.Product = Product.ProductId
                                            
                                             WHERE ( NOT ((1 = [Product].[IsDeleted]) AND ([Product].[IsDeleted] IS NOT NULL))) 
                                                                
                                                                                          {PricingFilter}                                                              
                                                                                          {BrandFilter}  
		                                                                                  AND (1 = [Product].[Published]) AND ([Product].[Category] IN ({categoryIdListArray}))																 
                    GROUP BY ParentCategoryId, CategoryId,  Category.Name , ProductId, Product.Name,Product.PictureName
                    )
                     ,ProductWishlist AS
                     (

                    select   ProductId, UserWishlist.Id, CASE WHEN (UserWishlist.Id) IS NULL 
                                    THEN CAST(0 AS BIT) ELSE CAST(1 AS BIT) END 
                                        AS FlagWishlist
                    From ProductCTE 
	                    INNER JOIN UserWishlist ON ProductCTE.ProductId = UserWishlist.Product
											                    AND UserWishlist.[User] = {userId}

                    )
                    ,ParentCategoryCTE AS 
					(
					 Select DISTINCT Category.Name AS ParentCategoryName, ProductCTE.ParentCategoryId 
					 FROM Category
					 Inner Join ProductCTE ON Category.CategoryId = ProductCTE.ParentCategoryId
					)
                    ,
                    BranchCTE AS
                    (
	                    SELECT DISTINCT Pricing.Product Product, Count(Branch) StoresCount, Min(SpecialPrice) SpecialPrice 
                        FROM Pricing 
	                    Inner Join ProductCTE ON Pricing.Product = ProductCTE.ProductId
                        
	                    WHERE Branch IN ({branchIdListFilter})
                        {SpecialPricingFilter}
                        AND [Pricing].[IsDeleted] IS NULL OR [Pricing].[IsDeleted] =0
	                    Group BY Pricing.Product
                    )
                , Results AS 
					(
                    Select ProductCTE.ParentCategoryId, ParentCategoryName, CategoryId AS SubCategoryId, SubCategoryName, 
                    ProductCTE.ProductId, Name,PictureName, Price, ISNULL(StoresCount,0) StoresCount
                    , ISNULL(SpecialPrice,0) SpecialPrice
                    , FlagWishlist
                    FROM ProductCTE
                    INNER JOIN ParentCategoryCTE ON ParentCategoryCTE.ParentCategoryId = ProductCTE.ParentCategoryId                    
                    LEFT JOIN BranchCTE ON ProductCTE.ProductId = BranchCTE.Product
                    LEFT JOIN ProductWishlist ON ProductCTE.ProductId = ProductWishlist.ProductId     
                    {PriceLowToHighFilterClause}              
                    )
                    {GetRowNumberQuery}
                    "
                        .FormatWith(new
            {
                //TODO:Check for list count in this method as well, and then join.
                categoryIdListArray  = string.Join(",", categoryIdList),
                branchIdListFilter   = branchIdList.Count > 0 ? string.Join(",", branchIdList): "0",
                SpecialPricingFilter = " AND [Pricing].[Price] >= {priceRangeFrom} AND [Pricing].[Price] <= {priceRangeTo}".FormatWith(new { priceRangeFrom, priceRangeTo }),
                PricingFilter        = " AND [Pricing].[SpecialPrice] >= {priceRangeFrom} AND [Pricing].[SpecialPrice] <= {priceRangeTo}".FormatWith(new { priceRangeFrom, priceRangeTo }),
                BrandFilter          = (filter != null && filter.SelectedBrandList != null && filter.SelectedBrandList.Count > 0) ? " AND [Product].[Manufacturer] IN ( " +
                                       string.Join(",", filter.SelectedBrandIdList) + " )" : "",
                GetRowNumberQuery          = ProductHelper.GetRowNumberQuery(GetSortByFieldBasedOnEnumForProductQuery(filter), pageStart, pageSize),
                PriceLowToHighFilterClause = (filter != null && filter.SortById > 0 && filter.SortById < 4) ? " WHERE SpecialPrice > 0 " : "",
                userId = userId
            });

            return(query);
        }
Example #23
0
        public static string GetProductsQuery_WithFilterAndBuy(this IGenericRepository <Product> productRepository, SelectedFilter filter,
                                                               List <VSOnline.VSECommerce.Domain.ResultSet.SelectedProductFilterList> selectedProductFilter,
                                                               int[] categoryIdList, List <int> branchIdList,
                                                               int?priceRangeFrom, int?priceRangeTo, int?pageStart, int?pageSize, int?userId)
        {
            string SelectedFilterDetailsCTE = "";

            if (selectedProductFilter != null)
            {
                //  var filters = selectedProductFilter.GroupBy(u => u.FilterParameter);
                if (selectedProductFilter.Count() > 0)
                {
                    HelperQuery productRepoObj = new HelperQuery();
                    SelectedFilterDetailsCTE = productRepoObj.GenerateFilterTempTable(selectedProductFilter);
                }
            }
            if (SelectedFilterDetailsCTE.Length <= 0)
            {
                SelectedFilterDetailsCTE = "Select NULL Dummy";
            }
            var query = @"   
                    WITH SelectedFilterDetails 
					AS 
					(
					{SelectedFilterDetailsCTE}
					)                    
                    , ProductCTE AS 
                    (
                     Select ParentCategoryId, CategoryId, Category.Name AS SubCategoryName, Category.FlagShowBuy AS FlagShowBuy,
                    Product.ProductId, Product.Name as Name,Product.PictureName, Max(Price) AS Price
                               From Product
                                            Inner Join Category ON Category.CategoryId = Product.Category
                                            {SelectedFilterDetailsCTEJoin}
                                            LEFT Join Pricing ON Pricing.Product = Product.ProductId
                                            
                                             WHERE ( NOT ((1 = [Product].[IsDeleted]) AND ([Product].[IsDeleted] IS NOT NULL))) 
                                                  
                                                                                          {PricingFilter}                                                              
                                                                                          {BrandFilter}  
		                                                                                  AND (1 = [Product].[Published]) AND ([Product].[Category] IN ({categoryIdListArray}))																 
                    GROUP BY ParentCategoryId, CategoryId,  Category.Name , FlagShowBuy, Product.ProductId, Product.Name,Product.PictureName
                    )
                     ,ProductWishlist AS
                     (

                    select   ProductId, UserWishlist.Id, CASE WHEN (UserWishlist.Id) IS NULL 
                                    THEN CAST(0 AS BIT) ELSE CAST(1 AS BIT) END 
                                        AS FlagWishlist
                    From ProductCTE 
	                    INNER JOIN UserWishlist ON ProductCTE.ProductId = UserWishlist.Product
											                    AND UserWishlist.[User] = {userId}

                    )
                    ,ParentCategoryCTE AS 
					(
					 Select DISTINCT Category.Name AS ParentCategoryName, ProductCTE.ParentCategoryId 
					 FROM Category
					 Inner Join ProductCTE ON Category.CategoryId = ProductCTE.ParentCategoryId
					)
                    ,
                    BranchCTE AS
                    (
	                    SELECT DISTINCT Pricing.Product Product, Count(Branch) StoresCount, Min(SpecialPrice) SpecialPrice 
                        FROM Pricing 
	                    Inner Join ProductCTE ON Pricing.Product = ProductCTE.ProductId                        
	                    WHERE Branch IN ({branchIdListFilter})
                        {SpecialPricingFilter}
                        AND [Pricing].[IsDeleted] IS NULL OR [Pricing].[IsDeleted] =0
	                    Group BY Pricing.Product
                    )
	                ,MinBranchCTE AS
					(
					Select Pricing.Branch,SellerBranch.BranchName, Pricing.Product, Pricing.DeliveryTime, 
					Pricing.AdditionalShippingCharge, SellerBranch.EnableBuy, ProductCTE.FlagShowBuy
					from Pricing 
					Inner Join SellerBranch on SellerBranch.BranchId = Pricing.Branch
					Inner Join BranchCTE on BranchCTE.Product = Pricing.Product
                    INNER JOIN ProductCTE ON ProductCTE.ProductId = Pricing.Product
					AND Pricing.Product = BranchCTE.Product
                    AND SellerBranch.EnableBuy =1
                    AND ProductCTE.FlagShowBuy =1
					AND Pricing.SpecialPrice = BranchCTE.SpecialPrice
					)
                , Results AS 
					(
                    Select ProductCTE.ParentCategoryId CategoryId, ParentCategoryName, CategoryId AS SubCategoryId, SubCategoryName, 
                    ProductCTE.ProductId, Name,PictureName, Price, ISNULL(StoresCount,0) StoresCount
                    , ISNULL(SpecialPrice,0) SpecialPrice
                    , FlagWishlist
	                ,MinBranchCTE.Branch,  MinBranchCTE.BranchName, MinBranchCTE.Product, MinBranchCTE.DeliveryTime, 
					MinBranchCTE.AdditionalShippingCharge, MinBranchCTE.EnableBuy, MinBranchCTE.FlagShowBuy
                    FROM ProductCTE
                    INNER JOIN ParentCategoryCTE ON ParentCategoryCTE.ParentCategoryId = ProductCTE.ParentCategoryId                    
                    LEFT JOIN BranchCTE ON ProductCTE.ProductId = BranchCTE.Product
                    LEFT JOIN ProductWishlist ON ProductCTE.ProductId = ProductWishlist.ProductId     
                    LEFT JOIN MinBranchCTE ON MinBranchCTE.Product =  ProductCTE.ProductId
                    {PriceLowToHighFilterClause}              
                    )
                    {GetRowNumberQuery}
                    "
                        .FormatWith(new
            {
                //TODO:Check for list count in this method as well, and then join.
                categoryIdListArray  = string.Join(",", categoryIdList),
                branchIdListFilter   = branchIdList.Count > 0 ? string.Join(",", branchIdList) : "0",
                SpecialPricingFilter = " AND [Pricing].[Price] >= {priceRangeFrom} AND [Pricing].[Price] <= {priceRangeTo}".FormatWith(new { priceRangeFrom, priceRangeTo }),
                PricingFilter        = " AND [Pricing].[SpecialPrice] >= {priceRangeFrom} AND [Pricing].[SpecialPrice] <= {priceRangeTo}".FormatWith(new { priceRangeFrom, priceRangeTo }),
                BrandFilter          = (filter != null && filter.SelectedBrandList != null && filter.SelectedBrandList.Count > 0) ? " AND [Product].[Manufacturer] IN ( " +
                                       string.Join(",", filter.SelectedBrandIdList) + " )" : "",
                GetRowNumberQuery          = ProductHelper.GetRowNumberQuery(GetSortByFieldBasedOnEnumForProductQuery(filter), pageStart, pageSize),
                PriceLowToHighFilterClause = (filter != null && filter.SortById > 0 && filter.SortById < 4) ? " WHERE SpecialPrice > 0 " : "",
                userId = userId,
                SelectedFilterDetailsCTE,
                SelectedFilterDetailsCTEJoin = (selectedProductFilter != null && selectedProductFilter.Count() > 0) ? @"Inner Join ProductFilterValue ON ProductFilterValue.ProductId = Product.ProductId
											 Inner Join [CategoryMasterFilter] ON ProductFilterValue.CategoryMasterFilter = [CategoryMasterFilter].Id
											 INNER JOIN SelectedFilterDetails ON Product.ProductId = SelectedFilterDetails.ProductId
											 "                                             : ""
                                               //Not thinking much to handle this. Need to performance enhance seperately.
            });

            return(query);
        }
Example #24
0
        private async void ApplyExecute()
        {
            IsWorking = true;

            if (_editingSession == null || _noChanges)
            {
                return;
            }

            if (!CanApply)
            {
                _queued = true;
                return;
            }

            CanApply = false;

            _filterApplied = true;
            if (_filterApplied && _editingSession.CanUndo())
            {
                try { _editingSession.Undo(); }
                catch (Exception e)
                {
                    App.LogError(e);
                }
            }

            // apply filter to selected pixels only
            PreviewImage = new WriteableBitmap(ImageWidth, ImageHeight);
            _buffer.CopyTo(PreviewImage.Pixels, 0);

            using (var ms = PreviewImage.ToStream())
            {
                var editingSession = await EditingSessionFactory.CreateEditingSessionAsync(ms);

                editingSession.AddFilter(SelectedFilter.Creator());
                await editingSession.RenderToWriteableBitmapAsync(PreviewImage);
            }

            // remove unnecessary pixels
            //var removal = ClearTransparent ? Constants.White & 0xFFFFFF : Constants.White;
            // transparent white
            var removal = (0xFF << 24) |
                          (Grayscale << 16) |
                          (Grayscale << 8) |
                          (Grayscale);

            for (var i = 0; i < PreviewImage.Pixels.Length; ++i)
            {
                if (_maskBuffer[i] == 0)
                {
                    PreviewImage.Pixels[i] = removal;
                }

                if (_maskBuffer[i] != 0)
                {
                    MainImage.Pixels[i] = ((Grayscale2 << 16) | (Grayscale2 << 8) | Grayscale2) | ((255 - _maskBuffer[i]) << 24);
                }
                else
                {
                    MainImage.Pixels[i] = _backup.Pixels[i];
                }
            }

#if DEBUG
            try
            {
                using (var fileStream = _isoStore.CreateFile("MainImage.jpg"))
                    MainImage.SaveJpeg(fileStream, ImageWidth, ImageHeight, 0, 100);
                using (var fileStream = _isoStore.CreateFile("PreviewImage.jpg"))
                    PreviewImage.SaveJpeg(fileStream, ImageWidth, ImageHeight, 0, 100);
            }
            catch (Exception e)
            {
                App.LogError(e);
            }
#endif

            using (var ms = MainImage.ToStream())
            {
                Helpers.SafeDispose(ref _editingSession);
                _editingSession = await EditingSessionFactory.CreateEditingSessionAsync(ms);
            }

            using (var ms = PreviewImage.ToStream())
                using (var blendingSession = await EditingSessionFactory.CreateEditingSessionAsync(ms))
                {
                    PreviewImage.Invalidate();

                    _editingSession.AddFilter(FilterFactory.CreateBlendFilter(blendingSession, SelectedBlendFunction));
                    var temp = new WriteableBitmap(MainImage.PixelWidth, MainImage.PixelHeight);
                    await _editingSession.RenderToWriteableBitmapAsync(temp);

                    MainImage = temp;
                    if (SelectedTool != null)
                    {
                        SelectedTool.TargetImage = MainImage;
                    }

                    UndoCommand.RaiseCanExecuteChanged();
                    CanApply = true;
                }

            if (_queued)
            {
                _queued = false;
                ApplyExecute();
            }

            IsWorking = false;
        }
Example #25
0
        public async Task <ActionResult> UpdateMasterFilter(int id, MasterFilter masterFilter)
        {
            var foundFilter = _context.MasterFilter.FirstOrDefault(m => m.Id == id);
            List <SelectedFilter> selectedFilter;

            if (foundFilter == null)
            {
                selectedFilter = masterFilter.SelectedFilter;
                masterFilter.SelectedFilter = null;
                _context.MasterFilter.Add(masterFilter);
                await _context.SaveChangesAsync();

                foundFilter = masterFilter;
            }
            else
            {
                // Update Database
                // Name
                foundFilter.Name = masterFilter.Name;
                // Value
                foundFilter.FilterValue = masterFilter.FilterValue;
                await _context.SaveChangesAsync();

                selectedFilter = masterFilter.SelectedFilter;
                //   // Delete All Selected Filters for the MasterFilter, and create new ones from the object
                var selectedFiltersToBeDeleted = _context.SelectedFilter.Where(w => w.MasterFilterId == foundFilter.Id);
                _context.SelectedFilter.RemoveRange(selectedFiltersToBeDeleted);
                await _context.SaveChangesAsync();
            }
            var user        = _context.User.FirstOrDefault(f => f.Id == masterFilter.UserId);
            var accessToken = user.Token;
            await _context.SaveChangesAsync();

            foreach (var filter in selectedFilter)
            {
                // update database
                var _filter = new SelectedFilter
                {
                    GoogleAccountId   = filter.GoogleAccountId,
                    GoogleFilterId    = filter.GoogleFilterId,
                    GoogleAccountName = filter.GoogleAccountName,
                    GoogleFilterName  = filter.GoogleFilterName,
                    MasterFilterId    = foundFilter.Id
                };
                await _context.SelectedFilter.AddAsync(_filter);

                await _context.SaveChangesAsync();

                // get filter object from Google
                var        accountId       = filter.GoogleAccountId;
                var        filterId        = filter.GoogleFilterId;
                var        API             = $"https://www.googleapis.com/analytics/v3/management/accounts/{accountId}/filters/{filterId}";
                HttpClient getFilterClient = new HttpClient();
                getFilterClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {accessToken}");
                getFilterClient.DefaultRequestHeaders.Add("Accept", "application/json");
                HttpResponseMessage response = await getFilterClient.GetAsync(API);

                var content = await response.Content.ReadAsStringAsync();

                var data = JsonConvert.DeserializeObject <RootObject>(content);

                // Update Filter Value
                data.excludeDetails.expressionValue = masterFilter.FilterValue;

                // Update Google
                HttpClient postFilterClient = new HttpClient();
                postFilterClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {accessToken}");
                postFilterClient.DefaultRequestHeaders.Add("Accept", "application/json");
                // postFilterClient.DefaultRequestHeaders.Add("Content-Type", "application/json");
                var postContent = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");

                HttpResponseMessage putResponse = await postFilterClient.PutAsync(API, postContent);
            }
            return(Ok(masterFilter));
        }
Example #26
0
        public void Compute()
        {
            int    distancePoints = 0;
            double distance       = 0;
            bool   radar          = false;

            SelectedSignal1Tab.TabContent.Data.FromSamples = true;
            SelectedSignal2Tab.TabContent.Data.FromSamples = true;
            if (SelectedSignal1Tab.TabContent.Data.HasData() && SelectedSignal2Tab.TabContent.Data.HasData())
            {
                DataHandler   data    = new DataHandler();
                List <double> pointsY = new List <double>();

                switch (SelectedOperation.Substring(1, 2))
                {
                case "O1":
                    if (!SelectedSignal2Tab.TabContent.Data.IsValidConvulution(SelectedSignal1Tab.TabContent.Data))
                    {
                        MessageBox.Show("Given signals are not valid", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    pointsY = SignalFiltering.CalculateConvolution(SelectedSignal1Tab.TabContent.Data.Samples,
                                                                   SelectedSignal2Tab.TabContent.Data.Samples);
                    break;

                case "O2":
                    int windowType = int.Parse(SelectedWindow.Substring(0, 1));
                    int filterType = int.Parse(SelectedFilter.Substring(0, 1));
                    pointsY = SignalFiltering.Filter(SelectedSignal1Tab.TabContent.Data.Samples, M, K, windowType, filterType);
                    break;

                case "O3":
                    if (!SelectedSignal2Tab.TabContent.Data.IsValidConvulution(SelectedSignal1Tab.TabContent.Data))
                    {
                        MessageBox.Show("Given signals are not valid", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    pointsY = SignalFiltering.CalculateCorrelation(SelectedSignal1Tab.TabContent.Data.Samples,
                                                                   SelectedSignal2Tab.TabContent.Data.Samples);
                    break;

                case "O4":
                    pointsY = SignalFiltering.CalculateDistance(SelectedSignal1Tab.TabContent.Data.Samples,
                                                                SignalFiltering.DelaySignal(SelectedSignal1Tab.TabContent.Data.Samples, t * SelectedSignal1Tab.TabContent.Data.Frequency), out distancePoints);
                    distance = distancePoints * v / SelectedSignal1Tab.TabContent.Data.Frequency;
                    radar    = true;
                    break;
                }

                data.StartTime   = SelectedSignal1Tab.TabContent.Data.StartTime;
                data.Frequency   = SelectedSignal1Tab.TabContent.Data.Frequency;
                data.Samples     = pointsY;
                data.FromSamples = true;
                SelectedResultTab.TabContent.IsScattered = true;
                SelectedResultTab.TabContent.LoadData(data);
                SelectedResultTab.TabContent.AddOriginal = false;
                SelectedResultTab.TabContent.AddSamples  = false;
                SelectedResultTab.TabContent.DrawCharts();
                SelectedResultTab.TabContent.CalculateSignalInfo(isDiscrete: true, fromSamples: true);
                if (radar)
                {
                    MessageBox.Show("Odległość: " + distance.ToString() + " m", "Radar", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
        }