예제 #1
0
        public async Task <ProcessedDownloadedFile> ProcessImageAsync(DownloadedFileInfo downloadedFile)
        {
            using var imageProcessor = new ImageProcessor(downloadedFile.FileContents);
            imageProcessor.Rotate();

            var sizeFileIdMap = new Dictionary <int, long>();

            foreach (var size in _imageProcessingSettings.Sizes)
            {
                imageProcessor.Crop(size);
                var bytes = imageProcessor.GetImageBytes();

                var savedFile = await _imageUploadService.SaveThumbnailAsync(bytes, downloadedFile.ResourceName,
                                                                             downloadedFile.UserName, downloadedFile.Source, size);

                sizeFileIdMap.Add(size, savedFile.Id);
            }

            DateTime?dateTimeTaken = null;
            string   exifString    = null;
            double?  longitude     = null;
            double?  latitude      = null;

            var exifExtractor = new ExifExtractor();

            var exif = exifExtractor.GetDataAsync(downloadedFile.FileContents);

            if (exif != null)
            {
                dateTimeTaken = GetDate(exif);

                var gps = exif.Gps;
                if (gps != null)
                {
                    latitude = gps.Latitude != null && gps.LatitudeRef != null
                        ? GpsHelper.ConvertLatitude(gps.Latitude, gps.LatitudeRef)
                        : (double?)null;

                    longitude = gps.Longitude != null && gps.LongitudeRef != null
                        ? GpsHelper.ConvertLongitude(gps.Longitude, gps.LongitudeRef)
                        : (double?)null;
                }

                exifString = JsonConvert.SerializeObject(exif);
            }

            return(new ProcessedDownloadedFile
            {
                FileName = downloadedFile.ResourceName,
                FileSource = downloadedFile.Source,
                Thumbs = sizeFileIdMap,
                Path = downloadedFile.Path,
                FileCreatedOn = downloadedFile.CreatedOn,
                PhotoTakenOn = dateTimeTaken,
                ExifString = exifString,
                Latitude = latitude,
                Longitude = longitude
            });
        }
예제 #2
0
        // ------------------QUERY WINDOW------------------------------



        public void onSearchButtonClicked(string mode)
        {
            queryPage.stackPanel.Children.Clear();

            StudyLevelQuery querySettings = queryPage.getQueryFields();

            // search remote
            List <QueryObject> results = new List <QueryObject>();

            if (mode == "remote")
            {
                results = explorerLogic.searchPatient(querySettings);
            }

            foreach (QueryObject result in results)
            {
                Button resultButton = new Button();
                resultButton.Content = result.GetField("PatientName").Replace('^', ' ') + "      " + result.GetField("StudyDescription").Replace('_', ' ') + "      " + result.GetField("StudyDate") + "      " + result.GetField("Modality");
                resultButton.Click  += (theSender, eventArgs) => { onStudyButtonClicked(result); };
                queryPage.stackPanel.Children.Add(resultButton);
            }
            // search database
            DownloadedFileInfo d = new DownloadedFileInfo();

            d.SetField("PatientName", queryPage.PatientNameBox.Text);
            List <DownloadedFileInfo> risultati = new List <DownloadedFileInfo>();

            if (mode == "local")
            {
                risultati = database.Get(d, Constants.database);
            }

            foreach (DownloadedFileInfo result in risultati)
            {
                Button resultButton = new Button();
                resultButton.Content = result.PatientName.Replace('^', ' ') + "      " + result.StudyDescription.Replace('_', ' ') + "      " + result.StudyDate + "      " + result.Modality;
                resultButton.Click  += (theSender, eventArgs) => {
                    MessageBox.Show(XmlTools.getStoragePath(result));
                };
                queryPage.stackPanel.Children.Add(resultButton);
            }
        }