Commit 2c3f3123ba9f98dc68e3182247b55be06f7da036
1 parent
78306c29
Exists in
master
-Correção de bugs.
-Versão funcional e gravando no gerente.
Showing
4 changed files
with
100 additions
and
88 deletions
Show diff stats
MapaTesteProj/MapaCACIC.identcache
No preview for this file type
MapaTesteProj/MapaTeste.dcu
No preview for this file type
MapaTesteProj/MapaTeste.dfm
| @@ -82,6 +82,8 @@ object frmMapaCacic: TfrmMapaCacic | @@ -82,6 +82,8 @@ object frmMapaCacic: TfrmMapaCacic | ||
| 82 | 00008000000180000003800000018000000180000003C0000003C0000003E000 | 82 | 00008000000180000003800000018000000180000003C0000003C0000003E000 |
| 83 | 0007F000000FF800001FF000000FF0000007F000000FF000000FFFFFFFFF} | 83 | 0007F000000FF800001FF000000FF0000007F000000FF000000FFFFFFFFF} |
| 84 | OldCreateOrder = False | 84 | OldCreateOrder = False |
| 85 | + PopupMode = pmAuto | ||
| 86 | + ScreenSnap = True | ||
| 85 | OnActivate = FormActivate | 87 | OnActivate = FormActivate |
| 86 | OnClose = FormClose | 88 | OnClose = FormClose |
| 87 | OnCreate = FormCreate | 89 | OnCreate = FormCreate |
MapaTesteProj/MapaTeste.pas
| @@ -43,7 +43,8 @@ uses | @@ -43,7 +43,8 @@ uses | ||
| 43 | IdComponent, | 43 | IdComponent, |
| 44 | Mask, | 44 | Mask, |
| 45 | ComObj, | 45 | ComObj, |
| 46 | - ldapsend; | 46 | + ldapsend, |
| 47 | + MultiMon; | ||
| 47 | 48 | ||
| 48 | function IsUserAnAdmin() : boolean; external shell32; | 49 | function IsUserAnAdmin() : boolean; external shell32; |
| 49 | 50 | ||
| @@ -121,7 +122,13 @@ type | @@ -121,7 +122,13 @@ type | ||
| 121 | strTeInfoPatrimonio5, | 122 | strTeInfoPatrimonio5, |
| 122 | strTeInfoPatrimonio6, | 123 | strTeInfoPatrimonio6, |
| 123 | strTeInfoPatrimonio7 : String; | 124 | strTeInfoPatrimonio7 : String; |
| 125 | + formMonitor: TForm; | ||
| 126 | + ldap: TLDAPsend; | ||
| 127 | + getTimer: TTimer; | ||
| 124 | 128 | ||
| 129 | + procedure WorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Int64); | ||
| 130 | + procedure WorkEnd(ASender: TObject; AWorkMode: TWorkMode); | ||
| 131 | + procedure GetTimerTimer(Sender: TObject); | ||
| 125 | procedure FormSetFocus(VerificaFoco: Boolean); | 132 | procedure FormSetFocus(VerificaFoco: Boolean); |
| 126 | procedure MontaInterface; | 133 | procedure MontaInterface; |
| 127 | procedure RecuperaValoresAnteriores; | 134 | procedure RecuperaValoresAnteriores; |
| @@ -301,10 +308,10 @@ Begin | @@ -301,10 +308,10 @@ Begin | ||
| 301 | 308 | ||
| 302 | if (Result <> '0') then | 309 | if (Result <> '0') then |
| 303 | Begin | 310 | Begin |
| 304 | - objCacic.setValueToFile('Configs' ,'Patrimonio_dados_ldap', objCacic.getValueFromTags('dados_ldap' , Result), strGerColsInfFileName); | 311 | + objCacic.setValueToFile('Configs' ,'servidor_autenticacao', objCacic.getValueFromTags('dados_ldap' , Result), strGerColsInfFileName); |
| 305 | objCacic.setValueToFile('Configs' ,'Patrimonio_Combos' , objCacic.getValueFromTags('Configs_Patrimonio_Combos' , Result), strGerColsInfFileName); | 312 | objCacic.setValueToFile('Configs' ,'Patrimonio_Combos' , objCacic.getValueFromTags('Configs_Patrimonio_Combos' , Result), strGerColsInfFileName); |
| 306 | objCacic.setValueToFile('Configs' ,'Patrimonio_Interface' , objCacic.getValueFromTags('Configs_Patrimonio_Interface', Result), strGerColsInfFileName); | 313 | objCacic.setValueToFile('Configs' ,'Patrimonio_Interface' , objCacic.getValueFromTags('Configs_Patrimonio_Interface', Result), strGerColsInfFileName); |
| 307 | -// objCacic.setValueToFile('Collects','col_patr_last' , objCacic.getValueFromTags('Collects_Patrimonio_Last' , Result), strGerColsInfFileName); | 314 | + //objCacic.setValueToFile('Collects','col_patr_last' , objCacic.getValueFromTags('Collects_Patrimonio_Last' , Result), strGerColsInfFileName); |
| 308 | End | 315 | End |
| 309 | else | 316 | else |
| 310 | begin | 317 | begin |
| @@ -330,8 +337,8 @@ begin | @@ -330,8 +337,8 @@ begin | ||
| 330 | Begin | 337 | Begin |
| 331 | 338 | ||
| 332 | if (strTeInfoPatrimonio1='') then | 339 | if (strTeInfoPatrimonio1='') then |
| 333 | - strTeInfoPatrimonio1 := objCacic.getValueFromTags('IDPatrimonio', objCacic.getValueFromTags('Patrimonio', | ||
| 334 | - strCollectsPatrimonioLast)); | 340 | + strTeInfoPatrimonio1 := objCacic.getValueFromTags('IDPatrimonio', |
| 341 | + strCollectsPatrimonioLast); | ||
| 335 | if (strTeInfoPatrimonio2='') then | 342 | if (strTeInfoPatrimonio2='') then |
| 336 | strTeInfoPatrimonio2 := objCacic.getValueFromTags('UserLogado', | 343 | strTeInfoPatrimonio2 := objCacic.getValueFromTags('UserLogado', |
| 337 | strCollectsPatrimonioLast); | 344 | strCollectsPatrimonioLast); |
| @@ -365,17 +372,16 @@ if edTeInfoNome.text <> '' then | @@ -365,17 +372,16 @@ if edTeInfoNome.text <> '' then | ||
| 365 | btGravarInformacoes.Caption := 'Enviando informações...'; | 372 | btGravarInformacoes.Caption := 'Enviando informações...'; |
| 366 | strFieldsAndValuesToRequest := 'CollectType=' + objCacic.replaceInvalidHTTPChars(objCacic.enCrypt('col_patr')) ; | 373 | strFieldsAndValuesToRequest := 'CollectType=' + objCacic.replaceInvalidHTTPChars(objCacic.enCrypt('col_patr')) ; |
| 367 | 374 | ||
| 368 | - strColetaAtual := StringReplace('[Patrimonio]' + | ||
| 369 | - '[IDPatrimonio]' + edTePatrimonioPc.Text + '[/IDPatrimonio]' + | 375 | + strColetaAtual := StringReplace('[IDPatrimonio]' + edTePatrimonioPc.Text + '[/IDPatrimonio]' + |
| 370 | '[UserLogado]' + edTeInfoUserLogado.Text + '[/UserLogado]' + | 376 | '[UserLogado]' + edTeInfoUserLogado.Text + '[/UserLogado]' + |
| 371 | - '[UserNameLDAP]' + edTeInfoNome.Text + '[/UserNameLDAP]' + | 377 | + '[UserName]' + edTeInfoNome.Text + '[/UserName]' + |
| 372 | '[IPComputer]' + edTeInfoIpComputador.Text + '[/IPComputer]' + | 378 | '[IPComputer]' + edTeInfoIpComputador.Text + '[/IPComputer]' + |
| 373 | '[ComputerName]' + edTeInfoNomeComputador.Text+ '[/ComputerName]' + | 379 | '[ComputerName]' + edTeInfoNomeComputador.Text+ '[/ComputerName]' + |
| 374 | '[PatrimonioMonitor1]' + edTeInfoPatrimonio5.Text + '[/PatrimonioMonitor1]' + | 380 | '[PatrimonioMonitor1]' + edTeInfoPatrimonio5.Text + '[/PatrimonioMonitor1]' + |
| 375 | - '[PatrimonioMonitor2]' + edTeInfoPatrimonio6.Text + '[/PatrimonioMonitor2]' + | ||
| 376 | - '[/Patrimonio]', ',','[[COMMA]]',[rfReplaceAll]); | 381 | + '[PatrimonioMonitor2]' + edTeInfoPatrimonio6.Text + '[/PatrimonioMonitor2]' |
| 382 | + , ',','[[COMMA]]',[rfReplaceAll]); | ||
| 377 | 383 | ||
| 378 | - strFieldsAndValuesToRequest := strFieldsAndValuesToRequest + ',col_patr=' + | 384 | + strFieldsAndValuesToRequest := strFieldsAndValuesToRequest + ',Patrimonio=' + |
| 379 | objCacic.replaceInvalidHTTPChars(objCacic.enCrypt(strColetaAtual)); | 385 | objCacic.replaceInvalidHTTPChars(objCacic.enCrypt(strColetaAtual)); |
| 380 | 386 | ||
| 381 | strRetorno := Comm(objCacic.getWebManagerAddress + objCacic.getWebServicesFolderName + | 387 | strRetorno := Comm(objCacic.getWebManagerAddress + objCacic.getWebServicesFolderName + |
| @@ -409,16 +415,18 @@ end; | @@ -409,16 +415,18 @@ end; | ||
| 409 | 415 | ||
| 410 | 416 | ||
| 411 | procedure TfrmMapaCacic.MontaInterface; | 417 | procedure TfrmMapaCacic.MontaInterface; |
| 412 | -var strConfigsPatrimonioInterface, strNomeLDAP : String; | 418 | +var strConfigsPatrimonioInterface, |
| 419 | + strNomeLDAP : String; | ||
| 413 | Begin | 420 | Begin |
| 414 | btCombosUpdate.Enabled := false; | 421 | btCombosUpdate.Enabled := false; |
| 415 | 422 | ||
| 416 | -//-------------------------------NOME USUARIO----------------------------------- | ||
| 417 | - strNomeLDAP := LDAPName; | 423 | + //-------------------------------NOME USUARIO----------------------------------- |
| 424 | + strNomeLDAP := getLastValue(LDAPName, #$D#$A); | ||
| 425 | + | ||
| 418 | 426 | ||
| 419 | if (strNomeLDAP <> '') and (strNomeLDAP <> 'Results: 0') then | 427 | if (strNomeLDAP <> '') and (strNomeLDAP <> 'Results: 0') then |
| 420 | begin | 428 | begin |
| 421 | - edTeInfoNome.Text := getLastValue(strNomeLDAP, #$D#$A); | 429 | + edTeInfoNome.Text := strNomeLDAP; |
| 422 | edTeInfoNome.Visible := true; | 430 | edTeInfoNome.Visible := true; |
| 423 | lbEtiquetaNome.Visible := true; | 431 | lbEtiquetaNome.Visible := true; |
| 424 | end | 432 | end |
| @@ -477,60 +485,8 @@ Begin | @@ -477,60 +485,8 @@ Begin | ||
| 477 | lbEtiquetaPatrimonioPc.Visible := true; | 485 | lbEtiquetaPatrimonioPc.Visible := true; |
| 478 | 486 | ||
| 479 | 487 | ||
| 480 | - //----------VALOR DE strGerColsInfFileName ALTERADO PARA ARQUIVO TESTE----------------------------- | ||
| 481 | strConfigsPatrimonioInterface := objCacic.deCrypt(objCacic.getValueFromFile('Configs','Patrimonio_Interface',strGerColsInfFileName)); | 488 | strConfigsPatrimonioInterface := objCacic.deCrypt(objCacic.getValueFromFile('Configs','Patrimonio_Interface',strGerColsInfFileName)); |
| 482 | 489 | ||
| 483 | - { objCacic.writeDebugLog('MontaInterface: in_exibir_etiqueobjCacic.enCta1 -> "' + | ||
| 484 | - objCacic.getValueFromTags('in_exibir_etiqueta1', | ||
| 485 | - strConfigsPatrimonioInterface)+'"'); | ||
| 486 | - | ||
| 487 | - if (trim(objCacic.getValueFromTags('in_exibir_etiqueta1', strConfigsPatrimonioInterface)) = 'S') then | ||
| 488 | - begin | ||
| 489 | - lbEtiqueta1.Caption := objCacic.getValueFromTags('te_etiqueta1', strConfigsPatrimonioInterface); | ||
| 490 | - lbEtiqueta1.Visible := true; | ||
| 491 | - edTeInfoPatrimonio1.Hint := objCacic.getValueFromTags('te_help_etiqueta1', strConfigsPatrimonioInterface); | ||
| 492 | - edTeInfoPatrimonio1.Text := strTeInfoPatrimonio1; | ||
| 493 | - edTeInfoPatrimonio1.visible := True; | ||
| 494 | - end; | ||
| 495 | - | ||
| 496 | - objCacic.writeDebugLog('MontaInterface: in_exibir_etiqueta2 -> "' + | ||
| 497 | - objCacic.getValueFromTags('in_exibir_etiqueta2', | ||
| 498 | - strConfigsPatrimonioInterface)+'"'); | ||
| 499 | - | ||
| 500 | - if (trim(objCacic.getValueFromTags('in_exibir_etiqueta2', strConfigsPatrimonioInterface)) = 'S') then | ||
| 501 | - begin | ||
| 502 | - lbEtiqueta2.Caption := objCacic.getValueFromTags('te_etiqueta2', strConfigsPatrimonioInterface); | ||
| 503 | - lbEtiqueta2.Visible := true; | ||
| 504 | - edTeInfoPatrimonio2.Hint := objCacic.getValueFromTags('te_help_etiqueta2', strConfigsPatrimonioInterface); | ||
| 505 | - edTeInfoPatrimonio2.Text := strTeInfoPatrimonio2; | ||
| 506 | - edTeInfoPatrimonio2.visible := True; | ||
| 507 | - end; | ||
| 508 | - | ||
| 509 | - objCacic.writeDebugLog('MontaInterface: in_exibir_etiqueta3 -> "' + | ||
| 510 | - objCacic.getValueFromTags('in_exibir_etiqueta3', | ||
| 511 | - strConfigsPatrimonioInterface)+'"'); | ||
| 512 | - | ||
| 513 | - if (trim(objCacic.getValueFromTags('in_exibir_etiqueta3', strConfigsPatrimonioInterface)) = 'S') then | ||
| 514 | - begin | ||
| 515 | - lbEtiqueta3.Caption := objCacic.getValueFromTags('te_etiqueta3', strConfigsPatrimonioInterface); | ||
| 516 | - lbEtiqueta3.Visible := true; | ||
| 517 | - edTeInfoPatrimonio3.Hint := objCacic.getValueFromTags('te_help_etiqueta3', strConfigsPatrimonioInterface); | ||
| 518 | - edTeInfoPatrimonio3.Text := strTeInfoPatrimonio3; | ||
| 519 | - edTeInfoPatrimonio3.visible := True; | ||
| 520 | - end; | ||
| 521 | - | ||
| 522 | - objCacic.writeDebugLog('MontaInterface: in_exibir_etiqueta4 -> "' + | ||
| 523 | - objCacic.getValueFromTags('in_exibir_etiqueta4', | ||
| 524 | - strConfigsPatrimonioInterface)+'"'); | ||
| 525 | - | ||
| 526 | - if (trim(objCacic.getValueFromTags('in_exibir_etiqueta4', strConfigsPatrimonioInterface)) = 'S') then | ||
| 527 | - begin | ||
| 528 | - lbEtiqueta4.Caption := objCacic.getValueFromTags('te_etiqueta4', strConfigsPatrimonioInterface); | ||
| 529 | - lbEtiqueta4.Visible := true; | ||
| 530 | - edTeInfoPatrimonio4.Hint := objCacic.getValueFromTags('te_help_etiqueta4', strConfigsPatrimonioInterface); | ||
| 531 | - edTeInfoPatrimonio4.Text := strTeInfoPatrimonio4; | ||
| 532 | - edTeInfoPatrimonio4.visible := True; | ||
| 533 | - end; } | ||
| 534 | 490 | ||
| 535 | // objCacic.writeDebugLog('MontaInterface: in_exibir_etiqueta5 -> "' + | 491 | // objCacic.writeDebugLog('MontaInterface: in_exibir_etiqueta5 -> "' + |
| 536 | // objCacic.getValueFromTags('in_exibir_etiqueta5', | 492 | // objCacic.getValueFromTags('in_exibir_etiqueta5', |
| @@ -558,10 +514,10 @@ Begin | @@ -558,10 +514,10 @@ Begin | ||
| 558 | edTeInfoPatrimonio6.visible := True; | 514 | edTeInfoPatrimonio6.visible := True; |
| 559 | // end; | 515 | // end; |
| 560 | 516 | ||
| 561 | - btGravarInformacoes.Visible := true; | ||
| 562 | - btCombosUpdate.Enabled := true; | ||
| 563 | 517 | ||
| 564 | - Application.ProcessMessages; | 518 | + btGravarInformacoes.Visible := true; |
| 519 | + btCombosUpdate.Enabled := true; | ||
| 520 | + Application.ProcessMessages; | ||
| 565 | end; | 521 | end; |
| 566 | 522 | ||
| 567 | procedure TfrmMapaCacic.FormClose(Sender: TObject; var Action: TCloseAction); | 523 | procedure TfrmMapaCacic.FormClose(Sender: TObject; var Action: TCloseAction); |
| @@ -571,6 +527,7 @@ begin | @@ -571,6 +527,7 @@ begin | ||
| 571 | Else | 527 | Else |
| 572 | begin | 528 | begin |
| 573 | Action := caFree; | 529 | Action := caFree; |
| 530 | + formMonitor:=nil; | ||
| 574 | objCacic.writeDebugLog('FormClose: ' + Sender.ClassName); | 531 | objCacic.writeDebugLog('FormClose: ' + Sender.ClassName); |
| 575 | Finalizar(true); | 532 | Finalizar(true); |
| 576 | end; | 533 | end; |
| @@ -580,8 +537,8 @@ end; | @@ -580,8 +537,8 @@ end; | ||
| 580 | procedure TfrmMapaCacic.mapa; | 537 | procedure TfrmMapaCacic.mapa; |
| 581 | begin | 538 | begin |
| 582 | Try | 539 | Try |
| 583 | - MontaInterface; | ||
| 584 | RecuperaValoresAnteriores; | 540 | RecuperaValoresAnteriores; |
| 541 | + MontaInterface; | ||
| 585 | Except | 542 | Except |
| 586 | on E:Exception do | 543 | on E:Exception do |
| 587 | Begin | 544 | Begin |
| @@ -671,8 +628,8 @@ begin | @@ -671,8 +628,8 @@ begin | ||
| 671 | 628 | ||
| 672 | if (getConfigs <> '0') then | 629 | if (getConfigs <> '0') then |
| 673 | begin | 630 | begin |
| 674 | - FormSetFocus(foco); | ||
| 675 | - mapa | 631 | + mapa; |
| 632 | + FormSetFocus(foco) | ||
| 676 | end | 633 | end |
| 677 | else | 634 | else |
| 678 | Sair; | 635 | Sair; |
| @@ -697,9 +654,12 @@ begin | @@ -697,9 +654,12 @@ begin | ||
| 697 | end; | 654 | end; |
| 698 | 655 | ||
| 699 | procedure TfrmMapaCacic.FormActivate(Sender: TObject); | 656 | procedure TfrmMapaCacic.FormActivate(Sender: TObject); |
| 657 | +var strNomeLDAP: String; | ||
| 658 | + | ||
| 700 | begin | 659 | begin |
| 701 | pnVersao.Caption := 'Versão: ' + objCacic.getVersionInfo(ParamStr(0)); | 660 | pnVersao.Caption := 'Versão: ' + objCacic.getVersionInfo(ParamStr(0)); |
| 702 | strFrmAtual := 'Principal'; | 661 | strFrmAtual := 'Principal'; |
| 662 | + | ||
| 703 | end; | 663 | end; |
| 704 | 664 | ||
| 705 | procedure TfrmMapaCacic.btCombosUpdateClick(Sender: TObject); | 665 | procedure TfrmMapaCacic.btCombosUpdateClick(Sender: TObject); |
| @@ -717,6 +677,9 @@ end; | @@ -717,6 +677,9 @@ end; | ||
| 717 | procedure TfrmMapaCacic.FormSetFocus(VerificaFoco: Boolean); | 677 | procedure TfrmMapaCacic.FormSetFocus(VerificaFoco: Boolean); |
| 718 | var | 678 | var |
| 719 | r : TRect; | 679 | r : TRect; |
| 680 | + MonInfo: TMonitorInfoEx; | ||
| 681 | + DispDev : TDisplayDevice; | ||
| 682 | + i, monitorWidth, monitorHeight: Integer; | ||
| 720 | begin | 683 | begin |
| 721 | if VerificaFoco then | 684 | if VerificaFoco then |
| 722 | begin | 685 | begin |
| @@ -724,12 +687,32 @@ begin | @@ -724,12 +687,32 @@ begin | ||
| 724 | BorderIcons := BorderIcons - [biSystemMenu] - [biMinimize] - [biMaximize]; | 687 | BorderIcons := BorderIcons - [biSystemMenu] - [biMinimize] - [biMaximize]; |
| 725 | BorderStyle := bsNone; | 688 | BorderStyle := bsNone; |
| 726 | FormStyle := fsStayOnTop; | 689 | FormStyle := fsStayOnTop; |
| 690 | + Position := poOwnerFormCenter; | ||
| 727 | timerProcessos.Enabled := True; | 691 | timerProcessos.Enabled := True; |
| 728 | SystemParametersInfo(SPI_GETWORKAREA, 0, @r,0); | 692 | SystemParametersInfo(SPI_GETWORKAREA, 0, @r,0); |
| 729 | SetBounds(r.Left, r.Top, r.Right-r.Left, r.Bottom-r.Top); | 693 | SetBounds(r.Left, r.Top, r.Right-r.Left, r.Bottom-r.Top); |
| 730 | - Top := 0; | ||
| 731 | - Left := 0; | ||
| 732 | - Width := Screen.Width; | 694 | + Screen.WorkAreaRect; |
| 695 | + Top := Screen.WorkAreaTop; | ||
| 696 | + Left := Screen.WorkAreaLeft; | ||
| 697 | + {if Screen.MonitorCount>1 then | ||
| 698 | + begin | ||
| 699 | + formMonitor := TForm.Create(Application); | ||
| 700 | + for i := 0 to Screen.MonitorCount - 1 do | ||
| 701 | + begin | ||
| 702 | + if not Screen.Monitors[i].Primary then | ||
| 703 | + formMonitor.WindowState := wsNormal; | ||
| 704 | + formMonitor.BorderStyle := bsNone; | ||
| 705 | + formMonitor.MakeFullyVisible(Screen.Monitors[i]); | ||
| 706 | + formMonitor.Visible:=true; | ||
| 707 | + end; | ||
| 708 | + end | ||
| 709 | + else | ||
| 710 | + begin | ||
| 711 | + monitorWidth := screen.Width; | ||
| 712 | + monitorHeight:= screen.Height; | ||
| 713 | + end;} | ||
| 714 | + | ||
| 715 | + Width := Screen.WorkAreaWidth; | ||
| 733 | Height := Screen.Height; | 716 | Height := Screen.Height; |
| 734 | EstadoBarraTarefa(FALSE); | 717 | EstadoBarraTarefa(FALSE); |
| 735 | end; | 718 | end; |
| @@ -826,44 +809,71 @@ begin | @@ -826,44 +809,71 @@ begin | ||
| 826 | end; | 809 | end; |
| 827 | end; | 810 | end; |
| 828 | 811 | ||
| 812 | +procedure TfrmMapaCacic.WorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Int64); | ||
| 813 | +begin | ||
| 814 | + getTimer.Enabled := True; | ||
| 815 | +end; | ||
| 816 | +procedure TfrmMapaCacic.WorkEnd(ASender: TObject; AWorkMode: TWorkMode); | ||
| 817 | +begin | ||
| 818 | + getTimer.Enabled := False; | ||
| 819 | +end; | ||
| 829 | 820 | ||
| 821 | +procedure TfrmMapaCacic.GetTimerTimer(Sender: TObject); | ||
| 822 | +begin | ||
| 823 | + ldap.Logout; | ||
| 824 | +end; | ||
| 830 | 825 | ||
| 831 | function TfrmMapaCacic.LDAPName: string; | 826 | function TfrmMapaCacic.LDAPName: string; |
| 832 | var | 827 | var |
| 833 | - ldap: TLDAPsend; | ||
| 834 | - identificador: TStringList; | 828 | + retorno: TStringList; |
| 835 | i: integer; | 829 | i: integer; |
| 836 | - host, username, psswd, base, strDadosLDAP, aux : string; | 830 | + host, username, psswd, base, strDadosLDAP, aux, identificador : string; |
| 831 | + | ||
| 837 | begin | 832 | begin |
| 838 | - result := ''; | ||
| 839 | - ldap := TLDAPsend.Create; | ||
| 840 | - identificador:= TStringList.Create; | 833 | + result := ''; |
| 834 | + ldap := TLDAPsend.Create; | ||
| 835 | + retorno := TStringList.Create; | ||
| 836 | + getTimer := TTimer.create(nil); | ||
| 837 | + getTimer.OnTimer := GetTimerTimer; | ||
| 838 | + getTimer.Interval := 5000; | ||
| 841 | // PEGANDO OS DADOS DO POR MEIO DO GET/CONFIGS, ONDE SERÁ GRAVADO NO GERCOLS.INF | 839 | // PEGANDO OS DADOS DO POR MEIO DO GET/CONFIGS, ONDE SERÁ GRAVADO NO GERCOLS.INF |
| 842 | - strDadosLDAP := objCacic.deCrypt(objCacic.getValueFromFile('Configs','Patrimonio_dados_ldap',strGerColsInfFileName)); | 840 | + strDadosLDAP := objCacic.deCrypt(objCacic.getValueFromFile('Configs','servidor_autenticacao',strGerColsInfFileName)); |
| 843 | host := objCacic.getValueFromTags('ip', strDadosLDAP); | 841 | host := objCacic.getValueFromTags('ip', strDadosLDAP); |
| 844 | username := objCacic.getValueFromTags('usuario', strDadosLDAP); | 842 | username := objCacic.getValueFromTags('usuario', strDadosLDAP); |
| 845 | psswd := objCacic.getValueFromTags('senha', strDadosLDAP); | 843 | psswd := objCacic.getValueFromTags('senha', strDadosLDAP); |
| 846 | base := objCacic.getValueFromTags('base', strDadosLDAP); | 844 | base := objCacic.getValueFromTags('base', strDadosLDAP); |
| 845 | + identificador:= objCacic.getValueFromTags('identificador', strDadosLDAP); | ||
| 847 | for i := 0 to 2 do //Até 2 porque são no máxio 3 identificadores que serão passados. | 846 | for i := 0 to 2 do //Até 2 porque são no máxio 3 identificadores que serão passados. |
| 848 | begin | 847 | begin |
| 849 | - aux:=objCacic.getValueFromTags('identificador'+IntToStr(i+1), strDadosLDAP); | 848 | + aux:=objCacic.getValueFromTags('retorno'+IntToStr(i+1), strDadosLDAP); |
| 850 | if aux<>'' then | 849 | if aux<>'' then |
| 851 | - identificador.Add(aux); | 850 | + retorno.Add(aux); |
| 852 | end; | 851 | end; |
| 853 | - if (host<>'') and (base<>'') then | 852 | + if (host<>'') or (base<>'') or (retorno.count=0) then |
| 854 | begin | 853 | begin |
| 854 | + try | ||
| 855 | + getTimer.Enabled := true; | ||
| 855 | try | 856 | try |
| 856 | ldap.TargetHost := host; | 857 | ldap.TargetHost := host; |
| 857 | ldap.UserName := username; | 858 | ldap.UserName := username; |
| 858 | ldap.Password := psswd; | 859 | ldap.Password := psswd; |
| 859 | ldap.Login; //Loga no LDAP. | 860 | ldap.Login; //Loga no LDAP. |
| 860 | ldap.BindSasl; //Autentica no LDAP com Usuário e senha repassado. (BindSasl é mais seguro que Bind) | 861 | ldap.BindSasl; //Autentica no LDAP com Usuário e senha repassado. (BindSasl é mais seguro que Bind) |
| 861 | - ldap.Search(base, False, 'uid=' + getUserLogon, identificador); //Faz a pesquisa, com o CPF repassado. | 862 | + ldap.Search(base, False, identificador+ '=' + getUserLogon, retorno); //Faz a pesquisa, com o CPF repassado. |
| 862 | result := LDAPResultdump(ldap.SearchResult); | 863 | result := LDAPResultdump(ldap.SearchResult); |
| 863 | ldap.Logout; | 864 | ldap.Logout; |
| 864 | finally | 865 | finally |
| 865 | ldap.Free; | 866 | ldap.Free; |
| 866 | - identificador.Free; | 867 | + retorno.Free; |
| 868 | + getTimer.Free; | ||
| 869 | + end; | ||
| 870 | + Except | ||
| 871 | + on E:Exception do | ||
| 872 | + Begin | ||
| 873 | + MessageDlg(#13#13+'Problemas para pegar nome do usuário.'+#13#13+ | ||
| 874 | + 'Por favor, digite seu nome no campo solicitado',mtError, [mbOK], 0); | ||
| 875 | + objCacic.writeExceptionLog(E.Message,e.ClassName); | ||
| 876 | + End; | ||
| 867 | end; | 877 | end; |
| 868 | end; | 878 | end; |
| 869 | end; | 879 | end; |