// --------------------------------------- // Script created by Ýíãåëü Âèòàëèé (UIN 145) // 15.11.2019 14:51:03 // --------------------------------------- const csv = '\\DFS-01.pa.local\exchange_subsystems$\ÐàáîòàþùèåÑîòðóäíèêè.csv'; var txt : String; function LoadFile():Boolean; begin txt := LoadTextFromFile( csv, 1 ); if Length( txt ) > 0 then Result := True else Result := False; end; function GetUinByFIO(str: String):Integer; var allUsers : String; uin : Integer; begin Result := 0; allUsers := mGetUsersListByParams( '' ); while Length( allUsers ) > 0 do begin uin := StrToInt( Fetch( allUsers, ',' ) ); if mIsUINExists( uin ) = True then begin if str = mGetUserAttribute( uin, 'DisplayName' ) then begin Result := uin; Break; end; end; end; end; procedure SetNewUserInfo(currentUin: Integer; department, fio, dr, title, pPhone, wMobile, iPhone, email : String); var res : Integer; begin //EMAIL,WORK_POSITION,WORK_DIVDEPT,WORK_OFFICE,WORK_PHONE,HOME_BIRTHDAY_WITHOUT_YEAR,COMPUTER_NET_NAME,IP_ADDRESS if Length( department ) > 0 then begin res := mSetUserAttribute( currentUin, 'Custom_1', department ); end; if Length( dr ) > 0 then begin res := mSetUserAttribute( currentUin, 'Home_Birthday', dr ); end; if Length( title ) > 0 then begin res := mSetUserAttribute( currentUin, 'WORK_POSITION', title ); end; if Length( pPhone ) > 0 then begin res := mSetUserAttribute( currentUin, 'Home_Phone', pPhone ); end; if Length( wMobile ) > 0 then begin res := mSetUserAttribute( currentUin, 'Home_Cellular', wMobile ); end; if Length( iPhone ) > 0 then begin res := mSetUserAttribute( currentUin, 'Work_Phone', iPhone ); end; if Length( email ) > 0 then begin res := mSetUserAttribute( currentUin, 'Email', email ); end; end; procedure ParseLine(str: String); var //fields: 1 - department, 2 - fio, 3 - DR, 4 - title, 5 - private phone, 6 - work mobile, 7 - work internal phone, 8 - email field : Integer; fieldContent : String; currentUin : Integer; department, fio, dr, title, pPhone, wMobile, iPhone, email : String; begin field := 0; while Length( str ) > 0 do begin Inc( field ); fieldContent := Fetch( str, ';' ); case field of 1: department := fieldContent; 2: fio := fieldContent; 3: dr := fieldContent; 4: title := fieldContent; 5: pPhone := fieldContent; 6: wMobile := fieldContent; 7: iPhone := fieldContent; 8: email := fieldContent; end; end; currentUin := GetUinByFIO( fio ); if currentUin > 0 then begin SetNewUserInfo(currentUin, department, fio, dr, title, pPhone, wMobile, iPhone, email); end; end; procedure ParseFile(); var txtline : String; begin // ïîñòðî÷íî ÷èòàåì ôàéëèê è êàæäóþ ñòðîêó ïåðåäàåì â îáðàáîò÷èê while Length( txt ) > 0 do begin txtline := Fetch( txt, CRLF ); if Length( txtline ) > 0 then ParseLine( txtline ); end; end; begin SetScriptTimeOut(15000); // ïî-óìîë÷àíèþ ÷óòü áîëåå 5 ñåêóíä, ÷åãî íå õâàòàåò. Óâåëè÷èâàåì äî 15 // åñëè ôàéë çàãðóæåí óäà÷íî - ïàðñèì, èíà÷å âûâîäèì â êîíñîëü îøèáêó (â ïðîäàêøåíå ìîæíî ýòî óáðàòü, âñå ðàâíî ÷èòàòü íå áóäåòå) if LoadFile = True then ParseFile() else mLogScript('ôàéë íå áûë ïðî÷èòàí', 'îøèáêà'); end.