You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

350 lines
10 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

unit u_update;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, bsSkinData, BusinessSkinForm, bsSkinCtrls, DB, ADODB,inifiles,
VCLUnZip, VCLZip, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP;
type
Tfrmsoftupdate = class(TForm)
Label1: TLabel;
Edit1: TEdit;
bsBusinessSkinForm1: TbsBusinessSkinForm;
bsSkinData1: TbsSkinData;
bsStoredSkin1: TbsStoredSkin;
bsSkinButton1: TbsSkinButton;
Edit2: TEdit;
Label2: TLabel;
Label3: TLabel;
Edit3: TEdit;
VCLZip1: TVCLZip;
bsBusinessSkinForm2: TbsBusinessSkinForm;
bsSkinData2: TbsSkinData;
bsStoredSkin2: TbsStoredSkin;
Label4: TLabel;
Edit4: TEdit;
bsSkinButton2: TbsSkinButton;
t_sys_soft_update: TADOQuery;
p_update: TADOStoredProc;
db_update: TADOConnection;
t_sql: TADOQuery;
t_readme: TADOQuery;
db: TADOConnection;
Label5: TLabel;
Edit5: TEdit;
GroupBox1: TGroupBox;
Memo1: TMemo;
bsSkinCheckRadioBox1: TbsSkinCheckRadioBox;
bsSkinButton3: TbsSkinButton;
t_update: TADOQuery;
t_view_update: TADOQuery;
t_sys_soft_do: TADOQuery;
t_sys_soft_doDSDesigner: TStringField;
t_sys_soft_doDSDesigner2: TBlobField;
t_sys_soft_doDSDesigner1: TStringField;
t_sys_soft_doDSDesigner22: TStringField;
t_sys_soft_doDSDesigner3: TStringField;
Label6: TLabel;
Edit8: TEdit;
t_max_sql: TADOQuery;
Button1: TButton;
IdHTTP1: TIdHTTP;
procedure bsSkinButton1Click(Sender: TObject);
procedure bsSkinButton2Click(Sender: TObject);
procedure db_updateBeforeConnect(Sender: TObject);
procedure dbBeforeConnect(Sender: TObject);
procedure bsSkinButton3Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function GetFileVersion(FileName: string): string;
end;
var
frmsoftupdate: Tfrmsoftupdate;
implementation
uses update_sql_readme;
{$R *.dfm}
procedure Tfrmsoftupdate.bsSkinButton1Click(Sender: TObject);
var
table:Tadoquery;
inifile1:Tinifile;
str:string;
j,i:integer;
if_add:boolean;
TempStr,Stemp:TStringlist;
begin
Memo1.Lines.Clear;
Memo1.Lines.Add('<27><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>'+DateTimeToStr(NOW));
try
db.Connected:=true;
except
showmessage('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>');
Memo1.Lines.Add('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>');
end;
TempStr:=TStringList.Create;
Stemp:=TStringList.Create;
try
table:=Tadoquery.Create(application);
table.Connection:=db;
table.SQL.text:='select top 1 <20><EFBFBD><E6B1BE> from t_sys_soft order by <20><EFBFBD><E6B1BE> desc ';
table.open;
t_max_sql.Open;
Memo1.Lines.Add('<27><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6B1BE>:'+table.fieldbyname('<27><EFBFBD><E6B1BE>').asstring);
Memo1.Lines.Add('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>'+t_max_sql.fieldbyname('<27><EFBFBD><E6B1BE>').AsString);
if bsSkinCheckRadioBox1.Checked then begin
str:=table.fieldbyname('<27><EFBFBD><E6B1BE>').AsString;
str:=StringReplace(str,'.','',[rfReplaceAll]);
t_sql.close;
t_sql.Parameters.ParamByName('<27><EFBFBD><E6B1BE>').value:=str;
t_sql.open;
if t_sql.IsEmpty then
begin
showmessage('<27><>ǰ<EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>°汾<C2B0><E6B1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
Memo1.Lines.Add('<27><>ǰ<EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>°汾<C2B0><E6B1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
table.free;
exit;
end;
t_sql.first;
while not t_sql.eof do
begin
TempStr.Text:=t_sql.fieldbyname('ִ<><D6B4>').asstring;
try
Memo1.Lines.Add('ִ<>а<D0B0><E6B1BE>'+t_sql.FieldByName('<27><EFBFBD><E6B1BE>').AsString+'˳<><CBB3>'+t_sql.FieldByName('˳<><CBB3>').AsString+'<27><>');
for i:=0 to TempStr.Count-1 do begin
if (TRIM(UpperCase(TempStr[i]))<>'GO') then
stemp.add(TempStr[i])
else begin
if (Stemp.Text)<>'' then begin
frmsoftupdate.p_update.close;
frmsoftupdate.p_update.Parameters.ParamByName('@sSQL').value:=Stemp.Text;
frmsoftupdate.p_update.Parameters.ParamByName('@pi_Result').value:=0;
frmsoftupdate.p_update.Parameters.ParamByName('@ps_Message').value:='';
frmsoftupdate.p_update.ExecProc;
stemp.Clear;
end;
end;
end;
if (Stemp.Text)<>'' then begin
frmsoftupdate.p_update.close;
frmsoftupdate.p_update.Parameters.ParamByName('@sSQL').value:=Stemp.Text;
frmsoftupdate.p_update.Parameters.ParamByName('@pi_Result').value:=0;
frmsoftupdate.p_update.Parameters.ParamByName('@ps_Message').value:='';
frmsoftupdate.p_update.ExecProc;
stemp.Clear;
end;
except
on e:Exception do begin
Memo1.Lines.Add('ִ<>а<D0B0><E6B1BE>'+t_sql.FieldByName('<27><EFBFBD><E6B1BE>').AsString+'˳<><CBB3>'+t_sql.FieldByName('˳<><CBB3>').AsString+'ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
Memo1.Lines.Add(e.Message);
Abort;
end;
end;
t_sql.next;
end;
end;
table.close;
table.open;
table.free;
showmessage('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD>');
Memo1.Lines.Add('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><CAB1>'+DateTimeToStr(Now));
FreeAndNil(TempStr);
FreeAndNil(Stemp);
// close;
except
showmessage('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
Memo1.Lines.Add('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7><><CAB1>'+DateTimeToStr(Now));
FreeAndNil(TempStr);
FreeAndNil(Stemp);
end;
Memo1.Lines.SaveToFile(ExtractFilePath(Application.ExeName)+FormatDateTime('YYYYMMDDHHNNSS',NOW)+'.txt');
end;
procedure Tfrmsoftupdate.bsSkinButton2Click(Sender: TObject);
begin
close;
end;
procedure Tfrmsoftupdate.db_updateBeforeConnect(Sender: TObject);
begin
db_update.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source='
+ExtractFilePath(Application.ExeName)+'update.mdb;'
+'Mode=Share Deny None;Extended Properties="";'
+'Jet OLEDB:System database="";Jet OLEDB:Registry Path="";'
+'Jet OLEDB:Database Password="";Jet OLEDB:Engine Type=5;'
+'Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;'
+'Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";'
+'Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;'
+'Jet OLEDB:Don'+''''+'t Copy Locale on Compact=False;'
+'Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False';
end;
procedure Tfrmsoftupdate.dbBeforeConnect(Sender: TObject);
var
str:string;
begin
str:='';
str:='Provider=SQLOLEDB.1;';
str:=str+'Password='+Edit3.text+';';
str:=str+'Persist Security Info=False;';
str:=str+'User ID='+Edit2.text+';';
str:=str+'Initial Catalog='+Edit4.text+';';
str:=str+'Data Source='+Edit1.text+';';
db.ConnectionString:=str;
end;
procedure Tfrmsoftupdate.bsSkinButton3Click(Sender: TObject);
begin
try
db.Connected:=true;
except
showmessage('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>');
Memo1.Lines.Add('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>');
exit;
end;
if not t_sys_soft_do.Active then
t_sys_soft_do.open;
frmsoftupdate.Caption:=frmsoftupdate.Caption+' '+t_sys_soft_do.fieldbyname('<27>汾1').asstring+t_sys_soft_do.fieldbyname('<27>汾2').asstring+t_sys_soft_do.fieldbyname('<27>汾3').asstring;
frmupdatesql:=Tfrmupdatesql.Create(Self);
try
frmupdatesql.ShowModal;
finally
FreeAndNil(frmupdatesql);
end;
end;
procedure Tfrmsoftupdate.FormShow(Sender: TObject);
var
inifile1:Tinifile;
str,s_ver,s,s3,s4:string;
table:Tadoquery;
begin
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
str:=inifile1.ReadString('database','Password','');
Edit3.Text:=copy(str,1,length(str)-1);
str:=inifile1.ReadString('database','User ID','');
Edit2.text:=copy(str,1,length(str)-1);
str:=inifile1.ReadString('database','Initial Catalog','');
Edit4.Text:=copy(str,1,length(str)-1);
str:=inifile1.ReadString('database','Data Source','');
edit1.text:=copy(str,1,length(str)-1);
inifile1.free;
try
db.Connected:=true;
except
showmessage('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>');
Memo1.Lines.Add('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>');
end;
try
table:=Tadoquery.Create(application);
table.Connection:=db;
table.SQL.text:='select top 1 <20><EFBFBD><E6B1BE> from t_sys_soft order by <20><EFBFBD><E6B1BE> desc';
table.open;
str:=table.fieldbyname('<27><EFBFBD><E6B1BE>').AsString;
str:=StringReplace(str,'.','',[rfReplaceAll]);
Edit8.Text:=str;
finally
table.Free;
end;
t_max_sql.Close;
t_max_sql.open;
Edit5.Text:=t_max_sql.fieldbyname('<27><EFBFBD><E6B1BE>').asstring;
end;
function Tfrmsoftupdate.GetFileVersion(FileName: string): string;
type
PVerInfo = ^TVS_FIXEDFILEINFO;
TVS_FIXEDFILEINFO = record
dwSignature: longint;
dwStrucVersion: longint;
dwFileVersionMS: longint;
dwFileVersionLS: longint;
dwFileFlagsMask: longint;
dwFileFlags: longint;
dwFileOS: longint;
dwFileType: longint;
dwFileSubtype: longint;
dwFileDateMS: longint;
dwFileDateLS: longint;
end;
var
ExeNames: array[0..255] of char;
zKeyPath: array[0..255] of Char;
VerInfo: PVerInfo;
Buf: pointer;
Sz: word;
L, Len: Cardinal;
begin
StrPCopy(ExeNames, FileName);
Sz := GetFileVersionInfoSize(ExeNames, L);
if Sz=0 then
begin
Result:='';
Exit;
end;
try
GetMem(Buf, Sz);
try
GetFileVersionInfo(ExeNames, 0, Sz, Buf);
if VerQueryValue(Buf, '\', Pointer(VerInfo), Len) then
begin
Result := IntToStr(HIWORD(VerInfo.dwFileVersionMS)) + '.' +
IntToStr(LOWORD(VerInfo.dwFileVersionMS)) + '.' +
IntToStr(HIWORD(VerInfo.dwFileVersionLS)) + '.' +
IntToStr(LOWORD(VerInfo.dwFileVersionLS));
end;
finally
FreeMem(Buf);
end;
except
Result := '-1';
end;
end;
procedure Tfrmsoftupdate.Button1Click(Sender: TObject);
var
DownLoadFile:TFileStream;
begin
DownLoadFile:=TFileStream.Create('c:\aa.rar',fmCreate);
IdHTTP1.Get('http://123.57.17.72:8008/tools/setup.rar',DownLoadFile);
DownLoadFile.Free;
end;
end.