public ActionResult Export(List <Guid> ids, bool exportBackground, string tempFileName) { if (ids != null) { RemoveOldPackages(); var inspektionsrouten = inspektionsRouteGISService.GetCurrentEntities().Where(ir => ids.Contains(ir.Id)); ereignisLogService.LogEreignis(EreignisTyp.InspektionsRoutenExport, new Dictionary <string, object>() { { "Inspektionsrouten", string.Join(", ", inspektionsrouten.Select(ir => ir.Bezeichnung)) } }); var cogModelList = new List <CheckOutsGISModel>(); foreach (var id in ids) { var cogModel = new CheckOutsGISModel(); cogModel.InspektionsRouteGIS = id; cogModel.Mandant = sessionService.SelectedMandantId; cogModel.CheckOutDatum = DateTime.Now; cogModelList.Add(cogModel); } var memoryStream = packageService.Export(checkOutService.CheckOutData(ids, exportBackground), cogModelList).Stream as MemoryStream; var filePath = Server.MapPath(String.Format(exportFilePattern, tempFileName)); using (var fs = new FileStream(filePath, FileMode.Create)) { memoryStream.WriteTo(fs); fs.Flush(); } inspektionsRouteGISService.LockInspektionsRouten(ids); foreach (var id in ids) { var inspektionsroute = inspektionsRouteGISService.GetInspektionsRouteById(id); inspektionsRouteStatusverlaufService.HistorizeRouteExportiert(inspektionsroute); } } return(new EmsgEmptyResult()); }