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/UploadImages.pas

    r738 r793  
    5757      destructor Destroy;  override;
    5858  end;
    59 
    60 
    61 
    62 
    6359
    6460type
     
    10399    Bitmap : TBitmap;
    104100    Picture : TPicture;
     101    FUploadedImagesList : TStringList; //List of strings of images succesfully uploaded.
    105102    function MakeThumbNail(Info: TImageInfo): boolean;
    106103
     
    126123  published
    127124    property ScanDir : String read FScanDir write SetScanDir;
     125    property UploadedImages : TStringList read FUploadedImagesList;
    128126  end;
    129127
     
    143141        ORNet, //for RPCBrokerV
    144142        rTIU,
     143        rHTMLTools,
    145144        uTMGOptions
    146145        ;
     
    281280      RPCBrokerV.param[5].value := DOB;       RPCBrokerV.Param[5].ptype := literal;
    282281      RPCBrokerV.param[6].value := Sex;       RPCBrokerV.Param[6].ptype := literal;
    283       RPCBrokerV.Call;
     282      //RPCBrokerV.Call;
     283      CallBroker;
    284284      RPCResult := RPCBrokerV.Results[0]; //returns: success: DFN;  or  error: -1^ErrMsg
    285285      if piece(RPCResult,'^',1) <> '-1' then begin
     
    321321    RPCBrokerV.ClearParameters := true;
    322322    RPCBrokerV.remoteprocedure := 'TMG GET BLANK TIU DOCUMENT';
    323     RPCBrokerV.param[0].value := DFN;       RPCBrokerV.param[0].ptype := literal;
     323    RPCBrokerV.param[0].value := '`'+DFN;   RPCBrokerV.param[0].ptype := literal;
    324324    RPCBrokerV.param[1].value := Provider;  RPCBrokerV.Param[1].ptype := literal;
    325325    RPCBrokerV.param[2].value := Location;  RPCBrokerV.Param[2].ptype := literal;
    326326    RPCBrokerV.param[3].value := DOS;       RPCBrokerV.Param[3].ptype := literal;
    327327    RPCBrokerV.param[4].value := Title;     RPCBrokerV.Param[4].ptype := literal;
    328     RPCBrokerV.Call;
     328    //RPCBrokerV.Call;
     329    CallBroker;
    329330    RPCResult := RPCBrokerV.Results[0];
    330331    try
     
    436437    ErrorMsg                     : AnsiString;
    437438    i                            : integer;
     439    CacheFPathName, tempFName    : string;
    438440
    439441  begin
     
    464466    RPCBrokerV.Param[0].Mult['"FileExt"'] := 'EXT^' + Info.Extension;
    465467
    466     for i := 0 to Info.pLongDesc.Count - 1 do begin
    467       index := IntToStr(i);
    468       while length(index) < 3 do index := '0' + index;
    469       index :='"LongDescr' + index + '"';
    470       RPCBrokerV.Param[0].Mult[index] := '11^' + Info.pLongDesc.Strings[i];
    471     end;
    472 
    473     RPCResult := RPCBrokerV.STRcall;   { returns ImageIEN^directory/filename }
     468    if assigned(Info.pLongDesc) then begin
     469      for i := 0 to Info.pLongDesc.Count - 1 do begin
     470        index := IntToStr(i);
     471        while length(index) < 3 do index := '0' + index;
     472        index :='"LongDescr' + index + '"';
     473        RPCBrokerV.Param[0].Mult[index] := '11^' + Info.pLongDesc.Strings[i];
     474      end;
     475    end;
     476
     477    //RPCResult := RPCBrokerV.STRcall;   { returns ImageIEN^directory/filename }
     478    CallBroker;
     479    if RPCBrokerV.Results.Count>0 then RPCResult := RPCBrokerV.Results.Strings[0];
    474480
    475481    ImageIEN := Piece(RPCResult,'^',1);
    476482    result := ((ImageIEN <> '0') and (ImageIEN <> ''));  // function result.
    477483    if result=false then begin
    478 //    ErrorMsg :='Server Error -- Couldn''t store image information';  <-- original line.  //kt 8/7/2007
    479484      ErrorMsg :=DKLangConstW('UploadImages_Server_Error_xx_Couldnxxt_store_image_information'); //kt added 8/7/2007
    480485      MessageDlg(ErrorMsg,mtWarning,[mbOK],0);
     
    485490      result := frmImages.UploadFile(Info.ImageFPathName,Info.ServerPath,Info.ServerFName,1,1);
    486491      if result=false then begin
    487 //      ErrorMsg :='Error uploading image to server';  <-- original line.  //kt 8/7/2007
    488492        ErrorMsg :=DKLangConstW('UploadImages_Error_uploading_image_to_server'); //kt added 8/7/2007
    489         //Application.MessageBox(@ErrorMsg,'Error Uploading Image');
    490493        MessageDlg(ErrorMsg,mtWarning,[mbCancel],0);
    491494      end;
    492       //Later, put code that also copies the file into the cache directory,
    493       //so that we don't have to turn around and download it again.
    494495      if result then begin
    495496        RPCBrokerV.remoteprocedure := 'MAG3 TIU IMAGE';
     
    498499        RPCBrokerV.Param[1].ptype := literal;
    499500        RPCBrokerV.param[1].value := IntToStr(Info.TIUIEN);
    500         RPCBrokerV.Call;
     501        //RPCBrokerV.Call;
     502        CallBroker;
    501503        RPCResult := RPCBrokerV.Results[0];
    502504        //returns:  success:  1^message;  or  error:  0^error message
     
    504506        result := (MsgNum = '1');
    505507        if result=false then begin
    506 //        ErrorMsg :='Error associating image with note:' + #13 + Piece(RPCResult,'^',2);  <-- original line.  //kt 8/7/2007
    507508          ErrorMsg :=DKLangConstW('UploadImages_Error_associating_image_with_notex') + #13 + Piece(RPCResult,'^',2); //kt added 8/7/2007
    508509          MessageDlg(ErrorMsg,mtWarning,[mbCancel],0);
    509510        end;
    510511      end;
    511       if (result=true) and (MoveCheckBox.Checked) then begin
     512      if (result=false) then exit;
     513      //Copy the file into the cache directory, so that we don't have to turn around and download it again.
     514      CacheFPathName := rHTMLTools.CPRSDir + '\cache\' + ExtractFileName (Info.ServerFName);
     515      if not FileExists(CacheFPathName) then begin
     516        tempFName := Info.ImageFPathName;
     517        CopyFile(PChar(tempFName),PChar(CacheFPathName),FALSE);
     518      end;
     519      if (MoveCheckBox.Checked) then begin
    512520        DeleteFile(Info.ImageFPathName);
    513521      end;
    514       if result then begin
    515         if MakeThumbNail(Info) then begin;
    516           result := frmImages.UploadFile(Info.ThumbFPathName,Info.ServerPath,Info.ServerThumbFName,1,1);
    517           if result=false then begin
    518 //          ErrorMsg :='Error sending thumbnail image to server.';  <-- original line.  //kt 8/7/2007
    519             ErrorMsg :=DKLangConstW('UploadImages_Error_sending_thumbnail_image_to_serverx'); //kt added 8/7/2007
    520             MessageDlg(ErrorMsg,mtWarning,[mbOK],0);
    521           end;
     522      if MakeThumbNail(Info) then begin;
     523        result := frmImages.UploadFile(Info.ThumbFPathName,Info.ServerPath,Info.ServerThumbFName,1,1);
     524        if result=false then begin
     525          ErrorMsg :=DKLangConstW('UploadImages_Error_sending_thumbnail_image_to_serverx'); //kt added 8/7/2007
     526          MessageDlg(ErrorMsg,mtWarning,[mbOK],0);
     527        end;
     528        CacheFPathName := rHTMLTools.CPRSDir + '\cache\' + ExtractFileName (Info.ServerFName);
     529        if not FileExists(CacheFPathName) then begin
     530          CopyFile(PChar(Info.ImageFPathName),PChar(CacheFPathName),FALSE);
    522531        end;
    523532        if DelOrig=true then begin
     
    559568      Info.Extension := MidStr(Info.Extension,2,17); //remove '.'
    560569
    561       if not UploadFile(Info,MoveCheckBox.Checked) then begin   //Upload function passes back filename info in Info class
     570      if UploadFile(Info,MoveCheckBox.Checked) then begin   //Upload function passes back filename info in Info class
     571        FUploadedImagesList.Add(Info.ServerFName);
     572      end else begin
    562573        //Application.MessageBox('Error uploading image file!','Error');
    563574      end;
    564 
    565575    end;
    566576    Info.Free;
     
    616626    end;
    617627    UploadChosenFiles();
     628    //note This UploadButton has .ModalResult = mrOK, so form is closed after this.
    618629  end;
    619630
     
    642653    FormRefresh(self);
    643654    FilesToUploadList.Items.Clear;
     655    FUploadedImagesList.Clear;
    644656    LoadNotesEdit();
    645657    SetupVars;
     
    666678    Bitmap.Width := 64;
    667679    Picture := TPicture.Create;
     680
     681    FUploadedImagesList := TStringList.Create;
    668682
    669683    AutoUploadNote := TAutoUploadNote.Create;
     
    692706    Bitmap.Free;
    693707    Picture.Free;
     708    FUploadedImagesList.Free;
    694709  end;
    695710
     
    822837      Text.Add('</html>');
    823838      Text.Add(' ');
    824       rTIU.SetText(ErrMsg,Text,UploadNote.TIUIEN,1); //1=commit data, do actual save.
     839      rTIU.SetText(ErrMsg,Text,UploadNote.TIUIEN,0);  //elh changed from 1 to 0 //1=commit data, do actual save.
    825840      Text.Free;
    826841      //Here I autosign  -- later make this optional?
    827842      RPCBrokerV.ClearParameters := true;
    828843      RPCBrokerV.remoteprocedure := 'TMG AUTOSIGN TIU DOCUMENT';
    829       RPCBrokerV.param[0].value := IntToStr(UploadNote.TIUIEN); 
     844      RPCBrokerV.param[0].value := IntToStr(UploadNote.TIUIEN);
    830845      RPCBrokerV.param[0].ptype := literal;
    831       RPCBrokerV.Call;
    832       RPCResult := RPCBrokerV.Results[0];    //returns:  error: -1;  success=1
     846      //RPCBrokerV.Call;
     847      CallBroker;
     848      if RPCBrokerV.Results.Count > 0 then begin
     849        RPCResult := RPCBrokerV.Results[0];    //returns:  error: -1;  success=1
     850      end else begin
     851        RPCResult := '-1';
     852      end;
    833853      if RPCResult='-1' then begin
    834854        MessageDlg('Unable to set status for scanned document to SIGNED',mtError,[mbOK],0);
    835       end;     
     855      end;
    836856      UploadNote.TIUIEN := 0;
    837857    end; 
Note: See TracChangeset for help on using the changeset viewer.