///<summary> /// Method Invocation of wrapper classes ///<summary> protected static FR_L3ABDA_GAAMTMfSC_1714 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L3ABDA_GAAMTMfSC_1714 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { bool cleanupConnection = Connection == null; bool cleanupTransaction = Transaction == null; FR_L3ABDA_GAAMTMfSC_1714 functionReturn = new FR_L3ABDA_GAAMTMfSC_1714(); 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_ABDA_ArticlesMainTableModel_for_SearchContitions", ex); } return(functionReturn); }
protected static FR_L3ABDA_GAAMTMfSC_1714 Execute(DbConnection Connection, DbTransaction Transaction, P_L3ABDA_GAAMTMfSC_1714 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L3ABDA_GAAMTMfSC_1714(); returnValue.Result = new L3ABDA_GAAMTMfSC_1714(); #region GetAbdaArticles var abdaParam = new P_L3ABDA_GAAfSC_1147() { Conditions = Parameter.Conditions, Order = Parameter.Order, FromArticle = Parameter.FromArticle, NumberOfArticles = Parameter.NumberOfArticles, }; var abdaArticles = cls_Get_ABDA_Articles_for_SearchConditions.Invoke(Connection, Transaction, abdaParam, securityTicket).Result.Articles; #endregion #region GetStandartPrices L3PR_GSPfPITLL_1258 standardPrices = new L3PR_GSPfPITLL_1258(); if (abdaArticles.Count() != 0) { var spParam = new P_L3PR_GSPfPITLL_1258() { ProductITLList = abdaArticles.Select(i => i.ProductITL).ToArray() }; standardPrices = cls_Get_StandardPrices_for_ProductITLList.Invoke(Connection, Transaction, spParam, securityTicket).Result; } #endregion #region Get All Articles From OmniDB var omniDBArticles = ORM_CMN_PRO_Product.Query.Search(Connection, Transaction, new ORM_CMN_PRO_Product.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false }); #endregion #region Prepare result List <ArticleMainTableModel> abdaResult = new List <ArticleMainTableModel>(); foreach (var article in abdaArticles) { var standardPrice = standardPrices.Prices.SingleOrDefault(i => i.ProductITL == article.ProductITL); var omniDBArticle = omniDBArticles.SingleOrDefault(i => i.ProductITL == article.ProductITL); var product = new ArticleMainTableModel(); product.ProductID = (omniDBArticle != null) ? omniDBArticle.CMN_PRO_ProductID : Guid.Empty; product.ProductITL = article.ProductITL; product.ProductName = article.Name; product.ProductNumber = article.Code; product.DosageFormName = article.Healthcare.DosageForm; product.Unit = article.Packaging.Unit; product.UnitAmount = article.Packaging.Amount; product.ABDAPrice = article.GetDefaultPrice().Value; product.SalesPrice = standardPrice == null ? 0 : standardPrice.SalesPrice; product.ProducerName = article.Producer; product.ActiveComponents = new List <ActiveComponents>(); foreach (var ac in article.Healthcare.Components) { foreach (var sub in ac.Substances) { product.ActiveComponents.Add( new ActiveComponents { SubstanceName = sub.Name, IsActive = sub.Active }); } } abdaResult.Add(product); } #endregion returnValue.Result.Articles = abdaResult.ToArray(); return(returnValue); #endregion UserCode }