请参考 系统空间\系统功能\组织机构\组织机构资源库\禁用的组织机构
procedure TNOUSINGORGS.actRestoreExecute(Sender: TObject);
var
I: Integer;
lRecovered: Boolean;
lDeleteIndex, lOrgURLs: TStringList;
lOrgUnit: TOrgUnit;
lDelOrgURLs: TOrgURLs;
lURL: TBizURL;
begin
Cursor := Business.Forms.Controls.crHourGlass;
lDeleteIndex := TStringList.Create;
lDelOrgURLs := TOrgURLs.Create;
lOrgURLs := TStringList.Create;
lURL := TBizURL.Create;
try
lRecovered := False;
for I := 0 to lvRecycleBin.Items.Count - 1 do
begin
if lvRecycleBin.Items[I].Selected then
begin
lOrgUnit := TOrgUnit(lvRecycleBin.Items[I].Data);
lURL.FileName := StrUtils.AnsiReplaceText(lOrgUnit.BizURL.FileName, '\~\', '');
if not Assigned(Org.OrgSys.OrgSystem.FindUnit(lURL)) then
lDelOrgURLs.Add(lOrgUnit.BizURL);
lURL.FileName := Sysutils.ExtractFileDir(StrUtils.AnsiReplaceText(lOrgUnit.BizURL.FileName, '\~\', ''));
if not Assigned(Org.OrgSys.Orgsystem.FindUnit(lURL)) then
begin
jsDialogs.ShowError('被恢复的组构单元的父单元不存在或已被禁用!', '不能恢复');
Exit;
end;
lOrgURLs.Add(lURL.FileName);
lDeleteIndex.Add(SysUtils.IntToStr(I));
lRecovered := True;
FModified := True;
end;
end;
if lRecovered then
begin
Org.OrgSys.OrgSystem.RecoverFromRecycleBin(lDelOrgURLs);
for I := lDeleteIndex.Count - 1 downto 0 do
begin
lvRecycleBin.Items.Delete(SysUtils.StrToInt(lDeleteIndex[I]));
FileSys.FileSystem.Refresh(lOrgURLs[I], False);
end;
TCommonFunc.OrgChanged;
end;
finally
lURL.Free;
lOrgURLs.Free;
lDelOrgURLs.Free;
lDeleteIndex.Free;
Cursor := Business.Forms.Controls.crDefault;
end;
end; |