/// <summary>
        /// Attempts to open a given table
        /// </summary>
        /// <param name="tablename">The unqualified name of the table to be opened.
        /// The table name will be qualfied within this function</param>
        /// <returns>A reference to the ITable</returns>
        public ITable FindTable(String name)
        {
            if (name == null || 1 > name.Length)
            {
                _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "FindTable", "Name not set.");
                throw new ArgumentException("table name not specified");
            }

            if (_currentWorkspace == null)
            {
                _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "FindTable", "Current workspace not set.");
                throw new Exception("Telecom workspace is not set.");
            }

            // Dictionary cached lookup
            ITable value = null;

            if (_tables.ContainsKey(name))
            {
                value = _tables[name];
            }
            else
            {
                // get qualified name from connection properties.
                ISQLSyntax sqlsyntax     = _currentWorkspace as ISQLSyntax;
                string     qualifiedName = sqlsyntax.QualifyTableName(_dbName, _ownerName, name);
                value = _currentWorkspace.OpenTable(qualifiedName);

                // Store the ITable ref in the cache.
                _tables.Add(name, value);
            }
            return(value);
        }
        public static string QualifyClassName(IWorkspace theWorkspace, string givenClassName)
        {
            if (theWorkspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
            {
                string dbName = ((IDataset)theWorkspace).Name;

                // ------- TROUBLE ---------
                // I don't know how to handle situations where the owner is not DBO.
                // ------- TROUBLE ---------
                string owner = "DBO";

                ISQLSyntax Qualifier = (ISQLSyntax)theWorkspace;
                return(Qualifier.QualifyTableName(dbName, owner, givenClassName));
            }
            else
            {
                return(givenClassName);
            }
        }
Example #3
0
        private bool method_0(string string_0, IWorkspaceReplicas iworkspaceReplicas_0)
        {
            ISQLSyntax   syntax   = iworkspaceReplicas_0 as ISQLSyntax;
            IEnumReplica replicas = iworkspaceReplicas_0.Replicas;

            replicas.Reset();
            for (IReplica replica2 = replicas.Next(); replica2 != null; replica2 = replicas.Next())
            {
                if (replica2.ReplicaRole == esriReplicaType.esriCheckOutTypeParent)
                {
                    string str = syntax.QualifyTableName("", replica2.Owner, replica2.Version);
                    if (string_0.ToLower() == str.ToLower())
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        protected bool InWorkspace(IWorkspace2 wksp2, esriDatasetType type, String name)
        {
            ISQLSyntax sqlSyntax = (ISQLSyntax)wksp2;
            String     fqname    = sqlSyntax.QualifyTableName(_dbName, _ownerName, name);

            bool       result    = true;
            IWorkspace workspace = wksp2 as IWorkspace;

            if (wksp2.get_NameExists(type, fqname))
            {
                _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", "Exists check: " + fqname, "PASS");
            }
            else
            {
                _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Exists check: " + fqname, "FAIL");
                return(false);
            }

            return(result);
        }
Example #5
0
        public static ITable OpenTable(string TableName)
        {
            string tableName;
            ITable table;

            if (CommonClass.m_pWorkspace == null)
            {
                CommonClass.m_pWorkspace = AppConfigInfo.GetWorkspace();
            }
            if (CommonClass.m_pWorkspace != null)
            {
                object item = CommonClass.m_hash[TableName];
                if (item != null)
                {
                    table = item as ITable;
                }
                else
                {
                    if (TableName.IndexOf(".") != -1)
                    {
                        tableName = TableName;
                    }
                    else
                    {
                        ISQLSyntax workspace = CommonClass.Workspace as ISQLSyntax;
                        tableName = workspace.QualifyTableName(CommonClass.Database, CommonClass.User, TableName);
                    }
                    ITable table1 = (CommonClass.m_pWorkspace as IFeatureWorkspace).OpenTable(tableName);
                    CommonClass.m_hash[TableName] = table1;
                    table = table1;
                }
            }
            else
            {
                table = null;
            }
            return(table);
        }