十二 28
Digg
Stumbleupon
Technorati
Delicious

FileNet添加和删除文件错误 An error occurred accessing the database

这两天在客户测试环境的FileNet Server遇到错误,不管是调用CE Web Service API的方式还是FileNet Workplace,上传或删除文件都失败,出现了Exception,显示的错误信息是 An error occurred accessing the database.  ErrorCode: 0, Message: ‘enlist: caught Exception’ 看错误信息,可能是oracle数据库有什么问题,可是查了很久没查出错误所在。 后来在WebSphere Server的SystemOut.log中看到具体错误信息如下: WTRN0037W: The transaction service encountered an error on an xa_recover operation. The resource was com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl@57562412. The error code was XAER_RMERR. The exception stack trace follows: javax.transaction.xa.XAException at oracle.jdbc.xa.OracleXAResource.recover(OracleXAResource.java(Compiled Code)) at com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl.recover(WSRdbXaResourceImpl.java(Compiled Code)) at com.ibm.ws.Transaction.JTA.XARminst.recover(XARminst.java(Compiled [...]

Author: jianyun
十二 28
Digg
Stumbleupon
Technorati
Delicious

Executing Multiple Select Statements for Oracle

使用SQL Server的时候,我们可以传多个Select语句作为CommandText,一次执行,然后通过DataReader的NextResult方法访问多个Select语句返回的结果集,当然也可以用DataAdapter来填充DataSet。 下面的例子就是用一个DBCommand执行多个Select语句的代码片段。 myCommand.CommandText = “UPDATE Books SET Price=Price*0.95 “ + “SELECT BookName, Price FROM Books ” + “UPDATE Toys SET Price=Price*0.9 “ + “SELECT ToyName, Price FROM Toys “; SqlDataReader dreader = myCommand.ExecuteReader(); while (dreader.Read()) // process the first result set { Console.WriteLine(dreader.GetString(0) + “: ” + dreader.GetSqlMoney(1).ToDouble()); } dreader.NextResult(); // Move on to [...]

Author: jianyun
十二 14
Digg
Stumbleupon
Technorati
Delicious

[VSTO] 区分MailItem的attachment是真正的附件还是内嵌资源

在遍历MailItem的Attachments集合的时候发现,不管是真正的附件还是内嵌资源,比如邮件内容中内嵌的图片(Embedded Image),都是Attachments集合的元素,通过查看attachment元素的属性,并没有发现可以区分它们的方法。 其实如果是Outlook2007及以上的话,可以通过MAPI Attachment Reference for PropertyAcessor取得attachment的ContentID来判断。 比较靠谱的判断方法是, 1)先看attachment的Type属性是不是OlAttachmentType.olByValue,如果不是那么它是内嵌的 2)再通过PropertyAccessor.GetProperty的方法看ContentID(http://schemas.microsoft.com/mapi/proptag/0x3712001E)和ContentLocation(http://schemas.microsoft.com/mapi/proptag/0x3713001E)是不是空的,如果是不为空的字符串,那么它是内嵌的 通常做1)和2)的check就行了,但某些情况下,这样还不保险,可以继续下面的check 3)通过PropertyAccessor.GetProperty的方法看METHOD属性(http://schemas.microsoft.com/mapi/proptag/0×37050003)的值是不是6,类型应该是int,如果是那么它是内嵌的 4)通过PropertyAccessor.GetProperty的方法看FLAGS属性(http://schemas.microsoft.com/mapi/proptag/0×37140003)的值是不是4,类型应该是int,如果是那么它是内嵌的   下面是代码判断: private bool isEmbeddedAttachment(Outlook.Attachment attachment) { if(attachment.Type != Outlook.OlAttachmentType.olByValue) { return true; } string ATTACH_CONTENT_ID = @”http://schemas.microsoft.com/mapi/proptag/0x3712001E”; string ATTACH_CONTENT_LOCATION = @”http://schemas.microsoft.com/mapi/proptag/0x3713001E”; if(attachment.PropertyAccessor.GetProperty(ATTACH_CONTENT_ID).ToString() != string.Empty || attachment.PropertyAccessor.GetProperty(ATTACH_CONTENT_LOCATION).ToString() != string.Empty) { return true; } string ATTACH_METHOD = @”http://schemas.microsoft.com/mapi/proptag/0×37050003″; if((int)attachment.PropertyAccessor.GetProperty(ATTACH_METHOD) == 6) { return [...]

Author: jianyun
十一 25
Digg
Stumbleupon
Technorati
Delicious

Oracle中RAW(16)与.Net中GUID字符串的转换

平常从来都没碰到过RAW类型的字段,最近碰到一个需求,就是我们数据库中保存了一个VARCHAR类型的GUID字符串,这个是调用FileNet API保存文档到FileNet Content Engine后返回的一个document id。 现在要利用这个document id直接去FileNet的数据库更新一些数据,经过查看和测试发现DOCVERSION这个表应该就是存储文档的信息的表,进一步发现Object_id应该就对应document id,但是这个字段的类型是RAW(16),初步看并不匹配。 在网上查了下发现 http://www.robobunny.com/cgi-bin/guid 解释了Oracle 用RAW(16)来表示GUID,而且这个页面提供了RAW(16)和普通的GUID字符串之间的转换。 后来发现RAW(16)和普通的GUID字符串之间的转换可以用如下方法: Oracle中: select * from docversion where substr(object_id,7,2) || substr(object_id,5,2) || substr(object_id,3,2) || substr(object_id,1,2) || ‘-’ || substr(object_id,11,2) || substr(object_id,9,2) || ‘-’ || substr(object_id,15,2) || substr(object_id,13,2) || ‘-’ || substr(object_id,17,4) || ‘-’ || substr(object_id,21,12) = ’64908CFC-2D78-4EC6-A5EF-6AC42B1D3454′   .Net中: static string DotNetToOracle(string text) { Guid guid [...]

Author: jianyun