Exemplo n.º 1
0
        /// <summary>
        /// Returns the Languages of a Person from Personnel. It excludes the MainLanguage.
        /// </summary>
        /// <remarks>The Language Codes are sorted by Language Level so that the Language
        /// with the best level comes first, then the other Languages in descending Language
        /// Level order.</remarks>
        /// <param name="APartnerKey">PartnerKey of the PERSON.</param>
        /// <param name="AMainLanguage">MainLanguage of the PERSON.</param>
        /// <param name="AReadTransaction">Open DB Transaction.</param>
        /// <returns>A String containing all the Language Codes from Personnel, excluding the
        /// MainLanguage. The Language Codes are separated with a '|' (pipe) character.</returns>
        private static String GetPersonLanguagesFromPersonnel(Int64 APartnerKey, string AMainLanguage, TDBTransaction AReadTransaction)
        {
            const string LANG_SEPARATOR      = "|";
            String       AdditionalLanguages = "";

            PmPersonLanguageTable PersonLangDT = PmPersonLanguageAccess.LoadViaPPerson(APartnerKey, AReadTransaction);

            if (PersonLangDT != null)
            {
                // We want the list of Languages sorted by Language Level so that the Language with the
                // best level comes first, then the other Languages in descending Language Level order.
                DataView PersonLangDV = new DataView(PersonLangDT, "",
                                                     PmPersonLanguageTable.GetLanguageLevelDBName() + " DESC", DataViewRowState.CurrentRows);

                for (int Counter = 0; Counter < PersonLangDV.Count; Counter++)
                {
                    PmPersonLanguageRow PersonLangDR = (PmPersonLanguageRow)PersonLangDV[Counter].Row;

                    if (PersonLangDR.LanguageCode != AMainLanguage)
                    {
                        AdditionalLanguages = AdditionalLanguages + PersonLangDR.LanguageCode + LANG_SEPARATOR;
                    }
                }

                if (AdditionalLanguages.Length > 0)
                {
                    AdditionalLanguages = AdditionalLanguages.Substring(0, AdditionalLanguages.Length - LANG_SEPARATOR.Length);
                }
            }

            return(AdditionalLanguages);
        }
