コード例 #1
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5OF_SSOfA_1652 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();
            //Put your code here

            var officeQuery = new ORM_CMN_STR_Office.Query();
            officeQuery.CMN_STR_OfficeID = Parameter.OfficeID;
            officeQuery.Tenant_RefID     = securityTicket.TenantID;
            var foundOffice = ORM_CMN_STR_Office.Query.Search(Connection, Transaction, officeQuery).Single();

            if (foundOffice != null)
            {
                var assignmentQuery = new ORM_CMN_BPT_EMP_Employee_2_Office.Query();
                assignmentQuery.CMN_BPT_EMP_Employee_RefID = Parameter.EmployeeID;
                assignmentQuery.CMN_STR_Office_RefID       = foundOffice.CMN_STR_OfficeID;
                assignmentQuery.Tenant_RefID = securityTicket.TenantID;
                var foundAssignment = ORM_CMN_BPT_EMP_Employee_2_Office.Query.Search(Connection, Transaction, assignmentQuery).SingleOrDefault();

                if (foundAssignment == null)
                {
                    foundAssignment = new ORM_CMN_BPT_EMP_Employee_2_Office();
                }

                foundAssignment.CMN_STR_Office_RefID       = foundOffice.CMN_STR_OfficeID;
                foundAssignment.CMN_BPT_EMP_Employee_RefID = Parameter.EmployeeID;
                foundAssignment.Tenant_RefID = securityTicket.TenantID;
                foundAssignment.IsDeleted    = false;
                foundAssignment.Save(Connection, Transaction);
            }

            return(returnValue);

            #endregion UserCode
        }
コード例 #2
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5OF_SOfA_1652 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

            var userAccount = new ORM_USR_Account();
            userAccount.Load(Connection, Transaction, Parameter.AccountID);

            //Get business participant for current user account
            var businessParticipantQuery = new ORM_CMN_BPT_BusinessParticipant.Query();
            businessParticipantQuery.CMN_BPT_BusinessParticipantID = userAccount.BusinessParticipant_RefID;
            businessParticipantQuery.Tenant_RefID = securityTicket.TenantID;
            var foundBusinessParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, businessParticipantQuery).Single();

            //Get employee using business participant
            var employeeQuery = new ORM_CMN_BPT_EMP_Employee.Query();
            employeeQuery.BusinessParticipant_RefID = foundBusinessParticipant.CMN_BPT_BusinessParticipantID;
            employeeQuery.Tenant_RefID = securityTicket.TenantID;
            var foundEmployee = ORM_CMN_BPT_EMP_Employee.Query.Search(Connection, Transaction, employeeQuery).Single();

            //clear all assignment tables (connection with offices) for found employee before new save
            var assignmentQuery = new ORM_CMN_BPT_EMP_Employee_2_Office.Query();
            if (foundEmployee != null)
            {
                assignmentQuery.CMN_BPT_EMP_Employee_RefID = foundEmployee.CMN_BPT_EMP_EmployeeID;
                assignmentQuery.Tenant_RefID = securityTicket.TenantID;
            }
            else
            {
                return(new FR_Guid("Employee not created", FR_Status.Error_Internal));
            }

            var foundAssignments = ORM_CMN_BPT_EMP_Employee_2_Office.Query.Search(Connection, Transaction, assignmentQuery);

            foreach (var assignment in foundAssignments)
            {
                assignment.IsDeleted = true;
                assignment.Save(Connection, Transaction);
            }

            //save offices
            foreach (var office in Parameter.Offices)
            {
                P_L5OF_SSOfA_1652 officeSaveParam = new P_L5OF_SSOfA_1652();
                officeSaveParam.OfficeID   = office;
                officeSaveParam.EmployeeID = foundEmployee.CMN_BPT_EMP_EmployeeID;
                cls_Save_SingleOffice_for_Account.Invoke(Connection, Transaction, officeSaveParam, securityTicket);
            }

            return(returnValue);

            #endregion UserCode
        }
コード例 #3
0
        protected static FR_L5US_GAOfA_1742 Execute(DbConnection Connection, DbTransaction Transaction, P_L5US_GAOfA_1742 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5US_GAOfA_1742();
            //Put your code here

            var allOfficesForTenant = cls_Get_AllOffices_for_TenantID.Invoke(Connection, Transaction, securityTicket).Result;

            ORM_USR_Account user = new ORM_USR_Account();
            user.Load(Connection, Transaction, Parameter.UserAccountID);

            ORM_CMN_BPT_EMP_Employee.Query employeeQuery = new ORM_CMN_BPT_EMP_Employee.Query();
            employeeQuery.BusinessParticipant_RefID = user.BusinessParticipant_RefID;
            employeeQuery.Tenant_RefID = securityTicket.TenantID;
            var foundEmployee = ORM_CMN_BPT_EMP_Employee.Query.Search(Connection, Transaction, employeeQuery).FirstOrDefault();

            if (foundEmployee == null)
            {
                foundEmployee = new ORM_CMN_BPT_EMP_Employee();
                foundEmployee.BusinessParticipant_RefID = user.BusinessParticipant_RefID;
                foundEmployee.Tenant_RefID = securityTicket.TenantID;
                foundEmployee.Save(Connection, Transaction);
            }

            List <L5US_GAOfA_1742a> listOfOfficesWithAssignments = new List <L5US_GAOfA_1742a>();

            foreach (var office in allOfficesForTenant)
            {
                var assignmentQuery = new ORM_CMN_BPT_EMP_Employee_2_Office.Query();
                assignmentQuery.CMN_BPT_EMP_Employee_RefID = foundEmployee.CMN_BPT_EMP_EmployeeID;
                assignmentQuery.CMN_STR_Office_RefID       = office.CMN_STR_OfficeID;
                assignmentQuery.Tenant_RefID = securityTicket.TenantID;
                assignmentQuery.IsDeleted    = false;
                var foundAssignment = ORM_CMN_BPT_EMP_Employee_2_Office.Query.Search(Connection, Transaction, assignmentQuery);

                L5US_GAOfA_1742a temp = new L5US_GAOfA_1742a();
                if (foundAssignment.Count > 0)
                {
                    temp.AssignmentID = foundAssignment.First().AssignmentID;
                }
                temp.CMN_BPT_EMP_Employee_RefID = foundEmployee.CMN_BPT_EMP_EmployeeID;
                temp.CMN_STR_OfficeID           = office.CMN_STR_OfficeID;
                temp.Office_InternalName        = office.Office_InternalName;
                temp.IsOfficeToAccountDeleted   = foundAssignment.Count == 0;
                temp.Office_Description         = office.Office_Description;
                temp.Office_Name  = office.Office_Name;
                temp.Parent_RefID = office.Parent_RefID;

                temp.USR_AccountID = Parameter.UserAccountID;

                listOfOfficesWithAssignments.Add(temp);
            }

            returnValue.Result = new L5US_GAOfA_1742();
            returnValue.Result.OfficesWithAssignedUser = new List <L5US_GAOfA_1742a>().ToArray();
            returnValue.Result.OfficesWithAssignedUser = listOfOfficesWithAssignments.ToArray();

            return(returnValue);

            #endregion UserCode
        }