用友畅捷通在T+系统中增加自定义页面,并进行二次开发,如何做page扩展?
发布时间:2021-03-29 20:03:00 访问数:1189
应用需求:在T+系统中增加自定义页面,并进行扩展
应用ID:Chanjet.Sample.HelloWorld
应用类型:Production
应用名:Page扩展
T+版本:11.51以上(含)
开发工具:Visual Studio 2012
开发步骤:
1、创建VS解决方案(Chanjet.Sample.HelloWorld)
2、创建VS项目(Chanjet.Sample.HelloWorld.UIP)
3、创建类(Chanjet.Sample.HelloWorld.UIP.Actions)
4、创建类(Chanjet.Sample.HelloWorld.UIP.HelloWorldPage)
5、创建VS项目(Chanjet.Sample.HelloWorld.Service)
6、创建类(Chanjet.Sample.HelloWorld.Service.HelloWorld)
7、创建VS项目(Chanjet.Sample.HelloWorld.Interface)
8、创建接口(Chanjet.Sample.HelloWorld.Interface.IHelloWorld)
9、创建JS(MyHelloWorld.js)
10、创建应用配置文件(Sample.HelloWorldPage.app.xml)
11、创建自定义页面(MyHelloWorldPage.aspx)
12、创建自定义页面(MyHelloWorldPage.aspx.cs)
13、创建服务配置文件(services_sample.xml)
14、创建应用配置文件(Sample.HelloWorld.app.xml)
15、执行数据库脚本、部署、重启iis、测试
可能会遇到问题:
1、VS项目引用哪些组件?
UIP
AjaxPro.2.dll
Ufida.T.BAP.Web.dll
Ufida.T.EAP.AopBase.dll
Ufida.T.EAP.AppBase.dll
Ufida.T.EAP.DataStruct.dll
Service
Ufida.T.EAP.DBLayer.dll
2、自定义页面MyHelloWorldPage需要做什么内容?
a、主要代码如下:
<asp:Label ID="lblHelloWorld" runat="server" ></asp:Label>
<button id="btn1">调用Ajax方法</button>
<script src="js/MyHelloWorld.js"></script>
3、JS文件MyHelloWorld.js需要做什么内容?
a、主要代码如下:
<span style="font-size:12px;">var btn1 = document.getElementById("btn1");<br data-filtered="filtered">btn1.onclick = function () {<br data-filtered="filtered"> var names = Chanjet.Sample.HelloWorld.UIP.Actions.GetPersonNames();<br data-filtered="filtered"> if (names.error) {<br data-filtered="filtered"> alert(names.error.Message);<br data-filtered="filtered"> }<br data-filtered="filtered"> btn1.innerHTML = names.value;<br data-filtered="filtered">}<br data-filtered="filtered"></span>
4、类Chanjet.Sample.HelloWorld.UIP.Actions需要做什么内容?
a、前台js调用UIP方法,主要代码如下:
<span style="font-size:12px;"> [AjaxPro.AjaxMethod()]<br data-filtered="filtered"> public string GetPersonNames()<br data-filtered="filtered"> {<br data-filtered="filtered"> string names = ServiceFactory.getService<IHelloWorld>().GetPersonNames();<br data-filtered="filtered"> return names;<br data-filtered="filtered"> }<br data-filtered="filtered"></span>
5、类Chanjet.Sample.HelloWorld.UIP.HelloWorldPage需要做什么内容?
a、实现IAppHandler接口
b、主要代码如下:
<span style="font-size:12px;"> public void AppEventHandler(object sender, AppEventArgs e)<br data-filtered="filtered"> {<br data-filtered="filtered"> controller = sender as GenericController;<br data-filtered="filtered"> lblHelloWorld = controller.GetViewControl("lblHelloWorld") as Label; <br data-filtered="filtered"> helloWorldService = ServiceFactory.getService<IHelloWorld>();<br data-filtered="filtered"> Page_Load(sender, e);<br data-filtered="filtered"> }<br data-filtered="filtered"></span>
<span style="font-size:12px;"> protected void Page_Load(object sender, EventArgs e)<br data-filtered="filtered"> {<br data-filtered="filtered"> lblHelloWorld.Text = "Hello New World !!";<br data-filtered="filtered"> lblHelloWorld.Text = helloWorldService.Say("Hello", "Service World");<br data-filtered="filtered"> lblHelloWorld.Text += "<br/><br/><br/><br/>操作员列表:" + helloWorldService.GetPersonNames();<br data-filtered="filtered"> UserInfo userInfo = HttpContext.Current.Session["UserInfo"] as UserInfo;<br data-filtered="filtered"> lblHelloWorld.Text += "<br/><br/><br/><br/>操作员: " + userInfo.PersonName;<br data-filtered="filtered"> AjaxPro.Utility.RegisterTypeForAjax(typeof(Actions), lblHelloWorld.Page);<br data-filtered="filtered"> }<br data-filtered="filtered"></span>
6、接口Chanjet.Sample.HelloWorld.Interface.IHelloWorld需要做什么内容?
a、接口方法如下:
<span style="font-size:12px;"> string Say(string word1, string word2);<br data-filtered="filtered"> string GetPersonNames();<br data-filtered="filtered"></span>
7、类Chanjet.Sample.HelloWorld.Service.HelloWorld需要做什么内容?
a、主要代码如下:
<span style="font-size:12px;"> public string Say(string word1, string word2)<br data-filtered="filtered"> {<br data-filtered="filtered"> return word1 + " " + word2 + "!!! (Return By Service)";<br data-filtered="filtered"> }<br data-filtered="filtered"></span>
<span style="font-size:12px;"> public string GetPersonNames()<br data-filtered="filtered"> {<br data-filtered="filtered"> DBSession db = DBSessionFactory.getDBSession();<br data-filtered="filtered"> DataTable dt = db.findDataTable("select personname from eap_user");<br data-filtered="filtered"> string names = string.Empty;<br data-filtered="filtered"> foreach (DataRow dr in dt.Rows)<br data-filtered="filtered"> {<br data-filtered="filtered"> names += dr["personname"] + ";";<br data-filtered="filtered"> }<br data-filtered="filtered"> return names;<br data-filtered="filtered"> }<br data-filtered="filtered"></span>
8、应用配置文件需要配置什么内容?
a、配置客户端Page.Load扩展
扩展点定义:
<span style="font-size:12px;"><ExtensionPoint id="Ufida.T.EAP.Web.Page.Load"><br data-filtered="filtered"> <View id="[CustomPage]" path="[CustomPagePath]" class="[CustomPageClassName]"></View><br data-filtered="filtered"></ExtensionPoint><br data-filtered="filtered"></span>
针对自定义页面初始化行为:
id:MyHelloWorldPage.aspx
path:App/Sample/Sample.HelloWorldPage/MyHelloWorldPage.aspx
class:Chanjet.Sample.HelloWorld.UIP.HelloWorldPage
b、配置服务器端服务扩展
扩展点定义:
<span style="font-size:12px;"><ExtensionPoint id="Ufida.T.EAP.Service.Config"><br data-filtered="filtered"> <Config id="[ExtensionName]" src="[ServiceFilePath]"></Config><br data-filtered="filtered"></ExtensionPoint><br data-filtered="filtered"></span>
针对自定义页面调用服务:
id:Sample
src:config/services_sample.xml
c、配置服务文件
服务定义:
<span style="font-size:12px;"><services domain="Sample" desc=""><br data-filtered="filtered"> <service name="Chanjet.Sample.HelloWorld.Interface.IHelloWorld"<br data-filtered="filtered"> className="Chanjet.Sample.HelloWorld.Service.HelloWorld"<br data-filtered="filtered"> loadFrom="..serverChanjet.Sample.HelloWorld.Service.dll"<br data-filtered="filtered"> desc="" mode="normal"></service><br data-filtered="filtered"></services><br data-filtered="filtered"></span>
9、菜单脚本(Sample_菜单.sql)
<span style="font-size:12px;">--Sample菜单和权限预制数据<br data-filtered="filtered">delete from eap_menu where Code='Sample'<br data-filtered="filtered">insert into eap_menu(Code,Name,ShortCut,SubID,Grade,SupMenuID,EndGrade,[Order],RequestUrl,GroupFlow,<br data-filtered="filtered">IsItemGroup,IsControl,Version,AccountType,Visibility,Updated,UpdatedBy,inID) values('Sample','Sample1',<br data-filtered="filtered">null,null,0,null,0,'95','#',null,0,1,null,0,1,null,null,'Sample')<br data-filtered="filtered">delete from eap_menu where Code='Sample01'<br data-filtered="filtered">insert into eap_menu(Code,Name,ShortCut,SubID,Grade,SupMenuID,EndGrade,[Order],RequestUrl,GroupFlow,<br data-filtered="filtered">IsItemGroup,IsControl,Version,AccountType,Visibility,Updated,UpdatedBy,inID) values('Sample01',<br data-filtered="filtered">'HelloWorld页面01',null,null,1,'Sample',0,'0','App/Sample/Sample.HelloWorldPage/MyHelloWorldPage.aspx',<br data-filtered="filtered">null,0,1,null,0,1,null,null,'Sample_Sample01')<br data-filtered="filtered">delete from eap_menutree where id='F8D60E71-A7FE-4FE6-AF10-28234E288B86'<br data-filtered="filtered">insert into eap_menutree(Title,ShowIndex,isSystem,id,parentID) values('Sample1',163,0,<br data-filtered="filtered">'F8D60E71-A7FE-4FE6-AF10-28234E288B86',null)<br data-filtered="filtered">delete from eap_menutreerelation where id='2B165C03-62F6-4DB9-98C3-E0E074B2A62D'<br data-filtered="filtered">insert into eap_menutreerelation(MenuCode,[Name],TreeID,ID,isSystem,showIndex) values('Sample01',<br data-filtered="filtered">'HelloWorld页面01','F8D60E71-A7FE-4FE6-AF10-28234E288B86','2B165C03-62F6-4DB9-98C3-E0E074B2A62D','0','0')<br data-filtered="filtered">delete from eap_functionauth where id='81084916-2D47-485F-A322-C0F2F57A45AD'<br data-filtered="filtered">insert into eap_functionauth(id,menucode,name,title,tabindex,issystem,functioncode,description,idparent) <br data-filtered="filtered">values('81084916-2D47-485F-A322-C0F2F57A45AD','Sample01','Read','查看',0,0,'Sample0106',null,null)<br data-filtered="filtered"></span>