.net读取Lotus Domino文件数据库

Domino有组件支持.net,虽然感觉支持的不太好,但是能用,安装组件的方法很简单,在NuGet中联机搜索Domino,然后根据需要安装即可。

开发时,要在开发机上安装Notes客户端,网上很多,这里不赘述,直接上简易读取代码:

 1 NotesSession ns = new NotesSession();
 2             //ns.Initialize("test1234");
 3             ns.Initialize();
 4             if (ns == null)
 5             {
 6                 MessageBox.Show("未能初始化");
 7                 return;
 8             }
 9             //http://10.31.100.50
10             NotesDatabase db = ns.GetDatabase("", @"names.nsf", false);
11             if (db == null)
12             {
13                 MessageBox.Show("未能初始化数据库");
14                 return;
15             }
16             
17             StringBuilder sb = new StringBuilder();
18 
19             NotesView view = db.GetView("$users");
20             object[] cols = view.ColumnNames;
21             Dictionary<int, object> dic = new Dictionary<int, object>();
22             if (cols != null)
23             {
24                 int ix = 0;
25                 foreach (object obj in cols)
26                 {
27                     dic.Add(ix, obj);
28                     if (obj != null) sb.Append(string.Format("{0}\r\n", obj));
29                     ix++;
30                 }
31             }
32             NotesViewEntry ve = view.GetEntryByKey("12345");
33             if (ve != null)
34             {
35                 int ix = 0;
36                 object[] objs = ve.ColumnValues;
37                 foreach (object obj in objs)
38                 {
39                     KeyValuePair<int, object> kv = dic.FirstOrDefault(m => m.Key == ix);
40                     Type tp = obj.GetType();
41                     if (tp.Name.Contains("Object[]"))
42                     {
43                         int ik = 0;
44                         object[] nobjs = (object[])obj;
45                         foreach (object nobj in nobjs)
46                         {
47                             sb.Append(string.Format("{0}[{1}]值为:{2}\r\n", kv.Value, ik, nobj));
48                             ik++;
49                         }
50                     }
51                     else
52                     {
53                         sb.Append(string.Format("{0}值为:{1}\r\n", kv.Value, obj));
54                     }
55                     ix++;
56                 }
57 
58             }

 

转载于:https://www.cnblogs.com/ymworkroom/p/6770730.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值