TEcoForumServices 类(繁体版4月15日博客)

来源:互联网 发布:淘宝开通淘金币 编辑:程序博客网 时间:2024/05/28 01:36
2007年05月16日 14:46:00

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-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.



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1611611


原创粉丝点击