using Domino;
导入包含Domino命名空间的dll:Interop.Domino.dll。
安装notes客户端。
访问domino是由建立一个NotesSession对象开始的。所以第一个问题是NotesSession对象的初始化。NotesSession对象的Initialize(string password)方法,直观却有些让人费解,因为即使没有接触过domino的人也知道建立一个会话,需要的是用户名和密码,而这里的方法只有一个password参数。
这里的道理不用深究,因为notes客户端会根据系统中的user.id文件找到用户名信息,而密码部分就是要验证的事情了。如果有做过domino开发的人,对这部分应该有更深的理解。
从domino数据文件中得到数据清单,并整理到DataTable中
实例1:
public NotesSession session = new NotesSession();
public SqlConnection sqlcon = new SqlConnection();
private string notesstatus;
private string notesServer = "Domino所在服务器地址";
public string ConDomino()
{
string returnvalue;
session.Initialize("password");
if (session != null)
{
returnvalue = "OK";
}
else
{
returnvalue = "Not User ID";
}
return returnvalue;
}
public DataTable GetOAHuanJie(string strliuchengUNID)
{
DataTable dt = new DataTable();
DataColumn dc = new DataColumn("NOID");
//Single liubianhao;
//System.Type ctype;
dt.Columns.Add(dc);
dc = new DataColumn("HuanjieName");
dt.Columns.Add(dc);
dc = new DataColumn("HuanjieNO", System.Type.GetType("System.Double"));
dt.Columns.Add(dc);
notesstatus = ConDomino();
if (notesstatus == "OK")
{
NotesDatabase notesdb = session.GetDatabase(notesServer, "oadata/FlowConfig.nsf", false);
NotesView notesvw = notesdb.GetView("v_sort_huanjieunid");
NotesDocumentCollection dcl = notesvw.GetAllDocumentsByKey(strliuchengUNID, true);
NotesDocument doc = dcl.GetFirstDocument();
while (doc != null)
{
DataRow dr = dt.NewRow();
dr.BeginEdit();
dr["NOID"] = doc.UniversalID;
dr["HuanjieName"] = doc.GetItemValue("tHuanJieMingCheng")[0];
//liubianhao = Convert.ToSingle(doc.GetItemValue("tHuanJieBianHao")[0]);
dr["HuanjieNO"] = Convert.ToSingle(doc.GetItemValue("tHuanJieBianHao")[0]);
dr.EndEdit();
dt.Rows.Add(dr);
doc = dcl.GetNextDocument(doc);
}
}
dt.DefaultView.Sort = "HuanjieNO asc";
return dt;
}
ASP.net调用Domino实例2
调用Domino时,可仿照Domino本身代码中的属性和方法去获取文档及文档中域的值
protected void Button2_Click(object sender, EventArgs e)
{
NotesSession ns = new NotesSession();
//DataTable dt=new DataTable();
string colm1;
string colm2;
string tLiuCheng_UNID;
string MyName;
string Status;
string Status_Num;
string Status_UNID;
string Status_Type;
string Status_Key;
string strKey;
ns.Initialize("password");
if (ns != null)
{
NotesDatabase notesdb = ns.GetDatabase("Domino所在服务器地址", "oadata/FlowConfig.nsf", false);
//按数据库名取得流程
NotesView nview = notesdb.GetView("v_f_list_flowconfig_e");
NotesDocument dot = nview.GetDocumentByKey("e_qingjiashenqing.nsf", true);
tLiuCheng_UNID = dot.UniversalID; //UniversalID号
//MyName = dot.GetItemValue("Creater");
//按流程UNID取得环节
NotesView huanjieview = notesdb.GetView("v_key_companyflowfloat"); 查找视图
NotesDocument huanjiedoc = huanjieview.GetDocumentByKey(tLiuCheng_UNID,true); 在视图中查找文档
Status = huanjiedoc.GetItemValue("tHuanJieMingCheng")[0]; /取得域中的值
Status_Num = huanjiedoc.GetItemValue("tHuanJieBianHao")[0]; /取得域中的值
Status_UNID = huanjiedoc.UniversalID; /取得文档中的UniversalID号,这个号是不重复的,唯一值
Status_Type = huanjiedoc.GetItemValue("tHuanJieLeiXing")[0]; /取得域中的值
Status_Key = huanjiedoc.GetItemValue("tTiaoJianPanDuan")[0]; /取得域中的值
Object ab = huanjiedoc.GetItemValue("tTiaoJianPanDuan"); /取得域中的值
Domino.NotesDatabase db = ns.GetDatabase("Domino所在服务器地址", "oadata/FlowConfig.nsf", false); //Domino的服务器名,数据库名
Domino.NotesView view = db.GetView("v_key_defaultliuxiang");
//Domino.NotesView view = db.GetView("agent_Search_manager_shenpi");
string formula = "form = \"f_LiuCheng\" & sys_SuperUserdeal != \"1\" & sys_SoftDelete != \"1\"";
formula = formula + "&tLiuChengMingCheng=\"系统检查流程\"";
NotesDocumentCollection dc = view.GetAllDocumentsByKey("UniversalID 号", true); //获取符且这个ID号的Docuent文档
NotesDocumentCollection dc = db.Search(formula, null, 0);
NotesDocument doc = dc.GetFirstDocument();
//Domino.NotesAgent na = new NotesAgent();
//na.Run("agent_Search_manager_shenpi");
object[] value;
string[] strarry;
NotesDocument doc= view.GetDocumentByKey("UniversalID号", true);
usrnam.Text = doc.GetItemValue("tAimHuanjieRole")[1]; //取得域中的值
object[] ob = (object[])doc.GetItemValue("tAimHuanjieRole");
for (int jij = 0; jij < ob.Count(); jij++)
{
DropDownList1.Items.Add(doc.GetItemValue("tAimHuanjieRole")[jij]); /取得域中的值
}
usrnam.Text = Convert.ToString(ob.Count());
//value = doc.UniversalID;
usrnam.Text = doc.UniversalID;
DataColumn dco = new DataColumn("No1");
dt.Columns.Add(dco);
dco = new DataColumn("No2");
dt.Columns.Add(dco);
dco = new DataColumn("环节编号");
dt.Columns.Add(dco);
dco = new DataColumn("UseKey");
dt.Columns.Add(dco);
while (doc != null)
{
DataRow dr = dt.NewRow();
//object[] ob = (object[])doc.ColumnValues;
colm1 = doc.GetItemValue("tHuanJieMingCheng")[0];
colm2 = doc.UniversalID;
dr.BeginEdit();
dr["No1"] = colm1;
dr["No2"] = colm2;
dr["环节编号"] = doc.GetItemValue("tHuanJieBianHao")[0];
dr["UseKey"] = doc.GetItemValue("UseKey")[0];
dr.EndEdit();
dt.Rows.Add(dr);
//doc = view.GetNextDocument(doc);
doc = dc.GetNextDocument(doc);
}
}
GridView1.DataSource = dt;
GridView1.DataBind();
Label1.Text = "当前页为:" + (GridView1.PageIndex + 1) + "/" + GridView1.PageCount + " 页";
}
本文作者:黄河水泡茶 来源:CIOZJ
CIO之家 www.ciozj.com 微信公众号:imciow