protected static FR_L6LR_LR_EV_D_1503 Execute(DbConnection Connection, DbTransaction Transaction, P_L6LR_LR_EV_D_1503 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L6LR_LR_EV_D_1503();
            int TotalUnapprovedLeaveCount    = 0;
            L5LR_GLRFSP_1532[] LeaveRequests = null;
            L5LR_EV_TSD_1047[] Events        = null;

            #region retrive employee list for leave request
            //get employee details
            var loggedInEmployeeDetails = cls_Get_Employee_For_LoggedAccount.Invoke(Connection, Transaction, securityTicket).Result;
            P_L5EM_GEFTAE_1517 p_employeesForTennantAndManager = new P_L5EM_GEFTAE_1517()
            {
                EmployeeID = loggedInEmployeeDetails.CMN_BPT_EMP_EmployeeID
            };
            //use employee details to retrive a list of employees whose leave requests you need
            var employeesForTenantAndManager = cls_Get_Employees_For_Tenant_And_ManagerEmployeeID.Invoke(Connection, Transaction, p_employeesForTennantAndManager, securityTicket).Result;
            //employed and non resigned people
            //employeesForTenantAndManager.Employees = employeesForTenantAndManager.Employees.Where(e => e.Work_StartDate.Ticks <= Parameter.EndDate.Ticks && !(e.Work_EndDate.Ticks <= Parameter.StartDate.Ticks)).ToArray();

            #endregion

            #region get leave requests
            P_L5LR_GLRFSP_1532 p_leaves_for_selected_person = new P_L5LR_GLRFSP_1532()
            {
                EmployeeIDList = employeesForTenantAndManager.Employees.Select(e => e.CMN_BPT_EMP_EmployeeID).ToArray()
            };
            L5LR_GLRFSP_1532[] AllLeaveRequests = cls_Get_LeaveRequests_For_SelectedPersons.Invoke(Connection, Transaction, p_leaves_for_selected_person, securityTicket).Result;
            TotalUnapprovedLeaveCount = AllLeaveRequests.Count(lr => lr.IsApproved == false);

            //add to rv only those that fit the timespan
            LeaveRequests = AllLeaveRequests.Where(a =>
                                                   ((a.StartTime >= Parameter.StartDate && a.EndTime <= Parameter.EndDate) ||
                                                    (a.StartTime <= Parameter.StartDate && a.EndTime >= Parameter.StartDate) ||
                                                    (a.StartTime <= Parameter.EndDate && a.EndTime >= Parameter.EndDate) ||
                                                    (a.StartTime <= Parameter.StartDate && a.EndTime >= Parameter.EndDate)) && !a.IsDeactivated).ToArray();
            #endregion

            #region  get events
            P_L5LR_EV_TSD_1047 param = new P_L5LR_EV_TSD_1047
            {
                EndDate   = Parameter.EndDate,
                StartDate = Parameter.StartDate
            };
            Events = cls_Get_Events_for_Timespan_Data.Invoke(Connection, Transaction, param, securityTicket).Result;
            #endregion
            returnValue.Result                           = new L6LR_LR_EV_D_1503();
            returnValue.Result.Events                    = Events;
            returnValue.Result.LeaveRequests             = LeaveRequests;
            returnValue.Result.TotalUnapprovedLeaveCount = TotalUnapprovedLeaveCount;
            return(returnValue);

            #endregion UserCode
        }
Esempio n. 2
0
        protected static FR_L5EM_GEFTAE_1517 Execute(DbConnection Connection, DbTransaction Transaction, P_L5EM_GEFTAE_1517 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5EM_GEFTAE_1517();
            returnValue.Result = new L5EM_GEFTAE_1517();
            //Put your code here

            L5EM_GEFT_0959[] employees      = cls_Get_Employees_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;
            L5EM_GEFT_0959   loggedEmployee = employees.Where(i => i.CMN_BPT_EMP_EmployeeID == Parameter.EmployeeID).FirstOrDefault();
            L5CM_GCSFT_1157  company        = cls_Get_Company_Structure_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;
            EmployeeUtils    employeeUtils  = new EmployeeUtils();
            employeeUtils.ComapnyStructure = company;
            List <Guid> employeesUnderManager = employeeUtils.getEmployeesForManager(Parameter.appStartDate, employees, company, Parameter.EmployeeID, securityTicket.SessionTicket);
            employees = employees.Where(i => employeesUnderManager.Contains(i.CMN_BPT_EMP_EmployeeID) || EmployeeUtils.getEmployeeWorkplaceHistoriesFromAppStartDate(i.EmployeeWorkplaceHistory, Parameter.appStartDate).Intersect(EmployeeUtils.getEmployeeWorkplaceHistoriesFromAppStartDate(loggedEmployee.EmployeeWorkplaceHistory, Parameter.appStartDate)).Any()).ToArray();

            if (employees.Where(i => i.CMN_BPT_EMP_EmployeeID == Parameter.EmployeeID).ToArray().Length == 0)
            {
                if (loggedEmployee != null)
                {
                    if (employees.Length == 0)
                    {
                        employees    = new L5EM_GEFT_0959[1];
                        employees[0] = loggedEmployee;
                    }
                    else
                    {
                        L5EM_GEFT_0959[] employeeList = new L5EM_GEFT_0959[employees.Length + 1];
                        for (int i = 0; i < employees.Length; i++)
                        {
                            employeeList[i] = employees[i];
                        }
                        employeeList[employees.Length] = loggedEmployee;
                        employees = employeeList;
                    }
                }
            }
            returnValue.Result.Employees = employees;
            if (employees.Length == 0)
            {
                returnValue.Result = null;
            }
            return(returnValue);

            #endregion UserCode
        }
Esempio n. 3
0
 ///<summary>
 /// Ivokes the method with the given Connection, leaving it open if no exceptions occured
 ///<summary>
 public static FR_L5EM_GEFTAE_1517 Invoke(DbConnection Connection, P_L5EM_GEFTAE_1517 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, null, null, Parameter, securityTicket));
 }
Esempio n. 4
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_L5EM_GEFTAE_1517 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5EM_GEFTAE_1517 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_L5EM_GEFTAE_1517 functionReturn = new FR_L5EM_GEFTAE_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 new Exception("Exception occured in method cls_Get_Employees_For_Tenant_And_ManagerEmployeeID", ex);
            }
            return(functionReturn);
        }