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 | 82 | 00008000000180000003800000018000000180000003C0000003C0000003E000 |
83 | 83 | 0007F000000FF800001FF000000FF0000007F000000FF000000FFFFFFFFF} |
84 | 84 | OldCreateOrder = False |
85 | + PopupMode = pmAuto | |
86 | + ScreenSnap = True | |
85 | 87 | OnActivate = FormActivate |
86 | 88 | OnClose = FormClose |
87 | 89 | OnCreate = FormCreate | ... | ... |
MapaTesteProj/MapaTeste.pas
... | ... | @@ -43,7 +43,8 @@ uses |
43 | 43 | IdComponent, |
44 | 44 | Mask, |
45 | 45 | ComObj, |
46 | - ldapsend; | |
46 | + ldapsend, | |
47 | + MultiMon; | |
47 | 48 | |
48 | 49 | function IsUserAnAdmin() : boolean; external shell32; |
49 | 50 | |
... | ... | @@ -121,7 +122,13 @@ type |
121 | 122 | strTeInfoPatrimonio5, |
122 | 123 | strTeInfoPatrimonio6, |
123 | 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 | 132 | procedure FormSetFocus(VerificaFoco: Boolean); |
126 | 133 | procedure MontaInterface; |
127 | 134 | procedure RecuperaValoresAnteriores; |
... | ... | @@ -301,10 +308,10 @@ Begin |
301 | 308 | |
302 | 309 | if (Result <> '0') then |
303 | 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 | 312 | objCacic.setValueToFile('Configs' ,'Patrimonio_Combos' , objCacic.getValueFromTags('Configs_Patrimonio_Combos' , Result), strGerColsInfFileName); |
306 | 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 | 315 | End |
309 | 316 | else |
310 | 317 | begin |
... | ... | @@ -330,8 +337,8 @@ begin |
330 | 337 | Begin |
331 | 338 | |
332 | 339 | if (strTeInfoPatrimonio1='') then |
333 | - strTeInfoPatrimonio1 := objCacic.getValueFromTags('IDPatrimonio', objCacic.getValueFromTags('Patrimonio', | |
334 | - strCollectsPatrimonioLast)); | |
340 | + strTeInfoPatrimonio1 := objCacic.getValueFromTags('IDPatrimonio', | |
341 | + strCollectsPatrimonioLast); | |
335 | 342 | if (strTeInfoPatrimonio2='') then |
336 | 343 | strTeInfoPatrimonio2 := objCacic.getValueFromTags('UserLogado', |
337 | 344 | strCollectsPatrimonioLast); |
... | ... | @@ -365,17 +372,16 @@ if edTeInfoNome.text <> '' then |
365 | 372 | btGravarInformacoes.Caption := 'Enviando informações...'; |
366 | 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 | 376 | '[UserLogado]' + edTeInfoUserLogado.Text + '[/UserLogado]' + |
371 | - '[UserNameLDAP]' + edTeInfoNome.Text + '[/UserNameLDAP]' + | |
377 | + '[UserName]' + edTeInfoNome.Text + '[/UserName]' + | |
372 | 378 | '[IPComputer]' + edTeInfoIpComputador.Text + '[/IPComputer]' + |
373 | 379 | '[ComputerName]' + edTeInfoNomeComputador.Text+ '[/ComputerName]' + |
374 | 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 | 385 | objCacic.replaceInvalidHTTPChars(objCacic.enCrypt(strColetaAtual)); |
380 | 386 | |
381 | 387 | strRetorno := Comm(objCacic.getWebManagerAddress + objCacic.getWebServicesFolderName + |
... | ... | @@ -409,16 +415,18 @@ end; |
409 | 415 | |
410 | 416 | |
411 | 417 | procedure TfrmMapaCacic.MontaInterface; |
412 | -var strConfigsPatrimonioInterface, strNomeLDAP : String; | |
418 | +var strConfigsPatrimonioInterface, | |
419 | + strNomeLDAP : String; | |
413 | 420 | Begin |
414 | 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 | 427 | if (strNomeLDAP <> '') and (strNomeLDAP <> 'Results: 0') then |
420 | 428 | begin |
421 | - edTeInfoNome.Text := getLastValue(strNomeLDAP, #$D#$A); | |
429 | + edTeInfoNome.Text := strNomeLDAP; | |
422 | 430 | edTeInfoNome.Visible := true; |
423 | 431 | lbEtiquetaNome.Visible := true; |
424 | 432 | end |
... | ... | @@ -477,60 +485,8 @@ Begin |
477 | 485 | lbEtiquetaPatrimonioPc.Visible := true; |
478 | 486 | |
479 | 487 | |
480 | - //----------VALOR DE strGerColsInfFileName ALTERADO PARA ARQUIVO TESTE----------------------------- | |
481 | 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 | 491 | // objCacic.writeDebugLog('MontaInterface: in_exibir_etiqueta5 -> "' + |
536 | 492 | // objCacic.getValueFromTags('in_exibir_etiqueta5', |
... | ... | @@ -558,10 +514,10 @@ Begin |
558 | 514 | edTeInfoPatrimonio6.visible := True; |
559 | 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 | 521 | end; |
566 | 522 | |
567 | 523 | procedure TfrmMapaCacic.FormClose(Sender: TObject; var Action: TCloseAction); |
... | ... | @@ -571,6 +527,7 @@ begin |
571 | 527 | Else |
572 | 528 | begin |
573 | 529 | Action := caFree; |
530 | + formMonitor:=nil; | |
574 | 531 | objCacic.writeDebugLog('FormClose: ' + Sender.ClassName); |
575 | 532 | Finalizar(true); |
576 | 533 | end; |
... | ... | @@ -580,8 +537,8 @@ end; |
580 | 537 | procedure TfrmMapaCacic.mapa; |
581 | 538 | begin |
582 | 539 | Try |
583 | - MontaInterface; | |
584 | 540 | RecuperaValoresAnteriores; |
541 | + MontaInterface; | |
585 | 542 | Except |
586 | 543 | on E:Exception do |
587 | 544 | Begin |
... | ... | @@ -671,8 +628,8 @@ begin |
671 | 628 | |
672 | 629 | if (getConfigs <> '0') then |
673 | 630 | begin |
674 | - FormSetFocus(foco); | |
675 | - mapa | |
631 | + mapa; | |
632 | + FormSetFocus(foco) | |
676 | 633 | end |
677 | 634 | else |
678 | 635 | Sair; |
... | ... | @@ -697,9 +654,12 @@ begin |
697 | 654 | end; |
698 | 655 | |
699 | 656 | procedure TfrmMapaCacic.FormActivate(Sender: TObject); |
657 | +var strNomeLDAP: String; | |
658 | + | |
700 | 659 | begin |
701 | 660 | pnVersao.Caption := 'Versão: ' + objCacic.getVersionInfo(ParamStr(0)); |
702 | 661 | strFrmAtual := 'Principal'; |
662 | + | |
703 | 663 | end; |
704 | 664 | |
705 | 665 | procedure TfrmMapaCacic.btCombosUpdateClick(Sender: TObject); |
... | ... | @@ -717,6 +677,9 @@ end; |
717 | 677 | procedure TfrmMapaCacic.FormSetFocus(VerificaFoco: Boolean); |
718 | 678 | var |
719 | 679 | r : TRect; |
680 | + MonInfo: TMonitorInfoEx; | |
681 | + DispDev : TDisplayDevice; | |
682 | + i, monitorWidth, monitorHeight: Integer; | |
720 | 683 | begin |
721 | 684 | if VerificaFoco then |
722 | 685 | begin |
... | ... | @@ -724,12 +687,32 @@ begin |
724 | 687 | BorderIcons := BorderIcons - [biSystemMenu] - [biMinimize] - [biMaximize]; |
725 | 688 | BorderStyle := bsNone; |
726 | 689 | FormStyle := fsStayOnTop; |
690 | + Position := poOwnerFormCenter; | |
727 | 691 | timerProcessos.Enabled := True; |
728 | 692 | SystemParametersInfo(SPI_GETWORKAREA, 0, @r,0); |
729 | 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 | 716 | Height := Screen.Height; |
734 | 717 | EstadoBarraTarefa(FALSE); |
735 | 718 | end; |
... | ... | @@ -826,44 +809,71 @@ begin |
826 | 809 | end; |
827 | 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 | 826 | function TfrmMapaCacic.LDAPName: string; |
832 | 827 | var |
833 | - ldap: TLDAPsend; | |
834 | - identificador: TStringList; | |
828 | + retorno: TStringList; | |
835 | 829 | i: integer; |
836 | - host, username, psswd, base, strDadosLDAP, aux : string; | |
830 | + host, username, psswd, base, strDadosLDAP, aux, identificador : string; | |
831 | + | |
837 | 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 | 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 | 841 | host := objCacic.getValueFromTags('ip', strDadosLDAP); |
844 | 842 | username := objCacic.getValueFromTags('usuario', strDadosLDAP); |
845 | 843 | psswd := objCacic.getValueFromTags('senha', strDadosLDAP); |
846 | 844 | base := objCacic.getValueFromTags('base', strDadosLDAP); |
845 | + identificador:= objCacic.getValueFromTags('identificador', strDadosLDAP); | |
847 | 846 | for i := 0 to 2 do //Até 2 porque são no máxio 3 identificadores que serão passados. |
848 | 847 | begin |
849 | - aux:=objCacic.getValueFromTags('identificador'+IntToStr(i+1), strDadosLDAP); | |
848 | + aux:=objCacic.getValueFromTags('retorno'+IntToStr(i+1), strDadosLDAP); | |
850 | 849 | if aux<>'' then |
851 | - identificador.Add(aux); | |
850 | + retorno.Add(aux); | |
852 | 851 | end; |
853 | - if (host<>'') and (base<>'') then | |
852 | + if (host<>'') or (base<>'') or (retorno.count=0) then | |
854 | 853 | begin |
854 | + try | |
855 | + getTimer.Enabled := true; | |
855 | 856 | try |
856 | 857 | ldap.TargetHost := host; |
857 | 858 | ldap.UserName := username; |
858 | 859 | ldap.Password := psswd; |
859 | 860 | ldap.Login; //Loga no LDAP. |
860 | 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 | 863 | result := LDAPResultdump(ldap.SearchResult); |
863 | 864 | ldap.Logout; |
864 | 865 | finally |
865 | 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 | 877 | end; |
868 | 878 | end; |
869 | 879 | end; | ... | ... |