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

            FR_L2CN_GACfT_1122_Array functionReturn = new FR_L2CN_GACfT_1122_Array();

            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 ex;
            }
            return(functionReturn);
        }
Esempio n. 2
0
        protected static FR_L2CN_GACfT_1122_Array Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            var returnStatus = new FR_L2CN_GACfT_1122_Array();

            DbCommand command = Connection.CreateCommand();

            command.Connection  = Connection;
            command.Transaction = Transaction;
            var commandLocation = "CL2_Country.Atomic.Retrieval.SQL.cls_Get_AllCountries_for_TenantID.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;
            List <L2CN_GACfT_1122> results = new List <L2CN_GACfT_1122>();
            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[] { "CMN_CountryID", "Default_Language_RefID", "Default_Currency_RefID", "Country_Name_DictID", "Country_ISOCode_Alpha2", "Country_ISOCode_Alpha3", "Country_ISOCode_Numeric" });
                while (reader.Read())
                {
                    L2CN_GACfT_1122 resultItem = new L2CN_GACfT_1122();
                    //0:Parameter CMN_CountryID of type Guid
                    resultItem.CMN_CountryID = reader.GetGuid(0);
                    //1:Parameter Default_Language_RefID of type Guid
                    resultItem.Default_Language_RefID = reader.GetGuid(1);
                    //2:Parameter Default_Currency_RefID of type Guid
                    resultItem.Default_Currency_RefID = reader.GetGuid(2);
                    //3:Parameter Country_Name of type Dict
                    resultItem.Country_Name             = reader.GetDictionary(3);
                    resultItem.Country_Name.SourceTable = "cmn_countries";
                    loader.Append(resultItem.Country_Name);
                    //4:Parameter Country_ISOCode_Alpha2 of type String
                    resultItem.Country_ISOCode_Alpha2 = reader.GetString(4);
                    //5:Parameter Country_ISOCode_Alpha3 of type String
                    resultItem.Country_ISOCode_Alpha3 = reader.GetString(5);
                    //6:Parameter Country_ISOCode_Numeric of type int
                    resultItem.Country_ISOCode_Numeric = reader.GetInteger(6);

                    results.Add(resultItem);
                }
            }
            catch (Exception ex)
            {
                reader.Close();
                throw ex;
            }
            reader.Close();
            //Load all the dictionaries from the datatables
            loader.Load();

            returnStatus.Result = results.ToArray();
            return(returnStatus);
        }