这个我已改。
当时还是保同样的错误
所有代码如下:
unit NEWSPLACARD_NAVINFO;
interface
uses
Business.System, Business.Model, Business.Data, Business.Forms,Business.Model.org,
SystemCore,SystemUtils;
type
TNEWSPLACARD_NAVINFO = class(TInfo)
sdsTask: TSQLDataSet;
FIELD_TaskIndex_FEventOptions: TExprCalcField;
FIELD_TaskIndex_FEventState: TExprCalcField;
FIELD_TaskIndex_FEventType: TExprCalcField;
FIELD_TaskIndex_FEventFinishTime: TExprCalcField;
FIELD_TaskIndex_FEventStartTime: TExprCalcField;
FIELD_TaskIndex_FUsedTime: TCalcField;
FIELD_Task_IsTip: TInternalDataField;
procedure sdsTaskAfterOpen(DataSet: TDataSet);
private
{private declarations}
FPersonMemberAndParentURLs: TStringList;
function GetFilter: string;
procedure SetIsTip;
function DoGetQueryURLStr(const AURL: string): string; overload;
function DoGetQueryURLStr(AURLS: TStringList): string; overload;
function GetPersonMemberAndParentURLs: TStringList;
function GetOgrn: TDept;
property PersonMemberAndParentURLs: TStringList read GetPersonMemberAndParentURLs;
public
{public declarations}
constructor Create(Acontext: Tcontext);
destructor Destroy;override;
end;
implementation
constructor TNEWSPLACARD_NAVINFO.Create(Acontext: Tcontext);
begin
inherited;
sdsTask.Open;
end;
destructor TNEWSPLACARD_NAVINFO.Destroy;
begin
if FPersonMemberAndParentURLs <> nil then
FPersonMemberAndParentURLs.Free;
inherited;
end;
function TNEWSPLACARD_NAVINFO.GetFilter: string;
var
lPerson,lPosition,lDept,lorg: string;
lFilter: string;
lNow: Double;
begin
lNow := Business.Data.SysSrv.SysService.Time;
lPerson := TContextUtils.GetOperator(Context).ID;
// lPosition := TContextUtils.GetOperatorPosition(context).PositionID;
lPosition := SystemCore.TSystemCore.Operator.DefaultPosition.PositionID ;
// if not Assigned(lPosition) then
if lPosition = '' then
lPosition := SystemCore.TSystemCore.Operator.Positions[0].PositionID ;
lDept := TContextUtils.GetDept(context).ID;
lorg := GetOgrn.ID;
lFilter := ' ftype = ''NEWSPLACARDDEAL'' ';
if SysUtils.SameText(sdsTask.Connection.Meta.DataProvider, Business.Data.BizSchemaTypes.cDriver_ORACLE) then
begin
lFilter := lFilter + SysUtils.Format('and TTask.FPLANSTARTTIME <= TO_DATE(''%s'', ''YY-MM-DD HH24:MI:SS'')',
[SysUtils.FormatDateTime('yyyy-mm-dd hh:mm:ss', lNow)]);
lFilter := lFilter + SysUtils.Format('and TTask.FPLANFINISHTIME >= TO_DATE(''%s'', ''YY-MM-DD HH24:MI:SS'')',
[SysUtils.FormatDateTime('yyyy-mm-dd hh:mm:ss', lNow)]);
end
else
begin
lFilter := lFilter + SysUtils.Format('and TTask.FPLANSTARTTIME <= ''%s''',
[SysUtils.FormatDateTime('yyyy-mm-dd hh:mm:ss', lNow)]);
lFilter := lFilter + SysUtils.Format('and TTask.FPLANFINISHTIME >= ''%s''',
[SysUtils.FormatDateTime('yyyy-mm-dd hh:mm:ss', lNow)]);
end;
lFilter := lFilter + 'and (TTASK.FGUID IN '+
' (SELECT TTASKMESSAGE.FTASKGUID '+
' FROM TTASKMESSAGE '+
' WHERE (TTASKMESSAGE.FSTATE IN '+
// ' (''tmsSend'', ''tmsReceived'', ''tmsProcessing'')) '+
' (''tmsFinished'')) '+
' AND (((TTASKMESSAGE.FRDEPT = '''+lDept+''') AND '+
' (TTASKMESSAGE.FRPOSITION = '''+lPosition+''') AND '+
' (TTASKMESSAGE.FRPERSON = '''+lPerson+''')) or '+
' ((TTASKMESSAGE.FRDEPT = '''+lDept+''') AND '+
' (TTASKMESSAGE.FRPOSITION = '''+lPosition+''') AND '+
' (TTASKMESSAGE.FRPERSON is null)) or '+
' ((TTASKMESSAGE.FRDEPT = '''+lDept+''') AND '+
' (TTASKMESSAGE.FRPOSITION is null) AND '+
' (TTASKMESSAGE.FRPERSON is null)) or '+
' ((TTASKMESSAGE.FRDEPT is null) AND '+
' (TTASKMESSAGE.FRPOSITION is null) AND '+
' (TTASKMESSAGE.FRPERSON is null) AND '+
' (TTASKMESSAGE.FROGN = '''+lorg+''')))) '+
' or (TTASK.FGUID IN '+
' (SELECT T1.FGUID '+
' FROM TTASK T1 '+
' WHERE (T1.FSTATE IN (''tsStarted'', ''tsProcessing'')) '+
' AND ((T1.FSDEPT = '''+lDept+''') AND (T1.FSPOSITION = '''+lPosition+''') AND '+
' (T1.FSPERSON = '''+lPerson+'''))))) ';
lFilter := lFilter + 'and (TTASK.FGUID IN '+
' (SELECT TTASKMESSAGE.FTASKGUID '+
' FROM TTASKMESSAGE '+
' WHERE (TTASKMESSAGE.FSTATE IN '+
' (''tmsFinished'')) '+
' AND (TTASKMESSAGE.FRORGURL IN ('+DoGetQueryURLStr(PersonMemberAndParentURLs)+') or '+
' (TTASKMESSAGE.FRORGURL in (''\ROOT\_UNEXIST_.OGN\.DPT\.PTM\.PSM'',''\ROOT\_UNEXIST_.OGN\.DPT'') and TTASKMESSAGE.FROGN = '''+lorg+''' )) ) '+
' or (TTASK.FGUID IN '+
' (SELECT T1.FGUID '+
' FROM TTASK T1 '+
' WHERE (T1.FSTATE IN (''tsStarted'', ''tsProcessing'',''tsFinished'')) '+
' and (T1.FSPERSON = '''+lPerson+''')))) ';
{ lFilter := lFilter + 'and (TTASK.FGUID IN '+
' (SELECT TTASKMESSAGE.FTASKGUID '+
' FROM TTASKMESSAGE '+
' WHERE (TTASKMESSAGE.FSTATE IN '+
// ' (''tmsSend'', ''tmsReceived'', ''tmsProcessing'')) '+
' (''tmsFinished'')) '+
' AND (((TTASKMESSAGE.FRDEPT = '''+lDept+''') AND '+
' (TTASKMESSAGE.FRPOSITION = '''+lPosition+''') AND '+
' (TTASKMESSAGE.FRPERSON = '''+lPerson+''')) or '+
' ((TTASKMESSAGE.FRDEPT = '''+lDept+''') AND '+
' (TTASKMESSAGE.FRPOSITION = '''+lPosition+''') AND '+
' (TTASKMESSAGE.FRPERSON is null)) or '+
' ((TTASKMESSAGE.FRDEPT = '''+lDept+''') AND '+
' (TTASKMESSAGE.FRPOSITION is null) AND '+
' (TTASKMESSAGE.FRPERSON is null)) or '+
' ((TTASKMESSAGE.FRDEPT is null) AND '+
' (TTASKMESSAGE.FRPOSITION is null) AND '+
' (TTASKMESSAGE.FRPERSON is null) AND '+
' (TTASKMESSAGE.FROGN = '''+lorg+''')))) '+
' or (TTASK.FGUID IN '+
' (SELECT T1.FGUID '+
' FROM TTASK T1 '+
' WHERE (T1.FSTATE IN (''tsStarted'', ''tsProcessing'')) '+
' AND ((T1.FSDEPT = '''+lDept+''') AND (T1.FSPOSITION = '''+lPosition+''') AND '+
' (T1.FSPERSON = '''+lPerson+'''))))) ';
lFilter := lFilter + 'and (TTASK.FGUID IN '+
' (SELECT TTASKMESSAGE.FTASKGUID '+
' FROM TTASKMESSAGE '+
' WHERE (TTASKMESSAGE.FSTATE IN '+
' (''tmsFinished'')) '+
' AND (TTASKMESSAGE.FRORGURL IN ('+DoGetQueryURLStr(PersonMemberAndParentURLs)+') or '+
' (TTASKMESSAGE.FRORGURL in (''\ROOT\_UNEXIST_.OGN\.DPT\.PTM\.PSM'',''\ROOT\_UNEXIST_.OGN\.DPT'') and TTASKMESSAGE.FROGN = '''+lorg+''' )) ) '+
' or (TTASK.FGUID IN '+
' (SELECT T1.FGUID '+
' FROM TTASK T1 '+
' WHERE (T1.FSTATE IN (''tsStarted'', ''tsProcessing'',''tsFinished'')) '+
' and (T1.FSPERSON = '''+lPerson+''')))) '; }
Result := lFilter;
end;
procedure TNEWSPLACARD_NAVINFO.SetIsTip;
var
lQuery: TQuery;
lISTip : String;
lGuid: String;
lkeyvalue0: String;
begin
lQuery := TQuery.Create(nil);
sdsTask.DisableControls;
try
lISTip := 'N';
sdsTask.First;
while not sdsTask.Eof do
begin
lGuid := sdsTask.FieldByName('FGUID').AsString;
lQuery.Close;
lQuery.ConnectionString := 'DataBaseURL=Biz:\SYSTEM\System.DataBase';
lQuery.CommandText := 'select ttaskbizdata.fkeyvalue0 '+
' from Ttaskbizdata, ttask '+
' where ttaskbizdata.ftaskguid = ttask.fguid '+
' and ttask.fguid = '''+lGuid+''' ';
lQuery.Open;
lkeyvalue0 := lQuery.Fields[0].AsString;
if not (lkeyvalue0 = '') then
begin
lQuery.Close;
lQuery.ConnectionString := 'DataBaseURL=Biz:\COLLABORATION\Collaboration.Database';
lQuery.CommandText := 'select TBUSINESSDATA.ESField02 from TBUSINESSDATA where FID = '''+lkeyvalue0+''' ';
lQuery.Open;
if not (lQuery.Fields[0].AsString = '') then
lISTip := lQuery.Fields[0].AsString;
end;
sdsTask.Edit;
sdsTask.FieldByName('IsTip').AsString := lISTip;
sdsTask.post;
sdsTask.Next;
end;
finally
lQuery.Free;
sdsTask.First;
sdsTask.EnableControls;
end;
end;
procedure TNEWSPLACARD_NAVINFO.sdsTaskAfterOpen(DataSet: TDataSet);
begin
sdsTask.UseBizRange := False;
sdsTask.SQLFiltered := False;
sdsTask.SQLFilter := GetFilter;
sdsTask.SQLFiltered := True;
SetIsTip;
end;
function TNEWSPLACARD_NAVINFO.DoGetQueryURLStr(const AURL: string): string;
var
lPrefix: string;
begin
lPrefix := ''; //干掉警告
Result := SysUtils.UpperCase(FileSys.FileUtils.ExcludeFilePrefix(AURL, lPrefix));
end;
function TNEWSPLACARD_NAVINFO.DoGetQueryURLStr(AURLS: TStringList): string;
var
I: Integer;
lStrList: TStringList;
begin
lStrList := TStringList.Create;
try
for I := 0 to AURLS.Count - 1 do
lStrList.Add(DoGetQueryURLStr(AURLS[I]));
Result := JSSysUtils.FormatAndUniteStr(' , ', '''%s''', lStrList);
finally
lStrList.Free;
end;
end;
function TNEWSPLACARD_NAVINFO.GetPersonMemberAndParentURLs: TStringList;
begin
if FPersonMemberAndParentURLs = nil then
begin
FPersonMemberAndParentURLs := TStringList.Create;
TContextUtils.GetPersonMemberURLs(Self.Context, FPersonMemberAndParentURLs, True);
end;
Result := FPersonMemberAndParentURLs;
end;
function TNEWSPLACARD_NAVINFO.GetOgrn: TDept;
begin
if TContextUtils.FindOperatorPosition(context) = nil then
Result := TOrgUtils.GetOrgan(TContextUtils.GetDefaultOperatorPosition(Context))
else
Result := TOrgUtils.GetOrgan(TContextUtils.GetOperatorPosition(Context));
end;
end. |