Репозитарий
Добавлено: 24 апр 2014, 15:48
Понадобилось тут ресурс в базу без купленного репозитария добавить. Решил набросать простенький интерфейсик и ... увлекся.
Вроде все работает, но сильно не тестировал.
За убитые репозитарии ответственности не несу!
Вроде все работает, но сильно не тестировал.
Код: Выделить всё
#component "U_Poor"
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// Интерфейс выбора модуля \\
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Interface PoorGetComponentModule 'Выберите модуль' ( ,,sci1EnEsc ) DoAccept, EscClose, Cyan;
Show At ( ,,50,10 );
Create View
Var cModule : comp;
As Select *
From ComponentModules
Where ((
0 << ComponentModules.owner
))
;
Parameters cModule;
Browse brw;
Table ComponentModules;
Fields
ComponentModules.ExeName 'Наименование' : [ 15 ], Protect;
ComponentModules.Description 'Описание' : [ 35 ], Protect;
End; //browse
HandleEvent
cmInit :
{
If Getfirst ComponentModules Where (( cModule == ComponentModules.atl_nrec )) = tsOk
ReReadRecord ( #ComponentModules );
}; //cmInit
cmDefault :
{
cModule := ComponentModules.atl_nrec;
}; //cmDefault
End;
END.
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// Интерфейс выбора группы компонентов \\
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Interface PoorGetComponentGroup 'Выберите группу компанентов' ( ,,sci1EnEsc ) DoAccept, EscClose, Cyan;
Show At ( ,,50,10 );
Create View
Var cGroup : comp;
As Select *
From Components
Where ( Components.Flags and 1 ) > 0
;
Parameters cGroup;
Browse brw;
Table Components;
Fields
Components.Name 'Наименование группы' : [ 15 ], Protect;
Components.Comment 'Описание' : [ 35 ], Protect;
End; //browse
HandleEvent
cmInit :
{
If Getfirst Components Where (( cGroup == Components.atl_nrec )) = tsOk
ReReadRecord ( #Components );
}; //cmInit
cmDefault :
{
cGroup := Components.atl_nrec;
}; //cmDefault
End;
END.
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// Интерфейс выбора пользователя \\
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Interface PoorGetUser 'Выберите пользователя' ( ,,sci1EnEsc ) DoAccept, EscClose, Cyan;
Show At ( ,,50,10 );
Create View
Var cUser : comp;
As Select *
From x$users;
Parameters cUser;
Browse brw;
Table x$users;
Fields
x$users.xu$UserOffice 'Офис' : [ 3 ] ,Protect;
x$users.xu$loginname 'Сетевое имя' : [ 15 ], Protect;
x$users.xu$FullName 'Полное имя' : [ 35 ], Protect;
End; //browse
HandleEvent
cmInit :
{
If Getfirst x$users Where (( cUser == x$users.atl_nrec )) = tsOk
ReReadRecord ( #x$users );
}; //cmInit
cmDefault :
{
cUser := x$users.atl_nrec;
}; //cmDefault
End;
END.
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// Основной интерфейс \\
// Components.Flags: \\
// 1 бит: 0 - ресурс, 1 - группа \\
// 2 бит: 0 - системный, 1 - пользователя ( не уверен ) \\
// 3 бит: 1 - критичность высокая \\
// 4 бит: 1 - критичность низкая \\
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Interface Repo4Poor 'Репозиторий' ( ,,sci1478EnEscTree ) EscClose, Cyan;
Create View
Var cNode : comp;
As Select *
From Components
,ComponentModules
,Components loComponents
,Components upComponents
,ComponentUsers
,ComponentUsers vComponentUsers
,x$users
Where ((
cNode == Components.owner
and Components.atl_nrec == loComponents.owner
and Components.ModuleCode == ComponentModules.atl_nrec
and Components.atl_nrec == ComponentUsers.ResCode
and ComponentUsers.UserCode == x$users.atl_nrec
and Components.owner == upComponents.atl_nrec
)) order by Components.Priority
;
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// Окно редактирования ресурса \\
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Window EditResource 'Свойства ресурса' ( ,,sci1Esc ), Blue, Dialog;
Show At ( ,,76,12 );
TabbedSheet Tabs;
Screen scrR 'Ресурс';
Table Components;
Fields
Components.name : noProtect;
Components.Resource : noProtect, PickButton;
TranslatePath ( Components.Resource ) : Skip;
upComponents.name ( ,,sci13Esc ) : Protect, PickButton;
Components.Priority : noProtect;
ComponentModules.ExeName ( ,,sci13Esc ) : Protect, PickButton;
Components.Flags : [ LIST 'Низкая', 'Средняя', 'Высокая' ], Protect;
Components.Version : noProtect;
Components.Copyright : noProtect;
Components.Comment : noProtect;
<<
Компонент: .@@@@@@@@@@@@@@@@@@@@@@@@@
Ресурс: .@@@@@@@@@@@@@@@@@@@@@@@@@
.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Входит в: .@@@@@@@@@@@@@ Приоритет: .@@@@@@
Система: .@@@@@@@@@@@@@ Критичность: .@@@@@@@@@@@@@@@@@@@@@@@
Версия: .@@@@@@@@@
Производитель:.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Описание: .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
>>
End; //screen
Screen scrG 'Группа';
Table Components;
Fields
Components.name : noProtect;
upComponents.name ( ,,sci13Esc ) : Protect, PickButton;
Components.Version : noProtect;
Components.Copyright : noProtect;
Components.Comment : noProtect;
<<
Группа: .@@@@@@@@@@@@@@@@@@@@@@@@@
Входит в: .@@@@@@@@@@@@@
Версия: .@@@@@@@@@
Производитель:.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Описание: .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
>>
End; //screen
HandleEvent
cmPick :
{
Case CurField Of
#ComponentModules.ExeName :
{
If RunInterface ( 'PoorGetComponentModule', Components.ModuleCode ) = cmDefault
RescanPanel ( #Components );
}
#upComponents.name :
{
var c : comp;
c := Components.owner;
If RunInterface ( 'PoorGetComponentGroup', c ) = cmDefault
set Components.owner := c;
};
#Components.Resource :
{
var Path : string;
Path := GetFileName ( '*.*', 'Выберите ресурс' );
If trim ( Path ) <> ''
set Components.Resource := trim ( Path );
};
End;
}
End;
Procedure MakeWindow;
{
SelectFormat ( If ( ( Components.Flags and 1 ) = 0, ScrR, ScrG ) );
SetTabbedSheetVisible ( scrR, ( Components.Flags and 1 ) = 0 );
SetTabbedSheetVisible ( scrG, ( Components.Flags and 1 ) = 1 );
}; //Procedure MakeWindow
Procedure SetCriticalList;
{
var i : array [ 1..3 ] of word;
i[1] := ( Components.Flags and 1 ) + ( Components.Flags and 2 ) + 8;
i[2] := ( Components.Flags and 1 ) + ( Components.Flags and 2 ) + 4;
i[3] := ( Components.Flags and 1 ) + ( Components.Flags and 2 );
var n : array [ 1..3 ] of string;
n[1] := 'Низкая';
n[2] := 'Высокая';
n[3] := 'Средняя';
SetEnumList ( scrR, #Components.Flags, n, i );
}; //Procedure SetCriticalList
Browse brwR 'Права доступа';
Table ComponentUsers;
Fields
[vUser] If ( isValid ( tnx$users ), x$users.xu$loginName, 'Общий' ) ( ,,sci1378Esc ) : [ 50 ], Protect, PickButton;
[vRight] If ( ComponentUsers.DenyFlag, 'запрещен', 'разрешен' ) : [ 15 ], Protect, PickButton;
End; //brose
End; //TabbedSheet
HandleEvent
cmInit :
{
MakeWindow;
}; //cmInit
End;
End; //window
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// \\
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
TableEvent Table ComponentUsers;
cmSetDefault :
{
ClearBuffer ( #ComponentUsers );
ComponentUsers.GroupCode := 0;
ComponentUsers.UserCode := 0;
ComponentUsers.Flags := 0; //приоритет низкий
ComponentUsers.DenyFlag := false;
SetModified ( true );
};
cmCheckRecord :
{
If ( GetFirst vComponentUsers Where (( ComponentUsers.ResCode == vComponentUsers.ResCode
and ComponentUsers.UserCode == vComponentUsers.UserCode ))
and ComponentUsers.atl_nrec <> vComponentUsers.atl_nrec ) = tsOk
{
Message ( 'Дублирование записи!' );
Abort;
};
};
cmPick :
{
Case CurField Of
#vUser
: {
var c : comp;
c := ComponentUsers.UserCode;
If RunInterface ( 'U_Poor::PoorGetUser', c ) = cmDefault
set ComponentUsers.UserCode := c;
};
#vRight
: set ComponentUsers.DenyFlag := not ComponentUsers.DenyFlag;
End;
};
cmInsertRecord : Insert Current ComponentUsers;
cmUpdateRecord : Update Current ComponentUsers;
cmDeleteRecord : If Message ( 'Удалить запись?', YesNo ) = cmYes
Delete Current ComponentUsers;
End; //TableEvent ComponentUsers
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// Основное окно \\
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Tree trRepo 'Репа' ( ,,sci1478EscExTreeI );
Table Components;
Fields
Components.Name 'Компонент' : [ 20 ], Protect;
If ( isValid ( tnloComponents ), '', Components.Resource )
'Ресурс' : [ 30 ], Protect;
Components.Priority 'Приоритет' : [ 6 ], noProtect;
ComponentModules.ExeName 'Система' : [ 10 ], Protect;
End;
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// \\
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
TableEvent Table Components;
cmTreeTop : cNode := 0;
cmTreeUp : cNode := Components.owner;
cmTreeDown : cNode := Components.atl_nrec;
cmTreeNodeType : {
If ( Components.Flags and 1 ) = 0
TreeSetNodeType ( trRepo, 2 );
};
cmTreeNeedOwner: If Components.owner <> 0
TreeJumpToRecord ( trRepo, Components.owner )
else
TreeJumpToRecord ( trRepo, 0 );
cmUpdateRecord :
{
If Update Current Components = tsOk
TreeJumpToRecord ( trRepo, Components.atl_nrec );
}
cmSetDefault :
{
ClearBuffer ( #Components );
Components.Name := 'Новый ресурс';
Components.Flags := 10;
SetCriticalList;
RunWindowModal ( EditResource );
};
cmCheckRecord :
{
If trim ( Components.name ) = ''
{
Message ( 'Не задано наименование компонента!'#13 + 'Исправьте или удалите запись!', Error );
Abort; Exit;
};
If ( Components.Flags and 1 ) = 0
If trim ( Components.Resource ) = ''
{
Message ( 'Не задано наименование ресурса!'#13 + 'Исправьте или удалите запись!', Error );
Abort; Exit;
};
};
cmInsertRecord :
{
If Insert Current Components = tsOk
{
ClearBuffer ( #vComponentUsers );
vComponentUsers.ResCode := Components.Atl_nRec;
vComponentUsers.DenyFlag := false;
insert current vComponentUsers;
};
};
cmDeleteRecord :
{
If GetFirst loComponents = tsOk
Message ( 'Группа не пуста! Удалять нельзя!', Warning );
else
If Message ( 'Вы уверены, что хотите удалить ' + If ( ( Components.Flags and 1 ) = 0, 'компонент', 'группу' ) + ' из репозитория?', YesNo + mfSwapButtons ) = cmYes
{
Delete vComponentUsers Where (( Components.atl_nrec == vComponentUsers.ResCode ));
Delete Current Components;
};
};
cmPositionChanged :
{
SetCriticalList;
MakeWindow;
};
End; //TableEvent Components
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// \\
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
HandleEvent
cmInit :
{
cNode := 0;
}; //cmInit
cmDefault :
{
RunWindowModal ( EditResource );
}; //cmDefault
cmEdit :
{
PutCommand ( cmDefault );
};
cmInsLevel :
{
ClearBuffer ( #Components );
Components.name := 'Новая группа';
Components.Flags := 1;
RunWindowModal ( EditResource );
};
End;
END.
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// Добавление в меню отчетов пользователя \\
///////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#include UserReport.vih
VipInterface UserReport_Repo4Poor
Implements F_UserReport::IUserReport
Licensed(Free)
;
interface UserReport_Repo4Poor;
create view
var
Dummy: Byte;
;
procedure Run;
begin
RunInterfaceNoModal ( 'U_POOR::Repo4Poor' );
end;
function GetReportName: String;
begin
Result := 'Репозитарий';
end;
function GetGroupName ( Level: Word ): String;
begin
Result := '';
end;
function GetPriority: Integer;
begin
Result := 0;
end;
function VisibleInModule(Ind: Byte): String;
begin
Result := '';
case Ind of
1: If Pr_CurUserAdmin Result := '*';
end;
end;
end.