惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
S
SegmentFault 最新的问题
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
C
Cisco Blogs
博客园 - 叶小钗
P
Privacy International News Feed
Jina AI
Jina AI
Apple Machine Learning Research
Apple Machine Learning Research
T
Threatpost
IT之家
IT之家
博客园 - 聂微东
Know Your Adversary
Know Your Adversary
Help Net Security
Help Net Security
罗磊的独立博客
I
Intezer
S
Schneier on Security
博客园_首页
C
CERT Recently Published Vulnerability Notes
雷峰网
雷峰网
Cisco Talos Blog
Cisco Talos Blog
宝玉的分享
宝玉的分享
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Webroot Blog
Webroot Blog
TaoSecurity Blog
TaoSecurity Blog
MyScale Blog
MyScale Blog
P
Privacy & Cybersecurity Law Blog
T
The Exploit Database - CXSecurity.com
PCI Perspectives
PCI Perspectives
Security Latest
Security Latest
H
Heimdal Security Blog
S
Secure Thoughts
Hacker News: Ask HN
Hacker News: Ask HN
Y
Y Combinator Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Microsoft Security Blog
Microsoft Security Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
SecWiki News
SecWiki News
The GitHub Blog
The GitHub Blog
A
Arctic Wolf
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
T
Threat Research - Cisco Blogs
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

博客园 - ymworkroom

Python学习——Ai+streamlit实现Ai伴侣(练习流式输出) Python中包的导入 Python中__name__与__all__两个特殊变量的作用 Python中模块导入方式 国内安装Claude方案 连接mysql8.0时报:KeyNotFoundException: 给定关键字不在字典中 vscode中运行的vue项目,vscode关闭后仍然运行,如何停止 [INS-30131] 执行安装程序验证所需的初始设置失败 Java中CornExpression说明 java项目开发常用配置文件模板 oracle数据库导入dmp文件,两种方法 Oracle dmp文件导入(还原)到不同的表空间和不同的用户下 pdf.js在IIS中配置使用笔记 禁止达梦数据库中not null字段插入空字符串 错误:java.lang.NoClassDefFoundError: org/jaxen/JaxenException 服务器级的urn筛选器无效:筛选器必须为空,或服务器属性必须等于实际的服务器名称处理方法 oracle下安装logminer笔记 .net导出图片到Excel .net获取网络图片 Lotus Notes连接Domino服务器时出错 配置Mysql远程访问 mysql Access denied for user root@localhost错误处理备忘 MsSql判断表是否有自增标识 .net用NPOI生成Word表格
.net读取Lotus Domino文件数据库并写入DataTable中
ymworkroom · 2017-04-27 · via 博客园 - ymworkroom

上一篇文章是简单的读取并输出,这里稍微加深一点,将读取到的内容按字段存入DataTable中。

 1 StringBuilder sb = new StringBuilder();
 2             NotesSession ns = new NotesSession();
 3             //ns.Initialize("test1234");
 4             ns.Initialize();
 5             if (ns == null)
 6             {
 7                 MessageBox.Show("未能初始化");
 8                 return;
 9             }
10             //NotesDatabase db = ns.GetDatabase("", @"names.nsf", false);
11             NotesDatabase db = ns.GetDatabase("", @"todo/120006.nsf", false);
12             if (db == null)
13             {
14                 MessageBox.Show("未能初始化数据库");
15                 return;
16             }
17             NotesView view = db.GetView(@"V5\01.待办文件");
18             if (view == null) return;
19             DataTable dt = new DataTable();
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)
29                     {
30                         sb.Append(string.Format("{0};", obj));
31                         if (!dt.Columns.Contains(obj.ToString()))
32                         {
33                             DataColumn dc = new DataColumn(obj.ToString());
34                             dt.Columns.Add(dc);
35                         }
36                         
37                     }
38                     ix++;
39                 }
40             }
41             NotesDocument doc = view.GetFirstDocument();
42             while (doc != null)
43             {
44                 object[] objs = (object[])doc.ColumnValues;
45                 if (objs == null) return;
46                 int ix = 0;
47                 DataRow dr = dt.NewRow();
48                 foreach (object obj in objs)
49                 {
50                     if (obj == null) continue;
51                     KeyValuePair<int, object> kv = dic.FirstOrDefault(m => m.Key == ix);
52                     Type tp = obj.GetType();
53                     if (tp.Name.Contains("Object[]"))
54                     {
55                         object[] nobjs = (object[])obj;
56                         List<string> list = new List<string>();
57                         foreach (var nobj in nobjs)
58                         {
59                             sb.Append(string.Format("{0}\r\n", nobj));
60                             list.Add(string.Format("{0}",nobj));
61                         }
62                         dr[kv.Value.ToString()] = string.Join("|", list);
63                     }
64                     else
65                     {
66                         sb.Append(string.Format("{0}\r\n", obj));
67                         dr[kv.Value.ToString()] = obj;
68                     }
69                     ix++;
70                 }
71                 dt.Rows.Add(dr);
72                 doc = view.GetNextDocument(doc);
73             }