瀏覽代碼

除查看报表时的保存项目,保存时,均进行文件校验,校验失败则进行二次保存并校验,二次校验失败时提示用户,并终止其后全部操作。

MaiXinRong 8 年之前
父節點
當前提交
50a538c42b
共有 5 個文件被更改,包括 112 次插入19 次删除
  1. 12 12
      Forms/MainFrm.dfm
  2. 5 5
      Forms/MainFrm.pas
  3. 1 1
      Frames/ProjectFme.pas
  4. 49 0
      Units/ProjectCommands.pas
  5. 45 1
      Units/ProjectData.pas

+ 12 - 12
Forms/MainFrm.dfm

@@ -21,7 +21,7 @@ object MainForm: TMainForm
   object jtsProjects: TJimTabSet
     Left = 0
     Top = 49
-    Width = 734
+    Width = 742
     Height = 21
     Align = alTop
     BackgroundColor = clGradientInactiveCaption
@@ -45,8 +45,8 @@ object MainForm: TMainForm
   end
   object dxStatusBar: TdxStatusBar
     Left = 0
-    Top = 480
-    Width = 734
+    Top = 487
+    Width = 742
     Height = 20
     Panels = <
       item
@@ -78,12 +78,12 @@ object MainForm: TMainForm
     object dxStatusBarContainer2: TdxStatusBarContainerControl
       Left = 604
       Top = 2
-      Width = 128
+      Width = 136
       Height = 16
       object ProgressBar: TProgressBar
         Left = 0
         Top = 0
-        Width = 128
+        Width = 136
         Height = 16
         Align = alClient
         Max = 200
@@ -94,8 +94,8 @@ object MainForm: TMainForm
   object jpsMain: TJimPages
     Left = 0
     Top = 70
-    Width = 734
-    Height = 410
+    Width = 742
+    Height = 417
     ActivePage = jpsMainProjectsManager
     ActivePageIndex = 0
     Align = alClient
@@ -103,8 +103,8 @@ object MainForm: TMainForm
     object jpsMainProjectsManager: TJimPage
       Left = 0
       Top = 0
-      Width = 734
-      Height = 410
+      Width = 742
+      Height = 417
       TabName = 'ProjectsManager'
       Caption = 'ProjsMgr'
       object pnlUser: TPanel
@@ -201,8 +201,8 @@ object MainForm: TMainForm
     object jpsMainProjects: TJimPage
       Left = 0
       Top = 0
-      Width = 734
-      Height = 410
+      Width = 742
+      Height = 417
       TabName = 'Projects'
       Caption = 'Projects'
       object jpsProjects: TJimPages
@@ -220,7 +220,7 @@ object MainForm: TMainForm
     Font.Charset = DEFAULT_CHARSET
     Font.Color = clWindowText
     Font.Height = -12
-    Font.Name = #24494#36719#38597#40657
+    Font.Name = 'Microsoft YaHei UI'
     Font.Style = []
     Bars = <
       item

+ 5 - 5
Forms/MainFrm.pas

@@ -473,7 +473,7 @@ end;
 
 procedure TMainForm.actnCloseProjectExecute(Sender: TObject);
 begin
-  OpenProjectManager.CurProjectData.Save;
+  OpenProjectManager.CurProjectData.SaveAndCheck;
   DeleteProjectView(jtsProjects.TabIndex - 1);
   LocateProjectView(jtsProjects.TabIndex - 1);
   ResetProcessView(jtsProjects.TabIndex);
@@ -510,7 +510,7 @@ end;
 
 procedure TMainForm.actnSaveProjectExecute(Sender: TObject);
 begin
-  OpenProjectManager.CurProjectData.Save;
+  OpenProjectManager.CurProjectData.SaveAndCheck;
 end;
 
 procedure TMainForm.actnNewAuditExecute(Sender: TObject);
@@ -573,7 +573,7 @@ begin
 
   Screen.Cursor := crHourGlass;
   try
-    CurProjectFrame.ProjectData.Save;
+    CurProjectFrame.ProjectData.SaveAndCheck;
     {$O-}
       // 失败后重复一次
       if not CurProjectFrame.ProjectData.ReplyProject then
@@ -593,7 +593,7 @@ begin
 
   Screen.Cursor := crHourGlass;
   try
-    CurProjectFrame.ProjectData.Save;
+    CurProjectFrame.ProjectData.SaveAndCheck;
     {$O-}
       // 失败后重复一次
       if not CurProjectFrame.ProjectData.SubmitProject then
@@ -748,7 +748,7 @@ var
   Rec: TsdDataRecord;
 begin
   // 导出前先保存
-  CurProjectFrame.ProjectData.Save;
+  CurProjectFrame.ProjectData.SaveAndCheck;
   // 导出云版专用
   sFileName := SupportManager.ConfigInfo.OutputPath + CurProjectFrame.ProjectData.ProjectName + '.ctf';
   if SaveFile(sFileName, '.ctf') then

