public void addStatusTextBoxLine(string msg) { mw.Dispatcher.BeginInvoke(new Action(() => mw.addStatusTextBoxLine(msg))); }
}////////////////////////////////////////////////////////// public void updateProcess() { //string _serverUpdateFilesFolder = AppConfs.updateFilesFolder; //ConfigurationManager.AppSettings["UpdateFilesFolder"].ToString(); //string _finalFolder = AppConfs.eVentasAppFolder; // ConfigurationManager.AppSettings["AppFolder"].ToString(); //string appDataFolder = AppConfs.eVentasAppFolder; // ConfigurationManager.AppSettings["AppFolder"].ToString(); //string _tmpFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\eVentas\appupp\"; /* * Se mata al proceso eVentasWPF.exe */ try { this.addStatusTextBoxLine("-Verificando estado el proceso de Elara..."); Process p = new Process(); p.StartInfo = new ProcessStartInfo(); p.StartInfo.UseShellExecute = true; p.StartInfo.FileName = "taskkill.exe"; p.StartInfo.Arguments = "/F /IM " + AppConfs.ProcessName; p.Start(); p.WaitForExit(); this.addStatusTextBoxLine("\tVerificado completo."); } catch (Exception ex) { this.addStatusTextBoxLine("\tVerificado completo. " + ex.Message); } new Thread(delegate() { MainWindow mW = this; string[] arr; //string serverUpdateFilesFolder = _serverUpdateFilesFolder; //string finalFolder = _finalFolder; //string tmpFolder = _tmpFolder; try { bool errorProcess = false; //UI update mW.Dispatcher.BeginInvoke(new Action(() => mW.addStatusTextBoxLine("- Inicia proceso de actualización..."))); mW.Dispatcher.BeginInvoke(new Action(() => mW.addStatusTextBoxLine("\tPor favor espere... "))); UpdateProc up = new UpdateProc(mW); /* * Se inicia el proceso de actualización */ string fin = ""; try { up.updateProcStart(); //fin = "- El proceso de actualización ha finalizado. "; } catch (Exception ex) { mW.Dispatcher.BeginInvoke(new Action(() => mW.addStatusTextBoxLine("***\nNO SE HA PODIDO ACTUALIZAR\nValide:" + "\n1. Conexión estable a la red de Elara" + "\n2. Permisos de su usuario en la carpeta compartida \ny vuelva a intentar."))); upFail = true; return; } mW.Dispatcher.BeginInvoke(new Action(() => mW.addProgressValue())); mW.Dispatcher.BeginInvoke(new Action(() => mW.addStatusTextBoxLine("\n" + fin + "- Haga clic en Terminar para salir de éste actualizador..."))); mW.Dispatcher.BeginInvoke(new Action(() => mW.disableCancelButton())); mW.Dispatcher.BeginInvoke(new Action(() => mW.enableButton())); } catch (Exception ex) { mW.Dispatcher.BeginInvoke(new Action(() => mW.addStatusTextBoxLine("*** La actualización no ha podido ser concluida. " + ex.Message.ToString()))); mW.Dispatcher.BeginInvoke(new Action(() => mW.disableCancelButton())); mW.Dispatcher.BeginInvoke(new Action(() => mW.enableButton())); upFail = true; return; } }).Start(); }//////////////////////////////////////////////////////////