try
with query1 do
begin
newguid := Business.System.JSCommon.CreateGUIDStr;
tpersonguid := newguid;
//插入人员表
close;
CommandText := '';
CommandText := 'insert into TPERSON (FGUID, FCLIENTACCOUNT, FID, FDISPLAYNAME, FDEPTID, FLOGINID, FDELETELEVEL) values(:00, ''CSSCAE.COM'', :01, :02, :03, :04, 0)';
Params[0].AsString := newguid;
Params[1].AsString := lPersonID;
Params[2].AsString := lDisplayName;
Params[3].AsString := lDeptURL;
Params[4].AsString := lPersonID;
execute;
//查询dfd
close;
CommandText := '';
CommandText := 'select Fguid, FFILENAME from TORGSYSTEM where FID=:00 and FDELETELEVEL=0 and FKIND=''.DFD''';
Params[0].AsString := lDeptURL;
//Params[1].AsString := lDeptURL+'.dfd';
//Params[2].AsString := lDeptURL;
//Params[3].AsString := newguid;
//Params[4].AsString := lPersonID;
open;
if RecordCount>0 then
begin
depguid := fields[0].asstring;
//depfilename := fields[1].asstring;
end
else
begin
newguid := Business.System.JSCommon.CreateGUIDStr;
//插入dfd
close;
CommandText := '';
CommandText := 'insert into TORGSYSTEM (FGUID, FCLIENTACCOUNT, FPARENTGUID, FFILENAME, FID, FKIND, FPATH, FSPACE, FDELETELEVEL, FDISPLAYNAME, FFLAG, FDUMMY)'
+' values(:00, ''CSSCAE.COM'', ''9680944C01484966ACB7E07EC5B822D4'', :01, :02, ''.DFD'', ''\PERSON\'', ''\PERSON\'', 0, '', ''10000000000000000000000000000000'', :03)';
Params[0].AsString := newguid;
Params[1].AsString := lDeptURL+'.dfd';
Params[2].AsString := lDeptURL;
Params[3].AsString := newguid;
//Params[4].AsString := lPersonID;
execute;
depguid := newguid;
//depfilename := lDeptURL+'.dfd';
end;
//newguid := Business.System.JSCommon.CreateGUIDStr;
//插入psn
close;
CommandText := '';
CommandText := 'insert into TORGSYSTEM (FGUID, FCLIENTACCOUNT, FPARENTGUID, FFILENAME, FID, FKIND, FPATH, FSPACE, FDELETELEVEL, FDISPLAYNAME, FPERSON)'
+' values(:00, ''CSSCAE.COM'', :01, :02, :03, ''.PSN'', :04, ''\PERSON\'', 0, :05, :06)';
Params[0].AsString := tpersonguid;
Params[1].AsString := depguid;
Params[2].AsString := lPersonID+'.psn';
Params[3].AsString := lPersonID;
Params[4].AsString := '\PERSON\'+lDeptURL+'.DFD\';
Params[5].AsString := lDisplayName;
Params[6].AsString := lPersonID;
execute;
//查询岗位
close;
CommandText := '';
CommandText := 'select FPATH, FID from TORGSYSTEM where FGUID=:00';
Params[0].AsString := PositionID;
//Params[1].AsString := lDeptURL+'.dfd';
//Params[2].AsString := lDeptURL;
//Params[3].AsString := newguid;
//Params[4].AsString := lPersonID;
open;
//******************************************这里没有检错--当岗位为空的时候
//不检测,错误则可以跳到except终止
gpath := fields[0].asstring;
gfid := fields[1].asstring;
newguid := Business.System.JSCommon.CreateGUIDStr;
//插入psm
close;
CommandText := '';
CommandText := 'insert into TORGSYSTEM (FGUID, FCLIENTACCOUNT, FPARENTGUID, FFILENAME, FID, FKIND, FPATH, FSPACE, FDELETELEVEL, FDISPLAYNAME, FDEPT, FPOSITION, FPERSON)'
+' values(:00, ''CSSCAE.COM'', :01, :02, :03, ''.PSM'', :04, :05, 0, :06, :07, :08, :09)';
Params[0].AsString := newguid;
Params[1].AsString := PositionID;
Params[2].AsString := lPersonID+'.psm';
Params[3].AsString := lPersonID;
Params[4].AsString := gpath+gfid+'.PTM\';
Params[5].AsString := gpath+gfid+'.PTM\';
Params[6].AsString := lDisplayName;
Params[7].AsString := lDeptURL;
Params[8].AsString := gfid;
Params[9].AsString := lPersonID;
execute;
end
finally
query1.Close;
end; |