<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Форум компьютерной помощи &mdash; Установка связей между документами]]></title>
	<link rel="self" href="https://itpmr.ru/extern.php?action=feed&amp;tid=831&amp;type=atom" />
	<updated>2014-01-30T09:38:34Z</updated>
	<generator>PunBB</generator>
	<id>https://itpmr.ru/viewtopic.php?id=831</id>
		<entry>
			<title type="html"><![CDATA[Re: Установка связей между документами]]></title>
			<link rel="alternate" href="https://itpmr.ru/viewtopic.php?pid=124089#p124089" />
			<content type="html"><![CDATA[<p>Links_Paste - Агент для связей(обновляет связываемые документы).</p><p>Function GetUnidFromUrl(url$)<br />&nbsp; &nbsp; &#039; получить Unid док-та по урлу<br />&nbsp; &nbsp; GetUnidFromUrl=Mid(url,Instr(url,&quot;?&quot;)-32,32)<br />End Function</p><br /><p>Sub Initialize<br />&nbsp; &nbsp; Dim ns As NotesSession&nbsp; &nbsp; <br />&nbsp; &nbsp; Dim db As NotesDatabase&nbsp; &nbsp; <br />&nbsp; &nbsp; Dim doc1 As NotesDocument<br />&nbsp; &nbsp; Dim curdoc As NotesDocument&nbsp; &nbsp; <br />&nbsp; &nbsp; Dim item As NotesItem<br />&nbsp; &nbsp; Dim agent As NotesAgent&nbsp; &nbsp; <br />&nbsp; &nbsp; Dim url_link_doc As String<br />&nbsp; &nbsp; Dim url_cur_doc As String<br />&nbsp; &nbsp; Set ns = New NotesSession&nbsp; &nbsp; <br />&nbsp; &nbsp; Set db = ns.CurrentDatabase&nbsp; &nbsp; <br />&nbsp; &nbsp; Set agent = ns.CurrentAgent&nbsp; &nbsp; <br />&nbsp; &nbsp; <br />&nbsp; &nbsp; &#039;Получаем параметр, передаваемый в агент, то есть получаем Noteid<br />&nbsp; &nbsp; NoteId = agent.ParameterDocID&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp;&#039;Получаем документ&nbsp; &nbsp; <br />&nbsp; &nbsp; Set doc1 = db.GetDocumentById(NoteId)&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp;&#039;Получаем url linkdoc-a &nbsp; &nbsp; <br />&nbsp; &nbsp; Set item = doc1.GetFirstItem(&quot;Field_linkdoc_url&quot;)<br />&nbsp; &nbsp; If (item Is Nothing) Then<br />&nbsp; &nbsp; &nbsp; &nbsp; Print &quot;Field_linkdoc_url не найдено!&quot;<br />&nbsp; &nbsp; Else<br />&nbsp; &nbsp; &nbsp; &nbsp; url_link_doc=item.Text<br />&nbsp; &nbsp; End If<br />&nbsp; &nbsp; &#039;Получаем url curdoc-a &nbsp; &nbsp; <br />&nbsp; &nbsp; Set item= doc1.GetFirstItem (&quot;Field_curdoc_url&quot;)<br />&nbsp; &nbsp; If (item Is Nothing) Then<br />&nbsp; &nbsp; &nbsp; &nbsp; Print &quot;Field_curdoc_url не найдено!&quot;<br />&nbsp; &nbsp; Else<br />&nbsp; &nbsp; &nbsp; &nbsp; url_cur_doc=item.Text<br />&nbsp; &nbsp; End If<br />&nbsp; &nbsp; &#039;--------------------сохранение связи в связуемом документе----------------------------------------<br />&nbsp; &nbsp; Dim ldb As New notesdatabase(&quot;&quot;,&quot;&quot;)<br />&nbsp; &nbsp; Dim linkdoc As&nbsp; NotesDocument<br />&nbsp; &nbsp; &#039;If ns.CurrentDatabase.ReplicaID&lt;&gt;GetReplFromUrl(url) Then<br />&nbsp; &nbsp; &#039;&nbsp; &nbsp; Call ldb.OpenByReplicaID(ns.CurrentDatabase.Server,GetReplFromUrl(url))<br />&nbsp; &nbsp; &#039;Else&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; Set ldb=ns.CurrentDatabase<br />&nbsp; &nbsp; &#039;End If<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; Set linkdoc=ldb.GetDocumentByUNID(GetUnidFromUrl(url_link_doc))<br />&nbsp; &nbsp; Print&quot;url &quot; + Cstr(url_link_doc)<br />&nbsp; &nbsp; Call linkdoc.ReplaceItemValue(&quot;Linked_From&quot;,Fulltrim(Arrayunique(Arrayappend(linkdoc.Linked_From,url_cur_doc))))<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; On Error Goto err1<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; Call linkdoc.Save(1,0)<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; Set curdoc=db.GetDocumentByUNID(GetUnidFromUrl(url_cur_doc))<br />&nbsp; &nbsp; Call curdoc.ReplaceItemValue(&quot;Linked_To&quot;,Fulltrim(Arrayunique(Arrayappend(curdoc.Linked_To,url_link_doc))))<br />&nbsp; &nbsp; Call curdoc.Save(1,0)<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; &#039;Удаляем док-запрос<br />&nbsp; &nbsp; Call doc1.Remove(True)<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; Print &quot;СВЯЗЬ УСТАНОВЛЕНА!&quot;<br />&nbsp; &nbsp; Exit Sub<br />err1:&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; Messagebox &quot;Связь не установлена! Проблемма безопасности!&quot;,0+48,&quot;Связи!&quot;<br />&nbsp; &nbsp; Exit Sub<br />End Sub</p>]]></content>
			<author>
				<name><![CDATA[admin]]></name>
				<uri>https://itpmr.ru/profile.php?id=2</uri>
			</author>
			<updated>2014-01-30T09:38:34Z</updated>
			<id>https://itpmr.ru/viewtopic.php?pid=124089#p124089</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Установка связей между документами]]></title>
			<link rel="alternate" href="https://itpmr.ru/viewtopic.php?pid=124088#p124088" />
			<content type="html"><![CDATA[<p>Вставить связь:</p><p>Sub Click(Source As Button)<br />&nbsp; &nbsp; On Error Goto Errh<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; Dim ns As New NotesSession&nbsp; &nbsp; <br />&nbsp; &nbsp; Dim db As NotesDatabase&nbsp; &nbsp; <br />&nbsp; &nbsp; Dim agent As NotesAgent&nbsp; &nbsp; <br />&nbsp; &nbsp; Dim docRequest As NotesDocument&nbsp; &#039;Новый документ запрос<br />&nbsp; &nbsp; Dim linkdoc As NotesDocument&nbsp; &#039;Док из которого копируем связь<br />&nbsp; &nbsp; Dim curdoc As NotesDocument &#039;Текущий(куда копируем связь)док<br />&nbsp; &nbsp; Dim Unid As String<br />&nbsp; &nbsp; Dim Unid1 As String<br />&nbsp; &nbsp; Dim uilinkdoc As NotesUIDocument<br />&nbsp; &nbsp; Dim uicurdoc As NotesUIDocument&nbsp; &nbsp;<br />&nbsp; &nbsp; Dim paramid As String <br />&nbsp; &nbsp; Dim nw As New NotesUIworkspace<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; Set uicurdoc=nw.CurrentDocument<br />&nbsp; &nbsp; Set curdoc=uicurdoc.Document<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; If uicurdoc.EditMode&nbsp; &nbsp; Then<br />&nbsp; &nbsp; &nbsp; &nbsp; uicurdoc.Save<br />&nbsp; &nbsp; End If<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; Set db = ns.CurrentDatabase&nbsp; &nbsp; <br />&nbsp; &nbsp; &#039;Set curdoc=nw.CurrentDocument.Document<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; &#039;Читаем переменную окружения и выделяем из нее Url(link_doc)&nbsp; <br />&nbsp; &nbsp; Dim url As String<br />&nbsp; &nbsp; url=ns.GetEnvironmentString(&quot;_url&quot;)<br />&nbsp; &nbsp; Unid=GetUnidFromUrl(url)<br />&nbsp; &nbsp; Unid1=GetUnidFromUrl(curdoc.NotesURL)<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; &#039;Создаем новый док(док-запрос) и записываем в него url дока(linkdoca) из которого копируем связь и url дока(текущего) куда вставляем связь<br />&nbsp; &nbsp; Set docRequest = db.CreateDocument &nbsp; &nbsp; <br />&nbsp; &nbsp; Set item = docRequest.AppendItemValue(&quot;Field_linkdoc_url&quot;, url)<br />&nbsp; &nbsp; Set item = docRequest.AppendItemValue(&quot;Field_curdoc_url&quot;, curdoc.NotesURL)<br />&nbsp; &nbsp; Call docRequest.save(True, False)<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; &#039;Получаем агента(серверного с правами менеджера), передаем ему параметр(Noteid дока-запроса,и запускаем агент)<br />&nbsp; &nbsp; Set agent = db.GetAgent(&quot;Links_Paste&quot;)<br />&nbsp; &nbsp; paramid = docRequest.Noteid<br />&nbsp; &nbsp; Call Agent.RunOnServer(paramid)<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; &#039;&#039;<br />&nbsp; &nbsp; REM Необходимо обновить два дока: <br />&nbsp; &nbsp; &nbsp;REM Закрываем текущий, получаем предыдущий, закрываем предыдущий, открываем предыдущий на просмотр<br />&nbsp; &nbsp; &nbsp;REM получаем текущий и окрываем на просмотр<br />&nbsp; &nbsp; &#039;В переменную paramid записываем параметр Noteid текущего документа, стираем его из памяти и закрываем <br />&nbsp; &nbsp; &#039;paramid = curdoc.Noteid<br />&nbsp; &nbsp; paramid = curdoc.UniversalID<br />&nbsp; &nbsp; Delete curdoc<br />&nbsp; &nbsp; Call uicurdoc.Close(True)<br />&nbsp; &nbsp; &#039;&#039;&#039;Call nw.CurrentDocument.Close(True)&nbsp; &nbsp; <br />&nbsp; &nbsp; &#039;&#039;<br />&nbsp; &nbsp; &#039;Получаем linkdoc, проверяем если он открыт в UI устанавливаем его текущим и закрываем<br />&nbsp; &nbsp; Set linkdoc = db.GetDocumentByUNID (Unid)<br />&nbsp; &nbsp; If linkdoc.IsUIDocOpen Then<br />&nbsp; &nbsp; &nbsp; &nbsp; Call nw.SetTargetFrame(&quot;&quot;)<br />&nbsp; &nbsp; &nbsp; &nbsp; Set uilinkdoc = nw.EditDocument(False, linkdoc, False,,False,False) <br />&nbsp; &nbsp; &nbsp; &nbsp; Delete linkdoc<br />&nbsp; &nbsp; &nbsp; &nbsp; Call uilinkdoc.Close(True)<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;Delete linkdoc<br />&nbsp; &nbsp; &#039;End If<br />&nbsp; &nbsp; &#039;Проверяем если linkdoc открыт в UI, стираем его из памяти, получаем его, окрываем на просмотр<br />&nbsp; &nbsp; &#039;If linkdoc.IsUIDocOpen Then&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;Delete linkdoc<br />&nbsp; &nbsp; &nbsp; &nbsp; Set linkdoc = db.GetDocumentByUNID (Unid)<br />&nbsp; &nbsp; &nbsp; &nbsp; Set uilinkdoc = nw.EditDocument(False, linkdoc) <br />&nbsp; &nbsp; End If<br />&nbsp; &nbsp; &#039;Получаем Текущий док и открывает его на просмотр<br />&nbsp; &nbsp; &#039;Set curdoc = db.GetDocumentById(paramid)<br />&nbsp; &nbsp; Set curdoc = db.GetDocumentByUNID(paramid)<br />&nbsp; &nbsp; Set uicurdoc = nw.EditDocument(False, curdoc) <br />&nbsp; &nbsp; &nbsp;&#039;&#039;<br />&nbsp; &nbsp; Exit Sub<br />errh:<br />&nbsp; &nbsp; Msgbox Error &amp; | in line | &amp; Erl(), 64, |Lotus Notes (| &amp; Lsi_info(2) &amp; |)|<br />&nbsp; &nbsp; Exit Sub<br />End Sub</p>]]></content>
			<author>
				<name><![CDATA[admin]]></name>
				<uri>https://itpmr.ru/profile.php?id=2</uri>
			</author>
			<updated>2014-01-30T09:34:01Z</updated>
			<id>https://itpmr.ru/viewtopic.php?pid=124088#p124088</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Установка связей между документами]]></title>
			<link rel="alternate" href="https://itpmr.ru/viewtopic.php?pid=124087#p124087" />
			<content type="html"><![CDATA[<p>Установка связей между документами </p><p>Копировать связь:</p><p>Sub Click(Source As Button)<br />&nbsp; &nbsp; Dim nw As New NotesUIworkspace<br />&nbsp; &nbsp; Dim ns As New NotesSession<br />&nbsp; &nbsp; Dim nd As NotesDocument<br />&nbsp; &nbsp; Dim uind As NotesUIDocument<br />&nbsp; &nbsp; Set nd=nw.CurrentDocument.Document<br />&nbsp; &nbsp; Set uind=nw.CurrentDocument<br />&nbsp; &nbsp; &#039;<br />&nbsp; &nbsp; If uind.IsNewDoc Then<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; flag=Messagebox (&quot;Документ, с которого выкопируете связь не сохранен!Сохранить документ?&quot;+Chr(13) +&quot;При нажатии на кнопку&nbsp; Отмена связь не будет скопирована!!!&quot;,1+64+0+0, &quot;Сообщение...&quot;)<br />&nbsp; &nbsp; &nbsp; &nbsp; Const IDCancel=2<br />&nbsp; &nbsp; &nbsp; &nbsp; If flag=IDCancel Then<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit Sub&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; Else<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;Call nd.Save(True,False) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Call uind.Save<br />&nbsp; &nbsp; &nbsp; &nbsp; End If<br />&nbsp; &nbsp; End If<br />&#039;<br />&nbsp; &nbsp; Call ns.SetEnvironmentVar(&quot;_url&quot;,nd.NotesURL)<br />&nbsp; &nbsp; Print &quot;СВЯЗЬ СКОПИРОВАНА!&quot;<br />End Sub</p>]]></content>
			<author>
				<name><![CDATA[admin]]></name>
				<uri>https://itpmr.ru/profile.php?id=2</uri>
			</author>
			<updated>2014-01-30T09:33:13Z</updated>
			<id>https://itpmr.ru/viewtopic.php?pid=124087#p124087</id>
		</entry>
</feed>
