hsghxm
路人甲
路人甲
  • 注册日期2004-10-27
  • 发帖数517
  • QQ4604052
  • 铜币1枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:2603回复:5

SDE编辑版本给用户锁定了,如何解锁。。。

楼主#
更多 发布于:2006-08-14 13:33
数据库SDE建立了N个版本,给某一版本下的用户锁住了,该用户就无法再次进行编辑,目前本人知道除了重新启动SDE服务或杀死该用户版本进程可解锁!可是很麻烦,得手动操作!请问大家在程序代码中有没有办法在该用户登陆时进行控制,使该版本解锁?AO中有这样的接口吗?<img src="images/post/smile/dvbbs/em12.gif" />
喜欢0 评分0
MSN:hsghxm@163.com QQ:4604052 (很少用,最好别加) Email:hsghxm@163.com 我的BOLG:http://www.gisempire.com/blog/user1/864/index.htm
hsghxm
路人甲
路人甲
  • 注册日期2004-10-27
  • 发帖数517
  • QQ4604052
  • 铜币1枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2006-08-14 13:33
<P>先抢个沙发,望高手指点一二。。。。</P><img src="images/post/smile/dvbbs/em02.gif" />
MSN:hsghxm@163.com QQ:4604052 (很少用,最好别加) Email:hsghxm@163.com 我的BOLG:http://www.gisempire.com/blog/user1/864/index.htm
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15947
  • QQ554730525
  • 铜币25339枚
  • 威望15364点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
2楼#
发布于:2006-08-15 14:02
<P>使用sde api来操作</P>
<P>  HowT  Access the SDE C API from Visual Basic
<TABLE>

<TR>
<TH vAlign=top>Article ID:</TH>
<TD vAlign=top>20120</TD></TR>
<TR>
<TH vAlign=top>Software:</TH>
<TD vAlign=top> <B>ArcSDE</B> 3.0, 3.0.1, 3.0.2, 3.0.2.1, 3.0.2.2 <B>MapObjects-Windows</B> 2.0, 2.0a, 2.1, 2.2, 2.3</TD></TR>
<TR>
<TH vAlign=top>Platforms:</TH>
<TD vAlign=top>N/A</TD></TR></TABLE></P>
<H4>Summary</H4>
<DIV>For those of you who use or want to use Visual Basic to access SDE C API but have come acroos a problem passing pointers to arrays of SDE structures. <BR><BR>This is especially useful for those who want to use MapObjects2 and SDE together. As most MO applications are written in VB, the potential for MO2 and SDE increases. The following Visual Basic code demonstrates how to get around the problem of calling SDE functions that return a list (array) of SDE structures. <BR><BR></DIV>
<P><BR> </P>
<H4>Procedure</H4>
<DIV>This example shows you how to get the SE_INSTANCE_LOCK details from a call to SE_instance_get_locks. You should be able to apply the same idea to whatever you need to implement.<BR><BR>
<DIV>
<P>Notes on the following sample: <BR>-The code uses the Win API function "CopyMemory". <BR>Refer to MSDN for details on this function <BR>-Where the SDE function calls parameters expect a pointer expect a <BR>pointer to an array of SE_INSTANCE_LOCK, we have defined it as <BR>LONG, i.e. the address of the first element of the expected array. <BR>-Use the Visual Basic function LenB (variable_name) to get the accurate <BR>length, in bytes, of the structure you want to use. See MSDN for more <BR>information. This length is used to increment the base address of the array <BR>to access each subsequent element in the array. <BR>-Save the initial address of your array to another variable; <BR>this is used to free the array later. <BR>-The code was written on Windows NT Service pack 4.0, <BR>Visual Studio 6.x with Service Pack 3, using SDE 3.0.2.1 for Oracle 7.2. <BR><BR>To run this VB sample, you will need a Form with MapObjects 2.x loaded, a Command button, and thr3ee Text boxes. You need to edit the code so it represents your specific SDE server, instance, username and password. If you're not using MapObjects 2.x, then just connect to SDE as normal Set up some instance locas and try it out! <BR><BR><BR></P>
<DIV #cccccc 2px solid; PADDING-RIGHT: 0.5em; BORDER-TOP: #cccccc 2px solid; PADDING-LEFT: 0.5em; PADDING-BOTTOM: 0.5em; BORDER-LEFT: #cccccc 2px solid; WIDTH: 500px; PADDING-TOP: 0.5em; BORDER-BOTTOM: #cccccc 2px solid; FONT-FAMILY: courier; BACKGROUND-COLOR: whitesmoke"><PRE 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">Option Explicit
<BR>
<BR>' Using MO2 to connect to SDE but you don't need to!
<BR>
<BR>Dim dc As New MapObjects2.DataConnection
<BR>
<BR>'note that the parameters are both long - passing the address of thefirst element of the array
<BR>
<BR>Private Declare Function SE_instance_free_locks Lib "sde30" (ByReflock_list_address As Long, ByVal lock_count As Long) As Long
<BR>
<BR>Private Declare Function SE_instance_get_locks Lib "sde30" (ByVal serverAs String, ByVal instance As String, ByRef address_to_array_of_lock_list_addr As Long, ByRef lock_count_addr AsLong) As Long
<BR>
<BR>'use this Win API call to access the memory for each element in the list array
<BR>Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal length As Long)
<BR>' my definition of SE_INSTANCE_LOCK structure
<BR>Private Type SE_INSTANCE_LOCK
<BR>pid As Long
<BR>layer_id As Integer
<BR>lock_type As Long
<BR>End Type
<BR>
<BR>Private Sub Command1_Click()
<BR>Dim status As Long 'set by SDE
<BR>Dim lock_list_addr As Long 'set by SDE API call
<BR>Dim sde_lock_count As Long 'set by SDE API call
<BR>Dim lock_list_addr_save As Long 'needed to free the list array later
<BR>Dim m_lockCount As Integer 'loop iterator
<BR>
<BR>'get the locks from SDE
<BR>status = SE_instance_get_locks("drfinlay", "esri_sde", lock_list_addr, sde_lock_count)
<BR>' Report the status, list array address and number of locks
<BR>Text1.Text = "SDE Error status: " ; Str(status)
<BR>Text2.Text = "Lock List Address: " ; Str(lock_list_addr)
<BR>Text3.Text = "Lock Count: " ; Str(sde_lock_count)
<BR>
<BR>
<BR>' save the list address
<BR>lock_list_addr_save = lock_list_addr
<BR>
<BR>' declare an array of 200 (max) SE_INSTANCE_LOCK structures
<BR>Dim myLocks(200) As SE_INSTANCE_LOCK
<BR>
<BR>' declare an instance of a single lock - used to get the size in Bytes of the structure
<BR>Dim aLock As SE_INSTANCE_LOCK
<BR>
<BR>' iterate through all the locks
<BR>For m_lockCount = 0 To sde_lock_count - 1
<BR>
<BR>' copy memory from the list array address into myLocks(n), using the length in Bytes
<BR>' of a single SE_INSTANCE_LOCK
<BR>CopyMemory myLocks(m_lockCount), ByVal lock_list_addr,LenB(aLock)
<BR>
<BR>' Report the details of the nth element of myLocks
<BR>MsgBox "Layer ID : " ; vbTab ; Str(myLocks(m_lockCount).layer_id) ; vbNewLine ; _
<BR>"Lock Type: " ; vbTab ; Str(myLocks(m_lockCount).lock_type) ; vbNewLine ; _
<BR>"Pid: " ; vbTab ; vbTab ; Str(myLocks(m_lockCount).pid), vbDefaultButton1, "SDE Lock Details"
<BR>
<BR>'increment the lock list array address by the length of a SE_INSTANCE_LOCK structure
<BR>lock_list_addr = lock_list_addr + LenB(aLock)
<BR>
<BR>Next m_lockCount
<BR>
<BR>' free the instance locks list array - using the previously saved address
<BR>status = SE_instance_free_locks(lock_list_addr_save, sde_lock_count)
<BR>
<BR>End Sub
<BR>
<BR>Private Sub Form_Load()
<BR>Command1.Caption = "Get all SDE locks"
<BR>Text1.Text = ""
<BR>Text2.Text = ""
<BR>Text3.Text = ""
<BR>Form1.Caption = "SDE Instance Locks example"
<BR>
<BR>' set up MapObjects SDE connection dc.server = "drfinlay"
<BR>dc.User = "sde_user"
<BR>dc.Password = "sde_user"
<BR>dc.Database = "esri_sde"
<BR>dc.Connect
<BR>
<BR>End Sub </PRE></DIV><BR><BR></DIV></DIV>
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15947
  • QQ554730525
  • 铜币25339枚
  • 威望15364点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
