uFolderContentExample.pas
2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
unit uFolderContentExample;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uKtwsapi, uWebService, ImgList, ComCtrls, StdCtrls;
type
TFolderContentExample = class(TForm)
tvFolderList: TTreeView;
ImageList4: TImageList;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure tvFolderListCollapsed(Sender: TObject; Node: TTreeNode);
procedure tvFolderListExpanded(Sender: TObject; Node: TTreeNode);
private
{ Private declarations }
FIsPopulating: Boolean;
procedure PopulateTreeView(items: kt_folder_items;
parent: TTreeNode; tv: TTreeView);
public
{ Public declarations }
end;
var
FolderContentExample: TFolderContentExample;
UserName, Password: String;
implementation
{$R *.dfm}
procedure TFolderContentExample.Button1Click(Sender: TObject);
var
ktapi: TKTWSAPI;
folder: TKTWSAPI_Folder;
contents: kt_folder_contents;
begin
if FIsPopulating then Exit;
Screen.Cursor := crHourglass;
FIsPopulating := True;
ktapi := TKTWSAPI.Create;
try
ktapi.SetDownloadPath(ExtractFileDir(Application.ExeName));
ktapi.StartSession(UserName,Password);
folder:= ktapi.GetRootFolder;
try
contents := folder.GetListing(10);
try
PopulateTreeView(contents.items, nil, tvFolderList);
finally
contents.Free;
end;
finally
folder.Free;
end;
ktapi.Logout;
finally
ktapi.Free;
Screen.Cursor := crDefault;
FIsPopulating := False;
end;
end;
procedure TFolderContentExample.PopulateTreeView(items: kt_folder_items; parent: TTreeNode;
tv: TTreeView);
var
I: Integer;
node: TTreeNode;
it: kt_folder_item;
begin
for I := 0 to Length(items) - 1 do
begin
it := items[i];
if it.item_type <> 'F' then Continue;
node := tv.Items.AddChild(parent, it.title);
node.ImageIndex := 0;
node.Data := it;
if (Length(it.items) > 0) then
PopulateTreeView(it.items, node, tv);
end;
end;
procedure TFolderContentExample.tvFolderListCollapsed(Sender: TObject;
Node: TTreeNode);
begin
Node.ImageIndex := 0;
end;
procedure TFolderContentExample.tvFolderListExpanded(Sender: TObject;
Node: TTreeNode);
begin
Node.ImageIndex := 1;
end;
initialization
UserName := 'xxxx';
Password := 'xxxx';
uktwsapi.KTWebServerUrl := 'http://ktdms.trunk';
uktwsapi.KTWebServiceUrl := uktwsapi.KTWebServerUrl+'/ktwebservice/webservice.php?wsdl';
uktwsapi.KTUploadUrl := uktwsapi.KTWebServerUrl+'/ktwebservice/upload.php';
end.