Exemple #1
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_L6LG_GDfDLR_1634 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_L6LG_GDfDLR_1634 functionReturn = new FR_L6LG_GDfDLR_1634();

            try
            {
                if (cleanupConnection == true)
                {
                    Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                if (cleanupTransaction == true)
                {
                    Transaction = Connection.BeginTransaction();
                }

                functionReturn = Execute(Connection, Transaction, 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_Data_for_DemandList_Report", ex);
            }
            return(functionReturn);
        }
Exemple #2
0
        protected static FR_L6LG_GDfDLR_1634 Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L6LG_GDfDLR_1634();
            returnValue.Result = new L6LG_GDfDLR_1634();

            var languages = cls_Get_All_Languages_ForTenantID.Invoke(Connection, Transaction, new P_L2LN_GALFTID_1530()
            {
                Tenant_RefID = securityTicket.TenantID
            }, securityTicket).Result;


            var account = cls_Get_DisplayName_of_Account.Invoke(Connection, Transaction, securityTicket).Result;

            List <L6LG_GDfDLR_1634a> returnList           = new List <L6LG_GDfDLR_1634a>();
            var         produtDemandAndSupplyQuantityList = cls_Get_Product_Demand_and_Supply_Quantity.Invoke(Connection, Transaction, securityTicket).Result;
            List <Guid> productIdList = produtDemandAndSupplyQuantityList.Select(p => p.ProductID).Distinct().ToList();

            L3AR_GAfAL_0942[] articlesForArticleList = new L3AR_GAfAL_0942[0];
            if (productIdList != null && productIdList.Count > 0)
            {
                P_L3AR_GAfAL_0942 articlesForArticleListParameter = new P_L3AR_GAfAL_0942();
                articlesForArticleListParameter.ProductID_List = productIdList.ToArray();
                FR_L3AR_GAfAL_0942_Array articlesForArticleListResult = cls_Get_Articles_for_ArticleList.Invoke(Connection, Transaction, articlesForArticleListParameter, securityTicket);
                articlesForArticleList = articlesForArticleListResult.Result;
            }


            foreach (L6LG_GPDaSQ_1636 productDemandAndSupplyQuantity in produtDemandAndSupplyQuantityList)
            {
                L3AR_GAfAL_0942 article = articlesForArticleList.FirstOrDefault(a => a.CMN_PRO_ProductID == productDemandAndSupplyQuantity.ProductID);

                if (article == null)
                {
                    continue;
                }


                L6LG_GDfDLR_1634a product = new L6LG_GDfDLR_1634a();
                product.ProductID       = article.CMN_PRO_ProductID;
                product.DossageFormName = article.DossageFormName;
                product.ProducerName    = article.ProducerName;
                product.Product_Name    = new Dictionary <string, string>();

                foreach (L2LN_GALFTID_1530 lang in languages)
                {
                    string iso     = lang.ISO_639_1;
                    string content = "";
                    if (article.Product_Name != null && article.Product_Name.Contents != null)
                    {
                        DictEntry dicEntry = article.Product_Name.Contents.FirstOrDefault(c => c.LanguageID == lang.CMN_LanguageID);
                        if (dicEntry != null)
                        {
                            content = dicEntry.Content;
                        }
                    }
                    product.Product_Name.Add(iso, content);
                }

                product.Product_Number      = article.Product_Number;
                product.UnitAmount          = article.UnitAmount;
                product.UnitIsoCode         = article.UnitIsoCode;
                product.DemandQuantity      = productDemandAndSupplyQuantity.DemandQuantity;
                product.SupplyQuantity      = productDemandAndSupplyQuantity.SupplyQuantity;
                product.ToBeOrderedQuantity = productDemandAndSupplyQuantity.DemandQuantity - productDemandAndSupplyQuantity.SupplyQuantity;
                returnList.Add(product);
            }

            returnValue.Result.Products = returnList.ToArray();
            returnValue.Result.Account  = account;

            return(returnValue);

            #endregion UserCode
        }