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 }
protected static FR_L6LR_GRARD_1130 Execute(DbConnection Connection, DbTransaction Transaction, P_L6LR_GRARD_1130 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6LR_GRARD_1130(); L6LR_GRARD_1130 result = new L6LR_GRARD_1130(); result.Company = cls_Get_Company_Structure_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result; L5EM_GEFT_0959[] allEmployees = cls_Get_Employees_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result; result.Employees = allEmployees; result.AbsenceReasons = cls_Get_AbsenceReasons_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result; P_L5LR_GLRFSP_1532 param = new P_L5LR_GLRFSP_1532(); param.EmployeeIDList = Parameter.ListOfEmployees; result.Leaves = cls_Get_LeaveRequests_For_SelectedPersons.Invoke(Connection, Transaction, param, securityTicket).Result; result.EmployeesForTenant = allEmployees; returnValue.Result = result; return(returnValue); #endregion UserCode }
protected static FR_L6LR_GLRD_1503 Execute(DbConnection Connection, DbTransaction Transaction, String ConnectionString, P_L6LR_GLRD_1503 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6LR_GLRD_1503(); //Put your code here L5EM_GEFU_445 LoggedEmplyeeID = null; L5EM_GEAAWCFT_1210[] For_Employees = null; L5AR_GAARFT_1130[] reasons_Res = null; L5TN_GTI_1646 tenant = null; L6TN_GSFT_1017 settings = null; L5EM_GEFT_0959[] employees = null; L5CM_GCSFT_1157 comapnyStructure = null; L5LR_GLRFSP_1532[] leaveRequests = null; L3EV_GSEFT_1647[] events = null; Parallel.Invoke(() => { LoggedEmplyeeID = cls_Get_Employee_For_LoggedAccount.Invoke(ConnectionString, securityTicket).Result; }, // close first Action () => { For_Employees = cls_Get_Employees_And_ActiveWorkingContracts_For_Tenant.Invoke(ConnectionString, securityTicket).Result; }, //close second Action () => { reasons_Res = cls_get_Active_AbsenceReason_For_TenantID.Invoke(ConnectionString, securityTicket).Result; } , () => { tenant = cls_get_Tenant_Informations.Invoke(ConnectionString, securityTicket).Result; } , () => { settings = cls_Get_Settings_For_Tenant.Invoke(ConnectionString, securityTicket).Result; } , () => { employees = cls_Get_Employees_For_Tenant.Invoke(ConnectionString, securityTicket).Result; }, () => { comapnyStructure = cls_Get_Company_Structure_For_Tenant.Invoke(ConnectionString, securityTicket).Result; } , () => { P_L5LR_GLRFSP_1532 param = new P_L5LR_GLRFSP_1532(); param.EmployeeIDList = Parameter.EmployeeIDListForRequests; leaveRequests = cls_Get_LeaveRequests_For_SelectedPersons.Invoke(ConnectionString, param, securityTicket).Result; } , () => { events = cls_Get_StructureEvents_For_Tenant.Invoke(ConnectionString, securityTicket).Result; } ); returnValue.Result = new L6LR_GLRD_1503(); returnValue.Result.AllEvents = events; returnValue.Result.AllLeaveRequests = leaveRequests; returnValue.Result.ForEmployees = For_Employees; returnValue.Result.LoggedEmployeeID = LoggedEmplyeeID; returnValue.Result.Settings = settings; returnValue.Result.LeavingReasons = reasons_Res; returnValue.Result.TenantInformations = tenant; returnValue.Result.AllEmployees = employees; return(returnValue); #endregion UserCode }
protected static FR_L5LR_GLRFSP_1532_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L5LR_GLRFSP_1532 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5LR_GLRFSP_1532_Array(); List <L5LR_GLRFSP_1532> resultList = new List <L5LR_GLRFSP_1532>(); Parameter.EmployeeIDList = Parameter.EmployeeIDList.Select(i => i).Distinct().ToArray(); foreach (var employeeID in Parameter.EmployeeIDList) { ORM_CMN_BPT_EMP_Employee employee = new ORM_CMN_BPT_EMP_Employee(); employee.Load(Connection, Transaction, employeeID); if (employee.CMN_BPT_EMP_EmployeeID == Guid.Empty) { continue; } //Covers ORM_CMN_BPT_EMP_Employee_LeaveRequest.Query leaveRequestQuery = new ORM_CMN_BPT_EMP_Employee_LeaveRequest.Query(); leaveRequestQuery.RequestedFor_Employee_RefID = employee.CMN_BPT_EMP_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); foreach (var leaveRequest in leaveRequests) { L5LR_GLRFSP_1532 result = new L5LR_GLRFSP_1532(); result.ForEmployeeID = employee.CMN_BPT_EMP_EmployeeID; result.ForEmployee_BusinessParticipant_RefID = employee.BusinessParticipant_RefID; result.ForEmployee_Staff_Number = employee.Staff_Number; result.ForEmployee_StandardFunction = employee.StandardFunction; result.LeaveRequestCreationSource = leaveRequest.LeaveRequestCreationSource; ORM_CMN_BPT_BusinessParticipant bpart = new ORM_CMN_BPT_BusinessParticipant(); bpart.Load(Connection, Transaction, employee.BusinessParticipant_RefID); ORM_CMN_PER_PersonInfo per = new ORM_CMN_PER_PersonInfo(); per.Load(Connection, Transaction, bpart.IfNaturalPerson_CMN_PER_PersonInfo_RefID); result.FirstName = per.FirstName; result.LastName = per.LastName; result.CMN_CAL_Event_RefID = leaveRequest.CMN_CAL_Event_RefID; result.CMN_CAL_Event_Approval_RefID = leaveRequest.CMN_CAL_Event_Approval_RefID; result.CMN_CAL_Event_Approval_RefID = leaveRequest.CMN_BPT_STA_AbsenceReason_RefID; result.Comment = leaveRequest.Comment; result.RequestedBy_Employee_RefID = leaveRequest.RequestedBy_Employee_RefID; result.CMN_BPT_EMP_Employee_LeaveRequestID = leaveRequest.CMN_BPT_EMP_Employee_LeaveRequestID; ORM_CMN_BPT_EMP_Employee_LeaveRequest_EmployeeCover.Query covers = new ORM_CMN_BPT_EMP_Employee_LeaveRequest_EmployeeCover.Query(); covers.CMN_BPT_EMP_Employee_LeaveRequests = leaveRequest.CMN_BPT_EMP_Employee_LeaveRequestID; covers.Tenant_RefID = securityTicket.TenantID; covers.IsDeleted = false; List <ORM_CMN_BPT_EMP_Employee_LeaveRequest_EmployeeCover> employeeCovers = ORM_CMN_BPT_EMP_Employee_LeaveRequest_EmployeeCover.Query.Search(Connection, Transaction, covers); result.Cover = new L5LR_GLRFSP_1532_Cover(); if (employeeCovers.Count != 0) { ORM_CMN_BPT_EMP_Employee_LeaveRequest_EmployeeCover employeeCover = employeeCovers[0]; result.Cover.CMN_BPT_EMP_EmployeeID = employeeCover.EmployeeCover_RefID; result.Cover.CMN_BPT_EMP_Employee_LeaveRequest_EmployeeCoverID = employeeCover.CMN_BPT_EMP_Employee_LeaveRequest_EmployeeCoverID; result.Cover.SequenceNumber = employeeCover.SequenceNumber; } ORM_CMN_BPT_STA_AbsenceReason absenceReason = new ORM_CMN_BPT_STA_AbsenceReason(); absenceReason.Load(Connection, Transaction, leaveRequest.CMN_BPT_STA_AbsenceReason_RefID); if (absenceReason.CMN_BPT_STA_AbsenceReasonID == Guid.Empty) { continue; } result.CMN_BPT_STA_AbsenceReason_RefID = absenceReason.CMN_BPT_STA_AbsenceReasonID; result.ShortName = absenceReason.ShortName; result.ReasonName = absenceReason.Name; result.ReasonDesc = absenceReason.Description; result.AbsenceReason_Type_RefID = absenceReason.AbsenceReason_Type_RefID; result.ColorCode = absenceReason.ColorCode; result.Parent_RefID = absenceReason.Parent_RefID; result.IsAuthorizationRequired = absenceReason.IsAuthorizationRequired; result.IsIncludedInCapacityCalculation = absenceReason.IsIncludedInCapacityCalculation; result.IsAllowedAbsence = absenceReason.IsAllowedAbsence; result.IsDeactivated = absenceReason.IsDeactivated; result.IsCarryOverEnabled = absenceReason.IsCarryOverEnabled; result.IsCaryOverLimited = absenceReason.IsCaryOverLimited; result.IfCarryOverLimited_MaximumAmount_Hrs = absenceReason.IfCarryOverLimited_MaximumAmount_Hrs; ORM_CMN_CAL_Event Event = new ORM_CMN_CAL_Event(); Event.Load(Connection, Transaction, leaveRequest.CMN_CAL_Event_RefID); if (Event.CMN_CAL_EventID == Guid.Empty) { continue; } result.CalendarInstance_RefID = Event.CalendarInstance_RefID; result.StartTime = Event.StartTime; result.EndTime = Event.EndTime; result.R_EventDuration_sec = Event.R_EventDuration_sec; ORM_CMN_CAL_Event_Approval eventApproval = new ORM_CMN_CAL_Event_Approval(); eventApproval.Load(Connection, Transaction, leaveRequest.CMN_CAL_Event_Approval_RefID); if (eventApproval.CMN_CAL_Event_ApprovalID == Guid.Empty) { continue; } result.Action = new L5LR_GLRFSP_1532_Action(); result.IsApproved = eventApproval.IsApproved; result.IsApprovalProcessOpened = eventApproval.IsApprovalProcessOpened; result.IsApprovalProcessDenied = eventApproval.IsApprovalProcessDenied; if (eventApproval.IsApprovalProcessCanceledByUser) { continue; } ORM_CMN_CAL_Event_Approval_Action.Query approvalQuery = new ORM_CMN_CAL_Event_Approval_Action.Query(); approvalQuery.EventApproval_RefID = eventApproval.CMN_CAL_Event_ApprovalID; approvalQuery.Tenant_RefID = securityTicket.TenantID; approvalQuery.IsDeleted = false; List <ORM_CMN_CAL_Event_Approval_Action> apporvalActions = ORM_CMN_CAL_Event_Approval_Action.Query.Search(Connection, Transaction, approvalQuery); if (apporvalActions.Count != 0) { ORM_CMN_CAL_Event_Approval_Action approvalAction = apporvalActions[0]; result.Action.ActionTriggeredBy_Account_RefID = approvalAction.ActionTriggeredBy_Account_RefID; result.Action.CMN_CAL_Event_Approval_ActionID = approvalAction.CMN_CAL_Event_Approval_ActionID; result.Action.IsApproval = approvalAction.IsApproval; result.Action.IsRevocation = approvalAction.IsRevocation; result.Action.IsDenial = approvalAction.IsDenial; result.Action.Approval_Action_Commnet = approvalAction.Comment; } if (!result.Action.IsRevocation) { resultList.Add(result); } } } returnValue.Result = resultList.ToArray(); //Put your code here return(returnValue); #endregion UserCode }
///<summary> /// Method Invocation of wrapper classes ///<summary> protected static FR_L5LR_GLRFSP_1532_Array Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5LR_GLRFSP_1532 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { bool cleanupConnection = Connection == null; bool cleanupTransaction = Transaction == null; FR_L5LR_GLRFSP_1532_Array functionReturn = new FR_L5LR_GLRFSP_1532_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 ex; } return(functionReturn); }
///<summary> /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured ///<summary> public static FR_L5LR_GLRFSP_1532_Array Invoke(DbConnection Connection, DbTransaction Transaction, P_L5LR_GLRFSP_1532 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(Connection, Transaction, null, Parameter, securityTicket)); }
///<summary> /// Opens the connection/transaction for the given connectionString, and closes them when complete ///<summary> public static FR_L5LR_GLRFSP_1532_Array Invoke(string ConnectionString, P_L5LR_GLRFSP_1532 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(null, null, ConnectionString, Parameter, securityTicket)); }