protected static FR_L5PR_GCPfCAfT_1705 Execute(DbConnection Connection, DbTransaction Transaction, P_L5PR_GCPfCAfT_1705 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5PR_GCPfCAfT_1705(); //Put your code here L5PR_GCPfCAfT_1705 retVal = new L5PR_GCPfCAfT_1705(); List <L5PR_GPwCPbSCfT_1237> retValProducts = new List <L5PR_GPwCPbSCfT_1237>(); var _service = CatalogServiceFactory.GetProductService(); var request = new ProductQueryRequest(); request.CatalogCode = Parameter.LastIncludedCatalog.CatalogITL; if (String.IsNullOrEmpty(Parameter.SearchCriteria)) { retValProducts = GetProductsWithoutSearchCriteria(Connection, Transaction, Parameter, securityTicket, retValProducts, _service, request); } else { retValProducts = GetProductsWithSearchCriteria(Connection, Transaction, Parameter, securityTicket, retValProducts, _service, request); } retVal.Products = retValProducts.ToArray(); returnValue.Result = retVal; return(returnValue); #endregion UserCode }
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 }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5PR_SPfA_1023 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); var productParameters = Parameter.Products; returnValue = cls_Save_Product.Invoke(Connection, Transaction, productParameters, securityTicket); var productService = CatalogServiceFactory.GetProductService(); foreach (var vendorProduct in Parameter.VendorProducts) { Guid vendorProductID = vendorProduct.VendorProductID; if (!string.IsNullOrEmpty(vendorProduct.ProductITL)) { ProductDetailsRequest productDetailsRequest = new ProductDetailsRequest(); productDetailsRequest.CatalogCode = vendorProduct.CatalogITL; productDetailsRequest.ProductIDs = new List <string>(); productDetailsRequest.ProductIDs.Add(vendorProduct.ProductITL); List <Product> products = new List <Product>(); products.AddRange(productService.GetProductDetails <Product>(productDetailsRequest).ProductDetails); foreach (var product in products) { P_L5PR_IPfC_1648 parameter = new P_L5PR_IPfC_1648(); parameter.Product = new ProductsForImport(); parameter.Product.Code = product.Code; parameter.Product.Custom = product.Custom; parameter.Product.Description = product.Description; parameter.Product.LongName = product.LongName; parameter.Product.Name = product.Name; parameter.Product.ProductITL = product.ProductITL; parameter.Product.CatalogITL = vendorProduct.CatalogITL; parameter.Product.Variants = new List <Variant>(); foreach (var variant in product.Variants) { parameter.Product.Variants.Add(variant); } parameter.Product.Vat = product.Vat; vendorProductID = cls_Import_Product_from_Catalog.Invoke(Connection, Transaction, parameter, securityTicket).Result; vendorProduct.ProductRefID = vendorProductID; } } ORM_CMN_PRO_ASS_AssortmentProduct_VendorProduct vendorProductToSave = new ORM_CMN_PRO_ASS_AssortmentProduct_VendorProduct(); var vendorProductExists = ORM_CMN_PRO_ASS_AssortmentProduct_VendorProduct.Query.Exists(Connection, Transaction, new ORM_CMN_PRO_ASS_AssortmentProduct_VendorProduct.Query() { CMN_PRO_ASS_AssortmentProduct_VendorProductID = vendorProduct.VendorProductID }); if (vendorProductExists) { vendorProductToSave.Load(Connection, Transaction, vendorProduct.VendorProductID); } vendorProductToSave.CMN_PRO_ASS_AssortmentProduct_RefID = vendorProduct.AssortmentProductID; vendorProductToSave.CMN_PRO_Product_RefID = vendorProduct.ProductRefID; vendorProductToSave.IsDeleted = vendorProduct.IsDeleted; vendorProductToSave.Tenant_RefID = securityTicket.TenantID; vendorProductToSave.Save(Connection, Transaction); if (vendorProduct.IsDeleted == true) { P_L3VA_GAVVfAP_1926 parameterAssortmentVendorVariants = new P_L3VA_GAVVfAP_1926(); parameterAssortmentVendorVariants.ProductID = Parameter.Products.ProductID; var assortmentVendorProductVariants = cls_Get_Assortment_Vendor_Variants_for_AssortmentProductID.Invoke(Connection, Transaction, parameterAssortmentVendorVariants, securityTicket).Result; P_L3VA_GAVfP_1300 parameterVendorVariantToDelete = new P_L3VA_GAVfP_1300(); parameterVendorVariantToDelete.ProductID = vendorProductToSave.CMN_PRO_Product_RefID; var vendorProductVariantsToDelete = cls_Get_All_Variants_for_Product.Invoke(Connection, Transaction, parameterVendorVariantToDelete, securityTicket).Result; if (vendorProductVariantsToDelete != null) { foreach (var vendorProductVariantToDelete in vendorProductVariantsToDelete) { if (assortmentVendorProductVariants.ToList().Count(x => x.CMN_PRO_Product_Variant_RefID == vendorProductVariantToDelete.CMN_PRO_Product_VariantID) > 0) { var assortmentProductVariantsIDs = assortmentVendorProductVariants.Where(x => x.CMN_PRO_Product_Variant_RefID == vendorProductVariantToDelete.CMN_PRO_Product_VariantID).Select(x => x.CMN_PRO_ASS_AssortmentVariant_VendorVariantID).ToList(); foreach (var assortmentProductVariantsID in assortmentProductVariantsIDs) { ORM_CMN_PRO_ASS_AssortmentVariant_VendorVariant variantToDelete = new ORM_CMN_PRO_ASS_AssortmentVariant_VendorVariant(); variantToDelete.Load(Connection, Transaction, assortmentProductVariantsID); variantToDelete.IsDeleted = true; variantToDelete.IsDefaultVendorVariant = false; variantToDelete.Save(Connection, Transaction); } assortmentVendorProductVariants.ToList().RemoveAll(x => x.CMN_PRO_Product_Variant_RefID == vendorProductVariantToDelete.CMN_PRO_Product_VariantID); var assortmentVariantIDs = assortmentVendorProductVariants.Select(x => x.CMN_PRO_ASS_AssortmentVariantID).ToList(); foreach (var assortmentVariantID in assortmentVariantIDs.Distinct().ToList()) { var vendorVariantsToUpdate = ORM_CMN_PRO_ASS_AssortmentVariant_VendorVariant.Query.Search(Connection, Transaction, new ORM_CMN_PRO_ASS_AssortmentVariant_VendorVariant.Query() { CMN_PRO_ASS_AssortmentVariant_RefID = assortmentVariantID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).ToList(); var orderSequence = 1; foreach (var variantToUpdate in vendorVariantsToUpdate) { variantToUpdate.OrderSequence = orderSequence; if (orderSequence == 0 && vendorVariantsToUpdate.Count(x => x.IsDefaultVendorVariant) == 0) { variantToUpdate.IsDefaultVendorVariant = true; } variantToUpdate.Save(Connection, Transaction); orderSequence++; } } } } } } } return(returnValue); #endregion UserCode }
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 }
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 }
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 }