Example #1
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);
        }
Example #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_GEAAWCFT_1210[]            employees          = cls_Get_Employees_And_ActiveWorkingContracts_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;
            L5EM_GEAAWCFT_1210              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;
            Dictionary <Guid, List <Guid> > managesPerLocation = new Dictionary <Guid, List <Guid> >();

            var oldEmpls = CLE_L5_CMN_Employees.Complex.Retrieval.cls_Get_Employees_For_Tenant_And_ManagerEmployeeID.Invoke(Connection, Transaction, new PlannicoModel.Models.P_L5EM_GEFTAE_1517 {
                EmployeeID = Parameter.EmployeeID
            }, securityTicket).Result;

            foreach (var office in company.Offices)
            {
                List <Guid> managerIDList = new List <Guid>();
                foreach (var manager in office.Managers)
                {
                    if (!managerIDList.Contains(manager.CMN_BPT_EMP_EmployeeID))
                    {
                        managerIDList.Add(manager.CMN_BPT_EMP_EmployeeID);
                    }
                }
                if (managerIDList.Count() > 0)
                {
                    managesPerLocation.Add(office.CMN_STR_OfficeID, managerIDList);
                }
            }
            foreach (var workarea in company.WorkAreas)
            {
                List <Guid> managerIDList = new List <Guid>();
                foreach (var manager in workarea.ResponsiblePersons)
                {
                    if (!managerIDList.Contains(manager.CMN_BPT_EMP_EmployeeID))
                    {
                        managerIDList.Add(manager.CMN_BPT_EMP_EmployeeID);
                    }
                }
                if (managerIDList.Count() > 0)
                {
                    managesPerLocation.Add(workarea.CMN_STR_PPS_WorkAreaID, managerIDList);
                }
            }
            foreach (var workplace in company.WorkPlaces)
            {
                List <Guid> managerIDList = new List <Guid>();
                foreach (var manager in workplace.ResponsiblePersons)
                {
                    if (!managerIDList.Contains(manager.CMN_BPT_EMP_EmployeeID))
                    {
                        managerIDList.Add(manager.CMN_BPT_EMP_EmployeeID);
                    }
                }
                if (managerIDList.Count() > 0)
                {
                    managesPerLocation.Add(workplace.CMN_STR_PPS_WorkplaceID, managerIDList);
                }
            }
            var employeeList = new List <L5EM_GEAAWCFT_1210>();
            foreach (var e in employees)
            {
                foreach (var wh in e.EmployeeWorkplaceHistory)
                {
                    if (managesPerLocation.ContainsKey(wh.BoundTo_Workplace_RefID) &&
                        managesPerLocation[wh.BoundTo_Workplace_RefID].Contains(loggedEmployee.CMN_BPT_EMP_EmployeeID))
                    {
                        var loggedEmployeeValidWorkplaces = loggedEmployee.EmployeeWorkplaceHistory.Where(w => w.WorkplaceAssignment_StartDate >= Parameter.appStartDate).Select(w => w.BoundTo_Workplace_RefID);
                        if (loggedEmployeeValidWorkplaces != null)
                        {
                            if (loggedEmployeeValidWorkplaces.Contains(wh.BoundTo_Workplace_RefID) && !employeeList.Contains(e))
                            {
                                employeeList.Add(e);
                            }
                        }
                    }
                }
            }
            if (!employeeList.Contains(loggedEmployee))
            {
                employeeList.Add(loggedEmployee);
            }
            returnValue.Result.Employees = employeeList.ToArray();
            if (employees.Length == 0)
            {
                returnValue.Result = null;
            }
            return(returnValue);

            #endregion UserCode
        }