Beispiel #1
0
        public string Document([System.Web.Http.FromBody] UploadData uploadData)
        {
            string            folder          = Request.Url.GetLeftPart(UriPartial.Authority) + "/Temp/";
            DocumentCreator   documentCreator = new DocumentCreator();
            InformativeExport data            = JsonConvert.DeserializeObject <InformativeExport>(uploadData.data);

            return(documentCreator.Create(folder, data));
        }
Beispiel #2
0
        public string KML([System.Web.Http.FromBody] UploadData uploadData)
        {
            KMLCreator kmlCreator = new KMLCreator();

            byte[]   bytes    = kmlCreator.Create(uploadData.data);
            string[] fileInfo = byteArrayToFileInfo(bytes, "kml");
            return(Request.Url.GetLeftPart(UriPartial.Authority) + "/Temp/" + fileInfo[1]);
        }
Beispiel #3
0
        public string TIFF([System.Web.Http.FromBody] UploadData uploadData)
        {
            MapExportItem exportItem = JsonConvert.DeserializeObject <MapExportItem>(uploadData.data);

            TIFFCreator tiffCreator = new TIFFCreator();
            Image       img         = tiffCreator.Create(exportItem);

            MemoryStream outStream = new MemoryStream();

            ZipOutputStream zipStream = new ZipOutputStream(outStream);

            zipStream.SetLevel(3);

            ZipEntry imageEntry = new ZipEntry(ZipEntry.CleanName("kartexport.tiff"));

            imageEntry.DateTime = DateTime.Now;

            zipStream.PutNextEntry(imageEntry);

            MemoryStream imageStream = new MemoryStream(imgToByteArray(img));

            byte[] buffer = new byte[4096];

            StreamUtils.Copy(imageStream, zipStream, buffer);

            imageStream.Close();
            zipStream.CloseEntry();

            ZipEntry worldFileEntry = new ZipEntry(ZipEntry.CleanName("kartexport.tfw"));

            worldFileEntry.DateTime = DateTime.Now;

            zipStream.PutNextEntry(worldFileEntry);
            MemoryStream worldFileStream = new MemoryStream(MapImageCreator.CreateWorldFile(exportItem));

            byte[] buffer2 = new byte[4096];
            StreamUtils.Copy(worldFileStream, zipStream, buffer2);

            worldFileStream.Close();
            zipStream.CloseEntry();

            zipStream.IsStreamOwner = false;    // False stops the Close also Closing the underlying stream.
            zipStream.Close();                  // Must finish the ZipOutputStream before using outputMemStream.

            outStream.Position = 0;
            outStream.ToArray();

            string[] fileInfo = byteArrayToFileInfo(outStream.ToArray(), "zip");
            if (exportItem.proxyUrl != "")
            {
                return(exportItem.proxyUrl + "/Temp/" + fileInfo[1]);
            }
            else
            {
                return(Request.Url.GetLeftPart(UriPartial.Authority) + "/Temp/" + fileInfo[1]);
            }
        }
Beispiel #4
0
        public string Excel([System.Web.Http.FromBody] UploadData uploadData)
        {
            List <ExcelTemplate> data = JsonConvert.DeserializeObject <List <ExcelTemplate> >(uploadData.data);
            DataSet      dataSet      = Util.ToDataSet(data);
            ExcelCreator excelCreator = new ExcelCreator();

            byte[]   bytes    = excelCreator.Create(dataSet);
            string[] fileInfo = byteArrayToFileInfo(bytes, "xls");
            return(Request.Url.GetLeftPart(UriPartial.Authority) + "/Temp/" + fileInfo[1]);
        }
Beispiel #5
0
        public string PDF([System.Web.Http.FromBody] UploadData uploadData)
        {
            // try to decode input string to see if it is base64 encoded
            //try
            //{
            //    byte[] decoded = Convert.FromBase64String(json);
            //    json = System.Text.Encoding.UTF8.GetString(decoded);
            //    _log.DebugFormat("json after decode: {0}", json);
            //}
            //catch (Exception e)
            //{
            //    _log.DebugFormat("Could not decode base64. Will treat as non-base64 encoded: {0}", e.Message);
            //}
            string        fontName   = string.IsNullOrEmpty(ConfigurationManager.AppSettings["exportFontName"]) ? "Verdana" : ConfigurationManager.AppSettings["exportFontName"];
            MapExportItem exportItem = new MapExportItem();

            if (uploadData.json != null)
            {
                exportItem = JsonConvert.DeserializeObject <MapExportItem>(uploadData.json);
            }
            if (uploadData.data != null)
            {
                exportItem = JsonConvert.DeserializeObject <MapExportItem>(uploadData.data);
            }

            AsyncManager.OutstandingOperations.Increment();
            PDFCreator pdfCreator = new PDFCreator();

            byte[]   blob     = pdfCreator.Create(exportItem, fontName);
            string[] fileInfo = byteArrayToFileInfo(blob, "pdf");
            if (!String.IsNullOrEmpty(exportItem.proxyUrl))
            {
                return(exportItem.proxyUrl + "/Temp/" + fileInfo[1]);
            }
            else
            {
                return(Request.Url.GetLeftPart(UriPartial.Authority) + "/Temp/" + fileInfo[1]);
            }
        }