+ 1 - 1
Frames/ProjectFme.pas

@@ -843,7 +843,7 @@ var sURL, sAppFile, sJsonFile_Bills, sJsonFile_Common, sAppFile_UnLock,
     Result := False;
     ProgressProCreate(100, '本地数据文件上传到云端');
     ProgressProRun('保存本地数据...', 0);
-    ProjectData.Save;
+    ProjectData.SaveAndCheck;
     ProgressProRun('保存本地数据。OK', 10, pmtEdit);
 
     ProgressProRun('导出并检验文件...', 0);

+ 49 - 0
Units/ProjectCommands.pas

@@ -289,6 +289,19 @@ type
     property AuditStatus: Integer read FAuditStatus;
   end;
 
+  // Îļþ¼ìÑé
+  TTenderZipCompleteChecker = class
+  private
+    FFileName: string;
+    FTempFolder: string;
+    FProjectData: TProjectData;
+
+    function CheckMain: Boolean;
+    function CheckAllPhase: Boolean;
+  public
+    function CheckFileValid(const AFileName: string): Boolean;
+  end;
+
 implementation
 
 uses
@@ -1173,4 +1186,40 @@ begin
   FTenderFileName := FTempFolder + '\' + AXmlNode.Attributes['FileName'];
 end;
 
+{ TTenderZipCompleteChecker }
+
+function TTenderZipCompleteChecker.CheckAllPhase: Boolean;
+begin
+  Result := Assigned(FProjectData) and FProjectData.CheckPhaseFileComplete;
+end;
+
+function TTenderZipCompleteChecker.CheckFileValid(
+  const AFileName: string): Boolean;
+begin
+  FFileName := AFileName;
+  FTempFolder := GenerateTempFolder(GetTempFilePath);
+  try
+    Result := UnZipFile(AFileName, FTempFolder) and CheckMain and CheckAllPhase;
+  finally
+    DeleteFileOrFolder(FTempFolder);
+  end;
+end;
+
+function TTenderZipCompleteChecker.CheckMain: Boolean;
+begin
+  Result := False;
+  if FileExists(FTempFolder + '\main.dat') then
+  begin
+    try
+      FProjectData := TProjectData.Create;
+      FProjectData.OpenForSubmit(FFileName);
+      Result := True;
+    except
+      if Assigned(FProjectData) then
+        FProjectData.Free;
+      Result := False;
+    end;
+  end;
+end;
+
 end.

+ 45 - 1
Units/ProjectData.pas

@@ -108,6 +108,7 @@ type
 
     procedure Open(AProjRec: TsdDataRecord);
     procedure Save;
+    procedure SaveAndCheck;
     //----------------------- Begin ---后台打开 ------------------------
     {总说明:
        为节省内存使用,对不同的后台打开分别写不同的方法
@@ -190,6 +191,7 @@ type
     procedure ImportDmfFile(const AFileName: string);
 
     function CheckPassword: Boolean;
+    function CheckPhaseFileComplete: Boolean;
 
     function CurUserIsOwner: Boolean;
     function CurUserIsAuthor: Boolean;
@@ -227,7 +229,7 @@ type
     property StageDataReadOnly: Boolean read GetStageDataReadOnly;
     property PriceMarginReadOnly: Boolean read GetPriceMarginReadOnly;
     property ValidStageIsRefer: Boolean read GetValidStageIsRefer;
-    property StartMeasure: Boolean read GetStartMeasure; 
+    property StartMeasure: Boolean read GetStartMeasure;
 
     property CanUnlockInfo: Boolean read FCanUnlockInfo write FCanUnlockInfo;
     property CanInsertNormalBills: Boolean read GetCanInsertNormalBills;
@@ -2095,4 +2097,46 @@ begin
   Result := ProjProperties.PhaseCount > 0;
 end;
 
+function TProjectData.CheckPhaseFileComplete: Boolean;
+var
+  i: Integer;
+begin
+  Result := True;
+  for i := 1 to FProjProperties.PhaseCount do
+  begin
+    if not FileExists(Format('%s\Phase%d.dat', [TempPath, i])) then
+    begin
+      Result := False;
+      Break;
+    end;
+  end;
+end;
+
+procedure TProjectData.SaveAndCheck;
+
+  function CheckFile(AFileName: string): Boolean;
+  var
+    Checker: TTenderZipCompleteChecker;
+  begin
+    Checker := TTenderZipCompleteChecker.Create;
+    try
+      Result := Checker.CheckFileValid(AFileName);
+    finally
+      Checker.Free;
+    end;
+  end;
+
+begin
+  Save;
+  if not CheckFile(FFileName) then
+  begin
+    Save;
+    if not CheckFile(FFileName) then
+    begin
+      ErrorMessage('保存数据出错。请重试,或联系纵横客服:企业QQ:800003850   客服热线:(0756)3850888');
+      Abort;
+    end;
+  end;
+end;
+
 end.