340 likes | 556 Views
PWB517 PowerBuilder in .NET World. Xue-song Wu Staff Software Engineer Xue-song.wu@sybase.com August/2004. The Enterprise. Unwired. The Enterprise. Unwired. Industry and Cross Platform Solutions. Manage Information. Unwire Information. Unwire People. Adaptive Server Enterprise
E N D
PWB517 PowerBuilder in .NET World Xue-song Wu Staff Software Engineer Xue-song.wu@sybase.com August/2004
The Enterprise. Unwired. Industry and Cross Platform Solutions Manage Information Unwire Information Unwire People • Adaptive Server Enterprise • Adaptive Server Anywhere • Sybase IQ • Dynamic Archive • Dynamic ODS • Replication Server • OpenSwitch • Mirror Activator • PowerDesigner • Connectivity Options • EAServer • Industry Warehouse Studio • Unwired Accelerator • Unwired Orchestrator • Unwired Toolkit • Enterprise Portal • Real Time Data Services • SQL Anywhere Studio • M-Business Anywhere • Pylon Family (Mobile Email) • Mobile Sales • XcelleNet Frontline Solutions • PocketBuilder • PowerBuilder Family • AvantGo Sybase Workspace
Agenda • Overview of the PB to .NET compiler • Mapping PB features to .NET • PB WebForm for .NET • PowerScript enhancement
Objectives of the PB to .NET Compiler • Compile PB applications as ASP.NET applications • Compile PB applications as Windows Forms applications. • Compile PB NVOs as .NET Web Services.
WinForm/ WebForm Application PBL files C# Code Overview of PB to .NET Compiler pb2cs generates compiles References to PB System Library For .NET Main modules of the PB to .NET compiler
PB system library for .NET • Implements all PB system classes and system functions in .NET programming languages. • No PBVM involved. • PBDWE.DLL, PBSHR.DLL, and DB drivers are needed.
Assemblies of PB system library for .NET Sybase.PowerBuilder.Win.Dll Sybase.PowerBuilder.Web.Dll DataWindowControl Sybase.PowerBuilder.Common.Dll DataWindow Web Control 3rd party Web Controls Sybase.PowerBuilder.Interop.Dll PBSHR.Dll Sybase.PowerBuilder.Core.Dll DB Drivers
Mapping PB Features to .NET • PB Features • Data types (including nullness of variables) • Arrays • System classes and system enumerations • Event handling • Method invocation (dynamic/post) • Operators and expressions • Statements • Embedded SQL • DataWindow (dot notation) • External functions • COM • EAServer integration • PBNI
PB Data types • Standard types: blob, boolean, char, date, datetime, decimal, double, int, long, real, string, time, uint, ulong, and longlong. • Any • Cursor and procedure • Nullness.
Nullness • IPBValue public interface IPBValue { … bool Null { get; set; } … } • Defining a struct or a class that implement the IPBValue interface for each PB data type.
System-defined enumerations • Enum names prefixed with “PB”. • Using Pascal naming convention for enum items. Powerscript: system type BorderStyle enumerated StyleBox! = 2 StyleRaised! = 6 StyleLowered! = 5 StyleShadowBox! = 1 end type C#: enum PBBorderStyle { StyleBox = 2, StyleRaised = 6, StyleLowered = 5, StyleShadowBox = 1 }
System-defined classes • Class names prefixed with “PB”. • Using Pascal naming convention for member functions and instance variables. PowerScript: system type Throwable from NonVisualObject string Text end type function string getMessage() return text end function subroutine setMessage(String msg) text = msg end subroutine C#: class PBThrowable : PBNonVisualObject { public PBString Text; public PBString GetMessage() { return Text; } public SetMessage(PBString msg) { Text = msg; } }
System-defined visual classes • Visual classes for WinForm. • Visual classes for WebForm. • Visual classes for mobile devices (in future)
Event handling • PB events .NET events. • PB event IDs .NET delegates. • PB event handler function that is registered to an .NET event.
Other features • Embedded SQL – PBSQL class. • Dynamic/post method invocation - .NET reflection • COM. • EAServer integration • PBNI • External functions
PB Windows Forms • Implemented using .NET Windows Forms controls. • No PBVM involved. • Make use of DataWindow.NET (supports dot notation)
PB .NET Web Services • Generate .asmx file for PB NVOs
PB WebForm for .NET • Rich internet application • Implemented on top of ASP.NET • Supporting most features of PowerBuilder
Brief introduction to ASP.NET • Form-based programming method. • Event-driven programming • Ready-to-use Web controls that hide the details of HTML rendering. • State management • ASP.NET applications are compiled, and thus fast.
ASP.NET page life cycle Image copied from http://www.dotnetguru/us/articles/JSFvsWebForms/JSFvsWebForms.html
Moving to ASP.NET • PB WebForm Architecture (2-tier applications) PB App DB drivers Database PB application Web Brower ASP.NET PB WebForm App DB drivers Database Web Server PB WebForm application
Moving to ASP.NET • PB WebForm Architecture (3-tier applications) PB Client App PB Components Database App Server PB application Web Brower ASP.NET PB WebForm App PB Components Database Web Server App Server PB WebForm application
Page Model of PB WebForm • Each application has an aspx. page to represent the main window. • WebWindow • Web control: can contain menu, toolbar, and other child WebWindow controls. • Controls are added to the WebWindow controls dynamically. • All user’s logic runs at server side. <form id="Form1" method="post" runat="server"> <pb:DialogOpener id="dialogOpener" runat="server" Visible="False"> </pb:DialogOpener> <pb:WebMessageBox id="webMessageBox" runat="server“ Visible="False"> </pb:WebMessageBox> <asp:PlaceHolder runat="server" ID="mainWindow"></asp:PlaceHolder> </form>
MessageBox • When a MessageBox is shown, the execution of script is suspended until the MessageBox is dismissed. • ASP.NET doesn’t provide a MessageBox control. • WebMessageBox control. st_1.text = "Showing MessageBox" messagebox("PB", "Hello world") st_1.text = "After showing MessageBox"
Dialog (Response Window) • Dialog hell (http://weblogs.asp.net/jezell/archive/2003/08/26/25450.aspx). • DialogOpener Web control. • ShowDialogX.html and DialogX.aspx. st_2.text = "Showing Dialog" open(w_genapp_about) st_2.text = "After showing Dialog"
Printing • Local printing: A PostScript or PDF file is generated at the server side, which is then downloaded to the client side for printing.
Things worth mentioning • Only Button and LinkButton can trigger post back events immediately. Other events are queued up by the browser. • PB WebForm applications are stateful, and states are kept at server side • In-proc state management • No ViewState passing back and forth • Web Farms require Server Affinity • Out-of-process state management (in future release) • Failover
Things not supported or working differently from PB • ActiveX • Visual – callable but not visible • Non-visual – callable • Avoid using STA (Single Thread Apartment) COM components (Requires Thread Affinity, setting ASPCompat to true) • File operations – happen at server side • Registry – probably not supported • Clipboard • Drag & drop • Hot keys, shortcut keys, and accelerate keys • Mouse move event
PB to .NET Compiler • What you can do with it in PB11 • Deploy PB applications as WebForm/WinForm applications. • Deploy PB NVOs as .NET Web Services • What you can do with it beyond PB11 • Use .NET classes in PB. • Debug WinForm/WebForm applications in PB IDE
PowerScript Enhancement • Parameterized constructors • StringBuilder • Bitwise operators (bitand, bitor, bitnot, bitxor) • Package & imports
PB to .NET Compiler Q & A