Ejemplo n.º 1
0
        protected static FR_L3AD_GaSAfCC_1508_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L3AD_GaSAfCC_1508 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L3AD_GaSAfCC_1508_Array();
            returnValue.Result = new L3AD_GaSAfCC_1508[0];

            var offices2CostCenter = ORM_CMN_STR_Office_2_CostCenter.Query.Search(Connection, Transaction, new ORM_CMN_STR_Office_2_CostCenter.Query()
            {
                Tenant_RefID     = securityTicket.TenantID,
                IsDeleted        = false,
                CostCenter_RefID = Parameter.CostCenterID
            }).ToArray();

            List <ORM_CMN_STR_Office> officesToSelect = new List <ORM_CMN_STR_Office>();

            if (offices2CostCenter != null && offices2CostCenter.Length > 0)
            {
                var offices = ORM_CMN_STR_Office.Query.Search(Connection, Transaction, new ORM_CMN_STR_Office.Query()
                {
                    Tenant_RefID = securityTicket.TenantID,
                    IsDeleted    = false
                });

                foreach (var office2CostCenter in offices2CostCenter)
                {
                    var office = offices.FirstOrDefault(o => o.CMN_STR_OfficeID == office2CostCenter.Office_RefID);
                    if (office != null)
                    {
                        if (!officesToSelect.Exists(o => o.CMN_STR_OfficeID == office.CMN_STR_OfficeID))
                        {
                            officesToSelect.Add(office);
                            FindAllChildren(officesToSelect, offices, office.CMN_STR_OfficeID);
                        }
                    }
                }
            }


            List <L3AD_GaSAfCC_1508> shippmentAddresses = new List <L3AD_GaSAfCC_1508>();
            int level = 0;
            foreach (var officeToSelect in officesToSelect)
            {
                var officeAddresses = ORM_CMN_STR_Office_Address.Query.Search(Connection, Transaction, new ORM_CMN_STR_Office_Address.Query()
                {
                    IsDeleted         = false,
                    Tenant_RefID      = securityTicket.TenantID,
                    IsShippingAddress = true,
                    Office_RefID      = officeToSelect.CMN_STR_OfficeID
                });

                foreach (var officeAddress in officeAddresses)
                {
                    var address = ORM_CMN_Address.Query.Search(Connection, Transaction, new ORM_CMN_Address.Query()
                    {
                        Tenant_RefID  = securityTicket.TenantID,
                        IsDeleted     = false,
                        CMN_AddressID = officeAddress.CMN_Address_RefID
                    }).FirstOrDefault();


                    if (address != null)
                    {
                        var shippmentAddress = new L3AD_GaSAfCC_1508();
                        shippmentAddress.OfficeName  = officeToSelect.Office_InternalName;
                        shippmentAddress.IsDefault   = officeAddress.IsDefault;
                        shippmentAddress.OfficeLevel = level;
                        shippmentAddress.Address     = address;
                        shippmentAddresses.Add(shippmentAddress);
                    }
                }

                level++;
            }

            returnValue.Result = shippmentAddresses.ToArray();
            return(returnValue);

            #endregion UserCode
        }
Ejemplo n.º 2
0
 ///<summary>
 /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured
 ///<summary>
 public static FR_L3AD_GaSAfCC_1508_Array Invoke(DbConnection Connection, DbTransaction Transaction, P_L3AD_GaSAfCC_1508 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
Ejemplo n.º 3
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_L3AD_GaSAfCC_1508_Array Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L3AD_GaSAfCC_1508 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_L3AD_GaSAfCC_1508_Array functionReturn = new FR_L3AD_GaSAfCC_1508_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_All_ShippingAddresses_For_CostCenter", ex);
            }
            return(functionReturn);
        }
Ejemplo n.º 4
0
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_L3AD_GaSAfCC_1508_Array Invoke(string ConnectionString, P_L3AD_GaSAfCC_1508 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }