?? unit1.pas
字號(hào):
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB, Grids, DBGrids, MPlayer, OleCtrls,
PLAYCLIENTLib_TLB, ComCtrls, ExtCtrls, WMPLib_TLB,inifiles, Mask, DBCtrls,
Menus, Buttons,Winsock, ActnList,StrUtils, MONITORCLIENTLib_TLB;
const
CM_RESTORE=WM_USER + $1000; {自定義的“恢復(fù)”消息}
MYAPPNAME='VLAN錄音記錄監(jiān)督臺(tái)';
ScreenWidth: LongInt = 800; {I designed my form in 800x600 mode.}
ScreenHeight: LongInt = 600;
type
TFooClass = class(TControl); { needed to get at protected }
{ font property }
TForm1 = class(TForm)
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
ADOConnection1: TADOConnection;
GroupBox2: TGroupBox;
DBGrid1: TDBGrid;
GroupBox3: TGroupBox;
PlayClient1: TPlayClient;
DBEdit1: TDBEdit;
StatusBar1: TStatusBar;
PopupMenu1: TPopupMenu;
DBEdit2: TDBEdit;
N1: TMenuItem;
DBEdit3: TDBEdit;
GroupBox4: TGroupBox;
Lb_StartTime: TLabel;
Lb_EndTime: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
CB_Agent: TCheckBox;
CB_CallerID: TCheckBox;
CB_DTMF: TCheckBox;
CB_PhoneNum: TCheckBox;
CB_TimeArea: TCheckBox;
GroupBox5: TGroupBox;
Btn_Close: TBitBtn;
Btn_Query: TBitBtn;
Edit4: TEdit;
DateTimePicker1: TDateTimePicker;
DateTimePicker2: TDateTimePicker;
PopupMenu2: TPopupMenu;
N2: TMenuItem;
PopupMenu3: TPopupMenu;
N3: TMenuItem;
DBEdit4: TDBEdit;
DateTimePicker3: TDateTimePicker;
DateTimePicker4: TDateTimePicker;
ADOQuery2: TADOQuery;
N4: TMenuItem;
N5: TMenuItem;
ActionList1: TActionList;
saveas: TAction;
SaveDialog1: TSaveDialog;
RBAccess: TRadioButton;
RBFireBird: TRadioButton;
CB_RecordLength: TCheckBox;
RBB: TRadioButton;
RBE: TRadioButton;
RBS: TRadioButton;
Edit5: TEdit;
CB_Channel: TCheckBox;
Edit6: TEdit;
WindowsMediaPlayer1: TWindowsMediaPlayer;
MonitorClient1: TMonitorClient;
ComboBox1: TComboBox;
CheckBox1: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure DBGrid1DblClick(Sender: TObject);
procedure PlayClient1ConnectHost(Sender: TObject; Success: Integer);
procedure PlayClient1LoadFileComplete(Sender: TObject;
const WaveFileName: WideString);
procedure WindowsMediaPlayer1PlayStateChange(Sender: TObject;
NewState: Integer);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure N1Click(Sender: TObject);
procedure Btn_CloseClick(Sender: TObject);
procedure CB_AgentClick(Sender: TObject);
procedure CB_CallerIDClick(Sender: TObject);
procedure CB_DTMFClick(Sender: TObject);
procedure CB_PhoneNumClick(Sender: TObject);
procedure CB_TimeAreaClick(Sender: TObject);
procedure Btn_QueryClick(Sender: TObject);
procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
procedure N2Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure DBGrid1CellClick(Column: TColumn);
procedure DBGrid1TitleClick(Column: TColumn);
procedure saveasExecute(Sender: TObject);
procedure PlayClient1QueryRecordCount(Sender: TObject; RecordCount,
StartDate, EndDate, StartID: Integer);
procedure CB_RecordLengthClick(Sender: TObject);
procedure CB_ChannelClick(Sender: TObject);
procedure PlayClient1VocFileLength(Sender: TObject;
const VocFileName: WideString; VocFileLength: Integer);
procedure FormResize(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure MonitorClient1MonitorPlay(Sender: TObject;
const HostName: WideString; ChannelNO: Smallint;
PlayKBytes: Integer);
procedure ComboBox1Change(Sender: TObject);
private
{ Private declarations }
FSort,FSortField:String;//控制grid排序
Procedure SearchData(sid,sType:string);
Procedure ApplicationEvents1Message(var Msg: tagMSG;
var Handled: boolean);
Function GetIP(Name:string):String;
Function SQLStrComb(dbtype:string):String;
Procedure iniRead;
Procedure iniLanguage;
Procedure getsourceCtrl;
public
{ Public declarations }
procedure CreateParams(var Params: TCreateParams); override;
Procedure RestoreRequest(var message: TMessage); message CM_RESTORE;
Procedure showParam(sStr:string);
end;
var
Form1: TForm1;
implementation
uses Splash, Save2;
procedure TForm1.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.WinClassName := MYAPPNAME;
end;
procedure TForm1.RestoreRequest(var message: TMessage);
//var
// P:Array [0..255] of char;
// i:integer;
// s:string;
begin
{GlobalGetAtomName(message.LParam, P,sizeof(P));
for i:=0 to 255 do
begin
if P[i]=#0 then break;
s :=s+P[i];
end;
}
if IsIconic(Application.Handle) then
Application.Restore
else
Application.BringToFront;
// showParam(s);
end;
{$R *.dfm}
var
sConnect:string;
sSql:string;
sSqlUpI:string;
sSqlUpU:string;
sVlanDsn:string;
sHostFileName:string;
sLocalFileName:string;
sIP:string;
sSqlType:string;
sPos:integer;
sRewind:string;
iniFileName:string;
myinifile:TInifile;
// sDateTimeType:string;
sSaveAs,sSaveFileName:String;
sDefaultDB:string;
sLanguage:String;
x1,y1,iControlcount:integer;
cl,ct,cw,ch:array [0..43] of real;//數(shù)組上限由可視控件數(shù)目而定
//語(yǔ)言參數(shù)
sNoData, // =沒(méi)有查到數(shù)據(jù)!
sNoRecord, // =無(wú)記錄
sRecords, // =記錄數(shù):
sTryToConnect, // =嘗試連接編號(hào):
sCannotConect, // =無(wú)法獲得主機(jī)IP,無(wú)法收聽(tīng)錄音
sStartConnect, // =開(kāi)始連接主機(jī):
sConnectFail, // =連接主機(jī)s%失敗
sGettingFile, // =獲取錄音文件中...
sSaveFileSuccess, // =文件保存成功
sGetFileSuccess, // =文件獲取成功
sCurrentPlayID, // =當(dāng)前播放編號(hào):
sGettingIP, // =獲取IP中...
sInputChannelNo, // =請(qǐng)輸入軌道編號(hào)!
sInputRecordLength, // =請(qǐng)輸入錄音時(shí)長(zhǎng)!
sEndTimeBiggerStarttime, // =結(jié)束時(shí)間不能小于開(kāi)始時(shí)間!
sPleaseSelectQueryParm,//=請(qǐng)選擇條件!
sMoreThen1k,//=查詢的記錄超過(guò)1000條,是否細(xì)化條件后繼續(xù)查詢?
sinfo,//=提示
sFileCopy,//=文件復(fù)制
sFileNotExist,
sPlayOnebyOne,sBtn_OK, sQuerying:string;//=文件不存在
//
procedure TForm1.showParam(sStr:string);
begin
// label1.Caption := sStr;
//SearchData(sStr,sSqlType);
end;
procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin
Application.OnMessage:=ApplicationEvents1Message;
//getsourceCtrl;
self.Caption := MYAPPNAME;
sSaveAs:='0';
sLocalFileName:= ExtractFilePath(Application.ExeName)+'temp.wav';
//ini文件讀取
iniRead;
//初始化空間語(yǔ)言類(lèi)型
iniLanguage;
//打開(kāi)數(shù)據(jù)庫(kù)
ADOConnection1.ConnectionString :=sConnect;
Try
// ADOConnection1.Connected := true;
except
// Showmessage('aa');
end;
//設(shè)置mediaplayer位置
// WindowsMediaPlayer1.Width :=781;
// WindowsMediaPlayer1.Top :=8;
// WindowsMediaPlayer1.Height :=65;
///界面大小
{scaled:=true;
if (screen.width<>orignwidth) then
begin
height:=longint(height)*longint
(screen.height) div orignheight;
width:=longint(width)*longint
(screen.width) div orignwidth;
scaleby(screen.width , orignwidth);
// scaleby(screen.height , orignheight);
Form1.Height := height-50;
Form1.Width := Width-10;
Form1.Top := 1;
Form1.Left := 1;
end;
}
scaled := true;
if (screen.width <> ScreenWidth) then
begin
height := longint(height) * longint(screen.height) div ScreenHeight;
width := longint(width) * longint(screen.width) div ScreenWidth;
scaleBy(screen.width, ScreenWidth);
end;
for i:=ControlCount-1 downto 0 do
TFooClass(Controls[i]).Font.Size:=(screen.width div 800)* TFooClass(Controls[i]).Font.Size;
End;
Procedure TForm1.SearchData(sid,sType:string);
var
StrLen:integer;
snewSql:String;
begin
StrLen:=Length(sSql);
Adoquery1.SQL.Clear ;
sNewSql:=sSql;
//判斷配置文件中是否有#號(hào),如果有,則代表sql中需要引號(hào)隔離變量
if sSqlType = '1' then
begin
Delete(snewSql,sPos,StrLen);
sNewSql:=sNewSql +''''+ sid + '''';
end
else
sNewSql:=sSql+Sid;
try
Adoquery1.SQL.Add(sNewSql );
Adoquery1.Active := true;
if Adoquery1.RecordCount <= 0 then
begin
Form2.Hide;
Form2.Update;
Showmessage(sNoData);
StatusBar1.Panels[2].Text :=sNoRecord;
dbgrid1.Enabled := false;
StatusBar1.Panels[1].Text :=' ';
exit;
end
else
begin
DbGrid1.Enabled :=True;
//DBGrid1.Columns[0].Title.Caption := '編號(hào)';
//DBGrid1.Columns[1].Title.Caption := '軌道號(hào)';
//DBGrid1.Columns[2].Title.Caption := '來(lái)電號(hào)碼';
//DBGrid1.Columns[3].Title.Caption := '坐席名稱(chēng)';
//DBGrid1.Columns[4].Title.Caption := '分機(jī)號(hào)碼';
//DBGrid1.Columns[5].Title.Caption := '電話按鍵';
//DBGrid1.Columns[6].Title.Caption := '開(kāi)始時(shí)間';
//DBGrid1.Columns[7].Title.Caption := '結(jié)束時(shí)間';
//DBGrid1.Columns[8].Title.Caption := '錄音總長(zhǎng)';
//DBGrid1.Columns[9].Title.Caption := '文件名';//DBGrid1.Columns[6].Title.Caption ;
adoquery1.First ;
StatusBar1.Panels[2].Text :=sRecords+inttostr(adoquery1.RecNo)+'/' +inttostr(Adoquery1.RecordCount);
end;
except
Form2.Update;
Form2.Free;
Btn_Query.Enabled := true;
exit;
end;
end;
procedure TForm1.DBGrid1DblClick(Sender: TObject);
begin
//雙擊直接播放
if ( Adoquery1.Active = false ) or ( Adoquery1.RecordCount <=0 ) then exit;
WindowsMediaPlayer1.URL :='';
StatusBar1.Panels[2].Text :=sRecords+inttostr(adoquery1.RecNo)+'/' +inttostr(Adoquery1.RecordCount);
StatusBar1.Panels[0].Text :=sTryToConnect+dbedit2.text;
//sIP:=GetIP(DBedit3.Text ); //host ip
if trim(sIP) = '' then
begin
StatusBar1.Panels[1].Text :=sCannotConect;
exit;
end;
StatusBar1.Panels[1].Text :=sStartConnect+sIP;
playclient1.ConnectHost(sIP,sVlanDsn);
end;
procedure TForm1.PlayClient1ConnectHost(Sender: TObject; Success: Integer);
begin
if Success = 0 then
begin
// PlayClient1.DisconnectHost ;
// Playclient1.Handle ;
Dbgrid1.Cursor :=crDefault;
if sSaveAs='1' then
begin
Form3.Label1.Caption :=Format(sConnectFail,[sIP]);
//Form3.Show;
Form3.Update;
Form3.BitBtn1.Caption :=sBtn_OK;
Form3.BitBtn1.Visible := true;
end;
StatusBar1.Panels[1].Text :=Format(sConnectFail,[sIP]);
exit;
end;
StatusBar1.Panels[1].Text :=sGettingFile;
sHostFileName := trim( dbedit1.Text );
if sSaveAs = '1' then
begin
Form3.Label1.Caption :=sGettingFile;
//Form3.Show;
Form3.Update;
if (VarToStr(playclient1.GetVoiceFile(sHostFileName,sSaveFileName))) = '-1' then
StatusBar1.Panels[1].Text :=sGettingFile;
end
else
begin
if (VarToStr(playclient1.GetVoiceFile(sHostFileName,sLocalFileName))) = '-1' then
StatusBar1.Panels[1].Text :=sGettingFile;
end;
end;
procedure TForm1.PlayClient1LoadFileComplete(Sender: TObject;
const WaveFileName: WideString);
begin
if sSaveAs='1' then
begin
Form3.Label1.Caption :=sSaveFileSuccess;
//Form3.ShowModal;
Form3.Update;
Form3.Free ;
Dbgrid1.Cursor :=crDefault;
StatusBar1.Panels[1].Text :=sSaveFileSuccess;
sSaveAs:='0';
end
else
begin
StatusBar1.Panels[1].Text :=sGetFileSuccess;
windowsMediaplayer1.URL :=sLocalFileName;
StatusBar1.Panels[0].Text :=sCurrentPlayID+DbEdit2.Text ;
WindowsMediaplayer1.controls.play ;
end;
end;
procedure TForm1.WindowsMediaPlayer1PlayStateChange(Sender: TObject;
NewState: Integer);
begin
if NewState = 1 then
begin
if sRewind = '1' then
begin
adoquery1.Next;
while not adoquery1.Eof do
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -