public static ProjectDetailsDataType MapProjectDetails(NamedNullMappingDataReader readerEx)
        {
            ProjectDetailsDataType projectDetails = new ProjectDetailsDataType();

            projectDetails.ProjectIdentifier      = readerEx.GetString("PROJECT_IDENTIFIER");
            projectDetails.ProjectName            = readerEx.GetString("PROJECT_NAME");
            projectDetails.ProjectDescription     = readerEx.GetNullString("PROJECT_DESCRIPTION");
            projectDetails.ScopeAreaTextSpecified = !readerEx.IsDBNull("SCOPE_AREA_TEXT");
            if (projectDetails.ScopeAreaTextSpecified)
            {
                projectDetails.ScopeAreaText = EnumUtils.ParseEnum <ScopeAreaTextDataType>(readerEx.GetString("SCOPE_AREA_TEXT"));
            }
            projectDetails.ProjectStartDate        = readerEx.GetDateTime("PROJECT_START_DATE");
            projectDetails.ProjectEndDateSpecified = !readerEx.IsDBNull("PROJECT_END_DATE");
            if (projectDetails.ProjectEndDateSpecified)
            {
                projectDetails.ProjectEndDate = readerEx.GetDateTime("PROJECT_END_DATE");
            }
            projectDetails.ProjectInputPerson          = readerEx.GetNullString("PROJECT_INPUT_PERSON");
            projectDetails.ProjectDateEnteredSpecified = !readerEx.IsDBNull("PROJECT_DATE_ENTERED");
            if (projectDetails.ProjectDateEnteredSpecified)
            {
                projectDetails.ProjectDateEntered = readerEx.GetDateTime("PROJECT_DATE_ENTERED");
            }
            return(projectDetails);
        }
        protected ProgramDetailsDataType[] FilterProgramDetailsListByYear(int year, ProgramDetailsDataType[] programDetails)
        {
            if (CollectionUtils.IsNullOrEmpty(programDetails))
            {
                return(programDetails);
            }
            int numProgramDetailsSetToNull = 0;

            for (int i = 0; i < programDetails.Length; ++i)
            {
                ProgramDetailsDataType programDetail = programDetails[i];
                if (!CollectionUtils.IsNullOrEmpty(programDetail.ProjectDetails))
                {
                    int numProjectDetailsSetToNull = 0;
                    for (int j = 0; j < programDetail.ProjectDetails.Length; ++j)
                    {
                        ProjectDetailsDataType projectDetail = programDetail.ProjectDetails[j];
                        if (projectDetail.ProjectStartDate.Year != year)
                        {
                            programDetail.ProjectDetails[j] = null;
                            numProjectDetailsSetToNull++;
                        }
                    }
                    if (numProjectDetailsSetToNull == programDetail.ProjectDetails.Length)
                    {
                        programDetails[i] = null;
                        numProgramDetailsSetToNull++;
                    }
                    else if (numProjectDetailsSetToNull > 0)
                    {
                        programDetail.ProjectDetails = CollectionUtils.RemoveNullElements(programDetail.ProjectDetails);
                    }
                }
                else
                {
                    programDetails[i] = null;
                    numProgramDetailsSetToNull++;
                }
            }
            if (numProgramDetailsSetToNull == programDetails.Length)
            {
                return(null);
            }
            else if (numProgramDetailsSetToNull > 0)
            {
                return(CollectionUtils.RemoveNullElements(programDetails));
            }
            else
            {
                return(programDetails);
            }
        }
