DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: mynk
今日帖子: 31
在线用户: 14
导航: 论坛 -> 文档资料 斑竹:liumazi,ruralboy  
作者:
男 jopher3 (樵夫的马六甲) ▲▲▲▲▲ -
普通会员
2014/4/8 22:37:46
标题:
用AppMethod/XE5UP2实现移动超级终端 浏览:4133
加入我的收藏
楼主: 1、概述
   作为网管,假如能拿着手机维护你千里之外的服务器的话,是不是很爽?
   有了Delphi XE5、AppMethod,我们就可以与QuickBurro结合,轻松做一个“移动超级终端”工具

先看设计期界面:
此帖子包含附件:
JPEG 图像
大小:61.2K
----------------------------------------------
樵夫的大马甲
作者:
男 jopher3 (樵夫的马六甲) ▲▲▲▲▲ -
普通会员
2014/4/8 22:38:31
1楼: 2、再来看代码和运行效果:

unit main;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Edit,
  FMX.StdCtrls, FMX.Layouts, FMX.Memo, mbcommon, MBConnection, MBParcel,
  FMX.Objects;

type
  TForm1 = class(TForm)
    StyleBook1: TStyleBook;
    ToolBar1: TToolBar;
    ToolBar2: TToolBar;
    Memo1: TMemo;
    Button1: TButton;
    Button2: TButton;
    MBConn: TMBConnection;
    RPC: TMobileRPC;
    Timer1: TTimer;
    Panel1: TPanel;
    Label1: TLabel;
    Edit1: TEdit;
    Button4: TButton;
    Line1: TLine;
    Label2: TLabel;
    Label3: TLabel;
    Edit2: TEdit;
    Edit3: TEdit;
    Button3: TButton;
    Button5: TButton;
    function CreateDos(): boolean;
    function FreeDos(): boolean;
    function ExecCommand(aCommand: string): boolean;
    function ReadPrompt(): string;
    procedure Button3Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure FormResize(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

//
// RPC,创建DOS频道...
function TForm1.CreateDos(): boolean;
var
   InParcel,OutParcel: TMBParcel;
begin
   InParcel:=TMBParcel.create;
   InParcel.PutIntegerGoods('FunctionId',1);
   InParcel.PutStringGoods('CallerId',MBConn.WebSessionId);
   OutParcel:=TMBParcel.create;
   result:=rpc.Call('mobile/mbdos.asq',inparcel,outparcel);
   if result then
      result:=OutParcel.GetBooleanGoods('ProcessResult');
   FreeAndNil(InParcel);
   FreeAndNil(OutParcel);
end;

//
// RPC,释放DOS频道...
function TForm1.FreeDos(): boolean;
var
   InParcel,OutParcel: TMBParcel;
begin
   InParcel:=TMBParcel.create;
   InParcel.PutIntegerGoods('FunctionId',4);
   InParcel.PutStringGoods('CallerId',MBConn.WebSessionId);
   OutParcel:=TMBParcel.create;
   result:=rpc.Call('mobile/mbdos.asq',inparcel,outparcel);
   if result then
      result:=OutParcel.GetBooleanGoods('ProcessResult');
   FreeAndNil(InParcel);
   FreeAndNil(OutParcel);
end;

//
// RPC,读DOS回显信息...
function TForm1.ReadPrompt(): string;
var
   InParcel,OutParcel: TMBParcel;
   ok: boolean;
begin
   InParcel:=TMBParcel.create;
   InParcel.PutIntegerGoods('FunctionId',3);
   InParcel.PutStringGoods('CallerId',MBConn.WebSessionId);
   OutParcel:=TMBParcel.create;
   ok:=rpc.Call('mobile/mbdos.asq',inparcel,outparcel);
   if ok then
      ok:=OutParcel.GetBooleanGoods('ProcessResult');
   if ok then
      result:=OutParcel.GetStringGoods('Prompt')
   else
      result:='';
   FreeAndNil(InParcel);
   FreeAndNil(OutParcel);
end;

//
// RPC,发送DOS命令...
function TForm1.ExecCommand(aCommand: string): boolean;
var
   InParcel,OutParcel: TMBParcel;
begin
   InParcel:=TMBParcel.create;
   InParcel.PutIntegerGoods('FunctionId',2);
   InParcel.PutStringGoods('CallerId',MBConn.WebSessionId);
   InParcel.PutStringGoods('DosCommand',aCommand);
   OutParcel:=TMBParcel.create;
   result:=rpc.Call('mobile/mbdos.asq',inparcel,outparcel);
   if result then
      result:=OutParcel.GetBooleanGoods('ProcessResult');
   FreeAndNil(InParcel);
   FreeAndNil(OutParcel);
end;

//
// 定时器,用于循环读信息...
procedure TForm1.Timer1Timer(Sender: TObject);
var
   tmpstr: string;
begin
   timer1.Enabled:=false;
   tmpstr:=ReadPrompt;
   if tmpstr<>'' then
      memo1.Lines.Text:=memo1.Lines.Text+tmpstr;
   timer1.Enabled:=true;
end;

//
// 自适应屏幕...
procedure TForm1.FormResize(Sender: TObject);
begin
   edit1.width:=button4.Position.X-6-edit1.Position.X;
   edit3.width:=button3.Position.X-6-edit3.Position.X;
end;

//
// 退出...
procedure TForm1.Button2Click(Sender: TObject);
begin
  if messagedlg('是否确认退出本测试程序?', TMsgDlgType.mtConfirmation, mbYesNo,0)<>mrYes then
     exit;
   mbconn.disconnect;
   halt;
end;

//
// 连接、断开...
procedure TForm1.Button3Click(Sender: TObject);
begin
   if Button3.Text='连接' then
      begin
         mbconn.Host:=trim(edit2.Text);
         mbconn.Port:=strtoint(edit3.Text);
         if mbconn.connect then
          begin
          Button3.Text:='断开';
          if CreateDos then
          begin
          memo1.Lines.Clear;
          Timer1Timer(nil);
          end
          else
          memo1.Lines.Add('创建远程DOS频道失败!');
          end
         else
          memo1.Lines.Add('连接应用服务器失败!');
      end
   else
      begin
         FreeDOS;
         memo1.Lines.Add('');
         memo1.Lines.Add('远程DOS频道关闭啦!');
         timer1.Enabled:=false;
         mbconn.disconnect;
         Button3.Text:='连接';
         memo1.Lines.Add('与应用服务器断开啦!');
      end;
end;

//
// 执行一个Dos命令...
procedure TForm1.Button4Click(Sender: TObject);
begin
   ExecCommand(trim(edit1.Text));
   if stricomp('CLS',pchar(trim(edit1.Text)))=0 then
      memo1.Lines.Clear;
   edit1.Text:='';
end;

//
// 清屏...
procedure TForm1.Button5Click(Sender: TObject);
begin
   memo1.Lines.Clear;
end;

end.
此帖子包含附件:
JPEG 图像
大小:99.1K
----------------------------------------------
樵夫的大马甲
作者:
男 ande (ande) ★☆☆☆☆ -
盒子活跃会员
2014/4/9 8:41:59
2楼: 砍柴的!牛人一個!
----------------------------------------------
支持 Delphi
作者:
男 doorkey (DoorKey) ★☆☆☆☆ -
盒子活跃会员
2014/4/9 8:57:07
3楼: 关键是这东西搞出来的体积大得吓死人了
----------------------------------------------
QQ: 9717005 我的Blog:http://www.cnblogs.com/anydelphi/
作者:
男 wang_80919 (Flying Wang) ★☆☆☆☆ -
普通会员
2014/4/9 9:45:28
4楼: 楼上的已经被吓死了,不能算人了。只能算鬼。
----------------------------------------------
(C)(P)Flying Wang
作者:
男 suker0917 (苏克) ▲▲▲▲△ -
普通会员
2015/2/5 9:16:31
5楼: 没源码下载?  mbcommon, MBConnection, MBParcel是自己写的控件 ?还是在那里可以下载
----------------------------------------------
-
作者:
男 guistory (鬼故事) ▲▲▲▲▲ -
普通会员
2015/2/5 9:26:40
6楼: 砍柴的就是AD狂人
----------------------------------------------
-
作者:
男 jopher3 (樵夫的马六甲) ▲▲▲▲▲ -
普通会员
2015/2/5 9:26:54
6楼: 来哉来哉

mbcommon.pas是quickburro移动开发包中的公共函数单元
mbconnection是quickburro移动开发包中的基本连接控件
mbparcel是quickburro移动开发包中的容器类

所以,下载解包quickburro,在fmxsdk目录或apmsdk目录下,就能找到它们。当然,它们需要quickburro中间件的支持才能用,否则没意义。
----------------------------------------------
樵夫的大马甲
作者:
男 jopher3 (樵夫的马六甲) ▲▲▲▲▲ -
普通会员
2015/2/5 9:28:56
7楼: 俺是广告狂营,也是创意大湿 :>
----------------------------------------------
樵夫的大马甲
作者:
男 allegrox (有点坏) ★☆☆☆☆ -
普通会员
2015/2/5 10:18:43
8楼: 其实,这是一个软广告按此在新窗口浏览图片
----------------------------------------------
-
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行117.1875毫秒 RSS