Ejemplo n.º 1
0
        IWorkspace ISdeConnectionInfo.CreateSdeWorkspace()
        {
            if (_sdeUser != null)
            {
                try
                {
                    //MessageBox.Show(string.Format("line 90 SdeConnection:sde service:{0}", _sdeUser.Sde_service));
                    UtilitiesBox.StartService(_sdeUser.Sde_service, 5000);
                    //UtilitiesBox.StartService("MSSQLSERVER", 3000);
                    WorkspaceManagement wspm = new WorkspaceManagement();
                    //_workspace = wspm.CreateWorkspaceSDE(_sdeUser.ServerSde, _sdeUser.Instance, _sdeUser.Db, _sdeUser.Version, _sdeUser.UserName, _sdeUser.Pass);
                    //_environment = String.Format("Database Connections/Connection to {0}.sde", _sdeUser.ServerSde);
                    string path=TnSystemTempPath.ConnectionFilePath;
                    try
                    {
                        if (System.IO.File.Exists("c:/tn/temp/tn.sde"))
                        {
                            System.IO.File.Delete("c:/tn/temp/tn.sde");
                        }
                    }
                    catch { }

                    _workspaceName = wspm.CreateConnectionFile(_sdeUser.Server, _sdeUser.Instance, _sdeUser.UserName, _sdeUser.Pass, _sdeUser.Db, _sdeUser.Version, "c:/tn/temp/","tn.sde");
                    _environment = "c:/tn/temp/tn.sde";
                    _workspace = (IWorkspace)((IName)_workspaceName).Open();

                    //MessageBox.Show("line 100 SdeConnection, path=" + _workspaceName.PathName);
                    return _workspace;

                }
                catch (Exception ex) { MessageBox.Show(ex.ToString()); }
                return _workspace;
            }
            return null;
        }
Ejemplo n.º 2
0
        IWorkspace ISdeConnectionInfo.CreateSdeWorkspace(ISdeUserInfo sdeUserInfo)
        {
            try
            {
                UtilitiesBox.StartService(sdeUserInfo.Sde_service, 3000);
                //UtilitiesBox.StartService("MSSQLSERVER", 3000);
                WorkspaceManagement wspm = new WorkspaceManagement();
                _workspace = wspm.CreateWorkspaceSDE(sdeUserInfo.ServerSde, sdeUserInfo.Instance, sdeUserInfo.Db, sdeUserInfo.Version, sdeUserInfo.UserName, sdeUserInfo.Pass);
                _environment = String.Format("Database Connections/Connection to {0}.sde", sdeUserInfo.ServerSde);
                _workspaceName = wspm.CreateConnectionFile(sdeUserInfo.Server, sdeUserInfo.Instance, sdeUserInfo.UserName, sdeUserInfo.Pass, sdeUserInfo.Db, sdeUserInfo.Version,TnSystemTempPath.ConnectionFileFullPath);
                //MessageBox.Show("line 44 SdeConnection, path=" + _workspaceName.PathName);
                return _workspace;
                //IWorkspace wsp = wspm.CreateWorkspaceSDE("froxtal-pc", "5152", "sde", "sde.DEFAULT", "sde", "arcsde");
                //if (wsp != null)
                //{
                //    TnConnectionInfo.CallMe.SetSDEWorkspace(wsp);
                //    _connectionOk = true;
                //}
                //else
                //{
                //    _connectionOk = false;
                //}

            }
            catch (Exception ex) { MessageBox.Show(ex.ToString());}

            return _workspace;
        }