Auto updater added
This commit is contained in:
+38
-20
@@ -1,10 +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.Forms;
|
||||
using System.Windows.Media;
|
||||
|
||||
/**
|
||||
* TODO:
|
||||
@@ -40,7 +40,10 @@ namespace PWAPPv2
|
||||
|
||||
List<Source.DataObjects.PWImage> images;
|
||||
|
||||
string ConfigPath = "C:\\PWAPP\\Config\\Config.xml";
|
||||
|
||||
//string ConfigPath = "C:\\PWAPP\\Config\\Config.xml";
|
||||
|
||||
string ConfigPath;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
@@ -53,7 +56,10 @@ namespace PWAPPv2
|
||||
|
||||
try
|
||||
{
|
||||
practiceConfig = new Source.Config.Configuration(".\\Config\\PracticeConfig.xml");
|
||||
ConfigPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
ConfigPath = Path.Combine(ConfigPath, "PWAPP\\Config\\");
|
||||
|
||||
practiceConfig = new Source.Config.Configuration(ConfigPath + "PracticeConfig.xml");
|
||||
universalConfig = new Source.Config.Configuration(".\\Config\\UniversalConfig.xml");
|
||||
}
|
||||
catch
|
||||
@@ -66,15 +72,28 @@ namespace PWAPPv2
|
||||
|
||||
try
|
||||
{
|
||||
if(pwapiConnection.CheckForUpdate() == true)
|
||||
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)
|
||||
if (result == System.Windows.Forms.DialogResult.Yes)
|
||||
{
|
||||
System.Windows.MessageBox.Show("HAHA NO UPDATE FOR YOU!");
|
||||
//System.Windows.MessageBox.Show("HAHA NO UPDATE FOR YOU!");
|
||||
Process p = new Process();
|
||||
p.StartInfo.FileName = "E:\\PatientWebAPI\\PWAPPv2\\PWAPPv2\\PWAppUpdater2\\bin\\Release\\net6.0-windows\\PWAppUpdaterForm.exe";
|
||||
p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
|
||||
p.StartInfo.UseShellExecute = false;
|
||||
p.StartInfo.RedirectStandardOutput = true;
|
||||
p.StartInfo.RedirectStandardError = true;
|
||||
p.StartInfo.Arguments = args[0];
|
||||
if(System.Environment.OSVersion.Version.Major >= 6)
|
||||
{
|
||||
p.StartInfo.Verb = "runas";
|
||||
}
|
||||
p.Start();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,11 +123,11 @@ namespace PWAPPv2
|
||||
|
||||
this.DataContext = new Source.PatientGUIAdapter(patient);
|
||||
}
|
||||
catch(NullReferenceException)
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Windows.MessageBox.Show(e.Message);
|
||||
}
|
||||
@@ -123,20 +142,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);
|
||||
}
|
||||
|
||||
@@ -205,7 +225,7 @@ namespace PWAPPv2
|
||||
try
|
||||
{
|
||||
string referralString = referral.ToJsonString();
|
||||
string result = apiConnection.SendPostRequestAsync("api/PWMakeReferral", referralString);
|
||||
string result = pwapiConnection.SendReferral(referralString); //apiConnection.SendPostRequestAsync("api/PWMakeReferral", referralString);
|
||||
if (images.Count > 0)
|
||||
{
|
||||
foreach (Source.DataObjects.PWImage im in images)
|
||||
@@ -214,12 +234,10 @@ namespace PWAPPv2
|
||||
string json = att.ToJsonString();
|
||||
apiConnection.SendPostRequestAsync("api/PWAttachment", json);
|
||||
}
|
||||
System.Windows.MessageBox.Show("Referral added successfully!");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Windows.MessageBox.Show(result);
|
||||
}
|
||||
|
||||
System.Windows.MessageBox.Show("Referral added successfully!");
|
||||
|
||||
this.Close();
|
||||
}
|
||||
catch (Source.DataObjects.Referral.InvalidReferalDataException)
|
||||
@@ -236,7 +254,7 @@ namespace PWAPPv2
|
||||
openFileDialog.Filter = "Image files (*.jpg,*.jpeg)|*.jpg;*.jpeg";
|
||||
openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
|
||||
|
||||
if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
foreach (string filename in openFileDialog.FileNames)
|
||||
{
|
||||
|
||||
@@ -100,6 +100,7 @@ namespace PWAPPv2.Source.API
|
||||
Client.DefaultRequestHeaders.Add("ApiID", Credentials.APIid);
|
||||
|
||||
StringContent content = new StringContent(PostData, Encoding.UTF8, "application/json");
|
||||
string conts = content.ToString();
|
||||
|
||||
var response = Client.PostAsync(apiUri, content).Result;
|
||||
|
||||
|
||||
@@ -12,6 +12,12 @@ namespace PWAPPv2.Source.API
|
||||
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;
|
||||
|
||||
@@ -20,6 +26,11 @@ namespace PWAPPv2.Source.API
|
||||
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");
|
||||
|
||||
@@ -46,5 +57,25 @@ namespace PWAPPv2.Source.API
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user