示例#1
0
        protected virtual ProgramDetailsDataType[] GetProgramDetails()
        {
            List <ProgramDetailsDataType> programDetails = null;
            List <string> programDetailsRecordIds        = null;

            _baseDao.DoSimpleQueryWithRowCallbackDelegate(
                Tables.P2R_PROGRAM_DETAILS.ToString(),
                "ORG_ID",
                new object[] { _organizationIdentifier },
                delegate(IDataReader reader)
            {
                NamedNullMappingDataReader readerEx = (NamedNullMappingDataReader)reader;
                if (programDetailsRecordIds == null)
                {
                    programDetailsRecordIds = new List <string>();
                }
                programDetailsRecordIds.Add(readerEx.GetString("PROGRAM_DETAILS_ID"));
                ProgramDetailsDataType programDetail = P2RPluginMappers.MapProgramDetails(readerEx);
                if (programDetails == null)
                {
                    programDetails = new List <ProgramDetailsDataType>();
                }
                programDetails.Add(programDetail);
            });
            if (programDetails != null)
            {
                GetProjectDetails(programDetailsRecordIds, programDetails);

                if (_year != 0)
                {
                    // Remove any programs that do not have associated projects
                    for (int i = programDetails.Count - 1; i >= 0; --i)
                    {
                        if (CollectionUtils.IsNullOrEmpty(programDetails[i].ProjectDetails))
                        {
                            programDetails.RemoveAt(i);
                        }
                    }
                }

                if (programDetails.Count == 0)
                {
                    programDetails = null;
                    AppendAuditLogEvent("Didn't find any program details");
                }
                else
                {
                    AppendAuditLogEvent("Found {0} program details",
                                        programDetails.Count.ToString());
                }
            }
            else
            {
                AppendAuditLogEvent("Didn't find any program details");
            }
            return(P2RPluginMappers.ToArray(programDetails));
        }
        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);
            }
        }
        public static ProgramDetailsDataType MapProgramDetails(NamedNullMappingDataReader readerEx)
        {
            ProgramDetailsDataType programDetails = new ProgramDetailsDataType();

            programDetails.ProgramIdentifier    = readerEx.GetString("PROGRAM_IDENTIFIER");
            programDetails.ProgramName          = readerEx.GetString("PROGRAM_NAME");
            programDetails.ProgramDescription   = readerEx.GetNullString("PROGRAM_DESCRIPTION");
            programDetails.ProgramAddress       = readerEx.GetNullString("PROGRAM_ADDRESS");
            programDetails.ProgramCity          = readerEx.GetNullString("PROGRAM_CITY");
            programDetails.ProgramState         = readerEx.GetNullString("PROGRAM_STATE");
            programDetails.ProgramZipCode       = readerEx.GetNullString("PROGRAM_ZIP_CODE");
            programDetails.ProgramPhoneNumber   = readerEx.GetNullString("PROGRAM_PHONE_NUMBER");
            programDetails.ProgramContactPerson = readerEx.GetNullString("PROGRAM_CONTACT_PERSON");
            return(programDetails);
        }
 protected void InsertProgramDetails(string orgId, ProgramDetailsDataType[] programDetails)
 {
     if (!CollectionUtils.IsNullOrEmpty(programDetails))
     {
         AppendAuditLogEvent("Inserting {0} program details into database", programDetails.Length.ToString());
         List <KeyValuePair <string, ProjectDetailsDataType> > projectDetailsList = null;
         {
             object[] insertValues = new object[11];
             _baseDao.DoBulkInsert(Tables.P2R_PROGRAM_DETAILS.ToString(),
                                   "PROGRAM_DETAILS_ID;ORG_ID;PROGRAM_IDENTIFIER;PROGRAM_NAME;PROGRAM_DESCRIPTION;PROGRAM_ADDRESS;PROGRAM_CITY;" +
                                   "PROGRAM_STATE;PROGRAM_ZIP_CODE;PROGRAM_PHONE_NUMBER;PROGRAM_CONTACT_PERSON",
                                   delegate(int currentInsertIndex)
             {
                 if (currentInsertIndex < programDetails.Length)
                 {
                     ProgramDetailsDataType programDetail = programDetails[currentInsertIndex];
                     int index             = 0;
                     string id             = _idProvider.Get();
                     insertValues[index++] = id;
                     insertValues[index++] = orgId;
                     insertValues[index++] = programDetail.ProgramIdentifier;
                     insertValues[index++] = programDetail.ProgramName;
                     insertValues[index++] = programDetail.ProgramDescription;
                     insertValues[index++] = programDetail.ProgramAddress;
                     insertValues[index++] = programDetail.ProgramCity;
                     insertValues[index++] = programDetail.ProgramState;
                     insertValues[index++] = (programDetail.ProgramZipCode == null) ? null : programDetail.ProgramZipCode;
                     insertValues[index++] = programDetail.ProgramPhoneNumber;
                     insertValues[index++] = programDetail.ProgramContactPerson;
                     AppendItems(id, programDetail.ProjectDetails, ref projectDetailsList);
                     return(insertValues);
                 }
                 else
                 {
                     return(null);
                 }
             });
         }
         InsertProjectDetails(projectDetailsList);
     }
     else
     {
         AppendAuditLogEvent("No program details specified to insert into database");
     }
 }