Compare commits

...

8 Commits
v2.1 ... master

39 changed files with 1408 additions and 188 deletions

10
Config/PracticeConfig.xml Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<Config>
<ODhost>10.0.1.107</ODhost>
<ODuser>root</ODuser>
<ODpassword></ODpassword>
<pwuserid>testdoctor</pwuserid>
<pwpassword>testdoctor</pwpassword>
<pwpracticeid>210</pwpracticeid>
<pwapiid>12345678</pwapiid>
</Config>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<Config>
<PWBaseURI>http://apipatientweb.azurewebsites.net/</PWBaseURI>
<PWUpdateURI>https://localhost:44354/api/PWAppVersion</PWUpdateURI>
</Config>

View File

@ -1,11 +1,11 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.33529.622
# Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PWAPPv2", "PWAPPv2\PWAPPv2.csproj", "{45E26AF8-41D7-4308-A2C8-D55A0350DB47}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{164B9220-F337-4E88-B619-0C52C502B9C4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PWAppUpdaterForm", "PWAppUpdater2\PWAppUpdaterForm.csproj", "{093798DD-2EDD-4519-AAC6-9DFF0DE3C15A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -17,10 +17,10 @@ Global
{45E26AF8-41D7-4308-A2C8-D55A0350DB47}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45E26AF8-41D7-4308-A2C8-D55A0350DB47}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45E26AF8-41D7-4308-A2C8-D55A0350DB47}.Release|Any CPU.Build.0 = Release|Any CPU
{164B9220-F337-4E88-B619-0C52C502B9C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{164B9220-F337-4E88-B619-0C52C502B9C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{164B9220-F337-4E88-B619-0C52C502B9C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{164B9220-F337-4E88-B619-0C52C502B9C4}.Release|Any CPU.Build.0 = Release|Any CPU
{093798DD-2EDD-4519-AAC6-9DFF0DE3C15A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{093798DD-2EDD-4519-AAC6-9DFF0DE3C15A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{093798DD-2EDD-4519-AAC6-9DFF0DE3C15A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{093798DD-2EDD-4519-AAC6-9DFF0DE3C15A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -15,15 +15,15 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.3" newVersion="7.0.0.3" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.1" newVersion="8.0.0.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Abstractions" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.24.0.0" newVersion="6.24.0.0" />
<bindingRedirect oldVersion="0.0.0.0-7.2.0.0" newVersion="7.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Identity.Client" publicKeyToken="0a613f4dd989e8ae" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.47.2.0" newVersion="4.47.2.0" />
<bindingRedirect oldVersion="0.0.0.0-4.58.1.0" newVersion="4.58.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
@ -31,16 +31,72 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.ProtectedData" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.AccessControl" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory.Data" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Azure.Core" publicKeyToken="92742159e12e44c8" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.37.0.0" newVersion="1.37.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Identity.Client.Extensions.Msal" publicKeyToken="0a613f4dd989e8ae" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.58.1.0" newVersion="4.58.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Azure.Identity" publicKeyToken="92742159e12e44c8" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.10.4.0" newVersion="1.10.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Protocols.OpenIdConnect" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.2.0.0" newVersion="7.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Protocols" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.2.0.0" newVersion="7.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Tokens" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.2.0.0" newVersion="7.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.2.0.0" newVersion="7.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.JsonWebTokens" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.2.0.0" newVersion="7.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Logging" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.2.0.0" newVersion="7.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -81,7 +81,7 @@
</GroupBox>
<Button Content="Send" HorizontalAlignment="Left" Margin="383,476,0,0" VerticalAlignment="Top" Width="75" Grid.Column="1" Height="20" Click="Button_Click_1"/>
<Button Content="Cancel" HorizontalAlignment="Left" Margin="303,476,0,0" VerticalAlignment="Top" Width="75" Grid.Column="1" Height="20" Click="Button_Click"/>
<GroupBox Header="Images" HorizontalAlignment="Left" Height="281" Margin="1,190,0,0" VerticalAlignment="Top" Width="457" Grid.Column="1">
<GroupBox Header="Attachments" HorizontalAlignment="Left" Height="281" Margin="1,190,0,0" VerticalAlignment="Top" Width="457" Grid.Column="1">
<Grid HorizontalAlignment="Left" Height="258" VerticalAlignment="Top" Width="447" Margin="0,0,-2,0">
<Grid.RowDefinitions>
<RowDefinition Height="4*"/>
@ -94,8 +94,8 @@
<ColumnDefinition Width="80*"/>
<ColumnDefinition Width="77*"/>
</Grid.ColumnDefinitions>
<Button x:Name="AddImageButton" Content="Add Image" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Height="20" Click="Button_Click_2"/>
<Button Content="Remove" Grid.Column="1" Margin="0,0,5,1" HorizontalAlignment="Right" Width="75" Click="Button_Click_3"/>
<Button x:Name="AddImageButton" Content="Add Attachment" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Width="100" Height="20" Click="Button_Click_2" Grid.ColumnSpan="2" Margin="47,0,0,0"/>
<Button Content="Remove" Margin="257,0,0,1" HorizontalAlignment="Left" Width="75" Click="Button_Click_3" Grid.ColumnSpan="2"/>
</Grid>
<ListBox x:Name="ImageList" HorizontalAlignment="Left" Height="234" Grid.Row="1" VerticalAlignment="Top" Width="447"/>
</Grid>

View File

@ -1,9 +1,10 @@
using Microsoft.Win32;
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Forms;
/**
* TODO:
@ -17,23 +18,32 @@ namespace PWAPPv2
/// </summary>
public partial class MainWindow : Window
{
static Source.APIConfig apiconfig = new Source.APIConfig();
static Source.APIConfig apiconfig;// = new Source.APIConfig();
static Source.Database.DatabaseConfig DataConfig;
static Source.API.APIConnection apiConnection;
Source.DataObjects.APICredentials apiCreds;
Source.API.PWApiConnection pwapiConnection;
Source.DataObjects.ComboBoxData TypeBox;
Source.DataObjects.ComboBoxData ToBox;
Source.DataObjects.ComboBoxData FromBox;
Source.Config.Configuration practiceConfig;
Source.Config.Configuration universalConfig;
string[] args;
Source.Patient patient;
List<Source.DataObjects.PWImage> images;
List<Source.DataObjects.Attachment> attachments;
string ConfigPath = "C:\\PWAPP\\Config\\Config.xml";
//string ConfigPath = "C:\\PWAPP\\Config\\Config.xml";
string ConfigPath;
public MainWindow()
{
@ -43,18 +53,70 @@ namespace PWAPPv2
}
catch (Exception)
{ }
ConfigPath = "C:\\PWAPP\\Config\\";
try
{
images = new List<Source.DataObjects.PWImage>();
//ConfigPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
//ConfigPath = Path.Combine(ConfigPath, "PWAPP\\Config\\");
apiconfig.LoadConfig(ConfigPath);
DataConfig = new Source.Database.DatabaseConfig(ConfigPath);
Source.Database.DatabaseConnection dbcon = new Source.Database.DatabaseConnection(DataConfig);
practiceConfig = new Source.Config.Configuration("C:\\PWAPP\\Config\\PracticeConfig.xml");
universalConfig = new Source.Config.Configuration("C:\\PWAPP\\App\\Config\\UniversalConfig.xml");
}
catch
(Exception ex)
{
System.Windows.MessageBox.Show("An error has occured in the configurations files.\n(" + ex.Message + ")");
}
pwapiConnection = new Source.API.PWApiConnection(practiceConfig, universalConfig);
try
{
if (pwapiConnection.CheckForUpdate() == true)
{
string message = "An update is available! Would you like to install it?";
string title = "Update available!";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result = System.Windows.Forms.MessageBox.Show(message, title, buttons);
if (result == System.Windows.Forms.DialogResult.Yes)
{
//System.Windows.MessageBox.Show("HAHA NO UPDATE FOR YOU!");
Process p = new Process();
p.StartInfo.FileName = "C:\\PWAPP\\Updater\\PWAppUpdaterForm.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
try
{
p.StartInfo.Arguments = args[0];
}
catch { }
if (System.Environment.OSVersion.Version.Major >= 6)
{
p.StartInfo.Verb = "runas";
}
p.Start();
Environment.Exit(0);
}
}
}
catch (Exception)
{
System.Windows.MessageBox.Show("An error has occured while checking for updates");
}
try
{
attachments = new List<Source.DataObjects.Attachment>();
Source.Database.DatabaseConnection dbcon = new Source.Database.DatabaseConnection(practiceConfig);
apiconfig = new Source.APIConfig(practiceConfig, universalConfig);
apiCreds = new Source.DataObjects.APICredentials(apiconfig);
apiConnection = new Source.API.APIConnection("http://apipatientweb.azurewebsites.net/",
apiCreds);
apiConnection = new Source.API.APIConnection(universalConfig.Get("PWBaseURI"), apiCreds);
InitializeComponent();
@ -66,13 +128,13 @@ namespace PWAPPv2
this.DataContext = new Source.PatientGUIAdapter(patient);
}
catch(NullReferenceException)
catch (NullReferenceException)
{
}
catch(Exception e)
catch (Exception e)
{
MessageBox.Show(e.Message);
System.Windows.MessageBox.Show(e.Message);
}
}
@ -85,20 +147,21 @@ namespace PWAPPv2
private void PopulateReferTypesBox()
{
string ReferTypeString = apiConnection.SendPostRequestAsync("api/PWReferralTypes");
//string ReferTypeString = apiConnection.SendPostRequestAsync("api/PWReferralTypes");
string ReferTypeString = pwapiConnection.GetReferalTypes();
TypeBox = new Source.DataObjects.ReferralTypeBox(boxReferType, ReferTypeString);
}
private void PopulateReferToBox()
{
string ReferToString = apiConnection.SendPostRequestAsync("api/PWReferTo");
string ReferToString = pwapiConnection.GetReferTo(); //apiConnection.SendPostRequestAsync("api/PWReferTo");
ToBox = new Source.DataObjects.ReferToBox(boxReferTo, ReferToString);
}
private void PopulateReferFromBox()
{
string ReferFromString = apiConnection.SendPostRequestAsync("api/PWReferFrom");
string ReferFromString = pwapiConnection.GetReferFrom(); //apiConnection.SendPostRequestAsync("api/PWReferFrom");
FromBox = new Source.DataObjects.ReferFromBox(boxReferFrom, ReferFromString);
}
@ -147,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,
@ -164,24 +228,25 @@ namespace PWAPPv2
fieldRemakrs, contact, true);
}
try
{
string referralString = referral.ToJsonString();
string result = 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);
}
MessageBox.Show("Referral added successfully!");
}
else
{
MessageBox.Show(result);
}
System.Windows.MessageBox.Show("Referral added successfully!");
this.Close();
}
catch (Source.DataObjects.Referral.InvalidReferalDataException)
@ -193,23 +258,43 @@ namespace PWAPPv2
//AddImage Button
private void Button_Click_2(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
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() == true)
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))
};
}
}
}
@ -218,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)
@ -235,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)
@ -252,7 +354,7 @@ namespace PWAPPv2
{
Grid imageGrid = new Grid();
imageGrid.Width = 477;
imageGrid.HorizontalAlignment = HorizontalAlignment.Left;
imageGrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
imageGrid.VerticalAlignment = VerticalAlignment.Top;
imageGrid.ShowGridLines = true;

View File

@ -37,77 +37,90 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Azure.Core, Version=1.25.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
<HintPath>..\packages\Azure.Core.1.25.0\lib\net461\Azure.Core.dll</HintPath>
<Reference Include="Azure.Core, Version=1.37.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
<HintPath>..\packages\Azure.Core.1.37.0\lib\net472\Azure.Core.dll</HintPath>
</Reference>
<Reference Include="Azure.Identity, Version=1.7.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
<HintPath>..\packages\Azure.Identity.1.7.0\lib\netstandard2.0\Azure.Identity.dll</HintPath>
<Reference Include="Azure.Identity, Version=1.10.4.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
<HintPath>..\packages\Azure.Identity.1.10.4\lib\netstandard2.0\Azure.Identity.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.SqlClient, Version=5.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.SqlClient.5.1.1\lib\net462\Microsoft.Data.SqlClient.dll</HintPath>
<HintPath>..\packages\Microsoft.Data.SqlClient.5.1.4\lib\net462\Microsoft.Data.SqlClient.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Identity.Client, Version=4.47.2.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Identity.Client.4.47.2\lib\net461\Microsoft.Identity.Client.dll</HintPath>
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Identity.Client.Extensions.Msal, Version=2.19.3.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Identity.Client.Extensions.Msal.2.19.3\lib\net45\Microsoft.Identity.Client.Extensions.Msal.dll</HintPath>
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.8.0.0\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Abstractions, Version=6.24.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Abstractions.6.24.0\lib\net472\Microsoft.IdentityModel.Abstractions.dll</HintPath>
<Reference Include="Microsoft.Identity.Client, Version=4.58.1.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Identity.Client.4.58.1\lib\net462\Microsoft.Identity.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.JsonWebTokens, Version=6.24.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.JsonWebTokens.6.24.0\lib\net472\Microsoft.IdentityModel.JsonWebTokens.dll</HintPath>
<Reference Include="Microsoft.Identity.Client.Extensions.Msal, Version=4.58.1.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Identity.Client.Extensions.Msal.4.58.1\lib\netstandard2.0\Microsoft.Identity.Client.Extensions.Msal.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Logging, Version=6.24.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Logging.6.24.0\lib\net472\Microsoft.IdentityModel.Logging.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Abstractions, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Abstractions.7.2.0\lib\net472\Microsoft.IdentityModel.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Protocols, Version=6.24.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Protocols.6.24.0\lib\net472\Microsoft.IdentityModel.Protocols.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.JsonWebTokens, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.JsonWebTokens.7.2.0\lib\net472\Microsoft.IdentityModel.JsonWebTokens.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect, Version=6.24.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Protocols.OpenIdConnect.6.24.0\lib\net472\Microsoft.IdentityModel.Protocols.OpenIdConnect.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Logging, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Logging.7.2.0\lib\net472\Microsoft.IdentityModel.Logging.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Tokens, Version=6.24.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Tokens.6.24.0\lib\net472\Microsoft.IdentityModel.Tokens.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Protocols, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Protocols.7.2.0\lib\net472\Microsoft.IdentityModel.Protocols.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Protocols.OpenIdConnect.7.2.0\lib\net472\Microsoft.IdentityModel.Protocols.OpenIdConnect.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Tokens, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Tokens.7.2.0\lib\net472\Microsoft.IdentityModel.Tokens.dll</HintPath>
</Reference>
<Reference Include="MySqlConnector, Version=2.0.0.0, Culture=neutral, PublicKeyToken=d33d3e53aa5f8c92, processorArchitecture=MSIL">
<HintPath>..\packages\MySqlConnector.2.2.7\lib\net471\MySqlConnector.dll</HintPath>
<HintPath>..\packages\MySqlConnector.2.3.4\lib\net471\MySqlConnector.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json.Bson, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.Bson.1.0.2\lib\net45\Newtonsoft.Json.Bson.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration.ConfigurationManager, Version=6.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Configuration.ConfigurationManager.6.0.1\lib\net461\System.Configuration.ConfigurationManager.dll</HintPath>
<Reference Include="System.Configuration.ConfigurationManager, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Configuration.ConfigurationManager.8.0.0\lib\net462\System.Configuration.ConfigurationManager.dll</HintPath>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Data.OracleClient" />
<Reference Include="System.Diagnostics.DiagnosticSource, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.6.0.0\lib\net461\System.Diagnostics.DiagnosticSource.dll</HintPath>
<Reference Include="System.Diagnostics.DiagnosticSource, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.8.0.0\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
<Reference Include="System.DirectoryServices" />
<Reference Include="System.Drawing" />
<Reference Include="System.IdentityModel" />
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=6.24.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.IdentityModel.Tokens.Jwt.6.24.0\lib\net472\System.IdentityModel.Tokens.Jwt.dll</HintPath>
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.IdentityModel.Tokens.Jwt.7.2.0\lib\net472\System.IdentityModel.Tokens.Jwt.dll</HintPath>
</Reference>
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.IO.FileSystem.AccessControl, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.FileSystem.AccessControl.5.0.0\lib\net461\System.IO.FileSystem.AccessControl.dll</HintPath>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Memory.Data, Version=1.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.Data.1.0.2\lib\net461\System.Memory.Data.dll</HintPath>
<Reference Include="System.Memory.Data, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.Data.8.0.0\lib\net462\System.Memory.Data.dll</HintPath>
</Reference>
<Reference Include="System.Net" />
<Reference Include="System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
@ -118,11 +131,11 @@
<Reference Include="System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Formatting, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.9\lib\net45\System.Net.Http.Formatting.dll</HintPath>
<Reference Include="System.Net.Http.Formatting, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.6.0.0\lib\net45\System.Net.Http.Formatting.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Json, Version=7.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Http.Json.7.0.1\lib\net462\System.Net.Http.Json.dll</HintPath>
<Reference Include="System.Net.Http.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Http.Json.8.0.0\lib\net462\System.Net.Http.Json.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Primitives, Version=4.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll</HintPath>
@ -164,26 +177,26 @@
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.ProtectedData, Version=4.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.ProtectedData.4.7.0\lib\net461\System.Security.Cryptography.ProtectedData.dll</HintPath>
<Reference Include="System.Security.Cryptography.ProtectedData, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.ProtectedData.8.0.0\lib\net462\System.Security.Cryptography.ProtectedData.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.X509Certificates.4.3.2\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Permissions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Permissions.6.0.0\lib\net461\System.Security.Permissions.dll</HintPath>
<Reference Include="System.Security.Permissions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Permissions.8.0.0\lib\net462\System.Security.Permissions.dll</HintPath>
</Reference>
<Reference Include="System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
</Reference>
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Text.Encodings.Web, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.7.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
<Reference Include="System.Text.Encodings.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=7.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.7.0.3\lib\net462\System.Text.Json.dll</HintPath>
<Reference Include="System.Text.Json, Version=8.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.8.0.1\lib\net462\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
@ -213,6 +226,8 @@
<Compile Include="Source\API\APIConfig.cs" />
<Compile Include="Source\API\APIConnection.cs" />
<Compile Include="Source\API\APIRequestBuilder.cs" />
<Compile Include="Source\API\PWApiConnection.cs" />
<Compile Include="Source\Config\Configuration.cs" />
<Compile Include="Source\Database\DatabaseConfig.cs" />
<Compile Include="Source\Database\DatabaseConnection.cs" />
<Compile Include="Source\DataObjects\APICredentials.cs" />
@ -222,6 +237,7 @@
<Compile Include="Source\DataObjects\PWImage.cs" />
<Compile Include="Source\DataObjects\NumValList.cs" />
<Compile Include="Source\DataObjects\NumValPair.cs" />
<Compile Include="Source\DataObjects\PWPdf.cs" />
<Compile Include="Source\DataObjects\ReferFromBox.cs" />
<Compile Include="Source\DataObjects\Referral.cs" />
<Compile Include="Source\DataObjects\ReferralTypeBox.cs" />
@ -268,9 +284,6 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Resource Include="Config\Config.xml" />
</ItemGroup>
<ItemGroup>
<Folder Include="Source\GUIData\" />
</ItemGroup>
@ -281,7 +294,7 @@
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Data.SqlClient.SNI.5.1.0\build\net462\Microsoft.Data.SqlClient.SNI.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Data.SqlClient.SNI.5.1.0\build\net462\Microsoft.Data.SqlClient.SNI.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Data.SqlClient.SNI.5.1.1\build\net462\Microsoft.Data.SqlClient.SNI.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Data.SqlClient.SNI.5.1.1\build\net462\Microsoft.Data.SqlClient.SNI.targets'))" />
</Target>
<Import Project="..\packages\Microsoft.Data.SqlClient.SNI.5.1.0\build\net462\Microsoft.Data.SqlClient.SNI.targets" Condition="Exists('..\packages\Microsoft.Data.SqlClient.SNI.5.1.0\build\net462\Microsoft.Data.SqlClient.SNI.targets')" />
<Import Project="..\packages\Microsoft.Data.SqlClient.SNI.5.1.1\build\net462\Microsoft.Data.SqlClient.SNI.targets" Condition="Exists('..\packages\Microsoft.Data.SqlClient.SNI.5.1.1\build\net462\Microsoft.Data.SqlClient.SNI.targets')" />
</Project>

View File

@ -1,4 +1,5 @@
using System;
using PWAPPv2.Source.Config;
using System;
using System.Xml;
namespace PWAPPv2.Source
@ -10,6 +11,25 @@ namespace PWAPPv2.Source
public string PWPracticeID;
public string PWApiID;
public string PWBaseURI;
public string PWUpdateURI;
public string PWAppVersion;
public APIConfig() { }
public APIConfig(Config.Configuration practiceConfig, Config.Configuration universalConfig)
{
PWUserID = practiceConfig.Get("pwuserid");
PWPassword = practiceConfig.Get("pwpassword");
PWPracticeID = practiceConfig.Get("pwpracticeid");
PWApiID = practiceConfig.Get("pwapiid");
PWBaseURI = universalConfig.Get("PWBaseURI");
PWUpdateURI = universalConfig.Get("PWUpdateURI");
PWAppVersion = universalConfig.Get("PWAppVersion");
}
public void LoadConfig(string path)
{
XmlDocument cfgDoc = new XmlDocument();

View File

@ -1,4 +1,6 @@
using System;
using Microsoft.Identity.Client.Platforms.Features.DesktopOs.Kerberos;
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Http;
@ -13,34 +15,32 @@ namespace PWAPPv2.Source.API
public DataObjects.APICredentials Credentials;
private static bool ResponseReady = false;
private static string Response = "";
HttpClient Client;
public APIConnection(string baseUrl, DataObjects.APICredentials credentials)
{
Credentials = credentials;
BaseURL = baseUrl;
Client = new HttpClient();
Client.BaseAddress = new Uri(BaseURL);
Client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
Client.DefaultRequestHeaders.Add("UserID", Credentials.UserID);
Client.DefaultRequestHeaders.Add("Password", Credentials.Password);
Client.DefaultRequestHeaders.Add("PracticeID", Credentials.PracticeId);
Client.DefaultRequestHeaders.Add("ApiID", Credentials.APIid);
}
public string GetResponse()
{
while (!ResponseReady) ;
return Response;
}
/// <summary>
/// Dont use. Doesn't work, sillyhead.
/// </summary>
/// <param name="Call"></param>
public static async void APIGet(string Call)
{
//WebRequest request = WebRequest.Create(BaseURL + Call);
//request.Method = "GET";
//request.ContentType = "application/json; charset=utf-8";
//var response = (HttpWebResponse)request.GetResponse();
//string text;
//using (var sr = new StreamReader(response.GetResponseStream()))
//{
// text = sr.ReadToEnd();
//}
//return text;
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(BaseURL);
@ -52,16 +52,16 @@ namespace PWAPPv2.Source.API
}
}
/// <summary>
/// Send a post requst without data. Essentially an advanced get since I was a retard when I wrote the original API.
/// </summary>
/// <param name="apiUri"></param>
/// <returns></returns>
public string SendPostRequestAsync(string apiUri)
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(BaseURL);
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
StringContent contetnt = new StringContent(Credentials.ToJsonString(), Encoding.UTF8, "application/json");
var response = client.PostAsync(apiUri, contetnt).Result;
var response = Client.PostAsync(apiUri, contetnt).Result;
if (response.IsSuccessStatusCode)
{
@ -69,16 +69,18 @@ namespace PWAPPv2.Source.API
}
return "";
}
/// <summary>
/// Send a post request with data
/// </summary>
/// <param name="apiUri"></param>
/// <param name="PostData"></param>
/// <returns></returns>
public string SendPostRequestAsync(string apiUri, string PostData)
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(BaseURL);
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
StringContent contetnt = new StringContent(PostData, Encoding.UTF8, "application/json");
var response = client.PostAsync(apiUri, contetnt).Result;
var response = Client.PostAsync(apiUri, contetnt).Result;
if (response.IsSuccessStatusCode)
{
@ -87,5 +89,44 @@ namespace PWAPPv2.Source.API
return "";
}
/// <summary>
/// Send a post request with the API credengials in the header of the request.
/// </summary>
/// <param name="apiUri"></param>
/// <param name="PostData"></param>
/// <returns></returns>
/// <exception cref="RequestFailedExcpetion"></exception>
public string SendPostWithCredsInHeader(string apiUri, string PostData)
{
StringContent content = new StringContent(PostData, Encoding.UTF8, "application/json");
string conts = content.ToString();
var response = Client.PostAsync(apiUri, content).Result;
//Client.DefaultRequestHeaders.Remove("UserID");
//Client.DefaultRequestHeaders.Remove("Password");
//Client.DefaultRequestHeaders.Remove("PraticeID");
//Client.DefaultRequestHeaders.Remove("ApiID");
if (response.IsSuccessStatusCode)
{
return response.Content.ReadAsStringAsync().Result;
}
throw new RequestFailedExcpetion(response.StatusCode.ToString());
}
}
public class RequestFailedExcpetion : Exception
{
public string RequestError;
public RequestFailedExcpetion(string errorCode)
{
RequestError = "Server responded with error code: " + errorCode;
}
}
}

View File

@ -0,0 +1,81 @@
using PWAPPv2.Source.DataObjects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PWAPPv2.Source.API
{
public class PWApiConnection
{
private APIConnection BaseConnection;
private APIConnection UpdateConnection;
private APIConnection AttachementConnection;
private APIConnection ReferralConnection;
private APIConnection ReferToConnection;
private APIConnection ReferFromConnection;
private APIConnection ReferTypesConnection;
private APICredentials Credentials;
private string AppVersion;
public PWApiConnection(Source.Config.Configuration practiceConfig, Source.Config.Configuration universalConfig)
{
Credentials = new APICredentials(practiceConfig);
BaseConnection = new APIConnection(universalConfig.Get("PWBaseURI"), Credentials);
UpdateConnection = new APIConnection(universalConfig.Get("PWUpdateURI"), Credentials);
AttachementConnection = new APIConnection(universalConfig.Get("PWAttachmentURI"), Credentials);
ReferralConnection = new APIConnection(universalConfig.Get("PWReferralURI"), Credentials);
ReferToConnection = new APIConnection(universalConfig.Get("PWReferToURI"), Credentials);
ReferFromConnection = new APIConnection(universalConfig.Get("PWReferFromURI"), Credentials);
ReferTypesConnection = new APIConnection(universalConfig.Get("PWReferTypesURI"), Credentials);
AppVersion = universalConfig.Get("PWAppVersion");
}
public string PostToApi(string uri, string data)
{
return BaseConnection.SendPostRequestAsync(uri, data);
}
public string GetFromApi(string uri)
{
return BaseConnection.SendPostRequestAsync(uri);
}
public bool CheckForUpdate()
{
string currentVersion = UpdateConnection.SendPostWithCredsInHeader("", "");
currentVersion = currentVersion.Replace("\"", "");
if(currentVersion != AppVersion)
{
return true;
}
return false;
}
public string GetReferalTypes()
{
return ReferTypesConnection.SendPostWithCredsInHeader("", "");
}
public string GetReferTo()
{
return ReferToConnection.SendPostWithCredsInHeader("", "");
}
public string GetReferFrom()
{
return ReferFromConnection.SendPostWithCredsInHeader("", "");
}
public string SendReferral(string JsonData)
{
return ReferralConnection.SendPostWithCredsInHeader("", JsonData);
}
}
}

View File

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.IO;
namespace PWAPPv2.Source.Config
{
public class Configuration
{
private Dictionary<string, string> values;
public Configuration(string file)
{
values = new Dictionary<string, string>();
if(!File.Exists(file))
{
throw new ConfigFileNotFoundException();
}
string f = File.ReadAllText(file);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(f);
XmlNodeList xmlNodeList = xmlDoc.DocumentElement.ChildNodes;
foreach (XmlNode xmlNode in xmlNodeList)
{
values.Add(xmlNode.Name, xmlNode.InnerText);
}
}
public string Get(string key)
{
try
{
return values[key];
}
catch
{
throw new ConfigValueNotFoundException();
}
}
}
public class ConfigFileNotFoundException : Exception { }
public class ConfigValueNotFoundException: Exception { }
}

View File

@ -20,6 +20,14 @@
APIid = config.PWApiID;
}
public APICredentials(Source.Config.Configuration practiceConfig)
{
UserID = practiceConfig.Get("pwuserid");
Password = practiceConfig.Get("pwpassword");
PracticeId = practiceConfig.Get("pwpracticeid");
APIid = practiceConfig.Get("pwapiid");
}
public string BuildJsonBodyContents()
{
return "'UserID':'" + UserID + "'," +

View File

@ -3,32 +3,59 @@
class Attachment
{
APICredentials Credentials;
PWImage image;
public PWImage image { get; set; }
public PWPdf pdf { get; set; }
public string Token;
string Token;
private string fileType { get; set; }
public Attachment(APICredentials credentials, PWImage pwImage, string token)
public Attachment(APICredentials credentials, PWImage pwImage)
{
Credentials = credentials;
image = pwImage;
Token = token;
//Token = token;
pdf = null;
fileType = "image/jpeg";
}
public Attachment(APICredentials credentials, PWPdf pwPdf)
{
Credentials = credentials;
pdf = pwPdf;
image = null;
fileType = "application/pdf";
}
public string ToJsonString()
{
return "\"{" + Credentials.BuildJsonBodyContents() +
",'UserNum':'API'," +
"'AttToken':'" + Token.Replace("\"", "") + "'," +
"'FileName':'" + image.ShortFileName() + "'," +
"'ContentType':'_1'," +
"'ThumbExists':'1'," +
"'ZoomExists':'1'," +
"'FileDate':''," +
"'Base64FileContents':'" + image.GetBase64String() + "',\n" +
"'Base64ThumbContents':'" + image.GetBase64ThumbString() + "',\n" +
"'Base64ZoomContents':'" + image.GetBase64ZoomString() + "'}\"";
if (fileType == "image/jpeg")
{
return "\"{" + Credentials.BuildJsonBodyContents() +
",'UserNum':'API'," +
"'AttToken':'" + Token.Replace("\"", "") + "'," +
"'FileName':'" + image.ShortFileName() + "'," +
"'ThumbExists':'1'," +
"'ZoomExists':'1'," +
"'FileDate':''," +
"'FileType':'" + fileType + "'," +
"'Base64FileContents':'" + image.GetBase64String() + "',\n" +
"'Base64ThumbContents':'" + image.GetBase64ThumbString() + "',\n" +
"'Base64ZoomContents':'" + image.GetBase64ZoomString() + "'}\"";
}
else
{
return "\"{" + Credentials.BuildJsonBodyContents() +
",'UserNum':'API'," +
"'AttToken':'" + Token.Replace("\"", "") + "'," +
"'FileName':'" + pdf.ShortFileName() + "'," +
"'ThumbExists':'0'," +
"'ZoomExists':'0'," +
"'FileDate':''," +
"'FileType':'" + fileType + "'," +
"'Base64FileContents':'" + pdf.GetBase64String() + "',\n" +
"'Base64ThumbContents':'',\n" +
"'Base64ZoomContents':''}\"";
}
}
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PWAPPv2.Source.DataObjects
{
public class PWPdf
{
public string path;
public PWPdf(string path)
{
this.path = path;
}
public string GetBase64String()
{
byte[] bytes = File.ReadAllBytes(path);
return Convert.ToBase64String(bytes);
}
public string ShortFileName()
{
return path.Substring(path.LastIndexOf("\\") + 1);
}
}
}

View File

@ -4,6 +4,9 @@ using System.Collections.Generic;
namespace PWAPPv2.Source.Database
{
/// <summary>
/// Class <c>DatabaseConnection</c> creates and maintains a connection to and OpenDental MySqlDatabase.
/// </summary>
class DatabaseConnection
{
@ -18,6 +21,12 @@ namespace PWAPPv2.Source.Database
Connection = new MySqlConnection(SqlString);
}
public DatabaseConnection(Config.Configuration config)
{
SqlString = "server=" + config.Get("ODhost") + ";Uid=" + config.Get("ODuser") + ";database=" + config.Get("ODdatabase") + ";Pwd=" + config.Get("ODpassword");
Connection = new MySqlConnection(SqlString);
}
public void Connect()
{
try

View File

@ -1,33 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Azure.Core" version="1.25.0" targetFramework="net472" />
<package id="Azure.Identity" version="1.7.0" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.9" targetFramework="net472" />
<package id="Azure.Core" version="1.37.0" targetFramework="net472" />
<package id="Azure.Identity" version="1.10.4" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi.Client" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net472" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net472" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net472" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net472" />
<package id="Microsoft.Data.SqlClient" version="5.1.1" targetFramework="net472" />
<package id="Microsoft.Data.SqlClient.SNI" version="5.1.0" targetFramework="net472" />
<package id="Microsoft.Identity.Client" version="4.47.2" targetFramework="net472" />
<package id="Microsoft.Identity.Client.Extensions.Msal" version="2.19.3" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Abstractions" version="6.24.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="6.24.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Logging" version="6.24.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Protocols" version="6.24.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Protocols.OpenIdConnect" version="6.24.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Tokens" version="6.24.0" targetFramework="net472" />
<package id="Microsoft.Data.SqlClient" version="5.1.4" targetFramework="net472" />
<package id="Microsoft.Data.SqlClient.SNI" version="5.1.1" targetFramework="net472" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="8.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="8.0.0" targetFramework="net472" />
<package id="Microsoft.Identity.Client" version="4.58.1" targetFramework="net472" />
<package id="Microsoft.Identity.Client.Extensions.Msal" version="4.58.1" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Abstractions" version="7.2.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="7.2.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Logging" version="7.2.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Protocols" version="7.2.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Protocols.OpenIdConnect" version="7.2.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Tokens" version="7.2.0" targetFramework="net472" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net472" />
<package id="MySqlConnector" version="2.2.7" targetFramework="net472" />
<package id="MySqlConnector" version="2.3.4" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
<package id="Newtonsoft.Json.Bson" version="1.0.2" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.Configuration.ConfigurationManager" version="6.0.1" targetFramework="net472" />
<package id="System.Diagnostics.DiagnosticSource" version="6.0.0" targetFramework="net472" />
<package id="System.IdentityModel.Tokens.Jwt" version="6.24.0" targetFramework="net472" />
<package id="System.Configuration.ConfigurationManager" version="8.0.0" targetFramework="net472" />
<package id="System.Diagnostics.DiagnosticSource" version="8.0.0" targetFramework="net472" />
<package id="System.IdentityModel.Tokens.Jwt" version="7.2.0" targetFramework="net472" />
<package id="System.IO" version="4.3.0" targetFramework="net472" />
<package id="System.IO.FileSystem.AccessControl" version="5.0.0" targetFramework="net472" />
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
<package id="System.Memory.Data" version="1.0.2" targetFramework="net472" />
<package id="System.Memory.Data" version="8.0.0" targetFramework="net472" />
<package id="System.Net.Http" version="4.3.4" targetFramework="net472" />
<package id="System.Net.Http.Json" version="7.0.1" targetFramework="net472" />
<package id="System.Net.Http.Json" version="8.0.0" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime" version="4.3.1" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
@ -36,13 +40,13 @@
<package id="System.Security.Cryptography.Algorithms" version="4.3.1" targetFramework="net472" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.ProtectedData" version="4.7.0" targetFramework="net472" />
<package id="System.Security.Cryptography.ProtectedData" version="8.0.0" targetFramework="net472" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.2" targetFramework="net472" />
<package id="System.Security.Permissions" version="6.0.0" targetFramework="net472" />
<package id="System.Security.Permissions" version="8.0.0" targetFramework="net472" />
<package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="net472" />
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net472" />
<package id="System.Text.Encodings.Web" version="7.0.0" targetFramework="net472" />
<package id="System.Text.Json" version="7.0.3" targetFramework="net472" />
<package id="System.Text.Encodings.Web" version="8.0.0" targetFramework="net472" />
<package id="System.Text.Json" version="8.0.1" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
</packages>

9
PWAppUpdater/App.xaml Normal file
View File

@ -0,0 +1,9 @@
<Application x:Class="PWAppUpdater.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:PWAppUpdater"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

17
PWAppUpdater/App.xaml.cs Normal file
View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace PWAppUpdater
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

View File

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

View File

@ -0,0 +1,45 @@
using System;
using System.IO;
using System.Net;
namespace PWAppUpdater.FTP
{
class FTPManager
{
private string BaseUri;
private NetworkCredential credential;
public FTPManager(string baseUri, string username, string password)
{
BaseUri = baseUri;
credential = new NetworkCredential(username, password);
}
public void DownloadFile(string FTPPath, string localPath)
{
try
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(BaseUri + FTPPath);
request.Method = WebRequestMethods.Ftp.DownloadFile;
request.Credentials = credential;
request.KeepAlive = false;
request.UseBinary = true;
request.UsePassive = true;
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
using (Stream s = File.Create(localPath))
{
responseStream.CopyTo(s);
}
response.Close();
}
catch (Exception e)
{
Console.WriteLine(e.Message.ToString());
}
}
}
}

View File

@ -0,0 +1,16 @@
<Window x:Class="PWAppUpdater.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:PWAppUpdater"
mc:Ignorable="d"
Title="PWUpdater" Height="137" Width="266">
<Grid Margin="0,0,0,-4">
<ProgressBar x:Name="barProgressBar" Minimum="0" Maximum="100" HorizontalAlignment="Center" Height="10" VerticalAlignment="Top" Width="246" Margin="0,46,0,0"/>
<Label x:Name="statusText" Content="Please wait while the application is updating." HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Label x:Name="txtUpdateStep" Content="{Binding Path=txtUpdateStep}" HorizontalAlignment="Left" Margin="10,31,0,0" VerticalAlignment="Top"/>
<Button x:Name="OKButton" Content="OK" HorizontalAlignment="Center" Margin="0,70,0,0" VerticalAlignment="Top" Click="Button_Click"/>
</Grid>
</Window>

View File

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace PWAppUpdater
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
statusText.Content = "The program will now be updated.\nPlease click \"OK\" to continue.";
}
private void Button_Click(object sender, RoutedEventArgs e)
{
OKButton.IsEnabled = false;
for(int i = 0; i < 100; i++)
{
barProgressBar.Value = i;
barProgressBar.UpdateLayout();
Thread.Sleep(100);
}
}
}
}

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<Folder Include="Config\" />
</ItemGroup>
</Project>

52
PWAppUpdater/Updater.cs Normal file
View File

@ -0,0 +1,52 @@
using PWAppUpdater.FTP;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace PWAppUpdater
{
class Updater
{
public static void Update(string installPath, string practiceConfigLocation = "", string tempPath = "")
{
try
{
if (tempPath == "")
{
tempPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
tempPath = Path.Combine(tempPath, "PWAPP\\Temp");
}
if (!Directory.Exists(tempPath))
{
Directory.CreateDirectory(tempPath);
}
FTP.FTPManager ftpManager = new FTPManager("ftp://waws-prod-blu-109.ftp.azurewebsites.windows.net/", "patientweb\\$patientweb", "vHBnkgxPDS4Q410eehaFlXb8DH67QW50m9Rsxf1omXyYWRDgYioWJL63Tagp");
ftpManager.DownloadFile("pwapp/current/Release.zip", tempPath);
if (Directory.Exists(installPath))
{
Directory.Delete(installPath, true);
}
Directory.CreateDirectory(installPath);
Zip.ZipManager.UnZip(tempPath, installPath, true);
}
catch (UnauthorizedAccessException)
{
MessageBox.Show("Updater does not have sufficent permissions to perform update. Please run with administrator privilages to continue.");
}
}
}
class CouldNotFindInstallPathException : Exception
{
}
}

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PWAppUpdater.Zip
{
class ZipManager
{
public static void UnZip(string source, string destination, bool Override)
{
if (Override)
{
if (Directory.Exists(destination))
{
Directory.Delete(destination, true);
}
}
ZipFile.ExtractToDirectory(source, destination);
}
}
}

View File

@ -0,0 +1,9 @@
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="highestAvailable" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View File

@ -0,0 +1,45 @@
using System;
using System.IO;
using System.Net;
namespace PWAppUpdater.FTP
{
class FTPManager
{
private string BaseUri;
private NetworkCredential credential;
public FTPManager(string baseUri, string username, string password)
{
BaseUri = baseUri;
credential = new NetworkCredential(username, password);
}
public void DownloadFile(string FTPPath, string localPath)
{
try
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(BaseUri + FTPPath);
request.Method = WebRequestMethods.Ftp.DownloadFile;
request.Credentials = credential;
request.KeepAlive = false;
request.UseBinary = true;
request.UsePassive = true;
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
using (Stream s = File.Create(localPath))
{
responseStream.CopyTo(s);
}
response.Close();
}
catch (Exception e)
{
Console.WriteLine(e.Message.ToString());
}
}
}
}

98
PWAppUpdater2/Form1.Designer.cs generated Normal file
View File

@ -0,0 +1,98 @@
namespace PWAppUpdater2
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
progressBar1 = new ProgressBar();
button1 = new Button();
label1 = new Label();
StepInfo = new Label();
SuspendLayout();
//
// progressBar1
//
progressBar1.Location = new Point(30, 60);
progressBar1.Name = "progressBar1";
progressBar1.Size = new Size(200, 10);
progressBar1.TabIndex = 0;
progressBar1.Click += progressBar1_Click;
//
// button1
//
button1.Location = new Point(105, 80);
button1.Name = "button1";
button1.Size = new Size(50, 23);
button1.TabIndex = 1;
button1.Text = "OK";
button1.UseVisualStyleBackColor = true;
button1.Click += button1_Click;
//
// label1
//
label1.AutoSize = true;
label1.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
label1.Location = new Point(12, 9);
label1.Name = "label1";
label1.Size = new Size(168, 30);
label1.TabIndex = 2;
label1.Text = "The program will now update. \r\nPlease click \"OK\" to continue.";
label1.Click += label1_Click;
//
// StepInfo
//
StepInfo.AutoSize = true;
StepInfo.Location = new Point(30, 42);
StepInfo.Name = "StepInfo";
StepInfo.Size = new Size(0, 15);
StepInfo.TabIndex = 3;
StepInfo.Click += label2_Click;
//
// Form1
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(264, 111);
Controls.Add(StepInfo);
Controls.Add(label1);
Controls.Add(button1);
Controls.Add(progressBar1);
Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
Name = "Form1";
Text = "Form1";
ResumeLayout(false);
PerformLayout();
}
#endregion
private ProgressBar progressBar1;
private Button button1;
private Label label1;
private Label StepInfo;
}
}

52
PWAppUpdater2/Form1.cs Normal file
View File

@ -0,0 +1,52 @@
using PWAppUpdater;
namespace PWAppUpdater2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void progressBar1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Directory.SetCurrentDirectory("C:\\PWAPP");
label1.Text = "Updating.... Please wait.";
label1.Update();
progressBar1.Maximum = 8;
progressBar1.Step = 1;
button1.Enabled = false;
try
{
PWAppUpdater.Updater.Update("C:\\PWAPP\\App", progressBar1, StepInfo, "C:\\PWAPP\\Temp");
}
catch (NoAuthException)
{
MessageBox.Show("Please run the updater with administrator privilages or from the PWApp Application.");
Application.Exit();
}
MessageBox.Show("Done!");
Application.Exit();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
}
}

120
PWAppUpdater2/Form1.resx Normal file
View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>

17
PWAppUpdater2/Program.cs Normal file
View File

@ -0,0 +1,17 @@
namespace PWAppUpdater2
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
}
}

73
PWAppUpdater2/Updater.cs Normal file
View File

@ -0,0 +1,73 @@
using PWAppUpdater.FTP;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace PWAppUpdater
{
class Updater
{
public static void Update(string installPath, ProgressBar progress, Label stepInfo, string tempPath = "")
{
try
{
progress.PerformStep();
stepInfo.Text = "Creating temp directories...";
stepInfo.Update();
if (tempPath == "")
{
tempPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
tempPath = Path.Combine(tempPath, "PWAPP\\Temp");
}
progress.PerformStep();
if (!Directory.Exists(tempPath))
{
Directory.CreateDirectory(tempPath);
}
progress.PerformStep();
stepInfo.Text = "Downloading update...";
stepInfo.Update();
FTP.FTPManager ftpManager = new FTPManager("ftp://waws-prod-blu-109.ftp.azurewebsites.windows.net/", "patientweb\\$patientweb", "vHBnkgxPDS4Q410eehaFlXb8DH67QW50m9Rsxf1omXyYWRDgYioWJL63Tagp");
ftpManager.DownloadFile("pwapp/current/Release.zip", tempPath + "\\Release.zip");
progress.PerformStep();
stepInfo.Text = "Removing old installation...";
stepInfo.Update();
progress.PerformStep();
stepInfo.Text = "Creating new install directory...";
stepInfo.Update();
Directory.CreateDirectory(installPath);
progress.PerformStep();
stepInfo.Text = "Unpacking update...";
stepInfo.Update();
Zip.ZipManager.UnZip(tempPath + "\\Release.zip", installPath, true);
progress.PerformStep();
stepInfo.Text = "Cleaning up installation...";
stepInfo.Update();
Directory.Delete(tempPath, true);
progress.PerformStep();
stepInfo.Text = "Complete!";
stepInfo.Update();
}
catch (UnauthorizedAccessException)
{
MessageBox.Show("Updater does not have sufficent permissions to perform update. Please run with administrator privilages to continue.");
throw new NoAuthException();
}
}
}
class NoAuthException : Exception { }
class CouldNotFindInstallPathException : Exception
{
}
}

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PWAppUpdater.Zip
{
class ZipManager
{
public static void UnZip(string source, string destination, bool Override)
{
if (Override)
{
if (Directory.Exists(destination))
{
Directory.Delete(destination, true);
}
}
ZipFile.ExtractToDirectory(source, destination);
}
}
}

21
UnitTests/ConfigTest.cs Normal file
View File

@ -0,0 +1,21 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using PWAPPv2.Source;
namespace UnitTests
{
[TestClass]
public class ConfigTest
{
[TestMethod]
public void TestGetPracticeConfigs()
{
PWAPPv2.Source.Config.Configuration configuration = new PWAPPv2.Source.Config.Configuration(".\\Config\\PracticeConfig.xml");
Assert.IsNotNull(configuration);
string apiKey = configuration.Get("pwapiid");
Assert.IsNotNull(apiKey);
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace UnitTests
{
[TestClass]
public class PWConnectionTest
{
[TestMethod]
public void TestCheckUpdate()
{
PWAPPv2.Source.Config.Configuration practiceConfig = new PWAPPv2.Source.Config.Configuration(".\\Config\\PracticeConfig.xml");
PWAPPv2.Source.Config.Configuration universalConfig = new PWAPPv2.Source.Config.Configuration(".\\Config\\UniversalConfig.xml");
PWAPPv2.Source.API.PWApiConnection pwApiConnection = new PWAPPv2.Source.API.PWApiConnection(practiceConfig, universalConfig);
Assert.IsNotNull(pwApiConnection);
Assert.IsFalse(pwApiConnection.CheckForUpdate());
}
}
}

View File

@ -25,5 +25,35 @@ namespace UnitTests
Assert.AreEqual("\"1|Endo|2|Implant|3|Oral Surgery|4|Ortho|5|Pedo|6|Perio|7|Restore|8|Other \\n\"", res);
}
[TestMethod]
public void TestV2Get()
{
APICredentials creds = new APICredentials();
creds.UserID = "testdoctor";
creds.Password = "testdoctor";
creds.PracticeId = "210";
creds.APIid = "12345678";
APIConnection conn = new APIConnection("https://localhost:44354/", creds);
string res = conn.SendPostWithCredsInHeader("api/PWAppVersion", "");
}
[TestMethod]
[ExpectedException(typeof(RequestFailedExcpetion))]
public void TestInvalidCredentialsV2()
{
APICredentials creds = new APICredentials();
creds.UserID = "testdoctor";
creds.Password = "badPassword";
creds.PracticeId = "210";
creds.APIid = "12345678";
APIConnection conn = new APIConnection("https://localhost:44354/", creds);
string res = conn.SendPostWithCredsInHeader("api/PWAppVersion", "");
}
}
}

View File

@ -51,16 +51,12 @@
<ItemGroup>
<Compile Include="UnitTest1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ConfigTest.cs" />
<Compile Include="PWConnectionTest.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PWAPPv2\PWAPPv2.csproj">
<Project>{45e26af8-41d7-4308-a2c8-d55a0350db47}</Project>
<Name>PWAPPv2</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">