diff --git a/PWAPPv2/MainWindow.xaml.cs b/PWAPPv2/MainWindow.xaml.cs
index 63bed7b..0be297d 100644
--- a/PWAPPv2/MainWindow.xaml.cs
+++ b/PWAPPv2/MainWindow.xaml.cs
@@ -59,11 +59,22 @@ namespace PWAPPv2
SupportedImageTypes.Add(".jpeg");
SupportedImageTypes.Add(".jpg");
SupportedImageTypes.Add(".png");
+ SupportedImageTypes.Add(".gif");
+ SupportedImageTypes.Add(".bmp");
try
{
args = App.Args;
+ if(args.Length == 0)
+ {
+ throw new NoArgumentsException();
+ }
+ }
+ catch (NoArgumentsException)
+ {
+ System.Windows.MessageBox.Show("No Patient ID was selected.\nPlease select a patient and retry the referral.");
+ return;
}
catch (Exception)
{ }
@@ -431,4 +442,9 @@ namespace PWAPPv2
}
}
+
+ public class NoArgumentsException : Exception
+ {
+
+ }
}
diff --git a/PWAPPv2/PWAPPv2.csproj b/PWAPPv2/PWAPPv2.csproj
index ca5b7bc..bf4d933 100644
--- a/PWAPPv2/PWAPPv2.csproj
+++ b/PWAPPv2/PWAPPv2.csproj
@@ -230,6 +230,8 @@
+
+
@@ -237,6 +239,7 @@
+
diff --git a/PWAPPv2/Source/Attachments/AttachmentFactory.cs b/PWAPPv2/Source/Attachments/AttachmentFactory.cs
index 3749375..956c1d6 100644
--- a/PWAPPv2/Source/Attachments/AttachmentFactory.cs
+++ b/PWAPPv2/Source/Attachments/AttachmentFactory.cs
@@ -1,4 +1,5 @@
-using PWAPPv2.Source.DataObjects;
+using Microsoft.Identity.Client;
+using PWAPPv2.Source.DataObjects;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -49,5 +50,29 @@ namespace PWAPPv2.Source.Attachments
return attachment;
}
+
+ public static PWBaseAttachment BuildBaseAttachment(string token, PWImage image)
+ {
+ PWBaseAttachment attachment = new PWBaseAttachment();
+ attachment.AttToken = token.Replace("\"", "");
+ attachment.ThumbExists = true;
+ attachment.ZoomExists = true;
+ attachment.FileDate = "";
+ attachment.FileName = image.ShortFileName();
+ attachment.FileType = image.FileType;
+ return attachment;
+ }
+
+ public static PWBaseAttachment BuildBaseAttachment(string token, PWPdf pdf)
+ {
+ PWBaseAttachment attachment = new PWBaseAttachment();
+ attachment.AttToken = token.Replace("\"", "");
+ attachment.ThumbExists = false;
+ attachment.ZoomExists = true;
+ attachment.FileDate = "";
+ attachment.FileName = pdf.ShortFileName();
+ attachment.FileType = "application/pdf";
+ return attachment;
+ }
}
}
diff --git a/PWAPPv2/Source/Attachments/AttachmentResponse.cs b/PWAPPv2/Source/Attachments/AttachmentResponse.cs
new file mode 100644
index 0000000..d0f059a
--- /dev/null
+++ b/PWAPPv2/Source/Attachments/AttachmentResponse.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PWAPPv2.Source.Attachments
+{
+ public class AttachmentResponse
+ {
+ }
+}
diff --git a/PWAPPv2/Source/Attachments/FileHandler.cs b/PWAPPv2/Source/Attachments/FileHandler.cs
index 2ded692..d3f0522 100644
--- a/PWAPPv2/Source/Attachments/FileHandler.cs
+++ b/PWAPPv2/Source/Attachments/FileHandler.cs
@@ -37,7 +37,10 @@ namespace PWAPPv2.Source.Attachments
SupportedImageTypes.Add(".jpeg");
SupportedImageTypes.Add(".jpg");
SupportedImageTypes.Add(".png");
- //SupportedImageTypes.Add(".tiff");
+ SupportedImageTypes.Add(".tiff");
+ SupportedImageTypes.Add(".tif");
+ SupportedImageTypes.Add(".gif");
+ SupportedImageTypes.Add(".bmp");
SupportedDocumentTypes.Clear();
SupportedDocumentTypes.Add(".pdf");
@@ -108,23 +111,50 @@ namespace PWAPPv2.Source.Attachments
}
foreach(DataObjects.Attachment attachment in Attachments)
{
- PWAttachment att = null;
+ //PWAttachment att = null;
+ PWBaseAttachment ba = null;
+
+ List fileUploads = new List();
+
if (attachment.image != null)
{
- att = AttachmentFactory.BuildAttachment(credentials, token, attachment.image);
+ //att = AttachmentFactory.BuildAttachment(credentials, token, attachment.image);
+ ba = AttachmentFactory.BuildBaseAttachment(token, attachment.image);
+ //fileUploads.Add(attachment.image.GetFileUploads(attachment.co))
+ string json = JsonSerializer.Serialize(ba);
+ string contId = connection.SendPostWithCredsInHeader("api/PWAddAttachment", json);
+ contId = contId.Replace("\"", "").Replace("\\n", "").Trim();
+ fileUploads = attachment.image.GetFileUploads(token, contId);
+ foreach(PWFileUpload file in fileUploads)
+ {
+ json = JsonSerializer.Serialize(file);
+ connection.SendPostWithCredsInHeader("api/PWUploadFile", json);
+ }
}
else if (attachment.pdf != null)
{
- att = AttachmentFactory.BuildAttachment(credentials, token, attachment.pdf);
+ //att = AttachmentFactory.BuildAttachment(credentials, token, attachment.pdf);
+ ba = AttachmentFactory.BuildBaseAttachment(token, attachment.pdf);
+
+ string json = JsonSerializer.Serialize(ba);
+ string contId = connection.SendPostWithCredsInHeader("api/PWAddAttachment", json);
+ fileUploads = attachment.pdf.GetFileUploads(token, contId);
+ foreach (PWFileUpload file in fileUploads)
+ {
+ json = JsonSerializer.Serialize(file);
+ connection.SendPostWithCredsInHeader("api/PWUploadFile", json);
+ }
}
- if (att == null)
- {
- throw new AttachmentTypeNotYetSupportedException();
- }
- string json = JsonSerializer.Serialize(att);
- connection.SendPostWithCredsInHeader("api/PWAttachment", json);
+ //if (att == null)
+ //{
+ // throw new AttachmentTypeNotYetSupportedException();
+ //}
+ //string json = JsonSerializer.Serialize(att);
+ //connection.SendPostWithCredsInHeader("api/PWAttachment", json);
+ //json = JsonSerializer.Serialize(ba);
+ //connection.SendPostWithCredsInHeader("api/PWAddAttachment", json);
}
}
diff --git a/PWAPPv2/Source/Attachments/PWBaseAttachment.cs b/PWAPPv2/Source/Attachments/PWBaseAttachment.cs
new file mode 100644
index 0000000..cb080a8
--- /dev/null
+++ b/PWAPPv2/Source/Attachments/PWBaseAttachment.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PWAPPv2.Source.Attachments
+{
+ public class PWBaseAttachment
+ {
+ public string AttToken { get; set; }
+ public string FileName { get; set; }
+ public bool ThumbExists { get; set; }
+ public bool ZoomExists { get; set; }
+ public string FileDate { get; set; }
+ public string FileType { get; set; }
+
+ }
+}
diff --git a/PWAPPv2/Source/Attachments/PWFileUpload.cs b/PWAPPv2/Source/Attachments/PWFileUpload.cs
new file mode 100644
index 0000000..35ec5d7
--- /dev/null
+++ b/PWAPPv2/Source/Attachments/PWFileUpload.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PWAPPv2.Source.Attachments
+{
+ public class PWFileUpload
+ {
+ public string Base64Content { get; set; }
+ public string AttToken { get; set; }
+ public string ContentId { get; set; }
+ public string Tag { get; set; }
+ }
+}
diff --git a/PWAPPv2/Source/DataObjects/PWFile.cs b/PWAPPv2/Source/DataObjects/PWFile.cs
new file mode 100644
index 0000000..2360f10
--- /dev/null
+++ b/PWAPPv2/Source/DataObjects/PWFile.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PWAPPv2.Source.DataObjects
+{
+ interface PWFile
+ {
+ List GetFileUploads(string attToken, string ContentId);
+ }
+}
diff --git a/PWAPPv2/Source/DataObjects/PWImage.cs b/PWAPPv2/Source/DataObjects/PWImage.cs
index 61e1e54..cbbacee 100644
--- a/PWAPPv2/Source/DataObjects/PWImage.cs
+++ b/PWAPPv2/Source/DataObjects/PWImage.cs
@@ -1,11 +1,14 @@
-using System;
+using PWAPPv2.Source.Attachments;
+using System;
+using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
namespace PWAPPv2.Source.DataObjects
{
- public class PWImage
+ public class PWImage : PWFile
{
private string ImagePath;
@@ -30,14 +33,26 @@ namespace PWAPPv2.Source.DataObjects
string extension = Path.GetExtension(path).ToLower();
- if(extension == ".jpeg" || extension == ".jpg")
+ if (extension == ".jpeg" || extension == ".jpg")
{
FileType = "image/jpeg";
}
- else if(extension == ".png")
+ else if (extension == ".png")
{
FileType = "image/png";
}
+ else if (extension == ".tiff" || extension == ".tif")
+ {
+ FileType = "image/tiff";
+ }
+ else if(extension == ".gif")
+ {
+ FileType = "image/gif";
+ }
+ else if(extension == ".bmp")
+ {
+ FileType = "image/bmp";
+ }
//bmp = (Bitmap)System.Drawing.Image.FromFile(ImagePath);
//thumb = resize(bmp, 50, 50);
@@ -118,5 +133,29 @@ namespace PWAPPv2.Source.DataObjects
return str;
}
+ public List GetFileUploads(string attToken, string ContentId)
+ {
+ List fileUploads = new List();
+ PWFileUpload baseImage = new PWFileUpload();
+ baseImage.ContentId = ContentId;
+ baseImage.Base64Content = GetBase64String();
+ baseImage.AttToken = attToken;
+
+ PWFileUpload zoom = new PWFileUpload();
+ zoom.Base64Content = GetBase64ZoomString();
+ zoom.ContentId = ContentId;
+ zoom.Tag = "_zoom";
+ zoom.AttToken = attToken;
+
+ PWFileUpload thumb = new PWFileUpload();
+ thumb.Base64Content= GetBase64ThumbString();
+ thumb.ContentId = ContentId;
+ thumb.Tag = "_th";
+ thumb.AttToken = attToken;
+ fileUploads.Add(baseImage);
+ fileUploads.Add(zoom);
+ fileUploads.Add(thumb);
+ return fileUploads;
+ }
}
}
diff --git a/PWAPPv2/Source/DataObjects/PWPdf.cs b/PWAPPv2/Source/DataObjects/PWPdf.cs
index efa371f..1bf15af 100644
--- a/PWAPPv2/Source/DataObjects/PWPdf.cs
+++ b/PWAPPv2/Source/DataObjects/PWPdf.cs
@@ -1,4 +1,5 @@
-using System;
+using PWAPPv2.Source.Attachments;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -7,7 +8,7 @@ using System.Threading.Tasks;
namespace PWAPPv2.Source.DataObjects
{
- public class PWPdf
+ public class PWPdf : PWFile
{
public string path;
@@ -23,6 +24,17 @@ namespace PWAPPv2.Source.DataObjects
return Convert.ToBase64String(bytes);
}
+ public List GetFileUploads(string attToken, string ContentId)
+ {
+ List fileUploads = new List();
+ PWFileUpload file = new PWFileUpload();
+ file.Base64Content = GetBase64String();
+ file.ContentId = ContentId;
+ file.AttToken = attToken;
+ fileUploads.Add(file);
+ return fileUploads;
+ }
+
public string ShortFileName()
{
return path.Substring(path.LastIndexOf("\\") + 1);