?? djsscx.pas.bak
字號:
unit DjSSCx;
interface
uses
SysUtils, Classes,DjBase,DjCBase,PubProc,uRecordcenter;
type
//涉及到兩個通道時的操作
TOnLinkEvent = procedure(Sender:TObject;ChannelID1,ChannelID2:integer) of object;
//內線摘機操作
TOnHookUpEnvent = procedure(Sender:TObject;ChannelID:integer) of object ;
//外線呼入時
TOnDialInEvent = procedure(Sender:TObject;ChannelID:integer) of object ;
//按鍵時
TOnDTMFHitEvent = procedure(sender:TObject;ChannelID:integer;DTMFNum:string) of object;
//異常時
TOnDjExceptionEvent = procedure(Sender:TObject;ChannelID:integer;ErrorCode:integer;ErrorType:integer = 0) of object;
TOnDjErrorEvent = procedure(Sender:TObject;ChannelID1,ChannelID2:integer;ErrorCode:integer) of object;
TOnKeepEvent = procedure(Sender:TObject;KeepChnlID:integer;KeepResult:Integer) of object ;
TBeforeGetKeepEvent = procedure(Sender:TObject;GetChnlID,KeepChnlID:integer) of object ;
TOnGetKeepEvent = procedure(Sender:TObject;GetChnlID,KeepChnlID:integer;KeepResult:Integer) of object ;
TOnThreeEvent = procedure(Sender:TObject;ChnlID1,ChnlID2,ChnlID3:integer) of object;
TOnRecordEvent = procedure(Sender:TObject;Chnlid1,ChnlID2:integer;RecordFile:string) of object;
TOnPlayFileBeginEvent=procedure(Sender:Tobject;ChnlID:integer;FileName:string) of object;
TOnPlayFileEndEvent = procedure(Sender:Tobject;ChnlID:integer) of object;
TDjSSCx = class(TDjCBase)
private
{ Private declarations }
FRecorded :boolean;
FFirstOutNum :Shortstring;
FFirstInNum :Shortstring;
FSubPhoneLength:Integer;
FPreDialNum:Shortstring;
FIsMeet:boolean;
FChannelList :TChannelList ;
FRecordFilePath:Shortstring;
FPackRate :integer;
FOnHangUp:TOnLinkEvent; //掛機
FOnHookUp:TOnHookUpEnvent; //內線摘機
FOnDial:TOnDialInEvent ; //外線呼入
FOnDTMFHit:TOnDTMFHitEvent; //接收到按鍵
FOnException:TOnDjExceptionEvent ; //異常
FOnLink :TOnLinkEvent ; //連通兩條線路
FOnClearLink:TOnLinkEvent; //拆線
FOnDialIn:TOnLinkEvent ; //呼叫內線
FOnDialBusy:TOnLinkEvent; //被呼叫方忙
FOnDialError:TOnLinkEvent; //被呼叫號碼錯誤
FOnCallOut:TOnLinkEvent; //外線呼出
FOnCallBusy:TOnLinkEvent; //呼出外線忙
FOnCallError:TOnDjErrorEvent ; //呼出外線指定錯誤
FOnKeep :TOnKeepEvent; //當保持一個通道后
FBeforeGetKeep :TBeforeGetKeepEvent;//當取一個保持通道前
FOnGetKeep :TOnGetKeepEvent; //取一個保持通道后
FOnLinkThree:TOnThreeEvent; //開始三方后
FOnClearThree:TOnThreeEvent; //三方結束后
FOnRecord : TOnRecordEvent;
FOnPlayBegin:TOnPlayFileBeginEvent;
FOnPlayEnd:TOnPlayFileEndEvent ;
function InCallIn(Channel1, Channel2: PChannel):integer;overload;
function InCallIn(ChnlID1,ChnlID2:integer):integer;overload;
function InCallOut(Channel1, Channel2: PChannel;DialerPhone:string):integer;overload;
procedure GetKeepChannel(ChnlIn,ChnlOut:PChannel); overload;
function LinkThree(Channel1,Channel2:PChannel):integer;overload; //開始一個三方
function ClearThree(Channel1,Channel2:PChannel):integer;overload; //結束一個三方
procedure SetFilePath(FilePath:Shortstring);
procedure SetPackRate(aPackRate:Integer);
//procedure test;//取保持
protected
{ Protected declarations }
public
{ Public declarations }
//dfsaf:TChannelList
constructor Create(AOwner:TComponent);override;
destructor Destroy;override;
procedure SetSubPhone(ChannelID:integer;Phone:String);
procedure SetRecord(ChnlId,RecordChnlID:integer;RecordType:integer;IsAgc:boolean);
procedure SetRecordFilePath(RecordFilePath:string);
procedure SetUse(ChnlID:integer;IsUse:Boolean);
function StartDjMonitor:boolean;
procedure ReceiveDTMFHit(ChnlID:integer);
procedure HangUp(ChnlID:Integer); //掛機
procedure FeedRealRing(ChnlID:Integer);
procedure DialIn(OutChnlID,InChnlID:integer);
function CheckDTMFNum(DTMFNum:string):integer;
function InCallIn(ChnlID:Integer;DialPhone:String):integer;overload;
function CheckIdleChannelState(SubPhone:string):TChannelState;
procedure DefaultDial(ChnlID:integer;DTMFNum:string);
function InCallOut(ChnlID:integer):Integer;overload; //與外線建立連接,手工撥號
function InCallOut(Chnlid:integer;DTMFNum:String):integer;overload;//不建立連接,軟件送號碼
function InCallOut(Chnlid:integer;CallerPhone,DTMFNum:String):integer;overload;//不不建立連接,指定外線,軟件送號碼
procedure HangOff(ChnlID:Integer); //振鈴摘機坐席
procedure OffHook(ChnlID:Integer); //主動摘機坐席
procedure KeepChannel(ChnlID:Integer) ;overload;//保留來電
procedure KeepChannel(SubPhone:string) ;overload;//保留來電
procedure GetKeepChannel(ChnlInID:integer;DTMFNum:string); overload;//取保持
procedure GetKeepChannel(ChnlInID,ChnlOutID:integer); overload;//取保持
procedure GetKeepChannel(ChnlInPhone,ChnlOutPhone:string); overload;//取保持
function GetKeepChannel(KeepChannelList:Variant):integer;overload;//當前系統中保持的通道總數
function LinkThree(ChnlID1:integer;ChnlID2:integer):integer;overload; //開始一個三方
function LinkThree(ChnlID:integer;CallerPhone:string):integer;overload; //開始一個三方
function ClearThree(ChnlId:integer;CallerPhone:string):integer;overload; //結束一個三方
function ClearThree(ChnlId1:integer;ChnlID2:integer):integer;overload; //結束一個三方
procedure PlayFile(ChnlID:integer;FileName:string);
procedure StopPlayFile(ChnlId:integer);
procedure test;
published
{ Published declarations }
property FirstOutNum:Shortstring read FFirstOutNum write FFirstOutNum;
property FirstInNum :Shortstring read FFirstInNum write FFirstInNum ;
property SubPhoneLength:integer read FSubPhoneLength write FSubPhoneLength ;
property PreDialNum:Shortstring read FPreDialNum write FPreDialNum ;
property IsMeet:boolean read FIsMeet write FIsMeet;
property Recorded :boolean read FRecorded write FRecorded ;
property RecordFilepath:Shortstring Read FRecordFilePath write SetFilePath;
property PackRate :integer read FPackRate write SetPackRate;
property OnHangUp : TOnLinkEvent read FOnHangUp write FOnHangUp;
property OnHookUp : TOnHookUpEnvent read FOnHookUp write FOnHookUp ;
property OnDial : TOnDialInEvent read FOnDial write FOnDial ;
property OnDTMFHit:TOnDTMFHitEvent read FOnDTMFHit write FOnDTMFHit ;
property ChannelList :TChannelList read FChannelList write FChannelList ;
property OnException :TOnDjExceptionEvent read FOnException write FOnException;
property OnDialIn:TOnLinkEvent read FOnDialIn write FOnDialIn ;
property OnLink :TOnLinkEvent read FOnLink write FOnLink ;
property OnClearLink:TOnLinkEvent read FOnClearLink write FOnClearLink;
property OnDialBusy :TOnLinkEvent read FOnDialBusy write FOnDialBusy;
property OnDialError:TOnLinkEvent read FOnDialError write FOnDialError ;
property OnCallBusy :TOnLinkEvent read FOnCallBusy write FOnCallBusy ;
property OnCallError:TOnDjErrorEvent read FOnCallError write FOnCallError ;
property OnCallOut:TOnLinkEvent read FOnCallOut write FOnCallOut;
property OnKeep :TOnKeepEvent read FOnKeep write FOnKeep ;
property BeforeGetKeep:TBeforeGetKeepEvent read FBeforeGetKeep write FBeforeGetKeep;
property OnGetKeep:TOnGetKeepEvent read FOnGetKeep write FOnGetKeep;
property OnLinkThree:TOnThreeEvent read FOnLinkThree write FOnLinkThree;
property OnClearThree :TOnThreeEvent read FOnClearThree write FOnClearThree ;
property OnRecord:TOnRecordEvent read FOnRecord write FOnRecord;
property OnPlayBegin:TOnPlayFileBeginEvent read FOnPlayBegin write FOnPlayBegin ;
property OnPlayEnd:TOnPlayFileEndEvent read FOnPlayEnd write FOnPlayEnd;
end;
procedure Register;
implementation
uses tc08a32,DjTc081AC,uMeetingCenter, Math;
procedure Register;
begin
RegisterComponents('djbK', [TDjSSCx]);
end;
{ TDjSSCx }
constructor TDjSSCx.Create;
begin
inherited;
FPackRate := 0 ;
end;
destructor TDjSSCx.Destroy;
begin
inherited;
end;
procedure TDjSSCx.FeedRealRing(ChnlID: Integer);
begin
tc08a32.FeedRealRing(ChnlID);
end;
procedure TDjSSCx.HangUp(ChnlID: Integer);
var
Channel :PChannel;
begin
Channel := ChannelList.Items[ChnlID];
Channel.DialActor := MasterActor;
DjTc081.HangUp(Channel);
end;
procedure TDjSSCx.DialIn(OutChnlID, InChnlID:integer);
var
ChannelIn,ChannelOut: PChannel;
begin
ChannelIn := ChannelList.Items[InChnlID];
ChannelOut := ChannelList.Items[OutChnlID];
if Assigned(ChannelIn) and (ChannelIn.ChannelType = UserChannel) then
begin
if ChannelIn.State <> Idle then
begin
if Assigned(FOnDialBusy) then
FOnDialBusy(self,OutChnlID,InChnlID)
else
Self.HangUp(OutChnlID);
exit;
end;
end
else
begin
if Assigned(FOnDialError) then
FOnDialError(Self,OutChnlID,InChnlID)
else
Self.HangUp(OutChnlID);
exit;
end;
StartPlaySignal(OutChnlID,SIG_RINGBACK);//放回鈴
FeedRealRing(InChnlID); //給內線振鈴
ChannelIn.Ringing := true;
ChannelIn.State := Dailing;
ChannelIn.Step := 0;
ChannelIn.ConnectChannel.ConState := OneConnect;
ChannelIn.ConnectChannel.ConChnlId := OutChnlID ;
ChannelIn.ConnectChannel.CallActive :=false ;
ChannelIn.ConnectChannel.CallerPhone := ChannelOut.ConnectChannel.CallerPhone;
ChannelIn.ConnectChannel.Channeler := nil ;
ChannelOut.ConnectChannel.ConState := Ringing;
ChannelOut.ConnectChannel.ConChnlId := InChnlID;
ChannelOut.ConnectChannel.CallActive := false;
ChannelOut.ConnectChannel.Channeler := nil ;
ChannelOut.Step := 1001 ;
if Assigned(FOnDialIn) then
begin
FOnDialIn(self,OutChnlID,InChnlID);
end;
end;
procedure TDjSSCx.ReceiveDTMFHit(ChnlID: integer);
var
Channel:PChannel;
begin
//StartPlaySignal(ChnlID, SIG_DIALTONE);
Channel := ChannelList.Items[ChnlID];
case Channel.ChannelType of
UserChannel:
begin
StartPlaySignal(ChnlID, SIG_DIALTONE);
end;
TrunkChannel:
begin
Tc08a32.OffHook(ChnlID);
end;
end;
InitDtmfBuf(ChnlID);
Channel.Step := 100 ;
//Channel.state := occupy;
end;
procedure TDjSSCx.SetSubPhone(ChannelID: integer; Phone: String);
var
Channel:PChannel;
begin
Channel := ChannelList.items[ChannelID] ;
Channel.Phone := Phone ;
end;
function TDjSSCx.StartDjMonitor: boolean;
begin
if not Assigned(DjTc081) then
begin
DjTc081 := TDjTc081AC.Create(Self);
end;
DjTc081.InitRecordChannel; //錄音初始化
FChannelList := DjBase.ChannelList ;
if FIsMeet then
begin
if not Assigned(DjMC) then
begin
DjMC := TDjMeetingCenter.Create(Self);
end;
end;
if Recorded then
begin
if Not Assigned(RecordCenter) then
begin
RecordCenter := TRecordCenter.Create ;
RecordCenter.RecordPath := FRecordFilePath ;
end;
end;
end;
function TDjSSCx.CheckDTMFNum(DTMFNum: string): integer;
var
Channel:PChannel ;
SubPhone:string;
begin
result := 0 ;
if FFirstOutNum = FFirstInNum then
raise Exception.Create('內線與外線預撥號碼重復,不能區分內線/外線');
if DTMFNum = FirstOutNum then
Begin
Result := 1;
exit;
end;
if Length(DTMFNum) > Length(FFirstInNum) then
if copy(DTMFNum,1,length(FFirstInNum)) = FFirstInNum then
begin
SubPhone := copy(DTMFNum,length(FFirstInNum)+1,Length(DTMFNum)- Length(FFirstInNum));
Channel := ChannelList.GetChannelFromPhone(SubPhone);
if Assigned(Channel) then
Result := 2
else
if Length(DTMFNum) >= SubPhoneLength then
result := -1 ;
end
else
Result := -1;
end;
function TDjSSCx.InCallIn(ChnlID: Integer; DialPhone: String): integer;
var
Channel:PChannel;
SubPhone:string;
begin
SubPhone := copy(DialPhone,Length(FFirstInNum)+1,Length(DialPhone)-Length(FFirstInNum));
Channel := ChannelList.GetChannelFromPhone(SubPhone);
if not Assigned(Channel) then
Result := -6
else
if Channel.ChannelType <> UserChannel then
Result := -7
else
if Channel.State <> Idle then
begin
Result := -8;
if Assigned(FOnCallBusy) then
FOnCallBusy(Self,ChnlID,Channel.ChannelID)
else
Self.HangUp(ChnlID);
end
else
begin
if Assigned(FOnCallOut) then
FOnCallOut(self,ChnlID,Channel.ChannelID);
Result := InCallIn(ChannelList.Items[ChnlID],Channel);
end;
end;
function TDjSSCx.InCallIn(Channel1, Channel2: PChannel): integer;
var
ChnlID1,ChnlID2:integer;
begin
ChnlID1 := Channel1.ChannelID;
ChnlID2 := Channel2.ChannelID;
//////FeedRealRing(ChnlID2); 屏蔽
//Channel1.State := Calling ;
Channel1.ConnectChannel.ConState := OneConnect ;
Channel1.ConnectChannel.ConChnlId := ChnlID2 ;
Channel1.ConnectChannel.CallActive := false;
Channel1.ConnectChannel.CallerPhone := '';
Channel1.ConnectChannel.Channeler := Channel2 ;
Channel1.Step := 1001 ;
Channel1.CallActor := CallerActor;
Channel2.State := Dailing ;
Channel2.Ringing := True ;
Channel2.ConnectChannel.ConState := OneConnect ;
Channel2.ConnectChannel.ConChnlId := ChnlID1;
Channel2.ConnectChannel.CallActive := False;
Channel2.ConnectChannel.CallerPhone := Channel1.Phone;
Channel2.ConnectChannel.Channeler := Channel1 ;
Channel2.Step := 0 ;
Channel2.CallActor := DialerActor ;
if Assigned(FOnDialIn) then
FOnDialIn(Self,ChnlID1,ChnlID2);
//SetLink(ChnlID1,ChnlID2);
end;
function TDjSSCx.CheckIdleChannelState(SubPhone: string): TChannelState;
var
Channel:PChannel;
begin
Result := NotingState;
Channel := ChannelList.GetChannelFromPhone(SubPhone);
if Assigned(Channel) then Result := Channel.State;
end;
procedure TDjSSCx.DefaultDial(ChnlID:integer;DTMFNum: string);
var
ChannelIn:PChannel ;
ChannelOut:PChannel;
Caller :integer;
begin
//SeatRecord := //.GetSeatFromChnlID(ChannelID);
ChannelOut := ChannelList.Items[ChnlID];
case ChannelOut.ChannelType of
TrunkChannel:
begin
if Length(DTMFNum) <= SubPhoneLength then
begin
ChannelIn := ChannelList.GetChannelFromPhone(DTMFNum);
if ChannelIn = nil then
begin
if Length(DTMFNum) = SubPhoneLength then
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -