Browse Source

修改导出文件同名提示相关,不再集成至导出类中。

MaiXinRong 10 years atrás
parent
commit
5fc5183a09
4 changed files with 15 additions and 13 deletions
  1. 3 0
      Forms/MainFrm.pas
  2. 1 1
      Frames/ProjectFme.pas
  3. 6 2
      Frames/ProjectManagerFme.pas
  4. 5 10
      Units/ProjectCommands.pas

+ 3 - 0
Forms/MainFrm.pas

@@ -709,6 +709,9 @@ begin
   sFileName := SupportManager.ConfigInfo.OutputPath + CurProjectFrame.ProjectData.ProjectName;
   if SaveFile(sFileName, '.ctf') then
   begin
+    if FileExists(sFileName) and not QuestMessage(Format('存在同名文件“%s”,是否替换?', [ExtractFileName(sFileName)])) then
+      Exit;
+
     Screen.Cursor := crHourGlass;
     try
       Rec := ProjectManagerFrame.Rec(CurProjectFrame.ProjectData.ProjectID);

+ 1 - 1
Frames/ProjectFme.pas

@@ -808,7 +808,7 @@ begin
 
       // Éú³ÉÎÞËøÎļþ
       vRec := MainForm.ProjectManagerFrame.Rec(ProjectData.ProjectID);
-      vExportor := TTenderExport.Create(vRec, sAppFile_UnLock, True);
+      vExportor := TTenderExport.Create(vRec, sAppFile_UnLock);
       try
         vExportor.Execute;
       finally

+ 6 - 2
Frames/ProjectManagerFme.pas

@@ -905,6 +905,9 @@ procedure TProjectManagerFrame.actnExportExecute(Sender: TObject);
     sFileName := SupportManager.ConfigInfo.OutputPath + ANode.Rec.ValueByName('Name').AsString + '.mtf';
     if SaveFile(sFileName, '.mtf') then
     begin
+      if FileExists(sFileName) and not QuestMessage(Format('存在同名文件“%s”,是否替换?', [ExtractFileName(sFileName)])) then
+        Exit;
+
       Screen.Cursor := crHourGlass;
       try
         Exportor := TTenderExport.Create(ANode.Rec, sFileName);
@@ -938,6 +941,9 @@ procedure TProjectManagerFrame.actnExportExecute(Sender: TObject);
     sFileName := SupportManager.ConfigInfo.OutputPath + ANode.Rec.ValueByName('Name').AsString + '.mpf';
     if SaveFile(sFileName, '.mpf') then
     begin
+      if FileExists(sFileName) and not QuestMessage(Format('存在同名文件“%s”,是否替换?', [ExtractFileName(sFileName)])) then
+        Exit;
+
       Screen.Cursor := crHourGlass;
       try
         bExpAtch := False;
@@ -969,10 +975,8 @@ begin
   stnNode := stdProjects.IDTree.Selected;
   if stnNode.Rec.ValueByName('Type').AsInteger = 1 then
   begin
-
     ExportTender(stnNode);
   end
-
   else
     ExportProject(stnNode);
 end;

+ 5 - 10
Units/ProjectCommands.pas

@@ -121,7 +121,6 @@ type
    6. 删除临时文件夹}
   TTenderExport = class
   private
-    FIngore: Boolean;
     // 临时文件夹(生成的项目文件、xml属性文件)
     FTempFolder: string;
     FProjectName: string;
@@ -139,7 +138,7 @@ type
     procedure SaveInfoToXmlDocument(AXmlNode: IXMLNode);
     procedure ExportXmlInfo;
   public
-    constructor Create(ARec: TsdDataRecord; const AFileName: string; AIngore: Boolean = False);
+    constructor Create(ARec: TsdDataRecord; const AFileName: string);
     destructor Destroy; override;
     // 参数AExportAttachment:是否导出附件
     procedure Execute(AExportAttachment: Boolean = False);
@@ -610,9 +609,8 @@ end;
 { TTenderExport }
 
 constructor TTenderExport.Create(ARec: TsdDataRecord;
-  const AFileName: string; AIngore: Boolean = False);
+  const AFileName: string);
 begin
-  FIngore := AIngore;
   FProjectName := ARec.ValueByName('Name').AsString;
   FFileName := GetMyProjectsFilePath +  ARec.ValueByName('FileName').AsString;
   if not G_IsCloud then
@@ -641,9 +639,7 @@ begin
     if AExportAttachment then
       CopyFolder(FAttachmentPath, FTempFolder + '\' + sFileName + '[附件包]');
 
-  if FIngore or (not FileExists(FResultFile) or
-      QuestMessage(Format('存在同名文件“%s”,是否替换?', [ExtractFileName(FResultFile)]))) then
-    ZipFolder(FTempFolder, FResultFile);
+  ZipFolder(FTempFolder, FResultFile);
 end;
 
 procedure TTenderExport.ExportXmlInfo;
@@ -725,8 +721,7 @@ procedure TProjectExport.Execute;
 begin
   ExportXmlInfo;
   ExportNode(FExportNode.FirstChild, FTempFolder + '\');
-  if not FileExists(FResultFile) or QuestMessage('存在同名文件,是否替换?') then
-    ZipFolder(FTempFolder, FResultFile);
+  ZipFolder(FTempFolder, FResultFile);
 end;
 
 procedure TProjectExport.ExportNode(ANode: TsdIDTreeNode;
@@ -750,7 +745,7 @@ procedure TProjectExport.ExportTender(ANode: TsdIDTreeNode;
   const AExportPath: string);
 begin
   FTenderExportor := TTenderExport.Create(ANode.Rec,
-    AExportPath + ANode.Rec.ValueByName('Name').AsString, True);
+    AExportPath + ANode.Rec.ValueByName('Name').AsString);
   try
     FTenderExportor.Execute(FExportAttachment);
   finally