public JsonResult ProductQuery(ProductQueryRequest request)
        {
            var totalNumber = 0;

            var dt = GetProductQuery(request, ref totalNumber);

            var data = BuildProductQueryModel(dt);

            GridViewModel <ProductQueryViewModel> result = new GridViewModel <ProductQueryViewModel>(totalNumber, data, request.sEcho);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
 public List <ProductResponse> Query(ProductQueryRequest productQuery)
 {
     return(_context.Product.Where(x => x.Id == productQuery.Id || x.Brand == productQuery.Brand)
            .ToList().Select(x => new ProductResponse()
     {
         Brand = x.Brand,
         Id = x.Id,
         Name = x.Name,
         Price = x.Price,
         StockCount = x.StockCount
     }).ToList());
 }
Example #3
0
 public List <ProductResponse> Query(ProductQueryRequest request)
 {
     return(_context.Product.Where(x => x.Id == request.Id || x.Brand == request.Brand)
            .ToList()
            .Select(e => new ProductResponse() //like models
     {
         Id = e.Id,
         Name = e.Name,
         Brand = e.Brand,
         UnitPrice = e.UnitPrice,
         StockCount = e.StockCount,
     }).ToList());
 }
Example #4
0
        protected static FR_L3ABDA_GAAPfSC_1547 Execute(DbConnection Connection, DbTransaction Transaction, P_L3ABDA_GAAPfSC_1547 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L3ABDA_GAAPfSC_1547();

            returnValue.Result = new L3ABDA_GAAPfSC_1547();

            string catalogITL = EnumUtils.GetEnumDescription(EPublicCatalogs.ABDA);

            var sbsCatalog = ORM_CMN_PRO_SubscribedCatalog.Query.Search(Connection, Transaction, new ORM_CMN_PRO_SubscribedCatalog.Query()
            {
                CatalogCodeITL = catalogITL,
                Tenant_RefID   = securityTicket.TenantID,
                IsDeleted      = false
            }).FirstOrDefault();

            if (sbsCatalog == null)
            {
                return(returnValue);
            }

            string query = "";
            bool   isSecondQueryNeeded = false;

            if (Parameter.IsPrefixSearch)
            {
                QueryBuilderPrefixSearch prefixSearch = new QueryBuilderPrefixSearch(Parameter);
                query = prefixSearch.GetQuery();
            }
            else
            {
                QueryBuilderImpressiveSearch impressiveSearch = new QueryBuilderImpressiveSearch(Parameter.PZN, Parameter.SearchQuery);
                query = impressiveSearch.GetQuery();
                isSecondQueryNeeded = impressiveSearch.IsSecondQueryNeeded();
            }

            var ProductService          = CatalogServiceFactory.GetProductService();
            ProductQueryRequest request = new ProductQueryRequest()
            {
                CatalogCode = catalogITL
            };
            var res = ProductService.QueryProducts(request, query);
            var retrievedProducts = res.Documents.ToList();

            returnValue.Result.Products = retrievedProducts.ToArray();
            returnValue.Result.Query    = query;
            return(returnValue);

            #endregion UserCode
        }
Example #5
0
        /// <summary>
        /// HttpClient实现Get请求(异步)
        /// </summary>
        public static async Task <ProductResponse> dooGet()
        {
            ProductQueryRequest request = new ProductQueryRequest
            {
                Head = new HeadRequest
                {
                    InvokeTime      = DateTime.Now.ToString("yyyy-MM-dd"),
                    InvokeUser      = "******",
                    ProtocolVersion = "V1"
                },
                Body = new Product
                {
                    Type = 0
                }
            };
            var data         = Base64Helper.ObjectToBase64Encode(request);
            var sign         = Md5Helper.Md5Encrypt32(data, "dc0b52fb-c750-44f2-b5dc-f2577fd98c1b");
            var securityType = "MD5";

            string url = "http://192.168.13.43:60110/api/product?data=" + data + "&sign=" + sign + "&securityType=" + securityType;
            //创建HttpClient(注意传入HttpClientHandler)
            var handler = new HttpClientHandler()
            {
                AutomaticDecompression = DecompressionMethods.GZip
            };

            using (var http = new HttpClient(handler))
            {
                //await异步等待回应
                var response = await http.GetAsync(url);

                //确保HTTP成功状态值
                var httpResponseMessage = response.EnsureSuccessStatusCode();
                if (httpResponseMessage.StatusCode == HttpStatusCode.OK)
                {
                    var ddd = await response.Content.ReadAsStringAsync();

                    var result = JsonHelper.JsonToObject <PageResult>(ddd);
                    return(Base64Helper.Base64EncodeToObject <ProductResponse>(result.Data));
                }
                return(null);

                //await异步读取最后的JSON(注意此时gzip已经被自动解压缩了,因为上面的AutomaticDecompression = DecompressionMethods.GZip)
            }
        }
Example #6
0
        public IActionResult Query([FromQuery] ProductQueryRequest filter)
        {
            ResultCode resultCode; QueryModel queryResult;

            (resultCode, queryResult) = _service.Query(filter);

            Result error; int statusCode;

            (statusCode, error) = ResultHandler.GetStatusCodeAndResult(resultCode);

            GeneralResponse response = new GeneralResponse
            {
                Result = queryResult,
                Error  = error,
            };

            return(StatusCode(statusCode, response));
        }
Example #7
0
        public ProductResponse GetProduct(ProductQueryRequest request)
        {
            request.Head = RequestHead();
            string url    = _website + "product";
            var    result = PostService(request, url);

            if (!string.IsNullOrEmpty(result.Data))
            {
                return(Base64Helper.Base64EncodeToObject <ProductResponse>(result.Data));
            }
            return(new ProductResponse
            {
                Head = new HeadResponse
                {
                    Code = "900001",
                    Describe = "数据格式不正确"
                }
            });
        }
        public async Task QueryShouldReturnHttpSuccessStatusCode()
        {
            // Arrange
            var queryRequest = new ProductQueryRequest()
            {
                Id    = 4,
                Brand = "test"
            };

            var contentJson   = JsonConvert.SerializeObject(queryRequest);
            var stringContent = new StringContent(contentJson, Encoding.UTF8, "application/json");

            var client = _factory.CreateClient();

            // Act
            var response = await client.PostAsync("/Product/Query", stringContent);

            // Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        }
Example #9
0
        public static ProductResponse GetProduct(ProductQueryRequest request)
        {
            request.Head = new HeadRequest
            {
                InvokeTime      = DateTime.Now.ToString("yyyy-MM-dd"),
                InvokeUser      = key,
                ProtocolVersion = "V1"
            };
            string url    = apiUrl + "product";
            var    result = dooPost(request, url).Result;

            if (!string.IsNullOrEmpty(result.Data))
            {
                return(Base64Helper.Base64EncodeToObject <ProductResponse>(result.Data));
            }
            return(new ProductResponse {
                Head = new HeadResponse {
                    Describe = "数据格式不正确"
                }
            });
        }
 public List <ProductResponse> Query([FromBody] ProductQueryRequest productQuery)
 {
     return(_service.Query(productQuery));
 }
Example #11
0
        private void UpdataUIStatusAsync()
        {
            int type        = 0;
            int productId   = 0;
            int currentPage = 0;
            int pageSize    = 0;

            if (comboBox1.Text == "分页")
            {
                type = 1;
                if (string.IsNullOrEmpty(textBox13.Text))
                {
                    MessageBox.Show("请填写当前页数");
                    return;
                }
                currentPage = Convert.ToInt32(textBox13.Text);
                if (string.IsNullOrEmpty(textBox14.Text))
                {
                    MessageBox.Show("请填写每页记录数");
                    return;
                }
                pageSize = Convert.ToInt32(textBox14.Text);
            }
            else if (comboBox1.Text == "获取单个产品")
            {
                type = 2;
                if (string.IsNullOrEmpty(textBox1.Text))
                {
                    MessageBox.Show("请填写产品id");
                    return;
                }
                productId = Convert.ToInt32(textBox1.Text);
            }

            ProductQueryRequest request = new ProductQueryRequest
            {
                Body = new Product
                {
                    Type        = type,
                    ProductId   = productId,
                    CurrentPage = currentPage,
                    PageSize    = pageSize
                }
            };
            var result = Class1.GetProduct(request);

            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("产品名称");
            dataTable.Columns.Add("产品id");
            dataTable.Columns.Add("景区名称");
            dataTable.Columns.Add("销售价格");
            dataTable.Columns.Add("购买人数");
            dataTable.Rows.Clear();
            if (result.Body != null)
            {
                foreach (var row in result.Body.ProductList)
                {
                    DataRow drow = dataTable.NewRow();
                    drow["产品名称"] = row.ProductName;
                    drow["产品id"] = row.ProductId;
                    drow["景区名称"] = row.SightName;
                    drow["销售价格"] = row.PriceInfo.SellPrice;
                    drow["购买人数"] = 1;
                    dataTable.Rows.Add(drow);
                }
            }
            Invoke(new InvokeHandler(delegate()
            {
                dataGridView1.DataSource = dataTable;
            }));
            SetMsg("获取订单: \r\n" + JsonHelper.ObjectToJson(result));
        }
Example #12
0
        protected static FR_L3ABDA_GAPfSC_1435 Execute(DbConnection Connection, DbTransaction Transaction, P_L3ABDA_GAPfSC_1435 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L3ABDA_GAPfSC_1435();
            returnValue.Result                 = new L3ABDA_GAPfSC_1435();
            returnValue.Result.Result          = new ABDASearchResult();
            returnValue.Result.Result.Products = new List <ABDAProduct>();

            string catalogITL = EnumUtils.GetEnumDescription(EPublicCatalogs.ABDA);

            var sbsCatalog = ORM_CMN_PRO_SubscribedCatalog.Query.Search(Connection, Transaction, new ORM_CMN_PRO_SubscribedCatalog.Query()
            {
                CatalogCodeITL = catalogITL,
                Tenant_RefID   = securityTicket.TenantID,
                IsDeleted      = false
            }).FirstOrDefault();

            if (sbsCatalog == null)
            {
                return(returnValue);
            }

            string query = new QueryBuilder <Product>()
                           .From(Parameter.pageIndex * Parameter.pageSize)
                           .Size(Parameter.pageSize)
                           .Query(q => q
                                  .Bool(b => b
                                        .Must(m => m
                                              .QueryString(qs => qs.Fields(new string[] { SearchCondition.GetFiledName(ProductField.NAME), SearchCondition.GetFiledName(ProductField.CODE) })
                                                           .Query(SearchCondition.GetQueryForField(Parameter.Conditions, ProductField.NAME)))
                                              .QueryString(qs => qs.Fields(SearchCondition.GetFiledName(ProductField.CODE)).Query(SearchCondition.GetQueryForField(Parameter.Conditions, ProductField.CODE)))
                                              .QueryString(qs => qs.Fields(SearchCondition.GetFiledName(ProductField.UNIT)).Query(SearchCondition.GetQueryForField(Parameter.Conditions, ProductField.UNIT)))
                                              .QueryString(qs => qs.Fields(SearchCondition.GetFiledName(ProductField.DOSAGE_FORM)).Query(SearchCondition.GetQueryForField(Parameter.Conditions, ProductField.DOSAGE_FORM)))
                                              .QueryString(qs => qs.Fields(SearchCondition.GetFiledName(ProductField.SUBSTANCE)).Query(SearchCondition.GetQueryForField(Parameter.Conditions, ProductField.SUBSTANCE)))
                                              .QueryString(qs => qs.Fields(SearchCondition.GetFiledName(ProductField.DISTRIBUTION_STATUS)).Query(SearchCondition.GetQueryForField(Parameter.Conditions, ProductField.DISTRIBUTION_STATUS)))
                                              .QueryString(qs => qs.Fields(SearchCondition.GetFiledName(ProductField.PRODUCER)).Query(SearchCondition.GetQueryForField(Parameter.Conditions, ProductField.PRODUCER)))
                                              .Prefix(p => p.Field(SearchCondition.GetFiledName(ProductField.NAME_TOKEN)).Prefix(SearchCondition.GetPrefixForField(Parameter.Conditions, ProductField.NAME_TOKEN)))
                                              )
                                        )
                                  )
                           .Sort(s => s
                                 .Field(SearchCondition.GetFiledName(Parameter.Order.field), (Parameter.Order.order == SortingOrder.ASC) ? PlainElastic.Net.SortDirection.asc : PlainElastic.Net.SortDirection.desc))
                           .BuildBeautified();

            var ProductService = CatalogServiceFactory.GetProductService();

            List <Product> retrievedProducts = new List <Product>();

            int hitsTotal;

            bool IsPartOFDefaultStock = Parameter.Conditions.Any(x => x.field == ProductField.IS_PART_OF_DEFAULT_STOCK && x.query == "true");


            if (IsPartOFDefaultStock)
            {
                List <string> ITLs = new List <string>();
                ITLs = cls_Get_ITLS_for_Products_HaveFlag_IsProductPartOfDefaultStock.Invoke(Connection, Transaction, securityTicket).Result.Select(x => x.ProductITL).ToList();
                ProductDetailsRequest requestWithITLS = new ProductDetailsRequest {
                    CatalogCode = catalogITL, ProductIDs = ITLs
                };

                var resWithITLS = ProductService.GetProductDetails(requestWithITLS);

                retrievedProducts = resWithITLS.ProductDetails.
                                    Where(x => !Parameter.Conditions.Any(y => y.field == ProductField.PRODUCER && !string.IsNullOrEmpty(y.query)) ||
                                          x.Producer.ToLower().Contains(Parameter.Conditions.SingleOrDefault(y => y.field == ProductField.PRODUCER).query.ToLower()))

                                    .Where(x => !(Parameter.Conditions.Any(y => y.field == ProductField.DOSAGE_FORM && !string.IsNullOrEmpty(y.query))) ||
                                           (x.Healthcare.DosageForm != null && x.Healthcare.DosageForm.ToLower().Contains(Parameter.Conditions.SingleOrDefault(y => y.field == ProductField.DOSAGE_FORM).query.ToLower())))

                                    .Where(x => !Parameter.Conditions.Any(y => y.field == ProductField.NAME && !string.IsNullOrEmpty(y.query)) ||
                                           x.Name.ToLower().Contains(Parameter.Conditions.SingleOrDefault(y => y.field == ProductField.NAME).query.ToLower()))

                                    .Where(x => !Parameter.Conditions.Any(y => y.field == ProductField.CODE && !string.IsNullOrEmpty(y.query)) ||
                                           x.Code.ToLower().Contains(Parameter.Conditions.SingleOrDefault(y => y.field == ProductField.CODE).query.ToLower()))

                                    .Where(x => !Parameter.Conditions.Any(y => y.field == ProductField.UNIT && !string.IsNullOrEmpty(y.query)) ||
                                           x.Packaging.Unit.ToLower().Contains(Parameter.Conditions.SingleOrDefault(y => y.field == ProductField.UNIT).query.ToLower()))
                                    .ToList();

                hitsTotal = retrievedProducts.Count();
            }
            else
            {
                ProductQueryRequest request = new ProductQueryRequest()
                {
                    CatalogCode = catalogITL
                };
                var res = ProductService.QueryProducts(request, query);
                hitsTotal         = res.hits.total;
                retrievedProducts = res.Documents.ToList();
            }


            var catalogInfoRequest = new CatalogInfoRequest()
            {
                CatalogCode = catalogITL
            };
            var catalogService = CatalogServiceFactory.GetCatalogService();
            var catalogInfo    = catalogService.GetCatalogInfo(catalogInfoRequest);

            // Find currency symbol
            var currencySymbol = string.Empty;
            if (catalogInfo != null && catalogInfo.CatalogInfo != null)
            {
                var currency = CL1_CMN.ORM_CMN_Currency.Query.Search(Connection, Transaction,
                                                                     new CL1_CMN.ORM_CMN_Currency.Query
                {
                    ISO4127      = catalogInfo.CatalogInfo.Currency,
                    Tenant_RefID = securityTicket.TenantID,
                    IsDeleted    = false
                }).SingleOrDefault();

                if (currency != null)
                {
                    currencySymbol = currency.Symbol;
                }
            }



            #region GetStandartPrices

            L3PR_GSPfPITLL_1258 standardPrices = new L3PR_GSPfPITLL_1258();
            if (retrievedProducts.Count() != 0)
            {
                var spParam = new P_L3PR_GSPfPITLL_1258()
                {
                    ProductITLList = retrievedProducts.Select(i => i.ProductITL).ToArray()
                };

                standardPrices = cls_Get_StandardPrices_for_ProductITLList.Invoke(Connection, Transaction, spParam, securityTicket).Result;
            }

            #endregion


            // Set ABDA products from Catalog Products
            var abdaProducts = new List <ABDAProduct>();
            foreach (var product in retrievedProducts)
            {
                var abdaProduct = new ABDAProduct();
                abdaProduct.Product        = product;
                abdaProduct.ABDAPrice      = product.GetDefaultPrice();
                abdaProduct.Prices         = standardPrices.Prices.Where(i => i.ProductITL == product.ProductITL).SingleOrDefault();
                abdaProduct.CurrencySymbol = currencySymbol;
                abdaProduct.Producer       = product.Producer;
                abdaProducts.Add(abdaProduct);
            }

            // Set ABDA results
            returnValue.Result.Result = new ABDASearchResult()
            {
                hitCount = hitsTotal,
                Products = abdaProducts
            };

            return(returnValue);

            #endregion UserCode
        }
        /// <summary>
        /// 产品查询SQL
        /// </summary>
        /// <param name="request"></param>
        /// <param name="totalNumber"></param>
        /// <returns></returns>
        public DataTable GetProductQuery(ProductQueryRequest request, ref int totalNumber)
        {
            var countSQl = @"select count(1) from IN_CMS.V_FP_PARAMETER_MAIN_ALL v where 1=1 {0}";

            var sql = @"with cte as(
                            select rownum rn,v.*
                            from IN_CMS.V_FP_PARAMETER_MAIN_ALL v where 1=1 {0}
                        ) 
                        select  c.rn
                                ,c.financial_product_id
                                ,c.financial_product_nme
                                ,c.FP_GROUP_NME --产品组
                                ,c.FP_GROUP_ID  --产品组ID
                                ,c.VALID_FROM_DTE --产品有效期始
                                ,c.VALID_TO_DTE --产品有效期至
                                ,c.Execution_Dte --更新日期
                                ,c.FLEET_COMP_INDIV_IND
                                ,c.MINIMUM_FINANCING_AMT --最小融资额
                                ,c.MAXIMUM_FINANCING_AMT --最大融资额
                                ,c.MINIMUM_LEASE_TRM --最小租期
                                ,c.MAXIMUN_LEASE_TRM --最大租期
                                ,c.MAXIMUM_FINANCING_PCT --最大融资比例
                                ,c.Future_Value_Typ --尾款 R 表示支持尾款
                                ,c.minimum_rv_pct
                                ,c.maximum_rv_pct
                                ,c.minimum_term_mm
                                ,c.maximum_term_mm
                                ,c.RV_PCT --残值百分比
                                ,c.Rv_Guarantee_Amt
                                ,c.CUSTOMER_RTE --客户利率
                                ,c.ACTUAL_RTE --实际利率
                                ,c.SUBSIDY_RTE --补贴率
                                ,c.rv_editable_ind
                                ,c.et_nonactrebate_pct --提前终止罚金比例
                                ,c.et_penalty_ind 
                                ,c.REPAYMENT_METHOD 
                                ,c.DEALER_SUBSIDY_PCT
                                ,c.MANUFACTURER_SUBSIDY_PCT
                                from cte c ";

            var conditions = string.Empty;

            if (!string.IsNullOrEmpty(request.ProductName))
            {
                conditions += string.Format(" And v.financial_product_nme like '%{0}%' ", request.ProductName);
            }
            if (!string.IsNullOrEmpty(request.StartTime))//接收时间的开始时间范围
            {
                conditions += string.Format(" AND  v.VALID_FROM_DTE>=to_date('{0}','yyyy-mm-dd')\r\n", request.StartTime);
            }
            if (!string.IsNullOrEmpty(request.EndTime))//接收时间的结束时间范围
            {
                conditions += string.Format(" AND v.VALID_TO_DTE<=to_date('{0}','yyyy-mm-dd')\r\n", request.EndTime);
            }
            if (request.StartIndex > 0 && request.EndIndex > 0)
            {
                sql += " where c.rn >={1} and c.rn<={2}";
                sql  = string.Format(sql, conditions, request.StartIndex, request.EndIndex);
            }
            else
            {
                sql = string.Format(sql, conditions);
            }

            countSQl = string.Format(countSQl, conditions);

            DataTable dt  = CommonFunction.ExecuteDataTableSql("CAPDB", sql);
            var       num = CommonFunction.ExecuteScalar("CAPDB", countSQl);

            totalNumber = Convert.ToInt32(num);
            return(dt);
        }
Example #14
0
        protected static FR_L3ABDA_GAAfAS_1256_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L3ABDA_GAAfAS_1256 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L3ABDA_GAAfAS_1256_Array();

            #region Check ABDA Catalog Subscription

            string catalogITL = EnumUtils.GetEnumDescription(EPublicCatalogs.ABDA);

            var sbsCatalog = ORM_CMN_PRO_SubscribedCatalog.Query.Search(Connection, Transaction, new ORM_CMN_PRO_SubscribedCatalog.Query()
            {
                CatalogCodeITL = catalogITL,
                Tenant_RefID   = securityTicket.TenantID,
                IsDeleted      = false
            }).FirstOrDefault();

            if (sbsCatalog == null)
            {
                return(returnValue);
            }

            #endregion

            var searchCondition = Parameter.SearchCondition;
            if (!searchCondition.Contains("*"))
            {
                searchCondition = String.Format("*{0}*", searchCondition);
            }

            string query = new QueryBuilder <Product>()
                           .From(0)
                           .Size(10000)
                           .Query(q => q
                                  .Bool(b => b
                                        .Must(m => m
                                              .QueryString(qs => qs.Fields(
                                                               new string[] {
                SearchCondition.GetFiledName(ProductField.NAME), SearchCondition.GetFiledName(ProductField.CODE)
            })
                                                           .Query(SearchCondition.GetConditionForSearchText(Parameter.SearchCondition)))
                                              )
                                        )
                                  )
                           .Sort(s => s
                                 .Field(SearchCondition.GetFiledName(ProductField.NAME), PlainElastic.Net.SortDirection.asc))
                           .BuildBeautified();

            var ProductService = CatalogServiceFactory.GetProductService();


            ProductQueryRequest request = new ProductQueryRequest()
            {
                CatalogCode = catalogITL
            };


            SearchResult <Product> res = ProductService.QueryProducts(request, query);


            var retrievedProducts = res.Documents.ToList();
            var abdaProducts      = new List <L3ABDA_GAAfAS_1256>();
            foreach (var product in retrievedProducts)
            {
                abdaProducts.Add(new L3ABDA_GAAfAS_1256()
                {
                    ProductITL    = product.ProductITL,
                    ProductNumber = product.Code,
                    ProductName   = product.Name
                });
            }

            returnValue.Result = abdaProducts.ToArray();

            return(returnValue);

            #endregion UserCode
        }
Example #15
0
        protected static FR_L3ABDA_GAAfSC_1147 Execute(DbConnection Connection, DbTransaction Transaction, P_L3ABDA_GAAfSC_1147 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L3ABDA_GAAfSC_1147();
            returnValue.Result = new L3ABDA_GAAfSC_1147();

            #region Check ABDA Catalog Subscription

            string catalogITL = EnumUtils.GetEnumDescription(EPublicCatalogs.ABDA);

            var sbsCatalog = ORM_CMN_PRO_SubscribedCatalog.Query.Search(Connection, Transaction, new ORM_CMN_PRO_SubscribedCatalog.Query()
            {
                CatalogCodeITL = catalogITL,
                Tenant_RefID   = securityTicket.TenantID,
                IsDeleted      = false
            }).FirstOrDefault();

            if (sbsCatalog == null)
            {
                return(returnValue);
            }

            #endregion

            string query = new QueryBuilder <Product>()
                           .From(Parameter.FromArticle)
                           .Size(Parameter.NumberOfArticles)
                           .Query(q => q
                                  .Bool(b => b
                                        .Must(m => m
                                              .QueryString(qs => qs.Fields(new string[] { SearchCondition.GetFiledName(ProductField.NAME), SearchCondition.GetFiledName(ProductField.CODE) }).Query(SearchCondition.GetConditionForSearchText(Parameter.Conditions.PZNOrName)))
                                              .QueryString(qs => qs.Fields(SearchCondition.GetFiledName(ProductField.UNIT)).Query(SearchCondition.GetConditionForSearchText(Parameter.Conditions.Unit)))
                                              .QueryString(qs => qs.Fields(SearchCondition.GetFiledName(ProductField.DOSAGE_FORM)).Query(SearchCondition.GetConditionForSearchText(Parameter.Conditions.DosageForm)))
                                              .QueryString(qs => qs.Fields(SearchCondition.GetFiledName(ProductField.SUBSTANCE)).Query(SearchCondition.GetConditionForSearchText(Parameter.Conditions.ActiveComponent)))
                                              .QueryString(qs => qs.Fields(SearchCondition.GetFiledName(ProductField.PRODUCER)).Query(SearchCondition.GetConditionForSearchText(Parameter.Conditions.ProducerName)))
                                              .Prefix(p => p.Field(SearchCondition.GetFiledName(ProductField.NAME_TOKEN)).Prefix(Parameter.Conditions.ProductNameStartWith))
                                              )
                                        )
                                  )
                           .Sort(s => s
                                 .Field(SearchCondition.GetFiledName(Parameter.Order.field), (Parameter.Order.order == SortingOrder.ASC) ? PlainElastic.Net.SortDirection.asc : PlainElastic.Net.SortDirection.desc))
                           .BuildBeautified();


            var ProductService = CatalogServiceFactory.GetProductService();

            if ((bool)Parameter.Conditions.IsDefaultStock)
            {
                List <string> ITLs = new List <string>();
                ITLs = cls_Get_ITLS_for_Products_HaveFlag_IsProductPartOfDefaultStock.Invoke(Connection, Transaction, securityTicket).Result.Select(x => x.ProductITL).ToList();
                ProductDetailsRequest requestWithITLS = new ProductDetailsRequest {
                    CatalogCode = catalogITL, ProductIDs = ITLs
                };
                var resWithITLS = ProductService.GetProductDetails(requestWithITLS);
                returnValue.Result.Articles = resWithITLS.ProductDetails.Where(x => Parameter.Conditions.ProducerName == string.Empty || x.Producer.ToLower().Contains(Parameter.Conditions.ProducerName.ToLower()))
                                              .Where(x => (Parameter.Conditions.DosageForm == string.Empty) || (x.Healthcare.DosageForm != null && x.Healthcare.DosageForm.ToLower().Contains(Parameter.Conditions.DosageForm.ToLower())))
                                              .Where(x => Parameter.Conditions.PZNOrName == string.Empty || x.Name.ToLower().Contains(Parameter.Conditions.PZNOrName.ToLower()) || x.Code.ToLower().Contains(Parameter.Conditions.PZNOrName.ToLower()))
                                              .Where(x => Parameter.Conditions.Unit == string.Empty || x.Packaging.Unit.ToLower().Contains(Parameter.Conditions.Unit.ToLower()))
                                              .ToArray();
            }
            else
            {
                ProductQueryRequest request = new ProductQueryRequest()
                {
                    CatalogCode = catalogITL
                };
                var res = ProductService.QueryProducts(request, query);
                returnValue.Result.Articles = res.Documents.ToArray();
            }

            return(returnValue);

            #endregion UserCode
        }
