Added support for PDFs and Images
This commit is contained in:
@@ -38,7 +38,7 @@ namespace PWAPPv2
|
||||
|
||||
Source.Patient patient;
|
||||
|
||||
List<Source.DataObjects.PWImage> images;
|
||||
List<Source.DataObjects.Attachment> attachments;
|
||||
|
||||
|
||||
//string ConfigPath = "C:\\PWAPP\\Config\\Config.xml";
|
||||
@@ -53,21 +53,21 @@ namespace PWAPPv2
|
||||
}
|
||||
catch (Exception)
|
||||
{ }
|
||||
|
||||
ConfigPath = "C:\\PWAPP\\Config\\";
|
||||
try
|
||||
{
|
||||
//ConfigPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
//ConfigPath = Path.Combine(ConfigPath, "PWAPP\\Config\\");
|
||||
|
||||
ConfigPath = "C:\\PWAPP\\Config\\";
|
||||
|
||||
practiceConfig = new Source.Config.Configuration(ConfigPath + "PracticeConfig.xml");
|
||||
universalConfig = new Source.Config.Configuration(ConfigPath + "UniversalConfig.xml");
|
||||
|
||||
practiceConfig = new Source.Config.Configuration("C:\\PWAPP\\Config\\PracticeConfig.xml");
|
||||
universalConfig = new Source.Config.Configuration("C:\\PWAPP\\App\\Config\\UniversalConfig.xml");
|
||||
}
|
||||
catch
|
||||
(Exception)
|
||||
(Exception ex)
|
||||
{
|
||||
System.Windows.MessageBox.Show("An error has occured in the configurations files.");
|
||||
System.Windows.MessageBox.Show("An error has occured in the configurations files.\n(" + ex.Message + ")");
|
||||
}
|
||||
|
||||
pwapiConnection = new Source.API.PWApiConnection(practiceConfig, universalConfig);
|
||||
@@ -89,8 +89,12 @@ namespace PWAPPv2
|
||||
p.StartInfo.UseShellExecute = false;
|
||||
p.StartInfo.RedirectStandardOutput = true;
|
||||
p.StartInfo.RedirectStandardError = true;
|
||||
p.StartInfo.Arguments = args[0];
|
||||
if(System.Environment.OSVersion.Version.Major >= 6)
|
||||
try
|
||||
{
|
||||
p.StartInfo.Arguments = args[0];
|
||||
}
|
||||
catch { }
|
||||
if (System.Environment.OSVersion.Version.Major >= 6)
|
||||
{
|
||||
p.StartInfo.Verb = "runas";
|
||||
}
|
||||
@@ -106,8 +110,7 @@ namespace PWAPPv2
|
||||
|
||||
try
|
||||
{
|
||||
images = new List<Source.DataObjects.PWImage>();
|
||||
|
||||
attachments = new List<Source.DataObjects.Attachment>();
|
||||
|
||||
Source.Database.DatabaseConnection dbcon = new Source.Database.DatabaseConnection(practiceConfig);
|
||||
|
||||
@@ -207,7 +210,8 @@ namespace PWAPPv2
|
||||
private void Button_Click_1(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Source.DataObjects.Referral referral;
|
||||
if (images.Count == 0)
|
||||
|
||||
if (attachments.Count == 0)
|
||||
{
|
||||
referral = new Source.DataObjects.Referral(apiCreds, patient,
|
||||
(Source.DataObjects.ReferralTypeBox)TypeBox,
|
||||
@@ -224,17 +228,20 @@ namespace PWAPPv2
|
||||
fieldRemakrs, contact, true);
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
string referralString = referral.ToJsonString();
|
||||
string result = pwapiConnection.SendReferral(referralString); //apiConnection.SendPostRequestAsync("api/PWMakeReferral", referralString);
|
||||
if (images.Count > 0)
|
||||
string result = pwapiConnection.SendReferral(referralString);
|
||||
|
||||
|
||||
if (attachments.Count > 0)
|
||||
{
|
||||
foreach (Source.DataObjects.PWImage im in images)
|
||||
foreach (Source.DataObjects.Attachment attachment in attachments)
|
||||
{
|
||||
Source.DataObjects.Attachment att = new Source.DataObjects.Attachment(apiCreds, im, result);
|
||||
string json = att.ToJsonString();
|
||||
apiConnection.SendPostRequestAsync("api/PWAttachment", json);
|
||||
attachment.Token = result;
|
||||
string json = attachment.ToJsonString();
|
||||
apiConnection.SendPostWithCredsInHeader("api/PWAttachment", json);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,21 +260,41 @@ namespace PWAPPv2
|
||||
{
|
||||
System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
openFileDialog.Multiselect = true;
|
||||
openFileDialog.Filter = "Image files (*.jpg,*.jpeg)|*.jpg;*.jpeg";
|
||||
openFileDialog.Filter = "Attachment files (*.jpg,*.jpeg,*.pdf)|*.jpg;*.jpeg;*.pdf";
|
||||
openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
|
||||
|
||||
if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
foreach (string filename in openFileDialog.FileNames)
|
||||
{
|
||||
try
|
||||
if (Path.GetExtension(filename) == ".jpg" || Path.GetExtension(filename) == ".jpeg")
|
||||
{
|
||||
images.Add(new Source.DataObjects.PWImage(filename));
|
||||
try
|
||||
{
|
||||
attachments.Add(new Source.DataObjects.Attachment(apiCreds, new Source.DataObjects.PWImage(filename)));
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
|
||||
attachments = new List<Source.DataObjects.Attachment>
|
||||
{
|
||||
new Source.DataObjects.Attachment(apiCreds, new Source.DataObjects.PWImage(filename))
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
if (Path.GetExtension(filename) == ".pdf")
|
||||
{
|
||||
images = new List<Source.DataObjects.PWImage>();
|
||||
images.Add(new Source.DataObjects.PWImage(filename));
|
||||
try
|
||||
{
|
||||
attachments.Add(new Source.DataObjects.Attachment(apiCreds, new Source.DataObjects.PWPdf(filename)));
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
attachments = new List<Source.DataObjects.Attachment>()
|
||||
{
|
||||
new Source.DataObjects.Attachment(apiCreds, new Source.DataObjects.PWPdf(filename))
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,9 +303,17 @@ namespace PWAPPv2
|
||||
try
|
||||
{
|
||||
ImageList.Items.Clear();
|
||||
foreach (Source.DataObjects.PWImage image in images)
|
||||
|
||||
foreach (var attachment in attachments)
|
||||
{
|
||||
ImageList.Items.Add(CreateImageGridItem(image));
|
||||
if (attachment.image == null)
|
||||
{
|
||||
ImageList.Items.Add(CreateImageGridItem(new Source.DataObjects.PWImage("C:\\PWAPP\\App\\App\\pdf.jpg")));
|
||||
}
|
||||
else
|
||||
{
|
||||
ImageList.Items.Add(CreateImageGridItem(attachment.image));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
@@ -293,13 +328,22 @@ namespace PWAPPv2
|
||||
{
|
||||
return;
|
||||
}
|
||||
images.RemoveAt(index);
|
||||
|
||||
attachments.RemoveAt(index);
|
||||
try
|
||||
{
|
||||
ImageList.Items.Clear();
|
||||
foreach (Source.DataObjects.PWImage image in images)
|
||||
|
||||
foreach (var attachment in attachments)
|
||||
{
|
||||
ImageList.Items.Add(CreateImageGridItem(image));
|
||||
if (attachment.image == null)
|
||||
{
|
||||
ImageList.Items.Add(CreateImageGridItem(new Source.DataObjects.PWImage("C:\\PWAPP\\App\\App\\pdf.jpg")));
|
||||
}
|
||||
else
|
||||
{
|
||||
ImageList.Items.Add(CreateImageGridItem(attachment.image));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
|
||||
Reference in New Issue
Block a user