示例#3
0
        protected virtual void FillProjectDetails(Dictionary <string, ProjectDetailsDataType> idToProjectDetailsMap)
        {
            if (CollectionUtils.IsNullOrEmpty(idToProjectDetailsMap))
            {
                return;
            }
            string selectText =
                string.Format("SELECT am.* FROM P2R_ACTIVITY_MEASURE am, P2R_PROJECT_DETAILS project, P2R_PROGRAM_DETAILS program WHERE " +
                              "{0} AND am.PROJECT_DETAILS_ID = project.PROJECT_DETAILS_ID",
                              _projectDetailsWhereQuery);

            {
                Dictionary <string, ActivityMeasureDataType> activityMeasureMap =
                    _baseDao.MapArrayObjects <ActivityMeasureDataType>(
                        "PROJECT_DETAILS_ID", idToProjectDetailsMap.Keys, selectText,
                        P2RPluginMappers.MapActivityMeasure, "ACTIVITY_MEASURE_ID",
                        delegate(ActivityMeasureDataType[] array, int listKeyFieldsIndex)
                {
                    ProjectDetailsDataType projectDetails =
                        idToProjectDetailsMap[CollectionUtils.NthItem(idToProjectDetailsMap.Keys, listKeyFieldsIndex)];
                    projectDetails.ActivityMeasure = array;
                });

                if (!CollectionUtils.IsNullOrEmpty(activityMeasureMap))
                {
                    selectText =
                        string.Format("SELECT amqr.* FROM P2R_ACTIVITY_MEASURE_QNT_RSLT amqr, P2R_ACTIVITY_MEASURE am, P2R_PROJECT_DETAILS project, P2R_PROGRAM_DETAILS program WHERE " +
                                      "{0} AND am.PROJECT_DETAILS_ID = project.PROJECT_DETAILS_ID AND am.ACTIVITY_MEASURE_ID = amqr.ACTIVITY_MEASURE_ID",
                                      _projectDetailsWhereQuery);
                    _baseDao.MapArrayObjects <ActivityMeasureQuantitativeResultDataType>(
                        "ACTIVITY_MEASURE_ID", activityMeasureMap.Keys, selectText,
                        P2RPluginMappers.MapActivityMeasureQuantitativeResultDataType,
                        delegate(ActivityMeasureQuantitativeResultDataType[] array, int listKeyFieldsIndex)
                    {
                        ActivityMeasureDataType activityMeasure =
                            activityMeasureMap[CollectionUtils.NthItem(activityMeasureMap.Keys, listKeyFieldsIndex)];
                        activityMeasure.QuantitativeResult = array;
                    });
                }
            }

            selectText =
                string.Format("SELECT pds.* FROM P2R_PROJECT_DETAILS_SECTOR pds, P2R_PROJECT_DETAILS project, P2R_PROGRAM_DETAILS program WHERE " +
                              "{0} AND pds.PROJECT_DETAILS_ID = project.PROJECT_DETAILS_ID",
                              _projectDetailsWhereQuery);

            _baseDao.MapArrayObjects <ProjectDetailsSectorDataType>(
                "PROJECT_DETAILS_ID", idToProjectDetailsMap.Keys, selectText,
                P2RPluginMappers.MapSectorText,
                delegate(ProjectDetailsSectorDataType[] array, int listKeyFieldsIndex)
            {
                ProjectDetailsDataType projectDetails =
                    idToProjectDetailsMap[CollectionUtils.NthItem(idToProjectDetailsMap.Keys, listKeyFieldsIndex)];
                projectDetails.SectorText = array;
            });

            selectText =
                string.Format("SELECT i.* FROM P2R_INVESTMENT i, P2R_PROJECT_DETAILS project, P2R_PROGRAM_DETAILS program WHERE " +
                              "{0} AND i.PROJECT_DETAILS_ID = project.PROJECT_DETAILS_ID",
                              _projectDetailsWhereQuery);

            _baseDao.MapArrayObjects <InvestmentDataType>(
                "PROJECT_DETAILS_ID", idToProjectDetailsMap.Keys, selectText,
                P2RPluginMappers.MapInvestment,
                delegate(InvestmentDataType[] array, int listKeyFieldsIndex)
            {
                ProjectDetailsDataType projectDetails =
                    idToProjectDetailsMap[CollectionUtils.NthItem(idToProjectDetailsMap.Keys, listKeyFieldsIndex)];
                projectDetails.Investment = array;
            });

            selectText =
                string.Format("SELECT bc.* FROM P2R_BEHAVIORAL_CHANGE bc, P2R_PROJECT_DETAILS project, P2R_PROGRAM_DETAILS program WHERE " +
                              "{0} AND bc.PROJECT_DETAILS_ID = project.PROJECT_DETAILS_ID",
                              _projectDetailsWhereQuery);
            {
                Dictionary <string, BehavioralChangeDataType> behavioralChangeMap =
                    _baseDao.MapArrayObjects <BehavioralChangeDataType>(
                        "PROJECT_DETAILS_ID", idToProjectDetailsMap.Keys, selectText,
                        P2RPluginMappers.MapBehavioralChange, "BEHAVIORAL_CHANGE_ID",
                        delegate(BehavioralChangeDataType[] array, int listKeyFieldsIndex)
                {
                    ProjectDetailsDataType projectDetails =
                        idToProjectDetailsMap[CollectionUtils.NthItem(idToProjectDetailsMap.Keys, listKeyFieldsIndex)];
                    projectDetails.BehavioralChange = array;
                });

                if (!CollectionUtils.IsNullOrEmpty(behavioralChangeMap))
                {
                    selectText =
                        string.Format("SELECT bcqr.* FROM P2R_BEHAVIORAL_CHANGE_QNT_RSLT bcqr, P2R_BEHAVIORAL_CHANGE bc, P2R_PROJECT_DETAILS project, P2R_PROGRAM_DETAILS program WHERE " +
                                      "{0} AND bc.PROJECT_DETAILS_ID = project.PROJECT_DETAILS_ID AND bc.BEHAVIORAL_CHANGE_ID = bcqr.BEHAVIORAL_CHANGE_ID",
                                      _projectDetailsWhereQuery);
                    _baseDao.MapArrayObjects <BehavioralChangeQuantitativeResultDataType>(
                        "BEHAVIORAL_CHANGE_ID", behavioralChangeMap.Keys, selectText,
                        P2RPluginMappers.MapBehavioralChangeQuantitativeResultDataType,
                        delegate(BehavioralChangeQuantitativeResultDataType[] array, int listKeyFieldsIndex)
                    {
                        BehavioralChangeDataType behavioralChange =
                            behavioralChangeMap[CollectionUtils.NthItem(behavioralChangeMap.Keys, listKeyFieldsIndex)];
                        behavioralChange.QuantitativeResult = array;
                    });
                }
            }
            selectText =
                string.Format("SELECT om.* FROM P2R_OUTCOME_MEASURE om, P2R_PROJECT_DETAILS project, P2R_PROGRAM_DETAILS program WHERE " +
                              "{0} AND om.PROJECT_DETAILS_ID = project.PROJECT_DETAILS_ID",
                              _projectDetailsWhereQuery);
            {
                Dictionary <string, OutcomeMeasureDataType> outcomeMeasureMap =
                    _baseDao.MapArrayObjects <OutcomeMeasureDataType>(
                        "PROJECT_DETAILS_ID", idToProjectDetailsMap.Keys, selectText,
                        P2RPluginMappers.MapOutcomeMeasure, "OUTCOME_MEASURE_ID",
                        delegate(OutcomeMeasureDataType[] array, int listKeyFieldsIndex)
                {
                    ProjectDetailsDataType projectDetails =
                        idToProjectDetailsMap[CollectionUtils.NthItem(idToProjectDetailsMap.Keys, listKeyFieldsIndex)];
                    projectDetails.OutcomeMeasure = array;
                });
                if (!CollectionUtils.IsNullOrEmpty(outcomeMeasureMap))
                {
                    selectText =
                        string.Format("SELECT omr.* FROM P2R_OUTCOME_MEASURE_RESULT omr, P2R_OUTCOME_MEASURE om, P2R_PROJECT_DETAILS project, P2R_PROGRAM_DETAILS program WHERE " +
                                      "{0} AND om.PROJECT_DETAILS_ID = project.PROJECT_DETAILS_ID AND om.OUTCOME_MEASURE_ID = omr.OUTCOME_MEASURE_ID",
                                      _projectDetailsWhereQuery);
                    _baseDao.MapArrayObjects <OutcomeMeasureResultDataType>(
                        "OUTCOME_MEASURE_ID", outcomeMeasureMap.Keys, selectText,
                        P2RPluginMappers.MapOutcomeMeasureResult,
                        delegate(OutcomeMeasureResultDataType[] array, int listKeyFieldsIndex)
                    {
                        OutcomeMeasureDataType outcomeMeasure =
                            outcomeMeasureMap[CollectionUtils.NthItem(outcomeMeasureMap.Keys, listKeyFieldsIndex)];
                        outcomeMeasure.OutcomeMeasureResult = array;
                    });
                }
            }
        }