...
var
...
oboAccounts: IboEMCAccount;
...
procedure DragMsg;
begin
try
oboAccounts.MoveMessage(GetUID, arvMsgId,
PAccount(MovedToNode.Data)^.FolderID,
PAccount(MovedToNode.Data)^.ProfileID, True);
except
on E:Exception do
begin
...
end
else
...
end;
end;
end;
begin
...
oboAccounts := CreateEverestObject(CLASS_boEMCAccount, GetAppServer) as IboEMCAccount;
DragMsg;
...
end;
function TboEMCAccount.MoveMessage(const sUID: WideString; vMsgID,
vFolderID, vProfileID: OleVariant; bCheckAccess: WordBool): WordBool;
var
iCount:integer;
rsMsg: _Recordset;
vSemaID: OleVariant;
begin
try
...
if VarIsArray(vMsgID) then
begin
for iCount := 0 to VarArrayHighBound(vMsgID,1)-1 do
begin
rsMsg := m_odoEMCMessage.Fetch(sUID, varToStr(vmsgid[iCount]), False);
//在这里设置的断点为什么是无效的呢?
if Assigned(rsMsg) and (rsMsg.RecordCount = 1) then
begin
rsMsg.Fields['FLDID'].Value := vFolderID;
rsMsg.Fields['PRFID'].Value := vProfileID; rsMsg := m_odoEMCMessage.Update(sUID, rsMsg, True); ...
Result := True;
end
else
RaiseValidationError(OTBusinessObject, sUID, 'TboEMCAccount.MoveMessage', EMCInvalidMessageError);
...
except
...
end;
end;以上是主要代码,我的程序有BUG,想单步跟踪找到错误点,可是断点不起作用。。应该怎么解决呢?试过用注释的方法来测试过,代码确实有运行到。怎样才能使设置的断点有效?
if VarIsArray(vMsgID) then
这一行代码是有执行到的而且FUNCTION从一开始设置的断点就是无效的function TboEMCAccount.MoveMessage(const sUID: WideString; vMsgID,
vFolderID, vProfileID: OleVariant; bCheckAccess: WordBool): WordBool;
var
iCount:integer;
rsMsg: _Recordset;
vSemaID: OleVariant;
begin
try
if bCheckAccess then
begin
if not (VarIsNull(vFolderID) or VarIsEmpty(vFolderID) or (VarToStr(vFolderID) = '')) then
begin
if vFolderID > 0 then
begin
if UpperCase(m_oboUserInfo.GetLoggedInUser(sUID)) <>
m_oboFolder.GetThisUser(sUID, vFolderID) then
begin
if not m_oboUserInfo.GetAccessPass(sUID, 0, 'EMC_MOVEMESSGES') then
RaiseValidationError(OTBusinessObject,sUID,'TboEMCAccount.MoveMessage', AccessDenied);
end;
end;
end
else
RaiseValidationError(OTBusinessObject, sUID, 'TboEMCAccount.MoveMessage', EMCFolderIDEmpty); if not m_oboUserInfo.GetAccessPass(sUID, 0, 'EMC_MOVEMESSGES') then
RaiseValidationError(OTBusinessObject,sUID,'TboEMCAccount.MoveMessage', AccessDenied); if not (VarIsNull(vProfileID) or VarIsEmpty(vProfileID) or (VarToStr(vProfileID) = '')) then
begin
if UpperCase(m_oboUserInfo.GetLoggedInUser(sUID)) <>
m_odoEMCAccount.GetThisUser(sUID, vProfileID) then
begin
if not m_oboUserInfo.GetAccessPass(sUID, 0, 'EMC_MOVEMESSGES') then
RaiseValidationError(OTBusinessObject,sUID,'TboEMCAccount.MoveMessage', AccessDenied);
end;
end
else
RaiseValidationError(OTBusinessObject, sUID, 'TboEMCAccount.MoveMessage', EMCProfileIDIsNull);
end; if VarIsArray(vMsgID) then
begin
for iCount := 0 to VarArrayHighBound(vMsgID,1)-1 do
begin
rsMsg := m_odoEMCMessage.Fetch(sUID, varToStr(vmsgid[iCount]), False);
if Assigned(rsMsg) and (rsMsg.RecordCount = 1) then
begin
rsMsg.Fields['FLDID'].Value := vFolderID;
rsMsg.Fields['PRFID'].Value := vProfileID; rsMsg := m_odoEMCMessage.Update(sUID, rsMsg, True); // if html formated mails then we will need to set the cids according to the
// new attachments so that the images can be rendered properly...
if (rsMsg.Fields['MESSAGE_FORMAT'].Value = 2) and
(rsMsg.Fields['HASATTACH'].Value = 'T') then
begin
UpdateHtmlMessage(sUID, rsMsg.Fields['MSGID'].Value,
rsMsg.Fields['BODY'].Value, bCheckAccess);
end; Result := True;
end
else
RaiseValidationError(OTBusinessObject, sUID, 'TboEMCAccount.MoveMessage', EMCInvalidMessageError);
end;
end
else
begin
rsMsg := m_odoEMCMessage.Fetch(sUID, vMsgID, False);
if Assigned(rsMsg) and (rsMsg.RecordCount = 1) then
begin
rsMsg.Fields['FLDID'].Value := vFolderID;
rsMsg.Fields['PRFID'].Value := vProfileID; rsMsg := m_odoEMCMessage.Update(sUID, rsMsg, True); // if html formated mails then we will need to set the cids according to the
// new attachments so that the images can be rendered properly...
if (rsMsg.Fields['MESSAGE_FORMAT'].Value = 2) and
(rsMsg.Fields['HASATTACH'].Value = 'T') then
begin
UpdateHtmlMessage(sUID, rsMsg.Fields['MSGID'].Value,
rsMsg.Fields['BODY'].Value);
end; Result := True;
end
else
RaiseValidationError(OTBusinessObject, sUID, 'TboEMCAccount.MoveMessage', EMCInvalidMessageError);//请注意,程序因为BUG原因,会执行到这一句,所以我想要实现对rsMsg的值的跟踪,但是现在设置不了断点。 end; except
on E:Exception do
begin
SetAbort;
if (not VarIsEmpty(vSemaID)) and m_oboSemaphore.LockExists(sUID, vSemaID) then
m_oboSemaphore.UnLockRecord(sUID, vSemaID);
HandleEverestError(OTBusinessObject, sUID, 'TboEMCAccount.MoveMessage', EMCMoveMessageError, E);
Result := False;
end;
end;
end;
//这一行代码是有执行到的
这一行代码是有执行到,不表示其判断结果一定是True
所以m_odoEMCMessage.Fetch执行不了
有些人觉得这很可笑,但是如果你的代码量大了,备份多了,就很可能出现逆当前打开的pas文件不是你真正被编译的pas文件。
如果你的工程文件和你的pas不在一个路径下,检查你delphi中的查找路径,看看是不是包含了你当前打开的那个pas文件;再检查一下dpr文件的内容,看看其中包含的你无法跟踪的那个pas是不是就是你当前打开的那个。
备份你的源代码,然后在资源管理器中查找你不能跟踪的那个pas,看看有多少?如果有多个,删除多余的,只留下你认为是对的那个(注意别把备份的也删除了),然后在编译跟踪试试看
总之就是保证你当前打开的pas是你真正最好被编译的pas就行
可使用showmessage来观察,或者借助工具codesite来判断