|
@@ -96,9 +96,9 @@ type
|
|
|
FPath: string;
|
|
|
|
|
|
// -------------业务扩展,单机版本地也要存储管理附件,以下这部分适用于单机版。
|
|
|
- FLocalCon: TADOConnection;
|
|
|
- FLocalQue: TADOQuery;
|
|
|
- FLocalQue2: TADOQuery;
|
|
|
+// FLocalCon: TADOConnection;
|
|
|
+// FLocalQue: TADOQuery;
|
|
|
+// FLocalQue2: TADOQuery;
|
|
|
|
|
|
function GetItem(Index: Integer): TUpFile;
|
|
|
procedure Clear;
|
|
@@ -108,13 +108,13 @@ type
|
|
|
constructor Create;
|
|
|
destructor Destroy; override;
|
|
|
function Add(AUpFile: TUpFile): Integer; overload; // 返回索引号
|
|
|
- function Add(ABillID, APhase: Integer): TUpFile; overload;
|
|
|
-
|
|
|
+ function Add(ABillID: Integer): TUpFile; overload;
|
|
|
+ function Find(AID: Integer): TUpFile;
|
|
|
procedure Delete(AIndex: Integer); overload;
|
|
|
procedure Delete(AUpFile: TUpFile); overload;
|
|
|
procedure Exchange(AUpFile1, AUpFile2: TUpFile);
|
|
|
procedure LoadDatas;
|
|
|
- function LocalSaveToDB(AUpFile: TUpFile): Integer; // 返回ID
|
|
|
+// function LocalSaveToDB(AUpFile: TUpFile): Integer; // 返回ID
|
|
|
|
|
|
property Item[Index: Integer]: TUpFile read GetItem; default;
|
|
|
property Count: Integer read GetCount;
|
|
@@ -125,7 +125,8 @@ type
|
|
|
|
|
|
implementation
|
|
|
|
|
|
-uses ProjectData, Forms, PHPWebDm, CslJson, ConstUnit, UtilMethods;
|
|
|
+uses ProjectData, Forms, PHPWebDm, CslJson, ConstUnit, UtilMethods,
|
|
|
+ StdConvs;
|
|
|
|
|
|
{ TUpFile }
|
|
|
|
|
@@ -194,21 +195,22 @@ constructor TUpFiles.Create;
|
|
|
begin
|
|
|
FList := TList.Create;
|
|
|
|
|
|
- if not G_IsCloud then
|
|
|
- begin
|
|
|
- FLocalCon := TADOConnection.Create(nil);
|
|
|
- FLocalCon.LoginPrompt := False;
|
|
|
-
|
|
|
- FLocalQue := TADOQuery.Create(nil);
|
|
|
- FLocalQue.Connection := FLocalCon;
|
|
|
-
|
|
|
- FLocalQue2 := TADOQuery.Create(nil);
|
|
|
- FLocalQue2.Connection := FLocalCon;
|
|
|
- end;
|
|
|
+// if not G_IsCloud then
|
|
|
+// begin
|
|
|
+// FLocalCon := TADOConnection.Create(nil);
|
|
|
+// FLocalCon.LoginPrompt := False;
|
|
|
+//
|
|
|
+// FLocalQue := TADOQuery.Create(nil);
|
|
|
+// FLocalQue.Connection := FLocalCon;
|
|
|
+//
|
|
|
+// FLocalQue2 := TADOQuery.Create(nil);
|
|
|
+// FLocalQue2.Connection := FLocalCon;
|
|
|
+// end;
|
|
|
end;
|
|
|
|
|
|
procedure TUpFiles.Delete(AUpFile: TUpFile);
|
|
|
begin
|
|
|
+ if AUpFile = nil then Exit;
|
|
|
FList.Remove(AUpFile);
|
|
|
end;
|
|
|
|
|
@@ -223,15 +225,15 @@ begin
|
|
|
Clear;
|
|
|
FList.Free;
|
|
|
|
|
|
- if not G_IsCloud then
|
|
|
- begin
|
|
|
- FLocalQue.Close;
|
|
|
- FLocalQue.Free;
|
|
|
- FLocalQue2.Close;
|
|
|
- FLocalQue2.Free;
|
|
|
- FLocalCon.Close;
|
|
|
- FLocalCon.Free;
|
|
|
- end;
|
|
|
+// if not G_IsCloud then
|
|
|
+// begin
|
|
|
+// FLocalQue.Close;
|
|
|
+// FLocalQue.Free;
|
|
|
+// FLocalQue2.Close;
|
|
|
+// FLocalQue2.Free;
|
|
|
+// FLocalCon.Close;
|
|
|
+// FLocalCon.Free;
|
|
|
+// end;
|
|
|
|
|
|
inherited;
|
|
|
end;
|
|
@@ -260,7 +262,7 @@ end;
|
|
|
|
|
|
procedure TUpFiles.LoadDatas;
|
|
|
var vArrFile: TOVArr;
|
|
|
- i, iBillID, iPhase: Integer;
|
|
|
+ i, iBillID: Integer;
|
|
|
vFile: TUpFile;
|
|
|
begin
|
|
|
if G_IsCloud then
|
|
@@ -270,43 +272,43 @@ begin
|
|
|
for i := Low(vArrFile) to High(vArrFile) do
|
|
|
begin
|
|
|
iBillID := StrToInt(vArrFile[i, 4]);
|
|
|
- iPhase := 0; // AAAAA
|
|
|
- vFile := Add(iBillID, iPhase);
|
|
|
- vFile.ID := StrToInt(vArrFile[i, 9]);
|
|
|
- vFile.WebID := TProjectData(FProjectData).WebID;
|
|
|
+ vFile := Add(iBillID); // AAAAA
|
|
|
+ vFile.DownURL := vArrFile[i, 0];
|
|
|
+ vFile.DisplayName := vArrFile[i, 1];
|
|
|
+ vFile.LocalFile := FPath + vArrFile[i, 1];
|
|
|
+ vFile.Phase := StrToInt(vArrFile[i, 2]);
|
|
|
+ vFile.UperName := vArrFile[i, 3];
|
|
|
vFile.Category := vArrFile[i, 5];
|
|
|
vFile.Memo := vArrFile[i, 6];
|
|
|
vFile.UperID := StrToInt(vArrFile[i, 7]);
|
|
|
- vFile.UperName := vArrFile[i, 3];
|
|
|
vFile.UpTime := vArrFile[i, 8];
|
|
|
- vFile.LocalFile := FPath + vArrFile[i, 1];
|
|
|
- vFile.DisplayName := vArrFile[i, 1];
|
|
|
- vFile.DownURL := vArrFile[i, 0];
|
|
|
+ vFile.ID := StrToInt(vArrFile[i, 9]);
|
|
|
+ vFile.WebID := TProjectData(FProjectData).WebID;
|
|
|
vFile.Status := ufsNormal;
|
|
|
end;
|
|
|
end;
|
|
|
- end
|
|
|
- else
|
|
|
- begin
|
|
|
- FLocalQue.Close;
|
|
|
- FLocalQue.SQL.Text := 'Select * from AttachmentFile order by ID';
|
|
|
- FLocalQue.Open;
|
|
|
- FLocalQue.First;
|
|
|
-
|
|
|
- while not FLocalQue.Eof do
|
|
|
- begin
|
|
|
- iBillID := FLocalQue.FieldByName('BillID').AsInteger;
|
|
|
- iPhase := FLocalQue.FieldByName('Phase').AsInteger;
|
|
|
- vFile := Add(iBillID, iPhase);
|
|
|
- vFile.ID := FLocalQue.FieldByName('ID').AsInteger;
|
|
|
- vFile.LocalFile := FPath + FLocalQue.FieldByName('FileName').AsString;
|
|
|
- vFile.DisplayName := FLocalQue.FieldByName('FileName').AsString;
|
|
|
-
|
|
|
- FLocalQue.Next;
|
|
|
- end;
|
|
|
-
|
|
|
- FLocalCon.Close;
|
|
|
end;
|
|
|
+// else
|
|
|
+// begin
|
|
|
+// FLocalQue.Close;
|
|
|
+// FLocalQue.SQL.Text := 'Select * from AttachmentFile order by ID';
|
|
|
+// FLocalQue.Open;
|
|
|
+// FLocalQue.First;
|
|
|
+//
|
|
|
+// while not FLocalQue.Eof do
|
|
|
+// begin
|
|
|
+// iBillID := FLocalQue.FieldByName('BillID').AsInteger;
|
|
|
+// iPhase := FLocalQue.FieldByName('Phase').AsInteger;
|
|
|
+// vFile := Add(iBillID, iPhase);
|
|
|
+// vFile.ID := FLocalQue.FieldByName('ID').AsInteger;
|
|
|
+// vFile.LocalFile := FPath + FLocalQue.FieldByName('FileName').AsString;
|
|
|
+// vFile.DisplayName := FLocalQue.FieldByName('FileName').AsString;
|
|
|
+//
|
|
|
+// FLocalQue.Next;
|
|
|
+// end;
|
|
|
+//
|
|
|
+// FLocalCon.Close;
|
|
|
+// end;
|
|
|
end;
|
|
|
|
|
|
procedure TUpFile.SetID(const Value: Integer);
|
|
@@ -345,24 +347,24 @@ begin
|
|
|
FPath := PHPWeb.WebPath + 'Projects\' + IntToStr(TProjectData(FProjectData).WebID) + '\Attachment\';
|
|
|
if not DirectoryExists(FPath) then
|
|
|
ForceDirectories(FPath);
|
|
|
- end
|
|
|
- else
|
|
|
- begin
|
|
|
- FPath := ExtractFilePath(Application.ExeName) + '我的项目\Attachment\' + ExtractFileName(TProjectData(FProjectData).FileName) + '\';
|
|
|
- if not DirectoryExists(FPath) then
|
|
|
- ForceDirectories(FPath);
|
|
|
-
|
|
|
- sLAFM := FPath + 'LocalAttachmentFileManager.dat';
|
|
|
- sModelFile := ExtractFilePath(Application.ExeName) + 'Data\LocalAttachmentFileManager.dat';
|
|
|
- if not FileExists(sLAFM) then
|
|
|
- if not CopyFile(PChar(sModelFile), PChar(sLAFM), True) then
|
|
|
- begin
|
|
|
- Application.MessageBox(PChar('本地附件管理库模板文件“' + sModelFile + '”丢失或被占用无法复制。'), '警告', MB_OK + MB_ICONWARNING);
|
|
|
- Exit;
|
|
|
- end;
|
|
|
-
|
|
|
- FLocalCon.ConnectionString := Format('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;Persist Security Info=False;', [sLAFM]);
|
|
|
end;
|
|
|
+// else
|
|
|
+// begin
|
|
|
+// FPath := ExtractFilePath(Application.ExeName) + '我的项目\Attachment\' + ExtractFileName(TProjectData(FProjectData).FileName) + '\';
|
|
|
+// if not DirectoryExists(FPath) then
|
|
|
+// ForceDirectories(FPath);
|
|
|
+//
|
|
|
+// sLAFM := FPath + 'LocalAttachmentFileManager.dat';
|
|
|
+// sModelFile := ExtractFilePath(Application.ExeName) + 'Data\LocalAttachmentFileManager.dat';
|
|
|
+// if not FileExists(sLAFM) then
|
|
|
+// if not CopyFile(PChar(sModelFile), PChar(sLAFM), True) then
|
|
|
+// begin
|
|
|
+// Application.MessageBox(PChar('本地附件管理库模板文件“' + sModelFile + '”丢失或被占用无法复制。'), '警告', MB_OK + MB_ICONWARNING);
|
|
|
+// Exit;
|
|
|
+// end;
|
|
|
+//
|
|
|
+// FLocalCon.ConnectionString := Format('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;Persist Security Info=False;', [sLAFM]);
|
|
|
+// end;
|
|
|
end;
|
|
|
|
|
|
procedure TUpFile.SetOwner(const Value: TUpFiles);
|
|
@@ -392,14 +394,13 @@ begin
|
|
|
FIcon.Handle := sInfo.hIcon;
|
|
|
end;
|
|
|
|
|
|
-function TUpFiles.Add(ABillID, APhase: Integer): TUpFile;
|
|
|
+function TUpFiles.Add(ABillID: Integer): TUpFile;
|
|
|
var vFile: TUpFile;
|
|
|
begin
|
|
|
vFile := TUpFile.Create;
|
|
|
vFile.No := Add(vFile);
|
|
|
vFile.Owner := Self;
|
|
|
vFile.BillID := ABillID;
|
|
|
- vFile.Phase := APhase;
|
|
|
Result := vFile;
|
|
|
end;
|
|
|
|
|
@@ -408,24 +409,24 @@ begin
|
|
|
FOrgFile := Value;
|
|
|
end;
|
|
|
|
|
|
-function TUpFiles.LocalSaveToDB(AUpFile: TUpFile): Integer;
|
|
|
-begin
|
|
|
- try
|
|
|
- FLocalQue2.Close;
|
|
|
- FLocalQue2.SQL.Text := 'Select * from AttachmentFile where 1 < 0';
|
|
|
- FLocalQue2.Open;
|
|
|
- FLocalQue2.Append;
|
|
|
- FLocalQue2.FieldByName('BillID').AsInteger := AUpFile.BillID;
|
|
|
- FLocalQue2.FieldByName('Phase').AsInteger := AUpFile.Phase;
|
|
|
- FLocalQue2.FieldByName('FileName').AsString := AUpFile.DisplayName;
|
|
|
- FLocalQue2.Post;
|
|
|
- Result := FLocalQue2.FieldByName('ID').AsInteger;
|
|
|
- FLocalQue2.Close;
|
|
|
- except
|
|
|
- Result := -1;
|
|
|
- Application.MessageBox('本地保存失败,请重试!', '警告', MB_OK + MB_ICONWARNING);
|
|
|
- end;
|
|
|
-end;
|
|
|
+//function TUpFiles.LocalSaveToDB(AUpFile: TUpFile): Integer;
|
|
|
+//begin
|
|
|
+// try
|
|
|
+// FLocalQue2.Close;
|
|
|
+// FLocalQue2.SQL.Text := 'Select * from AttachmentFile where 1 < 0';
|
|
|
+// FLocalQue2.Open;
|
|
|
+// FLocalQue2.Append;
|
|
|
+// FLocalQue2.FieldByName('BillID').AsInteger := AUpFile.BillID;
|
|
|
+// FLocalQue2.FieldByName('Phase').AsInteger := AUpFile.Phase;
|
|
|
+// FLocalQue2.FieldByName('FileName').AsString := AUpFile.DisplayName;
|
|
|
+// FLocalQue2.Post;
|
|
|
+// Result := FLocalQue2.FieldByName('ID').AsInteger;
|
|
|
+// FLocalQue2.Close;
|
|
|
+// except
|
|
|
+// Result := -1;
|
|
|
+// Application.MessageBox('本地保存失败,请重试!', '警告', MB_OK + MB_ICONWARNING);
|
|
|
+// end;
|
|
|
+//end;
|
|
|
|
|
|
procedure TUpFile.SetPhase(const Value: Integer);
|
|
|
begin
|
|
@@ -442,4 +443,21 @@ begin
|
|
|
Result := ExtractFileExt(DisplayName);
|
|
|
end;
|
|
|
|
|
|
+function TUpFiles.Find(AID: Integer): TUpFile;
|
|
|
+var i: Integer;
|
|
|
+ vUpFile: TUpFile;
|
|
|
+begin
|
|
|
+ vUpFile := nil;
|
|
|
+ for i := 0 to FList.Count - 1 do
|
|
|
+ begin
|
|
|
+ vUpFile := TUpFile(FList[i]);
|
|
|
+ if vUpFile.ID = AID then
|
|
|
+ begin
|
|
|
+ Result := vUpFile;
|
|
|
+ Break;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+end;
|
|
|
+
|
|
|
+
|
|
|
end.
|