コード例 #1
0
        } //  GetLayerSourceInfo()

        public PDX.BTS.DataMaintenance.MaintTools.FeatureClassSourceInfo GetLayerSourceInfo(string FeatureClassName, string OutputGeodatabaseName)
        {
            System.Data.SqlClient.SqlCommand    getSourceInfoSQLCommand    = null;
            System.Data.SqlClient.SqlDataReader getSourceInfoSQLDataReader = null;
            ESRI.ArcGIS.esriSystem.IPropertySet sourcePropertySet          = null;
            PDX.BTS.DataMaintenance.MaintTools.GeneralUtilities      maintenanceGeneralUtilities = null;
            PDX.BTS.DataMaintenance.MaintTools.PathManager           shapefilePathGenerator      = null;
            PDX.BTS.DataMaintenance.MaintTools.FeatureClassUtilities featureClassUtilities       = null;

            try
            {
                //  Make sure there is a valid connection to the Load Metadata Database before attempting to update it.
                if (!ConnecttoImportMonitorDatabase())
                {
                    //  Send a Message to the calling application to let the user know why this process failed.
                    if (ErrorMessage != null)
                    {
                        ErrorMessage("     Could not establish a connection to the Load Metadata Database!  LoaderUtilities.DatabaseTools.GetLayerSourceInfo() Failed!");
                    }

                    //  Return a NULL String to the calling routine to indicate that this process failed.
                    return(null);
                }


                //  Build the SQL Statement that will be used to retrieve the Source Information for the Feature Class.
                string getSourceInfoSQLStatement = "SELECT [Load_Source], [Data_Source], [Dataset], [GeoDB_File], [Source_Server_Name],"
                                                   + "       [Source_Instance], [Source_Database_Name], [Source_Database_User_Name],"
                                                   + "       [Input_Dataset_Name], [Output_Database] "
                                                   + "FROM " + _monitorTableName + " "
                                                   + "WHERE [Feature_Class_Name] = '" + FeatureClassName + "'";


                //  If the Output Geodatabase Name was passed to this method, include it in the query.
                if (!System.String.IsNullOrEmpty(OutputGeodatabaseName))
                {
                    //  Add the Output Geodatabase Name to the SQL Statement.
                    getSourceInfoSQLStatement = getSourceInfoSQLStatement + " AND [Output_Database] = '" + OutputGeodatabaseName + "'";
                }


                //  Build the SQL Command Object that will be used to retrieve the Source Data Info for the specified Feature Class.
                getSourceInfoSQLCommand                = new System.Data.SqlClient.SqlCommand();
                getSourceInfoSQLCommand.Connection     = _importMonitorDatabaseConnection;
                getSourceInfoSQLCommand.CommandType    = System.Data.CommandType.Text;
                getSourceInfoSQLCommand.CommandText    = getSourceInfoSQLStatement;
                getSourceInfoSQLCommand.CommandTimeout = 30;


                //  Use the SQL Command Object that was just instantiated to populate a SQL Data Reader Object with the info about the specified
                //  Feature Class.
                getSourceInfoSQLDataReader = getSourceInfoSQLCommand.ExecuteReader();


                //  Instantiate a Feature Class Source Info Object.
                PDX.BTS.DataMaintenance.MaintTools.FeatureClassSourceInfo currentFeatureClassSourceInfo = new PDX.BTS.DataMaintenance.MaintTools.FeatureClassSourceInfo();

                //  If some information was retrieved, populate a Feature Class Source Info Object and return it to the calling method.  If not,
                //  return a NULL Pointer to indicate that this method failed.
                if (getSourceInfoSQLDataReader.HasRows)
                {
                    if (getSourceInfoSQLDataReader.Read())
                    {
                        //  Populate the New Feature Class Source Info Object with the Source Info for the specified Feature Class.
                        //  Populate the Source Type Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Load_Source")))
                        {
                            currentFeatureClassSourceInfo.SourceType = (string)getSourceInfoSQLDataReader["Load_Source"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.SourceType = "";
                        }
                        //  Populate the Source Data Share Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Data_Source")))
                        {
                            currentFeatureClassSourceInfo.SourceDataShare = (string)getSourceInfoSQLDataReader["Data_Source"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.SourceDataShare = "";
                        }
                        //  Populate the Source Dataset Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Dataset")))
                        {
                            currentFeatureClassSourceInfo.SourceDataset = (string)getSourceInfoSQLDataReader["Dataset"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.SourceDataset = "";
                        }
                        //  Populate the Source Geodatabase File Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("GeoDB_File")))
                        {
                            currentFeatureClassSourceInfo.SourceGeoDBFile = (string)getSourceInfoSQLDataReader["GeoDB_File"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.SourceGeoDBFile = "";
                        }
                        //  Populate the Source Server Name Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Source_Server_Name")))
                        {
                            currentFeatureClassSourceInfo.SourceServerName = (string)getSourceInfoSQLDataReader["Source_Server_Name"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.SourceServerName = "";
                        }
                        //  Populate the Source Instance Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Source_Instance")))
                        {
                            currentFeatureClassSourceInfo.SourceInstance = (string)getSourceInfoSQLDataReader["Source_Instance"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.SourceInstance = "";
                        }
                        //  Populate the Source Database Name Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Source_Database_Name")))
                        {
                            currentFeatureClassSourceInfo.SourceDatabaseName = (string)getSourceInfoSQLDataReader["Source_Database_Name"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.SourceDatabaseName = "";
                        }
                        //  Populate the Source Database User Name Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Source_Database_User_Name")))
                        {
                            currentFeatureClassSourceInfo.SourceDatabaseUser = (string)getSourceInfoSQLDataReader["Source_Database_User_Name"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.SourceDatabaseUser = "";
                        }
                        //  Populate the Input Feature Class Name Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Input_Dataset_Name")))
                        {
                            currentFeatureClassSourceInfo.SourceFeatureClassName = (string)getSourceInfoSQLDataReader["Input_Dataset_Name"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.SourceFeatureClassName = "";
                        }
                        //  Populate the Output Geodatabase Property.
                        if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Output_Database")))
                        {
                            currentFeatureClassSourceInfo.OutputGeodatabaseName = (string)getSourceInfoSQLDataReader["Output_Database"];
                        }
                        else
                        {
                            currentFeatureClassSourceInfo.OutputGeodatabaseName = "";
                        }
                    }
                    else
                    {
                        //  Send a Message to the calling application to let the user know why this process failed.
                        if (ErrorMessage != null)
                        {
                            ErrorMessage("     No Source Information for the Specified Feature Class was found in the Load Metadata Database!  LoaderUtilities.DatabaseTools.GetLayerSourceInfo() Failed!");
                        }
                        //  Return a NULL String to the calling routine to indicate that this process failed.
                        return(null);
                    }
                }
                else
                {
                    //  Send a Message to the calling application to let the user know why this process failed.
                    if (ErrorMessage != null)
                    {
                        ErrorMessage("     The query to retrieve Source Information for the Specified Feature Class failed to retrieve any data from the Load Metadata Database!  LoaderUtilities.DatabaseTools.GetLayerSourceInfo() Failed!");
                    }

                    //  Return a NULL String to the calling routine to indicate that this process failed.
                    return(null);
                }


                //  Instantiate a Feature Class Utilities Object.
                featureClassUtilities = new PDX.BTS.DataMaintenance.MaintTools.FeatureClassUtilities();


                //  Build the Property Set for the Source Dataset and determine its Last Update Date.
                sourcePropertySet = new ESRI.ArcGIS.esriSystem.PropertySet();
                switch (currentFeatureClassSourceInfo.SourceType)
                {
                case "FILEGEODB":
                    //  Build the File Geodatabase PropertySet.
                    sourcePropertySet.SetProperty("DATABASE", currentFeatureClassSourceInfo.SourceGeoDBFile);
                    //  Determine the File Geodatabase Feature Class Last Update Date.
                    currentFeatureClassSourceInfo.SourceLastUpdateDate = featureClassUtilities.GetFileGeodatabaseFeatureClassLastUpdate(currentFeatureClassSourceInfo.SourceGeoDBFile, currentFeatureClassSourceInfo.SourceFeatureClassName);
                    //  Exit this case.
                    break;

                case "PERSONALGEODB":
                    //  Build the Personal Geodatabase PropertySet.
                    sourcePropertySet.SetProperty("DATABASE", currentFeatureClassSourceInfo.SourceGeoDBFile);
                    //  Determine the Source Personal Geodatabase Last Update Date.
                    currentFeatureClassSourceInfo.SourceLastUpdateDate = featureClassUtilities.GetPersonalGeoDBLastUpdateDate(currentFeatureClassSourceInfo.SourceGeoDBFile);
                    //  Exit this case.
                    break;

                case "GEODATABASE":
                    //  Determine the Server User Password.
                    maintenanceGeneralUtilities = new PDX.BTS.DataMaintenance.MaintTools.GeneralUtilities();
                    string serverUserPassword = maintenanceGeneralUtilities.RetrieveParameterValue(currentFeatureClassSourceInfo.SourceDatabaseUser + "_Password", _parameterTableName, _parameterDatabaseConnectionString, true);
                    //  Build the Enterprise Geodatabase Property Set.
                    sourcePropertySet.SetProperty("SERVER", currentFeatureClassSourceInfo.SourceServerName);
                    sourcePropertySet.SetProperty("INSTANCE", currentFeatureClassSourceInfo.SourceInstance);
                    sourcePropertySet.SetProperty("DATABASE", currentFeatureClassSourceInfo.SourceDatabaseName);
                    sourcePropertySet.SetProperty("USER", currentFeatureClassSourceInfo.SourceDatabaseUser);
                    sourcePropertySet.SetProperty("PASSWORD", serverUserPassword);
                    sourcePropertySet.SetProperty("VERSION", "SDE.Default");
                    //  Determine the Enterprise Geodatabase Feature Class Last Udpate Date.
                    currentFeatureClassSourceInfo.SourceLastUpdateDate = featureClassUtilities.GetEntGeoDBFeatureClassLastUpdate(currentFeatureClassSourceInfo.SourceFeatureClassName, currentFeatureClassSourceInfo.SourceServerName, currentFeatureClassSourceInfo.SourceDatabaseName, currentFeatureClassSourceInfo.SourceDatabaseUser, serverUserPassword);
                    //  Exit this case.
                    break;

                case "SHAPEFILE":
                    //  Instantiate a City of Portland Path Manager Object that will be used to determine the Path to the Source Shapefile.
                    shapefilePathGenerator = new PDX.BTS.DataMaintenance.MaintTools.PathManager();
                    string shapefileDirectoryPath = shapefilePathGenerator.BuildShapefileDirectoryPath(currentFeatureClassSourceInfo.SourceDataShare, currentFeatureClassSourceInfo.SourceDataset, currentFeatureClassSourceInfo.SourceFeatureClassName);
                    //  Build the Shapefile PropertySet.
                    sourcePropertySet.SetProperty("DATABASE", shapefileDirectoryPath);
                    //  Determine the Source Shapefile Last Update Date.
                    string fullShapefilePath = shapefilePathGenerator.BuildShapefilePath(currentFeatureClassSourceInfo.SourceDataShare, currentFeatureClassSourceInfo.SourceDataset, currentFeatureClassSourceInfo.SourceFeatureClassName);
                    currentFeatureClassSourceInfo.SourceLastUpdateDate = featureClassUtilities.GetShapefileLastUpdateDate(fullShapefilePath);
                    //  Exit this case.
                    break;

                default:
                    //  Exit this case.
                    break;
                }

                //  Set the Source PropertySet Property of the Current Source Feature Class Info Object.
                currentFeatureClassSourceInfo.SourceDatasetPropertySet = sourcePropertySet;


                //  Return the populated Current Feature Class Source Info Object to the calling method.
                return(currentFeatureClassSourceInfo);
            }
            catch (Exception caught)
            {
                //  Send a Message to the calling application to let the user know why this process failed.
                if (ErrorMessage != null)
                {
                    ErrorMessage("    The LoaderUtilities.DatabaseTools.GetLayerSourceInfo() Method Failed with error message:  " + caught.Message);
                }

                //  Return a NULL String to the calling routine to indicate that this process failed.
                return(null);
            }
            finally
            {
                //  If the Get Source Info SQL Data Reader Object was instantiated, close it.
                if (getSourceInfoSQLDataReader != null)
                {
                    if (!getSourceInfoSQLDataReader.IsClosed)
                    {
                        getSourceInfoSQLDataReader.Close();
                    }
                    getSourceInfoSQLDataReader.Dispose();
                    getSourceInfoSQLDataReader = null;
                }
                //  If the Get Source Info SQL Command Object was instantiated, close it.
                if (getSourceInfoSQLCommand != null)
                {
                    getSourceInfoSQLCommand.Dispose();
                    getSourceInfoSQLCommand = null;
                }
            }
        } //  GetLayerSourceInfo()
コード例 #2
0
        public PDX.BTS.DataMaintenance.MaintTools.FeatureClassSourceInfo GetLayerSourceInfo(string FeatureClassName, string OutputGeodatabaseName)
        {
            System.Data.SqlClient.SqlCommand                         getSourceInfoSQLCommand     = null;
              System.Data.SqlClient.SqlDataReader                      getSourceInfoSQLDataReader  = null;
              ESRI.ArcGIS.esriSystem.IPropertySet                      sourcePropertySet           = null;
              PDX.BTS.DataMaintenance.MaintTools.GeneralUtilities      maintenanceGeneralUtilities = null;
              PDX.BTS.DataMaintenance.MaintTools.PathManager           shapefilePathGenerator      = null;
              PDX.BTS.DataMaintenance.MaintTools.FeatureClassUtilities featureClassUtilities       = null;

              try
              {
            //  Make sure there is a valid connection to the Load Metadata Database before attempting to update it.
            if (!ConnecttoImportMonitorDatabase())
            {
              //  Send a Message to the calling application to let the user know why this process failed.
              if (ErrorMessage != null)
              {
            ErrorMessage("     Could not establish a connection to the Load Metadata Database!  LoaderUtilities.DatabaseTools.GetLayerSourceInfo() Failed!");
              }

              //  Return a NULL String to the calling routine to indicate that this process failed.
              return null;

            }

            //  Build the SQL Statement that will be used to retrieve the Source Information for the Feature Class.
            string getSourceInfoSQLStatement = "SELECT [Load_Source], [Data_Source], [Dataset], [GeoDB_File], [Source_Server_Name],"
                                         + "       [Source_Instance], [Source_Database_Name], [Source_Database_User_Name],"
                                         + "       [Input_Dataset_Name], [Output_Database] "
                                         + "FROM " + _monitorTableName + " "
                                         + "WHERE [Feature_Class_Name] = '" + FeatureClassName + "'";

            //  If the Output Geodatabase Name was passed to this method, include it in the query.
            if (!System.String.IsNullOrEmpty(OutputGeodatabaseName))
            {
              //  Add the Output Geodatabase Name to the SQL Statement.
              getSourceInfoSQLStatement = getSourceInfoSQLStatement + " AND [Output_Database] = '" + OutputGeodatabaseName + "'";

            }

            //  Build the SQL Command Object that will be used to retrieve the Source Data Info for the specified Feature Class.
            getSourceInfoSQLCommand = new System.Data.SqlClient.SqlCommand();
            getSourceInfoSQLCommand.Connection = _importMonitorDatabaseConnection;
            getSourceInfoSQLCommand.CommandType = System.Data.CommandType.Text;
            getSourceInfoSQLCommand.CommandText = getSourceInfoSQLStatement;
            getSourceInfoSQLCommand.CommandTimeout = 30;

            //  Use the SQL Command Object that was just instantiated to populate a SQL Data Reader Object with the info about the specified
            //  Feature Class.
            getSourceInfoSQLDataReader = getSourceInfoSQLCommand.ExecuteReader();

            //  Instantiate a Feature Class Source Info Object.
            PDX.BTS.DataMaintenance.MaintTools.FeatureClassSourceInfo currentFeatureClassSourceInfo = new PDX.BTS.DataMaintenance.MaintTools.FeatureClassSourceInfo();

            //  If some information was retrieved, populate a Feature Class Source Info Object and return it to the calling method.  If not,
            //  return a NULL Pointer to indicate that this method failed.
            if (getSourceInfoSQLDataReader.HasRows)
            {
              if (getSourceInfoSQLDataReader.Read())
              {
            //  Populate the New Feature Class Source Info Object with the Source Info for the specified Feature Class.
            //  Populate the Source Type Property.
            if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Load_Source")))
            {
              currentFeatureClassSourceInfo.SourceType = (string)getSourceInfoSQLDataReader["Load_Source"];
            }
            else
            {
              currentFeatureClassSourceInfo.SourceType = "";
            }
            //  Populate the Source Data Share Property.
            if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Data_Source")))
            {
              currentFeatureClassSourceInfo.SourceDataShare = (string)getSourceInfoSQLDataReader["Data_Source"];
            }
            else
            {
              currentFeatureClassSourceInfo.SourceDataShare = "";
            }
            //  Populate the Source Dataset Property.
            if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Dataset")))
            {
              currentFeatureClassSourceInfo.SourceDataset = (string)getSourceInfoSQLDataReader["Dataset"];
            }
            else
            {
              currentFeatureClassSourceInfo.SourceDataset = "";
            }
            //  Populate the Source Geodatabase File Property.
            if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("GeoDB_File")))
            {
              currentFeatureClassSourceInfo.SourceGeoDBFile = (string)getSourceInfoSQLDataReader["GeoDB_File"];
            }
            else
            {
              currentFeatureClassSourceInfo.SourceGeoDBFile = "";
            }
            //  Populate the Source Server Name Property.
            if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Source_Server_Name")))
            {
              currentFeatureClassSourceInfo.SourceServerName = (string)getSourceInfoSQLDataReader["Source_Server_Name"];
            }
            else
            {
              currentFeatureClassSourceInfo.SourceServerName = "";
            }
            //  Populate the Source Instance Property.
            if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Source_Instance")))
            {
              currentFeatureClassSourceInfo.SourceInstance = (string)getSourceInfoSQLDataReader["Source_Instance"];
            }
            else
            {
              currentFeatureClassSourceInfo.SourceInstance = "";
            }
            //  Populate the Source Database Name Property.
            if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Source_Database_Name")))
            {
              currentFeatureClassSourceInfo.SourceDatabaseName = (string)getSourceInfoSQLDataReader["Source_Database_Name"];
            }
            else
            {
              currentFeatureClassSourceInfo.SourceDatabaseName = "";
            }
            //  Populate the Source Database User Name Property.
            if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Source_Database_User_Name")))
            {
              currentFeatureClassSourceInfo.SourceDatabaseUser = (string)getSourceInfoSQLDataReader["Source_Database_User_Name"];
            }
            else
            {
              currentFeatureClassSourceInfo.SourceDatabaseUser = "";
            }
            //  Populate the Input Feature Class Name Property.
            if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Input_Dataset_Name")))
            {
              currentFeatureClassSourceInfo.SourceFeatureClassName = (string)getSourceInfoSQLDataReader["Input_Dataset_Name"];
            }
            else
            {
              currentFeatureClassSourceInfo.SourceFeatureClassName = "";
            }
            //  Populate the Output Geodatabase Property.
            if (!getSourceInfoSQLDataReader.IsDBNull(getSourceInfoSQLDataReader.GetOrdinal("Output_Database")))
            {
              currentFeatureClassSourceInfo.OutputGeodatabaseName = (string)getSourceInfoSQLDataReader["Output_Database"];
            }
            else
            {
              currentFeatureClassSourceInfo.OutputGeodatabaseName = "";
            }
              }
              else
              {
            //  Send a Message to the calling application to let the user know why this process failed.
            if (ErrorMessage != null)
            {
              ErrorMessage("     No Source Information for the Specified Feature Class was found in the Load Metadata Database!  LoaderUtilities.DatabaseTools.GetLayerSourceInfo() Failed!");
            }
            //  Return a NULL String to the calling routine to indicate that this process failed.
            return null;
              }

            }
            else
            {
              //  Send a Message to the calling application to let the user know why this process failed.
              if (ErrorMessage != null)
              {
            ErrorMessage("     The query to retrieve Source Information for the Specified Feature Class failed to retrieve any data from the Load Metadata Database!  LoaderUtilities.DatabaseTools.GetLayerSourceInfo() Failed!");
              }

              //  Return a NULL String to the calling routine to indicate that this process failed.
              return null;

            }

            //  Instantiate a Feature Class Utilities Object.
            featureClassUtilities = new PDX.BTS.DataMaintenance.MaintTools.FeatureClassUtilities();

            //  Build the Property Set for the Source Dataset and determine its Last Update Date.
            sourcePropertySet = new ESRI.ArcGIS.esriSystem.PropertySet();
            switch (currentFeatureClassSourceInfo.SourceType)
            {
              case "FILEGEODB":
            //  Build the File Geodatabase PropertySet.
            sourcePropertySet.SetProperty("DATABASE", currentFeatureClassSourceInfo.SourceGeoDBFile);
            //  Determine the File Geodatabase Feature Class Last Update Date.
            currentFeatureClassSourceInfo.SourceLastUpdateDate = featureClassUtilities.GetFileGeodatabaseFeatureClassLastUpdate(currentFeatureClassSourceInfo.SourceGeoDBFile, currentFeatureClassSourceInfo.SourceFeatureClassName);
            //  Exit this case.
            break;
              case "PERSONALGEODB":
            //  Build the Personal Geodatabase PropertySet.
            sourcePropertySet.SetProperty("DATABASE", currentFeatureClassSourceInfo.SourceGeoDBFile);
            //  Determine the Source Personal Geodatabase Last Update Date.
            currentFeatureClassSourceInfo.SourceLastUpdateDate = featureClassUtilities.GetPersonalGeoDBLastUpdateDate(currentFeatureClassSourceInfo.SourceGeoDBFile);
            //  Exit this case.
            break;
              case "GEODATABASE":
            //  Determine the Server User Password.
            maintenanceGeneralUtilities = new PDX.BTS.DataMaintenance.MaintTools.GeneralUtilities();
            string serverUserPassword = maintenanceGeneralUtilities.RetrieveParameterValue(currentFeatureClassSourceInfo.SourceDatabaseUser + "_Password", _parameterTableName, _parameterDatabaseConnectionString, true);
            //  Build the Enterprise Geodatabase Property Set.
            sourcePropertySet.SetProperty("SERVER", currentFeatureClassSourceInfo.SourceServerName);
            sourcePropertySet.SetProperty("INSTANCE", currentFeatureClassSourceInfo.SourceInstance);
            sourcePropertySet.SetProperty("DATABASE", currentFeatureClassSourceInfo.SourceDatabaseName);
            sourcePropertySet.SetProperty("USER", currentFeatureClassSourceInfo.SourceDatabaseUser);
            sourcePropertySet.SetProperty("PASSWORD", serverUserPassword);
            sourcePropertySet.SetProperty("VERSION", "SDE.Default");
            //  Determine the Enterprise Geodatabase Feature Class Last Udpate Date.
            currentFeatureClassSourceInfo.SourceLastUpdateDate = featureClassUtilities.GetEntGeoDBFeatureClassLastUpdate(currentFeatureClassSourceInfo.SourceFeatureClassName, currentFeatureClassSourceInfo.SourceServerName, currentFeatureClassSourceInfo.SourceDatabaseName, currentFeatureClassSourceInfo.SourceDatabaseUser, serverUserPassword);
            //  Exit this case.
            break;
              case "SHAPEFILE":
            //  Instantiate a City of Portland Path Manager Object that will be used to determine the Path to the Source Shapefile.
            shapefilePathGenerator = new PDX.BTS.DataMaintenance.MaintTools.PathManager();
            string shapefileDirectoryPath = shapefilePathGenerator.BuildShapefileDirectoryPath(currentFeatureClassSourceInfo.SourceDataShare, currentFeatureClassSourceInfo.SourceDataset, currentFeatureClassSourceInfo.SourceFeatureClassName);
            //  Build the Shapefile PropertySet.
            sourcePropertySet.SetProperty("DATABASE", shapefileDirectoryPath);
            //  Determine the Source Shapefile Last Update Date.
            string fullShapefilePath = shapefilePathGenerator.BuildShapefilePath(currentFeatureClassSourceInfo.SourceDataShare, currentFeatureClassSourceInfo.SourceDataset, currentFeatureClassSourceInfo.SourceFeatureClassName);
            currentFeatureClassSourceInfo.SourceLastUpdateDate = featureClassUtilities.GetShapefileLastUpdateDate(fullShapefilePath);
            //  Exit this case.
            break;
              default:
            //  Exit this case.
            break;
            }

            //  Set the Source PropertySet Property of the Current Source Feature Class Info Object.
            currentFeatureClassSourceInfo.SourceDatasetPropertySet = sourcePropertySet;

            //  Return the populated Current Feature Class Source Info Object to the calling method.
            return currentFeatureClassSourceInfo;

              }
              catch (Exception caught)
              {
            //  Send a Message to the calling application to let the user know why this process failed.
            if (ErrorMessage != null)
            {
              ErrorMessage("    The LoaderUtilities.DatabaseTools.GetLayerSourceInfo() Method Failed with error message:  " + caught.Message);
            }

            //  Return a NULL String to the calling routine to indicate that this process failed.
            return null;

              }
              finally
              {
            //  If the Get Source Info SQL Data Reader Object was instantiated, close it.
            if (getSourceInfoSQLDataReader != null)
            {
              if (!getSourceInfoSQLDataReader.IsClosed)
              {
            getSourceInfoSQLDataReader.Close();
              }
              getSourceInfoSQLDataReader.Dispose();
              getSourceInfoSQLDataReader = null;
            }
            //  If the Get Source Info SQL Command Object was instantiated, close it.
            if (getSourceInfoSQLCommand != null)
            {
              getSourceInfoSQLCommand.Dispose();
              getSourceInfoSQLCommand = null;
            }

              }
        }
コード例 #3
0
        }           //  GetLastLoadDatefromFeatureClass

        public System.DateTime GetFeatureClassSourceLastUpdateDate(string FeatureClassName, string OutputGeodatabaseName)
        {
            PDX.BTS.DataMaintenance.MaintTools.FeatureClassSourceInfo currentFeatureClassSourceInfo = null;
            PDX.BTS.DataMaintenance.MaintTools.PathManager            featureClassPathManager       = null;
            PDX.BTS.DataMaintenance.MaintTools.FeatureClassUtilities  featureClassUtilities         = null;

            try
            {
                //  Determine the Source Information for the specified Feature Class.
                currentFeatureClassSourceInfo = GetLayerSourceInfo(FeatureClassName, OutputGeodatabaseName);

                //  Make sure the Source Info was retrieved successfully before moving on.
                if (currentFeatureClassSourceInfo == null)
                {
                    //  Let the User know that the Information was not retrieved successfully.
                    if (ErrorMessage != null)
                    {
                        ErrorMessage("Failed to retrieve the Source Information for the " + FeatureClassName + " Feature Class.  The GetFeatureClassSourceUpdateDate() Method Failed!");
                    }

                    //  Return a date of "1/1/1900" to the calling method to indicate that this method failed.
                    return(System.DateTime.Parse("1/1/1900 00:00:00.000"));
                }


                //  Instantiate the Feature Class Path Manager Object that will be used, where necessary, to determine the path to the specified
                //  Source Dataset.
                featureClassPathManager = new PDX.BTS.DataMaintenance.MaintTools.PathManager();


                //  Instantiate the Feature Class Utilities Object that will be used to determine the Source Feature Class Last Update Date for the
                //  specified Feature Class.
                featureClassUtilities = new PDX.BTS.DataMaintenance.MaintTools.FeatureClassUtilities();


                //  Determine the Last Update Date of the Source Dataset for the specified Feature Class.
                switch (currentFeatureClassSourceInfo.SourceType.ToUpper())
                {
                case "SHAPEFILE":
                    //  Determine the Path to the Source Shapefile for the specified Feature Class.
                    string sourceShapefilePath = featureClassPathManager.BuildShapefilePath(currentFeatureClassSourceInfo.SourceDataShare, currentFeatureClassSourceInfo.SourceDataset, currentFeatureClassSourceInfo.SourceFeatureClassName);
                    //  Determine the Last Update of the Source Shapefile.
                    return(featureClassUtilities.GetShapefileLastUpdateDate(sourceShapefilePath));

                case "PERSONALGEODB":
                    //  Determine the Last Update Date for the Source Personal Geodatabase Feature Class for the specified Output Feature Class.
                    return(featureClassUtilities.GetPersonalGeoDBLastUpdateDate(currentFeatureClassSourceInfo.SourceGeoDBFile));

                case "FILEGEODB":
                    //  Determine the Last Update Date for the Source File Geodatabase Feature Class for the specified Output Feature Class.
                    return(featureClassUtilities.GetFileGeodatabaseLastUpdate(currentFeatureClassSourceInfo.SourceGeoDBFile));

                case "GEODATABASE":
                    //  Determine the Last Update Date for the Source Enterprise Geodatabasde Feature Class for the specified Output Feature Class.
                    return(featureClassUtilities.GetEntGeoDBFeatureClassLastUpdate(currentFeatureClassSourceInfo.SourceFeatureClassName, currentFeatureClassSourceInfo.SourceServerName, currentFeatureClassSourceInfo.SourceDatabaseName, currentFeatureClassSourceInfo.SourceDatabaseUser));

                default:
                    //  Return a date of "!/1/1900" to the calling method to indicate that the date could not be determined.
                    return(System.DateTime.Parse("1/1/1900 00:00:00.000"));
                }
            }
            catch (System.Exception caught)
            {
                //  Let the user know that this process failed.
                if (ErrorMessage != null)
                {
                    ErrorMessage("");
                    ErrorMessage("");
                    ErrorMessage("The FeatureClassUtilities.GetFeatureClassSourceLastUpdateDate() Method failed with error message - " + caught.Message + "!");
                }

                //  Return January 1st, 1900 to the calling routine to indicate that this process failed.
                return(new System.DateTime(1900, 1, 1));
            }
            finally
            {
                //  If the CGIS Data Maintenance Tools Feature Class Utilities Object was instantiated, close it.
                if (featureClassUtilities != null)
                {
                    featureClassUtilities.Dispose();
                    featureClassUtilities = null;
                }
                //  If the CGIS Data Maintenance Tools Feature Class Path Manager Object was instantiated, close it.
                if (featureClassPathManager != null)
                {
                    featureClassPathManager = null;
                }
            }
        } //  GetFeatureClassSourceLastUpdateDate()
コード例 #4
0
        public System.DateTime GetFeatureClassSourceLastUpdateDate(string FeatureClassName, string OutputGeodatabaseName)
        {
            PDX.BTS.DataMaintenance.MaintTools.FeatureClassSourceInfo currentFeatureClassSourceInfo = null;
              PDX.BTS.DataMaintenance.MaintTools.PathManager            featureClassPathManager       = null;
              PDX.BTS.DataMaintenance.MaintTools.FeatureClassUtilities  featureClassUtilities         = null;

              try
              {
            //  Determine the Source Information for the specified Feature Class.
            currentFeatureClassSourceInfo = GetLayerSourceInfo(FeatureClassName, OutputGeodatabaseName);

            //  Make sure the Source Info was retrieved successfully before moving on.
            if (currentFeatureClassSourceInfo == null)
            {
              //  Let the User know that the Information was not retrieved successfully.
              if (ErrorMessage != null)
              {
            ErrorMessage("Failed to retrieve the Source Information for the " + FeatureClassName + " Feature Class.  The GetFeatureClassSourceUpdateDate() Method Failed!");
              }

              //  Return a date of "1/1/1900" to the calling method to indicate that this method failed.
              return System.DateTime.Parse("1/1/1900 00:00:00.000");

            }

            //  Instantiate the Feature Class Path Manager Object that will be used, where necessary, to determine the path to the specified
            //  Source Dataset.
            featureClassPathManager = new PDX.BTS.DataMaintenance.MaintTools.PathManager();

            //  Instantiate the Feature Class Utilities Object that will be used to determine the Source Feature Class Last Update Date for the
            //  specified Feature Class.
            featureClassUtilities = new PDX.BTS.DataMaintenance.MaintTools.FeatureClassUtilities();

            //  Determine the Last Update Date of the Source Dataset for the specified Feature Class.
            switch (currentFeatureClassSourceInfo.SourceType.ToUpper())
            {
              case "SHAPEFILE":
            //  Determine the Path to the Source Shapefile for the specified Feature Class.
            string sourceShapefilePath = featureClassPathManager.BuildShapefilePath(currentFeatureClassSourceInfo.SourceDataShare, currentFeatureClassSourceInfo.SourceDataset, currentFeatureClassSourceInfo.SourceFeatureClassName);
            //  Determine the Last Update of the Source Shapefile.
            return featureClassUtilities.GetShapefileLastUpdateDate(sourceShapefilePath);
              case "PERSONALGEODB":
            //  Determine the Last Update Date for the Source Personal Geodatabase Feature Class for the specified Output Feature Class.
            return featureClassUtilities.GetPersonalGeoDBLastUpdateDate(currentFeatureClassSourceInfo.SourceGeoDBFile);
              case "FILEGEODB":
            //  Determine the Last Update Date for the Source File Geodatabase Feature Class for the specified Output Feature Class.
            return featureClassUtilities.GetFileGeodatabaseLastUpdate(currentFeatureClassSourceInfo.SourceGeoDBFile);
              case "GEODATABASE":
            //  Determine the Last Update Date for the Source Enterprise Geodatabasde Feature Class for the specified Output Feature Class.
            return featureClassUtilities.GetEntGeoDBFeatureClassLastUpdate(currentFeatureClassSourceInfo.SourceFeatureClassName, currentFeatureClassSourceInfo.SourceServerName, currentFeatureClassSourceInfo.SourceDatabaseName, currentFeatureClassSourceInfo.SourceDatabaseUser);
              default:
            //  Return a date of "!/1/1900" to the calling method to indicate that the date could not be determined.
            return System.DateTime.Parse("1/1/1900 00:00:00.000");
            }

              }
              catch (System.Exception caught)
              {
            //  Let the user know that this process failed.
            if (ErrorMessage != null)
            {
              ErrorMessage("");
              ErrorMessage("");
              ErrorMessage("The FeatureClassUtilities.GetFeatureClassSourceLastUpdateDate() Method failed with error message - " + caught.Message + "!");
            }

            //  Return January 1st, 1900 to the calling routine to indicate that this process failed.
            return new System.DateTime(1900, 1, 1);

              }
              finally
              {
            //  If the CGIS Data Maintenance Tools Feature Class Utilities Object was instantiated, close it.
            if (featureClassUtilities != null)
            {
              featureClassUtilities.Dispose();
              featureClassUtilities = null;
            }
            //  If the CGIS Data Maintenance Tools Feature Class Path Manager Object was instantiated, close it.
            if (featureClassPathManager != null)
            {
              featureClassPathManager = null;
            }

              }
        }