Example #16
0
        private static List <L5PR_GPwCPbSCfT_1237> GetProductsWithoutSearchCriteria(DbConnection Connection, DbTransaction Transaction, P_L5PR_GCPfCAfT_1705 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket, List <L5PR_GPwCPbSCfT_1237> retValProducts, IProductService _service, ProductQueryRequest request)
        {
            var query = new QueryBuilder <Product>()
                        .From(Parameter.IncludedProductsCountFromLastCatalog)
                        .Size(Parameter.Size).BuildBeautified();

            var result = _service.QueryProducts <Product>(request, query);

            retValProducts = PopulateProductList(retValProducts, result, Parameter);

            if (Parameter.CatalogsToInclude != null && Parameter.CatalogsToInclude.Count() > 0)
            {
                var leftedCatalogs = Parameter.CatalogsToInclude.SkipWhile(x => x.CatalogITL != Parameter.LastIncludedCatalog.CatalogITL).ToList();
                if (retValProducts.Count < Parameter.Size && leftedCatalogs.Count > 1)
                {
                    var nextCatalog = leftedCatalogs[1];
                    P_L5PR_GCPfCAfT_1705 newParam = new P_L5PR_GCPfCAfT_1705();
                    newParam.From = 0;
                    newParam.Size = Parameter.Size - retValProducts.Count;
                    newParam.IncludedProductsCountFromLastCatalog = 0;
                    newParam.LastIncludedCatalog = nextCatalog;
                    newParam.CatalogsToInclude   = Parameter.CatalogsToInclude;
                    newParam.SearchCriteria      = Parameter.SearchCriteria;
                    newParam.LanguageID          = Parameter.LanguageID;

                    retValProducts.AddRange(cls_Get_Catalogs_Products_from_CatalogAPI_for_Tenant.Invoke(Connection, Transaction, newParam, securityTicket).Result.Products);
                }
            }

            return(retValProducts);
        }