protected static FR_Bool Execute(DbConnection Connection, DbTransaction Transaction, P_L5OF_IOFU_1531 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Bool(); ORM_CMN_BPT_EMP_Employee_PlanGroup.Query planGroupQuery = new ORM_CMN_BPT_EMP_Employee_PlanGroup.Query(); planGroupQuery.BoundTo_Office_RefID = Parameter.OfficeID; planGroupQuery.IsDeleted = false; planGroupQuery.Tenant_RefID = securityTicket.TenantID; if (ORM_CMN_BPT_EMP_Employee_PlanGroup.Query.Exists(Connection, Transaction, planGroupQuery)) { returnValue.Result = true; } ORM_CMN_BPT_EMP_ExtraWorkCalculation_StructureBinding.Query extraWorkCalculationQuery = new ORM_CMN_BPT_EMP_ExtraWorkCalculation_StructureBinding.Query(); extraWorkCalculationQuery.BoundTo_Office_RefID = Parameter.OfficeID; extraWorkCalculationQuery.IsDeleted = false; extraWorkCalculationQuery.Tenant_RefID = securityTicket.TenantID; if (ORM_CMN_BPT_EMP_ExtraWorkCalculation_StructureBinding.Query.Exists(Connection, Transaction, extraWorkCalculationQuery)) { returnValue.Result = true; } ORM_CMN_BPT_EMP_ExtraWorkCalculation_Surcharge_StructureBinding.Query surchargeQuery = new ORM_CMN_BPT_EMP_ExtraWorkCalculation_Surcharge_StructureBinding.Query(); surchargeQuery.BoundTo_Office_RefID = Parameter.OfficeID; surchargeQuery.IsDeleted = false; surchargeQuery.Tenant_RefID = securityTicket.TenantID; if (ORM_CMN_BPT_EMP_ExtraWorkCalculation_Surcharge_StructureBinding.Query.Exists(Connection, Transaction, surchargeQuery)) { returnValue.Result = true; } ORM_CMN_BPT_EMP_Employee.Query employeeQuery = new ORM_CMN_BPT_EMP_Employee.Query(); employeeQuery.Primary_Office_RefID = Parameter.OfficeID; employeeQuery.IsDeleted = false; employeeQuery.Tenant_RefID = securityTicket.TenantID; if (ORM_CMN_BPT_EMP_Employee.Query.Exists(Connection, Transaction, employeeQuery)) { returnValue.Result = true; } ORM_CMN_PPS_ShiftTemplate.Query shiftTemplateQuery = new ORM_CMN_PPS_ShiftTemplate.Query(); shiftTemplateQuery.CMN_STR_Office_RefID = Parameter.OfficeID; shiftTemplateQuery.IsDeleted = false; shiftTemplateQuery.Tenant_RefID = securityTicket.TenantID; if (ORM_CMN_PPS_ShiftTemplate.Query.Exists(Connection, Transaction, shiftTemplateQuery)) { returnValue.Result = true; } ORM_CMN_PPS_BreakTime_Defaults_StructureBinding.Query defaultBreakQuery = new ORM_CMN_PPS_BreakTime_Defaults_StructureBinding.Query(); defaultBreakQuery.BoundTo_Office_RefID = Parameter.OfficeID; defaultBreakQuery.IsDeleted = false; defaultBreakQuery.Tenant_RefID = securityTicket.TenantID; if (ORM_CMN_PPS_BreakTime_Defaults_StructureBinding.Query.Exists(Connection, Transaction, defaultBreakQuery)) { returnValue.Result = true; } ORM_CMN_PPS_BreakTime_Template.Query breakTimeTemplateQuery = new ORM_CMN_PPS_BreakTime_Template.Query(); breakTimeTemplateQuery.BoundTo_Office_RefID = Parameter.OfficeID; breakTimeTemplateQuery.IsDeleted = false; breakTimeTemplateQuery.Tenant_RefID = securityTicket.TenantID; if (ORM_CMN_PPS_BreakTime_Template.Query.Exists(Connection, Transaction, breakTimeTemplateQuery)) { returnValue.Result = true; } ORM_CMN_STR_PPS_WorkArea.Query workplaceQuery = new ORM_CMN_STR_PPS_WorkArea.Query(); workplaceQuery.Office_RefID = Parameter.OfficeID; workplaceQuery.IsDeleted = false; workplaceQuery.Tenant_RefID = securityTicket.TenantID; if (ORM_CMN_STR_PPS_WorkArea.Query.Exists(Connection, Transaction, workplaceQuery)) { returnValue.Result = true; } ORM_CMN_BPT_STR_Office_SettingsProfile.Query OfficeSettingsProfileQuery = new ORM_CMN_BPT_STR_Office_SettingsProfile.Query(); OfficeSettingsProfileQuery.Office_RefID = Parameter.OfficeID; OfficeSettingsProfileQuery.IsDeleted = false; OfficeSettingsProfileQuery.Tenant_RefID = securityTicket.TenantID; if (ORM_CMN_BPT_STR_Office_SettingsProfile.Query.Exists(Connection, Transaction, OfficeSettingsProfileQuery)) { returnValue.Result = true; } ORM_CMN_STR_Office_2_CostCenter.Query OfficeCostcenterQuery = new ORM_CMN_STR_Office_2_CostCenter.Query(); OfficeCostcenterQuery.Office_RefID = Parameter.OfficeID; OfficeCostcenterQuery.IsDeleted = false; OfficeCostcenterQuery.Tenant_RefID = securityTicket.TenantID; if (ORM_CMN_STR_Office_2_CostCenter.Query.Exists(Connection, Transaction, OfficeCostcenterQuery)) { returnValue.Result = true; } ORM_CMN_STR_Office_Default_WorkRelationDefinition_Template.Query OfficeDefaultWorkRelationTemplateQuery = new ORM_CMN_STR_Office_Default_WorkRelationDefinition_Template.Query(); OfficeDefaultWorkRelationTemplateQuery.CMN_STR_Office_RefID = Parameter.OfficeID; OfficeDefaultWorkRelationTemplateQuery.IsDeleted = false; OfficeDefaultWorkRelationTemplateQuery.Tenant_RefID = securityTicket.TenantID; if (ORM_CMN_STR_Office_Default_WorkRelationDefinition_Template.Query.Exists(Connection, Transaction, OfficeDefaultWorkRelationTemplateQuery)) { returnValue.Result = true; } //Put your code here return(returnValue); #endregion UserCode }
protected static FR_L5OF_GOFT_1157_Array Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_L5OF_GOFT_1157_Array(); ORM_CMN_STR_Office.Query officesQuery = new ORM_CMN_STR_Office.Query(); officesQuery.IsDeleted = false; officesQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_STR_Office> officesResult = ORM_CMN_STR_Office.Query.Search(Connection, Transaction, officesQuery); List <L5OF_GOFT_1157> officesResultList = new List <L5OF_GOFT_1157>(); foreach (var office in officesResult) { L5OF_GOFT_1157 result = new L5OF_GOFT_1157(); var item = new ORM_CMN_STR_Office(); var resultOffice = item.Load(Connection, Transaction, office.CMN_STR_OfficeID); if (resultOffice.Status != FR_Status.Success || item.CMN_STR_OfficeID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(null); } result.CMN_CAL_CalendarInstance_RefID = item.CMN_CAL_CalendarInstance_RefID; result.CMN_STR_OfficeID = item.CMN_STR_OfficeID; result.Country_RefID = item.Country_RefID; result.Default_FaxNumber = item.Default_FaxNumber; result.Default_PhoneNumber = item.Default_PhoneNumber; result.Office_ShortName = item.Office_ShortName; result.OfficeDescription = item.Office_Description; result.OfficeName = item.Office_Name; result.Region_RefID = item.Region_RefID; result.BillingAddress_CMN_AddressID = item.Default_BillingAddress_RefID; var address = new ORM_CMN_Address(); var resultItem = address.Load(Connection, Transaction, item.Default_BillingAddress_RefID); if (resultItem.Status != FR_Status.Success || address.CMN_AddressID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(null); } result.BillingAddress_City_Name = address.City_Name; result.BillingAddress_City_AdministrativeDistrict = address.City_AdministrativeDistrict; result.BillingAddress_City_PostalCode = address.City_PostalCode; result.BillingAddress_City_Region = address.City_Region; result.BillingAddress_Country_Name = address.Country_Name; result.BillingAddress_Province_Name = address.Province_Name; result.BillingAddress_Street_Name = address.Street_Name; result.BillingAddress_Street_Number = address.Street_Number; result.BillingAddress_Country_ISOCode = address.Country_ISOCode; ORM_CMN_STR_Office_2_CostCenter.Query officeToCostcenterQuery = new ORM_CMN_STR_Office_2_CostCenter.Query(); officeToCostcenterQuery.Office_RefID = office.CMN_STR_OfficeID; officeToCostcenterQuery.Tenant_RefID = securityTicket.TenantID; officeToCostcenterQuery.IsDeleted = false; List <ORM_CMN_STR_Office_2_CostCenter> officeToCostcenterList = ORM_CMN_STR_Office_2_CostCenter.Query.Search(Connection, Transaction, officeToCostcenterQuery); if (officeToCostcenterList.Count != 0) { L5OF_GOFT_1157_Costcenter costCenter = new L5OF_GOFT_1157_Costcenter(); ORM_CMN_STR_CostCenter costCenterItem = new ORM_CMN_STR_CostCenter(); costCenterItem.Load(Connection, Transaction, officeToCostcenterList[0].CostCenter_RefID); if (!costCenterItem.IsDeleted) { costCenter.AssignmentID = officeToCostcenterList[0].AssignmentID; costCenter.CMN_STR_CostCenterID = officeToCostcenterList[0].CostCenter_RefID; costCenter.CostcenterName = costCenterItem.Name; costCenter.InternalID = costCenterItem.InternalID; result.Costcenter = costCenter; } } var responsiblePersonsQuery = new ORM_CMN_STR_Office_ResponsiblePerson.Query(); responsiblePersonsQuery.Tenant_RefID = securityTicket.TenantID; responsiblePersonsQuery.Office_RefID = item.CMN_STR_OfficeID; responsiblePersonsQuery.IsDeleted = false; var responsiblePersonsList = ORM_CMN_STR_Office_ResponsiblePerson.Query.Search(Connection, Transaction, responsiblePersonsQuery); List <L5OF_GOFT_1157_ResponsiblePersons> responsiblePresonsResultList = new List <L5OF_GOFT_1157_ResponsiblePersons>(); foreach (var responsiblePerson in responsiblePersonsList) { L5OF_GOFT_1157_ResponsiblePersons responsiblePersonResult = new L5OF_GOFT_1157_ResponsiblePersons(); responsiblePersonResult.CMN_BPT_EMP_EmployeeID = responsiblePerson.CMN_BPT_EMP_Employee_RefID; responsiblePersonResult.CMN_STR_Office_ResponsiblePersonID = responsiblePerson.CMN_STR_Office_ResponsiblePersonID; ORM_CMN_BPT_EMP_Employee employee = new ORM_CMN_BPT_EMP_Employee(); employee.Load(Connection, Transaction, responsiblePerson.CMN_BPT_EMP_Employee_RefID); ORM_CMN_BPT_BusinessParticipant bParticipant = new ORM_CMN_BPT_BusinessParticipant(); bParticipant.Load(Connection, Transaction, employee.BusinessParticipant_RefID); ORM_CMN_PER_PersonInfo person = new ORM_CMN_PER_PersonInfo(); person.Load(Connection, Transaction, bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID); responsiblePersonResult.CMN_BPT_BusinessParticipantID = bParticipant.CMN_BPT_BusinessParticipantID; responsiblePersonResult.FirstName = person.FirstName; responsiblePersonResult.LastName = person.LastName; responsiblePresonsResultList.Add(responsiblePersonResult); } result.Managers = responsiblePresonsResultList.ToArray(); officesResultList.Add(result); } returnValue.Result = officesResultList.ToArray(); //Put your code here return(returnValue); #endregion UserCode }
protected static FR_L5PP_GSHwDOfPfT_1013_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L5PP_GSHwDOfPfT_1013 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5PP_GSHwDOfPfT_1013_Array(); //Put your code here List <L5PP_GSHwDOfPfT_1013> retVal = new List <L5PP_GSHwDOfPfT_1013>(); returnValue.Result = retVal.ToArray(); #region Retrieve Headers // get all headers P_L2SH_GSHfT_1527 shipmentHeadersParam = new P_L2SH_GSHfT_1527(); shipmentHeadersParam.IsShipped = false; shipmentHeadersParam.ShipmentNumber = Parameter.ShipmentNumber; shipmentHeadersParam.ShipmentCreationDateFrom = Parameter.ShipmentCreationDateFrom; shipmentHeadersParam.ShipmentCreationDateTo = Parameter.ShipmentCreationDateTo; var headersResult = cls_Get_ShippmentHeaders_for_TenantID.Invoke(Connection, Transaction, shipmentHeadersParam, securityTicket).Result; if (headersResult == null) { return(returnValue); } // filter headers List <L2SH_GSHfT_1527> headers = new List <L2SH_GSHfT_1527>(); List <L2SH_GSHfT_1527> tempHeaders = new List <L2SH_GSHfT_1527>(); if (Parameter.HasPositionsPartiallyToPick) { // filtered by passed parameter option tempHeaders = headersResult.Where(i => i.IsPartiallyReadyForPicking && !i.IsManuallyCleared_ForPicking).ToList(); // add not inserted shipment headers headers.AddRange(tempHeaders.Where(i => !headers.Any(j => j.LOG_SHP_Shipment_HeaderID == i.LOG_SHP_Shipment_HeaderID)).ToList()); } if (Parameter.IsReadyForPicking) { // filtered by passed parameter option tempHeaders = headersResult.Where(i => i.IsReadyForPicking && !i.IsManuallyCleared_ForPicking).ToList(); // add not inserted shipment headers headers.AddRange(tempHeaders.Where(i => !headers.Any(j => j.LOG_SHP_Shipment_HeaderID == i.LOG_SHP_Shipment_HeaderID)).ToList()); } if (Parameter.IsInPickingProcess) { // filtered by passed parameter option tempHeaders = headersResult.Where(i => i.HasPickingStarted || i.HasPickingFinished || i.IsManuallyCleared_ForPicking).ToList(); // add not inserted shipment headers headers.AddRange(tempHeaders.Where(i => !headers.Any(j => j.LOG_SHP_Shipment_HeaderID == i.LOG_SHP_Shipment_HeaderID)).ToList()); } if (Parameter.NoPositionsFullyToPick) { // filtered by passed parameter option tempHeaders = headersResult.Where(i => !(i.IsPartiallyReadyForPicking && !i.IsManuallyCleared_ForPicking) && !(i.IsReadyForPicking && !i.IsManuallyCleared_ForPicking) && !(i.HasPickingStarted || i.HasPickingFinished || i.IsManuallyCleared_ForPicking) ).ToList(); // add not inserted shipment headers headers.AddRange(tempHeaders.Where(i => !headers.Any(j => j.LOG_SHP_Shipment_HeaderID == i.LOG_SHP_Shipment_HeaderID)).ToList()); } #endregion L5PP_GSHwDOfPfT_1013 retValItem; foreach (var header in headers) { #region Getting data #region Shipment positions // get one shipment position for shipment header ORM_LOG_SHP_Shipment_Position.Query shipmentPositionsQuery = new ORM_LOG_SHP_Shipment_Position.Query(); shipmentPositionsQuery.LOG_SHP_Shipment_Header_RefID = header.LOG_SHP_Shipment_HeaderID; shipmentPositionsQuery.Tenant_RefID = securityTicket.TenantID; shipmentPositionsQuery.IsDeleted = false; List <ORM_LOG_SHP_Shipment_Position> shipmentPositions = ORM_LOG_SHP_Shipment_Position.Query.Search(Connection, Transaction, shipmentPositionsQuery); if (shipmentPositions == null || shipmentPositions.Count == 0) { continue; } #endregion #region Distribution order position for shipment position // get one distribution order position for shipment position ORM_ORD_DIS_DistributionOrderPosition_2_ShipmentOrderPosition distributionOrder2ShipmentPosition = null; foreach (var shipmentPosition in shipmentPositions) { ORM_ORD_DIS_DistributionOrderPosition_2_ShipmentOrderPosition.Query distributionOrder2ShipmentPositionQuery = new ORM_ORD_DIS_DistributionOrderPosition_2_ShipmentOrderPosition.Query(); distributionOrder2ShipmentPositionQuery.LOG_SHP_Shipment_Position_RefID = shipmentPosition.LOG_SHP_Shipment_PositionID; distributionOrder2ShipmentPositionQuery.Tenant_RefID = securityTicket.TenantID; distributionOrder2ShipmentPositionQuery.IsDeleted = false; distributionOrder2ShipmentPosition = ORM_ORD_DIS_DistributionOrderPosition_2_ShipmentOrderPosition.Query .Search(Connection, Transaction, distributionOrder2ShipmentPositionQuery).FirstOrDefault(); if (distributionOrder2ShipmentPosition != null) { break; } } if (distributionOrder2ShipmentPosition == null) { continue; } #endregion #region Disrtibution order position ORM_ORD_DIS_DistributionOrder_Position orm_DistributionOrderPosition = new ORM_ORD_DIS_DistributionOrder_Position(); var distributionOrderPosition = orm_DistributionOrderPosition.Load(Connection, Transaction, distributionOrder2ShipmentPosition.ORD_DIS_DistributionOrder_Position_RefID); if (distributionOrderPosition.Status != FR_Status.Success || orm_DistributionOrderPosition.ORD_DIS_DistributionOrder_PositionID == Guid.Empty) { continue; } #endregion #region Distribution order header // get sitribution order header for distribution order position ORM_ORD_DIS_DistributionOrder_Header.Query distributionOrderHeaderQuery = new ORM_ORD_DIS_DistributionOrder_Header.Query(); distributionOrderHeaderQuery.ORD_DIS_DistributionOrder_HeaderID = orm_DistributionOrderPosition.DistributionOrder_Header_RefID; distributionOrderHeaderQuery.Tenant_RefID = securityTicket.TenantID; distributionOrderHeaderQuery.IsDeleted = false; ORM_ORD_DIS_DistributionOrder_Header distributionOrderHeader = ORM_ORD_DIS_DistributionOrder_Header.Query.Search(Connection, Transaction, distributionOrderHeaderQuery).FirstOrDefault(); if (distributionOrderHeader == null) { continue; } // apply filter for distribution order header if (Parameter.OrderDateFrom != null) { if (distributionOrderHeader.DistributionOrderDate < Parameter.OrderDateFrom) { continue; } } if (Parameter.OrderDateTo != null) { if (distributionOrderHeader.DistributionOrderDate > Parameter.OrderDateTo) { continue; } } if (!String.IsNullOrEmpty(Parameter.DistributionOrderNumber)) { if (!distributionOrderHeader.DistributionOrderNumber.ToUpper().Contains(Parameter.DistributionOrderNumber.ToUpper())) { continue; } } #endregion #region CostCenter // get cost center for distribution order header ORM_CMN_STR_CostCenter orm_CostCenter = new ORM_CMN_STR_CostCenter(); var costCenter = orm_CostCenter.Load(Connection, Transaction, distributionOrderHeader.Charged_CostCenter_RefID); if (costCenter.Status != FR_Status.Success || orm_CostCenter.CMN_STR_CostCenterID == Guid.Empty) { continue; } if (!String.IsNullOrEmpty(Parameter.CostCenter)) { // apply filter for cost center if (!orm_CostCenter.Name.Contents.Any(i => i.Content.ToLower().Contains(Parameter.CostCenter))) { continue; } } #endregion #region Office // get office for cost center ORM_CMN_STR_Office_2_CostCenter.Query office2CostCenterQuery = new ORM_CMN_STR_Office_2_CostCenter.Query(); office2CostCenterQuery.CostCenter_RefID = orm_CostCenter.CMN_STR_CostCenterID; office2CostCenterQuery.Tenant_RefID = securityTicket.TenantID; office2CostCenterQuery.IsDefault = false; ORM_CMN_STR_Office_2_CostCenter office2CostCenter = ORM_CMN_STR_Office_2_CostCenter.Query.Search(Connection, Transaction, office2CostCenterQuery).FirstOrDefault(); ORM_CMN_STR_Office orm_Office = null; if (office2CostCenter != null) { orm_Office = new ORM_CMN_STR_Office(); var office = orm_Office.Load(Connection, Transaction, office2CostCenter.Office_RefID); if (office.Status != FR_Status.Success || orm_Office.CMN_STR_OfficeID == Guid.Empty) { // there is no office with such ID orm_Office = null; } else { // office loaded, apply filter if (!String.IsNullOrEmpty(Parameter.OrganizationalUnit)) { if (!(orm_Office.Office_InternalName.ToLower().Contains(Parameter.OrganizationalUnit) || orm_Office.Office_Name.Contents.Any(i => i.Content.ToLower().Contains(Parameter.OrganizationalUnit)))) { continue; } } } } #endregion #endregion retValItem = new L5PP_GSHwDOfPfT_1013(); retValItem.LOG_SHP_Shipment_HeaderID = header.LOG_SHP_Shipment_HeaderID; retValItem.ShipmentHeader_Number = header.ShipmentHeader_Number; retValItem.IsShipped = header.IsShipped; retValItem.IsBilled = header.IsBilled; retValItem.IsReadyForPicking = header.IsReadyForPicking; retValItem.IsPartiallyReadyForPicking = header.IsPartiallyReadyForPicking; retValItem.HasPickingStarted = header.HasPickingStarted; retValItem.HasPickingFinished = header.HasPickingFinished; retValItem.IsManuallyCleared_ForPicking = header.IsManuallyCleared_ForPicking; retValItem.ShipmentCreationDate = header.Creation_Timestamp; retValItem.ORD_DIS_DistributionOrder_HeaderID = distributionOrderHeader.ORD_DIS_DistributionOrder_HeaderID; retValItem.DistributionOrderNumber = distributionOrderHeader.DistributionOrderNumber; retValItem.DistributionOrderDate = distributionOrderHeader.DistributionOrderDate; retValItem.CMN_STR_CostCenterID = orm_CostCenter.CMN_STR_CostCenterID; retValItem.CostCenterName = orm_CostCenter.Name; retValItem.CMN_STR_OfficeID = orm_Office != null ? orm_Office.CMN_STR_OfficeID : Guid.Empty; retValItem.OfficeInternalName = orm_Office != null ? orm_Office.Office_InternalName : String.Empty; retVal.Add(retValItem); } retVal = retVal.Skip(Parameter.From).Take(Parameter.Size).ToList(); returnValue.Result = retVal.ToArray(); return(returnValue); #endregion UserCode }