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

推荐订阅源

U
Unit 42
N
News and Events Feed by Topic
S
Schneier on Security
G
GRAHAM CLULEY
Scott Helme
Scott Helme
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
C
CERT Recently Published Vulnerability Notes
T
The Exploit Database - CXSecurity.com
C
Cisco Blogs
T
The Blog of Author Tim Ferriss
Cisco Talos Blog
Cisco Talos Blog
P
Privacy & Cybersecurity Law Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 司徒正美
Blog — PlanetScale
Blog — PlanetScale
Project Zero
Project Zero
MyScale Blog
MyScale Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
The Last Watchdog
The Last Watchdog
Vercel News
Vercel News
The Cloudflare Blog
C
Check Point Blog
Help Net Security
Help Net Security
Microsoft Security Blog
Microsoft Security Blog
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
Stack Overflow Blog
Stack Overflow Blog
腾讯CDC
NISL@THU
NISL@THU
S
Security @ Cisco Blogs
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
S
SegmentFault 最新的问题
MongoDB | Blog
MongoDB | Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
AWS News Blog
AWS News Blog
Cloudbric
Cloudbric
N
News and Events Feed by Topic
PCI Perspectives
PCI Perspectives
S
Securelist
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
Vulnerabilities – Threatpost
S
Secure Thoughts

博客园 - 陈典洪

ASP.NET生成Excel文件的历程总结 C# Excel操作类 SharePoint 2010 安装部署 将excel2003转换为excel2007格式 用VS2010为SharePoint 2010 添加Ribbon自定义按钮 在sql server 中如何移动tempdb到新的位置 禁用MOSS2007“我的网站”功能 使用Exchange 2007搭建多域名邮件系统 Exchange 2007 配置 如何简化Exchange 2007 OWA URL访问 [转载]利用MOSS文档库自制一个山寨版mp3在线播放器 - 陈典洪 - 博客园 MOSS中自定义WebService与客户端应用 将项目从vs2008转到Vs2005的办法 如何控制列表视图栏位的宽度? WSS(MOSS)如何修改Rich文本编辑器的宽度 WSS 3.0 and MOSS 2007 SDK 更新到了1.5版本啦 moss 自定义文档库文档图标 - 陈典洪 - 博客园 moss 列表类型和对应类型编号 MOSS LIST的一些属性说明
用VSTA动态改变infopath数据源查询参数与反回查询结果
陈典洪 · 2010-07-27 · via 博客园 - 陈典洪

用infopath 引用外部数据源,进行数据操作,是一件非常方便的事情,比如连接SQL数据库,引用webServices、xml、sharepoint list等,但是我们发现了一个问题,infopath引用数据源时,会将数据缓存在客户端,当我们引用的数居源数据量大的时候,会产生用户操作缓慢的问题。这个时候我们希望下载下来数据能够,既小又准确。我们能够通过自定义数据源加参数的方法,实现动态的数据源查询。在VSTA中动态改变数据源查询参数与反回查询结果,可以参考如下代码:

代码

 public void CTRL1_14_Clicked(object sender, ClickedEventArgs e)
        {
            
// 在此处编写代码。
            System.Xml.XPath.XPathNavigator root;
            root 
= this.MainDataSource.CreateNavigator();
            DataConnection dc 
= ((DataConnection)DataSources["GetData"].QueryConnection);//获取数据源对象if (dc is WebServiceConnection)
            {
                
string queryField = ""
                                     
+ "<tns:GetData xmlns:tns=\"http://tempuri.org/\"><tns:SecuCode>" + root.SelectSingleNode("//ns2:证券代码", this.NamespaceManager).Value + "</tns:SecuCode>"

                                   
+ "   <tns:TradingDay>" + root.SelectSingleNode("//ns2:查询日期"this.NamespaceManager).Value + "</tns:TradingDay>"
                                   
+ "   </tns:GetData>"
                                   
+ "";
                XmlDocument inputDocument
=new XmlDocument();
                inputDocument.LoadXml(queryField);
                XPathNavigator inputNav
= inputDocument.CreateNavigator();

                XmlDocument outputDocument 

= new XmlDocument();
               XPathNavigator outputNav 
= outputDocument.CreateNavigator();

                Microsoft.Office.InfoPath.WebServiceConnection fqc 

= (Microsoft.Office.InfoPath.WebServiceConnection)dc;

                fqc.Execute(inputNav, outputNav, 

null);//执行数据查询
                
//MessageBox.Show(outputNav.OuterXml);

                
string outXml = outputNav.OuterXml.Replace("xmlns=\"http://tempuri.org/\"", "");
                outputDocument.LoadXml(outXml);

                XmlElement nodeElement 

= (XmlElement)outputDocument.SelectSingleNode("GetDataResponse/GetDataResult/证券简称");
                XPathNavigator setNode 
= root.SelectSingleNode("//ns2:公司名称"this.NamespaceManager);
                DeleteNil(setNode);
                setNode.SetValue(nodeElement.InnerText);//对infopath域进行附值

                nodeElement 

= (XmlElement)outputDocument.SelectSingleNode("GetDataResponse/GetDataResult/交易日期");
                setNode 
= root.SelectSingleNode("//ns2:交易日期"this.NamespaceManager);
                DeleteNil(setNode);
                setNode.SetValue(nodeElement.InnerText);

            }
        }

public void DeleteNil(XPathNavigator node)
        {
            
if (node.MoveToAttribute(
               
"nil""http://www.w3.org/2001/XMLSchema-instance"))
                node.DeleteSelf();
        }