示例#1
0
        public static ITable OpenTable(string string_0)
        {
            ITable table;
            string string0;
            string str;
            object obj;
            object obj1;

            try
            {
                if (!AppConfigInfo.m_Init)
                {
                    AppConfigInfo.m_pFeatureWorkspace = AppConfigInfo.GetWorkspace() as IFeatureWorkspace;
                    if (AppConfigInfo.m_pFeatureWorkspace != null)
                    {
                        AppConfigInfo.m_Init = true;
                    }
                }
                if (AppConfigInfo.m_pFeatureWorkspace != null)
                {
                    string0 = string_0;
                    if ((AppConfigInfo.m_pFeatureWorkspace as IWorkspace).Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
                    {
                        str = "";
                        try
                        {
                            object property = (AppConfigInfo.m_pFeatureWorkspace as IWorkspace).ConnectionProperties.GetProperty("VERSION");
                            str = property.ToString();
                            string[] strArrays = str.Split(new char[] { '.' });
                            str = ((int)strArrays.Length <= 1 ? "" : strArrays[0]);
                        }
                        catch (Exception exception)
                        {
                        }
                        if (AppConfigInfo.m_pFeatureWorkspace is ISQLSyntax)
                        {
                            string0 = (AppConfigInfo.m_pFeatureWorkspace as ISQLSyntax).QualifyTableName(AppConfigInfo.SDEDatabase, str, string_0);
                        }
                    }
                    table = AppConfigInfo.m_pFeatureWorkspace.OpenTable(string0);
                    return(table);
                }
                else
                {
                    table = null;
                    return(table);
                }
            }
            catch (Exception exception1)
            {
                CErrorLog.writeErrorLog(null, exception1, "");
            }
            try
            {
                string0 = string_0;
                if ((AppConfigInfo.m_pFeatureWorkspace as IWorkspace).Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
                {
                    str = "DBO";
                    if (AppConfigInfo.m_pFeatureWorkspace is ISQLSyntax)
                    {
                        string0 = (AppConfigInfo.m_pFeatureWorkspace as ISQLSyntax).QualifyTableName(AppConfigInfo.SDEDatabase, str, string_0);
                    }
                }
                (AppConfigInfo.m_pFeatureWorkspace as IWorkspace).ConnectionProperties.GetAllProperties(out obj, out obj1);
                table = AppConfigInfo.m_pFeatureWorkspace.OpenTable(string0);
                return(table);
            }
            catch (Exception exception2)
            {
                CErrorLog.writeErrorLog(null, exception2, "");
            }
            table = null;
            return(table);
        }
示例#2
0
        public static IWorkspace GetWorkspace()
        {
            IWorkspaceFactory sdeWorkspaceFactoryClass;
            IWorkspace        mPWorkspace;
            Exception         exception;

            if (!AppConfigInfo.m_IsCreate)
            {
                AppConfigInfo.m_IsCreate = true;
                string upper = AppConfigInfo.dbclient.ToUpper();
                if (!(upper == "SQLSERVER" ? false : !(upper == "ORACLE")))
                {
                    sdeWorkspaceFactoryClass = new SdeWorkspaceFactoryClass();
                    try
                    {
                        IPropertySet propertySet = AppConfigInfo.CreateSdePropertySet();
                        if (propertySet != null)
                        {
                            AppConfigInfo.m_pWorkspace = sdeWorkspaceFactoryClass.Open(propertySet, 0);
                        }
                        else
                        {
                            mPWorkspace = null;
                            return(mPWorkspace);
                        }
                    }
                    catch (Exception exception1)
                    {
                        exception = exception1;
                        CErrorLog.writeErrorLog(null, exception, "");
                    }
                }
                else if (upper != "MDB")
                {
                    try
                    {
                        if ((AppConfigInfo.m_LayerConfigDB.Length <= 0 ? false : File.Exists(AppConfigInfo.m_LayerConfigDB)))
                        {
                            sdeWorkspaceFactoryClass   = new FileGDBWorkspaceFactoryClass();
                            AppConfigInfo.m_pWorkspace = sdeWorkspaceFactoryClass.OpenFromFile(AppConfigInfo.m_LayerConfigDB, 0);
                        }
                    }
                    catch (Exception exception2)
                    {
                        exception = exception2;
                        MessageBox.Show(exception.Message);
                        CErrorLog.writeErrorLog(null, exception, "");
                    }
                }
                else
                {
                    try
                    {
                        if ((AppConfigInfo.m_LayerConfigDB.Length <= 0 ? false : File.Exists(AppConfigInfo.m_LayerConfigDB)))
                        {
                            sdeWorkspaceFactoryClass   = new AccessWorkspaceFactoryClass();
                            AppConfigInfo.m_pWorkspace = sdeWorkspaceFactoryClass.OpenFromFile(AppConfigInfo.m_LayerConfigDB, 0);
                        }
                    }
                    catch (Exception exception3)
                    {
                        exception = exception3;
                        MessageBox.Show(exception.Message);
                        CErrorLog.writeErrorLog(null, exception, "");
                    }
                }
            }
            mPWorkspace = AppConfigInfo.m_pWorkspace;
            return(mPWorkspace);
        }