3楼#
发布于:2006-08-15 14:04
<P>另外从技术支持那里看到的一个方法</P>
<P>To kill all the SDE sessions <BR><BR>1. create another adodb connection in vb , this time connecting as the system user <BR>2. run this sql query -- you need to do this for all the spatial users (some may not be user SDE) <BR><BR>select SID,SERIAL# from v$session WHERE USERNAME= 'SDE' <BR><BR>grab the results then in your vb program run these sql statements on the database as system <BR><BR>alter system kill session SID,SERIAL# <BR><BR>where SID and SERIAL# have the values from the 1st query. <BR><BR><BR>below is a PL/SQL procedure that would disconnect all users to the database that have connected to the SDe database using arcmap <BR><BR>DECLARE <BR>l_cursor INTEGER; <BR>l_exec_result INTEGER; <BR>-- <BR>BEGIN <BR>FOR l_session_rec IN (SELECT sid, serial# FROM v$session WHERE program = 'ArcMap.exe') <BR>LOOP <BR>l_cursor := DBMS_SQL.Open_Cursor; <BR>DBMS_SQL.Parse (l_cursor, 'ALTER SYSTEM KILL SESSION ''' || l_session_rec.sid || ',' || l_session_rec.serial# || '''', DBMS_SQL.native); <BR>l_exec_result := DBMS_SQL.Execute (l_cursor); <BR>DBMS_SQL.Close_Cursor (l_cursor); <BR>END LOOP; <BR>END; <BR><BR><BR></P>
举报 回复(0) 喜欢(0)     评分
hsghxm
路人甲
路人甲
  • 注册日期2004-10-27
  • 发帖数517
  • QQ4604052
  • 铜币1枚
  • 威望0点
  • 贡献值0点
  • 银元0个
4楼#
发布于:2006-08-16 09:08
先谢谢猪头总统,然后再慢慢研究...<img src="images/post/smile/dvbbs/em04.gif" />
MSN:hsghxm@163.com QQ:4604052 (很少用,最好别加) Email:hsghxm@163.com 我的BOLG:http://www.gisempire.com/blog/user1/864/index.htm
举报 回复(0) 喜欢(0)     评分
GIS_ADMIN
路人甲
路人甲
  • 注册日期2005-05-29
  • 发帖数43
  • QQ
  • 铜币243枚
  • 威望0点
  • 贡献值0点
  • 银元0个
5楼#
发布于:2006-08-17 12:46
谢谢了,好好学习一下
举报 回复(0) 喜欢(0)     评分
游客

返回顶部