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

            FR_L5LR_CLRC_1517 functionReturn = new FR_L5LR_CLRC_1517();

            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 ex;
            }
            return(functionReturn);
        }
Example #2
0
        protected static FR_L5LR_CLRC_1517 Execute(DbConnection Connection, DbTransaction Transaction, P_L5LR_CLRC_1517 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_L5LR_CLRC_1517();
            returnValue.Result = new L5LR_CLRC_1517();

            int retVal = 0;

            //Put your code here
            ORM_CMN_BPT_EMP_Employee_LeaveRequest.Query leaveRequestQuery = new ORM_CMN_BPT_EMP_Employee_LeaveRequest.Query();
            leaveRequestQuery.RequestedFor_Employee_RefID = Parameter.EmployeeID;
            leaveRequestQuery.Tenant_RefID = securityTicket.TenantID;
            leaveRequestQuery.IsDeleted    = false;
            List <ORM_CMN_BPT_EMP_Employee_LeaveRequest> leaveRequests = ORM_CMN_BPT_EMP_Employee_LeaveRequest.Query.Search(Connection, Transaction, leaveRequestQuery);

            FR_Base evetResult;
            FR_Base eventApprovalResult;
            foreach (var leaveRequest in leaveRequests)
            {
                ORM_CMN_CAL_Event Event = new ORM_CMN_CAL_Event();
                evetResult = Event.Load(Connection, Transaction, leaveRequest.CMN_CAL_Event_RefID);

                if (evetResult.Status == FR_Status.Success && Event.CMN_CAL_EventID != Guid.Empty && Event.StartTime.Ticks > Parameter.StartDate.Ticks)
                {
                    ORM_CMN_CAL_Event_Approval eventApproval = new ORM_CMN_CAL_Event_Approval();
                    eventApprovalResult = eventApproval.Load(Connection, Transaction, leaveRequest.CMN_CAL_Event_Approval_RefID);

                    if (eventApprovalResult.Status == FR_Status.Success && eventApproval.CMN_CAL_Event_ApprovalID != Guid.Empty &&
                        !eventApproval.IsApprovalProcessCanceledByUser && !eventApproval.IsApprovalProcessDenied)
                    {
                        retVal++;
                    }
                }
            }

            returnValue.Result.LeaveCount = retVal;

            return(returnValue);

            #endregion UserCode
        }