팩스번호를 여러개 약 (50개)이상을 입력하고 팩스를 걸어주면 자동으로 팩스번호를 하나씩
이동하면서 걸어주는 소스인데 어디가 이상이 있는지 잘걸다가
팩스를 걸지 못했는데도 팩스가 실패메세지를 리턴하지 않고 계속
포트만 장악을 하고다음번호로 넘어가지도 않아요.그래서 cancelfax명령으로
팩스를 끊으면 시스템이 다운됩니다. 이때의 상황이 awuser.pas의
procedure TDispThread.Execute;에 있는 repeat문이 빠져나오지 못하고
무한 루프를 돌아요. 이것이 확실한 문제인지는 모르겠으나
팩스를 다음번호로 넘어가게 할수있는 방법이 없을 까요?
다음번호로 팩스를 걸어부는 부분의 소스는 팩스가 finish이벤트를
발생하면 다음번호를 읽어 서 다음소스의sendfax함수를 호출합니다.
이함수에서 팩스번호를 읽어온 팩스번호를 sendfax컴포넌트에 입력하고
팩스를 보냄니다.
procedure Tallview.BitBtn1Click(Sender: TObject);는 팩스를 취소시키는
버튼입니다. 취소는 팩스의 상태를 체크할때 cancelstr와 cancelstart
변수를 검사하여 취소시킴니다.
procedure Tallview.CloseComPort;
begin
{stop port and modem}
if apdComPort1.Open then
begin
apdModem1.Started := False;
{if (AutoTrig <> 0) then begin
ComPort.RemoveTrigger(AutoTrig);
AutoTrig := 0;
end;}
apdComPort1.Open := False;
end;
end;
procedure Tallview.OpenComPort;
begin
CloseComPort;
{set port options}
//ComPort.ComNumber := strtoint(com);{StrToInt(Copy(Com, 4, Length(Com))); {!!.01}
{$IFNDEF Win32}
apdComPort1.DeviceLayer := Device;
{$ELSE}
apdComPort1.DeviceLayer := dlWin32;
{$ENDIF}
apdComPort1.TapiMode := tmOff;
try
apdComPort1.Open := True;
except
on EBadId do
end;
end;
//팩스
procedure Tallview.sendfax(number:string);
var
next, line, col6, col7, col8 : integer;
colstr : string;
begin
col6:=6; col7:=7; col8:=8;
{try
ApdSendFax1.CancelFax;
except
on EAccessViolation do
end;}
//ShowMessage('Fatal fax error: ' + ApdSendFax1.StatusMsg(ApdSendFax1.ErrorCode));
numm:=number;
if oneselect='1' then
begin
panel2.visible:=true;
label9.caption:='통화가 이루어졌읍니까?';
for next:=0 to 12 do
begin
line:=next;
colstr:=allview.stringgrid1.cells[line,0];
if dmform.delspace(colstr,length(colstr))='Tel1' then col6:=line else
if dmform.delspace(colstr,length(colstr))='Tel2' then col7:=line else
if dmform.delspace(colstr,length(colstr))='H.P' then col8:=line;
if stringgrid1.cells[col6,totcnt]=numm then
begin
scol:=col6;
srow:=totcnt;
end
else
if stringgrid1.cells[col7,totcnt]=numm then
begin
scol:=col7;
srow:=totcnt;
end
else
if stringgrid1.cells[col8,totcnt]=numm then
begin
scol:=col8;
srow:=totcnt;
end
end;
end
else
if oneselect='7' then
begin
yakallview.panel1.visible:=true;
if choice='4' then
begin
yakallview.label1.caption:='통화가 이루어졌읍니까?';
end
else
if choice='5' then
begin
yakallview.bitbtn5.visible:=false;
yakallview.bitbtn4.visible:=false;
yakallview.bitbtn9.visible:=false;
yakallview.label2.visible:=false;
yakallview.label1.caption:='팩스를 보내고 있읍니다.';
end;
if yakallview.stringgrid1.Cells[1,totcnt]=numm then
begin
scol:=1;
srow:=totcnt;
end
else
if yakallview.stringgrid1.Cells[4,totcnt]=numm then
begin
scol:=4;
srow:=totcnt;
end;
end
else
if oneselect='2' then
begin
for next:=3 to 10 do
begin
line:=next;
colstr:=allview.stringgrid2.cells[line,0];
if dmform.delspace(colstr,length(colstr))='팩스' then col6:=line;
end;
if stringgrid2.cells[col6,totcnt]=numm then
begin
srow:=totcnt;
end;
panel2.visible:=true;
bitbtn6.visible:=false;
bitbtn7.visible:=false;
bitbtn13.visible:=false;
label10.Visible:=false;
label9.caption:='팩스를 보내고 있읍니다.';
end;
timer1.enabled:=true;
ApdSendFax1.faxclass:=fcDetect;
//ApdSendFax1.DialRetryWait:=10;
//ApdSendFax1.DialWait:=40;
//Link to the status display
//ApdSendFax1.StatusDisplay := ApdFaxStatus1;
//ApdFaxStatus1.Fax := ApdSendFax1;
apdSendFax1.PhoneNumber:=number;
if (head=true) and (faxcnt=0)then
begin
{ ApdSendFax1.FaxFile:='';
ApdSendFax1.FaxFilelist.clear;
ApdSendFax1.FaxFilelist.add('c:\autocom\head.APF');
ApdSendFax1.FaxFilelist.add(filename);}
faxcnt:=1;
end;
//ApdSendFax1.FaxFile:=edit1.text;
//Send the fax
ApdSendFax1.StartTransmit;
//ApdSendFax1.dial;
end;
procedure Tallview.BitBtn3Click(Sender: TObject);
var
number, findcnt, strgrid, yakstrgrid : string;
next, next_1, line, col4, col5, col6, col7, col8, col9, col11, nn : integer;
colstr, headstr, filename : string;
begin
col4:=4; col5:=5; col6:=6; col7:=7; col8:=8; col9:=9; col11:=11;
timer6.Enabled:=false;
//enabledfalse;
//yakenabledfalse;
{if callch='' then
opencomport;}
if portbool=false then
begin
showmessage('포트 설정이 잘못되었읍니다.');
timer3.enabled:=false;
exit;
end;
cancelstr:='0';
cancelstart:='';
timer2.Enabled:=false;
if oneselect='1' then
begin
if callch='' then
opencomport;
for next:=0 to 12 do
begin
line:=next;
colstr:=stringgrid1.cells[line,0];
if dmform.delspace(colstr,length(colstr))='상태' then col11:=line else
if dmform.delspace(colstr,length(colstr))='Tel1' then col6:=line else
if dmform.delspace(colstr,length(colstr))='Tel2' then col7:=line else
if dmform.delspace(colstr,length(colstr))='H.P' then col8:=line;
end;
if (memo2.lines.count<1) then
begin
// messagedlg('통신 포트를 정확히 맞춰주세요.',mtinformation, [mbok],0);
enabledtrue;
closecomport;
exit;
end
else
begin
findcnt:=finddial(totcnt);
if (findcnt='false') or (totcnt>stringgrid1.rowcount) then
begin
//allview.ApdComPort1.open:=true;
for next:=1 to stringgrid1.rowcount-1 do
begin
line:=next;
strgrid:=stringgrid1.cells[col11,line];
if strgrid='No' then
begin
YNchoice:='';
allview.datajungri;
for next_1:=0 to 600000 do
begin
end;
// threeselect:='2';
// totcnt:=1;
// allview.datashow;
if messagedlg('전화걸기가 끝났읍니다. 통화가 안된 회원에게 전화를 하시겠읍니까?',mtinformation,[mbYes,mbNo],0)=mrYes then
begin
// showmessage('전화걸기가 끝났읍니다');
threeselect:='2';
totcnt:=1;
allview.datashow;
enabledtrue;
{ threeselect:='2';
totcnt:=1;}
bitbtn3.onclick(self);
exit;
end
else
begin
break;
end;
end;
end;
closecomport;
showmessage('전화걸기가 끝났읍니다');
totcnt:=stringgrid1.rowcount;
enabledtrue;
//{// showmessage('모든 회원에게 전화를 했읍니다.');
exit;
end//if findcnt='false' then
else
begin
if findcnt{finddial(totcnt)}='1' then
begin
number:=stringgrid1.cells[col6,totcnt];
enabledfalse;
bitbtn13.Enabled:=false;
tim:=0;
timer5.Enabled:=true;
if outphone<>'' then
number:=outphone+','+number;
dial(number);
end
else
if findcnt{finddial(totcnt)}='2' then
begin
number:=stringgrid1.cells[col7,totcnt];
enabledfalse;
bitbtn13.Enabled:=false;
tim:=0;
timer5.Enabled:=true;
if outphone<>'' then
number:=outphone+','+number;
dial(number);
end
else
if findcnt{finddial(totcnt)}='3' then
begin
number:=stringgrid1.cells[col8,totcnt];
enabledfalse;
bitbtn13.Enabled:=false;
tim:=0;
timer5.Enabled:=true;
if outphone<>'' then
number:=outphone+','+number;
dial(number);
end;
end;
end;// if (memo2.lines.count=0) then
end//if oneselect='1' then
else
if oneselect='2' then
begin
for next:=3 to 10 do
begin
line:=next;
colstr:=stringgrid2.cells[line,0];
if dmform.delspace(colstr,length(colstr))='상태' then col9:=line else
if dmform.delspace(colstr,length(colstr))='팩스' then col6:=line else
if dmform.delspace(colstr,length(colstr))='이름' then col4:=line else
if dmform.delspace(colstr,length(colstr))='업체명' then col5:=line;
end;
if (memo2.lines.count<1) then
begin
// messagedlg('통신 포트를 정확히 맞춰주세요.',mtinformation, [mbok],0);
enabledtrue;
closecomport;
exit;
end
else
begin
{if ApdSendFax1.FaxFile='' then
begin
showmessage('보낼 팩스화일을 입력하세요.');
enabledtrue;
exit;
end;}
findcnt:=finddial(totcnt);
if (findcnt='false') or (totcnt>stringgrid2.rowcount) then
begin
for next:=1 to stringgrid2.rowcount-1 do
begin
//allview.ApdComPort1.open:=true;
line:=next;
strgrid:=stringgrid2.cells[col9,line];
if strgrid='No' then
begin
YNchoice:='';
allview.datajungri;
for next_1:=0 to 600000 do
begin
end;
// threeselect:='2';
// totcnt:=1;
// allview.datashow;
if messagedlg('팩스걸기가 끝났읍니다. 팩스보내기에 실패한 회원에게 다시 보내시겠읍니까?',mtinformation,[mbYes,mbNo],0)=mrYes then
begin
// showmessage('팩스보내기가 끝났읍니다');
threeselect:='2';
totcnt:=1;
allview.datashow;
{threeselect:='2';
totcnt:=1;}
enabledtrue;
bitbtn3.onclick(self);
exit;
end
else
begin
break;
end;
end;
end;
closecomport;
showmessage('팩스보내기가 끝났읍니다');
totcnt:=stringgrid2.rowcount;
enabledtrue;
// showmessage('모든 팩스에게 보냈읍니다.');
exit;
end
else
if findcnt{finddial(totcnt)}='1' then
begin
memo9.clear;
filename:='c:\autocom\fax\head.txt';
number:=stringgrid2.cells[col6,totcnt];
if (stringgrid2.cells[col5,totcnt]='') and
(stringgrid2.cells[col4,totcnt]<>'') then
begin
headstr:='수신 : '+stringgrid2.cells[col4,totcnt]+'님';
end
else
if (stringgrid2.cells[col5,totcnt]<>'') and
(stringgrid2.cells[col4,totcnt]<>'') then
begin
headstr:='수신 : '+stringgrid2.cells[col5,totcnt]+
' '+stringgrid2.cells[col4,totcnt]+'님';
end
else
if (stringgrid2.cells[col5,totcnt]<>'') and
(stringgrid2.cells[col4,totcnt]='') then
begin
headstr:='수신 : '+stringgrid2.cells[col5,totcnt];
end
else
if (stringgrid2.cells[col5,totcnt]='') and
(stringgrid2.cells[col4,totcnt]='') then
begin
headstr:='';
end;
try
memo9.lines.loadfromfile(filename);
except
on EFOpenError do
begin
fileclose(filecreate(filename));
memo9.lines.loadfromfile(filename);
end;
end;
if head=true then
begin
if memo9.lines.count<2 then
begin
memo9.lines.add(headstr);
end
else
begin
memo9.lines.insert(1,headstr);
for nn:=2 to memo9.lines.count-1 do
begin
memo9.lines.delete(nn);
end;
end;
end
else
begin
memo9.lines.clear;
memo9.lines.add(headstr);
end;
memo9.lines.SaveToFile(filename);
if callch='' then
opencomport;
enabledfalse;
bitbtn1.Enabled:=false;
tim:=0;
timer5.Enabled:=true;
// ApdSendFax1.StartTransmit;
if outphone<>'' then
number:=outphone+','+number;
sendfax(number);
end;
end;// if (memo2.lines.count=0) then
end//if oneselect='2' then
else
if oneselect='7' then
begin
if (memo2.lines.count<1) then
begin
// messagedlg('통신 포트를 정확히 맞춰주세요.',mtinformation, [mbok],0);
closecomport;
exit;
end;
if choice='4' then//전화
begin
if callch='' then
opencomport;
findcnt:=finddial(totcnt);
if (findcnt='false') or (findcnt='') then
begin
//allview.ApdComPort1.open:=true;
for next:=1 to yakallview.stringgrid1.rowcount-1 do
begin
line:=next;
yakstrgrid:=yakallview.stringgrid1.cells[3,line];
strgrid:=yakallview.stringgrid1.cells[6,line];
if (yakstrgrid='No') or
(strgrid='No')then
begin
YNch:='';
for next_1:=0 to 600000 do
begin
end;
{ threeselect:='2';
totcnt:=1;
sun:='1';
yakallview.datash;}
if messagedlg('전화걸기가 끝났읍니다. 통화가 안된 회원에게 전화를 하시겠읍니까?',mtinformation,[mbYes,mbNo],0)=mrYes then
begin
// showmessage('전화걸기가 끝났읍니다');
threeselect:='2';
totcnt:=1;
sun:='1';
{threeselect:='2';
totcnt:=1;}
bitbtn3.onclick(self);
exit;
end
else
begin
break;
end;
end;
end;
closecomport;
showmessage('전화걸기가 끝났읍니다');
if sun='1' then
begin
totcnt:=totcnt+1;
sun:='2';
end
else
if sun='2' then
begin
sun:='1';
end;
exit;
end
else
if findcnt{finddial(totcnt)}='4' then
begin
number:=yakallview.stringgrid1.cells[1,totcnt];
enabledfalse;
yakallview.bitbtn9.Enabled:=false;
tim:=0;
yakallview.timer2.Enabled:=true;
if outphone<>'' then
number:=outphone+','+number;
dial(number);
end
else
if findcnt{finddial(totcnt)}='5' then
begin
number:=yakallview.stringgrid1.cells[4,totcnt];
enabledfalse;
yakallview.bitbtn9.Enabled:=false;
tim:=0;
yakallview.timer2.Enabled:=true;
if outphone<>'' then
number:=outphone+','+number;
dial(number);
end;
end
else
if choice='5' then//팩스
begin
{if ApdSendFax1.FaxFile='' then
begin
showmessage('보낼 팩스화일을 입력하세요.');
yakenabledtrue;
exit;
end;}
findcnt:=finddial(totcnt);
if (findcnt='false') or (findcnt='') then
begin
for next:=1 to yakallview.stringgrid1.rowcount-1 do
begin
//allview.ApdComPort1.open:=true;
line:=next;
yakstrgrid:=yakallview.stringgrid1.cells[3,line];
strgrid:=yakallview.stringgrid1.cells[6,line];
if (yakstrgrid='No') or
(strgrid='No') then
begin
YNch:='';
for next_1:=0 to 600000 do
begin
end;
{ threeselect:='2';
totcnt:=1;
sun:='1';
yakallview.datash;}
if messagedlg('팩스걸기가 끝났읍니다. 팩스보내기에 실패한 회원에게 다시 보내시겠읍니까?',mtinformation,[mbYes,mbNo],0)=mrYes then
begin
// showmessage('팩스보내기가 끝났읍니다');
threeselect:='2';
totcnt:=1;
sun:='1';
{threeselect:='2';
totcnt:=1;}
bitbtn3.onclick(self);
exit;
end
else
begin
break;
end;
end;
end;
closecomport;
showmessage('팩스보내기가 끝났읍니다');
if sun='1' then
begin
totcnt:=totcnt+1;
sun:='2';
end
else
if sun='2' then
begin
sun:='1';
end;
exit;
end
else
begin
memo9.clear;
filename:='c:\autocom\fax\head.txt';
if (label11.caption<>'') then
begin
headstr:='수신 : '+label11.caption;
end
else
headstr:='';
try
memo9.lines.loadfromfile(filename);
except
on EFOpenError do
begin
fileclose(filecreate(filename));
memo9.lines.loadfromfile(filename);
end;
end;
if head=true then
begin
if memo9.lines.count<2 then
begin
memo9.lines.add(headstr);
end
else
begin
memo9.lines.insert(1,headstr);
for nn:=2 to memo9.lines.count-1 do
begin
memo9.lines.delete(nn);
end;
end;
end
else
begin
memo9.lines.clear;
memo9.lines.add(headstr);
end;
memo9.lines.SaveToFile(filename);
if callch='' then
opencomport;
if findcnt{finddial(totcnt)}='4' then
begin
number:=yakallview.stringgrid1.cells[1,totcnt];
enabledfalse;
yakallview.bitbtn3.Enabled:=false;
tim:=0;
yakallview.timer2.Enabled:=true;
// ApdSendFax1.StartTransmit;
if outphone<>'' then
number:=outphone+','+number;
sendfax(number);
end
else
if findcnt{finddial(totcnt)}='5' then
begin
number:=yakallview.stringgrid1.cells[4,totcnt];
enabledfalse;
yakallview.bitbtn3.Enabled:=false;
tim:=0;
yakallview.timer2.Enabled:=true;
// ApdSendFax1.StartTransmit;
if outphone<>'' then
number:=outphone+','+number;
sendfax(number);
end;
end;
end;
end;
end;
procedure Tallview.selectdial(cnt : integer);
var
next : integer;
begin
if oneselect='7' then
begin
if sun='1' then
begin
totcnt:=totcnt+1;
end;
end
else
totcnt:=totcnt+1;
for next:=0 to 6000000 do
begin
end;
allview.bitbtn3.OnClick(self);
end;
procedure Tallview.BitBtn1Click(Sender: TObject);
var
next, line, col6 : integer;
colstr : string;
begin
timer5.Enabled:=false;
timer6.Enabled:=false;
col6:=6;
enabledtrue;
callch:='';
timer1.Enabled:=false;
bitbtn3.enabled:=true;
if oneselect='1' then
begin
allview.stringgrid1.cells[scol,srow]:=numm;
if ApdModemDialer1.Dialing then
begin
try
ApdModemDialer1.Abort;
except
on ECommNotOpen do
end;
end;
// closecomport;
end
else
if oneselect='2' then
begin
for next:=3 to 10 do
begin
line:=next;
colstr:=stringgrid2.cells[line,0];
if dmform.delspace(colstr,length(colstr))='팩스' then col6:=line;
end;
allview.stringgrid2.cells[col6,srow]:=numm;
cancelstr:='1';
// ApdSendFax1.CancelFax;
end;
//allview.ApdComPort1.open:=false;
for next:=0 to 6000000 do
begin
end;
//allview.ingsave;
{if (allview.bitbtn6.visible=false) and (allview.bitbtn7.visible=false) then
begin
allview.bitbtn6.visible:=true;
allview.bitbtn7.visible:=true;
end;}
allview.panel2.visible:=false;
end;
procedure Tallview.ApdSendFax1FaxFinish(CP: TObject; ErrorCode: Integer);
var
er : string;
{ next : integer;}
begin
eror:=ErrorCode;
er:=ErrorMsg(ErrorCode);
edit1.text:=er; //Bad response from modem
yakallview.edit1.text:=er;
if er='Bad response from modem' then
begin
if oneselect='1' then
begin
bitbtn6.onclick(self);
end
else
begin
yakallview.BitBtn4.onclick(self);
end;
// ApdSendFax1.CancelFax;
{ apdsefax.destroy;
apdsefax:=Tapdsendfax.create(self);}
// moset:='1';
// setmodem;
// ttt:=0;
// timer4.enabled:=true;
exit;
end;
if er='Cancel requested' then
begin
exit;
end;
if er='Error while initializing modem' then
begin
{ moset:='1';
setmodem;
ttt:=0;
timer4.enabled:=true;}
if oneselect='1' then
begin
bitbtn6.onclick(self);
end
else
begin
yakallview.BitBtn4.onclick(self);
end;
// apdmodem1.Initialize;
if oneselect='2' then
begin
bitbtn6.OnClick(self);
end
else
if oneselect='7' then
begin
yakallview.bitbtn4.OnClick(self);
end;
end;
if (oneselect='2') and (cancelstr='0') then
begin
if er='OK' then
begin
opencomport;
bitbtn7.OnClick(self);
end
else
if er<>'Bad response from modem' then
begin
bitbtn6.OnClick(self);
end
else
if apdcomport1.open=true then
begin
ttt:=0;
// timer4.enabled:=true;
end
else
begin
ttt:=0;
// timer4.enabled:=true;
end;
end
else
if (oneselect='7') and (cancelstr='0') then
begin
if er='OK' then
begin
yakallview.bitbtn5.onclick(self);
end
else
if er<>'Bad response from modem' then
begin
yakallview.bitbtn4.onclick(self);
end
else
if apdcomport1.open=true then
begin
ttt:=0;
{ timer4.enabled:=true;}
end
else
begin
ttt:=0;
{ timer4.enabled:=true;}
end;
end;
end;
procedure Tallview.ApdSendFax1FaxStatus(CP: TObject; First, Last: Boolean);
begin
edit6.text:=ErrorMsg(Eror); yakallview.edit1.text:=ErrorMsg(Eror);// then
yakallview.edit3.text:=inttostr(apdsendfax1.FaxProgress);
if (cancelstr='1') and (cancelstart='') then
begin
cancelstart:='1';
ApdSendFax1.cancelfax;
end;
end;
|