コード例 #1
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5OF_SOfA_1652 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_Guid();
            //Put your code here

            var userAccount = new ORM_USR_Account();
            userAccount.Load(Connection, Transaction, Parameter.AccountID);

            //Get business participant for current user account
            var businessParticipantQuery = new ORM_CMN_BPT_BusinessParticipant.Query();
            businessParticipantQuery.CMN_BPT_BusinessParticipantID = userAccount.BusinessParticipant_RefID;
            businessParticipantQuery.Tenant_RefID = securityTicket.TenantID;
            var foundBusinessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, businessParticipantQuery).Single();

            //Get employee using business participant
            var employeeQuery = new ORM_CMN_BPT_EMP_Employee.Query();
            employeeQuery.BusinessParticipant_RefID = foundBusinessParticipant.CMN_BPT_BusinessParticipantID;
            employeeQuery.Tenant_RefID = securityTicket.TenantID;
            var foundEmployee = ORM_CMN_BPT_EMP_Employee.Query.Search(Connection, Transaction, employeeQuery).Single();

            //clear all assignment tables (connection with offices) for found employee before new save
            var assignmentQuery = new ORM_CMN_BPT_EMP_Employee_2_Office.Query();
            if (foundEmployee != null)
            {
                assignmentQuery.CMN_BPT_EMP_Employee_RefID = foundEmployee.CMN_BPT_EMP_EmployeeID;
                assignmentQuery.Tenant_RefID = securityTicket.TenantID;
            }
            else
            {
                return(new FR_Guid("Employee not created", FR_Status.Error_Internal));
            }

            var foundAssignments = ORM_CMN_BPT_EMP_Employee_2_Office.Query.Search(Connection, Transaction, assignmentQuery);

            foreach (var assignment in foundAssignments)
            {
                assignment.IsDeleted = true;
                assignment.Save(Connection, Transaction);
            }

            //save offices
            foreach (var office in Parameter.Offices)
            {
                P_L5OF_SSOfA_1652 officeSaveParam = new P_L5OF_SSOfA_1652();
                officeSaveParam.OfficeID   = office;
                officeSaveParam.EmployeeID = foundEmployee.CMN_BPT_EMP_EmployeeID;
                cls_Save_SingleOffice_for_Account.Invoke(Connection, Transaction, officeSaveParam, securityTicket);
            }

            return(returnValue);

            #endregion UserCode
        }
コード例 #2
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Guid Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5OF_SSOfA_1652 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_Guid functionReturn = new FR_Guid();

            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_Save_SingleOffice_for_Account", ex);
            }
            return(functionReturn);
        }
コード例 #3
0
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_Guid Invoke(string ConnectionString, P_L5OF_SSOfA_1652 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }
コード例 #4
0
 ///<summary>
 /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured
 ///<summary>
 public static FR_Guid Invoke(DbConnection Connection, DbTransaction Transaction, P_L5OF_SSOfA_1652 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
コード例 #5
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5OF_SSOfA_1652 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();
            //Put your code here

            var officeQuery = new ORM_CMN_STR_Office.Query();
            officeQuery.CMN_STR_OfficeID = Parameter.OfficeID;
            officeQuery.Tenant_RefID     = securityTicket.TenantID;
            var foundOffice = ORM_CMN_STR_Office.Query.Search(Connection, Transaction, officeQuery).Single();

            if (foundOffice != null)
            {
                var assignmentQuery = new ORM_CMN_BPT_EMP_Employee_2_Office.Query();
                assignmentQuery.CMN_BPT_EMP_Employee_RefID = Parameter.EmployeeID;
                assignmentQuery.CMN_STR_Office_RefID       = foundOffice.CMN_STR_OfficeID;
                assignmentQuery.Tenant_RefID = securityTicket.TenantID;
                var foundAssignment = ORM_CMN_BPT_EMP_Employee_2_Office.Query.Search(Connection, Transaction, assignmentQuery).SingleOrDefault();

                if (foundAssignment == null)
                {
                    foundAssignment = new ORM_CMN_BPT_EMP_Employee_2_Office();
                }

                foundAssignment.CMN_STR_Office_RefID       = foundOffice.CMN_STR_OfficeID;
                foundAssignment.CMN_BPT_EMP_Employee_RefID = Parameter.EmployeeID;
                foundAssignment.Tenant_RefID = securityTicket.TenantID;
                foundAssignment.IsDeleted    = false;
                foundAssignment.Save(Connection, Transaction);
            }

            return(returnValue);

            #endregion UserCode
        }