代码拉取完成,页面将自动刷新
unit U_impmain;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, CheckLst, ExtCtrls, Buttons, ComCtrls, Spin, U_orauser,Alarm;
type
Tfrm_ImportMain = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
GroupBox3: TGroupBox;
Label8: TLabel;
Label7: TLabel;
Label9: TLabel;
Label10: TLabel;
lastTime: TLabel;
runCount: TLabel;
Dt_Time: TDateTimePicker;
Dt_Date: TDateTimePicker;
Ed_Name: TEdit;
SP_SaveScheme: TSpeedButton;
export: TSpeedButton;
ListView1: TListView;
GroupBox1: TGroupBox;
Bevel2: TBevel;
Fr_OracleUser1: TFr_OracleUser;
OpenDialog1: TOpenDialog;
Label5: TLabel;
Ed_FileName: TEdit;
Sp_SelectFile: TSpeedButton;
Label6: TLabel;
Ed_User2: TEdit;
Label11: TLabel;
Ed_Pass2: TEdit;
Label12: TLabel;
Ed_Role: TEdit;
Label13: TLabel;
Ed_IndexFile: TEdit;
Sp_SetIndexFile: TSpeedButton;
Ck_DelUser: TCheckBox;
Ck_CreateUser: TCheckBox;
Cb_Cycle: TComboBox;
Ck_OnlyIndexFile: TCheckBox;
Label14: TLabel;
Ed_Grant: TEdit;
Sp_SetUserRole: TSpeedButton;
Sp_SetUserGrant: TSpeedButton;
Panel4: TPanel;
CL_EXPParam: TCheckListBox;
Panel5: TPanel;
Label4: TLabel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
SB_TestConn: TSpeedButton;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
ED_User: TEdit;
ED_Pass: TEdit;
ED_ArcDir: TEdit;
ED_Server: TEdit;
Se_buffer: TSpinEdit;
Se_filesize: TSpinEdit;
se_commit: TSpinEdit;
SaveDialog1: TSaveDialog;
Label19: TLabel;
Ed_OracleHome: TEdit;
ED_Server2: TEdit;
Label22: TLabel;
Cb_inctype: TComboBox;
procedure SP_SaveSchemeClick(Sender: TObject);
procedure Fr_OracleUser1SB_OraUserClick(Sender: TObject);
procedure SB_TestConnClick(Sender: TObject);
procedure CL_EXPParamClick(Sender: TObject);
procedure CL_EXPParamClickCheck(Sender: TObject);
procedure exportClick(Sender: TObject);
procedure ListView1Click(Sender: TObject);
procedure Sp_SelectFileClick(Sender: TObject);
procedure Sp_SetIndexFileClick(Sender: TObject);
procedure Fr_OracleUser1seleBClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Fr_OracleUser1SP_AddUserClick(Sender: TObject);
private
{ Private declarations }
CHECKCLICK:Boolean;
PreImpStr:String;
procedure GetSchemeList;
procedure GetCurrentScheme(SectName: String; ValueName:array of String;var value:array of String);
procedure LoadParFile;
procedure ShowCurrentScheme(name:String;getOraUser:Boolean);
procedure SetCurrentScheme;
procedure SetExpParamCurrent(value: TStrings);
procedure ShowLastTime;
function SaveCurrentScheme(name: String): integer;
procedure WriteTheScheme(name: String; var sch: array of String);
function getTempParam: String;
procedure SaveTempScheme;
function OpenDMPFile(fileName: String): String;
function SaveIndexFile(fileName: String): String;
public
{ Public declarations }
function FrmShow: Integer;
end;
var
frm_ImportMain: Tfrm_ImportMain;
implementation
uses U_COMMFUNC,inifiles, U_des;
{$R *.DFM}
function Tfrm_ImportMain.FrmShow:Integer;
var i:integer;
begin
frm_ImportMain:= Tfrm_ImportMain.Create(Application);
frm_ImportMain.Fr_OracleUser1.ME_TableName.Clear;
frm_ImportMain.GetSchemeList;
frm_ImportMain.PreImpStr:='IMP_';
if (frm_ImportMain.ListView1.Selected<>nil) then
begin
i:=frm_ImportMain.ListView1.Selected.Index;
if i>-1 then
frm_ImportMain.ShowCurrentScheme(IMP_SECTION_NAME+IntToStr(i+1),false);
end;
frm_ImportMain.Fr_OracleUser1.SetFullCaption('imp');
frm_ImportMain.ShowModal;
Result:=0;
frm_ImportMain.Release;
end;
//以下显示当前方案
procedure Tfrm_ImportMain.GetSchemeList;
var ini:TIniFile;
current:String;// s,
i:Integer;
Alist:tlistitem;
s:String;
begin
ini:=TIniFile.Create(iniFileName);
current:=ini.ReadString('MAIN','IMPCURRENT','缺省');
IMPScheme_Count:=Strtoint(ini.ReadString('MAIN','IMPCOUNT','0'));
ListView1.Items.BeginUpdate;
ListView1.Items.Clear;
ListView1.Items.EndUpdate;
for i := 0 to IMPScheme_Count-1 do
begin
s:=ini.ReadString(IMP_SECTION_NAME+IntToStr(i+1),IMPSCHEME_VALUES[0],'缺省');
Alist:=listview1.Items.Add;
Alist.Caption:=s;
Alist.SubItems.Add(ini.ReadString(IMP_SECTION_NAME+IntToStr(i+1),IMPSCHEME_VALUES[15],DEFAULT_DMP_FILENAME));
Alist.SubItems.Add(ini.ReadString(IMP_SECTION_NAME+IntToStr(i+1),IMPSCHEME_VALUES[19],'0'));
Alist.SubItems.Add(ini.ReadString(IMP_SECTION_NAME+IntToStr(i+1),IMPSCHEME_VALUES[18],''));
end;
ini.Destroy;
Alist:=ListView1.FindCaption(0,current,false,true,true);
if Alist =nil then
Alist:=ListView1.TopItem;// Items[0];
ListView1.Selected:=Alist;
end;
procedure Tfrm_ImportMain.GetCurrentScheme(SectName:String;ValueName:array of String;var value:array of String);//;readParile:Boolean);//=true
var ini: TIniFile;
i:Integer;
begin
ini:=TIniFile.Create(iniFileName);
for i := 0 to length(ValueName)-1 do
begin
if ValueName[i]='' then
value[i]:=''
else
value[i]:=ini.ReadString(SectName,ValueName[i],'');
end;
ini.Destroy;
If value[3]='' Then
value[3]:=FormatDateTime('YYYY-MM-DD',date);
If value[4]='' Then
value[4]:='0';
If value[2]='' Then
value[2]:='00:00:00';
If value[9]='' Then
value[9]:='0';
If value[10]='' Then
value[10]:='0';
If value[14]='' Then
value[14]:='0';
If value[19]='' Then //运行次数
value[19]:='0';
If value[20]='' Then
value[20] := OracleDir;
If value[21]='' Then
value[21] := value[7];
If value[22]='' Then
value[22] := '0';
end;
procedure Tfrm_ImportMain.LoadParFile;
var s:String;
begin
try
Fr_OracleUser1.ParStringList.Clear;
s:=GetParFileName(PreImpStr+IMPCurrent_Scheme_Values[1]);
if FileExists(s) then
Fr_OracleUser1.ParStringList.LoadFromFile(s);
except end;
end;
procedure Tfrm_ImportMain.SetCurrentScheme;
begin
Ed_Name.Text:=IMPCurrent_Scheme_Values[0];
Dt_Time.Time:=StrToTime(IMPCurrent_Scheme_Values[2]);
Dt_Date.Date:=StrToDate(IMPCurrent_Scheme_Values[3]);
Cb_Cycle.ItemIndex:=StrToInt(IMPCurrent_Scheme_Values[4]);
ED_User.Text:=IMPCurrent_Scheme_Values[5];
ED_Pass.Text:=decode_string(IMPCurrent_Scheme_Values[6]);
ED_Server.Text:=IMPCurrent_Scheme_Values[7];
ED_ArcDir.Text:=IMPCurrent_Scheme_Values[8];
Ck_DelUser.Checked:=IMPCurrent_Scheme_Values[9]='1';
Ck_CreateUser.Checked:=IMPCurrent_Scheme_Values[10]='1';
Ed_Role.Text:=IMPCurrent_Scheme_Values[11];
Ed_Grant.Text:=IMPCurrent_Scheme_Values[12];
Ed_IndexFile.Text:=IMPCurrent_Scheme_Values[13];
Ck_OnlyIndexFile.Checked:=IMPCurrent_Scheme_Values[14]='1';
Ed_FileName.Text:=IMPCurrent_Scheme_Values[15];
Ed_User2.Text:=IMPCurrent_Scheme_Values[16];
Ed_Pass2.Text:=IMPCurrent_Scheme_Values[17];
ShowLastTime;
Ed_OracleHome.Text:=IMPCurrent_Scheme_Values[20];
ED_Server2.Text:=IMPCurrent_Scheme_Values[21];
Cb_inctype.ItemIndex := StrToInt(IMPCurrent_Scheme_Values[22]);
SetExpParamCurrent(Fr_OracleUser1.ParStringList);
end;
procedure Tfrm_ImportMain.SetExpParamCurrent(value:TStrings);
var
i:Integer;
s:string;
b:boolean;
begin
If value.Count<1 Then exit;
for i := 0 to Length(IMP_PARAM[0])-1 do
begin
s:=IMP_PARAM[1,i];
b:=false;
If IMP_PARAM[2,i]<>'' Then
begin
s:=s+'='+YESWORD;
end;
If value.IndexOf(s)>=0 Then
b:=true;
CL_EXPParam.Checked[i]:=b;
end;
Fr_OracleUser1.ShowFullDatabase(value.IndexOf('FULL=Y')>=0);
ShowExpTables(value,Fr_OracleUser1.ME_TableName);
ShowExpOwners(value,Fr_OracleUser1.ME_TableName,Fr_OracleUser1.CL_OraUserList);
ShowOtherParam(self,value,true);
end;
procedure Tfrm_ImportMain.ShowCurrentScheme(name:String;getOraUser:Boolean);
begin
GetCurrentScheme(name,IMPSCHEME_VALUES,IMPCurrent_Scheme_Values);
if Fr_OracleUser1.ParStringList=nil then
Fr_OracleUser1.ParStringList:=TStringList.Create;
LoadParFile;
SetExpParamDefault(CL_EXPParam,IMP_PARAM[0],IMP_PARAM[2]);
SetCurrentScheme;
if getOraUser then
Fr_OracleUser1SB_OraUserClick(self)
Else Begin
If Fr_OracleUser1.CL_OraUserList.Items.Count<1 Then
Fr_OracleUser1.CL_OraUserList.Items.Add('全库导出');
End;
end;
procedure Tfrm_ImportMain.ShowLastTime;
begin
lastTime.Caption:='上次时间:'+IMPCurrent_Scheme_Values[18];
runCount.Caption:='次数:'+IMPCurrent_Scheme_Values[19];
end;
//以上为显示部分
//以下为函数和过程
function Tfrm_ImportMain.SaveCurrentScheme(name:String):integer;
var
index,count:Integer;
begin
Result:=2;
WriteTheScheme(name,IMPCurrent_Scheme_Values);
name:=IMPCurrent_Scheme_Values[0];
if (ListView1.FindCaption(0,name,false,false,false)<>nil) then
index:=ListView1.FindCaption(0,name,false,false,false).Index+1
else index:=-1;
count:=0;
If index<1 Then
Begin
inc(IMPScheme_Count);
index:=IMPScheme_Count;
IMPCurrent_Scheme_Values[18]:='';
IMPCurrent_Scheme_Values[19]:='0';
Result:=1;
count:=IMPScheme_Count;
End;
if IMPCurrent_Scheme_Values[19]='' then
IMPCurrent_Scheme_Values[19]:='0';
WriteIniParam(index,count,1,IMPSCHEME_VALUES,IMPCurrent_Scheme_Values);
end;
procedure Tfrm_ImportMain.WriteTheScheme(name:String;var sch:array of String);
begin
If name='' Then name:=Ed_Name.Text;
If name='' Then name:=ListView1.Selected.Caption;
sch[0]:=name;
sch[1]:=name;
sch[2]:=TimeToStr(Dt_Time.Time);
sch[3]:=FormatDateTime('YYYY-MM-DD',Dt_Date.Date);// Edit6.Text;
sch[4]:=IntToStr(Cb_Cycle.ItemIndex);
sch[5]:=ED_User.Text;
sch[6]:=encode_string(ED_Pass.Text);
sch[7]:=ED_Server.Text;
sch[8]:=ED_ArcDir.Text;
IF Ck_DelUser.Checked THEN
sch[9]:='1'
ELSE
sch[9]:='0';
IF Ck_CreateUser.Checked THEN
sch[10]:='1'
ELSE
sch[10]:='0';
sch[11]:=Ed_Role.Text;
sch[12]:=Ed_Grant.Text;
sch[13]:=Ed_IndexFile.Text;
IF Ck_OnlyIndexFile.Checked THEN
sch[14]:='1'
ELSE
sch[14]:='0';
sch[15]:=Ed_FileName.Text;
sch[16]:=ED_User2.Text;
sch[17]:=encode_string(ED_Pass2.Text);
sch[20]:=Ed_OracleHome.Text;
sch[21] := trim(ED_Server2.Text);
sch[22] := IntToStr(Cb_inctype.ItemIndex);;
end;
procedure Tfrm_ImportMain.SaveTempScheme;
var
s:String;
Temp_Scheme_Values:Array[0..ImportParamCount] Of String;
begin
s:='IMPTEMP';
WriteTheScheme(s,Temp_Scheme_Values);
WriteIniParam(0,0,1,IMPSCHEME_VALUES,Temp_Scheme_Values);
end;
function Tfrm_ImportMain.getTempParam:String;
var param:String;
begin
setDatabaseParam(Ed_OracleHome.Text,ED_Server2.Text);
param:='';
param:=nvl(ED_User.Text,'NULL')+' '+nvl(CheckLastDir(trim(Ed_OracleHome.Text)),'NULL')+' '+nvl(ED_Pass.Text,'NULL')+'@'+nvl(ED_Server.Text,'NULL')+' '+nvl(ED_ArcDir.Text,workdir)+' ';
param:= param+winrarPath;
param:= param+' '+ServerDate+' ';
param:= param+Fr_OracleUser1.SetParFile('temp',IMPCurrent_Scheme_Values[1]
,frm_ImportMain,CL_EXPParam,IMP_PARAM[1],IMP_PARAM[2],PreImpStr)+' temp';//+IntToStr(RadioGroup1.ItemIndex);
param:= param +' '+nvl(Ed_FileName.Text,'NULL');
SaveTempScheme;
Result:=param;
end;
function Tfrm_ImportMain.OpenDMPFile(fileName:String):String;
var s:String;
begin
result:=fileName;
OpenDialog1.FileName:=ExtractFileName(fileName);
OpenDialog1.Filter:='DMP文件(*.DMP)|*.dmp|SQL文件(*.sql)|*.dmp|所有文件(*.*)|*.*';
fileName:=ExtractFilePath(fileName);
If s<>'' Then
OpenDialog1.InitialDir:=fileName
Else
OpenDialog1.InitialDir:=WorkDir;
If OpenDialog1.Execute Then
result:=OpenDialog1.FileName;
end;
function Tfrm_ImportMain.SaveIndexFile(fileName:String):String;
var s:String;
begin
result:=fileName;
SaveDialog1.FileName:=ExtractFileName(fileName);
SaveDialog1.Filter:='SQL文件(*.sql)|*.dmp|所有文件(*.*)|*.*';
fileName:=ExtractFilePath(fileName);
If s<>'' Then
SaveDialog1.InitialDir:=fileName
Else
SaveDialog1.InitialDir:=WorkDir;
If SaveDialog1.Execute Then
result:=SaveDialog1.FileName;
end;
//以上为函数和过程
//以下为事件 过程
procedure Tfrm_ImportMain.SP_SaveSchemeClick(Sender: TObject);
begin
SetCurrentDir(workdir);
SaveCurrentScheme('');
Fr_OracleUser1.SetParFile(Ed_Name.Text,IMPCurrent_Scheme_Values[1]
,frm_ImportMain,CL_EXPParam,IMP_PARAM[1],IMP_PARAM[2],PreImpStr);
SaveLogFile(3);
end;
procedure Tfrm_ImportMain.Fr_OracleUser1SB_OraUserClick(Sender: TObject);
begin
Fr_OracleUser1.GetOracleUser(ED_User.Text,ED_Pass.Text,ED_Server2.Text,Ed_OracleHome.Text);
end;
procedure Tfrm_ImportMain.SB_TestConnClick(Sender: TObject);
begin
SetOracleEnv(Ed_OracleHome.Text,true);
Fr_OracleUser1.TestConntion(ED_User.Text,ED_Pass.Text,ED_Server2.Text);
end;
procedure Tfrm_ImportMain.CL_EXPParamClick(Sender: TObject);
begin
if not CHECKCLICK Then
Begin
SETSELECT(Sender);
End;
CHECKCLICK:=false;
end;
procedure Tfrm_ImportMain.CL_EXPParamClickCheck(Sender: TObject);
begin
CHECKCLICK:=TRUE;
end;
procedure Tfrm_ImportMain.exportClick(Sender: TObject);
var param,logFile,parfile:String;
begin
logFile:=ED_User.Text;
SetCurrentDir(workdir);
If not FileExists(logFile+'\log') Then
CreateDir(logFile+'\log');
setDatabaseParam(Ed_OracleHome.Text,ED_Server2.Text);
ServerDate:=getServerDate(ED_User.Text,ED_Pass.Text,ED_Server2.Text,Ed_OracleHome.Text);
logFile:='IMP_'+logFile+'-'+ServerDate;
If IMPCurrent_Scheme_Values[1]<>PAR_DEFAULT_FILE Then
logFile:=logFile+'_'+parfile;
logFile:=logFile+'.log';
param:=getTempParam;
RunBack(param,ImportName);
SaveLogFile(4);
end;
procedure Tfrm_ImportMain.ListView1Click(Sender: TObject);
var i:integer;
begin
i:=0;
if ListView1.Selected<>nil then
i:=ListView1.Selected.Index;
if i>-1 then
ShowCurrentScheme(IMP_SECTION_NAME+IntToStr(i+1),false);
end;
procedure Tfrm_ImportMain.Sp_SelectFileClick(Sender: TObject);
var s:String;
begin
s:=Ed_FileName.Text;
s:=OpenDMPFile(s);
Ed_FileName.Text:=s;
end;
procedure Tfrm_ImportMain.Sp_SetIndexFileClick(Sender: TObject);
var s:String;
begin
s:=Ed_IndexFile.Text;
s:=SaveIndexFile(s);
Ed_IndexFile.Text:=s;
end;
procedure Tfrm_ImportMain.Fr_OracleUser1seleBClick(Sender: TObject);
begin
setDatabaseParam(Ed_OracleHome.Text,ED_Server2.Text);
Fr_OracleUser1.seleBClick(Sender);
end;
procedure Tfrm_ImportMain.FormCreate(Sender: TObject);
begin
Fr_OracleUser1.SetUserEdit(ED_User,ED_Pass,ED_Server2,Ed_OracleHome);
SetTheItems(Cb_Cycle.Items,RUN_CYCLE);
end;
procedure Tfrm_ImportMain.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if Fr_OracleUser1.ParStringList <> nil then
Fr_OracleUser1.ParStringList.Destroy;
if Fr_OracleUser1.addTempUser <> nil then
Fr_OracleUser1.addTempUser.Destroy;
end;
procedure Tfrm_ImportMain.Fr_OracleUser1SP_AddUserClick(Sender: TObject);
begin
Fr_OracleUser1.SP_AddUserClick(Sender);
end;
end.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。