public void RestoreDatabaseDump() { try { if (Settings.Default.UseMongoServer) { ElvaSettings.getInstance().RestorData(); Thread.Sleep(10000); } } catch (Exception s) { SetError(s.Message); } //var result = DataHelpers.ShowMessage("Voulez-vous installer les données initiales (Configuration, Taxes, Paramétres achats & ventes...etc)", "Demo Data", MessageBoxButton.YesNo, MessageBoxImage.Question); //if (result == MessageBoxResult.Yes) //{ // ElvaSettings.getInstance().RestorData(); //} //else //{ // // Comptes // FrameworkManager.SetupAccounts(); //} }
public void Print() { var file = DoCreate(false, "WORD"); var verb = "Printto"; if (string.IsNullOrEmpty(file)) { return; } var defaultPrinter = ElvaSettings.getInstance().ImprimanteDefault; if (string.IsNullOrEmpty(defaultPrinter)) { DataHelpers.ShowMessage(_("Aucune imprimante par default, modifier les paramétres")); verb = "Print"; } try { ProcessStartInfo info = new ProcessStartInfo(file); info.Arguments = "\"" + defaultPrinter + "\""; info.Verb = verb; info.CreateNoWindow = true; info.WindowStyle = ProcessWindowStyle.Hidden; Process.Start(info); } catch (Exception s) { DataHelpers.ShowMessage(s.Message); } try { this.RequestClose(); } catch { } }
public void PrintReport() { var posPrinter = ElvaSettings.getInstance().ImprimanteDefault; if (string.IsNullOrEmpty(posPrinter)) { DataHelpers.ShowMessage("Imprimante introuvable, vérifier les paramétres"); return; } File.WriteAllText("report.txt", $"{this.Report.ReportName}\n"); using (var file = new StreamWriter("report.txt", true)) { var typeRepor = DataHelpers.ShowMessage("Inclure les quantités vendues", "Type rapport", MessageBoxButton.YesNo, MessageBoxImage.Question); if (typeRepor == MessageBoxResult.Yes) { lines = Report.GetReport().SelectMany(z => z.Children); } else { lines = Report.GetReport().Where(z => !z.CL1.Contains("Détails")).SelectMany(z => z.Children); } foreach (var item in lines) { file.WriteLine($"{item.CL1}\n{item.CL2} {item.CL3}\n___________________"); } file.Close(); Process p = null; try { p = new Process(); p.StartInfo.FileName = Path.GetFullPath("report.txt"); var verbs = p.StartInfo.Verbs; foreach (var v in verbs) { Console.WriteLine(v); } p.StartInfo.Verb = "Print"; p.StartInfo.Arguments = "\"" + posPrinter + "\""; p.StartInfo.Verb = "Printto"; p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; p.StartInfo.UseShellExecute = true; p.Start(); p.WaitForExit(); } catch (Exception e) { DataHelpers.ShowMessage(e.Message); } } }
private void LoadSettingsInDatahelpers() { try { var setting = ElvaSettings.getInstance(); DataHelpers.Settings = setting; DataHelpers.NotAllowedProperties = typeof(ModelBase <>).GetProperties().Select(z => z.Name).ToList(); DataHelpers.NotAllowedProperties = typeof(Document).GetProperties().Select(z => z.Name).ToList(); } catch (Exception s) { SetError(s.Message); } }
public void SetDefaultCultureOnThread() { try { setting = ElvaSettings.getInstance(); if (!string.IsNullOrWhiteSpace(setting?.Pays)) { ElvaSettings.SetGlobalCulture(setting?.Pays); } } catch (Exception s) { SetError(s.Message); } }
public void Save() { try { Validate(); var settings = ElvaSettings.getInstance(); //settings.LangeDefault = SelectedLang; settings.Pays = SelectedLang?.Name;// CultureInfo.CurrentCulture?.Name; settings.Save(); RequestClose(true); } catch (Exception s) { DataHelpers.ShowMessageError(s); return; } }
public void ActivateDemo() { if (string.IsNullOrWhiteSpace(clePublic)) { DataHelpers.ShowMessage("Clé public obligatoire!"); return; } using (var publicK = new StreamWriter("public-lcs")) { publicK.Write(clePublic); publicK.Close(); } var used = ElvaSettings.getInstance().DemoUsed; if (false) { DataHelpers.ShowMessage("Licence demo expirée, Contactez votre fournisseur/ 0665 97 76 79 / [email protected]"); return; } else { FrameworkManager.CreateLicenceTrial(userName, email); try { if (FrameworkManager.ValidateLicence(clePublic, userName, email)) { DataHelpers.ShowMessage("Licence validée"); IsValide = true; this.RequestClose(); } else { DataHelpers.ShowMessage("Licence invalide"); IsValide = false; } } catch (Exception s) { DataHelpers.ShowMessage(s.Message); } } }
public void CheckDefaultLang() { var setting = ElvaSettings.getInstance(); if (string.IsNullOrWhiteSpace(setting?.Pays)) { Execute.OnUIThreadSync(() => { try { var langChoose = new LangViewModel(); RestartAtFinish = DataHelpers.windowManager.ShowDialog(langChoose); } catch (Exception s) { DataHelpers.ShowMessageError(s); return; } }); } }
private void Worker_DoWork(object sender, DoWorkEventArgs e) { DoCheckApplicationFolders(); SetNote("startup.label.loadingdb"); StartServerDatabase(); Worker.ReportProgress(10); // SetNote("startup.label.checkingdb"); //if( EnsureServerIsRunning() == false) // { // SetError("Server Off!"); // return; // } SetNote("startup.label.loadingmodule"); LoadModulesDll(); Worker.ReportProgress(20); SetNote("startup.label.logging"); StartLogger(); SetNote("startup.label.data"); LoadTypesToDatahelper(); SetNote("startup.label.initdb"); InstallDefaultDatabase(); Worker.ReportProgress(30); SetNote("startup.label.cultures"); SetDefaultCultureOnThread(); Worker.ReportProgress(40); SetNote("startup.label.lang"); CheckDefaultLang(); Worker.ReportProgress(55); SetNote("startup.label.checkmodules"); ReloadAllModules(); var setting = ElvaSettings.getInstance(); if (setting.IsRestheatUsed) { StartServerApi(); } if (setting.AppInitialized == false) { Mode = StartupMode.ALL; } else { Mode = StartupMode.LAUNCH; } if (Mode == StartupMode.ALL) { SetNote("startup.label.init"); RestoreDatabaseDump(); Worker.ReportProgress(50); SetNote("startup.label.data"); FrameworkManager.UpdateModules(); Worker.ReportProgress(60); SetNote("startup.label.series"); InitSeries(); Worker.ReportProgress(70); // SetNote("Lancement assistant"); //Execute.PostToUIThread(() => OpenAppAssistant()); // Worker.ReportProgress(80); //Execute.OnUIThread(() => { _windowManager.ShowMessageBox("Vous devez relancer l'application aprés cette configuration"); }); } else { SetNote("startup.label.lang"); SetDefaultLang(); Worker.ReportProgress(50); } Worker.ReportProgress(60); SetNote("startup.label.checkadmin"); InstallDefaultUser(); SetNote("startup.label.data"); ReloadAllModules(); Worker.ReportProgress(60); SetNote("startup.label.temp"); CleanTempFiles(); Worker.ReportProgress(70); SetNote("startup.label.loadingmodule"); CheckForNewModules(); Worker.ReportProgress(80); LoadSettingsInDatahelpers(); Worker.ReportProgress(90); SetNote("startup.label.updates"); CheckForUpdates(); Worker.ReportProgress(95); }
public void InstallDefaultDatabase() { try { // Prepare database var adr = Properties.Settings.Default.MongoServerSettings; var db = Properties.Settings.Default.dbUrl; bool addDefault = false; DbSourceLink DefaultDbSource = new DbSourceLink(); // CHeck if DefaultDB exist var dblinks = DS.db.GetAll <DbSourceLink>(a => true) as IEnumerable <DbSourceLink>; if (dblinks != null) { if (!dblinks.Select(a => a.DbName).Contains("Default")) { DefaultDbSource = new DbSourceLink(); DefaultDbSource.DbName = "Default"; DefaultDbSource.SourceIp = adr; addDefault = true; } } setting = ElvaSettings.getInstance(); if (setting != null) { if (addDefault) { DefaultDbSource.Save(); } if (setting.DbSourceLink.IsValide()) { // i have db set var DbSource = DS.db.GetOne <DbSourceLink>(a => a.Id == setting.DbSourceLink) as DbSourceLink; if (DbSource != null) { Properties.Settings.Default.MongoServerSettings = DbSource.SourceIp; Properties.Settings.Default.dbUrl = DbSource.DbName; DataHelpers.DbAdresse = DbSource.SourceIp; DataHelpers.DbName = DbSource.DbName; DS._db = null; } else { SetDefaultDB(); } } else { SetDefaultDB(); } } else { SetDefaultDB(); } } catch (Exception s) { SetError(s.Message); Console.Write(s.Message); SetDefaultDB(); } }
public void OpenSettings() { var settings = ElvaSettings.getInstance(); DataHelpers.Shell.OpenScreenAttach(settings, _("home.app.btn.settings")); }