Ignore:
Timestamp:
Jun 10, 2010, 3:13:12 PM (14 years ago)
Author:
Kevin Toppenberg
Message:

update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cprs/branches/tmg-cprs/CPRS-Chart/fImages.pas

    r738 r793  
    126126    function CreateBarcode(MsgStr: AnsiString; ImageType: AnsiString): AnsiString;
    127127    function DecodeBarcode(LocalFNamePath,ImageType: AnsiString): AnsiString;
     128    procedure EnsureImagesDownloaded(ImagesList : TStringList);
    128129  published
    129130  end;
     
    152153
    153154procedure TfrmImages.timLoadImagesTimer(Sender: TObject);
     155//This function's goal is to download images in the background,
     156// with one image to be downloaded each time the timer fires
    154157begin
    155158  inherited;
     
    185188
    186189
     190procedure TfrmImages.EnsureImagesDownloaded(ImagesList : TStringList);
     191//This function's goal is to download images in the FOREground,
     192// But only images matching those passed in ImagesList will be downloaded;
     193// The intent is to only download images that have links to them in HTML source
     194//Thus, if note has a large amount of images attached to it, but not referenced
     195//  in HTML code, then they will not be downloaded here. (But will be downloaded
     196//  later via timLoadImagesTimer
     197var i : integer;
     198    Rec : TImageInfo;
     199
     200begin
     201  if ImagesList.Count = 0 then exit;
     202  GetImageList();
     203  if ImageInfoList.Count = 0 then exit;
     204  if ImageInfoList.Count > 1 then begin
     205    ImageTransferForm.ProgressMsg.Caption := 'Downloading Images';
     206    ImageTransferForm.ProgressBar.Min := 0;
     207    ImageTransferForm.ProgressBar.Position := 0;
     208    ImageTransferForm.ProgressBar.Max := ImageInfoList.Count-1;
     209    ImageTransferForm.Show;
     210  end;
     211  for i := 0 to ImageInfoList.Count-1 do begin
     212    ImageTransferForm.ProgressBar.Position := i;
     213    Rec := TImageInfo(ImageInfoList[i]);
     214    if ImagesList.IndexOf(Rec.ServerFName)>-1 then begin
     215      DownloadToCache(i);
     216    end;
     217  end;
     218  ImageTransferForm.Hide;
     219end;
     220
     221
    187222{ TPage common methods --------------------------------------------------------------------- }
    188223procedure TfrmImages.mnuChartTabClick(Sender: TObject);
     
    211246  CurImageToLoad := 0;
    212247  CacheDir := ExtractFilePath(ParamStr(0))+ 'Cache';
    213   NullImageName := ExtractFilePath(ParamStr(0)) + 'images\blank.htm';
     248  //NullImageName := ExtractFilePath(ParamStr(0)) + 'images\blank.htm';
     249  NullImageName := 'about:blank';
    214250  if not DirectoryExists(CacheDir) then ForceDirectories(CacheDir);
    215251
     
    563599  RPCBrokerV.Param[2].Value := '1'; //see comments in UploadFile re '1' hardcoding
    564600
    565   RPCBrokerV.Call;  //Move file into dropbox.
    566   Result := (Piece(RPCBrokerV.Results[0],'^',1)='1');  //1=success, 0=failure
     601  //RPCBrokerV.Call;  //Move file into dropbox.
     602  CallBroker;
     603  if RPCBrokerV.Results.Count>0 then begin
     604    Result := (Piece(RPCBrokerV.Results[0],'^',1)='1');  //1=success, 0=failure
     605  end else Result := false;
    567606end;
    568607
     
    692731  RPCBrokerV.Param[2].Value := '1'; //see comments in UploadFile re '1' hardcoding
    693732
    694   RPCBrokerV.Call;  //Move file into dropbox.
     733  //RPCBrokerV.Call;  //Move file into dropbox.
     734  CallBroker;
    695735  if RPCBrokerV.Results.Count > 0 then begin
    696736    Result := (Piece(RPCBrokerV.Results[0],'^',1)='1');  //1=success, 0=failure
     
    702742
    703743  if Result=true then begin
     744    if DirectoryExists(DropboxDir) = False then begin     //elh   added to ensure a dropbox directory is valid
     745      MessageDlg('Invalid Dropbox Directory. Please check your settings and try again.',mtError,[mbOK],0);
     746      ImageTransferForm.hide;
     747      exit;
     748    end;
    704749    CurrentFileSize := strtoint(Piece(RPCBrokerV.Results[0],'^',3));  //Piece 3 = file size
    705750    DropboxFile := ExcludeTrailingBackslash(DropboxDir) + '\' + FName;
     
    10801125  RPCBrokerV.Param[1].PType := list;
    10811126  RPCBrokerV.Param[1].Mult['"IMAGE TYPE"'] := ImageType;
    1082   RPCBrokerV.Call;
     1127  //RPCBrokerV.Call;
     1128  CallBroker;
    10831129
    10841130  Application.ProcessMessages;
Note: See TracChangeset for help on using the changeset viewer.