protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5CC_DCC_1801 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { var returnValue = new FR_Guid(); var item = new ORM_CMN_STR_CostCenter(); if (Parameter.CMN_STR_CostCenterID != Guid.Empty) { var result = item.Load(Connection, Transaction, Parameter.CMN_STR_CostCenterID); if (result.Status != FR_Status.Success || item.CMN_STR_CostCenterID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } item.IsDeleted = true; return(new FR_Guid(item.Save(Connection, Transaction), item.CMN_STR_CostCenterID)); }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5CC_SCC_1744 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { var returnValue = new FR_Guid(); var item = new ORM_CMN_STR_CostCenter(); if (Parameter.CMN_STR_CostCenterID != Guid.Empty) { var result = item.Load(Connection, Transaction, Parameter.CMN_STR_CostCenterID); if (result.Status != FR_Status.Success || item.CMN_STR_CostCenterID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } if (Parameter.IsDeleted == true) { item.IsDeleted = true; return(new FR_Guid(item.Save(Connection, Transaction), item.CMN_STR_CostCenterID)); } //Creation specific parameters (Tenant, Account ... ) if (Parameter.CMN_STR_CostCenterID == Guid.Empty) { item.Tenant_RefID = securityTicket.TenantID; } item.InternalID = Parameter.InternalID; item.Name = Parameter.Name; return(new FR_Guid(item.Save(Connection, Transaction), item.CMN_STR_CostCenterID)); }
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_L5WA_GWAFWA_0907 Execute(DbConnection Connection, DbTransaction Transaction, P_L5WA_GWAFWA_0907 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5WA_GWAFWA_0907(); returnValue.Result = new L5WA_GWAFWA_0907(); L5WA_GWAFT_1201 result = new L5WA_GWAFT_1201(); ORM_CMN_STR_PPS_WorkArea item = new ORM_CMN_STR_PPS_WorkArea(); if (Parameter.WorkAreaID != Guid.Empty) { var resultWorkplace = item.Load(Connection, Transaction, Parameter.WorkAreaID); if (resultWorkplace.Status != FR_Status.Success || item.CMN_STR_PPS_WorkAreaID == 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_BPT_STA_SettingProfile_RefID = item.CMN_BPT_STA_SettingProfile_RefID; result.Office_RefID = item.Office_RefID; result.Parent_RefID = item.Parent_RefID; result.WorkAreaName = item.Name; result.WorkAreaDescription = item.Description; result.ShortName = item.ShortName; result.CMN_STR_PPS_WorkAreaID = item.CMN_STR_PPS_WorkAreaID; result.Default_StartWorkingHour = item.Default_StartWorkingHour; ORM_CMN_STR_PPS_WorkArea_2_CostCenter.Query workareaToCostcenterQuery = new ORM_CMN_STR_PPS_WorkArea_2_CostCenter.Query(); workareaToCostcenterQuery.WorkArea_RefID = Parameter.WorkAreaID; workareaToCostcenterQuery.Tenant_RefID = securityTicket.TenantID; workareaToCostcenterQuery.IsDeleted = false; List <ORM_CMN_STR_PPS_WorkArea_2_CostCenter> workareaToCostcenterList = ORM_CMN_STR_PPS_WorkArea_2_CostCenter.Query.Search(Connection, Transaction, workareaToCostcenterQuery); if (workareaToCostcenterList.Count != 0) { L5WA_GWAFT_1201_Costcenter costCenter = new L5WA_GWAFT_1201_Costcenter(); ORM_CMN_STR_CostCenter costCenterItem = new ORM_CMN_STR_CostCenter(); costCenterItem.Load(Connection, Transaction, workareaToCostcenterList[0].CostCenter_RefID); if (!costCenterItem.IsDeleted) { costCenter.AssignmentID = workareaToCostcenterList[0].AssignmentID; costCenter.CMN_STR_CostCenterID = workareaToCostcenterList[0].CostCenter_RefID; costCenter.CostcenterName = costCenterItem.Name; costCenter.InternalID = costCenterItem.InternalID; result.Costcenter = costCenter; } } var responsiblePersonsQuery = new ORM_CMN_STR_PPS_WorkArea_ResponsiblePerson.Query(); responsiblePersonsQuery.Tenant_RefID = securityTicket.TenantID; responsiblePersonsQuery.WorkArea_RefID = item.CMN_STR_PPS_WorkAreaID; responsiblePersonsQuery.IsDeleted = false; var responsiblePersonsList = ORM_CMN_STR_PPS_WorkArea_ResponsiblePerson.Query.Search(Connection, Transaction, responsiblePersonsQuery); List <L5WA_GWAFT_1201_ResponsiblePersons> responsiblePresonsResultList = new List <L5WA_GWAFT_1201_ResponsiblePersons>(); foreach (var responsiblePerson in responsiblePersonsList) { L5WA_GWAFT_1201_ResponsiblePersons responsiblePersonResult = new L5WA_GWAFT_1201_ResponsiblePersons(); responsiblePersonResult.CMN_BPT_EMP_EmployeeID = responsiblePerson.CMN_BPT_EMP_Employee_RefID; responsiblePersonResult.CMN_STR_PPS_WorkArea_ResponsiblePersonID = responsiblePerson.CMN_STR_PPS_WorkArea_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; responsiblePersonResult.CMN_PER_PersonInfoID = person.CMN_PER_PersonInfoID; responsiblePersonResult.WorkArea_RefID = item.CMN_STR_PPS_WorkAreaID; responsiblePresonsResultList.Add(responsiblePersonResult); } result.ResponsiblePersons = responsiblePresonsResultList.ToArray(); returnValue.Result.workarea = result; //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 }