ラベル Notes の投稿を表示しています。 すべての投稿を表示
ラベル Notes の投稿を表示しています。 すべての投稿を表示

2014年9月1日月曜日

【Notes】プリビュー画面で編集を禁止方法

Querymodechangeに以下のソースを追加する。

If source.InPreviewPane Then
    continue = False
    Exit Sub
End If

2013年11月26日火曜日

【XPages】SSJSでのパラメータクエリ取得方法(その2)

パラメータ毎に取得する方法(その2)

context.getUrlParameter("paramName") ;

「paramName」は取得したいパラメータ名です。必要に応じて変更して下さい。

2013年11月7日木曜日

【XPages】日時ピッカーの初期値

日時ピッカーにて、「日付/時刻ピッカーポップアップを使用」にチェックを入れると、初期値で当日がセットされる。
セットしたく無いときは<xp:this.resources>に以下の構文を追加する。

<xp:script clientSide="true">
                       <xp:this.contents><![CDATA[
require([
       "dojo/_base/lang",
       "ibm/xsp/widget/layout/DateTextBox",
       "ibm/xsp/widget/layout/TimeTextBox",
       "ibm/xsp/widget/layout/DateTimeTextBox"
], function(lang, DateTextBox, TimeTextBox, DateTimeTextBox){
       var a = {};
       lang.mixin(a, {
               postCreate: function(){
                       this.inherited(arguments);
               }
       });
       DateTextBox.extend(a);
       TimeTextBox.extend(a);
       DateTimeTextBox.extend(a);
});
]]></xp:this.contents>
               </xp:script>

例:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
       <xp:this.resources>
               <xp:script clientSide="true">
                       <xp:this.contents><![CDATA[
require([
       "dojo/_base/lang",
       "ibm/xsp/widget/layout/DateTextBox",
       "ibm/xsp/widget/layout/TimeTextBox",
       "ibm/xsp/widget/layout/DateTimeTextBox"
], function(lang, DateTextBox, TimeTextBox, DateTimeTextBox){
       var a = {};
       lang.mixin(a, {
               postCreate: function(){
                       this.inherited(arguments);
               }
       });
       DateTextBox.extend(a);
       TimeTextBox.extend(a);
       DateTimeTextBox.extend(a);
});
]]></xp:this.contents>
               </xp:script>
       </xp:this.resources>

       <xp:inputText id="inputText1" value="#{sessionScope.inputText1}">
               <xp:this.converter>
                       <xp:convertDateTime type="date" />
               </xp:this.converter>
               <xp:dateTimeHelper />
       </xp:inputText>
</xp:view>

2013年10月25日金曜日

【XPages】SSJSでのパラメータクエリ取得方法

パラメータ毎に取得する方法

var exCon = facesContext.getExternalContext();
var request = exCon.getRequest();
var paramValue = request.getParameter("paramName");
return paramValue;

「paramName」は取得したいパラメータ名です。必要に応じて変更して下さい。

パラメータ全体を取得する方法


var externalContext=facesContext.getExternalContext();
var servletRequest=externalContext.getRequest();
var queryString=servletRequest.getQueryString();
return queryString

2013年10月19日土曜日

Notes9.0

会社でNotes9.0を導入することになりました。
この機会に一部のDBをXPagesしてみることにしました。
情報が少なくて、四苦八苦しています。
参考になったテクニックを備考録としてアップしていこうと思っています。

2012年1月19日木曜日

VB.NETからNotesDBの新規文書を作成する

自分の環境では「参照の追加」は不要ですが、環境によっては必要かもしれませんので、ご注意を。

        Dim session As Object
        Dim db As Object
        Dim doc As Object

        Dim strDominoServer As String
        Dim strDBName As String

        'NotesDB接続初期化
        ' ***NotesDBからの読み込み
        ' *** セッションの確立
        session = CreateObject("Notes.NotesSession")

        ' *** ノーツDBの取得
        db = session.GetDatabase(strDominoServer, strDBName)

        If (Not db.IsOpen()) Then
            ' *** エラーメッセージの表示
            MsgBox("データベースが見つかりませんでした", vbOKOnly + vbCritical)
            GoTo load_exit
        End If

        doc = db.CreateDocument

        doc.ReplaceItemValue("Form", "MainDoc")
        doc.ReplaceItemValue("Subject", “テスト”)

        Call doc.Save(True, True)

load_exit:
        ' *** オブジェクトの破棄
        db = Nothing
        session = Nothing

2012年1月5日木曜日

スクリプトによるNotesDBからCSV書き出し

「ファイル」-「書き出し」からでもCSV書き出しが出来ますが、スクリプトによるCSV書き出しのサンプルコードです。

