📄 ucbase.pas
字号:
UCControlList : TList;
FUCDataConn: TUCDataConn;
LoginMonitorList : TList;
procedure SetItems(Value: TUCCollection);
procedure SetWindow;
procedure SetWindowProfile;
{$IFDEF VER130}
{$ELSE}
procedure SetFMailUserControl(const Value: TMailUserControl);
{$ENDIF}
procedure ActionCadUser(Sender: TObject);
procedure ActionTrocaSenha(Sender: TObject);
procedure ActionUserProfile(Sender: TObject);
procedure ActionOKLogin(Sender: TObject);
procedure TestaFecha(Sender: TObject; var CanClose: Boolean);
procedure ApplySettings(SourceSettings: TUCSettings);
procedure UnlockEX( FormObj : TCustomForm; ObjName : String);
procedure LockEX( FormObj : TCustomForm; ObjName : String; naInvisible : Boolean);
{$IFDEF UCACTMANAGER}
procedure TrataActMenuBarIt(IT: TActionClientItem; FDataset : TDataset);
procedure IncPermissActMenuBar(idUser : Integer; Act: TAction);
{$ENDIF}
procedure SetUCDataConn(const Value: TUCDataConn);
protected
FRetry : Integer;
FormCadastroUsuarios, FormPerfilUsuarios, FormTrocarSenha, FormLogin, FormLogControl : TCustomForm;
procedure Loaded; override;
procedure ActionBtPermissDefault;
procedure ActionBtPermissProfileDefault;
procedure CriaCadUserForm; dynamic;
procedure CriaProfileUserForm; dynamic;
procedure ActionLog(Sender : TObject); dynamic;
procedure ActionBtPermiss(Sender : TObject); dynamic;
procedure ActionBtPermissProfile(Sender: TObject); dynamic;
procedure CriaTrocaSenhaForm; dynamic;
procedure ActionTSBtGrava(Sender : TObject);
procedure SetFUserSettings ( const Value : TUserSettings);
procedure SetLoginWindow ( Form : TCustomForm);
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure RegistraCurrentUser(dados: TDataset);
procedure ApplyRightsObj(FDataset: TDataset ; FProfile : Boolean = False);
{$IFDEF VER130}
{$ELSE}
procedure ActionEsqueceuSenha(Sender: TObject);
{$ENDIF}
procedure ShowLogin;
procedure ApplyRights;
procedure CriaTableLog;
procedure CriaTableRights(ExtraRights : Boolean = False);
procedure CriaTabelaUsuarios(TableExists : Boolean);
procedure CriaTabelaMsgs(const TableName : String);
procedure TryAutoLogon;
procedure AddUCControlMonitor(UCControl : TUCControls);
procedure DeleteUCControlMonitor(UCControl : TUCControls);
procedure ApplyRightsUCControlMonitor;
procedure LockControlsUCControlMonitor;
procedure AddLoginMonitor(UCAppMessage : TUCAppMessage);
procedure DeleteLoginMonitor(UCAppMessage : TUCAppMessage);
procedure NotificationLoginMonitor;
public
procedure Execute;
procedure StartLogin;
procedure ShowUserManager;
procedure ShowProfileManager;
procedure ShowLogManager;
procedure ShowChangePassword;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property CurrentUser : TUserDef read FUser write FUser;
property Settings : TUserSettings read FUserSettings write SetFUserSettings;
procedure Log( MSG : String; Level : Integer = llDefault);
function VerificaLogin(User , Password : String) : Boolean;
procedure Logoff;
function AddUser(Login, Password, Name, Mail : String; Profile : Integer; PrivUser : Boolean) : Integer;
procedure ChangeUser(IDUser : Integer; Login, Name, Mail : String; Profile : Integer; PrivUser : Boolean);
procedure ChangePassword(IDUser : Integer; NewPassword: String);
procedure AddRight(idUser : Integer; ItemRight : TObject; FullPath : Boolean = True);overload;
procedure AddRight(idUser : Integer; ItemRight : String);overload;
procedure AddRightEX( idUser : Integer; Module, FormName, ObjName : String);
procedure HideField(Sender: TField; var Text: String; DisplayText: Boolean);
published
property About: TUCAboutVar read FAbout write FAbout;
property AutoStart : Boolean read FAutoStart write FAutoStart;
property ApplicationID : String read FAplID write FAplID;
property ControlRight : TUCControlRight read FUCControlRight write FUCControlRight;
property UsersForm : TCadastroUsuarios read FCadUsuarios write FCadUsuarios;
property EncryptKey : word read FEncrytKey write FEncrytKey;
property NotAllowedItems : TNaoPermitidos read FNaoPermitidos write FNaoPermitidos;
property Login : TLogin read FLogin write FLogin;
property LogControl : TLogControl read FLogControl write FLogControl;
property ExtraRight: TUCCollection read FRightItems write SetItems;
property LoginMode : TUCLoginMode read FMode write FMode;
{$IFDEF VER130}
{$ELSE}
property MailUserControl : TMailUserControl read FMailUserControl write SetFMailUserControl;
{$ENDIF}
property UsersProfile : TPerfilUsuarios read FPerfUsuarios write FPerfUsuarios;
property TableUsers : TUCTableUsers read FTableUsers write FTableUsers;
property TableRights : TUCTableRights read FTableRights write FTableRights;
property ChangePasswordForm : TTrocarSenha read FTrocarSenha write FTrocarSenha;
property OnLogin : TOnLogin read FOnLogin Write FOnLogin;
property OnStartApplication : TNotifyEvent read FOnStartApp write FOnStartApp;
property OnLoginSucess : TOnLoginSucess read FOnLoginSucess write FOnLoginSucess;
property OnLoginError : TOnLoginError read FOnLoginError write FOnLoginError;
property OnApplyRightsMenuIt : TOnApplyRightsMenuIt read FOnApplyRightsMenuIt write FOnApplyRightsMenuIt;
property OnApplyRightsActionIt : TOnApllyRightsActionIt read FOnApplyRightsActionIt write FOnApplyRightsActionIt;
property OnCustomUsersForm : TCustomCadUsuarioForm read FOnCustomCadUsuarioForm write FOnCustomCadUsuarioForm;
property OnCustomUsersProfileForm : TCustomPerfilUsuarioForm read FCustomPerfilUsuarioForm write FCustomPerfilUsuarioForm;
property OnCustomLoginForm : TCustomLoginForm read FCustomLoginForm write FCustomLoginForm;
property OnCustomChangePasswordForm : TCustomTrocarSenhaForm read FCustomTrocarSenhaForm write FCustomTrocarSenhaForm;
property OnCustomLogControlForm : TCustomLogControlForm read FCustomLogControlForm write FCustomLogControlForm;
property OnCustomInitialMsg : TCustomInicialMsg read FCustomInicialMsg write FCustomInicialMsg;
property OnAddUser : TOnAddUser read FOnAddUser write FOnAddUser;
property OnChangeUser : TOnChangeUser read FOnChangeUser write FOnChangeUser;
property OnDeleteUser : TOnDeleteUser read FOnDeleteUser write FOnDeleteUser;
property OnAddProfile : TOnAddProfile read FOnAddProfile write FOnAddProfile;
property OnDeleteProfile : TOnDeleteProfile read FOnDeleteProfile write FOnDeleteProfile;
property OnChangePassword : TOnChangePassword read FOnChangePassword write FOnChangePassword;
property OnLogoff : TOnLogoff read FOnLogoff write FOnLogoff;
property DataConnector : TUCDataConn read FUCDataConn write SetUCDataConn;
end;
TUCCollectionItem = class(TCollectionItem)
private
FFormName, FCompName, FCaption: String;
FGroupName: string;
procedure SetFormName(const Value: string);
procedure SetCompName(const Value: string);
procedure SetCaption(const Value: string);
procedure SetGroupName(const Value: string);
protected
function GetDisplayName: string; override;
public
published
property FormName: string read FFormName write SetFormName;
property CompName: string read FCompName write SetCompName;
property Caption : string read FCaption write SetCaption;
property GroupName : string read FGroupName write SetGroupName;
end;
TUCCollection = class(TCollection)
private
FUCBase: TUserControl;
function GetItem(Index: Integer): TUCCollectionItem;
procedure SetItem(Index: Integer; Value: TUCCollectionItem);
protected
function GetOwner: TPersistent; override;
public
constructor Create(UCBase: TUserControl);
function Add: TUCCollectionItem;
property Items[Index: Integer]: TUCCollectionItem
read GetItem write SetItem; default;
end;
TVerifThread = class(TThread)
private
procedure VerNovaMsg;
public
AOwner : TComponent;
protected
procedure Execute; override;
end;
TUCRun = class(TThread)
private
procedure UCStart;
public
AOwner : TComponent;
protected
procedure Execute; override;
end;
TUCAppMessage = class(TComponent)
private
FActive: Boolean;
FReady : Boolean;
FInterval: integer;
FUserControl: TUserControl;
FVerifThread : TVerifThread;
FTabelaMsg: String;
procedure SetActive(const Value: Boolean);
protected
procedure Loaded; override;
public
constructor Create(AOWner : TComponent);override;
destructor Destroy; override;
procedure ShowMessages(Modal : Boolean = True);
procedure SendAppMessage(ToUser: Integer; Subject, Msg: String);
procedure DeleteAppMessage(IdMsg : Integer);
procedure CheckMessages;
published
property Active : Boolean read FActive write SetActive;
property Interval : integer read FInterval write FInterval;
property TableMessages : String read FTabelaMsg write FTabelaMsg;
property UserControl : TUserControl read FUserControl write FUserControl;
end;
TUCSettings = class(TComponent)
private
FAddProfileFormMSG: TAddProfileFormMSG;
FAddUserFormMSG: TAddUserFormMSG;
FCadUserFormMSG: TCadUserFormMSG;
FLogControlFormMSG: TLogControlFormMSG;
FLoginFormMSG: TLoginFormMSG;
FPermissFormMSG: TPermissFormMSG;
FProfileUserFormMSG: TProfileUserFormMSG;
FResetPassword: TResetPassword;
FTrocaSenhaFormMSG: TTrocaSenhaFormMSG;
FUserCommomMSG: TUserCommonMSG;
FAppMessagesMSG: TAppMessagesMSG;
FUCXPSet: TUCXPSet;
FXPStyle: Boolean;
FPosition: TPosition;
procedure SetFAddProfileFormMSG(const Value: TAddProfileFormMSG);
procedure SetFAddUserFormMSG(const Value: TAddUserFormMSG);
procedure SetFCadUserFormMSG(const Value: TCadUserFormMSG);
procedure SetFFormLoginMsg(const Value: TLoginFormMSG);
procedure SetFLogControlFormMSG(const Value: TLogControlFormMSG);
procedure SetFPermissFormMSG(const Value: TPermissFormMSG);
procedure SetFProfileUserFormMSG(const Value: TProfileUserFormMSG);
procedure SetFResetPassword(const Value: TResetPassword);
procedure SetFTrocaSenhaFormMSG(const Value: TTrocaSenhaFormMSG);
procedure SetFUserCommonMSg(const Value: TUserCommonMSG);
procedure SetAppMessagesMSG(const Value: TAppMessagesMSG);
protected
public
constructor Create(AOwner : TComponent);override;
destructor Destroy; override;
procedure Assign(Source : TPersistent); override;
published
property AppMessages : TAppMessagesMSG read FAppMessagesMSG write SetAppMessagesMSG;
property CommonMessages : TUserCommonMSG read FUserCommomMSG write SetFUserCommonMSg;
property Login : TLoginFormMSG read FLoginFormMSG write SetFFormLoginMsg;
property Log : TLogControlFormMSG read FLogControlFormMSG write SetFLogControlFormMSG;
property UsersForm : TCadUserFormMSG read FCadUserFormMSG write SetFCadUserFormMSG;
property AddChangeUser : TAddUserFormMSG read FAddUserFormMSG write SetFAddUserFormMSG;
property AddChangeProfile : TAddProfileFormMSG read FAddProfileFormMSG write SetFAddProfileFormMSG;
property UsersProfile : TProfileUserFormMSG read FProfileUserFormMSG write SetFProfileUserFormMSG;
property Rights : TPermissFormMSG read FPermissFormMSG write SetFPermissFormMSG;
property ChangePassword : TTrocaSenhaFormMSG read FTrocaSenhaFormMSG write SetFTrocaSenhaFormMSG;
property ResetPassword : TResetPassword read FResetPassword write SetFResetPassword;
property XPStyleSet : TUCXPSet read FUCXPSet write FUCXPSet;
property XPStyle : Boolean read FXPStyle write FXPStyle;
property WindowsPosition : TPosition read FPosition write FPosition;
end;
TUCComponentsVar = String[10];
// TUCComponentsVarProperty = class;
TUCNotAllowed = (naInvisible, naDisabled);
TUCControls = class (TComponent)
private
FGroupName: String;
FUCComponents: TUCComponentsVar;
FUCComp: TUserControl;
FUCNotAllowed: TUCNotAllowed;
function GetUCAccessType: String;
function GetActiveForm: String;
procedure SetGroupName(const Value: String);
protected
procedure Loaded; override;
public
destructor Destroy; override;
procedure ApplyRights;
procedure LockControls;
procedure ListComponents(Form: String; List : TStrings);
published
property AccessType : String read GetUCAccessType;
property ActiveForm : String read GetActiveForm;
property GroupName : String read FGroupName write SetGroupName;
property UserControl : TUserControl read FUCComp write FUCComp;
property Components : TUCComponentsVar read FUCComponents write FUCComponents;
property NotAllowed : TUCNotAllowed read FUCNotAllowed write FUCNotAllowed;
end;
procedure IniSettings( DestSettings : TUserSettings);
procedure IniSettings2(DestSettings: TUCSettings);
implementation
{$R UCLock.res}
{ TUserControl }
uses
Dialogs, CadPerfil_U, CadUser_U, UserPermis_U, TrocaSenha_U,
MsgRecForm_U, MsgsForm_U, LoginWindow_U, UCXPMenu, ViewLog_U;
constructor TUserControl.Create(AOwner: TComponent);
begin
inherited;
FUser := TUserDef.Create(self);
ControlRight := TUCControlRight.Create(Self);
Login := TLogin.Create(Self);
LogControl := TLogControl.Create(Self);
UsersForm := TCadastroUsuarios.Create(Self);
UsersProfile := TPerfilUsuarios.Create(Self);
ChangePasswordForm := TTrocarSenha.Create(Self);
FUserSettings := TUserSettings.Create(Self);
FNaoPermitidos := TNaoPermitidos.Create(Self);
FRightItems := TUCCollection.Create(Self);
TableUsers := TUCTableUsers.Create(Self);
TableRights := TUCTableRights.Create(Self);
if csDesigning in ComponentState then
begin
FMode := lmActive;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -