用户操作
[留言]  [发消息]  [加为好友] 
订阅我的博客
XML聚合    FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
gordonliwei的公告
<div align='center'> <a href="http://liwei.csdn.net" target="_blank" > <img src='http://www.china-pub.com/main/sale/renwu/images/lw.gif' border=1 width=152></a> <br> <a href="http://www.china-pub.com/computers/common/info.asp?id=30782" target="_blank" alt="Delphi 2006 高效数据库程序设计——dbExpress篇"><img src='http://liwei.csdn.net/Img/delphi2006.jpg' border=1 width=152></a> <br> <a href="http://www.china-pub.com/computers/common/info.asp?id=34233" target="_blank" alt="Delphi 2006 高效数据库程序设计——dbExpress篇"><img src='http://www.china-pub.com/computers/ebook30001-35000/34233/zcover.jpg ' border=1 width=152></a> </div>
文章分类
    个人网站链接!
    博文视点读书热线(期书早知道)
    李维个人网站!
    存档

    原创  TEcoForumServices 类(繁体版4月15日博客) 收藏

    TEcoForumServices

     

    有位大陆的读者写信跟我说他在《Delphi MDA/DDA程序设计——使用ECO》一书的CD中找不到TEcoForumServices 类的源代码,虽然我记得我已经把整本书下的Source打包到CD中了,而且TEcoForumServices 是一个很简易的类.Anyway,如果有人也需要这个类的源代码,下面就是它完整的列表。

    unit EcoForumWrapperServices;

    interface

    uses System.Web, ECOForumWebAppDemo1EcoSpace, PECOForumUnit,
         Borland.Eco.Handles, Borland.Eco.ObjectRepresentation,
         System.Web.Security, Borland.Eco.Services;

    type
      TEcoForumServices = class
      private
        { Private Declarations }
      public
        class function CreateMemeber(mySpace :  Borland.Eco.Handles.EcoSpace) : ForumMember;
        class function getForumSite(objl : IObjectList) : ForumSite;
        class function MemberLogin(mySpace :  Borland.Eco.Handles.EcoSpace; const UserId : string; const sPassword : string) : ForumMember;
      end;

    implementation


    { TEcoForumServices }

    class function TEcoForumServices.CreateMemeber(mySpace :  Borland.Eco.Handles.EcoSpace): ForumMember;
    begin
      Result := ForumMember.Create(mySpace);
    end;

    class function TEcoForumServices.getForumSite(objl: IObjectList): ForumSite;
    var
      obj : System.Object;
    begin
      Result := HttpContext.Current.Session['ForumSite'] as ForumSite;

      if (Result = nil) then
      begin
        obj := objl[0].AsObject;
        Result := obj as ForumSite;
        HttpContext.Current.Session['ForumSite'] := Result;
      end;
    end;

    class function TEcoForumServices.MemberLogin(mySpace :  Borland.Eco.Handles.EcoSpace;
      const UserId, sPassword: string): ForumMember;
    const
      selectUser = 'ForumMember.allInstances->select( M | (M.Name = ''{0}'')  and  (M.Password = ''{1}'') )->First';
    var
      enPW : string;
      userOCL : string;
      OCLResult : IElement;
      oclService : IOclService;
    begin
      enPW := FormsAuthentication.HashPasswordForStoringInConfigFile(sPassword,'md5');
      oclService := mySpace.GetEcoService(typeof(IOclService)) as IOclService;
      userOCL := System.String.Format(selectUser,UserId,enPW);
      OCLResult := oclService.Evaluate(userOCL);
      Result := nil;
      if (OCLResult.GetAsCollection.Count <> 0) then
        Result := OCLResult.GetAsCollection.Item[0].AsObject as ForumMember;
      HttpContext.Current.Session['ForumMember'] := Result;
    end;

    end.

     

    发表于 @ 2007年05月16日 14:46:00 | 评论( loading... ) | 编辑| 举报| 收藏

    旧一篇:生日快乐,师大附中!(繁体版4月15日博客) | 新一篇:《Delphi MDA/DDA程序设计——使用ECO》一书已到台湾(繁体版4月16号博客)

    • 发表评论
    • 评论内容:
    •  
    Copyright © gordonliwei
    Powered by CSDN Blog