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

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

            DbCommand command = Connection.CreateCommand();

            command.Connection  = Connection;
            command.Transaction = Transaction;
            var commandLocation = "CL2_CostCenter.Atomic.Retrieval.SQL.cls_Get_CostCenters_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 <L2CC_GCCfT_1349> results = new List <L2CC_GCCfT_1349>();
            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_STR_CostCenterID", "InternalID", "CostCenterName_DictID", "Description_DictID", "IsDeleted", "CostCenterType_RefID", "ResponsiblePerson_RefID", "Currency_RefID", "CostCenter_Parent_RefID", "R_CostCenter_HasChildren", "OpenForBooking", "FirstName", "LastName", "CostCenterType_Name_DictID", "CurrencyName_DictID", "Office_RefID" });
                while (reader.Read())
                {
                    L2CC_GCCfT_1349 resultItem = new L2CC_GCCfT_1349();
                    //0:Parameter CMN_STR_CostCenterID of type Guid
                    resultItem.CMN_STR_CostCenterID = reader.GetGuid(0);
                    //1:Parameter InternalID of type String
                    resultItem.InternalID = reader.GetString(1);
                    //2:Parameter CostCenterName of type Dict
                    resultItem.CostCenterName             = reader.GetDictionary(2);
                    resultItem.CostCenterName.SourceTable = "cmn_str_costcenters";
                    loader.Append(resultItem.CostCenterName);
                    //3:Parameter Description of type Dict
                    resultItem.Description             = reader.GetDictionary(3);
                    resultItem.Description.SourceTable = "cmn_str_costcenters";
                    loader.Append(resultItem.Description);
                    //4:Parameter IsDeleted of type bool
                    resultItem.IsDeleted = reader.GetBoolean(4);
                    //5:Parameter CostCenterType_RefID of type Guid
                    resultItem.CostCenterType_RefID = reader.GetGuid(5);
                    //6:Parameter ResponsiblePerson_RefID of type Guid
                    resultItem.ResponsiblePerson_RefID = reader.GetGuid(6);
                    //7:Parameter Currency_RefID of type Guid
                    resultItem.Currency_RefID = reader.GetGuid(7);
                    //8:Parameter CostCenter_Parent_RefID of type Guid
                    resultItem.CostCenter_Parent_RefID = reader.GetGuid(8);
                    //9:Parameter R_CostCenter_HasChildren of type bool
                    resultItem.R_CostCenter_HasChildren = reader.GetBoolean(9);
                    //10:Parameter OpenForBooking of type bool
                    resultItem.OpenForBooking = reader.GetBoolean(10);
                    //11:Parameter FirstName of type String
                    resultItem.FirstName = reader.GetString(11);
                    //12:Parameter LastName of type String
                    resultItem.LastName = reader.GetString(12);
                    //13:Parameter CostCenterType_Name of type Dict
                    resultItem.CostCenterType_Name             = reader.GetDictionary(13);
                    resultItem.CostCenterType_Name.SourceTable = "cmn_str_costcenter_types";
                    loader.Append(resultItem.CostCenterType_Name);
                    //14:Parameter CurrencyName of type Dict
                    resultItem.CurrencyName             = reader.GetDictionary(14);
                    resultItem.CurrencyName.SourceTable = "cmn_currencies";
                    loader.Append(resultItem.CurrencyName);
                    //15:Parameter Office_RefID of type Guid
                    resultItem.Office_RefID = reader.GetGuid(15);

                    results.Add(resultItem);
                }
            }
            catch (Exception ex)
            {
                reader.Close();
                throw new Exception("Exception occured durng data retrieval in method cls_Get_CostCenters_for_TenantID", ex);
            }
            reader.Close();
            //Load all the dictionaries from the datatables
            loader.Load();

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