protected static FR_L3PR_GAwSPfT_1535_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L3PR_GAwSPfT_1535 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L3PR_GAwSPfT_1535_Array(); //Put your code here List <Guid> productList = new List <Guid>(); var paramArticles = new CL3_Articles.Atomic.Retrieval.P_L3AR_GAfT_0942 { ActiveComponent = Parameter.ActiveComponent, ActiveComponentStartWith = Parameter.ActiveComponentStartWith, CustomArticlesGroupGlobalPropertyID = Parameter.CustomArticlesGroupGlobalPropertyID, DosageFormQuery = Parameter.DosageFormQuery, GeneralQuery = Parameter.GeneralQuery, IsAvailableForOrdering = Parameter.IsAvailableForOrdering, LanguageID = Parameter.LanguageID, ProducerName = Parameter.ProducerName, ProductID = Parameter.ProductID, ProductNameStartWith = Parameter.ProductNameStartWith, PZNQuery = Parameter.PZNQuery, UnitQuery = Parameter.UnitQuery, IsDefaultStock = Parameter.IsPartOfDefaultStock }; List <L3AR_GAfT_0942> articles = cls_Get_Articles_for_Tenant.Invoke(Connection, Transaction, paramArticles, securityTicket).Result.ToList(); foreach (var item in articles) { productList.Add(item.CMN_PRO_ProductID); } List <L3PR_GAwSPfT_1535> results = new List <L3PR_GAwSPfT_1535>(); if (productList.Count > 0) { var paramPrices = new CL3_Price.Complex.Retrieval.P_L3PR_GSPfPIL_1645 { ProductIDList = productList.ToArray() }; var prices = CL3_Price.Complex.Retrieval.cls_Get_StandardPrices_for_ProductIDList.Invoke(Connection, Transaction, paramPrices, securityTicket).Result.ToList(); foreach (var articl in articles) { var articlesWithPrices = new L3PR_GAwSPfT_1535(); articlesWithPrices.Article = articl; articlesWithPrices.Prices = prices.Where(x => x.ProductID == articl.CMN_PRO_ProductID).Single(); results.Add(articlesWithPrices); } } returnValue.Result = results.ToArray(); return(returnValue); #endregion UserCode }
protected static FR_L5AR_GWSAfAG_0908_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L5AR_GWSAfAG_0908 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5AR_GWSAfAG_0908_Array(); var paramArticles = new CL3_Articles.Atomic.Retrieval.P_L3AR_GAfT_0942 { ActiveComponent = Parameter.ActiveComponent, ActiveComponentStartWith = Parameter.ActiveComponentStartWith, CustomArticlesGroupGlobalPropertyID = Parameter.ArticlesGroupGlobalPropertyID, DosageFormQuery = Parameter.DosageFormQuery, GeneralQuery = Parameter.GeneralQuery, IsAvailableForOrdering = true, LanguageID = Parameter.LanguageID, ProducerName = Parameter.ProducerName, ProductNameStartWith = Parameter.ProductNameStartWith, PZNQuery = Parameter.PZNQuery, UnitQuery = Parameter.UnitQuery, }; List <L3AR_GAfT_0942> articles = cls_Get_Articles_for_Tenant.Invoke(Connection, Transaction, paramArticles, securityTicket).Result.ToList(); #region Get Prices var subscribedCatalogID = articles.Select(i => i.IfImportedFromExternalCatalog_CatalogSubscription_RefID).Distinct().SingleOrDefault(); var subscribedCatalog = new ORM_CMN_PRO_SubscribedCatalog(); subscribedCatalog.Load(Connection, Transaction, subscribedCatalogID); var param = new P_L2PR_GPVfSC_1424() { SubscribedCatalogITL = subscribedCatalog.CatalogCodeITL }; var prices = cls_Get_PriceValues_for_SubscribedCatalogITL.Invoke(Connection, Transaction, param, securityTicket).Result; #endregion List <L5AR_GWSAfAG_0908> results = new List <L5AR_GWSAfAG_0908>(); foreach (var article in articles) { var articlesWithPrices = new L5AR_GWSAfAG_0908(); articlesWithPrices.Article = article; articlesWithPrices.Price = prices.Where(x => x.CMN_PRO_Product_RefID == article.CMN_PRO_ProductID).Select(j => j.PriceAmount).SingleOrDefault(); results.Add(articlesWithPrices); } returnValue.Result = results.ToArray(); return(returnValue); #endregion UserCode }
protected static FR_L3AR_GAfT_0942_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L3AR_GAfT_0942 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { var returnStatus = new FR_L3AR_GAfT_0942_Array(); DbCommand command = Connection.CreateCommand(); command.Connection = Connection; command.Transaction = Transaction; var commandLocation = "CL3_Articles.Atomic.Retrieval.SQL.cls_Get_Articles_for_Tenant.sql"; command.CommandText = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(commandLocation)).ReadToEnd(); CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ticket", securityTicket); command.CommandTimeout = QueryTimeout; CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "LanguageID", Parameter.LanguageID); CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ProductNameStartWith", Parameter.ProductNameStartWith); CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ProducerName", Parameter.ProducerName); CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "GeneralQuery", Parameter.GeneralQuery); CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "DosageFormQuery", Parameter.DosageFormQuery); CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "UnitQuery", Parameter.UnitQuery); CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "PZNQuery", Parameter.PZNQuery); CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CustomArticlesGroupGlobalPropertyID", Parameter.CustomArticlesGroupGlobalPropertyID); CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ActiveComponent", Parameter.ActiveComponent); CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ActiveComponentStartWith", Parameter.ActiveComponentStartWith); CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsAvailableForOrdering", Parameter.IsAvailableForOrdering); CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ProductID", Parameter.ProductID); CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDefaultStock", Parameter.IsDefaultStock); List <L3AR_GAfT_0942_raw> results = new List <L3AR_GAfT_0942_raw>(); var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction); var reader = new CSV2Core_MySQL.Support.DBSQLReader(command.ExecuteReader()); try { reader.SetOrdinals(new string[] { "ProductName", "Product_Number", "ProductGroup", "CMN_PRO_ProductID", "PackageInfo_RefID", "ProductDistributionStatus", "ProductType_Name_DictID", "Product_Description_DictID", "Abbreviation_DictID", "Label_DictID", "IsPlaceholderArticle", "ProductITL", "UnitAmount", "UnitAmount_DisplayLabel", "UnitIsoCode", "DossageFormName", "ProducerName", "IfImportedFromExternalCatalog_CatalogSubscription_RefID", "IsProductPartOfDefaultStock", "HEC_PRO_ComponentID", "Component_Name_DictID", "Component_SimpleName", "IsActiveComponent", "HEC_SUB_SubstanceID", "SubstanceName", "ACC_TAX_TaxeID", "EconomicRegion_RefID", "TaxRate", "TaxName_DictID" }); while (reader.Read()) { L3AR_GAfT_0942_raw resultItem = new L3AR_GAfT_0942_raw(); //0:Parameter ProductName of type String resultItem.ProductName = reader.GetString(0); //1:Parameter Product_Number of type String resultItem.Product_Number = reader.GetString(1); //2:Parameter ProductGroup of type String resultItem.ProductGroup = reader.GetString(2); //3:Parameter CMN_PRO_ProductID of type Guid resultItem.CMN_PRO_ProductID = reader.GetGuid(3); //4:Parameter PackageInfo_RefID of type Guid resultItem.PackageInfo_RefID = reader.GetGuid(4); //5:Parameter ProductDistributionStatus of type int resultItem.ProductDistributionStatus = reader.GetInteger(5); //6:Parameter ProductType_Name of type Dict resultItem.ProductType_Name = reader.GetDictionary(6); resultItem.ProductType_Name.SourceTable = "cmn_pro_product_types"; loader.Append(resultItem.ProductType_Name); //7:Parameter Product_Description of type Dict resultItem.Product_Description = reader.GetDictionary(7); resultItem.Product_Description.SourceTable = "cmn_pro_products"; loader.Append(resultItem.Product_Description); //8:Parameter Abbreviation of type Dict resultItem.Abbreviation = reader.GetDictionary(8); resultItem.Abbreviation.SourceTable = "cmn_units"; loader.Append(resultItem.Abbreviation); //9:Parameter Label of type Dict resultItem.Label = reader.GetDictionary(9); resultItem.Label.SourceTable = "cmn_units"; loader.Append(resultItem.Label); //10:Parameter IsPlaceholderArticle of type bool resultItem.IsPlaceholderArticle = reader.GetBoolean(10); //11:Parameter ProductITL of type String resultItem.ProductITL = reader.GetString(11); //12:Parameter UnitAmount of type double resultItem.UnitAmount = reader.GetDouble(12); //13:Parameter UnitAmount_DisplayLabel of type String resultItem.UnitAmount_DisplayLabel = reader.GetString(13); //14:Parameter UnitIsoCode of type String resultItem.UnitIsoCode = reader.GetString(14); //15:Parameter DossageFormName of type string resultItem.DossageFormName = reader.GetString(15); //16:Parameter ProducerName of type string resultItem.ProducerName = reader.GetString(16); //17:Parameter IfImportedFromExternalCatalog_CatalogSubscription_RefID of type Guid resultItem.IfImportedFromExternalCatalog_CatalogSubscription_RefID = reader.GetGuid(17); //18:Parameter IsProductPartOfDefaultStock of type bool resultItem.IsProductPartOfDefaultStock = reader.GetBoolean(18); //19:Parameter HEC_PRO_ComponentID of type Guid resultItem.HEC_PRO_ComponentID = reader.GetGuid(19); //20:Parameter Component_Name of type Dict resultItem.Component_Name = reader.GetDictionary(20); resultItem.Component_Name.SourceTable = "hec_pro_components"; loader.Append(resultItem.Component_Name); //21:Parameter Component_SimpleName of type String resultItem.Component_SimpleName = reader.GetString(21); //22:Parameter IsActiveComponent of type bool resultItem.IsActiveComponent = reader.GetBoolean(22); //23:Parameter HEC_SUB_SubstanceID of type Guid resultItem.HEC_SUB_SubstanceID = reader.GetGuid(23); //24:Parameter SubstanceName of type String resultItem.SubstanceName = reader.GetString(24); //25:Parameter ACC_TAX_TaxeID of type Guid resultItem.ACC_TAX_TaxeID = reader.GetGuid(25); //26:Parameter EconomicRegion_RefID of type Guid resultItem.EconomicRegion_RefID = reader.GetGuid(26); //27:Parameter TaxRate of type double resultItem.TaxRate = reader.GetDouble(27); //28:Parameter TaxName_DictID of type Dict resultItem.TaxName_DictID = reader.GetDictionary(28); resultItem.TaxName_DictID.SourceTable = "acc_tax_taxes"; loader.Append(resultItem.TaxName_DictID); results.Add(resultItem); } } catch (Exception ex) { reader.Close(); throw new Exception("Exception occured durng data retrieval in method cls_Get_Articles_for_Tenant", ex); } reader.Close(); //Load all the dictionaries from the datatables loader.Load(); returnStatus.Result = L3AR_GAfT_0942_raw.Convert(results).ToArray(); return(returnStatus); }
///<summary> /// Method Invocation of wrapper classes ///<summary> protected static FR_L3AR_GAfT_0942_Array Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L3AR_GAfT_0942 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { bool cleanupConnection = Connection == null; bool cleanupTransaction = Transaction == null; FR_L3AR_GAfT_0942_Array functionReturn = new FR_L3AR_GAfT_0942_Array(); try { if (cleanupConnection == true) { Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString); Connection.Open(); } if (cleanupTransaction == true) { Transaction = Connection.BeginTransaction(); } functionReturn = Execute(Connection, Transaction, Parameter, securityTicket); #region Cleanup Connection/Transaction //Commit the transaction if (cleanupTransaction == true) { Transaction.Commit(); } //Close the connection if (cleanupConnection == true) { Connection.Close(); } #endregion } catch (Exception ex) { try { if (cleanupTransaction == true && Transaction != null) { Transaction.Rollback(); } } catch { } try { if (cleanupConnection == true && Connection != null) { Connection.Close(); } } catch { } throw new Exception("Exception occured in method cls_Get_Articles_for_Tenant", ex); } return(functionReturn); }
///<summary> /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured ///<summary> public static FR_L3AR_GAfT_0942_Array Invoke(DbConnection Connection, DbTransaction Transaction, P_L3AR_GAfT_0942 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(Connection, Transaction, null, Parameter, securityTicket)); }
///<summary> /// Opens the connection/transaction for the given connectionString, and closes them when complete ///<summary> public static FR_L3AR_GAfT_0942_Array Invoke(string ConnectionString, P_L3AR_GAfT_0942 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(null, null, ConnectionString, Parameter, securityTicket)); }