public static void StoreAttachmentFilesFromFolder(IObjectsToDatabase objectsToDatabase, SpringBaseDao baseDao, OrganizationDataType data, string folderPath)
        {
            if (data.Activity != null)
            {
                foreach (ActivityDataType activity in data.Activity)
                {
                    if (activity.AttachedBinaryObject != null)
                    {
                        foreach (AttachedBinaryObjectDataType attachment in activity.AttachedBinaryObject)
                        {
                            if (string.IsNullOrEmpty(attachment.BinaryObjectFileName))
                            {
                                throw new ArgException("An attachment for the activity with id \"{0}\" does not have an attachment name.",
                                                       activity.ActivityDescription.ActivityIdentifier);
                            }

                            string filePath = Path.Combine(folderPath, attachment.BinaryObjectFileName);
                            if (!File.Exists(filePath))
                            {
                                throw new ArgException("Failed to locate an attachment with the name \"{0}\" for the activity with id \"{1}\" in the temporary folder: \"{2}\"",
                                                       attachment.BinaryObjectFileName, activity.ActivityDescription.ActivityIdentifier, filePath);
                            }

                            byte[] content = CompressFile(folderPath, filePath);

                            int updateCount = baseDao.DoJDBCExecuteNonQuery("UPDATE WQX_ACTATTACHEDBINARYOBJECT SET BINARYOBJECTCONTENT = ? WHERE PARENTID = ? AND BINARYOBJECTFILE = ?",
                                                                            content, activity.RecordId, attachment.BinaryObjectFileName);
                            if (updateCount == 0)
                            {
                                throw new ArgException("Failed to update the content for an attachment with the name \"{0}\" for the activity with id \"{1}\"",
                                                       attachment.BinaryObjectFileName, activity.ActivityDescription.ActivityIdentifier);
                            }
                        }
                    }
                }
            }

            if (data.MonitoringLocation != null)
            {
                foreach (MonitoringLocationDataType monitoringLocation in data.MonitoringLocation)
                {
                    if (monitoringLocation.AttachedBinaryObject != null)
                    {
                        foreach (AttachedBinaryObjectDataType attachment in monitoringLocation.AttachedBinaryObject)
                        {
                            if (string.IsNullOrEmpty(attachment.BinaryObjectFileName))
                            {
                                throw new ArgException("An attachment for the monitoring location \"{0}\" with id \"{1}\" does not have an attachment name.",
                                                       monitoringLocation.WellInformation, monitoringLocation.MonitoringLocationIdentity.MonitoringLocationIdentifier);
                            }

                            string filePath = Path.Combine(folderPath, attachment.BinaryObjectFileName);
                            if (!File.Exists(filePath))
                            {
                                throw new ArgException("Failed to locate an attachment with the name \"{0}\" for the monitoring location \"{1}\" with id \"{2}\" in the temporary folder: \"{3}\"",
                                                       attachment.BinaryObjectFileName, monitoringLocation.WellInformation, monitoringLocation.MonitoringLocationIdentity.MonitoringLocationIdentifier, filePath);
                            }

                            byte[] content = CompressFile(folderPath, filePath);

                            int updateCount = baseDao.DoJDBCExecuteNonQuery("UPDATE WQX_MONLOCATTACHEDBINARYOBJECT SET BINARYOBJECTCONTENT = ? WHERE PARENTID = ? AND BINARYOBJECTFILE = ?",
                                                                            content, monitoringLocation.RecordId, attachment.BinaryObjectFileName);
                            if (updateCount == 0)
                            {
                                throw new ArgException("Failed to update the content for an attachment with the name \"{0}\" for the monitoring location with id \"{1}\"",
                                                       attachment.BinaryObjectFileName, monitoringLocation.MonitoringLocationIdentity.MonitoringLocationIdentifier);
                            }
                        }
                    }
                }
            }

            if (data.Project != null)
            {
                foreach (ProjectDataType project in data.Project)
                {
                    if (project.AttachedBinaryObject != null)
                    {
                        foreach (AttachedBinaryObjectDataType attachment in project.AttachedBinaryObject)
                        {
                            if (string.IsNullOrEmpty(attachment.BinaryObjectFileName))
                            {
                                throw new ArgException("An attachment for the project \"{0}\" with id \"{1}\" does not have an attachment name.",
                                                       project.ProjectDescriptionText, project.ProjectIdentifier);
                            }

                            string filePath = Path.Combine(folderPath, attachment.BinaryObjectFileName);
                            if (!File.Exists(filePath))
                            {
                                throw new ArgException("Failed to locate an attachment with the name \"{0}\" for the project \"{1}\" with id \"{2}\" in the temporary folder: \"{3}\"",
                                                       attachment.BinaryObjectFileName, project.ProjectDescriptionText, project.ProjectIdentifier, filePath);
                            }

                            byte[] content = CompressFile(folderPath, filePath);

                            int updateCount = baseDao.DoJDBCExecuteNonQuery("UPDATE WQX_PROJATTACHEDBINARYOBJECT SET BINARYOBJECTCONTENT = ? WHERE PARENTID = ? AND BINARYOBJECTFILE = ?",
                                                                            content, project.RecordId, attachment.BinaryObjectFileName);
                            if (updateCount == 0)
                            {
                                throw new ArgException("Failed to update the content for an attachment with the name \"{0}\" for the project with id \"{1}\"",
                                                       attachment.BinaryObjectFileName, project.ProjectIdentifier);
                            }
                        }
                    }
                }
            }
        }
        public static void DeleteFromStagingTables(SpringBaseDao baseDao)
        {
            int count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_RESULTDETECTQUANTLIMIT WHERE 1=1 ");

            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_RESULTATTACHEDBINARYOBJECT WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_LABSAMPLEPREP WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_RESULT WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_PROJECTACTIVITY WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_ACTATTACHEDBINARYOBJECT WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_ACTIVITYACTIVITYGROUP WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_ACTIVITYCONDUCTINGORG WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_ACTIVITYGROUP WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_ACTIVITYMETRIC WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_ACTIVITY WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_BIOLOGICALHABITATINDEX WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_PROJECTMONLOC WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_PROJATTACHEDBINARYOBJECT WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_PROJECT WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_MONLOCATTACHEDBINARYOBJECT WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_ALTMONLOC WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_MONITORINGLOCATION WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_ORGADDRESS WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_TELEPHONIC WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_ELECTRONICADDRESS WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_DELETES WHERE 1=1 ");
            count = baseDao.DoJDBCExecuteNonQuery("	DELETE FROM WQX_ORGANIZATION WHERE 1=1 ");
        }