protected static FR_L3TX_GTOFTO_1006 Execute(DbConnection Connection, DbTransaction Transaction, P_L3TX_GTOFTO_1006 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L3TX_GTOFTO_1006(); returnValue.Result = new L3TX_GTOFTO_1006(); var item = new ORM_ACC_TAX_TaxOffice(); returnValue.Result.TaxOffice = new L3TX_GTOFT_0914(); var result = item.Load(Connection, Transaction, Parameter.ACC_TAX_TaxOfficeID); ORM_CMN_BPT_BusinessParticipant bparticipant = new ORM_CMN_BPT_BusinessParticipant(); bparticipant.Load(Connection, Transaction, item.CMN_BPT_BusinessParticipant_RefID); returnValue.Result.TaxOffice.DisplayName = bparticipant.DisplayName; ORM_CMN_COM_CompanyInfo companyInfo = new ORM_CMN_COM_CompanyInfo(); companyInfo.Load(Connection, Transaction, bparticipant.IfCompany_CMN_COM_CompanyInfo_RefID); ORM_CMN_UniversalContactDetail ucd = new ORM_CMN_UniversalContactDetail(); ucd.Load(Connection, Transaction, companyInfo.Contact_UCD_RefID); returnValue.Result.TaxOffice.VATIdentificationNumber = companyInfo.VATIdentificationNumber; returnValue.Result.TaxOffice.ACC_TAX_TaxOfficeID = item.ACC_TAX_TaxOfficeID; returnValue.Result.TaxOffice.Country_639_1_ISOCode = ucd.Country_639_1_ISOCode; //Put your code here return(returnValue); #endregion UserCode }
protected static FR_L5EM_GENFT_1344_Array Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5EM_GENFT_1344_Array(); List <L5EM_GENFT_1344> employeeResultList = new List <L5EM_GENFT_1344>(); ORM_CMN_BPT_EMP_Employee.Query employeeQuery = new ORM_CMN_BPT_EMP_Employee.Query(); employeeQuery.IsDeleted = false; employeeQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_BPT_EMP_Employee> employeeList = ORM_CMN_BPT_EMP_Employee.Query.Search(Connection, Transaction, employeeQuery); foreach (var employeeItem in employeeList) { L5EM_GENFT_1344 result = new L5EM_GENFT_1344(); ORM_CMN_BPT_EMP_Employee employee = new ORM_CMN_BPT_EMP_Employee(); employee.Load(Connection, Transaction, employeeItem.CMN_BPT_EMP_EmployeeID); result.CMN_BPT_EMP_EmployeeID = employeeItem.CMN_BPT_EMP_EmployeeID; ORM_CMN_BPT_BusinessParticipant businessParticipant = new ORM_CMN_BPT_BusinessParticipant(); businessParticipant.Load(Connection, Transaction, employee.BusinessParticipant_RefID); ORM_CMN_PER_PersonInfo personInfo = new ORM_CMN_PER_PersonInfo(); personInfo.Load(Connection, Transaction, businessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID); result.FirstName = personInfo.FirstName; result.LastName = personInfo.LastName; employeeResultList.Add(result); //Employee workplace history ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query employeeWorkplaceAssignmentsQuery = new ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query(); employeeWorkplaceAssignmentsQuery.CMN_BPT_EMP_Employee_RefID = employee.CMN_BPT_EMP_EmployeeID; employeeWorkplaceAssignmentsQuery.Tenant_RefID = securityTicket.TenantID; employeeWorkplaceAssignmentsQuery.IsDeleted = false; List <ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment> employeeWorkplaceAssignemntsList = ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query.Search(Connection, Transaction, employeeWorkplaceAssignmentsQuery); List <L5EM_GENFT_1344_EmployeeWorkplaceHistory> employeeWorkplaceAssignments = new List <L5EM_GENFT_1344_EmployeeWorkplaceHistory>(); foreach (var workplaceAssignemns in employeeWorkplaceAssignemntsList) { L5EM_GENFT_1344_EmployeeWorkplaceHistory item = new L5EM_GENFT_1344_EmployeeWorkplaceHistory(); item.BoundTo_Workplace_RefID = workplaceAssignemns.BoundTo_Workplace_RefID; item.CMN_BPT_EMP_Employee_PlanGroup_RefID = workplaceAssignemns.CMN_BPT_EMP_Employee_PlanGroup_RefID; item.CMN_BPT_EMP_Employee_WorkplaceAssignmentID = workplaceAssignemns.CMN_BPT_EMP_Employee_WorkplaceAssignment; item.Default_BreakTime_Template_RefID = workplaceAssignemns.Default_BreakTime_Template_RefID; item.IsBreakTimeCalculated_Actual = workplaceAssignemns.IsBreakTimeCalculated_Actual; item.IsBreakTimeCalculated_Planning = workplaceAssignemns.IsBreakTimeCalculated_Planning; item.SequenceNumber = workplaceAssignemns.SequenceNumber; item.WorkplaceAssignment_StartDate = workplaceAssignemns.WorkplaceAssignment_StartDate; employeeWorkplaceAssignments.Add(item); } result.EmployeeWorkplaceHistory = employeeWorkplaceAssignments.ToArray(); } returnValue.Result = employeeResultList.ToArray(); //Put your code here return(returnValue); #endregion UserCode }
protected static FR_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L6MRMS_SEtR_1606 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Base(); List <ORM_MRS_RUN_MeasurementRun_AccountDownloadCode> downloadCodes = ORM_MRS_RUN_MeasurementRun_AccountDownloadCode.Query.Search(Connection, Transaction, new ORM_MRS_RUN_MeasurementRun_AccountDownloadCode.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, MeasurementRun_RefID = Parameter.ReadingSessionId }); foreach (var downloadCode in downloadCodes) { ORM_CMN_BPT_BusinessParticipant businessParticipant = new ORM_CMN_BPT_BusinessParticipant(); var bpLoad = businessParticipant.Load(Connection, Transaction, downloadCode.Account_RefID); if (bpLoad.Status != FR_Status.Success) { continue; } ORM_CMN_BPT_BusinessParticipant_AccessCode bpAccountCode = ORM_CMN_BPT_BusinessParticipant_AccessCode.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant_AccessCode.Query() { Tenant_RefID = securityTicket.TenantID, BusinessParticipant_RefID = businessParticipant.CMN_BPT_BusinessParticipantID }).SingleOrDefault(); if (bpAccountCode == null) { continue; } ORM_CMN_PER_PersonInfo personInfo = new ORM_CMN_PER_PersonInfo(); var piLoad = personInfo.Load(Connection, Transaction, businessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID); if (piLoad.Status != FR_Status.Success) { continue; } //sending email string subject = Parameter.EmailSubjectTemplate; string body = String.Format ( Parameter.EmailBodyTemplate, personInfo.FirstName, personInfo.LastName, downloadCode.DownloadCode, bpAccountCode.Code ); EmailUtils.SendMail(personInfo.PrimaryEmail, subject, body); } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3L_SLP_1114 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); //Put your code here // CREATE NEW if (Parameter.LogisticProviderID == Guid.Empty) { ORM_CMN_BPT_BusinessParticipant bp = new ORM_CMN_BPT_BusinessParticipant(); bp.CMN_BPT_BusinessParticipantID = Guid.NewGuid(); bp.DisplayName = Parameter.Name; bp.IsCompany = true; bp.Tenant_RefID = securityTicket.TenantID; bp.Save(Connection, Transaction); ORM_LOG_LogisticsProvider logisticProvider = new ORM_LOG_LogisticsProvider(); logisticProvider.LOG_LogisticsProviderID = Guid.NewGuid(); logisticProvider.Ext_CMN_BPT_BusinessParticipant_RefID = bp.CMN_BPT_BusinessParticipantID; logisticProvider.IsProviding_TransportServices = Parameter.IsProvidingTransportServices; logisticProvider.IsTrackingAvailable = Parameter.IsTrackingAvailable; logisticProvider.Tenant_RefID = securityTicket.TenantID; logisticProvider.Save(Connection, Transaction); returnValue.Result = logisticProvider.LOG_LogisticsProviderID; } // UPDATE EXISTING else { ORM_LOG_LogisticsProvider logisticProvider = new ORM_LOG_LogisticsProvider(); logisticProvider.Load(Connection, Transaction, Parameter.LogisticProviderID); logisticProvider.IsProviding_TransportServices = Parameter.IsProvidingTransportServices; logisticProvider.IsTrackingAvailable = Parameter.IsTrackingAvailable; logisticProvider.Save(Connection, Transaction); ORM_CMN_BPT_BusinessParticipant bp = new ORM_CMN_BPT_BusinessParticipant(); bp.Load(Connection, Transaction, logisticProvider.Ext_CMN_BPT_BusinessParticipant_RefID); bp.DisplayName = Parameter.Name; bp.Save(Connection, Transaction); returnValue.Result = Parameter.LogisticProviderID; } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5US_SSU_1847 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); var userAccount = new ORM_USR_Account(); var result = userAccount.Load(Connection, Transaction, Parameter.USR_AccountID); if (result.Status == FR_Status.Success) { //Get business participant via userAccount var businessParticipant = new ORM_CMN_BPT_BusinessParticipant(); businessParticipant.Load(Connection, Transaction, userAccount.BusinessParticipant_RefID); //Load person var personInfo = new ORM_CMN_PER_PersonInfo(); personInfo.Load(Connection, Transaction, businessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID); //Load communication contacts for person P_L2CN_GCCfPI_1222 contactsParam = new P_L2CN_GCCfPI_1222(); contactsParam.PersonInfoID = personInfo.CMN_PER_PersonInfoID; var contactsForPersonInfo = cls_Get_ComunicationContacts_for_PersonInfoID.Invoke(Connection, Transaction, contactsParam, securityTicket).Result.ToList(); if (!Parameter.IsInitialSave) { if (Parameter.IsDeleted) { #region Delete var queryApplicationSubscription = new ORM_CMN_Account_ApplicationSubscription.Query(); queryApplicationSubscription.Application_RefID = Parameter.ApplicationID; queryApplicationSubscription.Account_RefID = userAccount.USR_AccountID; queryApplicationSubscription.Tenant_RefID = securityTicket.TenantID; var foundApplicationSubscription = ORM_CMN_Account_ApplicationSubscription.Query.SoftDelete(Connection, Transaction, queryApplicationSubscription); return(new FR_Guid(FR_Base.Status_OK, userAccount.USR_AccountID)); #endregion } #region Edit personInfo.FirstName = Parameter.FirstName_ContactPerson; personInfo.LastName = Parameter.LastName_ContactPerson; personInfo.Save(Connection, Transaction); var employeeTemp = ORM_CMN_BPT_EMP_Employee.Query.Search(Connection, Transaction, new ORM_CMN_BPT_EMP_Employee.Query() { BusinessParticipant_RefID = businessParticipant.CMN_BPT_BusinessParticipantID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (employeeTemp == null) { var newEmployee = new ORM_CMN_BPT_EMP_Employee(); newEmployee.CMN_BPT_EMP_EmployeeID = Guid.NewGuid(); newEmployee.BusinessParticipant_RefID = businessParticipant.CMN_BPT_BusinessParticipantID; newEmployee.StandardFunction = "APOAdminEmployee"; newEmployee.Tenant_RefID = securityTicket.TenantID; newEmployee.Save(Connection, Transaction); } var address = new ORM_CMN_Address(); address.Load(Connection, Transaction, personInfo.Address_RefID); address.Street_Name = Parameter.Street_Name; address.Street_Number = Parameter.Street_Number; address.City_Name = Parameter.Town; address.City_PostalCode = Parameter.ZIP; address.Save(Connection, Transaction); try { //telephone var telephone = contactsForPersonInfo.Where(i => i.Type == EnumUtils.GetEnumDescription(EComunactionContactType.Phone)) .First().Contacts; if (telephone.Count() == 1) { var contactID = telephone[0].CMN_PER_CommunicationContactID; var contactTelephone = new ORM_CMN_PER_CommunicationContact(); contactTelephone.Load(Connection, Transaction, contactID); contactTelephone.Content = Parameter.Contact_Telephone; contactTelephone.Save(Connection, Transaction); } } catch { //Log this } #region CommentedUsefull-PreviousWayOfContactEmailHandling //try //{ // //email // var email = contactsForPersonInfo.Where(i => i.Type == EnumUtils.GetEnumDescription(EComunactionContactType.Email)) // .First().Contacts; // if (email.Count() == 1) // { // var contactID = email[0].CMN_PER_CommunicationContactID; // var contactEmail = new ORM_CMN_PER_CommunicationContact(); // contactEmail.Load(Connection, Transaction, contactID); // contactEmail.Content = Parameter.Contact_Email; // contactEmail.Save(Connection, Transaction); // } //} //catch //{ // //Log this //} #endregion #endregion } #region SaveGroup var userAccountToGroup = ORM_USR_Account_2_Group.Query.Search(Connection, Transaction, new ORM_USR_Account_2_Group.Query() { USR_Account_RefID = userAccount.USR_AccountID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (userAccountToGroup == null) { var newGroup = new ORM_USR_Account_2_Group(); newGroup.AssignmentID = Guid.NewGuid(); newGroup.USR_Account_RefID = userAccount.USR_AccountID; newGroup.USR_Group_RefID = Parameter.USR_GroupID; newGroup.Creation_Timestamp = DateTime.Now; newGroup.Tenant_RefID = securityTicket.TenantID; newGroup.Save(Connection, Transaction); } else { userAccountToGroup.USR_Group_RefID = Parameter.USR_GroupID; userAccountToGroup.Save(Connection, Transaction); } #endregion #region SaveEmployee var employee = ORM_CMN_BPT_EMP_Employee.Query.Search(Connection, Transaction, new ORM_CMN_BPT_EMP_Employee.Query() { BusinessParticipant_RefID = businessParticipant.CMN_BPT_BusinessParticipantID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (employee == null) { var newEmployee = new ORM_CMN_BPT_EMP_Employee(); newEmployee.CMN_BPT_EMP_EmployeeID = Guid.NewGuid(); newEmployee.BusinessParticipant_RefID = businessParticipant.CMN_BPT_BusinessParticipantID; newEmployee.StandardFunction = "APOAdminEmployee"; newEmployee.Tenant_RefID = securityTicket.TenantID; newEmployee.Save(Connection, Transaction); } #endregion #region CreateOrUpdateContactEmail var emailTypeProperty = EnumUtils.GetEnumDescription(EComunactionContactType.Email); var contactEmailTypeQuery = new ORM_CMN_PER_CommunicationContact_Type.Query(); contactEmailTypeQuery.Type = emailTypeProperty; contactEmailTypeQuery.Tenant_RefID = securityTicket.TenantID; var contactEmailType = ORM_CMN_PER_CommunicationContact_Type.Query.Search(Connection, Transaction, contactEmailTypeQuery).FirstOrDefault(); //Search for default contact email and create it if don't exist var defaultContactEmailQuery = new ORM_CMN_PER_CommunicationContact.Query(); defaultContactEmailQuery.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; defaultContactEmailQuery.Contact_Type = contactEmailType.CMN_PER_CommunicationContact_TypeID; defaultContactEmailQuery.Tenant_RefID = securityTicket.TenantID; var defaultContactEmail = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, defaultContactEmailQuery).FirstOrDefault(); if (defaultContactEmail == null) { defaultContactEmail = new ORM_CMN_PER_CommunicationContact(); defaultContactEmail.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; defaultContactEmail.Contact_Type = contactEmailType.CMN_PER_CommunicationContact_TypeID; defaultContactEmail.IsDefaultForContactType = true; defaultContactEmail.Tenant_RefID = securityTicket.TenantID; } defaultContactEmail.Content = Parameter.Contact_Email; defaultContactEmail.IsDefaultForContactType = true; defaultContactEmail.Save(Connection, Transaction); #endregion } else { FR_Guid error = new FR_Guid(); error.ErrorMessage = "No Such ID."; error.Status = FR_Status.Error_Internal; return(error); } return(new FR_Guid(FR_Base.Status_OK, userAccount.USR_AccountID)); #endregion UserCode }
protected static FR_L5RS_CSaRSPfH_0449 Execute(DbConnection Connection, DbTransaction Transaction, P_L5RS_CSaRSPfH_0449 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5RS_CSaRSPfH_0449(); returnValue.Result = new L5RS_CSaRSPfH_0449(); FR_Base resultHeader, resultPosition, resultReturnPosition; if (Parameter.Positions.Count() <= 0) { returnValue.Status = FR_Status.Success; returnValue.Result = null; return(returnValue); } #region Load Shipment Header and calculate Total Price decimal totalValueWithoutTax = 0; #region Load Shipment Header var shipmentHeader = new ORM_LOG_SHP_Shipment_Header(); var result = shipmentHeader.Load(Connection, Transaction, Parameter.Positions[0].ShipmentHeaderID); if (result.Status != FR_Status.Success) { returnValue.Status = FR_Status.Error_Internal; returnValue.Result = null; return(returnValue); } #endregion #region Load Shipment Header Positions And Calculate Total Value var shipmentPositions = ORM_LOG_SHP_Shipment_Position.Query.Search( Connection, Transaction, new ORM_LOG_SHP_Shipment_Position.Query() { LOG_SHP_Shipment_Header_RefID = shipmentHeader.LOG_SHP_Shipment_HeaderID, Tenant_RefID = securityTicket.TenantID }).ToList(); foreach (var position in shipmentPositions) { totalValueWithoutTax += position.ShipmentPosition_ValueWithoutTax; } #endregion shipmentHeader.ShipmentHeader_ValueWithoutTax = totalValueWithoutTax; #endregion var resultShipmentPositionsIDs = new List <Guid>(); var resultReturnShipmentPositionIDs = new List <Guid>(); foreach (P_L5RS_CSaRSPfH_0449a position in Parameter.Positions) { #region Create Shipment Position Object var newShipmentPositionObject = new ORM_LOG_SHP_Shipment_Position(); newShipmentPositionObject.CMN_PRO_Product_RefID = position.ProductId; newShipmentPositionObject.Creation_Timestamp = DateTime.Now; newShipmentPositionObject.LOG_SHP_Shipment_Header_RefID = position.ShipmentHeaderID; newShipmentPositionObject.LOG_SHP_Shipment_PositionID = Guid.NewGuid(); newShipmentPositionObject.QuantityToShip = position.Quantity; newShipmentPositionObject.ShipmentPosition_ValueWithoutTax = position.PricePerUnit * position.Quantity; newShipmentPositionObject.ShipmentPosition_PricePerUnitValueWithoutTax = position.PricePerUnit; newShipmentPositionObject.Tenant_RefID = securityTicket.TenantID; shipmentHeader.ShipmentHeader_ValueWithoutTax += newShipmentPositionObject.ShipmentPosition_ValueWithoutTax; #endregion #region Create ReturnShipment Position Object var newReturnShipmentPositionObject = new ORM_LOG_SHP_ReturnShipment_Position(); newReturnShipmentPositionObject.Creation_Timestamp = DateTime.Now; newReturnShipmentPositionObject.Ext_Shipment_Position_RefID = newShipmentPositionObject.LOG_SHP_Shipment_PositionID; newReturnShipmentPositionObject.LOG_SHP_ReturnShipment_PositionID = Guid.NewGuid(); newReturnShipmentPositionObject.ReturnPolicy_RefID = position.ReturnPolicyId; newReturnShipmentPositionObject.ReturnProductOriginatedFromReceiptPosition_RefID = position.ReceiptPositionId; newReturnShipmentPositionObject.ReturnShipment_Header_RefID = position.ReturnShipmentHeaderID; newReturnShipmentPositionObject.Tenant_RefID = securityTicket.TenantID; #endregion #region Save Position resultPosition = newShipmentPositionObject.Save(Connection, Transaction); resultReturnPosition = newReturnShipmentPositionObject.Save(Connection, Transaction); if (resultPosition.Status != FR_Status.Success || resultReturnPosition.Status != FR_Status.Success) { returnValue.Status = FR_Status.Error_Internal; returnValue.Result = null; return(returnValue); } resultShipmentPositionsIDs.Add(newShipmentPositionObject.LOG_SHP_Shipment_PositionID); resultReturnShipmentPositionIDs.Add(newReturnShipmentPositionObject.LOG_SHP_ReturnShipment_PositionID); #endregion } #region Update Shipment Header with Total Value resultHeader = shipmentHeader.Save(Connection, Transaction); if (resultHeader.Status != FR_Status.Success) { returnValue.Status = FR_Status.Error_Internal; returnValue.Result = null; return(returnValue); } #endregion #region Fetch ShipmentHeader SupplierName var supplierBusinessParticipant = new ORM_CMN_BPT_BusinessParticipant(); supplierBusinessParticipant.Load(Connection, Transaction, shipmentHeader.RecipientBusinessParticipant_RefID); #endregion returnValue.Status = FR_Status.Success; returnValue.Result.ShipmentPositionIDs = resultShipmentPositionsIDs.ToArray(); returnValue.Result.ReturnShipmentPositionIDs = resultReturnShipmentPositionIDs.ToArray(); returnValue.Result.ShipmentHeaderSupplierName = supplierBusinessParticipant == null ? string.Empty : supplierBusinessParticipant.DisplayName; returnValue.Result.ShipmentHeaderNumber = shipmentHeader.ShipmentHeader_Number; returnValue.Result.ShipmentHeaderTotalValue = shipmentHeader.ShipmentHeader_ValueWithoutTax; return(returnValue); #endregion UserCode }
protected static FR_L5EM_GEFU_445 Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_L5EM_GEFU_445(); L5EM_GEFU_445 result = new L5EM_GEFU_445(); ORM_USR_Account account = new ORM_USR_Account(); account.Load(Connection, Transaction, securityTicket.AccountID); if (account.USR_AccountID == Guid.Empty) { return(null); } ORM_CMN_BPT_EMP_Employee.Query employeeQuery = new ORM_CMN_BPT_EMP_Employee.Query(); employeeQuery.IsDeleted = false; employeeQuery.Tenant_RefID = securityTicket.TenantID; employeeQuery.BusinessParticipant_RefID = account.BusinessParticipant_RefID; List <ORM_CMN_BPT_EMP_Employee> employeeList = ORM_CMN_BPT_EMP_Employee.Query.Search(Connection, Transaction, employeeQuery); if (employeeList.Count != 0) { ORM_CMN_BPT_EMP_Employee employee = employeeList[0]; result.CMN_BPT_EMP_EmployeeID = employee.CMN_BPT_EMP_EmployeeID; result.Staff_Number = employee.Staff_Number; result.StandardFunction = employee.StandardFunction; ORM_CMN_BPT_BusinessParticipant businessParticipant = new ORM_CMN_BPT_BusinessParticipant(); businessParticipant.Load(Connection, Transaction, employee.BusinessParticipant_RefID); ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query employeeWorkplaceAssignmentsQuery = new ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query(); employeeWorkplaceAssignmentsQuery.CMN_BPT_EMP_Employee_RefID = employee.CMN_BPT_EMP_EmployeeID; employeeWorkplaceAssignmentsQuery.Tenant_RefID = securityTicket.TenantID; employeeWorkplaceAssignmentsQuery.IsDeleted = false; List <ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment> employeeWorkplaceAssignemntsList = ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query.Search(Connection, Transaction, employeeWorkplaceAssignmentsQuery); List <L5EM_GEFU_445_EmployeeWorkplaceHistory> employeeWorkplaceAssignments = new List <L5EM_GEFU_445_EmployeeWorkplaceHistory>(); foreach (var workplaceAssignemns in employeeWorkplaceAssignemntsList) { L5EM_GEFU_445_EmployeeWorkplaceHistory item = new L5EM_GEFU_445_EmployeeWorkplaceHistory(); item.BoundTo_Workplace_RefID = workplaceAssignemns.BoundTo_Workplace_RefID; item.CMN_BPT_EMP_Employee_PlanGroup_RefID = workplaceAssignemns.CMN_BPT_EMP_Employee_PlanGroup_RefID; item.CMN_BPT_EMP_Employee_WorkplaceAssignmentID = workplaceAssignemns.CMN_BPT_EMP_Employee_WorkplaceAssignment; item.Default_BreakTime_Template_RefID = workplaceAssignemns.Default_BreakTime_Template_RefID; item.IsBreakTimeCalculated_Actual = workplaceAssignemns.IsBreakTimeCalculated_Actual; item.IsBreakTimeCalculated_Planning = workplaceAssignemns.IsBreakTimeCalculated_Planning; item.SequenceNumber = workplaceAssignemns.SequenceNumber; item.WorkplaceAssignment_StartDate = workplaceAssignemns.WorkplaceAssignment_StartDate; employeeWorkplaceAssignments.Add(item); } result.EmployeeWorkplaceHistory = employeeWorkplaceAssignments.ToArray(); } returnValue.Result = result; //Put your code here return(returnValue); #endregion UserCode }
protected static FR_L6BL_GADfBSBR_1010 Execute(DbConnection Connection, DbTransaction Transaction, P_L6BL_GADfBSBR_1010 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6BL_GADfBSBR_1010(); //Put your code here #region Retrieving bill header. ORM_BIL_BillHeader billHeader = new ORM_BIL_BillHeader(); FR_Base billHeaderLoad = billHeader.Load(Connection, Transaction, Parameter.BillHeaderID); if (billHeaderLoad.Status != FR_Status.Success) { Exception ex = new Exception(billHeaderLoad.ErrorMessage); return(new FR_L6BL_GADfBSBR_1010(ex)); } #endregion #region Retrieving universal contact details. ORM_CMN_UniversalContactDetail universalContactDetails = new ORM_CMN_UniversalContactDetail(); FR_Base universalContactDetailsLoad = universalContactDetails.Load(Connection, Transaction, billHeader.BillingAddress_UCD_RefID); if (universalContactDetailsLoad.Status != FR_Status.Success) { Exception ex = new Exception(universalContactDetailsLoad.ErrorMessage); return(new FR_L6BL_GADfBSBR_1010(ex)); } #endregion #region Retrieving business participants details. ORM_CMN_BPT_BusinessParticipant businessParticipant = new ORM_CMN_BPT_BusinessParticipant(); FR_Base businessParticipantLoad = businessParticipant.Load(Connection, Transaction, billHeader.BillRecipient_BuisnessParticipant_RefID); if (businessParticipantLoad.Status != FR_Status.Success) { Exception ex = new Exception(businessParticipantLoad.ErrorMessage); return(new FR_L6BL_GADfBSBR_1010(ex)); } #endregion #region Retrieving customer details. ORM_CMN_BPT_CTM_Customer customer = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, new ORM_CMN_BPT_CTM_Customer.Query { Ext_BusinessParticipant_RefID = businessParticipant.CMN_BPT_BusinessParticipantID }).FirstOrDefault(); if (customer == null) { Exception ex = new Exception("Retrieving ORM_CMN_BPT_CTM_Customer details failed."); return(new FR_L6BL_GADfBSBR_1010(ex)); } #endregion #region Retriving method of payments (taking first one) ORM_BIL_BillHeader_MethodOfPayment methodOfPayment = ORM_BIL_BillHeader_MethodOfPayment.Query.Search(Connection, Transaction, new ORM_BIL_BillHeader_MethodOfPayment.Query { BIL_BillHeader_RefID = billHeader.BIL_BillHeaderID }).FirstOrDefault(); #endregion #region Retrieving payment type ORM_ACC_PAY_Type type = null; if (methodOfPayment != null) { type = ORM_ACC_PAY_Type.Query.Search(Connection, Transaction, new ORM_ACC_PAY_Type.Query { ACC_PAY_TypeID = methodOfPayment.ACC_PAY_Type_RefID }).Single(); } #endregion #region Retrieving payment condition ORM_ACC_PAY_Condition condition = ORM_ACC_PAY_Condition.Query.Search(Connection, Transaction, new ORM_ACC_PAY_Condition.Query { ACC_PAY_ConditionID = billHeader.BillHeader_PaymentCondition_RefID }).FirstOrDefault(); #endregion #region Retrieving bill positions var allBillPositions = cls_Get_AllPositions_with_Articles_for_BillHeader.Invoke(Connection, Transaction, new P_L5BL_GAPwAfBH_1118 { BillHeaderID = billHeader.BIL_BillHeaderID }, securityTicket).Result; #endregion returnValue.Result = new L6BL_GADfBSBR_1010(); returnValue.Result.BillShipmentBasedReportHeaderDetails = new L6BL_GADfBSBR_1010a(); returnValue.Result.BillShipmentBasedReportHeaderDetails.BillHeaderComment = billHeader.BillComment; returnValue.Result.BillShipmentBasedReportHeaderDetails.BillHeaderDate = billHeader.DateOnBill; returnValue.Result.BillShipmentBasedReportHeaderDetails.BillHeaderNumber = billHeader.BillNumber; returnValue.Result.BillShipmentBasedReportHeaderDetails.BillHeaderTotalValue_BeforeTax = billHeader.TotalValue_BeforeTax; returnValue.Result.BillShipmentBasedReportHeaderDetails.BillHeaderTotalValue_IncludingTax = billHeader.TotalValue_IncludingTax; if (condition != null) { returnValue.Result.BillShipmentBasedReportHeaderDetails.BillHeaderPaymentDeadline = billHeader.DateOnBill.AddDays(condition.MaximumPaymentTreshold_InDays); } if (type != null) { returnValue.Result.BillShipmentBasedReportHeaderDetails.BillHeaderPaymentType = type.PaymentType_Name; } if (businessParticipant != null) { returnValue.Result.BillShipmentBasedReportHeaderDetails.RecepientBusinessParticipantDisplayName = businessParticipant.DisplayName; } if (customer != null) { returnValue.Result.BillShipmentBasedReportHeaderDetails.RecepientBusinessParticipantNumber = customer.InternalCustomerNumber; } if (universalContactDetails != null) { returnValue.Result.BillShipmentBasedReportHeaderDetails.RecepientBusinessParticipantStreetName = universalContactDetails.Street_Name; returnValue.Result.BillShipmentBasedReportHeaderDetails.RecepientBusinessParticipantStreetNumber = universalContactDetails.Street_Number; returnValue.Result.BillShipmentBasedReportHeaderDetails.RecepientBusinessParticipantCity = universalContactDetails.Town; returnValue.Result.BillShipmentBasedReportHeaderDetails.RecepientBusinessParticipantZipCode = universalContactDetails.ZIP; } #region bill positions returnValue.Result.BillPositions = null; List <L6BL_GADfBSBR_1010bp> unsortedBillPositionsTemp = new List <L6BL_GADfBSBR_1010bp>(); if (allBillPositions.ShipmentBillPositions != null) { var unsortedBillPositions = allBillPositions.ShipmentBillPositions.Where(x => x.BillPosition.CMN_BPT_CTM_OrganizationalUnitID == Guid.Empty).ToList(); foreach (L5BL_GBPwAfBH_1848 unsortedBillPosition in unsortedBillPositions) { L6BL_GADfBSBR_1010bp tempBillPosition = new L6BL_GADfBSBR_1010bp(); tempBillPosition.BIL_BillPositionID = unsortedBillPosition.BillPosition.BIL_BillPositionID; tempBillPosition.BillPosition_ValuePerUnit_BeforeTax = (double)unsortedBillPosition.BillPosition.PositionPricePerUnitValue_BeforeTax; tempBillPosition.BillPosition_ValuePerUnit_AfterTax = (double)unsortedBillPosition.BillPosition.PositionPricePerUnitValue_IncludingTax; tempBillPosition.ACC_TAX_TaxeID = unsortedBillPosition.Article.Taxes.First().ACC_TAX_TaxeID; tempBillPosition.TaxRate = unsortedBillPosition.Article.Taxes.First().TaxRate; tempBillPosition.TaxName_DictID = unsortedBillPosition.Article.Taxes.First().TaxName_DictID; tempBillPosition.HeaderID = unsortedBillPosition.BillPosition.LOG_SHP_Shipment_HeaderID; tempBillPosition.Header_Number = unsortedBillPosition.BillPosition.ShipmentHeader_Number; tempBillPosition.Creation_Timestamp = unsortedBillPosition.BillPosition.LOG_SHP_ShipmentHeader_Creation_Timestamp; tempBillPosition.IsShipmentPosition = true; tempBillPosition.Quantity = unsortedBillPosition.BillPosition.Quantity; unsortedBillPositionsTemp.Add(tempBillPosition); } } // now for customer orders return if (allBillPositions.OrderReturnBillPosition != null) { var unsortedCustomerOrderReturnPositions = allBillPositions.OrderReturnBillPosition.Where(x => x.OrderReturnBillPosition.CMN_BPT_CTM_OrganizationalUnitID == Guid.Empty).OrderBy(x => x.OrderReturnBillPosition.DateOfCustomerReturn).ToList(); foreach (L5OR_GCORPwAfBH_1051 unsortedBillPosition in unsortedCustomerOrderReturnPositions) { L6BL_GADfBSBR_1010bp tempBillPosition = new L6BL_GADfBSBR_1010bp(); tempBillPosition.BIL_BillPositionID = unsortedBillPosition.OrderReturnBillPosition.BIL_BillPositionID; tempBillPosition.BillPosition_ValuePerUnit_BeforeTax = (double)unsortedBillPosition.OrderReturnBillPosition.PositionPricePerUnitValue_BeforeTax; tempBillPosition.BillPosition_ValuePerUnit_AfterTax = (double)unsortedBillPosition.OrderReturnBillPosition.PositionPricePerUnitValue_IncludingTax; tempBillPosition.ACC_TAX_TaxeID = unsortedBillPosition.Article.Taxes.First().ACC_TAX_TaxeID; tempBillPosition.TaxRate = unsortedBillPosition.Article.Taxes.First().TaxRate; tempBillPosition.TaxName_DictID = unsortedBillPosition.Article.Taxes.First().TaxName_DictID; tempBillPosition.HeaderID = unsortedBillPosition.OrderReturnBillPosition.ORD_CUO_CustomerOrderReturn_HeaderID; tempBillPosition.Header_Number = unsortedBillPosition.OrderReturnBillPosition.CustomerOrderReturnNumber; tempBillPosition.Creation_Timestamp = unsortedBillPosition.OrderReturnBillPosition.Creation_Timestamp; tempBillPosition.IsShipmentPosition = false; tempBillPosition.Quantity = unsortedBillPosition.OrderReturnBillPosition.Quantity; unsortedBillPositionsTemp.Add(tempBillPosition); } } returnValue.Result.BillPositions = unsortedBillPositionsTemp.ToArray(); #region bill position organisation unit returnValue.Result.OrganizationalUnits = null; List <L6BL_GADfBSBR_1010bo> organizationalUnitsTemp = new List <L6BL_GADfBSBR_1010bo>(); if (allBillPositions.ShipmentBillPositions != null) { List <L5BL_GBPwAfBH_1848> sortedBillPositions = allBillPositions.ShipmentBillPositions.Where(x => x.BillPosition.CMN_BPT_CTM_OrganizationalUnitID != Guid.Empty).ToList(); foreach (L5BL_GBPwAfBH_1848 sortedBillPosition in sortedBillPositions) { L6BL_GADfBSBR_1010bo tempOrganizationalUnit = organizationalUnitsTemp.FirstOrDefault(organizationalUnitTemp => organizationalUnitTemp.CMN_BPT_CTM_OrganizationalUnitID == sortedBillPosition.BillPosition.CMN_BPT_CTM_OrganizationalUnitID); if (tempOrganizationalUnit == null) { tempOrganizationalUnit = new L6BL_GADfBSBR_1010bo(); tempOrganizationalUnit.BillPositions = new L6BL_GADfBSBR_1010bp[0]; tempOrganizationalUnit.CMN_BPT_CTM_OrganizationalUnitID = sortedBillPosition.BillPosition.CMN_BPT_CTM_OrganizationalUnitID; tempOrganizationalUnit.OrganizationalUnit_SimpleName = sortedBillPosition.BillPosition.OrganizationalUnit_SimpleName; tempOrganizationalUnit.OrganizationalUnit_Name = sortedBillPosition.BillPosition.OrganizationalUnit_Name_DictID; tempOrganizationalUnit.OrganizationalUnit_Description = sortedBillPosition.BillPosition.OrganizationalUnit_Name_DictID; tempOrganizationalUnit.InternalOrganizationalUnitNumber = sortedBillPosition.BillPosition.InternalOrganizationalUnitNumber; tempOrganizationalUnit.InternalOrganizationalUnitSimpleName = sortedBillPosition.BillPosition.InternalOrganizationalUnitSimpleName; tempOrganizationalUnit.ExternalOrganizationalUnitNumber = sortedBillPosition.BillPosition.ExternalOrganizationalUnitNumber; organizationalUnitsTemp.Add(tempOrganizationalUnit); } L6BL_GADfBSBR_1010bp tempBillPosition = new L6BL_GADfBSBR_1010bp(); tempBillPosition.BIL_BillPositionID = sortedBillPosition.BillPosition.BIL_BillPositionID; tempBillPosition.BillPosition_ValuePerUnit_BeforeTax = (double)sortedBillPosition.BillPosition.PositionPricePerUnitValue_BeforeTax; tempBillPosition.BillPosition_ValuePerUnit_AfterTax = (double)sortedBillPosition.BillPosition.PositionPricePerUnitValue_IncludingTax; tempBillPosition.ACC_TAX_TaxeID = sortedBillPosition.Article.Taxes.First().ACC_TAX_TaxeID; tempBillPosition.TaxRate = sortedBillPosition.Article.Taxes.First().TaxRate; tempBillPosition.TaxName_DictID = sortedBillPosition.Article.Taxes.First().TaxName_DictID; tempBillPosition.HeaderID = sortedBillPosition.BillPosition.LOG_SHP_Shipment_HeaderID; tempBillPosition.Header_Number = sortedBillPosition.BillPosition.ShipmentHeader_Number; tempBillPosition.Creation_Timestamp = sortedBillPosition.BillPosition.LOG_SHP_ShipmentHeader_Creation_Timestamp; tempBillPosition.IsShipmentPosition = true; tempBillPosition.Quantity = sortedBillPosition.BillPosition.Quantity; //hate this List <L6BL_GADfBSBR_1010bp> currentBillPositions = tempOrganizationalUnit.BillPositions.ToList(); currentBillPositions.Add(tempBillPosition); tempOrganizationalUnit.BillPositions = currentBillPositions.ToArray(); } } // now for organization unit in customer order return if (allBillPositions.OrderReturnBillPosition != null) { List <L5OR_GCORPwAfBH_1051> sortedBillPositionsforCustomerOrderReturn = allBillPositions.OrderReturnBillPosition.Where(x => x.OrderReturnBillPosition.CMN_BPT_CTM_OrganizationalUnitID != Guid.Empty).OrderBy(x => x.OrderReturnBillPosition.DateOfCustomerReturn).ToList(); foreach (L5OR_GCORPwAfBH_1051 sortedBillPosition in sortedBillPositionsforCustomerOrderReturn) { L6BL_GADfBSBR_1010bo tempOrganizationalUnit = organizationalUnitsTemp.FirstOrDefault(organizationalUnitTemp => organizationalUnitTemp.CMN_BPT_CTM_OrganizationalUnitID == sortedBillPosition.OrderReturnBillPosition.CMN_BPT_CTM_OrganizationalUnitID); if (tempOrganizationalUnit == null) { tempOrganizationalUnit = new L6BL_GADfBSBR_1010bo(); tempOrganizationalUnit.BillPositions = new L6BL_GADfBSBR_1010bp[0]; tempOrganizationalUnit.CMN_BPT_CTM_OrganizationalUnitID = sortedBillPosition.OrderReturnBillPosition.CMN_BPT_CTM_OrganizationalUnitID; tempOrganizationalUnit.OrganizationalUnit_SimpleName = sortedBillPosition.OrderReturnBillPosition.OrganizationalUnit_SimpleName; tempOrganizationalUnit.OrganizationalUnit_Name = sortedBillPosition.OrderReturnBillPosition.OrganizationalUnit_Name_DictID; tempOrganizationalUnit.OrganizationalUnit_Description = sortedBillPosition.OrderReturnBillPosition.OrganizationalUnit_Name_DictID; tempOrganizationalUnit.InternalOrganizationalUnitNumber = sortedBillPosition.OrderReturnBillPosition.InternalOrganizationalUnitNumber; tempOrganizationalUnit.InternalOrganizationalUnitSimpleName = sortedBillPosition.OrderReturnBillPosition.InternalOrganizationalUnitSimpleName; tempOrganizationalUnit.ExternalOrganizationalUnitNumber = sortedBillPosition.OrderReturnBillPosition.ExternalOrganizationalUnitNumber; organizationalUnitsTemp.Add(tempOrganizationalUnit); } L6BL_GADfBSBR_1010bp tempBillPosition = new L6BL_GADfBSBR_1010bp(); tempBillPosition.BIL_BillPositionID = sortedBillPosition.OrderReturnBillPosition.BIL_BillPositionID; tempBillPosition.BillPosition_ValuePerUnit_BeforeTax = (double)sortedBillPosition.OrderReturnBillPosition.PositionPricePerUnitValue_BeforeTax; tempBillPosition.BillPosition_ValuePerUnit_AfterTax = (double)sortedBillPosition.OrderReturnBillPosition.PositionPricePerUnitValue_IncludingTax; tempBillPosition.ACC_TAX_TaxeID = sortedBillPosition.Article.Taxes.First().ACC_TAX_TaxeID; tempBillPosition.TaxRate = sortedBillPosition.Article.Taxes.First().TaxRate; tempBillPosition.TaxName_DictID = sortedBillPosition.Article.Taxes.First().TaxName_DictID; tempBillPosition.HeaderID = sortedBillPosition.OrderReturnBillPosition.ORD_CUO_CustomerOrderReturn_HeaderID; tempBillPosition.Header_Number = sortedBillPosition.OrderReturnBillPosition.CustomerOrderReturnNumber; tempBillPosition.Creation_Timestamp = sortedBillPosition.OrderReturnBillPosition.Creation_Timestamp; tempBillPosition.IsShipmentPosition = false; tempBillPosition.Quantity = sortedBillPosition.OrderReturnBillPosition.Quantity; //hate this List <L6BL_GADfBSBR_1010bp> currentBillPositions = tempOrganizationalUnit.BillPositions.ToList(); currentBillPositions.Add(tempBillPosition); tempOrganizationalUnit.BillPositions = currentBillPositions.ToArray(); } } returnValue.Result.OrganizationalUnits = organizationalUnitsTemp.ToArray(); #endregion #endregion return(returnValue); #endregion UserCode }
protected static FR_L6LR_GLR_ID_1339 Execute(DbConnection Connection, DbTransaction Transaction, P_L6LR_GLR_ID_1339 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6LR_GLR_ID_1339(); returnValue.Result = new L6LR_GLR_ID_1339(); //Covers ORM_CMN_BPT_EMP_Employee_LeaveRequest.Query leaveRequestQuery = new ORM_CMN_BPT_EMP_Employee_LeaveRequest.Query(); leaveRequestQuery.CMN_BPT_EMP_Employee_LeaveRequestID = Parameter.LeaveID; leaveRequestQuery.Tenant_RefID = securityTicket.TenantID; leaveRequestQuery.IsDeleted = false; ORM_CMN_BPT_EMP_Employee_LeaveRequest leaveRequest = ORM_CMN_BPT_EMP_Employee_LeaveRequest.Query.Search(Connection, Transaction, leaveRequestQuery).FirstOrDefault(); ORM_CMN_BPT_EMP_Employee employee = new ORM_CMN_BPT_EMP_Employee(); employee.Load(Connection, Transaction, leaveRequest.RequestedFor_Employee_RefID); 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.AbsenceReason_Type_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); 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); 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); result.Action = new L5LR_GLRFSP_1532_Action(); result.IsApproved = eventApproval.IsApproved; result.IsApprovalProcessOpened = eventApproval.IsApprovalProcessOpened; result.IsApprovalProcessDenied = eventApproval.IsApprovalProcessDenied; 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; } returnValue.Result.Leave = result; //Put your code here return(returnValue); #endregion UserCode }
protected static FR_L5BC_GBPwCDfBH_1607 Execute(DbConnection Connection, DbTransaction Transaction, P_L5BC_GBPwCDfBH_1607 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5BC_GBPwCDfBH_1607(); var result = new L5BC_GBPwCDfBH_1607(); #region Get Bill Header var billHeader = new ORM_BIL_BillHeader(); if (billHeader.Load(Connection, Transaction, Parameter.BillHeaderId).Status != FR_Status.Success) { returnValue.Status = FR_Status.Error_Internal; returnValue.Result = null; return(returnValue); } #endregion #region Get Bill Recipiant BusinessParticipant var billRecipiant = new ORM_CMN_BPT_BusinessParticipant(); if (billRecipiant.Load(Connection, Transaction, billHeader.BillRecipient_BuisnessParticipant_RefID).Status != FR_Status.Success) { returnValue.Result = null; returnValue.Status = FR_Status.Error_Internal; return(returnValue); } #endregion #region Get Bill Positions var resultBillPositions = cls_Get_BillPositions_with_Articles_for_BillHeader.Invoke( Connection, Transaction, new P_L5BL_GBPwAfBH_1848() { BillHeaderID = Parameter.BillHeaderId }, securityTicket); if (resultBillPositions.Status != FR_Status.Success || resultBillPositions.Result == null || resultBillPositions.Result.Count() <= 0) { returnValue.Status = FR_Status.Error_Internal; returnValue.Result = null; return(returnValue); } #endregion #region Get Order Header (Shipment and CustomerOrderReturn) var resultOrderHeader = cls_Get_Shipment_and_CustomerOrderReturn_Header_for_BillPositionIDs.Invoke( Connection, Transaction, new P_L5BC_GSaCORHfCP_1109() { BillPositionIDs = resultBillPositions.Result.Select(bp => bp.BillPosition.BIL_BillPositionID).ToArray() }, securityTicket); if (resultOrderHeader.Status != FR_Status.Success || resultOrderHeader.Result == null) { returnValue.Result = null; returnValue.Status = FR_Status.Error_Internal; return(returnValue); } #endregion #region Get Bill Credit data var resultBillCredits = cls_Get_BillReimbursement_and_GrantedCreditNotes_for_BillPositionIDs.Invoke( Connection, Transaction, new P_L5BC_GBRaGCNfBP_1331() { BillPositionIDs = resultBillPositions.Result.Select(bp => bp.BillPosition.BIL_BillPositionID).ToArray() }, securityTicket); if (resultBillCredits.Status != FR_Status.Success) { returnValue.Result = null; returnValue.Status = FR_Status.Error_Internal; return(returnValue); } #endregion #region Set result var creditingBills = new List <L5BC_GBPwCDfBH_1607a>(); foreach (var billPosition in resultBillPositions.Result) { var orderHeader = resultOrderHeader.Result .Where(coh => coh.BIL_BillPositionID == billPosition.BillPosition.BIL_BillPositionID).FirstOrDefault(); if (orderHeader == null) { returnValue.Result = null; returnValue.Status = FR_Status.Error_Internal; return(returnValue); } var billCredits = resultBillCredits.Result .Where(bc => bc.BIL_BillPosition_RefID == billPosition.BillPosition.BIL_BillPositionID).FirstOrDefault(); var creditingBill = new L5BC_GBPwCDfBH_1607a() { BillPosition = billPosition.BillPosition, Article = billPosition.Article, BillCredits = billCredits ?? new L5BC_GBRaGCNfBP_1331(), CustomerOrderHeaderNumber = orderHeader.LOG_SHP_Shipment_HeaderID == Guid.Empty || orderHeader.LOG_SHP_Shipment_HeaderID == null || string.IsNullOrEmpty(orderHeader.ShipmentHeader_Number) ? orderHeader.CustomerOrderReturnNumber : orderHeader.ShipmentHeader_Number }; creditingBills.Add(creditingBill); } result.CreditingBills = creditingBills.ToArray(); result.BillHeaderNumber = billHeader.BillNumber; result.BillHeaderBillRecipiantName = billRecipiant.DisplayName; result.BillHeaderDateOnBill = billHeader.DateOnBill; result.BillHeaderCurencyID = billHeader.Currency_RefID; returnValue.Status = FR_Status.Success; returnValue.Result = result; #endregion return(returnValue); #endregion UserCode }
protected static FR_L5EM_GEFT_0959_Array Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5EM_GEFT_0959_Array(); List <L5EM_GEFT_0959> employeeResultList = new List <L5EM_GEFT_0959>(); ORM_CMN_BPT_EMP_Employee.Query employeeQuery = new ORM_CMN_BPT_EMP_Employee.Query(); employeeQuery.IsDeleted = false; employeeQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_BPT_EMP_Employee> employeeList = ORM_CMN_BPT_EMP_Employee.Query.Search(Connection, Transaction, employeeQuery); foreach (var employeeItem in employeeList) { L5EM_GEFT_0959 result = new L5EM_GEFT_0959(); ORM_CMN_BPT_EMP_Employee employee = new ORM_CMN_BPT_EMP_Employee(); employee.Load(Connection, Transaction, employeeItem.CMN_BPT_EMP_EmployeeID); result.CMN_BPT_EMP_EmployeeID = employee.CMN_BPT_EMP_EmployeeID; result.Staff_Number = employee.Staff_Number; result.StandardFunction = employee.StandardFunction; ORM_USR_Account.Query accountQuery = new ORM_USR_Account.Query(); accountQuery.BusinessParticipant_RefID = employee.BusinessParticipant_RefID; accountQuery.Tenant_RefID = securityTicket.TenantID; accountQuery.IsDeleted = false; ORM_USR_Account account = ORM_USR_Account.Query.Search(Connection, Transaction, accountQuery).FirstOrDefault(); if (account != null) { result.USR_AccountID = account.USR_AccountID; } ORM_CMN_BPT_BusinessParticipant businessParticipant = new ORM_CMN_BPT_BusinessParticipant(); businessParticipant.Load(Connection, Transaction, employee.BusinessParticipant_RefID); result.CMN_BPT_BusinessParticipantID = businessParticipant.CMN_BPT_BusinessParticipantID; result.DisplayName = businessParticipant.DisplayName; ORM_CMN_PER_PersonInfo personInfo = new ORM_CMN_PER_PersonInfo(); personInfo.Load(Connection, Transaction, businessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID); result.CMN_PER_PersonInfoID = personInfo.CMN_PER_PersonInfoID; result.FirstName = personInfo.FirstName; result.LastName = personInfo.LastName; result.PrimaryEmail = personInfo.PrimaryEmail; result.Title = personInfo.Title; result.ProfileImage_Document_RefID = personInfo.ProfileImage_Document_RefID; result.BirthDate = personInfo.BirthDate; ORM_CMN_BPT_EMP_EmploymentRelationship.Query workingContractQuery = new ORM_CMN_BPT_EMP_EmploymentRelationship.Query(); workingContractQuery.Employee_RefID = employee.CMN_BPT_EMP_EmployeeID; workingContractQuery.IsDeleted = false; workingContractQuery.Tenant_RefID = securityTicket.TenantID; ORM_CMN_BPT_EMP_EmploymentRelationship employmentRelationship = ORM_CMN_BPT_EMP_EmploymentRelationship.Query.Search(Connection, Transaction, workingContractQuery).FirstOrDefault(); result.CMN_BPT_EMP_EmploymentRelationshipID = employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID; result.Work_StartDate = employmentRelationship.Work_StartDate; result.Work_EndDate = employmentRelationship.Work_EndDate; //Address if (personInfo.Address_RefID != Guid.Empty) { ORM_CMN_Address address = new ORM_CMN_Address(); address.Load(Connection, Transaction, personInfo.Address_RefID); result.CMN_AddressID = address.CMN_AddressID; result.Street_Name = address.Street_Name; result.Street_Number = address.Street_Number; result.City_AdministrativeDistrict = address.City_AdministrativeDistrict; result.City_Region = address.City_Region; result.City_Name = address.City_Name; result.City_PostalCode = address.City_PostalCode; result.Province_Name = address.Province_Name; result.Country_Name = address.Country_Name; result.Country_ISOCode = address.Country_ISOCode; } //Contacts ORM_CMN_PER_CommunicationContact.Query comunicationContactQuery = new ORM_CMN_PER_CommunicationContact.Query(); comunicationContactQuery.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; comunicationContactQuery.Tenant_RefID = securityTicket.TenantID; comunicationContactQuery.IsDeleted = false; List <ORM_CMN_PER_CommunicationContact> comunicationContacts = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, comunicationContactQuery); List <L5EM_GEFT_0959_Contacts> resultComunicationContacts = new List <L5EM_GEFT_0959_Contacts>(); foreach (var comunicationContact in comunicationContacts) { ORM_CMN_PER_CommunicationContact_Type contactType = new ORM_CMN_PER_CommunicationContact_Type(); contactType.Load(Connection, Transaction, comunicationContact.CMN_PER_CommunicationContactID); L5EM_GEFT_0959_Contacts resultComunicationContact = new L5EM_GEFT_0959_Contacts(); resultComunicationContact.CMN_PER_CommunicationContact_TypeID = contactType.CMN_PER_CommunicationContact_TypeID; resultComunicationContact.CMN_PER_CommunicationContactID = comunicationContact.CMN_PER_CommunicationContactID; resultComunicationContact.Content = comunicationContact.Content; resultComunicationContact.Type = contactType.Type; resultComunicationContacts.Add(resultComunicationContact); } result.Contacts = resultComunicationContacts.ToArray(); //Employee workplace history ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query employeeWorkplaceAssignmentsQuery = new ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query(); employeeWorkplaceAssignmentsQuery.CMN_BPT_EMP_Employee_RefID = employee.CMN_BPT_EMP_EmployeeID; employeeWorkplaceAssignmentsQuery.Tenant_RefID = securityTicket.TenantID; employeeWorkplaceAssignmentsQuery.IsDeleted = false; List <ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment> employeeWorkplaceAssignemntsList = ORM_CMN_BPT_EMP_Employee_WorkplaceAssignment.Query.Search(Connection, Transaction, employeeWorkplaceAssignmentsQuery); List <L5EM_GEFT_0959_EmployeeWorkplaceHistory> employeeWorkplaceAssignments = new List <L5EM_GEFT_0959_EmployeeWorkplaceHistory>(); foreach (var workplaceAssignemns in employeeWorkplaceAssignemntsList) { L5EM_GEFT_0959_EmployeeWorkplaceHistory item = new L5EM_GEFT_0959_EmployeeWorkplaceHistory(); item.BoundTo_Workplace_RefID = workplaceAssignemns.BoundTo_Workplace_RefID; item.CMN_BPT_EMP_Employee_PlanGroup_RefID = workplaceAssignemns.CMN_BPT_EMP_Employee_PlanGroup_RefID; item.CMN_BPT_EMP_Employee_WorkplaceAssignmentID = workplaceAssignemns.CMN_BPT_EMP_Employee_WorkplaceAssignment; item.Default_BreakTime_Template_RefID = workplaceAssignemns.Default_BreakTime_Template_RefID; item.IsBreakTimeCalculated_Actual = workplaceAssignemns.IsBreakTimeCalculated_Actual; item.IsBreakTimeCalculated_Planning = workplaceAssignemns.IsBreakTimeCalculated_Planning; item.SequenceNumber = workplaceAssignemns.SequenceNumber; item.WorkplaceAssignment_StartDate = workplaceAssignemns.WorkplaceAssignment_StartDate; employeeWorkplaceAssignments.Add(item); } result.EmployeeWorkplaceHistory = employeeWorkplaceAssignments.ToArray(); //Contracts ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query contractTermQuery = new ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query(); contractTermQuery.EmploymentRelationship_RefID = employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID; contractTermQuery.IsDeleted = false; contractTermQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract> contracts = ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query.Search(Connection, Transaction, contractTermQuery); List <L5EM_GEFT_0959_WorkingContracts> resultContracts = new List <L5EM_GEFT_0959_WorkingContracts>(); foreach (var contractToRelationship in contracts) { L5EM_GEFT_0959_WorkingContracts resultContract = new L5EM_GEFT_0959_WorkingContracts(); ORM_CMN_BPT_EMP_WorkingContract workingContract = new ORM_CMN_BPT_EMP_WorkingContract(); workingContract.Load(Connection, Transaction, contractToRelationship.WorkingContract_RefID); if (!workingContract.IsDeleted) { resultContract.CMN_BPT_EMP_WorkingContractID = workingContract.CMN_BPT_EMP_WorkingContractID; resultContract.EmploymentRelationshipToWorkingContractAssignmentID = contractToRelationship.AssignmentID; resultContract.IsWorkingContract_Active = contractToRelationship.IsContract_Active; resultContract.Contract_StartDate = workingContract.Contract_StartDate; resultContract.Contract_EndDate = workingContract.Contract_EndDate; resultContract.IsContractEndDateDefined = workingContract.IsContractEndDateDefined; resultContract.IsWorkTimeCalculated_InDays = workingContract.IsWorkTimeCalculated_InDays; resultContract.IsWorkTimeCalculated_InHours = workingContract.IsWorkTimeCalculated_InHours; resultContract.R_WorkTime_DaysPerWeek = workingContract.R_WorkTime_DaysPerWeek; resultContract.R_WorkTime_HoursPerWeek = workingContract.R_WorkTime_HoursPerWeek; //Office hours ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query workingContractTermToWorkingDayQuery = new ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query(); workingContractTermToWorkingDayQuery.CMN_BPT_EMP_WorkingContract_RefID = workingContract.CMN_BPT_EMP_WorkingContractID; workingContractTermToWorkingDayQuery.Tenant_RefID = securityTicket.TenantID; workingContractTermToWorkingDayQuery.IsDeleted = false; List <ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay> workingDayAssigments = ORM_CMN_BPT_EMP_WorkingContract_2_WorkingDay.Query.Search(Connection, Transaction, workingContractTermToWorkingDayQuery); List <L5EM_GEFT_0959_WeeklyOfficeHours> resultWeeklyOfficeHours = new List <L5EM_GEFT_0959_WeeklyOfficeHours>(); foreach (var workingDayAssigment in workingDayAssigments) { ORM_CMN_CAL_WeeklyOfficeHours_Interval interval = new ORM_CMN_CAL_WeeklyOfficeHours_Interval(); interval.Load(Connection, Transaction, workingDayAssigment.CMN_CAL_WeeklyOfficeHours_Interval_RefID); L5EM_GEFT_0959_WeeklyOfficeHours resultOfficeHour = new L5EM_GEFT_0959_WeeklyOfficeHours(); resultOfficeHour.CMN_CAL_WeeklyOfficeHours_IntervalID = interval.CMN_CAL_WeeklyOfficeHours_IntervalID; resultOfficeHour.IsFriday = interval.IsFriday; resultOfficeHour.IsMonday = interval.IsMonday; resultOfficeHour.IsSaturday = interval.IsSaturday; resultOfficeHour.IsSunday = interval.IsSunday; resultOfficeHour.IsThursday = interval.IsThursday; resultOfficeHour.IsTuesday = interval.IsTuesday; resultOfficeHour.IsWednesday = interval.IsWednesday; resultOfficeHour.IsWholeDay = interval.IsWholeDay; resultOfficeHour.TimeFrom_InMinutes = interval.TimeFrom_InMinutes; resultOfficeHour.TimeTo_InMinutes = interval.TimeTo_InMinutes; resultWeeklyOfficeHours.Add(resultOfficeHour); } resultContract.WeeklyOfficeHours = resultWeeklyOfficeHours.ToArray(); //Allowed absence reasons ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason.Query AllowedAbsenceReasonQuery = new ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason.Query(); AllowedAbsenceReasonQuery.WorkingContract_RefID = resultContract.CMN_BPT_EMP_WorkingContractID; AllowedAbsenceReasonQuery.Tenant_RefID = securityTicket.TenantID; AllowedAbsenceReasonQuery.IsDeleted = false; List <ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason> allowedAbsenceReasons = ORM_CMN_BPT_EMP_WorkingContract_AllowedAbsenceReason.Query.Search(Connection, Transaction, AllowedAbsenceReasonQuery); List <L5EM_GEFT_0959_WorkingContractToLeaveRequest> resultAllowedAbsenceReasons = new List <L5EM_GEFT_0959_WorkingContractToLeaveRequest>(); foreach (var allowedAbsenceReason in allowedAbsenceReasons) { ORM_CMN_BPT_STA_AbsenceReason absenceReason = new ORM_CMN_BPT_STA_AbsenceReason(); absenceReason.Load(Connection, Transaction, allowedAbsenceReason.STA_AbsenceReason_RefID); L5EM_GEFT_0959_WorkingContractToLeaveRequest resultReasonresultReason = new L5EM_GEFT_0959_WorkingContractToLeaveRequest(); resultReasonresultReason.CMN_BPT_EMP_Employee_WorkingContract_AllowedAbsenceReasonID = allowedAbsenceReason.CMN_BPT_EMP_WorkingContract_AllowedAbsenceReasonID; resultReasonresultReason.STA_AbsenceReason_RefID = absenceReason.CMN_BPT_STA_AbsenceReasonID; resultReasonresultReason.IsAbsenceCalculated_InDays = allowedAbsenceReason.IsAbsenceCalculated_InDays; resultReasonresultReason.IsAbsenceCalculated_InHours = allowedAbsenceReason.IsAbsenceCalculated_InHours; resultReasonresultReason.ContractAllowedAbsence_per_Month = allowedAbsenceReason.ContractAllowedAbsence_per_Month; resultAllowedAbsenceReasons.Add(resultReasonresultReason); } resultContract.WorkingContractToLeaveRequest = resultAllowedAbsenceReasons.ToArray(); resultContracts.Add(resultContract); } } result.WorkingContracts = resultContracts.ToArray(); employeeResultList.Add(result); } returnValue.Result = employeeResultList.ToArray(); //Put your code here return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6DR_SD_1537 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); //Put your code here if (Parameter.CMN_BPT_BusinessParticipantID == Guid.Empty) { #region Create Mode #region BusinessParticipant ORM_CMN_BPT_BusinessParticipant bParticipant = new ORM_CMN_BPT_BusinessParticipant(); bParticipant.CMN_BPT_BusinessParticipantID = Guid.NewGuid(); bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = Guid.NewGuid(); bParticipant.IsNaturalPerson = true; bParticipant.Tenant_RefID = securityTicket.TenantID; bParticipant.Creation_Timestamp = DateTime.Now; bParticipant.Save(Connection, Transaction); #endregion #region Account ORM_USR_Account account = new ORM_USR_Account(); account.Username = Parameter.FirstName + "_" + Parameter.LastName; account.AccountType = 3; account.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; account.Tenant_RefID = securityTicket.TenantID; account.Creation_Timestamp = DateTime.Now; account.Save(Connection, Transaction); P_L2DC_GUDCfT_1505 codeParam = new P_L2DC_GUDCfT_1505(); codeParam.codeLength = 8; var checkCodeValue = cls_GetUniqueDeviceCodeForTenant.Invoke(Connection, Transaction, codeParam, securityTicket).Result; ORM_USR_Device_AccountCode accountCode = new ORM_USR_Device_AccountCode(); accountCode.Account_RefID = account.USR_AccountID; accountCode.AccountCode_Value = checkCodeValue.CodeValue; accountCode.AccountCode_ValidFrom = DateTime.Now; accountCode.AccountCode_CurrentStatus_RefID = Guid.NewGuid(); accountCode.IsAccountCode_Expirable = false; accountCode.Tenant_RefID = securityTicket.TenantID; accountCode.Creation_Timestamp = DateTime.Now; accountCode.Save(Connection, Transaction); ORM_USR_Device_AccountCode_StatusHistory Device_AccountCode_StatusHistory = new ORM_USR_Device_AccountCode_StatusHistory(); Device_AccountCode_StatusHistory.USR_Device_AccountCode_StatusHistoryID = accountCode.AccountCode_CurrentStatus_RefID; Device_AccountCode_StatusHistory.IsAccountCode_Active = true; Device_AccountCode_StatusHistory.Device_AccountCode_RefID = accountCode.USR_Device_AccountCodeID; Device_AccountCode_StatusHistory.Tenant_RefID = securityTicket.TenantID; Device_AccountCode_StatusHistory.Creation_Timestamp = DateTime.Now; Device_AccountCode_StatusHistory.Save(Connection, Transaction); ORM_USR_Device_AccountCode_UsageHistory USR_Device_AccountCode_UsageHistory = new ORM_USR_Device_AccountCode_UsageHistory(); USR_Device_AccountCode_UsageHistory.USR_Device_AccountCode_UsageHistoryID = Guid.NewGuid(); USR_Device_AccountCode_UsageHistory.Tenant_RefID = securityTicket.TenantID; USR_Device_AccountCode_UsageHistory.Device_AccountCode_RefID = accountCode.USR_Device_AccountCodeID; USR_Device_AccountCode_UsageHistory.Creation_Timestamp = DateTime.Now; USR_Device_AccountCode_UsageHistory.Save(Connection, Transaction); #endregion #region PersonInfo and Adresses ORM_CMN_PER_PersonInfo personInfo = new ORM_CMN_PER_PersonInfo(); personInfo.CMN_PER_PersonInfoID = bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID; personInfo.Salutation_General = Parameter.Salutation_General; personInfo.FirstName = Parameter.FirstName; personInfo.LastName = Parameter.LastName; personInfo.PrimaryEmail = Parameter.PrimaryMail; personInfo.Address_RefID = Guid.NewGuid(); personInfo.Tenant_RefID = securityTicket.TenantID; personInfo.Save(Connection, Transaction); ORM_CMN_PER_PersonInfo_2_Address personAdress = new ORM_CMN_PER_PersonInfo_2_Address(); personAdress.AssignmentID = Guid.NewGuid(); personAdress.CMN_PER_PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; personAdress.CMN_Address_RefID = personInfo.Address_RefID; personAdress.IsPrimary = true; personAdress.Tenant_RefID = securityTicket.TenantID; personAdress.Save(Connection, Transaction); ORM_CMN_Address adress = new ORM_CMN_Address(); adress.CMN_AddressID = personInfo.Address_RefID; adress.City_Name = Parameter.City_Name; adress.Province_Name = Parameter.Province_Name; adress.Street_Name = Parameter.Street_Name; adress.Street_Number = Parameter.Street_Number; adress.City_PostalCode = Parameter.City_PostalCode; adress.Tenant_RefID = securityTicket.TenantID; adress.Save(Connection, Transaction); #endregion #region Contacts foreach (var parContact in Parameter.Contacts) { ORM_CMN_PER_CommunicationContact contact = new ORM_CMN_PER_CommunicationContact(); contact.Content = parContact.Content; contact.Contact_Type = parContact.CMN_PER_CommunicationContact_TypeID; contact.Tenant_RefID = securityTicket.TenantID; contact.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; contact.Save(Connection, Transaction); } #endregion #region Driver To Employer ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant bpt_asBP = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant(); bpt_asBP.CMN_BPT_BusinessParticipant_AssociatedBusinessParticipantID = Guid.NewGuid(); bpt_asBP.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; bpt_asBP.AssociatedParticipant_FunctionName = "Driver"; bpt_asBP.Tenant_RefID = securityTicket.TenantID; bpt_asBP.AssociatedBusinessParticipant_RefID = Parameter.CMN_BPT_BusinessParticipantID_Of_Employer; bpt_asBP.Save(Connection, Transaction); #endregion #endregion } else { ORM_CMN_BPT_BusinessParticipant bParticipant = new ORM_CMN_BPT_BusinessParticipant(); bParticipant.Load(Connection, Transaction, Parameter.CMN_BPT_BusinessParticipantID); var personInfo = new ORM_CMN_PER_PersonInfo(); personInfo.Load(Connection, Transaction, bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID); personInfo.Salutation_General = Parameter.Salutation_General; personInfo.FirstName = Parameter.FirstName; personInfo.LastName = Parameter.LastName; personInfo.PrimaryEmail = Parameter.PrimaryMail; personInfo.Save(Connection, Transaction); ORM_CMN_Address adress = new ORM_CMN_Address(); adress.Load(Connection, Transaction, personInfo.Address_RefID); adress.City_Name = Parameter.City_Name; adress.Province_Name = Parameter.Province_Name; adress.Street_Name = Parameter.Street_Name; adress.Street_Number = Parameter.Street_Number; adress.Save(Connection, Transaction); foreach (var parContact in Parameter.Contacts) { var query = new ORM_CMN_PER_CommunicationContact.Query(); query.Contact_Type = parContact.CMN_PER_CommunicationContact_TypeID; query.IsDeleted = false; query.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; var contact = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, query).First(); contact.Content = parContact.Content; contact.Contact_Type = parContact.CMN_PER_CommunicationContact_TypeID; contact.Save(Connection, Transaction); } var associationQuery = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query(); associationQuery.BusinessParticipant_RefID = Parameter.CMN_BPT_BusinessParticipantID; associationQuery.IsDeleted = false; var bpt_asBP = ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query.Search(Connection, Transaction, associationQuery).First(); bpt_asBP.AssociatedBusinessParticipant_RefID = Parameter.CMN_BPT_BusinessParticipantID_Of_Employer; bpt_asBP.Save(Connection, Transaction); } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5EM_SE_1657 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here ORM_CMN_Address address = new ORM_CMN_Address(); if (Parameter.CMN_AddressID != Guid.Empty) { var result = address.Load(Connection, Transaction, Parameter.CMN_AddressID); if (result.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(error); } } address.City_Name = Parameter.City_Name; address.Street_Name = Parameter.Street_Name; address.Street_Number = Parameter.Street_Number; address.Country_Name = Parameter.Country_Name; address.Province_Name = Parameter.Province_Name; address.Tenant_RefID = securityTicket.TenantID; address.City_PostalCode = Parameter.City_PostalCode; address.Save(Connection, Transaction); CSV2Core.DlTrace.Trace("success address"); ORM_CMN_PER_PersonInfo person = new ORM_CMN_PER_PersonInfo(); if (Parameter.CMN_PER_PersonInfoID != Guid.Empty) { var result = person.Load(Connection, Transaction, Parameter.CMN_PER_PersonInfoID); if (result.Status != FR_Status.Success || person.CMN_PER_PersonInfoID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } //person.AccountImage_URL = Parameter.ProfileImage_Document_RefID; person.FirstName = Parameter.FirstName; person.LastName = Parameter.LastName; person.PrimaryEmail = Parameter.PrimaryEmail; person.Tenant_RefID = securityTicket.TenantID; person.Title = Parameter.Title; person.Address_RefID = address.CMN_AddressID; person.ProfileImage_Document_RefID = Parameter.ImageID; person.BirthDate = Parameter.BirthDate; person.NumberOfChildren = Parameter.TaxInfoParameter != null ? Parameter.TaxInfoParameter.NumberOfChildren : 0; person.Save(Connection, Transaction); CSV2Core.DlTrace.Trace("success persopm"); var contactQuery = new ORM_CMN_PER_CommunicationContact.Query(); contactQuery.Tenant_RefID = securityTicket.TenantID; contactQuery.PersonInfo_RefID = person.CMN_PER_PersonInfoID; contactQuery.IsDeleted = false; var deleteContacts = ORM_CMN_PER_CommunicationContact.Query.SoftDelete(Connection, Transaction, contactQuery); foreach (var parContact in Parameter.Contacts) { ORM_CMN_PER_CommunicationContact contact = new ORM_CMN_PER_CommunicationContact(); if (parContact.CMN_PER_CommunicationContactID != Guid.Empty) { var result = contact.Load(Connection, Transaction, parContact.CMN_PER_CommunicationContactID); if (result.Status != FR_Status.Success || contact.CMN_PER_CommunicationContactID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } contact.Content = parContact.Content; contact.Contact_Type = parContact.CMN_PER_CommunicationContact_TypeID; contact.Tenant_RefID = securityTicket.TenantID; contact.PersonInfo_RefID = person.CMN_PER_PersonInfoID; contact.Save(Connection, Transaction); CSV2Core.DlTrace.Trace("success contact"); } ORM_CMN_BPT_BusinessParticipant bParticipant = new ORM_CMN_BPT_BusinessParticipant(); if (Parameter.CMN_BPT_BusinessParticipantID != Guid.Empty) { var result = bParticipant.Load(Connection, Transaction, Parameter.CMN_BPT_BusinessParticipantID); if (result.Status != FR_Status.Success || bParticipant.CMN_BPT_BusinessParticipantID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } bParticipant.DisplayName = Parameter.DisplayName; bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = person.CMN_PER_PersonInfoID; bParticipant.IsNaturalPerson = true; bParticipant.Tenant_RefID = securityTicket.TenantID; bParticipant.Save(Connection, Transaction); ORM_CMN_BPT_EMP_Employee employee = new ORM_CMN_BPT_EMP_Employee(); CSV2Core.DlTrace.Trace("success bpart"); if (Parameter.CMN_BPT_EMP_EmployeeID != Guid.Empty) { var result = employee.Load(Connection, Transaction, Parameter.CMN_BPT_EMP_EmployeeID); if (result.Status != FR_Status.Success || employee.CMN_BPT_EMP_EmployeeID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } employee.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; employee.Staff_Number = Parameter.Staff_Number; employee.StandardFunction = Parameter.StandardFunction; employee.Tenant_RefID = securityTicket.TenantID; employee.Save(Connection, Transaction); CSV2Core.DlTrace.Trace("success employee"); ORM_CMN_BPT_EMP_EmploymentRelationship employmentRelationship = new ORM_CMN_BPT_EMP_EmploymentRelationship(); if (Parameter.CMN_BPT_EMP_Employee_EmploymentRelationshipID != Guid.Empty) { var result = employmentRelationship.Load(Connection, Transaction, Parameter.CMN_BPT_EMP_Employee_EmploymentRelationshipID); if (result.Status != FR_Status.Success || employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } employmentRelationship.Work_StartDate = Parameter.Work_StartDate; bool resignationDateChanged = false; if (employmentRelationship.Work_EndDate != Parameter.Work_EndDate) { resignationDateChanged = true; } employmentRelationship.Work_EndDate = Parameter.Work_EndDate; employmentRelationship.Tenant_RefID = securityTicket.TenantID; employmentRelationship.Employee_RefID = employee.CMN_BPT_EMP_EmployeeID; employmentRelationship.Save(Connection, Transaction); CSV2Core.DlTrace.Trace("success employmentRelationship"); if (Parameter.Work_EndDate.Ticks != 0) { ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query empRelationShipToWorkingContractQuery = new ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query(); empRelationShipToWorkingContractQuery.EmploymentRelationship_RefID = employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID; empRelationShipToWorkingContractQuery.Tenant_RefID = securityTicket.TenantID; empRelationShipToWorkingContractQuery.IsDeleted = false; List <ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract> workingContractAssignments = ORM_CMN_BPT_EMP_EmploymentRelationship_2_WorkingContract.Query.Search(Connection, Transaction, empRelationShipToWorkingContractQuery); foreach (var workingContractAssignment in workingContractAssignments) { ORM_CMN_BPT_EMP_WorkingContract workingContract = new ORM_CMN_BPT_EMP_WorkingContract(); if (workingContractAssignment.WorkingContract_RefID != Guid.Empty) { var result = workingContract.Load(Connection, Transaction, workingContractAssignment.WorkingContract_RefID); if (result.Status != FR_Status.Success || workingContract.CMN_BPT_EMP_WorkingContractID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } if (workingContract.Contract_EndDate.Ticks == 0 || workingContract.Contract_EndDate.Ticks > Parameter.Work_EndDate.Ticks) { workingContract.Contract_EndDate = Parameter.Work_EndDate; workingContract.IsContractEndDateDefined = true; workingContract.Save(Connection, Transaction); } } } var activeTimeFrame = cls_Get_Active_CalculationTimeFrame.Invoke(Connection, Transaction, securityTicket).Result; var timeframes = cls_Get_CalculationTimeFramesForTenant.Invoke(Connection, Transaction, securityTicket).Result.ToList(); var resultFrames = timeframes.Where(i => i.CalculationTimeframe_StartDate.Year == employmentRelationship.Work_StartDate.Year).ToList(); if (resultFrames.Count == 0) { var newFrame = new ORM_CMN_CAL_CalculationTimeframe(); int currentYear = Parameter.Work_StartDate.Year; while (currentYear < activeTimeFrame.CalculationTimeframe_StartDate.Year) { if (!timeframes.Any(i => i.CalculationTimeframe_StartDate.Year == currentYear)) { newFrame.CalculationTimeframe_StartDate = new DateTime(currentYear, 1, 1); newFrame.CalculationTimeframe_EstimatedEndDate = new DateTime(currentYear, 12, 31); newFrame.Tenant_RefID = securityTicket.TenantID; newFrame.Save(Connection, Transaction); newFrame = new ORM_CMN_CAL_CalculationTimeframe(); } currentYear++; ORM_CMN_BPT_EMP_EmploymentRelationship_Timeframe relationshipFrame = new ORM_CMN_BPT_EMP_EmploymentRelationship_Timeframe(); relationshipFrame.CalculationTimeframe_RefID = newFrame.CMN_CAL_CalculationTimeframeID; relationshipFrame.EmploymentRelationship_RefID = employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID; relationshipFrame.Tenant_RefID = securityTicket.TenantID; relationshipFrame.Save(Connection, Transaction); } } else { timeframes = timeframes.Where(i => i.CalculationTimeframe_StartDate.Year < activeTimeFrame.CalculationTimeframe_StartDate.Year && i.CalculationTimeframe_StartDate.Year >= employmentRelationship.Work_StartDate.Year).ToList(); foreach (var timeframe in timeframes) { ORM_CMN_BPT_EMP_EmploymentRelationship_Timeframe.Query relationshipFrameQuery = new ORM_CMN_BPT_EMP_EmploymentRelationship_Timeframe.Query(); relationshipFrameQuery.CalculationTimeframe_RefID = timeframe.CMN_CAL_CalculationTimeframeID; relationshipFrameQuery.EmploymentRelationship_RefID = employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID; relationshipFrameQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_BPT_EMP_EmploymentRelationship_Timeframe> oldContractFrames = ORM_CMN_BPT_EMP_EmploymentRelationship_Timeframe.Query.Search(Connection, Transaction, relationshipFrameQuery); if (oldContractFrames.Count == 0) { ORM_CMN_BPT_EMP_EmploymentRelationship_Timeframe relationshipFrame = new ORM_CMN_BPT_EMP_EmploymentRelationship_Timeframe(); relationshipFrame.CalculationTimeframe_RefID = timeframe.CMN_CAL_CalculationTimeframeID; relationshipFrame.EmploymentRelationship_RefID = employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID; relationshipFrame.Tenant_RefID = securityTicket.TenantID; relationshipFrame.Save(Connection, Transaction); } } } P_L5EM_GAERCTFFE_1405 timeFrameParam = new P_L5EM_GAERCTFFE_1405(); timeFrameParam.EmployeeID = employee.CMN_BPT_EMP_EmployeeID; L5EM_GAERCTFFE_1405 employeeTimeFrame = cls_Get_Active_EmployeeRelationshipTimeFrame_For_EmployeeID.Invoke(Connection, Transaction, timeFrameParam, securityTicket).Result; if (employeeTimeFrame == null) { ORM_CMN_BPT_EMP_EmploymentRelationship_Timeframe timeFrame = new ORM_CMN_BPT_EMP_EmploymentRelationship_Timeframe(); timeFrame.CalculationTimeframe_RefID = activeTimeFrame.CMN_CAL_CalculationTimeframeID; timeFrame.EmploymentRelationship_RefID = employmentRelationship.CMN_BPT_EMP_EmploymentRelationshipID; timeFrame.Tenant_RefID = securityTicket.TenantID; timeFrame.Save(Connection, Transaction); CSV2Core.DlTrace.Trace("success timeFrame"); } //save employee professions P_L5EM_SEP_1447 saveProfessionsPar = new P_L5EM_SEP_1447(); saveProfessionsPar.Employee_RefID = employee.CMN_BPT_EMP_EmployeeID; saveProfessionsPar.FunctionHistories = Parameter.FunctionHistories; cls_Save_EmployeeFunctionHistory.Invoke(Connection, Transaction, saveProfessionsPar, securityTicket); CSV2Core.DlTrace.Trace("success employee function history"); //save workplace histories P_L5EM_SWPH_1625 saveWorkplaceHistoryPar = new P_L5EM_SWPH_1625(); saveWorkplaceHistoryPar.Employee_RefID = employee.CMN_BPT_EMP_EmployeeID; saveWorkplaceHistoryPar.WorkplaceHistories = Parameter.WorkplaceHistories; cls_Save_WorkplaceHistories.Invoke(Connection, Transaction, saveWorkplaceHistoryPar, securityTicket); CSV2Core.DlTrace.Trace("success workplaceHistories"); P_L5EM_SUED_1648 saveDocuments = new P_L5EM_SUED_1648(); saveDocuments.Employee_RefID = employee.CMN_BPT_EMP_EmployeeID; saveDocuments.Documents = Parameter.Documents; cls_Save_Uploaded_Employee_Document.Invoke(Connection, Transaction, saveDocuments, securityTicket); CSV2Core.DlTrace.Trace("success documents"); P_L5EM_SEQS_0959 saveSkillsPar = new P_L5EM_SEQS_0959(); saveSkillsPar.Employee_RefID = employee.CMN_BPT_EMP_EmployeeID; saveSkillsPar.Skills = Parameter.Skills; cls_Save_Employee_QualificationSkills.Invoke(Connection, Transaction, saveSkillsPar, securityTicket); CSV2Core.DlTrace.Trace("success skills"); CSV2Core.DlTrace.Trace("AccountID :" + Parameter.USR_AccountID); if (Parameter.USR_AccountID != null && Parameter.USR_AccountID != Guid.Empty) { CSV2Core.DlTrace.Trace("success param"); ORM_USR_Account account = new ORM_USR_Account(); if (Parameter.USR_AccountID != Guid.Empty) { var result = account.Load(Connection, Transaction, Parameter.USR_AccountID); if (account.USR_AccountID == Guid.Empty) { account.USR_AccountID = Guid.NewGuid(); account.AccountType = 2; } account.Username = Parameter.username; account.DefaultLanguage_RefID = Parameter.LanguageID; account.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; account.Tenant_RefID = securityTicket.TenantID; account.Save(Connection, Transaction); var personToAccountQuery = new ORM_CMN_PER_PersonInfo_2_Account.Query(); personToAccountQuery.Tenant_RefID = securityTicket.TenantID; personToAccountQuery.USR_Account_RefID = account.USR_AccountID; personToAccountQuery.IsDeleted = false; var personToAccounts = ORM_CMN_PER_PersonInfo_2_Account.Query.Search(Connection, Transaction, personToAccountQuery); if (personToAccounts.Count != 0) { ORM_CMN_PER_PersonInfo_2_Account personToAccount = personToAccounts[0]; personToAccount.CMN_PER_PersonInfo_RefID = person.CMN_PER_PersonInfoID; personToAccount.USR_Account_RefID = account.USR_AccountID; personToAccount.Tenant_RefID = securityTicket.TenantID; personToAccount.Save(Connection, Transaction); } else { ORM_CMN_PER_PersonInfo_2_Account personToAccount = new ORM_CMN_PER_PersonInfo_2_Account(); personToAccount.CMN_PER_PersonInfo_RefID = person.CMN_PER_PersonInfoID; personToAccount.USR_Account_RefID = account.USR_AccountID; personToAccount.Tenant_RefID = securityTicket.TenantID; personToAccount.Save(Connection, Transaction); } } if (Parameter.Rights != null) { foreach (var rightsParam in Parameter.Rights) { if (rightsParam.RightAssinmentID == Guid.Empty && rightsParam.RightID != Guid.Empty) { var right2account = new ORM_USR_Account_2_FunctionLevelRight(); right2account.Account_RefID = Parameter.USR_AccountID; right2account.FunctionLevelRight_RefID = rightsParam.RightID; right2account.Tenant_RefID = securityTicket.TenantID; right2account.Save(Connection, Transaction); CSV2Core.DlTrace.Trace("success save right: " + right2account.FunctionLevelRight_RefID); } if (rightsParam.RightAssinmentID != Guid.Empty && rightsParam.RightID == Guid.Empty) { var right2account = new ORM_USR_Account_2_FunctionLevelRight(); if (rightsParam.RightAssinmentID != Guid.Empty) { var result = right2account.Load(Connection, Transaction, rightsParam.RightAssinmentID); if (result.Status != FR_Status.Success || right2account.AssignmentID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } right2account.IsDeleted = true; right2account.Save(Connection, Transaction); CSV2Core.DlTrace.Trace("success save right2Acc: " + right2account.FunctionLevelRight_RefID); } } } } CSV2Core.DlTrace.Trace("emp id wtf " + Parameter.CMN_BPT_EMP_EmployeeID); if (Parameter.CMN_BPT_EMP_EmployeeID == Guid.Empty || resignationDateChanged) { var enterpriseService = InfrastructureFactory.CreateEnterpriseService(); KeyPerformanceIndicator action = new KeyPerformanceIndicator(); action.PerformedByAccountID = securityTicket.AccountID; action.PerformedByApplicationID = Parameter.ApplicationID; action.PerformedOn = DateTime.Now; action.PerformedByTenantID = securityTicket.TenantID; action.KeyPerformanceIndicatorID = Guid.Parse("4dda967a-5399-4929-afae-7af64699895b"); action.Value = cls_Get_Employees_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result.Where(i => i.Work_EndDate.Ticks == 0 || i.Work_EndDate.Ticks > DateTime.Now.Ticks).ToArray().Length; var result = enterpriseService.SendMessage(action.ToPayload(), KeyPerformanceIndicator.MESSAGE_TYPE, Parameter.ApplicationID, EMessageRecipient.CUSTOMER_MANAGEMENT_PLATFORM); // ServerLog.Instance.Info("Enterprise message sending " + (result.Code == 200 ? "successful" : "failed")); CSV2Core.DlTrace.Trace("success send kpi"); } Parameter.TaxInfoParameter.EmployeeID = employee.CMN_BPT_EMP_EmployeeID; Parameter.TaxInfoParameter.CMN_BPT_BusinessParticipantID = bParticipant.CMN_BPT_BusinessParticipantID; cls_Save_Employee_TaxInformation.Invoke(Connection, Transaction, Parameter.TaxInfoParameter, securityTicket); cls_Save_Employee_BankAccount.Invoke(Connection, Transaction, Parameter.BankAccountParameter, securityTicket); Parameter.SocialSecurity.CMN_PER_PersonInfoID = person.CMN_PER_PersonInfoID; Parameter.SocialSecurity.CMN_BPT_EMP_EmployeeID = employee.CMN_BPT_EMP_EmployeeID; Parameter.SocialSecurity.CMN_BPT_BusinessParticipantID = bParticipant.CMN_BPT_BusinessParticipantID; cls_Save_Employee_SocialSecurity.Invoke(Connection, Transaction, Parameter.SocialSecurity, securityTicket); returnValue.Result = employee.CMN_BPT_EMP_EmployeeID; return(returnValue); #endregion UserCode }
protected static FR_L5WP_GWPFWPID_1132 Execute(DbConnection Connection, DbTransaction Transaction, P_L5WP_GWPFWPID_1132 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5WP_GWPFWPID_1132(); returnValue.Result = new L5WP_GWPFWPID_1132(); L5WP_GWFT_1203 result = new L5WP_GWFT_1203(); ORM_CMN_STR_PPS_Workplace item = new ORM_CMN_STR_PPS_Workplace(); if (Parameter.workplaceID != Guid.Empty) { var resultWorkplace = item.Load(Connection, Transaction, Parameter.workplaceID); if (resultWorkplace.Status != FR_Status.Success || item.CMN_STR_PPS_WorkplaceID == 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_PPS_WorkplaceID = item.CMN_STR_PPS_WorkplaceID; result.ShortName = item.ShortName; result.WorkArea_RefID = item.WorkArea_RefID; result.WorkPlaceDescription = item.Description; result.WorkPlaceName = item.Name; var responsiblePersonsQuery = new ORM_CMN_STR_PPS_Workplace_ResponsiblePerson.Query(); responsiblePersonsQuery.Tenant_RefID = securityTicket.TenantID; responsiblePersonsQuery.Workplace_RefID = item.CMN_STR_PPS_WorkplaceID; responsiblePersonsQuery.IsDeleted = false; var responsiblePersonsList = ORM_CMN_STR_PPS_Workplace_ResponsiblePerson.Query.Search(Connection, Transaction, responsiblePersonsQuery); List <L5WP_GWFT_1203_ResponsiblePerson> responsiblePresonsResultList = new List <L5WP_GWFT_1203_ResponsiblePerson>(); foreach (var responsiblePerson in responsiblePersonsList) { L5WP_GWFT_1203_ResponsiblePerson responsiblePersonResult = new L5WP_GWFT_1203_ResponsiblePerson(); responsiblePersonResult.CMN_BPT_EMP_EmployeeID = responsiblePerson.CMN_BPT_EMP_Employee_RefID; responsiblePersonResult.CMN_STR_PPS_Workplace_ResponsiblePersonID = responsiblePerson.CMN_STR_PPS_Workplace_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; responsiblePresonsResultList.Add(responsiblePersonResult); } result.ResponsiblePersons = responsiblePresonsResultList.ToArray(); returnValue.Result.workplace = result; //Put your code here return(returnValue); #endregion UserCode }
protected static FR_Bool Execute(DbConnection Connection, DbTransaction Transaction, P_L5ZW_SDfNC_1707 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Bool(); returnValue.Result = false; //Put your code here #region get securityTicket and businessParticipantID by Paramter.AccountID and set defaultLanguageID Guid tenantID; Guid businessParticipantID; if (Parameter.AccountID == Guid.Empty) { return(returnValue); } ORM_USR_Account orm_account = new ORM_USR_Account(); var result = orm_account.Load(Connection, Transaction, Parameter.AccountID); if (result.Status != FR_Status.Success || orm_account.USR_AccountID == Guid.Empty) { return(returnValue); } tenantID = orm_account.Tenant_RefID; securityTicket = new CSV2Core.SessionSecurity.SessionSecurityTicket() { TenantID = tenantID }; ORM_CMN_BPT_BusinessParticipant.Query businessParticipantQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); businessParticipantQuery.IfTenant_Tenant_RefID = tenantID; businessParticipantQuery.IsDeleted = false; ORM_CMN_BPT_BusinessParticipant businessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, businessParticipantQuery).FirstOrDefault(); if (businessParticipant == null) { return(returnValue); } businessParticipantID = businessParticipant.CMN_BPT_BusinessParticipantID; #endregion #region get languages for tenant and set parameter dict values P_L2LN_GALFTID_1530 languageParam = new P_L2LN_GALFTID_1530() { Tenant_RefID = tenantID }; L2LN_GALFTID_1530[] languages = cls_Get_All_Languages_ForTenantID.Invoke(Connection, Transaction, languageParam, securityTicket).Result; SetParameterDictValues(Parameter, languages); List <ISOLanguage> languagesISOs = new List <ISOLanguage>(); languagesISOs.AddRange(languages.Select(l => new ISOLanguage() { ISO = l.ISO_639_1, LanguageID = l.CMN_LanguageID }).ToList()); #endregion #region save defaultLanguage // We are setting language for bp and acc var defaultLanguage = languages.FirstOrDefault(i => i.ISO_639_1.ToLower().Contains(Parameter.DefaultLanguageCode.ToLower())); if (defaultLanguage != null) { businessParticipant.DefaultLanguage_RefID = defaultLanguage.CMN_LanguageID; businessParticipant.Save(Connection, Transaction); orm_account.DefaultLanguage_RefID = defaultLanguage.CMN_LanguageID; orm_account.Save(Connection, Transaction); } #endregion #region save default country if (Parameter.DefaultCountry != null) { ORM_CMN_Country country = new ORM_CMN_Country(); country.CMN_CountryID = Guid.NewGuid(); country.Country_ISOCode_Alpha3 = Parameter.DefaultCountry.Code; country.Country_Name = new Dict() { DictionaryID = Guid.NewGuid() }; country.Creation_Timestamp = DateTime.Now; country.Default_Currency_RefID = Guid.Empty; country.Default_Language_RefID = Guid.Empty; country.Tenant_RefID = tenantID; country.IsDeleted = false; country.IsDefault = true; foreach (var languageItem in languages) { country.Country_Name.UpdateEntry(languageItem.CMN_LanguageID, Parameter.DefaultCountry.Name); } country.Save(Connection, Transaction); } #endregion #region save default currency //asign currency if (Parameter.DefaultCurrency != null) { ORM_CMN_Currency currency = new ORM_CMN_Currency(); currency.CMN_CurrencyID = Guid.NewGuid(); currency.Creation_Timestamp = DateTime.Now; currency.IsDeleted = false; currency.ISO4127 = Parameter.DefaultCurrency.Code; currency.Name = new Dict() { DictionaryID = Guid.NewGuid() }; currency.Tenant_RefID = tenantID; foreach (var language in languages) { currency.Name.UpdateEntry(language.CMN_LanguageID, Parameter.DefaultCurrency.Name); } currency.Save(Connection, Transaction); //set default currency ORM_CMN_BPT_BusinessParticipant businessPart = new ORM_CMN_BPT_BusinessParticipant(); businessPart.Load(Connection, Transaction, businessParticipantID); businessPart.DefaultCurrency_RefID = currency.CMN_CurrencyID; businessPart.Save(Connection, Transaction); } #endregion #region save organisational units if (Parameter.OrganisationalUnitParameters.Length > 0) { foreach (var item in Parameter.OrganisationalUnitParameters) { cls_Save_Office.Invoke(Connection, Transaction, item, securityTicket); } } #endregion #region save cost centers if (Parameter.CostCenterParameters.Length > 0) { foreach (var item in Parameter.CostCenterParameters) { cls_Save_CostCenter.Invoke(Connection, Transaction, item, securityTicket); } } #endregion #region save warehouses if (Parameter.WarehousesParameters.Length > 0) { #region save warehouse group P_L2WH_SWHG_1327 warehouseGroupParam = new P_L2WH_SWHG_1327(); warehouseGroupParam.Parent_RefID = Guid.Empty; warehouseGroupParam.WarehouseGroup_Name = "Waregouse group"; warehouseGroupParam.WarehouseGroup_Description = new Dict() { DictionaryID = Guid.NewGuid() }; foreach (var language in languages) { warehouseGroupParam.WarehouseGroup_Description.UpdateEntry(language.CMN_LanguageID, String.Empty); } var warehouseGroupID = cls_Save_Warehouse_Group.Invoke(Connection, Transaction, warehouseGroupParam, securityTicket).Result; #endregion foreach (var item in Parameter.WarehousesParameters) { item.LOG_WRH_WarehouseGroupID = warehouseGroupID; cls_Save_Warehouse.Invoke(Connection, Transaction, item, securityTicket); } } #endregion #region create dimension templates string jsonTemplates = ReadFromFile.LoadContentFromFile(@"Dimensions.json"); List <Dimension> dimensionTemplates = JsonConvert.DeserializeObject <List <Dimension> >(jsonTemplates); int orderSequence = 1; ORM_CMN_PRO_Dimension orm_dimension; ORM_CMN_PRO_Dimension_Value orm_dimensionValue; foreach (var template in dimensionTemplates) { orderSequence = 1; #region save dimension orm_dimension = new ORM_CMN_PRO_Dimension(); orm_dimension.Product_RefID = Guid.Empty; orm_dimension.DimensionName = new Dict() { DictionaryID = Guid.NewGuid() }; orm_dimension.IsDimensionTemplate = true; orm_dimension.Tenant_RefID = tenantID; foreach (var language in languages) { orm_dimension.DimensionName.UpdateEntry(language.CMN_LanguageID, template.Name); } orm_dimension.Save(Connection, Transaction); #endregion #region save dimension values foreach (var templateValue in template.DimansionValues) { orm_dimensionValue = new ORM_CMN_PRO_Dimension_Value(); orm_dimensionValue.Dimensions_RefID = orm_dimension.CMN_PRO_DimensionID; orm_dimensionValue.DimensionValue_Text = new Dict() { DictionaryID = Guid.NewGuid() }; orm_dimensionValue.Tenant_RefID = tenantID; orm_dimensionValue.OrderSequence = orderSequence; foreach (var language in languages) { orm_dimensionValue.DimensionValue_Text.UpdateEntry(language.CMN_LanguageID, templateValue); } orm_dimensionValue.Save(Connection, Transaction); orderSequence++; } #endregion } #endregion #region create shipment types string shipmentTypesJson = ReadFromFile.LoadContentFromFile(@"ShipmentTypes.json"); List <ShipmentTypes> shipmentTypes = JsonConvert.DeserializeObject <List <ShipmentTypes> >(shipmentTypesJson); ORM_LOG_SHP_Shipment_Type orm_shipmentType; foreach (var type in shipmentTypes) { #region save LOG_SHP_Shipment_Type orm_shipmentType = new ORM_LOG_SHP_Shipment_Type(); orm_shipmentType.ShipmentType_Name = new Dict() { DictionaryID = Guid.NewGuid() }; orm_shipmentType.ShipmentType_Description = new Dict() { DictionaryID = Guid.NewGuid() }; orm_shipmentType.Tenant_RefID = tenantID; foreach (var language in languages) { orm_shipmentType.ShipmentType_Name.UpdateEntry(language.CMN_LanguageID, type.Name); orm_shipmentType.ShipmentType_Description.UpdateEntry(language.CMN_LanguageID, string.Empty); } orm_shipmentType.Save(Connection, Transaction); #endregion } #endregion #region create number ranges string numberRangesJson = ReadFromFile.LoadContentFromFile(@"NumberRanges.json"); NumberRange numberRanges = JsonConvert.DeserializeObject <NumberRange>(numberRangesJson); ORM_CMN_NumberRange_UsageArea numberRangeUsageArea; ORM_CMN_NumberRange orm_numberRanges; foreach (var item in numberRanges.NumberRanges) { if (Parameter.IsCustomerRegistration && item.Name == "Customer orders") { continue; } if (!Parameter.IsCustomerRegistration && item.Name == "Distribution orders") { continue; } if (!Parameter.IsCustomerRegistration && item.Name == "Procurement orders") { continue; } numberRangeUsageArea = new ORM_CMN_NumberRange_UsageArea(); numberRangeUsageArea.UsageArea_Name = new Dict() { DictionaryID = Guid.NewGuid() }; numberRangeUsageArea.UsageArea_Description = new Dict() { DictionaryID = Guid.NewGuid() }; foreach (var language in languages) { numberRangeUsageArea.UsageArea_Name.UpdateEntry(language.CMN_LanguageID, item.Name); numberRangeUsageArea.UsageArea_Description.UpdateEntry(language.CMN_LanguageID, string.Empty); } numberRangeUsageArea.Tenant_RefID = tenantID; numberRangeUsageArea.GlobalStaticMatchingID = item.GlobalStaticMatchingID; numberRangeUsageArea.Save(Connection, Transaction); orm_numberRanges = new ORM_CMN_NumberRange(); orm_numberRanges.NumberRange_Name = item.Name; orm_numberRanges.Tenant_RefID = tenantID; orm_numberRanges.NumberRange_UsageArea_RefID = numberRangeUsageArea.CMN_NumberRange_UsageAreaID; orm_numberRanges.FixedPrefix = item.FixedPrefix; orm_numberRanges.Formatting_LeadingFillCharacter = item.FillCharacter; orm_numberRanges.Formatting_NumberLength = item.Length; orm_numberRanges.Value_Current = item.CurrentValue; orm_numberRanges.Value_Start = item.StartValue; orm_numberRanges.Value_End = item.EndValue; orm_numberRanges.Save(Connection, Transaction); } #endregion #region create inventory change reasons string inventoryChangeReasonsJson = ReadFromFile.LoadContentFromFile(@"InventoryChangeReasons.json"); List <InventoryChangeReasons> inventoryChangeReasons = JsonConvert.DeserializeObject <List <InventoryChangeReasons> >(inventoryChangeReasonsJson); ORM_LOG_WRH_InventoryChangeReason orm_inventoryChangeReason; foreach (var reason in inventoryChangeReasons) { #region save inventory change reason orm_inventoryChangeReason = new ORM_LOG_WRH_InventoryChangeReason(); orm_inventoryChangeReason.GlobalPropertyMatchingID = InventoryChangeReasons.InventoryChangeReasonGlobalPropertyMatchingID + "-" + reason.Name; orm_inventoryChangeReason.InventoryChange_Name = new Dict() { DictionaryID = Guid.NewGuid() }; orm_inventoryChangeReason.InventoryChange_Description = new Dict() { DictionaryID = Guid.NewGuid() }; orm_inventoryChangeReason.Tenant_RefID = tenantID; foreach (var language in languages) { orm_inventoryChangeReason.InventoryChange_Name.UpdateEntry(language.CMN_LanguageID, reason.Name); orm_inventoryChangeReason.InventoryChange_Description.UpdateEntry(language.CMN_LanguageID, string.Empty); } orm_inventoryChangeReason.Save(Connection, Transaction); #endregion } #endregion #region create shipment statuses var shipmentStatuses = Enum.GetValues(typeof(EShipmentStatus)); var shipmentStatusDicts = EnumUtils.GetDictObjectsForStaticListData <EShipmentStatus>( ResourceFilePath.ShipmentStatus, ORM_LOG_SHP_Shipment_Status.TableName, languagesISOs); var statusCodeCount = 1; ORM_LOG_SHP_Shipment_Status shipmentStatus; foreach (EShipmentStatus status in shipmentStatuses) { shipmentStatus = new ORM_LOG_SHP_Shipment_Status(); shipmentStatus.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription((EShipmentStatus)status); shipmentStatus.Status_Code = statusCodeCount++; shipmentStatus.Status_Name = shipmentStatusDicts[EnumUtils.GetEnumDescription((EShipmentStatus)status)]; shipmentStatus.Tenant_RefID = tenantID; shipmentStatus.Save(Connection, Transaction); } #endregion if (Parameter.IsCustomerRegistration) { #region create procurement order statuses var procurementStatuses = Enum.GetValues(typeof(EProcurementStatus)); ORM_ORD_PRC_ProcurementOrder_Status procurementOrderStatus; foreach (EProcurementStatus status in procurementStatuses) { procurementOrderStatus = new ORM_ORD_PRC_ProcurementOrder_Status(); procurementOrderStatus.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(status); procurementOrderStatus.Tenant_RefID = tenantID; procurementOrderStatus.Save(Connection, Transaction); } #endregion } else { #region create customer order statuses var customerOrderStatuses = Enum.GetValues(typeof(ECustomerOrderStatus)); var customerOrderStatusesDicts = EnumUtils.GetDictObjectsForStaticListData <ECustomerOrderStatus>( ResourceFilePath.CustomerOrderStatus, ORM_ORD_CUO_CustomerOrder_Status.TableName, languagesISOs); var count = 1; ORM_ORD_CUO_CustomerOrder_Status customerOrderStatus; foreach (var status in customerOrderStatuses) { customerOrderStatus = new ORM_ORD_CUO_CustomerOrder_Status(); customerOrderStatus.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription((ECustomerOrderStatus)status); customerOrderStatus.Status_Code = count++; customerOrderStatus.Status_Name = customerOrderStatusesDicts[EnumUtils.GetEnumDescription((ECustomerOrderStatus)status)]; customerOrderStatus.Tenant_RefID = tenantID; customerOrderStatus.Save(Connection, Transaction); } #endregion } returnValue.Result = true; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6PA_SBBVP_1223 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); ORM_HEC_Patient patient = new ORM_HEC_Patient(); if (Parameter.HEC_PatientID != Guid.Empty) { var result = patient.Load(Connection, Transaction, Parameter.HEC_PatientID); if (result.Status != FR_Status.Success || patient.HEC_PatientID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } patient.IsPatientParticipationPolicyValidated = Parameter.HasFulfilledParticipationPolicyRequirements; patient.PatientComment = Parameter.Comment; patient.Tenant_RefID = securityTicket.TenantID; ORM_CMN_BPT_BusinessParticipant bParticipant = new ORM_CMN_BPT_BusinessParticipant(); if (patient.CMN_BPT_BusinessParticipant_RefID != Guid.Empty) { var result = bParticipant.Load(Connection, Transaction, patient.CMN_BPT_BusinessParticipant_RefID); if (result.Status != FR_Status.Success || bParticipant.CMN_BPT_BusinessParticipantID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } bParticipant.IsNaturalPerson = true; bParticipant.Tenant_RefID = securityTicket.TenantID; ORM_CMN_PER_PersonInfo person = new ORM_CMN_PER_PersonInfo(); if (bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID != Guid.Empty) { var result = person.Load(Connection, Transaction, bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID); if (result.Status != FR_Status.Success || person.CMN_PER_PersonInfoID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } person.FirstName = Parameter.FirstName; person.LastName = Parameter.LastName; person.PrimaryEmail = Parameter.Mail; person.Tenant_RefID = securityTicket.TenantID; person.Salutation_General = Parameter.Salutation; person.Save(Connection, Transaction); bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = person.CMN_PER_PersonInfoID; bParticipant.Save(Connection, Transaction); patient.CMN_BPT_BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; patient.Save(Connection, Transaction); ORM_CMN_PER_CommunicationContact.Query contactQuery = new ORM_CMN_PER_CommunicationContact.Query(); contactQuery.IsDeleted = false; contactQuery.Tenant_RefID = securityTicket.TenantID; contactQuery.PersonInfo_RefID = person.CMN_PER_PersonInfoID; var contactQueryRes = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, contactQuery); ORM_CMN_PER_CommunicationContact contactPhone = contactQueryRes.FirstOrDefault(c => c.Contact_Type == STLD_ContactTypes.Phone); ORM_CMN_PER_CommunicationContact contactFax = contactQueryRes.FirstOrDefault(c => c.Contact_Type == STLD_ContactTypes.Fax); if (contactPhone == null) { contactPhone = new ORM_CMN_PER_CommunicationContact(); contactPhone.Contact_Type = STLD_ContactTypes.Phone; contactPhone.Tenant_RefID = securityTicket.TenantID; contactPhone.PersonInfo_RefID = person.CMN_PER_PersonInfoID; } contactPhone.Content = Parameter.Phone; contactPhone.Save(Connection, Transaction); if (contactFax == null) { contactFax = new ORM_CMN_PER_CommunicationContact(); contactFax.Content = Parameter.Fax; contactFax.Contact_Type = STLD_ContactTypes.Fax; contactFax.Tenant_RefID = securityTicket.TenantID; contactFax.PersonInfo_RefID = person.CMN_PER_PersonInfoID; contactFax.Save(Connection, Transaction); } contactFax.Content = Parameter.Fax; contactFax.Save(Connection, Transaction); ORM_HEC_Patient_HealthInsurance.Query Patient_HealthInsuranceQuery = new ORM_HEC_Patient_HealthInsurance.Query(); Patient_HealthInsuranceQuery.Tenant_RefID = securityTicket.TenantID; Patient_HealthInsuranceQuery.IsDeleted = false; Patient_HealthInsuranceQuery.Patient_RefID = patient.HEC_PatientID; ORM_HEC_Patient_HealthInsurance Patient_HealthInsurance; var Patient_HealthInsuranceQueryRes = ORM_HEC_Patient_HealthInsurance.Query.Search(Connection, Transaction, Patient_HealthInsuranceQuery); if (Patient_HealthInsuranceQueryRes.Count == 1) { Patient_HealthInsurance = Patient_HealthInsuranceQueryRes[0]; } else { Patient_HealthInsurance = new ORM_HEC_Patient_HealthInsurance(); Patient_HealthInsurance.Patient_RefID = patient.HEC_PatientID; Patient_HealthInsurance.Tenant_RefID = securityTicket.TenantID; Patient_HealthInsurance.IsPrimary = true; } Patient_HealthInsurance.HealthInsurance_Number = Parameter.HealthcareNumber; Patient_HealthInsurance.Save(Connection, Transaction); ORM_HEC_STU_Study_ParticipatingPatient.Query Study_ParticipatingPatientsQuery = new ORM_HEC_STU_Study_ParticipatingPatient.Query(); Study_ParticipatingPatientsQuery.Tenant_RefID = securityTicket.TenantID; Study_ParticipatingPatientsQuery.IsDeleted = false; Study_ParticipatingPatientsQuery.Patient_RefID = patient.HEC_PatientID; ORM_HEC_STU_Study_ParticipatingPatient Study_ParticipatingPatients; var Study_ParticipatingPatientsQueryRes = ORM_HEC_STU_Study_ParticipatingPatient.Query.Search(Connection, Transaction, Study_ParticipatingPatientsQuery); if (Study_ParticipatingPatientsQueryRes.Count == 1) { Study_ParticipatingPatients = Study_ParticipatingPatientsQueryRes[0]; } else { Study_ParticipatingPatients = new ORM_HEC_STU_Study_ParticipatingPatient(); Study_ParticipatingPatients.Patient_RefID = patient.HEC_PatientID; Study_ParticipatingPatients.Tenant_RefID = securityTicket.TenantID; } Study_ParticipatingPatients.HasFulfilledParticipationPolicyRequirements = Parameter.HasFulfilledParticipationPolicyRequirements; Study_ParticipatingPatients.Save(Connection, Transaction); returnValue.Result = patient.HEC_PatientID; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6PA_SMSP_1548 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); ORM_HEC_Patient patient = new ORM_HEC_Patient(); if (Parameter.HEC_PatientID != Guid.Empty) { var result = patient.Load(Connection, Transaction, Parameter.HEC_PatientID); if (result.Status != FR_Status.Success || patient.HEC_PatientID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } patient.IsPatientParticipationPolicyValidated = Parameter.HasFulfilledParticipationPolicyRequirements; patient.PatientComment = Parameter.Comment; patient.Tenant_RefID = securityTicket.TenantID; ORM_CMN_BPT_BusinessParticipant bParticipant = new ORM_CMN_BPT_BusinessParticipant(); if (patient.CMN_BPT_BusinessParticipant_RefID != Guid.Empty) { var result = bParticipant.Load(Connection, Transaction, patient.CMN_BPT_BusinessParticipant_RefID); if (result.Status != FR_Status.Success || bParticipant.CMN_BPT_BusinessParticipantID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } bParticipant.IsNaturalPerson = true; bParticipant.Tenant_RefID = securityTicket.TenantID; ORM_CMN_PER_PersonInfo person = new ORM_CMN_PER_PersonInfo(); if (bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID != Guid.Empty) { var result = person.Load(Connection, Transaction, bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID); if (result.Status != FR_Status.Success || person.CMN_PER_PersonInfoID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } person.FirstName = Parameter.FirstName; person.LastName = Parameter.LastName; person.PrimaryEmail = Parameter.Mail; person.Tenant_RefID = securityTicket.TenantID; person.Salutation_General = Parameter.Salutation; person.Save(Connection, Transaction); bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = person.CMN_PER_PersonInfoID; bParticipant.Save(Connection, Transaction); patient.CMN_BPT_BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; patient.Save(Connection, Transaction); ORM_CMN_PER_CommunicationContact.Query contactQuery = new ORM_CMN_PER_CommunicationContact.Query(); contactQuery.IsDeleted = false; contactQuery.Tenant_RefID = securityTicket.TenantID; contactQuery.PersonInfo_RefID = person.CMN_PER_PersonInfoID; var contactQueryRes = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, contactQuery); ORM_CMN_PER_CommunicationContact contactPhone = contactQueryRes.FirstOrDefault(c => c.Contact_Type == STLD_ContactTypes.Phone); ORM_CMN_PER_CommunicationContact contactFax = contactQueryRes.FirstOrDefault(c => c.Contact_Type == STLD_ContactTypes.Fax); if (contactPhone == null) { contactPhone = new ORM_CMN_PER_CommunicationContact(); contactPhone.Contact_Type = STLD_ContactTypes.Phone; contactPhone.Tenant_RefID = securityTicket.TenantID; contactPhone.PersonInfo_RefID = person.CMN_PER_PersonInfoID; } contactPhone.Content = Parameter.Phone; contactPhone.Save(Connection, Transaction); if (contactFax == null) { contactFax = new ORM_CMN_PER_CommunicationContact(); contactFax.Content = Parameter.Fax; contactFax.Contact_Type = STLD_ContactTypes.Fax; contactFax.Tenant_RefID = securityTicket.TenantID; contactFax.PersonInfo_RefID = person.CMN_PER_PersonInfoID; contactFax.Save(Connection, Transaction); } contactFax.Content = Parameter.Fax; contactFax.Save(Connection, Transaction); ORM_HEC_Patient_HealthInsurance.Query Patient_HealthInsuranceQuery = new ORM_HEC_Patient_HealthInsurance.Query(); Patient_HealthInsuranceQuery.Tenant_RefID = securityTicket.TenantID; Patient_HealthInsuranceQuery.IsDeleted = false; Patient_HealthInsuranceQuery.Patient_RefID = patient.HEC_PatientID; ORM_HEC_Patient_HealthInsurance Patient_HealthInsurance; var Patient_HealthInsuranceQueryRes = ORM_HEC_Patient_HealthInsurance.Query.Search(Connection, Transaction, Patient_HealthInsuranceQuery); if (Patient_HealthInsuranceQueryRes.Count == 1) { Patient_HealthInsurance = Patient_HealthInsuranceQueryRes[0]; } else { Patient_HealthInsurance = new ORM_HEC_Patient_HealthInsurance(); Patient_HealthInsurance.Patient_RefID = patient.HEC_PatientID; Patient_HealthInsurance.Tenant_RefID = securityTicket.TenantID; Patient_HealthInsurance.IsPrimary = true; } Patient_HealthInsurance.HealthInsurance_Number = Parameter.HealthcareNumber; Patient_HealthInsurance.Save(Connection, Transaction); ORM_HEC_STU_Study_ParticipatingPatient.Query Study_ParticipatingPatientsQuery = new ORM_HEC_STU_Study_ParticipatingPatient.Query(); Study_ParticipatingPatientsQuery.Tenant_RefID = securityTicket.TenantID; Study_ParticipatingPatientsQuery.IsDeleted = false; Study_ParticipatingPatientsQuery.Patient_RefID = patient.HEC_PatientID; ORM_HEC_STU_Study_ParticipatingPatient Study_ParticipatingPatients; var Study_ParticipatingPatientsQueryRes = ORM_HEC_STU_Study_ParticipatingPatient.Query.Search(Connection, Transaction, Study_ParticipatingPatientsQuery); if (Study_ParticipatingPatientsQueryRes.Count == 1) { Study_ParticipatingPatients = Study_ParticipatingPatientsQueryRes[0]; } else { Study_ParticipatingPatients = new ORM_HEC_STU_Study_ParticipatingPatient(); Study_ParticipatingPatients.Patient_RefID = patient.HEC_PatientID; Study_ParticipatingPatients.Tenant_RefID = securityTicket.TenantID; } Study_ParticipatingPatients.HasFulfilledParticipationPolicyRequirements = Parameter.HasFulfilledParticipationPolicyRequirements; Study_ParticipatingPatients.Save(Connection, Transaction); ORM_USR_Account account; ORM_USR_Account.Query ORM_USR_AccountQuery = new ORM_USR_Account.Query(); ORM_USR_AccountQuery.IsDeleted = false; ORM_USR_AccountQuery.Tenant_RefID = securityTicket.TenantID; ORM_USR_AccountQuery.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; var accountRes = ORM_USR_Account.Query.Search(Connection, Transaction, ORM_USR_AccountQuery); if (accountRes.Count == 1) { account = accountRes[0]; } else { account = new ORM_USR_Account(); account.Tenant_RefID = securityTicket.TenantID; account.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; account.AccountType = 3; account.Save(Connection, Transaction); } ORM_USR_Device_AccountCode.Query ORM_USR_Device_AccountCodeQuery = new ORM_USR_Device_AccountCode.Query(); ORM_USR_Device_AccountCodeQuery.IsDeleted = false; ORM_USR_Device_AccountCodeQuery.Tenant_RefID = securityTicket.TenantID; ORM_USR_Device_AccountCodeQuery.Account_RefID = account.USR_AccountID; var accountCodeRes = ORM_USR_Device_AccountCode.Query.Search(Connection, Transaction, ORM_USR_Device_AccountCodeQuery); if (accountCodeRes.Count == 0) { P_L2DC_GUDCfT_1505 codeParam = new P_L2DC_GUDCfT_1505(); codeParam.codeLength = 8; var checkCodeValue = cls_GetUniqueDeviceCodeForTenant.Invoke(Connection, Transaction, codeParam, securityTicket).Result; ORM_USR_Device_AccountCode_StatusHistory AccountCode_StatusHistory = new ORM_USR_Device_AccountCode_StatusHistory(); AccountCode_StatusHistory.Tenant_RefID = securityTicket.TenantID; AccountCode_StatusHistory.IsAccountCode_Active = true; AccountCode_StatusHistory.Save(Connection, Transaction); ORM_USR_Device_AccountCode devoceAccpimtCpde = new ORM_USR_Device_AccountCode(); devoceAccpimtCpde.Account_RefID = account.USR_AccountID; devoceAccpimtCpde.Tenant_RefID = securityTicket.TenantID; devoceAccpimtCpde.AccountCode_Value = checkCodeValue.CodeValue; devoceAccpimtCpde.IsAccountCode_Expirable = false; devoceAccpimtCpde.AccountCode_CurrentStatus_RefID = AccountCode_StatusHistory.USR_Device_AccountCode_StatusHistoryID; devoceAccpimtCpde.Save(Connection, Transaction); AccountCode_StatusHistory.Device_AccountCode_RefID = devoceAccpimtCpde.USR_Device_AccountCodeID; AccountCode_StatusHistory.Save(Connection, Transaction); } returnValue.Result = patient.HEC_PatientID; 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_L6LG_GDfDLR_1522 Execute(DbConnection Connection, DbTransaction Transaction, P_L6LG_GDfDLR_1522 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6LG_GDfDLR_1522(); L5SO_GSaCOHDfSH_1446 shipmentAndCustomerOrderDetails = null; #region Retrieve Shipment and CustomerOrder Details P_L5SO_GSaCOHDfSH_1446 shipmentAndCustomerOrderDetailsParameter = new P_L5SO_GSaCOHDfSH_1446(); shipmentAndCustomerOrderDetailsParameter.ShippingHeaderID = Parameter.ShipmentHeaderID; FR_L5SO_GSaCOHDfSH_1446 shipmentAndCustomerOrderDetailsResult = CL5_APOLogistic_ShippingOrder.Atomic.Retrieval.cls_Get_Shipment_and_CustomerOrderHeaderDetails_for_ShipmentHeaderID.Invoke(Connection, Transaction, shipmentAndCustomerOrderDetailsParameter, securityTicket); shipmentAndCustomerOrderDetails = shipmentAndCustomerOrderDetailsResult.Result; #endregion #region Customer name var customerName = ""; if (shipmentAndCustomerOrderDetails != null && shipmentAndCustomerOrderDetails.OrderingCustomer_BusinessParticipant_RefID != Guid.Empty) { ORM_CMN_BPT_BusinessParticipant bp = new ORM_CMN_BPT_BusinessParticipant(); var bpResult = bp.Load(Connection, Transaction, shipmentAndCustomerOrderDetails.OrderingCustomer_BusinessParticipant_RefID); if (bpResult.Status == FR_Status.Success && bp.CMN_BPT_BusinessParticipantID != Guid.Empty) { customerName = bp.DisplayName; } } #endregion #region CustomerAddress var CustomerAddress = CL5_APOLogistic_ShippingOrder.Atomic.Retrieval.cls_Get_CustomerAddress_from_ShipmentHeaderID.Invoke(Connection, Transaction, new P_L5SO_GCAfSHI_1127 { ShipmentHeaderID = Parameter.ShipmentHeaderID }, securityTicket); #endregion #region Organisational unit Dict organizationalUnitName = null; if (shipmentAndCustomerOrderDetails != null && shipmentAndCustomerOrderDetails.CMN_BPT_CTM_OrganizationalUnit_RefID != Guid.Empty) { ORM_CMN_BPT_CTM_OrganizationalUnit orgUnit = new ORM_CMN_BPT_CTM_OrganizationalUnit(); var orgUnitResult = orgUnit.Load(Connection, Transaction, shipmentAndCustomerOrderDetails.CMN_BPT_CTM_OrganizationalUnit_RefID); if (orgUnitResult.Status == FR_Status.Success && orgUnit.CMN_BPT_CTM_OrganizationalUnitID != Guid.Empty) { organizationalUnitName = orgUnit.OrganizationalUnit_Name; } } #endregion L6SO_GASPbtWSvR_1413[] shipmentPositions = new L6SO_GASPbtWSvR_1413[0]; #region Retrieve Shipment Positions with reservation details (including storage place) P_L6SO_GASPbtWSvR_1413 shipmentPositionsParameter = new P_L6SO_GASPbtWSvR_1413(); shipmentPositionsParameter.ShipmentHeaderID = Parameter.ShipmentHeaderID; FR_L6SO_GASPbtWSvR_1413_Array shipmentPositionsForPickingListResult = cls_Get_AllShipmentPositions_bound_to_WarehouseStructure_via_Reservations.Invoke(Connection, Transaction, shipmentPositionsParameter, securityTicket); shipmentPositions = shipmentPositionsForPickingListResult.Result; #endregion #region Retrieve Customer Order Positions for Shipment Positions which are not shipped. P_L5CO_GACOPfUSP_1038 customerOrderPositionsForUnshippedShipmentPositionsParameter = new P_L5CO_GACOPfUSP_1038(); customerOrderPositionsForUnshippedShipmentPositionsParameter.ShipmentHeaderID = Parameter.ShipmentHeaderID; customerOrderPositionsForUnshippedShipmentPositionsParameter.OrganizationalUnitID = Parameter.OrganizationalUnitID; FR_L5CO_GACOPfUSP_1038_Array customerOrderPositionsForUnshippedShipmentPositionsResult = cls_Get_AllCustomerOrderPositions_for_Unshipped_ShipmentPositions.Invoke(Connection, Transaction, customerOrderPositionsForUnshippedShipmentPositionsParameter, securityTicket); L5CO_GACOPfUSP_1038[] customerOrderPositions = customerOrderPositionsForUnshippedShipmentPositionsResult.Result; #endregion // // Taking product array from shipment positions previously retrieved. // Product array is used for taking product information // IEnumerable <Guid> productIdList1 = shipmentPositions.Select(x => x.CMN_PRO_Product_RefID).Distinct(); IEnumerable <Guid> productIdList2 = customerOrderPositions.Select(x => x.CMN_PRO_Product_RefID).Distinct(); Guid[] productIdArray = productIdList1.Concat(productIdList2).Distinct().ToArray(); L3AR_GAfAL_0942[] articlesForArticleList = new L3AR_GAfAL_0942[0]; #region Retrive product details if (productIdArray.Length > 0) { P_L3AR_GAfAL_0942 articlesForArticleListParameter = new P_L3AR_GAfAL_0942(); articlesForArticleListParameter.ProductID_List = productIdArray; FR_L3AR_GAfAL_0942_Array articlesForArticleListResult = cls_Get_Articles_for_ArticleList.Invoke(Connection, Transaction, articlesForArticleListParameter, securityTicket); articlesForArticleList = articlesForArticleListResult.Result; } #endregion List <ORM_LOG_SHP_Shipment_Note> shipmentNoteList = new List <ORM_LOG_SHP_Shipment_Note>(); if (shipmentAndCustomerOrderDetails != null) { shipmentNoteList = ORM_LOG_SHP_Shipment_Note.Query .Search(Connection, Transaction, new ORM_LOG_SHP_Shipment_Note.Query { IsDeleted = false, IsNotePrintedOnDeliveryPaper = true, Shipment_Header_RefID = shipmentAndCustomerOrderDetails.LOG_SHP_Shipment_HeaderID }) .OrderBy(i => i.Creation_Timestamp).ToList(); } List <L6LG_GDfDLR_1522c> commentList = new List <L6LG_GDfDLR_1522c>(); foreach (ORM_LOG_SHP_Shipment_Note shipmentNote in shipmentNoteList) { L6LG_GDfDLR_1522c comment = new L6LG_GDfDLR_1522c(); ORM_CMN_BPT_BusinessParticipant businessParticipant = new ORM_CMN_BPT_BusinessParticipant(); FR_Base bpLoad = businessParticipant.Load(Connection, Transaction, shipmentNote.CreatedBy_BusinessParticipant_RefID); if (bpLoad.Status == FR_Status.Success) { comment.Name = businessParticipant.DisplayName; } comment.Comment = shipmentNote.Comment; commentList.Add(comment); } #region Building return object List <L6LG_GDfDLR_1522a> tempShipmentPositions = new List <L6LG_GDfDLR_1522a>(); foreach (L6SO_GASPbtWSvR_1413 shipmentPosition in shipmentPositions) { L6LG_GDfDLR_1522a tempShipmentPosition = new L6LG_GDfDLR_1522a(); tempShipmentPosition.ShipmentPositionDetails = shipmentPosition; tempShipmentPosition.ProductDetails = articlesForArticleList.FirstOrDefault(a => a.CMN_PRO_ProductID == shipmentPosition.CMN_PRO_Product_RefID); tempShipmentPositions.Add(tempShipmentPosition); } List <L6LG_GDfDLR_1522b> tempCustomerOrderPositions = new List <L6LG_GDfDLR_1522b>(); foreach (L5CO_GACOPfUSP_1038 customerOrderPosition in customerOrderPositions) { L6LG_GDfDLR_1522b tempCustomerOrderPosition = new L6LG_GDfDLR_1522b(); tempCustomerOrderPosition.CustomerOrderPositionDetails = customerOrderPosition; tempCustomerOrderPosition.ProductDetails = articlesForArticleList.FirstOrDefault(a => a.CMN_PRO_ProductID == customerOrderPosition.CMN_PRO_Product_RefID); tempCustomerOrderPositions.Add(tempCustomerOrderPosition); } returnValue.Result = new L6LG_GDfDLR_1522(); returnValue.Result.CustomerName = customerName; returnValue.Result.StreetAndNumber = CustomerAddress != null && CustomerAddress.Result != null ? CustomerAddress.Result.Street_Name + " " + CustomerAddress.Result.Street_Number : "keine Kundenadresse"; returnValue.Result.ZipAndCity = CustomerAddress != null && CustomerAddress.Result != null ? CustomerAddress.Result.ZIP + " " + CustomerAddress.Result.Town : "keine Kundenadresse"; returnValue.Result.OrganizationalUnitName = organizationalUnitName; returnValue.Result.ShipmentPositionList = tempShipmentPositions.ToArray(); returnValue.Result.CustomerOrderPositionList = tempCustomerOrderPositions.ToArray(); returnValue.Result.ShipmentAndCustomerOrderDetails = shipmentAndCustomerOrderDetails; returnValue.Result.CommentList = commentList.ToArray(); #endregion 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_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6DR_DDBID_1653 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); //Put your code here P_L6DR_DDBID_1653 param = new P_L6DR_DDBID_1653(); param.CMN_BPT_BusinessParticipantID = Parameter.CMN_BPT_BusinessParticipantID; var drivers = cls_Retrieve_Driver_Info_and_VerCode.Invoke(Connection, Transaction, securityTicket).Result; var driver = drivers.FirstOrDefault(x => x.CMN_BPT_BusinessParticipantID == param.CMN_BPT_BusinessParticipantID); if (driver != null) { ORM_CMN_PER_PersonInfo person = new ORM_CMN_PER_PersonInfo(); if (driver.CMN_PER_PersonInfoID != Guid.Empty) { var result = person.Load(Connection, Transaction, driver.CMN_PER_PersonInfoID); if (result.Status != FR_Status.Success || person.CMN_PER_PersonInfoID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } person.IsDeleted = true; person.Save(Connection, Transaction); } ORM_CMN_BPT_BusinessParticipant bParticipant = new ORM_CMN_BPT_BusinessParticipant(); if (driver.CMN_BPT_BusinessParticipantID != Guid.Empty) { var result = bParticipant.Load(Connection, Transaction, driver.CMN_BPT_BusinessParticipantID); if (result.Status != FR_Status.Success || bParticipant.CMN_BPT_BusinessParticipantID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } bParticipant.IsDeleted = true; bParticipant.Save(Connection, Transaction); } if (driver.Contacts != null) { foreach (var parContact in driver.Contacts) { ORM_CMN_PER_CommunicationContact contact = new ORM_CMN_PER_CommunicationContact(); if (parContact.CMN_PER_CommunicationContact_TypeID != Guid.Empty) { var result = contact.Load(Connection, Transaction, parContact.CMN_PER_CommunicationContact_TypeID); if (result.Status != FR_Status.Success || contact.CMN_PER_CommunicationContactID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } contact.IsDeleted = true; contact.Save(Connection, Transaction); } } } ORM_CMN_Address adress = new ORM_CMN_Address(); if (driver.CMN_AddressID != Guid.Empty) { var result = adress.Load(Connection, Transaction, driver.CMN_AddressID); if (result.Status != FR_Status.Success || adress.CMN_AddressID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } adress.IsDeleted = true; adress.Save(Connection, Transaction); } ORM_CMN_BPT_Supplier supplier = new ORM_CMN_BPT_Supplier(); if (driver.CMN_BPT_SupplierID != Guid.Empty) { var result = supplier.Load(Connection, Transaction, driver.CMN_BPT_SupplierID); if (result.Status != FR_Status.Success || supplier.CMN_BPT_SupplierID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } supplier.IsDeleted = true; supplier.Save(Connection, Transaction); } ORM_CMN_BPT_BusinessParticipant asossBParticipant = new ORM_CMN_BPT_BusinessParticipant(); if (driver.AssociatedBusinessParticipant_RefID != Guid.Empty) { var result = asossBParticipant.Load(Connection, Transaction, driver.AssociatedBusinessParticipant_RefID); if (result.Status != FR_Status.Success || asossBParticipant.CMN_BPT_BusinessParticipantID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } asossBParticipant.IsDeleted = true; asossBParticipant.Save(Connection, Transaction); } ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant BusinessParticipant_AssociatedBusinessParticipant = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant(); if (driver.AssociatedBusinessParticipant_RefID != Guid.Empty) { var result = BusinessParticipant_AssociatedBusinessParticipant.Load(Connection, Transaction, driver.CMN_BPT_BusinessParticipant_AssociatedBusinessParticipantID); if (result.Status != FR_Status.Success || BusinessParticipant_AssociatedBusinessParticipant.CMN_BPT_BusinessParticipant_AssociatedBusinessParticipantID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } BusinessParticipant_AssociatedBusinessParticipant.IsDeleted = true; BusinessParticipant_AssociatedBusinessParticipant.Save(Connection, Transaction); } ORM_USR_Account account = new ORM_USR_Account(); if (driver.USR_AccountID != Guid.Empty) { var result = account.Load(Connection, Transaction, driver.USR_AccountID); if (result.Status != FR_Status.Success || account.USR_AccountID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } account.IsDeleted = true; account.Save(Connection, Transaction); } ORM_USR_Device_AccountCode_StatusHistory Device_AccountCode_StatusHistory = new ORM_USR_Device_AccountCode_StatusHistory(); if (driver.USR_Device_AccountCode_UsageHistoryID != Guid.Empty) { var result = Device_AccountCode_StatusHistory.Load(Connection, Transaction, driver.USR_Device_AccountCode_UsageHistoryID); if (result.Status != FR_Status.Success || Device_AccountCode_StatusHistory.USR_Device_AccountCode_StatusHistoryID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } Device_AccountCode_StatusHistory.IsDeleted = true; Device_AccountCode_StatusHistory.Save(Connection, Transaction); } ORM_USR_Device_AccountCode accountCode = new ORM_USR_Device_AccountCode(); if (driver.USR_Device_AccountCodeID != Guid.Empty) { var result = accountCode.Load(Connection, Transaction, driver.USR_Device_AccountCodeID); if (result.Status != FR_Status.Success || accountCode.USR_Device_AccountCodeID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } accountCode.IsDeleted = true; accountCode.Save(Connection, Transaction); } var Device_AccountCode_UsageHistoryQuery = new ORM_USR_Device_AccountCode_UsageHistory.Query(); Device_AccountCode_UsageHistoryQuery.Device_AccountCode_RefID = accountCode.USR_Device_AccountCodeID; Device_AccountCode_UsageHistoryQuery.IsDeleted = false; Device_AccountCode_UsageHistoryQuery.Tenant_RefID = securityTicket.TenantID; var historyArray = ORM_USR_Device_AccountCode_UsageHistory.Query.Search(Connection, Transaction, Device_AccountCode_UsageHistoryQuery); if (historyArray != null && historyArray.Count > 0) { foreach (var historyItem in historyArray) { historyItem.IsDeleted = true; historyItem.Save(Connection, Transaction); } } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5AR_SA_1525 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); var languageQuery = new ORM_CMN_Language.Query(); languageQuery.Tenant_RefID = securityTicket.TenantID; languageQuery.IsDeleted = false; var languages = ORM_CMN_Language.Query.Search(Connection, Transaction, languageQuery); var product = new ORM_CMN_PRO_Product(); if (Parameter.ArticleID == Guid.Empty) { #region ORM_CMN_PRO_Product product = new ORM_CMN_PRO_Product(); product.CMN_PRO_ProductID = Guid.NewGuid(); product.ProductITL = Guid.NewGuid().ToString(); product.IsProduct_Article = true; product.IsProductAvailableForOrdering = true; product.IsImportedFromExternalCatalog = false; product.Product_Name = new Dict(ORM_CMN_PRO_Product.TableName); product.Product_Description = new Dict(ORM_CMN_PRO_Product.TableName); product.PackageInfo_RefID = Guid.NewGuid(); product.Creation_Timestamp = DateTime.Now; product.Tenant_RefID = securityTicket.TenantID; product.Save(Connection, Transaction); #endregion #region CustomArticles Group var customerArticlesGroupID = Guid.Empty; var customArticlesGlobalMatching = EnumUtils.GetEnumDescription(EProductGroup.CustomArticles); var customerArticlesGroup = ORM_CMN_PRO_ProductGroup.Query.Search(Connection, Transaction, new ORM_CMN_PRO_ProductGroup.Query() { GlobalPropertyMatchingID = customArticlesGlobalMatching, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); if (customerArticlesGroup == null || customerArticlesGroup.Count() == 0) { var group = new ORM_CMN_PRO_ProductGroup(); group.CMN_PRO_ProductGroupID = Guid.NewGuid(); group.GlobalPropertyMatchingID = customArticlesGlobalMatching; group.ProductGroup_Name = new Dict(ORM_CMN_PRO_ProductGroup.TableName); foreach (var language in languages) { group.ProductGroup_Name.AddEntry(language.CMN_LanguageID, "Custom Articles"); } group.ProductGroup_Description = new Dict(ORM_CMN_PRO_ProductGroup.TableName); group.IsDeleted = false; group.Creation_Timestamp = DateTime.Now; group.Tenant_RefID = securityTicket.TenantID; group.Save(Connection, Transaction); customerArticlesGroupID = group.CMN_PRO_ProductGroupID; } else { customerArticlesGroupID = customerArticlesGroup.Single().CMN_PRO_ProductGroupID; } var product2Group = new ORM_CMN_PRO_Product_2_ProductGroup(); product2Group.AssignmentID = Guid.NewGuid(); product2Group.CMN_PRO_Product_RefID = product.CMN_PRO_ProductID; product2Group.CMN_PRO_ProductGroup_RefID = customerArticlesGroupID; product2Group.Creation_Timestamp = DateTime.Now; product2Group.Tenant_RefID = securityTicket.TenantID; product2Group.Save(Connection, Transaction); #endregion } else { product.Load(Connection, Transaction, Parameter.ArticleID); } #region ORM_CMN_PRO_Product product.Product_Number = Parameter.PZN; foreach (var language in languages) { product.Product_Name.UpdateEntry(language.CMN_LanguageID, Parameter.ArticleName); } foreach (var language in languages) { product.Product_Description.UpdateEntry(language.CMN_LanguageID, Parameter.Notice); } product.DefaultStorageTemperature_min_in_kelvin = Parameter.StorageTemperatureFrom_in_kelvin; product.DefaultStorageTemperature_max_in_kelvin = Parameter.StorageTemperatureTo_in_kelvin; product.DefaultExpirationPeriod_in_sec = Parameter.Expiring_in_seconds; product.ProductType_RefID = Parameter.ArticleType_RefID; product.IsPlaceholderArticle = Parameter.IsDummy; product.IsStorage_CoolingRequired = Parameter.IsStorage_CoolingRequired; product.IsStorage_BatchNumberMandatory = Parameter.IsStorage_BatchNumberMandatory; product.IsStorage_ExpiryDateMandatory = Parameter.IsStorage_ExpiryDateMandatory; product.IsProductPartOfDefaultStock = Parameter.IsProduct_PartOfDefaultStock; var xml = new ProductAdditionalInfoXML() { IsPharmacyOnlyDistribution = Parameter.IsProduct_PharmacyOnlyDistribution }; product.ProductAdditionalInfoXML = xml.ToPayload(); product.ProductSuccessor_RefID = Parameter.ProductSuccessor_RefID; product.Save(Connection, Transaction); #endregion #region ORM_HEC_Product var query = new ORM_HEC_Product.Query(); query.Ext_PRO_Product_RefID = product.CMN_PRO_ProductID; query.IsDeleted = false; query.Tenant_RefID = securityTicket.TenantID; var hecProduct = ORM_HEC_Product.Query.Search(Connection, Transaction, query).SingleOrDefault(); if (hecProduct == null) { hecProduct = new ORM_HEC_Product(); hecProduct.HEC_ProductID = Guid.NewGuid(); hecProduct.Ext_PRO_Product_RefID = product.CMN_PRO_ProductID; hecProduct.Creation_Timestamp = DateTime.Now; hecProduct.Tenant_RefID = securityTicket.TenantID; } hecProduct.ProductDosageForm_RefID = Parameter.DosageForm_RefID; hecProduct.IsProduct_AddictiveDrug = Parameter.IsProduct_AddictiveDrug; hecProduct.Save(Connection, Transaction); #endregion #region ORM_CMN_PRO_Product_2_ProductGroup var groupQuery = new ORM_CMN_PRO_Product_2_ProductGroup.Query(); groupQuery.CMN_PRO_Product_RefID = product.CMN_PRO_ProductID; groupQuery.IsDeleted = false; groupQuery.Tenant_RefID = securityTicket.TenantID; var alreadyPersistedGroups = ORM_CMN_PRO_Product_2_ProductGroup.Query.Search(Connection, Transaction, groupQuery); //delete removed groups foreach (var item in alreadyPersistedGroups) { var globalGroup = new ORM_CMN_PRO_ProductGroup(); globalGroup.Load(Connection, Transaction, item.CMN_PRO_ProductGroup_RefID); if (!Parameter.ArticleGroup_RefIDs.Contains(item.CMN_PRO_ProductGroup_RefID) && String.IsNullOrEmpty(globalGroup.GlobalPropertyMatchingID)) { item.IsDeleted = true; item.Save(Connection, Transaction); } } //add new groups foreach (var groupID in Parameter.ArticleGroup_RefIDs) { if (!alreadyPersistedGroups.Select(i => i.CMN_PRO_ProductGroup_RefID).Contains(groupID)) { var group = new ORM_CMN_PRO_Product_2_ProductGroup(); group.AssignmentID = Guid.NewGuid(); group.CMN_PRO_Product_RefID = product.CMN_PRO_ProductID; group.CMN_PRO_ProductGroup_RefID = groupID; group.Creation_Timestamp = DateTime.Now; group.Tenant_RefID = securityTicket.TenantID; group.Save(Connection, Transaction); } } #endregion #region ORM_CMN_PRO_Product_SalesTaxAssignmnet var salesTaxQuery = new ORM_CMN_PRO_Product_SalesTaxAssignmnet.Query(); salesTaxQuery.Product_RefID = product.CMN_PRO_ProductID; salesTaxQuery.IsDeleted = false; salesTaxQuery.Tenant_RefID = securityTicket.TenantID; var salesTax = ORM_CMN_PRO_Product_SalesTaxAssignmnet.Query.Search(Connection, Transaction, salesTaxQuery).SingleOrDefault(); if (salesTax == null) { salesTax = new ORM_CMN_PRO_Product_SalesTaxAssignmnet(); salesTax.CMN_PRO_Product_SalesTaxAssignmnetID = Guid.NewGuid(); salesTax.Product_RefID = product.CMN_PRO_ProductID; salesTax.Creation_Timestamp = DateTime.Now; salesTax.Tenant_RefID = securityTicket.TenantID; } salesTax.ApplicableSalesTax_RefID = Parameter.VAT_RefID; salesTax.Save(Connection, Transaction); #endregion #region ORM_CMN_PRO_Product_2_ProductCode var product2CodeQuery = new ORM_CMN_PRO_Product_2_ProductCode.Query(); product2CodeQuery.CMN_PRO_Product_RefID = product.CMN_PRO_ProductID; product2CodeQuery.Tenant_RefID = securityTicket.TenantID; product2CodeQuery.IsDeleted = false; var productCodeAssignment = ORM_CMN_PRO_Product_2_ProductCode.Query.Search(Connection, Transaction, product2CodeQuery).SingleOrDefault(); if (productCodeAssignment == null) { #region ORM_CMN_PRO_ProductCode //Get Product Code Type or create it if not exist var eanID = DMProductCodeTypes.Get_ProductCodeType_ByGlobalMatchingID(Connection, Transaction, EProductCodeType.EAN, securityTicket); var productCode = new ORM_CMN_PRO_ProductCode(); productCode.CMN_PRO_ProductCodeID = Guid.NewGuid(); productCode.ProductCode_Type_RefID = eanID; productCode.ProductCode_Value = Parameter.EAN; productCode.Creation_Timestamp = DateTime.Now; productCode.Tenant_RefID = securityTicket.TenantID; productCode.Save(Connection, Transaction); #endregion #region ORM_CMN_PRO_Product_2_ProductCode var product2Code = new ORM_CMN_PRO_Product_2_ProductCode(); product2Code.AssignmentID = Guid.NewGuid(); product2Code.CMN_PRO_Product_RefID = product.CMN_PRO_ProductID; product2Code.CMN_PRO_ProductCode_RefID = productCode.CMN_PRO_ProductCodeID; product2Code.Creation_Timestamp = DateTime.Now; product2Code.Tenant_RefID = securityTicket.TenantID; product2Code.Save(Connection, Transaction); #endregion } else { #region ORM_CMN_PRO_ProductCode var productCode = new ORM_CMN_PRO_ProductCode(); productCode.Load(Connection, Transaction, productCodeAssignment.CMN_PRO_ProductCode_RefID); productCode.ProductCode_Value = Parameter.EAN; productCode.Save(Connection, Transaction); #endregion } #endregion #region ORM_CMN_PRO_PackageInfo var packageInfo = new ORM_CMN_PRO_PAC_PackageInfo(); packageInfo.Load(Connection, Transaction, product.PackageInfo_RefID); if (packageInfo.CMN_PRO_PAC_PackageInfoID == Guid.Empty) { packageInfo = new ORM_CMN_PRO_PAC_PackageInfo(); packageInfo.CMN_PRO_PAC_PackageInfoID = product.PackageInfo_RefID; packageInfo.Creation_Timestamp = DateTime.Now; packageInfo.Tenant_RefID = securityTicket.TenantID; } packageInfo.PackageContent_Amount = PackageAmountUtils.GetPackageAmount(Parameter.UnitAmount); packageInfo.PackageContent_DisplayLabel = Parameter.UnitAmount; packageInfo.PackageContent_MeasuredInUnit_RefID = Parameter.Unit_RefID; packageInfo.Save(Connection, Transaction); #endregion #region Producer var producer = new ORM_CMN_BPT_BusinessParticipant(); producer.Load(Connection, Transaction, product.ProducingBusinessParticipant_RefID); if (producer.CMN_BPT_BusinessParticipantID == Guid.Empty) { producer.CMN_BPT_BusinessParticipantID = Guid.NewGuid(); producer.IsCompany = true; producer.Tenant_RefID = securityTicket.TenantID; producer.Creation_Timestamp = DateTime.Now; product.ProducingBusinessParticipant_RefID = producer.CMN_BPT_BusinessParticipantID; product.Save(Connection, Transaction); } producer.DisplayName = Parameter.Producer; producer.Save(Connection, Transaction); #endregion returnValue.Result = product.CMN_PRO_ProductID; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5EM_SFE_1524 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); ORM_CMN_Address address = new ORM_CMN_Address(); if (Parameter.CMN_AddressID != Guid.Empty) { var result = address.Load(Connection, Transaction, Parameter.CMN_AddressID); if (result.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(error); } } address.City_Name = Parameter.City_Name; address.Street_Name = Parameter.Street_Name; address.Street_Number = Parameter.Street_Number; address.Country_Name = Parameter.Country_Name; address.Province_Name = Parameter.Province_Name; address.Tenant_RefID = Parameter.TenantID; address.Save(Connection, Transaction); ORM_CMN_PER_PersonInfo person = new ORM_CMN_PER_PersonInfo(); if (Parameter.CMN_PER_PersonInfoID != Guid.Empty) { var result = person.Load(Connection, Transaction, Parameter.CMN_PER_PersonInfoID); if (result.Status != FR_Status.Success || person.CMN_PER_PersonInfoID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } //person.AccountImage_URL = Parameter.ProfileImage_Document_RefID; person.FirstName = Parameter.FirstName; person.LastName = Parameter.LastName; person.PrimaryEmail = Parameter.PrimaryEmail; person.Tenant_RefID = Parameter.TenantID; person.Title = Parameter.Title; person.Address_RefID = address.CMN_AddressID; person.BirthDate = Parameter.BirthDate; person.Save(Connection, Transaction); ORM_CMN_BPT_BusinessParticipant bParticipant = new ORM_CMN_BPT_BusinessParticipant(); if (Parameter.CMN_BPT_BusinessParticipantID != Guid.Empty) { var result = bParticipant.Load(Connection, Transaction, Parameter.CMN_BPT_BusinessParticipantID); if (result.Status != FR_Status.Success || bParticipant.CMN_BPT_BusinessParticipantID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } bParticipant.DisplayName = Parameter.DisplayName; bParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID = person.CMN_PER_PersonInfoID; bParticipant.IsNaturalPerson = true; bParticipant.Tenant_RefID = Parameter.TenantID; bParticipant.Save(Connection, Transaction); ORM_CMN_BPT_EMP_Employee employee = new ORM_CMN_BPT_EMP_Employee(); CSV2Core.DlTrace.Trace("Parameter.CMN_BPT_EMP_EmployeeID " + Parameter.CMN_BPT_EMP_EmployeeID); if (Parameter.CMN_BPT_EMP_EmployeeID != Guid.Empty) { var result = employee.Load(Connection, Transaction, Parameter.CMN_BPT_EMP_EmployeeID); if (result.Status != FR_Status.Success || employee.CMN_BPT_EMP_EmployeeID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } employee.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; employee.Staff_Number = Parameter.Staff_Number; employee.StandardFunction = Parameter.StandardFunction; employee.Tenant_RefID = Parameter.TenantID; employee.Save(Connection, Transaction); CSV2Core.DlTrace.Trace("after save Parameter.CMN_BPT_EMP_EmployeeID " + Parameter.CMN_BPT_EMP_EmployeeID); CSV2Core.DlTrace.Trace("employee.Status_IsAlreadySaved " + employee.Status_IsAlreadySaved); ORM_CMN_BPT_EMP_EmploymentRelationship employeeRelationship = new ORM_CMN_BPT_EMP_EmploymentRelationship(); if (Parameter.CMN_BPT_EMP_Employee_WorkingContractID != Guid.Empty) { var result = employeeRelationship.Load(Connection, Transaction, Parameter.CMN_BPT_EMP_Employee_WorkingContractID); if (result.Status != FR_Status.Success || employeeRelationship.CMN_BPT_EMP_EmploymentRelationshipID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } employeeRelationship.Work_StartDate = Parameter.Work_StartDate; employeeRelationship.Work_EndDate = Parameter.Work_EndDate; employeeRelationship.Tenant_RefID = Parameter.TenantID; employeeRelationship.Employee_RefID = employee.CMN_BPT_EMP_EmployeeID; employeeRelationship.Save(Connection, Transaction); if (Parameter.USR_AccountID != null && Parameter.USR_AccountID != Guid.Empty) { ORM_USR_Account account = new ORM_USR_Account(); account.Load(Connection, Transaction, Parameter.USR_AccountID); account.USR_AccountID = Parameter.USR_AccountID; account.Username = Parameter.username; account.DefaultLanguage_RefID = Parameter.LanguageID; account.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; account.Tenant_RefID = Parameter.TenantID; account.Save(Connection, Transaction); var personToAccountQuery = new ORM_CMN_PER_PersonInfo_2_Account.Query(); personToAccountQuery.Tenant_RefID = securityTicket.TenantID; personToAccountQuery.USR_Account_RefID = account.USR_AccountID; personToAccountQuery.IsDeleted = false; var personToAccounts = ORM_CMN_PER_PersonInfo_2_Account.Query.Search(Connection, Transaction, personToAccountQuery); if (personToAccounts.Count != 0) { ORM_CMN_PER_PersonInfo_2_Account personToAccount = personToAccounts[0]; personToAccount.CMN_PER_PersonInfo_RefID = person.CMN_PER_PersonInfoID; personToAccount.USR_Account_RefID = account.USR_AccountID; personToAccount.Tenant_RefID = securityTicket.TenantID; personToAccount.Save(Connection, Transaction); } else { ORM_CMN_PER_PersonInfo_2_Account personToAccount = new ORM_CMN_PER_PersonInfo_2_Account(); personToAccount.CMN_PER_PersonInfo_RefID = person.CMN_PER_PersonInfoID; personToAccount.USR_Account_RefID = account.USR_AccountID; personToAccount.Tenant_RefID = securityTicket.TenantID; personToAccount.Save(Connection, Transaction); } if (Parameter.Rights != null) { foreach (var rightParam in Parameter.Rights) { var right = new ORM_USR_Account_FunctionLevelRight(); if (rightParam.RightID != Guid.Empty) { var result = right.Load(Connection, Transaction, rightParam.RightID); if (result.Status != FR_Status.Success || right.USR_Account_FunctionLevelRightID == Guid.Empty) { right.USR_Account_FunctionLevelRightID = rightParam.RightID; right.Tenant_RefID = Parameter.TenantID; right.RightName = rightParam.RightName; right.FunctionLevelRights_Group_RefID = Guid.Empty; right.Save(Connection, Transaction); } } var right2account = new ORM_USR_Account_2_FunctionLevelRight(); right2account.Account_RefID = account.USR_AccountID; right2account.FunctionLevelRight_RefID = rightParam.RightID; right2account.Tenant_RefID = Parameter.TenantID; right2account.Save(Connection, Transaction); } } } returnValue.Result = employee.CMN_BPT_EMP_EmployeeID; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3MP_DPBID_1026 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); P_L3MP_GPfID_1222 param = new P_L3MP_GPfID_1222(); param.HEC_MedicalPractiseID = Parameter.HEC_MedicalPractiseID; var practice = cls_Get_Practice_For_ID.Invoke(Connection, Transaction, param, securityTicket).Result; if (practice != null) { ORM_CMN_UniversalContactDetail contactDetails = new ORM_CMN_UniversalContactDetail(); if (practice.BaseInfo.CMN_UniversalContactDetailID != Guid.Empty) { var result = contactDetails.Load(Connection, Transaction, practice.BaseInfo.CMN_UniversalContactDetailID); if (result.Status != FR_Status.Success || contactDetails.CMN_UniversalContactDetailID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } contactDetails.IsDeleted = true; contactDetails.Save(Connection, Transaction); } ORM_CMN_COM_CompanyInfo info = new ORM_CMN_COM_CompanyInfo(); if (practice.BaseInfo.CMN_COM_CompanyInfoID != Guid.Empty) { var result = info.Load(Connection, Transaction, practice.BaseInfo.CMN_COM_CompanyInfoID); if (result.Status != FR_Status.Success || info.CMN_COM_CompanyInfoID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } info.IsDeleted = true; info.Save(Connection, Transaction); } ORM_CMN_BPT_BusinessParticipant bParticipant = new ORM_CMN_BPT_BusinessParticipant(); if (practice.BaseInfo.CMN_BPT_BusinessParticipantID != Guid.Empty) { var result = bParticipant.Load(Connection, Transaction, practice.BaseInfo.CMN_BPT_BusinessParticipantID); if (result.Status != FR_Status.Success || bParticipant.CMN_BPT_BusinessParticipantID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } bParticipant.IsDeleted = true; bParticipant.Save(Connection, Transaction); } ORM_HEC_MedicalPractis practis = new ORM_HEC_MedicalPractis(); if (practice.BaseInfo.HEC_MedicalPractiseID != Guid.Empty) { var result = practis.Load(Connection, Transaction, practice.BaseInfo.HEC_MedicalPractiseID); if (result.Status != FR_Status.Success || practis.HEC_MedicalPractiseID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } practis.IsDeleted = true; practis.Save(Connection, Transaction); } if (practice.BaseInfo.WeeklyOfficeHours_Template_RefID != Guid.Empty) { ORM_CMN_CAL_WeeklyOfficeHours_Template consultationHours = new ORM_CMN_CAL_WeeklyOfficeHours_Template(); if (practice.BaseInfo.WeeklyOfficeHours_Template_RefID != Guid.Empty) { var result = consultationHours.Load(Connection, Transaction, practice.BaseInfo.WeeklyOfficeHours_Template_RefID); if (result.Status != FR_Status.Success || consultationHours.CMN_CAL_WeeklyOfficeHours_TemplateID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } consultationHours.IsDeleted = true; consultationHours.Save(Connection, Transaction); } } if (practice.BaseInfo.WeeklySurgeryHours_Template_RefID != Guid.Empty) { ORM_CMN_CAL_WeeklyOfficeHours_Template consultationHours = new ORM_CMN_CAL_WeeklyOfficeHours_Template(); if (practice.BaseInfo.WeeklyOfficeHours_Template_RefID != Guid.Empty) { var result = consultationHours.Load(Connection, Transaction, practice.BaseInfo.WeeklySurgeryHours_Template_RefID); if (result.Status != FR_Status.Success || consultationHours.CMN_CAL_WeeklyOfficeHours_TemplateID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } consultationHours.IsDeleted = true; consultationHours.Save(Connection, Transaction); } } if (practice.ShippingAddress != null) { ORM_CMN_UniversalContactDetail shippingDetails = new ORM_CMN_UniversalContactDetail(); if (practice.ShippingAddress.CMN_UniversalContactDetailID != Guid.Empty) { var result = shippingDetails.Load(Connection, Transaction, practice.ShippingAddress.CMN_UniversalContactDetailID); if (result.Status != FR_Status.Success || contactDetails.CMN_UniversalContactDetailID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } shippingDetails.IsDeleted = true; shippingDetails.Save(Connection, Transaction); } ORM_CMN_COM_CompanyInfo_Address shippingAddress = new ORM_CMN_COM_CompanyInfo_Address(); if (practice.ShippingAddress.CMN_COM_CompanyInfo_AddressID != Guid.Empty) { var result = shippingAddress.Load(Connection, Transaction, practice.ShippingAddress.CMN_COM_CompanyInfo_AddressID); if (result.Status != FR_Status.Success || shippingAddress.CMN_COM_CompanyInfo_AddressID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } shippingAddress.IsDeleted = true; shippingAddress.Save(Connection, Transaction); } } var associatedBussinessParticipantsQuery = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query(); associatedBussinessParticipantsQuery.AssociatedBusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID; associatedBussinessParticipantsQuery.IsDeleted = false; var associatedBussinessParticipants = ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query.Search(Connection, Transaction, associatedBussinessParticipantsQuery); if (associatedBussinessParticipants.Count != 0) { foreach (var assBussiness in associatedBussinessParticipants) { assBussiness.IsDeleted = true; assBussiness.Save(Connection, Transaction); //brisanje doktora ako je imao jednu praksu //var d2pAssignmentQuery = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query(); //d2pAssignmentQuery.IsDeleted = false; //d2pAssignmentQuery.BusinessParticipant_RefID = assBussiness.BusinessParticipant_RefID; //var d2pAssignmentRes = ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant.Query.Search(Connection, Transaction, d2pAssignmentQuery).ToArray(); //if (d2pAssignmentRes.Length == 0) //{ // var docQuery = new ORM_HEC_Doctor.Query(); // docQuery.BusinessParticipant_RefID = assBussiness.BusinessParticipant_RefID; // var doctor = ORM_HEC_Doctor.Query.Search(Connection, Transaction, docQuery).First(); // P_L3MD_DDbID_1031 delDoc = new P_L3MD_DDbID_1031(); // delDoc.DoctorID = doctor.HEC_DoctorID; // var delRes = cls_Delete_Doctor_byID.Invoke(Connection, Transaction, delDoc, securityTicket).Result; //} } } if (practice.OtherOphthal_PracticeData != null) { ORM_HEC_PublicHealthcare_PhysitianAssociation association = new ORM_HEC_PublicHealthcare_PhysitianAssociation(); if (practice.OtherOphthal_PracticeData.HEC_PublicHealthcare_PhysitianAssociationID != Guid.Empty) { var result = association.Load(Connection, Transaction, practice.OtherOphthal_PracticeData.HEC_PublicHealthcare_PhysitianAssociationID); if (result.Status != FR_Status.Success || association.HEC_PublicHealthcare_PhysitianAssociationID == Guid.Empty) { var item = STLD_MedicalAssociation.associationItems.FirstOrDefault(a => a.Value == practice.OtherOphthal_PracticeData.HEC_PublicHealthcare_PhysitianAssociationID); if (item != null) { association.IsDeleted = true; association.HealthAssociation_Name = item.Text; association.Save(Connection, Transaction); } } } var customerQuery = new ORM_CMN_BPT_CTM_Customer.Query(); customerQuery.Ext_BusinessParticipant_RefID = practice.BaseInfo.CMN_BPT_BusinessParticipantID; var customer = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery).FirstOrDefault(); if (customer != null) { customer.IsDeleted = true; customer.Save(Connection, Transaction); } var companyTypeQuery = new ORM_CMN_COM_CompanyInfo_Type.Query(); companyTypeQuery.IsDeleted = false; companyTypeQuery.CMN_COM_CompanyInfo_TypeID = practice.OtherOphthal_PracticeData.CMN_COM_CompanyInfo_TypeID; var companyType = ORM_CMN_COM_CompanyInfo_Type.Query.Search(Connection, Transaction, companyTypeQuery).First(); var pHealthcareQuery = new ORM_HEC_PublicHealthcare_PhysitianAssociation.Query(); pHealthcareQuery.HEC_PublicHealthcare_PhysitianAssociationID = practice.OtherOphthal_PracticeData.HEC_PublicHealthcare_PhysitianAssociationID; var pHealthcare = ORM_HEC_PublicHealthcare_PhysitianAssociation.Query.Search(Connection, Transaction, pHealthcareQuery).First(); pHealthcare.IsDeleted = true; pHealthcare.Save(Connection, Transaction); if (customer != null) { var affinityStatusQuery = new ORM_CMN_BPT_CTM_AffinityStatus.Query(); affinityStatusQuery.CMN_BPT_CTM_AffinityStatusID = customer.CustomerAffinityStatus_RefID; var affinityStatus = ORM_CMN_BPT_CTM_AffinityStatus.Query.Search(Connection, Transaction, affinityStatusQuery).First(); if (affinityStatus != null) { affinityStatus.IsDeleted = true; affinityStatus.Save(Connection, Transaction); } } } } return(returnValue); #endregion UserCode }