CreateAccounts([N]):= ( Created:=NowUtc; Accounts:= { "NrAccounts":N, "Created":Created }; Records:=[]; AccountNr:=1; BatchFolder:=Waher.IoTGateway.Gateway.AppDataFolder+"Batch"; if !System.IO.Directory.Exists(BatchFolder) then System.IO.Directory.CreateDirectory(BatchFolder); while AccountNr<=N do ( AccountNrStr:=Str(AccountNr); preview("Creating account "+Str(AccountNrStr)+"..."); do ( P:=Waher.Service.IoTBroker.XmppServerModule.PersistenceLayer.CreateAccount("",Str(NewGuid()),RandomPassword(),"","",Request.RemoteEndPoint); Account:=P.Key; AlternativeNames:=P.Value ) while !exists(Account); Code:=Account.GetOnboardingUrl(Now.AddDays(3)); CodeUrl:=Waher.IoTGateway.Gateway.GetUrl("/QR/"+UrlEncode(Code)+"?w=400&h=400&q=2"); QrCode:=Get(CodeUrl); QrCodeFileName:=BatchFolder+"\\"+Left("00000000",9-len(AccountNrStr))+AccountNrStr+".png"; SaveFile(QrCode,QrCodeFileName); Record:= { "AccountNr":AccountNr, "UserName":Account.UserName, "OnboardingUrl":Code, "QrCodeUrl":CodeUrl, "QrCode":QrCodeFileName }; PushLast(Record,Records); AccountNr++; ); Accounts["Records"]:=Records; SaveFile(Accounts,BatchFolder+"\\Accounts.json"); AccountsXml:= <[[foreach Record in Records do ]]> ; SaveFile(AccountsXml,BatchFolder+"\\Accounts.xml"); );