Sub Click(Source As Button)
    Dim s As New NotesSession
    Dim db As NotesDatabase
    Dim view As NotesView
    Dim doc As NotesDocument
    Dim Code, Section, Name As Variant
    Dim FileName As String   
    Dim FileNum As Long
    Dim i As Integer

    Set db = s.CurrentDatabase
    Set view = db.GetView("EmployeeView")
    Set doc = view.GetFirstDocument

    FileName = "C:\Employee.CSV"
    FileNum = Freefile '空いている番号を取得する
    Open FileName For Output As #FileNum '書き込みモードで開く

    Do Until doc Is Nothing
        Code = doc.GetItemValue("Code")
        Section = doc.GetItemValue("Section")
        Name = doc.GetItemValue("Name")
        Print #FileNum , & _
        Code(0) & "," & _
        Section(0) & "," & _
        Name(0)
        Set doc = view.GetNextDocument(doc)
    Loop

    Close #FileNum 'ファイルを閉じる

End Sub

NotesDBのデータを直接Excelに書き出す

ビューをCSVに書き出す機能は標準で用意されていますが、以下のスクリプトを参考にすれば、直接Excelに書き出すことが出来ます。(当然のことですが、Excelがインストールされていないと使えません。)
以下のスクリプトはビューのボタンに配置したときのサンプルです。

Sub Click(Source As Button)
    Dim s As New NotesSession
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim doc As NotesDocument
    Dim view As NotesView
    Dim XLApp As Variant
    Dim XLBook As Variant
    Dim Code, Section, Name As Variant
    Dim x As Integer
    Set db = s.CurrentDatabase
    Set view = db.GetView("EmployeeView")
    Set doc = view.GetFirstDocument
    Set XLApp = createobject("Excel.Application")
    If ( XLApp Is Nothing ) Then
        Messagebox "Excelが見つかりません。
                             Excelが正しくインストールされていることを
                             確認してください。", MB_OK, "エラー"
        Exit Sub
    End If
    XLApp.Workbooks.add
    Set XLBook = XLApp.ActiveWorkbook
    XLApp.Visible=True
'見出し
    XLBook.Worksheets( 1 ).Cells( 1, 1 ).Value="社員コード"
    XLBook.Worksheets( 1 ).Cells( 1, 2 ).Value="部署"
    XLBook.Worksheets( 1 ).Cells( 1, 3 ).Value="氏名"
    x = 2
    Do Until doc Is Nothing
        Code = doc.GetItemValue("Code")
        Section = doc.GetItemValue("Section")
        Name = doc.GetItemValue("Name")
        XLBook.Worksheets( 1 ).Cells( x, 1 ).Value = Code(0)
        XLBook.Worksheets( 1 ).Cells( x, 2 ).Value = Section(0)
        XLBook.Worksheets( 1 ).Cells( x, 3 ).Value = Name(0)
        x = x + 1
        Set doc = view.GetNextDocument(doc)
    Loop
End Sub

2011年11月22日火曜日

VB.NETからNotesDBへアクセスするサンプルコード

自分の環境では「参照の追加」は不要ですが、環境によっては必要かもしれませんので、ご注意を。

        Dim session As Object
        Dim db As Object
        Dim view As Object
        Dim doc As Object

        Dim strDominoServer As String
        Dim strDBName As String
        Dim strViewName As String

        Dim NSubject As Object
        Dim strSubject As String

        ' ***NotesDBからの読み込み
        ' *** セッションの確立
        session = CreateObject("Notes.NotesSession")

        ' *** ノーツDBの取得
        db = session.GetDatabase(strDominoServer, strDBName)
        If (Not db.IsOpen()) Then
            ' *** エラーメッセージの表示
            MsgBox("データベースが見つかりませんでした", vbOKOnly + vbCritical)
            GoTo load_exit
        End If

        ' *** ビューの取得
        view = db.GetView(strViewName)
        If (view Is Nothing) Then
            ' *** エラーメッセージの表示
            MsgBox("ビューが見つかりませんでした", vbOKOnly + vbCritical)
            GoTo load_exit
        End If

        ' *** ビューより最初の文書を取得
        doc = view.GetFirstDocument()

        ' *** ビューより全文書を読み込むまでループ
        Do While (Not (doc Is Nothing))
            'タイトル
            NSubject = doc.GetItemValue("Subject")
            strSubject = NSubject(0).ToString

            doc = view.GetNextDocument(doc)
        Loop

load_exit:

        ' *** オブジェクトの破棄
        db = Nothing
        session = Nothing

2011年11月9日水曜日

LotusScriptでSQLServerへアクセスする方法

