<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    jinfeng_wang

    G-G-S,D-D-U!

    BlogJava 首頁 新隨筆 聯(lián)系 聚合 管理
      400 Posts :: 0 Stories :: 296 Comments :: 0 Trackbacks
    Whether you love or loathe blogging, it has grown extremely popular. Many sites and applications that have been created for blogging in an attempt to fulfill this new demand. One such application is .Text, written by Scott Watermasysk.

    By default .Text uses SQL Server for its database back end. However, .Text was designed with a provider model to support different database back ends. In 2003, John Kaster presented Delphi 8 to our local users group. Afterwards he issued a challenge, and I accepted. The challenge was to support InterBase with .Text. The result is blogs.borland.com and blogs.teamb.com.

    .Text provides two interfaces to make replaceable database backends possible.

    • Dottext.Framework.Data.IDbProvider
    • Dottext.Framework.Data.IDTOProvider

    Dottext.Framework.Data.IDbProvider

    This interface defines approximately 65 methods needed to select, insert, update, and delete records for various tables in the database. Data is retrieved from select statements using standard ADO.NET Interfaces and classes. The IDataReader interface is returned for many of the select statements. The rest are returned in a DataSet.

    Dottext.Framework.Data.IDTOProvider

    For the most part .Text does not directly access data that is returned from a class that implements Dottext.Framework.Data.IDbProvider. Instead it calls a class that implements Dottext.Framework.Data.IDTOProvider, .Text provides a default implementation of this class which it uses for SQL Server called Dottext.Framework.Data.DataDTOProvider. It is responsible for taking the raw data and mapping it into objects that .Text has defined for each type of data.

    Implementing the Interfaces

    After converting the database schema to InterBase, (Minus the 60+ stored procedures that .Text has for its MS SQL Server implementation) I started by implementing a custom IDbProvider in Delphi for .NET. This provider Implemented all of the database calls with SQL statements instead of using stored procedures.

    One problem I ran into was the way .Text used several procedures that returned multiple cursors. The only way to duplicate this behavior for InterBase was to fill a DataSet using Multiple SQL Statements.


    var
    Cmd : BDPCommand;
    DA : BDPDataAdapter;
    ResultData : DataSet;
    begin
    ResultData := DataSet.Create;
    ...
    Cmd.CommandText := 'SELECT * FROM TABLEA';
    ...
    DA := BdpDataAdapter.Create(Cmd);
    DA.Fill(ResultData);
    DA.Free;
    ...
    Cmd.CommandText := 'SELECT * FROM TABLEB';
    ...
    DA := BdpDataAdapter.Create(Cmd);
    DA.Fill(ResultData.Tables.Add);
    DA.Free;
    ...
    end;

    I also created a new class that implemented the Dottext.Framework.Data.IDTOProvider using C#, to address data transformation issues. I used C# for this class as it was almost the same as the original one provided by .Text so I able to copy, rename, modify instead of writing it from scratch.

    Database Connections

    BDP does not currently implement connection pooling, so I needed a custom solution. For performance reasons I could not have each page request connecting to the database. Instead I opted to create a unique Database Connection per thread. With Delphi this was quite easy to do, we placed our connection variable in a threadvar section, then we always accessed our database connection through a function that would check to see if the database was created if it was not created it would create it.
    function BdpDataProvider.GetDbConnection: BdpConnection;
    begin
    if Not Assigned(FConnection) then
    FConnection := BdpConnection.Create(ConnectionString);
    end;

    The number of possible page request threads your ASP.NET application can have is partially controlled by how you have configured your system, and also is further controlled by how you have configured you application. The following article explains many of the details on how threading works in ASP.NET.

    Closing the BdpCommand

    When working BDP you must remember to always call close on the BdpCommand. SqlClient does not seem to have this requirement most of the original .Text DTO provider code never called close on the Command, but I have heard from other users of .Text that their servers might run more reliably if the commands were closed in the .Text code. During during the testing, I found myself on a bug hunt, making sure every command was closed.

    Specifically remember to call close in the correct order.

    BdpReader.Close;
    BdpCommand.Close;
    BdpConnection.Close;

    Building the Code

    .Text was written with C# in Visual Studio 2003. My IDBProvider was written in Delphi for .NET. Initially, to compile the application, I had to first compile the .Text Solution in Visual Studio. Then I used Delphi 8 for .Net to compile the Provider. .Text does not know about the Delphi Assembly at compile time: it dynamically loads the provider using a value stored in the web.config file. Initially, I was unsure of what to expect when debugging my Delphi Assembly when a Visual Studio application was the main project. I found out that as long as I include debug information, it is possible to step through your Delphi code in Visual Studio.

    Now that Delphi 2005 that combines both Delphi and C#, we were able to use the Visual Studio project Import wizard to import the existing projects. After setting up all the projects into a single Project Group and I am able to compile the entire blogging application inside Delphi, with no need to use Visual Studio at all on the project.

    In addition to writing a custom provider, I modified the security system in .Text so that Borland Employees can use their BDN account to administer their .Text blogs, instead of having another user id/password to maintain. Currently this is done by modifying security.cs from the .Text code base, but I hope to change this to be a provider-based model similar to the database provider model in use now.

    Feedback intelligence

    If you are logged into BDN when you submit feedback, your name will auto-populate with your BDN account information. In the future, the feedback may be changed to require that you log into your BDN account to comment, if comment spam becomes a problem as it has for some other popular blog servers.

    Complete interoperability

    During this exercise, I was able to prove to myself that Delphi is a first class citizen in the world of the .Net framework. It was able to work in a mixed language environment with out any problems. I also found that BDP is a good database solution that implements the ADO.NET interfaces correctly.

    Robert Love - http://peakxml.com (My personal blog)

    Side Note: If you are Delphi user interested in creating a technical blog for yourself, visit blogs.slcdug.org. we still have enough bandwidth for quite a few more active bloggers.


    NOTE: The views and information expressed in this document represent those of its author(s) who are solely responsible for its content. Borland does not make or give any representation or warranty with respect to such content.

    posted on 2006-01-10 22:14 jinfeng_wang 閱讀(638) 評(píng)論(0)  編輯  收藏 所屬分類: .Net
    主站蜘蛛池模板: 日本亚洲免费无线码| 最新中文字幕电影免费观看| 亚洲av日韩aⅴ无码色老头| 久久精品国产精品亚洲色婷婷| 日韩高清免费观看| 五月亭亭免费高清在线| 免费无码又爽又刺激一高潮| 污网站在线观看免费| 亚洲色www永久网站| 亚洲一二成人精品区| 亚洲精品无码AV人在线播放| 免费成人在线观看| 成人黄页网站免费观看大全| 6080午夜一级毛片免费看6080夜福利 | 亚洲va无码va在线va天堂| 凹凸精品视频分类国产品免费| 拨牐拨牐x8免费| 可以免费看的卡一卡二| 精品无码无人网站免费视频| 国内精品免费视频精选在线观看| 国产大陆亚洲精品国产| 自拍偷自拍亚洲精品播放| 亚洲国产精品无码观看久久| 亚洲中文字幕久久无码| 亚洲av无码国产综合专区| 91亚洲精品视频| 亚洲自偷自拍另类图片二区| 99人中文字幕亚洲区| 亚洲AV无码国产在丝袜线观看| 亚洲色婷婷综合久久| 亚洲综合av永久无码精品一区二区 | 午夜亚洲www湿好大| 亚洲韩国精品无码一区二区三区 | 美女被免费视频网站a| 337P日本欧洲亚洲大胆精品| 亚洲啪AV永久无码精品放毛片| 91在线亚洲综合在线| 亚洲欧美成人av在线观看| 亚洲欧美日本韩国| 日本亚洲中午字幕乱码| 羞羞的视频在线免费观看|