Exemplo n.º 2
0
        public static TSubmitChangesResult SubmitChangesServerSide(ref IndividualDataTDS AInspectDS,
                                                                   ref PartnerEditTDS APartnerEditInspectDS,
                                                                   TDBTransaction ASubmitChangesTransaction,
                                                                   out TVerificationResultCollection AVerificationResult)
        {
            TSubmitChangesResult SubmissionResult;

            PmJobAssignmentTable PmJobAssignmentTableSubmit;

            AVerificationResult = new TVerificationResultCollection();

            if (AInspectDS != null)
            {
                SubmissionResult = TSubmitChangesResult.scrOK;

                // Job Assignments: make sure that jobs exist for assignments
                if (AInspectDS.Tables.Contains(PmJobAssignmentTable.GetTableName()) &&
                    (AInspectDS.PmJobAssignment.Rows.Count > 0))
                {
                    UmJobTable JobTableTemp = new UmJobTable();

                    UmJobTable JobTableSubmit = new UmJobTable();
                    UmJobRow   JobRow;

                    PmJobAssignmentTableSubmit = AInspectDS.PmJobAssignment;

                    // every job_assignment_row needs to have a row that it references in um_job
                    foreach (PmJobAssignmentRow JobAssignmentRow in PmJobAssignmentTableSubmit.Rows)
                    {
                        if (JobAssignmentRow.RowState != DataRowState.Deleted)
                        {
                            JobTableTemp = UmJobAccess.LoadByPrimaryKey(JobAssignmentRow.UnitKey,
                                                                        JobAssignmentRow.PositionName,
                                                                        JobAssignmentRow.PositionScope,
                                                                        JobAssignmentRow.JobKey,
                                                                        ASubmitChangesTransaction);

                            // if no corresponding job record found then we need to create one
                            // (job key was already set on client side to new value so merging back to the
                            // client does not cause problems because of primary key change)
                            if (JobTableTemp.Count == 0)
                            {
                                JobRow = (UmJobRow)JobTableSubmit.NewRow();

                                JobRow.UnitKey          = JobAssignmentRow.UnitKey;
                                JobRow.PositionName     = JobAssignmentRow.PositionName;
                                JobRow.PositionScope    = JobAssignmentRow.PositionScope;
                                JobRow.JobKey           = JobAssignmentRow.JobKey;
                                JobRow.FromDate         = JobAssignmentRow.FromDate;
                                JobRow.ToDate           = JobAssignmentRow.ToDate;
                                JobRow.CommitmentPeriod = "None";
                                JobRow.TrainingPeriod   = "None";

                                // Need to update the JobKey field in job assignment table record from job record
                                JobAssignmentRow.JobKey = JobRow.JobKey;

                                JobTableSubmit.Rows.Add(JobRow);
                            }
                            else
                            {
                                // job record exists: in this case we need to update JobKey in
                                // the Job Assignment Record from Job Row
                                JobAssignmentRow.JobKey = ((UmJobRow)JobTableTemp.Rows[0]).JobKey;
                            }
                        }
                    }

                    // submit table with newly created jobs
                    if (JobTableSubmit.Rows.Count > 0)
                    {
                        UmJobAccess.SubmitChanges(JobTableSubmit, ASubmitChangesTransaction);
                    }
                }

                // now submit the whole dataset at once
                IndividualDataTDSAccess.SubmitChanges(AInspectDS);

                // Need to merge tables back into APartnerEditInspectDS so the updated s_modification_id_t is returned
                // correctly to the Partner Edit.
                // Unfortunately this can't be done simply by using merge method of the dataset since they are two different
                // types but has to be done per table.
                if (AInspectDS.Tables.Contains(PmSpecialNeedTable.GetTableName()) &&
                    (AInspectDS.PmSpecialNeed.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmSpecialNeedTable.GetTableName()].Merge(AInspectDS.PmSpecialNeed);
                }

                if (AInspectDS.Tables.Contains(PmPersonAbilityTable.GetTableName()) &&
                    (AInspectDS.PmPersonAbility.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmPersonAbilityTable.GetTableName()].Merge(AInspectDS.PmPersonAbility);
                }

                if (AInspectDS.Tables.Contains(PmPassportDetailsTable.GetTableName()) &&
                    (AInspectDS.PmPassportDetails.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmPassportDetailsTable.GetTableName()].Merge(AInspectDS.PmPassportDetails);
                }

                if (AInspectDS.Tables.Contains(PmPersonalDataTable.GetTableName()) &&
                    (AInspectDS.PmPersonalData.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmPersonalDataTable.GetTableName()].Merge(AInspectDS.PmPersonalData);
                }

                if (AInspectDS.Tables.Contains(PmPersonLanguageTable.GetTableName()) &&
                    (AInspectDS.PmPersonLanguage.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmPersonLanguageTable.GetTableName()].Merge(AInspectDS.PmPersonLanguage);
                }

                if (AInspectDS.Tables.Contains(PmPersonEvaluationTable.GetTableName()) &&
                    (AInspectDS.PmPersonEvaluation.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmPersonEvaluationTable.GetTableName()].Merge(AInspectDS.PmPersonEvaluation);
                }

                if (AInspectDS.Tables.Contains(PmStaffDataTable.GetTableName()) &&
                    (AInspectDS.PmStaffData.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmStaffDataTable.GetTableName()].Merge(AInspectDS.PmStaffData);
                }

                if (AInspectDS.Tables.Contains(PmPersonSkillTable.GetTableName()) &&
                    (AInspectDS.PmPersonSkill.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmPersonSkillTable.GetTableName()].Merge(AInspectDS.PmPersonSkill);
                }

                if (AInspectDS.Tables.Contains(PmPastExperienceTable.GetTableName()) &&
                    (AInspectDS.PmPastExperience.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmPastExperienceTable.GetTableName()].Merge(AInspectDS.PmPastExperience);
                }

                if (AInspectDS.Tables.Contains(PmDocumentTable.GetTableName()) &&
                    (AInspectDS.PmDocument.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmDocumentTable.GetTableName()].Merge(AInspectDS.PmDocument);
                }

                if (AInspectDS.Tables.Contains(PmJobAssignmentTable.GetTableName()) &&
                    (AInspectDS.PmJobAssignment.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmJobAssignmentTable.GetTableName()].Merge(AInspectDS.PmJobAssignment);
                }

                if (AInspectDS.Tables.Contains(PmGeneralApplicationTable.GetTableName()) &&
                    (AInspectDS.PmGeneralApplication.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmGeneralApplicationTable.GetTableName()].Merge(AInspectDS.PmGeneralApplication);
                }

                if (AInspectDS.Tables.Contains(PmShortTermApplicationTable.GetTableName()) &&
                    (AInspectDS.PmShortTermApplication.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmShortTermApplicationTable.GetTableName()].Merge(AInspectDS.PmShortTermApplication);
                }

                if (AInspectDS.Tables.Contains(PmYearProgramApplicationTable.GetTableName()) &&
                    (AInspectDS.PmYearProgramApplication.Rows.Count > 0))
                {
                    APartnerEditInspectDS.Tables[PmYearProgramApplicationTable.GetTableName()].Merge(AInspectDS.PmYearProgramApplication);
                }
            }
            else
            {
                TLogging.LogAtLevel(8, "TIndividualDataWebConnector.SubmitChangesServerSide: AInspectDS = nil!");
                SubmissionResult = TSubmitChangesResult.scrNothingToBeSaved;
            }

            return(SubmissionResult);
        }