Sub Click(Source As Button)
    Dim cn As Variant
    Dim rs As Variant
    Dim strSQL As String
    Dim strEmployeeID As String
    Dim ws As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument

    Set uidoc = ws.CurrentDocument
    Set cn = CreateObject("ADODB.Connection")
    Set rs = CreateObject("ADODB.Recordset")

    On Error Goto ConnectionErr
    'SQLServer接続文字列
    cn.ConnectionString = "Provider=SQLOLEDB ;" & _
    "Password='' ; User ID=sa;Initial Catalog=Northwind;Data Source=SQLServer"
    strEmployeeID = Trim(uidoc.FieldGetText("EmployeeID"))

    'SQL文
    strSQL = "SELECT EmployeeID, LastName " & _
    "FROM dbo.Employees " & _
    "WHERE (EmployeeID = " & strEmployeeID & ")"

    '接続開始
    Call cn.Open
    'SQL文発行
    Call rs.Open(strSQL,cn)
    '取得した値をフィールドにセット
    Call uidoc.FieldSetText("LastName",Trim(rs.Fields("LastName").Value))
    'Recordsetクローズ
    Call rs.Close
    'Connectionクローズ
    Call cn.Close
    '文書を更新する
    Call uidoc.Refresh

ConnectionExit:
    Exit Sub

ConnectionErr:
    Resume  ConnectionExit
End Sub

2011年10月19日水曜日

Search Server 2008 ExpressによるNotesDBの検索

社内にNoetsDBとファイルサーバーを横断的に検索出来るサイトが欲しい!!
出来ることなら無償のソフトがないかなと思っていたところ、「Search Server 2008 Express」にたどり着きました。
http://www.microsoft.com/japan/enterprisesearch/default.aspx

NotesDBの検索方法については、こちらで紹介されています。
http://technet.microsoft.com/ja-jp/office/sharepointserver/cc952469.aspx#NotesDomino_with_Search

Office SharePoint Server 2007のドキュメントですが、Search Server 2008はこれのサブセットなので、問題なく動作します。
ただ、注意しなければならないのは、検索キャッシュです。
例えば、「機密情報Field、Managerロールには見せるがだが、ロールなしには見せない。」と言ったケース。
機密情報Fieldもしっかりキャッシュされるので、権限がない人間はFormで機密情報見られなくても、キャッシュで見れてします。

その辺を上手く運用でカバー出来れば非常に面白いソフトではないでしょうか。

プロセッサ: 2.5 ギガヘルツ (GHz) (最小)
メモリ: 2 ギガバイト (GB) RAM (最小)
とシステム要件が少々高いのが難点です。(今時だとこのくらい大したことないのかな?)

2011年10月15日土曜日

NotesSQLに関するドキュメントとサンプルコード

NotesDB に格納されている文書を集計したいときなど、SQL文が使えると便利なんだろうなって思うときが時々あります。
いろいろと調べていたら、NotesSQLというソフトの存在を知りました。
しかし、いざ使ってみようと思うと日本語の情報が全然ない・・・。
あるとき、Microsoft Office SharePoint Server 2007のサイトを見ていましたら
「Microsoft Office SharePoint Server 2007 自習書 Notes/Domino アプリケーション資産の活性化」
というのを発見。早速PDFをダウンロードしてみたら、日本語でNotesSQLの使い方が懇切丁寧に書いてありました。
しかも使い方だけでなくダウンロード方法も解説してあります。
ConnectionStringの書き方に少々苦戦しましたが、無事VB.NETからアクセス出来ました!!
ちょっと凝ったSQL文を書くと、すぐにこけるのでNotes側のViewで工夫することがポイント。(特にINNER JOIN等での結合は出来なかった。)

まさか、ライバルから情報を入手出来るとは夢にも思っていませんでした。

サンプルコードは非接続型で、GridViewにバインドするコードです。
WindowsForm、WebFormどちらでも可。もちろん、接続型でももちろん接続可能。

サンプルコード(VB.NET)

Dim strConn As String = "DRIVER={Lotus NotesSQL Driver (*.nsf)}; " & _
                                                                          "Server=ServerName; " & _
                                                                          "Database=DbName.nsf; " & _
                                                                          "Uid=UserID; " & _
                                                                          "Pwd=password; "

Dim strSQL As String
Dim dtAdapter As Odbc.OdbcDataAdapter
Dim dtSet As DataSet

strSQL = "SELECT * FROM ViewName" ' 単純なWHERE句なら指定可能

dtAdapter = New Odbc.OdbcDataAdapter(strSQL, strConn)
dtSet = New DataSet
dtAdapter.Fill(dtSet, "board")

GV_Board.DataSource = dtSet.Tables("board")
GV_Board.DataBind()