1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. gmmg

Beiträge von gmmg

  • Array durchsuchen und Zählen

    • gmmg
    • 10. Februar 2011 um 20:07

    Hallo autoBert,

    hab hier gerade ein problem, beim einlesen von XML datein, vielleicht kannst du mal drüberschauen!
    das script läuft schon so halbwegs! hab aber beim 3. oder 4. durchlauf eine dopplung eines wertes!
    in den xml dateinen gibt es immer einen abschnitt <MN20>rufnummer01</MN20> und
    dazugehörige <DESTNAME>zielrufnummer</DESTNAME> einträge (mal einer, mal mehrere!

    was will ich erreichen: es sollen alle <MN20> und die dazugehörigen <DESTNAME>in einer zeile stehen! d.h. im excel spalte 1|2|3 usw.
    dabei sollen doppelte <DESTNAME> nicht mit übernommen werden.

    Spoiler anzeigen
    [autoit]


    #Include <Array.au3>
    #include <file.au3>
    #include <Excel.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Dim $aRecords, $avArray_01[1], $avArray_xx[1], $aC, $aCD
    Local $z

    [/autoit] [autoit][/autoit] [autoit]

    $FileList=_FileListToArray(@DesktopDir,"*.xml")
    If @Error=1 Then
    MsgBox (0,"","No Folders Found.")
    Exit
    EndIf
    If @Error=4 Then
    MsgBox (0,"","No Files Found.")
    Exit
    EndIf
    ;_ArrayDisplay($FileList,"$FileList")

    [/autoit] [autoit][/autoit] [autoit]

    ;erstelle excel dokument
    Local $oExcel = _ExcelBookNew() ;Create new book, make it visible

    [/autoit] [autoit][/autoit] [autoit]

    For $z = 1 to $FileList[0]
    ;MsgBox(0,"", $FileList[$z])
    $eintrag = ""
    _test()
    Next

    [/autoit] [autoit][/autoit] [autoit]

    Func _test()

    [/autoit] [autoit][/autoit] [autoit]

    If Not _FileReadToArray(@DesktopDir & "\" & $FileList[$z],$aRecords) Then
    MsgBox(4096,"Error", " Error reading log to Array error:" & @error)
    Exit
    EndIf
    For $x = 1 to $aRecords[0]
    $var = $aRecords[$x]
    $var = StringReplace($var, " ", "")
    $var = StringStripCR($var)
    $var = StringStripWS($var, 3)
    ;Msgbox(0,'Record:' & $x, $aRecords[$x])

    [/autoit] [autoit][/autoit] [autoit]

    IF StringLeft($var, 6) = "<MN20>" Then
    $var01 = $var
    $var01 = StringTrimRight($var01, 7)
    ;Msgbox(0,'Record:' & $x, $var01)
    $var01 = StringTrimLeft($var01, 6)
    ;Msgbox(0,'Record:' & $x, $var01)
    EndIf
    IF StringLeft($var, 10) = "<DESTNAME>" Then
    $var02 = $var
    $var02 = StringTrimRight($var02, 11)
    $var02 = StringTrimLeft($var02, 10)
    ;Msgbox(0,'Record:' & $x, $var01 & "|" & $var02)
    _ArrayAdd($avArray_01, $var01 & "|" & $var02)
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    ;_ArrayDisplay($avArray_01)
    Local $aC = _ArrayUnique($avArray_01)
    _ArrayDelete($aC, 0)
    _ArraySort($aC)
    ;_ArrayDisplay($aC)

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To _ArrayMaxIndex($aC, 0, 1)
    ;MsgBox(0,"", _ArrayMin($aC, 0, 1))
    $zeile_1 = $i + 1
    $eintrag = StringSplit($aC[$i], "|")
    _ArrayAdd($avArray_xx, $eintrag[1])
    Next
    Local $aCD = _ArrayUnique($avArray_xx)
    _ArrayDelete($aCD, 0)
    _ArraySort($aCD)
    _ArrayDisplay($aCD, "test")

    [/autoit] [autoit][/autoit] [autoit]

    ;erstelle excel dokument
    ;Local $oExcel = _ExcelBookNew() ;Create new book, make it visible

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To _ArrayMaxIndex($aC, 0, 1)
    ;MsgBox(0,"", _ArrayMin($aC, 0, 1))
    $zeile_1 = $i
    $eintrag = StringSplit($aC[$i], "|")
    ;MsgBox(0,"",$eintrag[1] & " " & $eintrag[2])
    IF $i = 1 and $aCD[1] = $eintrag[1] Then
    _ExcelWriteCell($oExcel, "'"&$eintrag[1], $zeile_1 + $z, 1)
    _ExcelWriteCell($oExcel, $eintrag[2], $zeile_1 + $z, 2)
    ;MsgBox(0,$i & " 1", $zeile_1 + $z)
    Else
    ;_ExcelWriteCell($oExcel, $eintrag[1], $zeile_1, 3)

    [/autoit] [autoit][/autoit] [autoit]

    _ExcelWriteCell($oExcel, $eintrag[2], $zeile_1 + $z -1 , $i +1)
    ;MsgBox(0,$i &" 2 " & $eintrag[1] , $zeile_1 + $z -1)
    EndIf
    $eintrag[1] = ""
    $eintrag[2] = ""
    ;$oExcel.Range("A"& $zeile_1 &":B"& $zeile_1) .Interior.ColorIndex = 27 ; setze Farbe
    ;$oExcel.Range("A1:B"&$zeile_1).Borders.LineStyle = 1 ; setze einen Rahmen um die Zellen
    Next

    [/autoit] [autoit][/autoit] [autoit]

    $oExcel.Columns.AutoFit ;AutoFits the Columns for better viewing
    $oExcel.Rows.AutoFit ;AutoFits the Rows for better viewing

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit]


    wo könnte der fehler liegen? hab auch mal die excel ausgabe angehangen und das markiert, was da zuviel geschrieben wird!
    ich denke es liegt an einer schleife, denn pro durchlauf sollte immer nur 1 element im array sein, wenn man sich die bilder ansieht, ist aber schon im zweiten durchlauf ein zweites vorhanden!

    danke

    gruß gmmg

    Bilder

    • schleifendurchlauf1.gif
      • 3,04 kB
      • 323 × 207
    • schleifendurchlauf2.gif
      • 3,29 kB
      • 346 × 209

    Dateien

    index2.jsp2.xml.txt 873 Byte – 341 Downloads index.jsp_1.xml.txt 253 Byte – 324 Downloads
  • FTP Upload geht nicht

    • gmmg
    • 7. Februar 2011 um 11:21

    @cinema

    was enthält denn deine variable $log?

    hier mal ein beispiel!

    [autoit][/autoit][autoit][/autoit][autoit]

    $server = 'server'
    $username = 'user'
    $pass = 'pass'

    [/autoit][autoit][/autoit][autoit]

    $path = '/'

    [/autoit][autoit][/autoit][autoit]

    $Open = _FTP_Open('server')
    $Conn = _FTP_Connect($Open, $server, $username, $pass, true)
    ;MsgBox(0,"",$Conn)
    $setdir = _Ftp_DirSetCurrent($Conn, $path)
    ;MsgBox(0,"set dir",$setdir)

    [/autoit][autoit][/autoit][autoit]

    ;$Dirlist = _FTPFilesListToArray($Conn, 1)
    ;_ArrayDisplay($Dirlist, 'Directorys List')

    [/autoit][autoit][/autoit][autoit]

    $Dirlist = _FTP_ListToArray2D($Conn, 2)
    ;MsgBox(0,"files vorhanden?",$Dirlist[0])
    ;_ArrayDisplay($Dirlist, 'File List')

    [/autoit][autoit][/autoit][autoit]

    If $Dirlist[0][0] = 0 Then
    MsgBox(0,"", "keine Files vorhanden",1)
    Exit
    Else
    For $i = 1 To $Dirlist[0][0]
    ;MsgBox(0,"files ++++",$Dirlist[$i][0])
    IF $Dirlist[$i][1] = 0 Then ;prüfung auf fehler
    ;MsgBox(0,"files ++++",$Dirlist[$i][1])
    Else
    $left = StringLeft($Dirlist[$i][0], 6)
    $right = StringRight($Dirlist[$i][0], 4)
    ;MsgBox(0,"",$left & $right)

    [/autoit][autoit][/autoit][autoit]

    IF $left = "agabda" And $right = ".dat" Then
    ;MsgBox(0,"",$Dirlist[$i][0])
    _FTP_FileGet($Conn, $Dirlist[$i][0], $Zielpfad & $Dirlist[$i][0]) ; lädt file vom ftp server
    Sleep(1000)
    _FTP_FileDelete($Conn, $Dirlist[$i][0]) ; löscht file vom ftp server
    Sleep(1000)
    _alltours_upload()
    Else
    ;MsgBox(0,"",$Dirlist[$i][0])
    _FileWriteLog(@ScriptDir & "\Temp\upload.log","Error - No dat File")
    EndIf
    EndIf
    Next
    EndIf

    [/autoit][autoit][/autoit][autoit]

    _FTP_Close($Open)

    [/autoit][autoit][/autoit][autoit][/autoit]

    gruß gmmg

  • Array durchsuchen und Zählen

    • gmmg
    • 3. Februar 2011 um 15:07

    hallo UEZ,

    das komplette script läuft aber ca. 25 sek, bis es fertig ist, inklusive schreiben der exceldatei die erstellt wird!!!

    hier der benchmark über die einzelnen AD Site einträge:
    1. version von autoBert, die 2. von dir

    Spoiler anzeigen


    1. version 2. version
    0.0007 s ------ 0.0006 s
    0.005 s ------ 0.0048 s
    0.003 s ------ 0.0028 s
    0.0014 s ------ 0.0012 s
    0.0004 s ------ 0.0002 s
    0.0021 s ------ 0.0017 s
    0.0333 s ------ 0.0238 s
    0.0014 s ------ 0.0012 s
    0.0012 s ------ 0.0008 s
    0.0003 s ------ 0.0002 s
    0.0053 s ------ 0.0052 s
    0.0016 s ------ 0.0013 s
    0.0368 s ------ 0.0265 s
    0.008 s ------ 0.0064 s
    0.9615 s ------ 0.2286 s
    0.0004 s ------ 0.0003 s

    @UAZ deine ist etwas schneller, bringt aber in meinem script noch einen fehler.

    gruß gmmg

  • Array durchsuchen und Zählen

    • gmmg
    • 3. Februar 2011 um 14:40

    ja, das ist super!!!
    hab das schon so übernommen.

    gruß gmmg :)

  • Array durchsuchen und Zählen

    • gmmg
    • 3. Februar 2011 um 14:09

    hallo UEZ,

    das sind ca 20 AD Sites mit ca 3000 usern!

    schau mir das mal an!!!

    funktioniert alles bisher bestens ;)
    danke nochmal ...

    gruß gmmg

  • Array durchsuchen und Zählen

    • gmmg
    • 3. Februar 2011 um 13:44

    funktioniert prima ... ;)
    danke autoBert , UEZ, name22

    jetzt noch eine frage, wie kann ich einen dummy wert dem array hinzufügen, wenn feld 3 leer ist!

    gruß gmmg

  • Array durchsuchen und Zählen

    • gmmg
    • 3. Februar 2011 um 12:44

    autoBert

    so, hab jetzt mal 100 testdaten aus dem array "$aObjects" erstellt!

    Spoiler anzeigen
    [autoit]


    [0]|99|3|
    [1]|ftina|[email='ftireditors2@test.com'][/email]|Accounting Service
    [2]|mlaaa|[email='big2.creditors@test.com'][/email]|Accounting Service
    [3]|mlaaag|[email='anlla.agius@test.com'][/email]|Accounting Service
    [4]|mlaaat|[email='ane.attard@test.com'][/email]|Accounting Service
    [5]|mlaab|mlat.FTi.Com|Accounting Service
    [6]|mlaaba|[email='alder.barbara@test.com'][/email]|Accounting Service
    [7]|mlaabo|[email='ane.borg@test.com'][/email]|Accounting Service
    [8]|mlaacl|[email='ansia.calleja@test.com'][/email]|Accounting Service
    [9]|mlaacu|[email='Au.Curmi@test.com'][/email]|Accounting Service
    [10]|mlaade|[email='anette.demanuele@test.com'][/email]|Accounting Service
    [11]|mlaadu|[email='aair.duncan@test.com'][/email]|Accounting Service
    [12]|mlaage|[email='aw.gerardi@test.com'][/email]|Accounting Service
    [13]|mlaagl|[email='an.galea@test.com'][/email]|Accounting Service
    [14]|mlaamg|[email='Ail.Magro@test.com'][/email]|Accounting Services
    [15]|mlaamr|[email='ail.mercieca@test.com'][/email]|Accounting Service
    [16]|mlaan|[email='al.scicluna@test.com'][/email]|Accounting Service
    [17]|mlaas|[email='al.savona@test.com'][/email]|Accounting Service
    [18]|mlaasc|[email='aise.scicluna@test.com'][/email]|Accounting Service
    [19]|mlaasp|[email='Ael.Spiteri@test.com'][/email]|Accounting Service
    [20]|mlaat|[email='keatkins@test.com'][/email]|Accounting Service
    [21]|mlaawa|[email='a.watanabe@test.com'][/email]|Accounting Service
    [22]|mlabc|[email='crors19@test.com'][/email]|Accounting Service
    [23]|mlabgr|[email='bce.grima@test.com'][/email]|Accounting Service
    [24]|mlabmi|[email='brdette.micallef@test.com'][/email]|Accounting Service
    [25]|mlaca|[email='che.psaila@test.com'][/email]|Accounting Service
    [26]|mlacao|[email='ctina.azzopardi@test.com'][/email]|Accounting Service
    [27]|mlacat|[email='ctian.attard@test.com'][/email]|Accounting Service
    [28]|mlacaz|[email='clina.azzopardi@test.com'][/email]|Accounting Service
    [29]|mlacbe|[email='Ctian.Bezzina@test.com'][/email]|Accounting Service
    [30]|mlacbr|[email='celle.borg@test.com'][/email]|Accounting Service
    [31]|mlacbu|[email='cc.buhagiar@test.com'][/email]|Accounting Service
    [32]|mlacc|[email='caciscaldi@test.com'][/email]|Accounting Service
    [33]|mlaccl|[email='C.Carabott@test.com'][/email]|Accounting Service
    [34]|mlaccm|[email='ctianne.camilleri@test.com'][/email]|Accounting Service
    [35]|mlaccs|[email='C.Cassar@test.com'][/email]|Accounting Service
    [36]|mlacdi|[email='con.dingli-bennetti@meetingpointint.com'][/email]|GD Life Limited
    [37]|mlacfe|[email='ctine.fenech@meetingpointmalta.com'][/email]|Services Malta Ltd.
    [38]|mlacga|[email='lhools1.accounts@test.com'][/email]|Accounting Service
    [39]|mlachi|[email='ctian.hili@test.com'][/email]|Accounting Service
    [40]|mlacma|[email='c.micallef@test.com'][/email]|Accounting Service
    [41]|mlacmz|[email='ctianne.mizzi@test.com'][/email]|Accounting Service
    [42]|mlacpo|[email='crine.portelli@test.com'][/email]|Accounting Service
    [43]|mlacq|[email='crors24@test.com'][/email]|Accounting Service
    [44]|mlacsa|[email='crine.saliba@test.com'][/email]|Accounting Service
    [45]|mlacsl|[email='csaliba@test.com'][/email]|Accounting Service
    [46]|mlacvl|[email='Cene.Vella@test.com'][/email]|Accounting Service
    [47]|mlacxe|[email='cene.xuereb@test.com'][/email]|Accounting Service
    [48]|mlacxu|[email='ctian.xuereb@test.com'][/email]|Accounting Service
    [49]|mlada|icest.com|Accounting Service
    [50]|mladb|[email='da.bugeja@test.com'][/email]|Accounting Service
    [51]|mladba|[email='dn.barbara@test.com'][/email]|Accounting Service
    [52]|mladc|[email='doy.camilleri@test.com'][/email]|Accounting Service
    [53]|mladca|[email='dra.catania@test.com'][/email]|Accounting Service
    [54]|mladd|[email='da.delia@test.com'][/email]|Accounting Service
    [55]|mlade|[email='bia3.creditors@test.com'][/email]|Accounting Service
    [56]|mladga|[email='de.galea@test.com'][/email]|Accounting Service
    [57]|mladgi|[email='dnne.grima@test.com'][/email]|Accounting Service
    [58]|mladmi|[email='de.mifsud@test.com'][/email]|Accounting Service
    [59]|mladmu|[email='D.Muscat@test.com'][/email]|Accounting Service
    [60]|mladp|[email='done.spiteri@test.com'][/email]|Accounting Service
    [61]|mlaea|[email='crors18@test.com'][/email]|Accounting Service
    [62]|mlaeca|[email='e.carabott@test.com'][/email]|Accounting Service
    [63]|mlaemi|[email='eora.micallef@test.com'][/email]|Accounting Service
    [64]|mlaena|[email='e.nappa@test.com'][/email]|Accounting Service
    [65]|mlaesp|[email='eel.spiteri@test.com'][/email]|Accounting Service
    [66]|mlaet|[email='trort@meetingpointmalta.com'][/email]|Services Malta Ltd.
    [67]|mlaev|[email='el.vella@test.com'][/email]|Accounting Service
    [68]|mlafbu|[email='Fzia.Buhagiar@test.com'][/email]|Accounting Service
    [69]|mlafm|[email='maka.frantz@test.com'][/email]|Accounting Service
    [70]|mlagcr|[email='Gelle.Curmi@test.com'][/email]|Accounting Service
    [71]|mlagg|[email='gleorge.grima@test.com'][/email]|Accounting Service
    [72]|mlaggo|[email='ga.gouder@test.com'][/email]|Accounting Service
    [73]|mlagm|[email='ftcreditors@test.com'][/email]|Accounting Service
    [74]|mlagve|[email='getta.vella@test.com'][/email]|Accounting Service
    [75]|mlagvl|[email='Gella.Vella@test.com'][/email]|Accounting Service
    [76]|mlagza|[email='gio.zammit@test.com'][/email]|Accounting Service
    [77]|mlahfa|[email='hh.farrugia@test.com'][/email]|Accounting Service
    [78]|mlaig|mlMt.FTi.Com|Accounting Service
    [79]|mlaim|[email='chr4.creditors@test.com'][/email]|Accounting Service
    [80]|mlajaq|[email='jtte.aquilina@test.com'][/email]|Accounting Service
    [81]|mlajaz|[email='ctors22@test.com'][/email]|Accounting Service
    [82]|mlajba|[email='jca.bajada@test.com'][/email]|Accounting Service
    [83]|mlajbo|[email='j.bonnici@test.com'][/email]|Accounting Service
    [84]|mlajca|[email='jh.carabott@test.com'][/email]|Services Malta Ltd.
    [85]|mlajcc|[email='j.cauchi@test.com'][/email]|Accounting Service
    [86]|mlajco|[email='Jne.Cortis@test.com'][/email]|Accounting Service
    [87]|mlajcr|[email='jfer.caruana@test.com'][/email]|Accounting Service
    [88]|mlajd|[email='bia5.creditors@test.com'][/email]|Accounting Service
    [89]|mlajga|[email='j.gatt@test.com'][/email]|Accounting Service
    [90]|mlajl|[email='jete.galea@test.com'][/email]|Accounting Service
    [91]|mlajm|[email='jaline.thorpe@test.com'][/email]|Accounting Service
    [92]|mlajme|[email='jeline.mercieca@test.com'][/email]|Accounting Service
    [93]|mlajq|[email='jabriffa@test.com'][/email]|Accounting Service
    [94]|mlajs|mlMt.FTi.Com|Accounting Service
    [95]|mlajto|[email='j.torpiano@test.com'][/email]|Accounting Service
    [96]|mlajve|[email='jca.vella@test.com'][/email]|Accounting Services
    [97]|mlajza|[email='ctors14@test.com'][/email]|Accounting Service
    [98]|mlaka|yimeetingpointmalta.com|Meeting Point Malta Ltd.
    [99]|mlakaz|[email='kazzopardi@test.com'][/email]|Accounting Service

    [/autoit]

    in deiner Funktion listet er jetzt schon die einzelnen Companies Spalte 3 auf

    [autoit]


    Func _GetUsers_Summary(ByRef $aObjects)
    if not IsArray($aObjects) Then SetError(1,0,0)
    Local $aCompanies = _ArrayUnique($aObjects, 3)
    ;_ArrayDisplay($aCompanies)
    _ArrayDelete($aCompanies,0)
    _ArraySort($aCompanies)
    _ArrayDisplay($aCompanies) ; hier werden jetzt schon richtig die einzelnen companies aufgelistet
    Local $aResult[UBound($aCompanies)][2]
    For $i = 0 To UBound($aCompanies) -1
    $aResult[$i][0] = $aCompanies[$i]
    Next
    For $i = 0 To UBound($aResult) - 1
    $aTemp = _ArrayFindAll($aObjects, $aResult[$i][0], 0, 0, 0, 0, 2)
    $aResult[$i][1] = UBound($aTemp)
    Next
    Return $aResult
    EndFunc ;==>_GetAD_Summary

    [/autoit][autoit][/autoit][autoit][/autoit]

    wie aber bekomme ich jetzt die anzahl der user heraus, die in der jeweiligen company sind?

    gruß gmmg

    Bilder

    • ArrayDisplay_1.gif
      • 7,2 kB
      • 338 × 238
  • Array durchsuchen und Zählen

    • gmmg
    • 3. Februar 2011 um 12:20

    hallo autoBert,

    du bist ja fix mit antworten :)
    mit echtdaten läuft das nicht!
    hab die neue funktion eingebaut und es läuft ohne fehler durch!!! ich poste mal das komplette script!
    da sind aber noch jede menge excel ausgaben drin, mit formatierung :)

    Spoiler anzeigen
    [autoit][/autoit] [autoit][/autoit] [autoit]

    #include <Excel.au3>
    #Include <File.au3>
    #include <AD.au3>
    #include <Array.au3>
    #include <GUIConstantsEx.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ;ldap attribute -> http://www.selfadsi.de/user-attributes-w2k3.htm

    [/autoit] [autoit][/autoit] [autoit]

    DIM $oMyRet, $oMyError, $oExcel, $saveas, $sOU
    Local $avArray[1] , $avArray_1[1], $aObjects
    _AD_Open()

    [/autoit] [autoit][/autoit] [autoit]

    ;auslesen der einzelnen OU's
    $aOUs = _AD_GetObjectsInOU($sOU, "(objectCategory=organizationalUnit)", 1, "name") ;"distinguishedName")
    If @error > 0 Then
    MsgBox(64, "Active Directory Functions - Example 2", "No OUs could be found")
    Else
    ;_ArrayDisplay($aOUs, "Active Directory Functions - Example 2 - All OUs starting with: '" & $sOU & "'")
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;_ArrayDelete($aOUs, 0) ;löscht 1 eintrag aus dem array
    _ArraySort($aOUs)
    ;_ArrayDisplay($aOUs, "AD all Site OUs!")

    [/autoit] [autoit][/autoit] [autoit]

    ;erstelle excel dokument
    Local $oExcel = _ExcelBookNew() ;Create new book, make it visible
    _ExcelSheetDelete($oExcel, "Sheet1") ;Delete Sheet by string name of SheetName
    _ExcelSheetDelete($oExcel, "Sheet2") ;Delete Sheet by string name of SheetName
    _ExcelSheetDelete($oExcel, "Sheet3") ;Delete Sheet by string name of SheetName
    _ExcelSheetDelete($oExcel, "Tabelle1") ;Delete Sheet by string name of SheetName
    _ExcelSheetDelete($oExcel, "Tabelle2") ;Delete Sheet by string name of SheetName
    ;-----------------------

    [/autoit] [autoit][/autoit] [autoit]

    Sleep(1000)

    [/autoit] [autoit][/autoit] [autoit]

    For $x = 1 to $aOUs[0]

    [/autoit] [autoit][/autoit] [autoit]

    $aObjects = _AD_GetObjectsInOU("OU=User,OU="&$aOUs[$x]&",DC=domäne,DC=int", "(&(objectcategory=person)(objectclass=user)(mail=*)(userAccountControl=512))", 2, "sAMAccountName,mail,company")
    ;_ArrayDisplay($aObjects)

    [/autoit] [autoit][/autoit] [autoit]

    If @error > 0 Then
    ;MsgBox(64, "", "Nichts gefunden Error: " & @error)
    Else

    [/autoit] [autoit][/autoit] [autoit]

    _GetUsers_Summary($aObjects);get company in site, zähle unser pro company

    [/autoit] [autoit][/autoit] [autoit]

    ;--------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    _ExcelSheetAddNew($oExcel, $aOUs[$x])
    _ExcelWriteCell($oExcel, "User", 1, 1) ;Write to the Cell
    _ExcelWriteCell($oExcel, "Email", 1, 2) ;Write to the Cell
    _ExcelWriteCell($oExcel, "Company", 1, 3) ;Write to the Cell
    With $oExcel.ActiveWorkbook.Sheets(1)
    .Columns("A:A").ColumnWidth = "30"
    .Columns("B:B").ColumnWidth = "50"
    .Columns("C:C").ColumnWidth = "50"
    .range("A1:C1") .Font.Bold = TRUE
    .range("A1:C1") .Font.Size = 14
    ;.range("A1:D1") .Font.Color = 0xffffff
    .range("A1:C1") .Interior.ColorIndex = 43
    ;.Name = $aOUs[$x]
    EndWith

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To $aObjects[0][0]
    ;MsgBox(0,"", $aObjects[$i][0])
    $zeile = $i + 1
    IF $aObjects[0][0] <> "" Then
    _ExcelWriteCell($oExcel, $aObjects[$i][0], $zeile, 1)
    _ExcelWriteCell($oExcel, $aObjects[$i][1], $zeile, 2)
    _ExcelWriteCell($oExcel, $aObjects[$i][2], $zeile, 3)
    With $oExcel.ActiveWorkbook.Sheets(1)
    .Range("A"& $zeile &":C"& $zeile) .Interior.ColorIndex = 27
    .Range("A1:C"&$zeile).Borders.LineStyle = 1 ; setze einen Rahmen um die Zellen
    EndWith
    EndIf
    Next
    _ArrayAdd($avArray, $aOUs[$x] & ";" & $aObjects[0][0])
    _ExcelWriteCell($oExcel, $aObjects[0][0], $zeile + 2, 2)
    _ExcelWriteCell($oExcel, "All USER " & $aOUs[$x] & ":", $zeile + 2, 1)

    [/autoit] [autoit][/autoit] [autoit]

    With $oExcel.ActiveWorkbook.Sheets(1)
    .Range("A"& $zeile +2 &":B"& $zeile+2) .Interior.ColorIndex = 27
    .Range("A1:B"&$zeile +2).Borders.LineStyle = 1 ; setze einen Rahmen um die Zellen
    .Range("A"& $zeile +2 &":B"& $zeile+2) .Font.Bold = TRUE
    EndWith

    [/autoit] [autoit][/autoit] [autoit]

    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    _AD_Close()
    _ExcelSheetDelete($oExcel, "Tabelle3") ;Delete Sheet by string name of SheetName
    _ExcelSheetAddNew($oExcel, "ZGesamt")
    _ExcelSheetOrderByName($oExcel, 0)

    [/autoit] [autoit][/autoit] [autoit]

    ;_ArrayDisplay($avArray)
    _ExcelWriteCell($oExcel, "Site", 1, 1) ;Write to the Cell
    _ExcelWriteCell($oExcel, "Anzahl User", 1, 2) ;Write to the Cell
    With $oExcel.ActiveWorkbook.Sheets("ZGesamt")
    .Columns("A:A").ColumnWidth = "30"
    .Columns("B:B").ColumnWidth = "50"
    .range("A1:B1") .Font.Bold = TRUE
    .range("A1:B1") .Font.Size = 14
    ;.range("A1:D1") .Font.Color = 0xffffff
    .range("A1:B1") .Interior.ColorIndex = 43
    ;.Name = $aOUs[$x]
    EndWith

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To _ArrayMaxIndex($avArray, 0, 1)
    ;MsgBox(0,"", $avArray[$i])
    $zeile_1 = $i + 1
    $eintrag = StringSplit($avArray[$i], ";")
    _ExcelWriteCell($oExcel, $eintrag[1], $zeile_1, 1)
    _ExcelWriteCell($oExcel, $eintrag[2], $zeile_1, 2)
    With $oExcel.ActiveWorkbook.Sheets("ZGesamt")
    .Range("A"& $zeile_1 &":B"& $zeile_1) .Interior.ColorIndex = 27
    .Range("A1:B"&$zeile_1).Borders.LineStyle = 1 ; setze einen Rahmen um die Zellen
    EndWith
    Next

    [/autoit] [autoit][/autoit] [autoit]

    _ExcelWriteCell($oExcel, "=Summe(B2:B"& $zeile_1 ,$zeile_1 + 1 , 2) ;Write formula another way Uses A1 referencing, not R1C1
    _ExcelWriteCell($oExcel, "All User",$zeile_1 + 1 , 1) ;Write formula another way Uses A1 referencing, not R1C1
    With $oExcel.ActiveWorkbook.Sheets("ZGesamt") ; formatiert letzte Zeile
    .Range("A"& $zeile_1 +1 &":B"& $zeile_1 + 1) .Interior.ColorIndex = 27
    .Range("A"& $zeile_1 +1 &":B"& $zeile_1 + 1).Borders.LineStyle = 1 ; setze einen Rahmen um die Zellen
    .Range("A"& $zeile_1 +1 &":B"& $zeile_1 + 1) .Font.Bold = TRUE
    EndWith

    [/autoit] [autoit][/autoit] [autoit]

    ;$saveas = "C:\User_in Sites"
    ;_ExcelBookSaveAs($oExcel, $saveas, "xls")
    ;_ExcelBookClose($oExcel, 1, 0)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ; Function Name: _ExcelSheetOrderByName($oExcel, $iDesc=0)
    ; Description::Order ExcelBook-Sheets by name ascending (default) or descending
    ; Parameter(s):$oExcel - Excel object opened by a preceding call to _ExcelBookOpen() or _ExcelBookNew()
    ; $iDesc - order descending on=1/off=0 (default)
    ; Requirement(s): #Include <Array.au3>
    ; Return Value(s): On Success - Returns 1
    ; On Failure - Returns 0 and sets @error=1 - Specified object does not exist
    ; Author(s): BugFix ([email='bugfix@autoit.de'][/email])
    ;===============================================================================
    Func _ExcelSheetOrderByName($oExcel, $iDesc=0)
    If Not IsObj($oExcel) Then Return SetError(1, 0, 0)
    If $iDesc <> 1 Then $iDesc = 0
    Local $aList = _ExcelSheetList($oExcel)
    _ArraySort($aList, $iDesc)
    Local $pos = 1
    For $i = 0 To UBound($aList) -1
    If $i = 0 Then
    _ExcelSheetMove($oExcel, $aList[$i], $pos, True)
    Else
    _ExcelSheetMove($oExcel, $aList[$i], $pos, False)
    $pos += 1
    EndIf
    Next
    Return 1
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _GetUsers_Summary(ByRef $aObjects)
    if not IsArray($aObjects) Then SetError(1,0,0)
    Local $aCompanies = _ArrayUnique($aObjects, 3)
    ;_ArrayDisplay($aCompanies)
    _ArrayDelete($aCompanies,0)
    _ArraySort($aCompanies)
    _ArrayDisplay($aCompanies) ; hier werden jetzt schon richtig die einzelnen companies aufgelistet
    Local $aResult[UBound($aCompanies)][2]
    For $i = 0 To UBound($aCompanies) -1
    $aResult[$i][0] = $aCompanies[$i]
    Next
    For $i = 0 To UBound($aResult) - 1
    $aTemp = _ArrayFindAll($aObjects, $aResult[$i][0], 0, 0, 0, 0, 2)
    $aResult[$i][1] = UBound($aTemp)
    Next
    Return $aResult
    EndFunc ;==>_GetAD_Summary

    [/autoit] [autoit][/autoit] [autoit][/autoit]

    _ArrayDisplay($aCompanies) ; hier werden jetzt schon richtig die einzelnen companies aufgelistet, es fehlt nur noch die anzahl der user, die in den entsprechenden companys sind!

    gruß gmmg

  • Array durchsuchen und Zählen

    • gmmg
    • 3. Februar 2011 um 09:42

    autoBert

    bekomme beim ausführen eine fehlermeldung:

    Array variable subscript badly formatted.: Local $aResult[$aCompanies[0]][2]

    [autoit]


    Func _GetUsers_Summary(ByRef $aObjects)
    if not IsArray($aObjects) Then SetError(1,0,0)
    Local $aCompanies = _ArrayUnique($aObjects, 3)
    _ArraySort($aCompanies)
    _ArrayDisplay($aCompanies) ; bis hierhin funktioniert es (siehe ArrayDisplay.gif)
    Local $aResult[$aCompanies[0]][2] ; hier kommt der fehler
    For $i = 1 To $aCompanies[0]
    $aResult[$i - 1][0] = $aCompanies[$i]
    Next
    For $i = 0 To UBound($aResult) - 1
    $aTemp = _ArrayFindAll($aObjects, $aResult[$i][0], 0, 0, 0, 0, 2)
    $aResult[$i][1] = UBound($aTemp)
    Next
    Return $aResult
    EndFunc ;==>_GetAD_Summary

    [/autoit]


    finde aber den fehler nicht!!!

    leider sortiert _ArraySort nicht richtig, wenn aus irgendeinem grund im array der 3. wert fehlt!
    könnte man in diesen fall z.b. ein error als 3 wert einfügen?

    so funktioniert es nicht!

    [autoit]


    For $i = 1 to UBound($aObjects) -1
    ;MsgBox(0,"", $aObjects[$i][2])
    If $aObjects[$i][2] = "" Then _Array2DInsert($aObjects, $aObjects[$i][2], "kein Wert")
    Next

    [/autoit][autoit][/autoit][autoit][/autoit]


    gruß gmmg

    Dateien

    ArrayDisplay.gif 7,23 kB – 0 Downloads
  • Array durchsuchen und Zählen

    • gmmg
    • 2. Februar 2011 um 22:47

    autoBert
    super ... :) werds mir morgen früh auf arbeit gleich mal ansehen!
    danke bisher für eure hilfe ;)

    gruß gmmg

  • Array durchsuchen und Zählen

    • gmmg
    • 2. Februar 2011 um 21:23

    Hallo UEZ,

    danke auch für deine lösung!
    werd das alles mal testen und melde mich dann!

    schöne grüsse

    gmmg :)

  • Array durchsuchen und Zählen

    • gmmg
    • 2. Februar 2011 um 20:55

    danke!!!

    lasse mir das ergebnis gerade in ein array schreiben und bekomme einen fehler wenn $aObjects[$i][2] leer ist!

    [autoit]


    _ArraySort($aObjects,0,0,0,1)
    ;_ArrayDisplay($aObjects)
    $sVar = ""
    $icount = 0

    [/autoit][autoit][/autoit][autoit]

    for $i = 1 to UBound($aObjects) -1
    if $sVar <> $aObjects[$i][2] Then
    if $icount > 0 Then ConsoleWrite($sVar & " " & $icount & @CRLF)
    $sVar = $aObjects[$i][2]
    $icount = 1
    Else
    $icount += 1
    EndIf
    Next
    if $icount > 0 Then _ArrayAdd($avArray_1, $sVar & " " & $icount) ;ConsoleWrite($sVar & " " & $icount & @CRLF & "----------------")
    _ArrayDisplay($avArray_1)

    [/autoit][autoit][/autoit][autoit][/autoit]

    den fehler hab ich abgefangen!!!

    [autoit][/autoit][autoit][/autoit][autoit]

    For $x = 1 to $aOUs[0]
    ;MsgBox(0,"", $aOUs[$x])
    $aObjects = _AD_GetObjectsInOU("OU=User,OU="&$aOUs[$x]&",DC=domäne,DC=int", "(&(objectcategory=person)(objectclass=user)(mail=*)(userAccountControl=512))", 2, "sAMAccountName,mail,company")
    ;_ArrayDisplay($aObjects)

    [/autoit][autoit][/autoit][autoit]

    If @error > 0 Then
    ;MsgBox(64, "", "Nichts gefunden Error: " & @error)
    Else

    [/autoit][autoit][/autoit][autoit]

    ;---- zählen user in companys pro site
    _ArraySort($aObjects,0,0,0,1)
    ;_ArrayDisplay($aObjects)
    $sVar = ""
    $icount = 0

    [/autoit][autoit][/autoit][autoit]

    For $i = 1 to UBound($aObjects) -1
    IF $aObjects[0][0] <> "" Then
    If $sVar <> $aObjects[$i][2] Then
    If $icount > 0 Then _ArrayAdd($avArray_1, $sVar & " " & $icount);if $icount > 0 Then ConsoleWrite($sVar & " " & $icount & @CRLF)
    $sVar = $aObjects[$i][2]
    $icount = 1
    Else
    $icount += 1
    EndIf
    EndIf
    Next
    If $icount > 0 Then _ArrayAdd($avArray_1, $sVar & " " & $icount) ;ConsoleWrite($sVar & " " & $icount & @CRLF & "----------------")
    _ArrayDisplay($avArray_1)
    ;--------------------------------------

    [/autoit]

    als ergebnis erhalte ich folgendes array:
    [1]|Firma1 10
    [2]|Firma2 1
    [3]|Firma1 135
    [4]|Firma3 1
    [5]|Firma1 27

    diese müssten jetzt zusammengezählt werden :)
    Firma1 = 172
    Firma2 = 1
    Firma3 = 1

    gruß gmmg

  • Array durchsuchen und Zählen

    • gmmg
    • 2. Februar 2011 um 20:17

    Hallo,

    danke für die Infos!!!
    werd das dann gleich mal testen! :)

    name22 das ist ne gute frage, muss ich gleich mal nachsehen, wie er das array erstellt!
    mit der AD Funktion:

    [autoit]


    $aObjects = _AD_GetObjectsInOU("OU=User,OU="&$aOUs[$x]&",DC=Domäne,DC=int", "(&(objectcategory=person)(objectclass=user)(mail=*)(userAccountControl=512))", 2, "sAMAccountName,mail,company")

    [/autoit]


    wird ein Array mit 3 spalten erstellt, also nicht als string

    [autoit]


    $aObjects[$i][0] = username
    $aObjects[$i][1] = email
    $aObjects[$i][2] = company

    [/autoit]

    gruß gmmg

  • Array durchsuchen und Zählen

    • gmmg
    • 2. Februar 2011 um 19:07

    Hallo Zusammen,

    vielleicht hat jemand von euch eine Lösung!
    Ich habe ein Array aus folgender Function!

    [autoit]


    $aObjects = _AD_GetObjectsInOU("OU=User,OU="&$aOUs[$x]&",DC=Domäne,DC=int", "(&(objectcategory=person)(objectclass=user)(mail=*)(userAccountControl=512))", 2, "sAMAccountName,mail,company")

    [/autoit]

    im array stehen jetzt die werte "sAMAccountName,mail,company"
    unter Company steht jetzt für jeden User ein eintrag Beispiel wie folgt:

    [autoit]

    user1 Firma1
    user2 Firma1
    user3 Firma1
    user4 Firma2
    user5 Firma2
    user6 Firma1
    user7 Firma3
    user8 Firma3
    user9 Firma2

    [/autoit]


    wie kann ich jetzt die company einträge zählen?
    als ergebnis sollte herauskommen:
    Firma1 = 4
    Firma2 = 3
    Firma3 = 2

    Gruß gmmg

  • 7-Zip Archiv packen

    • gmmg
    • 27. Januar 2011 um 11:26

    ich hab das reingenommen, das ich eine ausgabe sehe oder zeigt er auch so was er in meinen beispiel entpackt ?:)

    gruß gmmg

  • 7-Zip Archiv packen

    • gmmg
    • 25. Januar 2011 um 10:16

    ich machs immer so!

    beispiel ist für das entpacken.

    [autoit]


    FileInstall("D:\Data\scripte\zip\7z.exe", "C:\TEMP\7z.exe", 1)
    FileInstall("D:\Data\scripte\zip\7z.dll", "C:\TEMP\7z.dll", 1)

    [/autoit][autoit][/autoit][autoit]

    $Archive1 = "V:\test.zip"
    $Output1 = "C:\Programme\test\"

    [/autoit][autoit][/autoit][autoit]

    RunWait(@ComSpec & " /c " & "C:\TEMP\7z.exe x " & '"' & $Archive1 & '"' & " -aoa -y -o" & '"' & $Output1 & '"')

    [/autoit]

    gruß gmmg

  • Jpg zu ico

    • gmmg
    • 18. Januar 2011 um 10:33

    hallo,

    ich benutze immer das tool "icoFX".
    wird auch in dem thema behandelt: [ gelöst ] IconFX Beispiele ( Icon2DLLs )

    gruß gmmg :P

  • Regedit per Autoit bearbeiten für einen RollOut

    • gmmg
    • 18. Januar 2011 um 09:27

    es gibt die möglichkeit komplette regkeys zu importieren

    Beispiel

    [autoit][/autoit][autoit][/autoit][autoit]

    #include <HKCUReg.au3>

    [/autoit][autoit][/autoit][autoit]

    ;FileInstall("d:\Screwdriver_hklu.reg", @ScriptDir & "\Screwdriver_hklu.reg", 1)

    [/autoit][autoit][/autoit][autoit]

    $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\triCerat\Simplify Printing\Screwdrivers Client v4","Version")
    If @error <> 0 Then
    ;MsgBox(0,"nicht vorhanden",@error)
    Else
    ;MsgBox(0,"vorhanden",@error)
    _HKCU_Import(@ScriptDir & "\Screwdriver_hklu.reg")
    EndIf

    [/autoit]

    hab mal noch die benötigten au3 angehangen!

    Gruß gmmg :)

    Dateien

    Reg.au3 15,89 kB – 514 Downloads HKCUReg.au3 23,45 kB – 430 Downloads Privilege.au3 3,96 kB – 272 Downloads
  • [FTP] ganzer ordner Download (problem mit _FTPFilesListToArray)

    • gmmg
    • 11. Januar 2011 um 14:23

    hallo,
    ich hab mal einen download so realisiert!

    Spoiler anzeigen
    [autoit]


    #include <Misc.au3>
    #include <FTPEx.au3>
    #Include <File.au3>
    #Include <Array.au3>
    #include <Date.au3>
    #include <Process.au3>

    [/autoit] [autoit][/autoit] [autoit]

    If Not FileExists (@ScriptDir & "\Temp") Then DirCreate (@ScriptDir & "\Temp")

    [/autoit] [autoit][/autoit] [autoit]

    $Zielpfad = @ScriptDir & "\Temp\"

    [/autoit] [autoit][/autoit] [autoit]

    $server = 'server'
    $username = 'user'
    $pass = '*********'

    [/autoit] [autoit][/autoit] [autoit]

    $path = '/'

    [/autoit] [autoit][/autoit] [autoit]

    $Open = _FTP_Open('server')
    $Conn = _FTP_Connect($Open, $server, $username, $pass, true)
    ;MsgBox(0,"",$Conn)
    $setdir = _Ftp_DirSetCurrent($Conn, $path)
    ;MsgBox(0,"set dir",$setdir)

    [/autoit] [autoit][/autoit] [autoit]

    ;$Dirlist = _FTPFilesListToArray($Conn, 1)
    ;_ArrayDisplay($Dirlist, 'Directorys List')

    [/autoit] [autoit][/autoit] [autoit]

    $Dirlist = _FTP_ListToArray2D($Conn, 2)
    ;MsgBox(0,"files vorhanden?",$Dirlist[0])
    ;_ArrayDisplay($Dirlist, 'File List')

    [/autoit] [autoit][/autoit] [autoit]

    If $Dirlist[0][0] = 0 Then
    MsgBox(0,"", "keine Files vorhanden",1)
    Exit
    Else
    For $i = 1 To $Dirlist[0][0]
    ;MsgBox(0,"files ++++",$Dirlist[$i][0])
    IF $Dirlist[$i][1] = 0 Then ;prüfung auf fehler
    ;MsgBox(0,"files ++++",$Dirlist[$i][1])
    Else
    $left = StringLeft($Dirlist[$i][0], 6)
    $right = StringRight($Dirlist[$i][0], 4)
    ;MsgBox(0,"",$left & $right)

    [/autoit] [autoit][/autoit] [autoit]

    IF $left = "agabda" And $right = ".dat" Then
    ;MsgBox(0,"",$Dirlist[$i][0])
    _FTP_FileGet($Conn, $Dirlist[$i][0], $Zielpfad & $Dirlist[$i][0]) ; lädt file vom ftp server
    Sleep(1000)
    _FTP_FileDelete($Conn, $Dirlist[$i][0]) ; löscht file vom ftp server
    Sleep(1000)
    ;_upload()
    Else
    ;MsgBox(0,"",$Dirlist[$i][0])
    _FileWriteLog(@ScriptDir & "\Temp\upload.log","Error - No dat File")
    EndIf
    EndIf
    Next
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    _FTP_Close($Open)

    [/autoit]

    vielleicht hilft es dir ja weiter.

    gruß gmmg

  • Ordnerinhalte auslesen

    • gmmg
    • 4. Januar 2011 um 09:51

    servus,

    na da hab ich ja mit meinem scriptbeispiel was angestellt!
    das sollte nur als anhaltspunkt dienen :)

    aber schön das es jetzt geht!

    gruß gmmg

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™