Good day.
We are creating a Control System sales in school cafeterias in C # with WPF and this system will be implemented in 18 schools in our network. ( Schools are scattered throughout the city and , therefore, the system updates will be made automatically by the Internet ) .
Researched ClickOnce ( got to develop something like that ) and we understand that this type of update is not feasible .
We created a system update using DotNetZip API but errors occurred saving file in the directory where the system files as incompatibility among other problems was installed .
My question is as follows :
Does anyone have any experience in this matter that could share with me , or any example of situation ( like it is) so we can apply here in our system ?
I'll put here the snippet of code that updates the system to create , analyze it if anyone wants it , it will be easier to understand the problem .
The logic of this code search an XML file available system version and compares it with the version of the assembly . If the version is higher, then down to a temp directory update files and transfer to the directory where the application was installed . The problem that occurs is that some types of files appear as if they are running even after they have been finalized with the main application .
I appreciate the help .
Main form that calls the updater
private void Window_Loaded(object sender, RoutedEventArgs e)
{
var doc = new XmlDocument();
doc.Load("http://www.meusite.org.br/Cantina/arquivoXML.xml");
if (doc.DocumentElement != null)
{
var node = doc.DocumentElement.SelectSingleNode("/Application/Version");
var node1 = doc.DocumentElement.SelectSingleNode("/Application/ZipFile");
if (node != null)
{
var version = node.InnerText;
var versionAssembly = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
if (Convert.ToDouble(version) > Convert.ToDouble(versionAssembly))
{
Process.Start("Updater.exe");
}
}
}
}
Updater system:
using System.Diagnostics;
using Ionic.Zip;
using System.Xml;
using System.IO;
namespace Updater
{
public class Program
{
private static void Main()
{
Process[] process = Process.GetProcessesByName("IASD.ASCS.WPF");
foreach (Process proc in process)
{
if (!proc.HasExited)
proc.Kill();
}
XmlDocument doc = new XmlDocument();
doc.Load("http://www.meusite.org.br/Cantina/arquivoXML.xml");
if (doc.DocumentElement != null)
{
XmlNode node1 = doc.DocumentElement.SelectSingleNode("/Application/ZipFile");
if (node1 != null)
{
string zipfile = node1.InnerText;
const string end = ("http://www.meusite.org.br/Cantina/");
string file = (end + zipfile);
ZipFile zipFile = ZipFile.Read(file);
{
foreach (var zipEntry in zipFile)
{
zipEntry.Extract(@"c:\IASD\CantinaEscolar\Temp",ExtractExistingFileAction.OverwriteSilently);
}
}
string dirTemp = @"c:\IASD\CantinaEscolar\Temp";
string dirInstalacao = @"c:\IASD\CantinaEscolar\";
string[] arquivos = Directory.GetFiles(dirTemp);
foreach (string item in arquivos)
{
string nomedoarquivo = Path.GetFileName(item);
if (nomedoarquivo != null)
{
string destino = Path.Combine(dirInstalacao, nomedoarquivo);
File.Copy(item, destino, true);
}
}
string[] arquivosApagar = Directory.GetFiles(dirTemp);
foreach (string item in arquivosApagar)
{
File.Delete(item);
}
Process.Start("IASD.ASCS.WPF.exe");
}
}
const string nomeExecutavel2 = "Updater.exe";
foreach (Process pr2 in Process.GetProcessesByName(nomeExecutavel2))
{
if (!pr2.HasExited) pr2.Kill();
}
}
}
}
In this example I am determining which location the system will be installed but will I need to provide the user installs in any directory on your computer (which is another problem that I could not work around).