2 Star 8 Fork 3

闲散居士/数据库备份

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
U_orauser.pas 7.26 KB
一键复制 编辑 原始数据 按行查看 历史
闲散居士 提交于 2021-12-08 10:58 . 清理源码注释
unit U_orauser;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Buttons, StdCtrls, CheckLst, ExtCtrls;
type
TStartMulSelect = function(user,pass,serv,sqlstr:String;var inSelectValues,SelectItem:TStrings; isOnlyOne:Boolean=false):boolean;stdcall; //定义函数指针,用于调用报表DLL
TTestConnect = function(user,pass,serv:pchar):boolean;stdcall;
TFr_OracleUser = class(TFrame)
Panel1: TPanel;
Label5: TLabel;
CL_OraUserList: TCheckListBox;
Panel2: TPanel;
Ed_addUser: TEdit;
SP_AddUser: TSpeedButton;
SB_OraUser: TSpeedButton;
Bevel1: TBevel;
Panel3: TPanel;
Label6: TLabel;
Panel4: TPanel;
SP_ClearTableName: TSpeedButton;
seleB: TSpeedButton;
ME_TableName: TMemo;
procedure CL_OraUserListClick(Sender: TObject);
procedure CL_OraUserListClickCheck(Sender: TObject);
procedure SP_ClearTableNameClick(Sender: TObject);
procedure seleBClick(Sender: TObject);
procedure SP_AddUserClick(Sender: TObject);
private
{ Private declarations }
CHECKCLICK:Boolean;
ed_u,ed_p,ed_s,ed_o:Tedit;
procedure GetOraUsers(u,p,s,dir:String);
procedure AddTempUsersList;
public
{ Public declarations }
ParStringList:TStrings;
addTempUser:TStrings;
function TestConntion(u, p, s: String): boolean;
function SetParFile(schName,parName:String;form:Tform;cl:TCheckListBox;name,value:Array of String;ImpStr:String):String;
procedure GetOracleUser(u, p, s,dir: String);
procedure ShowFullDatabase(b: boolean);
procedure SetFullCaption(isImp:String='');
procedure SetUserEdit(e_u,e_p,e_s,e_o:TEdit);
end;
implementation
uses U_COMMFUNC,U_des, U_main;
{$R *.DFM}
{ TFr_OracleUser }
function TFr_OracleUser.TestConntion(u,p,s:String):boolean;
var
LibHandle: THandle;
P_device:TTestConnect;
begin
Result:=false;
LibHandle := LoadLibrary(dllfilename);
try
if LibHandle <=32 then raise EDLLLoadError.Create('调用 '+dllfilename+' 失败!')
else
begin
@P_device := GetProcAddress(LibHandle, 'TestConnect');
if not (@P_device = nil) then
begin
try
Result:=P_device(pchar(u),pchar(p),pchar(s));
except
end;
end;
end;
finally
FreeLibrary(LibHandle);
end;
if Result then
Begin
Application.MessageBox('数据库连接正常!','提示',0);
End Else
Application.MessageBox('不能获得数据库连接,请重新设置!','提示',0);
end;
procedure TFr_OracleUser.GetOracleUser(u,p,s,dir:String);
begin
setDatabaseParam(dir,s);
GetOraUsers(u,p,s,dir);
AddTempUsersList;
end;
procedure TFr_OracleUser.ShowFullDatabase(b:boolean);
begin
If CL_OraUserList.Items.Count<1 Then exit;
CL_OraUserList.Checked[0]:=b;
CL_OraUserListClickCheck(CL_OraUserList);
end;
procedure TFr_OracleUser.GetOraUsers(u,p,s,dir:String);
var t:TStrings;
begin
begin
CL_OraUserList.Clear;
CL_OraUserList.Items.Add('全库导出');
ShowFullDatabase((ParStringList.Count>0) and (ParStringList.IndexOf('FULL=Y')>=0) );
t := TStringList.Create;
try
GetStringsList1(t,'SELECT USERNAME FROM ALL_USERS WHERE USERNAME NOT LIKE ''%$%''',u,p,s,dir);
CL_OraUserList.Items.AddStrings(t);
finally
t.Destroy;
end;
ShowExpOwners(ParStringList,ME_TableName,CL_OraUserList);
end;
end;
function TFr_OracleUser.SetParFile(schName,parName:String;form:Tform;cl:TCheckListBox;name,value:Array of String;ImpStr:String):String;
var s,s1,s2:String;
i:integer;
t:TStrings;
a:TArray;
begin
s1:='OWNER';
s:='';
If ImpStr<>'' Then
s1:='FROMUSER=';
ParStringList.Clear;
If CL_OraUserList.Checked[0] Then
Begin
ParStringList.Add('FULL=Y');
End;
s2:=GetSelectText(CL_OraUserList);
If s2<>'' Then
Begin
s:=s1+'('+s2+')';
ParStringList.Add(s);
If impStr<>'' Then
ParStringList.Add('TOUSER=('+s2+')');
End;
If ME_TableName.Lines.Count>0 Then Begin
ParStringList.Add('TABLES=(');
FOR I:= 0 to ME_TableName.Lines.Count-1 do
begin
s:=ME_TableName.Lines.Strings[i];
If i>0 Then
s:=','+s;
ParStringList.Add(s);
end;
ParStringList.Add(')');
End;
t := TStringlist.Create;
try
GetExpParam(t,CL,name,value);
ParStringList.AddStrings(t);
ParStringList.Add('FEEDBACK=1000');
GetOtherParam(t,form,true);
ParStringList.AddStrings(t);
//增加增量类型处理
if (IMPCurrent_Scheme_Values[22] <> '0') and (IMPCurrent_Scheme_Values[22] <> '') then
begin
a := split(INCTYPE_PARAM[0],',');
s := IMPScheme_Values[22]+ '='+a[strtoint(IMPCurrent_Scheme_Values[22])];
ParStringList.Add(s);
end;
finally
t.Destroy;
end;
If not FileExists(PAR_DIR) Then
CreateDir(PAR_DIR);
s:=GetParFileName(schName,ImpStr);
ParStringList.SaveToFile(s);
If parName=PAR_DEFAULT_FILE Then
result:='NULL'
Else
Result:=ImpStr+parName;
end;
procedure TFr_OracleUser.AddTempUsersList;
var i:Integer;
s:String;
begin
if addTempUser=nil then exit;
if addTempUser.Count<1 then exit;
for i := 0 to addTempUser.Count-1 do
begin
s:=addTempUser.Strings[i];
if CL_OraUserList.Items.IndexOf(s)<0 then
CL_OraUserList.Items.Add(s);
end;
end;
procedure TFr_OracleUser.CL_OraUserListClick(Sender: TObject);
begin
if not CHECKCLICK Then
Begin
SETSELECT(Sender);
CL_OraUserListClickCheck(Sender);
End;
CHECKCLICK:=false;
end;
procedure TFr_OracleUser.CL_OraUserListClickCheck(Sender: TObject);
begin
CHECKCLICK:=TRUE;
If (Sender as TCheckListBox).Checked[0] Then
Begin
ME_TableName.Enabled:=false;
ME_TableName.Color:=clBtnFace;
End Else Begin
ME_TableName.Enabled:=true;
ME_TableName.Color:=clWindow;
End;
seleB.Enabled:=ME_TableName.Enabled;
end;
procedure TFr_OracleUser.SP_ClearTableNameClick(Sender: TObject);
begin
ME_TableName.Clear;
end;
procedure TFr_OracleUser.seleBClick(Sender: TObject);
var selectValues,item:TStrings;
sqlstr:String;
begin
If CL_OraUserList.Checked[0] Then Exit;
selectValues:=ME_TableName.Lines;
sqlstr:=GetSelectText(CL_OraUserList);
If sqlstr='' Then
sqlstr:='SELECT TABLE_NAME N FROM USER_TABLES ORDER BY N'
Else
sqlstr:='SELECT OWNER||''.''||TABLE_NAME N FROM ALL_TABLES WHERE OWNER IN ('+sqlstr+') ORDER BY N';
StartSelect(sqlstr,selectValues,Item,ed_u.Text,ed_p.Text,ed_s.Text,Ed_O.Text);
end;
procedure TFr_OracleUser.SP_AddUserClick(Sender: TObject);
var s:String;
begin
s:=trim(Ed_addUser.Text);
if s='' then exit;
if CL_OraUserList.Items.IndexOf(s)<0 then
begin
if addTempUser=nil then
addTempUser:=TStringList.Create;
addTempUser.Add(s);
CL_OraUserList.Items.Add(s);
end;
end;
procedure TFr_OracleUser.SetFullCaption(isImp: String='');
var s:String;
begin
if CL_OraUserList.Items.Count<1 Then exit;
s:='全库导出';
if (isImp='imp') then
s:='全文导入';
CL_OraUserList.Items[0]:=s;
end;
procedure TFr_OracleUser.SetUserEdit(e_u, e_p, e_s,e_o: TEdit);
begin
self.ed_u:=e_u;
self.ed_p:=e_p;
self.ed_s:=e_s;
self.ed_o:=e_o;
end;
end.
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Delphi
1
https://gitee.com/xyxia/oraback.git
git@gitee.com:xyxia/oraback.git
xyxia
oraback
数据库备份
master

搜索帮助