public ActionResult GetApplicationVersionInfo() { Assembly assembly = this.GetType().GetTypeInfo().Assembly; DateTime creationTime = System.IO.File.GetLastWriteTimeUtc(assembly.Location); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); var versionNumbers = fvi.FileVersion.Split('.'); string minorNums = versionNumbers[2]; string fileVersion = $"{Configuration.GetReleaseVersion()}{minorNums}"; ApplicationVersionInfo avi = new ApplicationVersionInfo() { BaseUri = Configuration["BASE_URI"], BasePath = Configuration["BASE_PATH"], Environment = Configuration.GetEnvironmentName(), SourceCommit = Configuration["OPENSHIFT_BUILD_COMMIT"], SourceRepository = Configuration["OPENSHIFT_BUILD_SOURCE"], SourceReference = Configuration["OPENSHIFT_BUILD_REFERENCE"], FileCreationTime = creationTime.ToString("O"), // Use the round trip format as it includes the time zone. FileVersion = fileVersion, ReleaseVersion = Configuration.GetReleaseVersion(), }; return(Json(avi)); }
public ActionResult GetApplicationVersionInfo() { Assembly assembly = this.GetType().GetTypeInfo().Assembly; DateTime creationTime = System.IO.File.GetLastWriteTimeUtc(assembly.Location); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); string fileVersion = fvi.FileVersion; ApplicationVersionInfo avi = new ApplicationVersionInfo() { BaseUri = Configuration["BASE_URI"], BasePath = Configuration["BASE_PATH"], Environment = Configuration["ASPNETCORE_ENVIRONMENT"], SourceCommit = Configuration["OPENSHIFT_BUILD_COMMIT"], SourceRepository = Configuration["OPENSHIFT_BUILD_SOURCE"], SourceReference = Configuration["OPENSHIFT_BUILD_REFERENCE"], FileCreationTime = creationTime.ToString("O"), // Use the round trip format as it includes the time zone. FileVersion = fileVersion }; return(Json(avi)); }
public ActionResult GetApplicationVersionInfo() { var assembly = GetType().GetTypeInfo().Assembly; var creationTime = System.IO.File.GetLastWriteTimeUtc(assembly.Location); var fvi = FileVersionInfo.GetVersionInfo(assembly.Location); string fileVersion = fvi.FileVersion; var avi = new ApplicationVersionInfo { BaseUri = Configuration["BASE_URI"], BasePath = Configuration["BASE_PATH"], Environment = Configuration["ASPNETCORE_ENVIRONMENT"], SourceCommit = Configuration["OPENSHIFT_BUILD_COMMIT"], SourceRepository = Configuration["OPENSHIFT_BUILD_SOURCE"], SourceReference = Configuration["OPENSHIFT_BUILD_REFERENCE"], FileCreationTime = creationTime.ToString("O"), // Use the round trip format as it includes the time zone. FileVersion = fileVersion }; _logger.LogInformation("Displaying application version information: {@VersionInformation}", avi); return(new JsonResult(avi)); }
private void btnUpdate_Click(object sender, EventArgs e) { //get fiel from web lbStatus.Text = "Download config."; using (WebClient wc = new WebClient()) { wc.DownloadProgressChanged += wc_DownloadProgressChanged; wc.DownloadFileAsync(new System.Uri(urlFileConfig), outFileConfig ); } lbStatus.Text += "\nCheck current version"; List< ApplicationVersionInfo> list = new List<ApplicationVersionInfo>(); try { XmlDocument doc = new XmlDocument(); doc.Load(outFileConfig); //read struct data XmlNodeList root = doc.SelectNodes("/listVersion/version"); //read version foreach (XmlNode version in root) { ApplicationVersionInfo data = new ApplicationVersionInfo(); data.id = version.SelectSingleNode("id").InnerText; data.date = version.SelectSingleNode("date").InnerText; data.readme = version.SelectSingleNode("readme").InnerText; foreach (XmlNode files in version.SelectNodes("files")) { data.file.Add(new urlFile( files.SelectSingleNode("file").SelectSingleNode("in").InnerText, files.SelectSingleNode("file").SelectSingleNode("out").InnerText )); } list.Add(data); } lbStatus.Text += "\nDelete config"; System.IO.File.Delete(outFileConfig); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (list.Count > 0) { //max version (id) ApplicationVersionInfo versionMax = list[0]; if (list.Count > 1) for (int i = 1; i < list.Count; i++) { if (list[i].id.CompareTo(versionMax.id) > 0) { versionMax = new ApplicationVersionInfo(list[i]); } } //check current version if (versionMax.id.CompareTo(appVersion) <= 0) { lbStatus.Text += "\n\nit is current version"; } else { bool exe = false; //download file lbStatus.Text += "\nDownload file app..."; txtReadme.Text = versionMax.readme; foreach (urlFile url in versionMax.file) { if (url.outFile.Contains(".exe")) { exe = true; } lbStatus.Text += "\n File: "+ url.outFile; using (WebClient wc = new WebClient()) { wc.DownloadProgressChanged += wc_DownloadProgressChanged; wc.DownloadFileAsync(new System.Uri(url.inFile), Application.StartupPath + @"\"+url.outFile ); } } if (exe) Application.Restart(); } } else lbStatus.Text += "\n\nversion not found"; }
public static void Main(string[] args) { UnhandledExceptionHandler unhandledExceptionHandler = new UnhandledExceptionHandler(); try { WindowStartupFix.WindowsCheck(); Application.Init(); QSMain.GuiThread = System.Threading.Thread.CurrentThread; GtkGuiDispatcher.GuiThread = System.Threading.Thread.CurrentThread; var builder = new ContainerBuilder(); AutofacStartupConfig(builder); startupContainer = builder.Build(); unhandledExceptionHandler.UpdateDependencies(startupContainer); unhandledExceptionHandler.SubscribeToUnhandledExceptions(); } catch (MissingMethodException ex) when(ex.Message.Contains("System.String System.String.Format")) { WindowStartupFix.DisplayWindowsOkMessage("Версия .Net Framework должна быть не ниже 4.6.1. Установите более новую платформу.", "Старая версия .Net"); return; } catch (Exception fallEx) { if (WindowStartupFix.IsWindows) { WindowStartupFix.DisplayWindowsOkMessage(fallEx.ToString(), "Критическая ошибка"); } else { Console.WriteLine(fallEx); } logger.Fatal(fallEx); return; } ILifetimeScope scopeLoginTime = startupContainer.BeginLifetimeScope(); // Создаем окно входа Login LoginDialog = new Login(); LoginDialog.Logo = Gdk.Pixbuf.LoadFromResource("workwear.icon.logo.png"); LoginDialog.SetDefaultNames("workwear"); LoginDialog.DefaultLogin = "******"; LoginDialog.DefaultServer = "demo.qsolution.ru"; LoginDialog.DefaultConnection = "Демонстрационная база"; Login.ApplicationDemoServer = "demo.qsolution.ru"; LoginDialog.DemoMessage = "Для подключения к демонстрационному серверу используйте следующие настройки:\n" + "\n" + "<b>Сервер:</b> demo.qsolution.ru\n" + "<b>Пользователь:</b> demo\n" + "<b>Пароль:</b> demo\n" + "\n" + "Для установки собственного сервера обратитесь к документации."; Login.CreateDBHelpTooltip = "Инструкция по установке сервера MySQL"; Login.CreateDBHelpUrl = "http://doc.qsolution.ru/workwear/" + new ApplicationVersionInfo().Version.ToString(2) + "/install.html#InstallDBServer"; LoginDialog.GetDBCreator = scopeLoginTime.Resolve <IDBCreator>; LoginDialog.UpdateFromGConf(); ResponseType LoginResult; LoginResult = (ResponseType)LoginDialog.Run(); if (LoginResult == ResponseType.DeleteEvent || LoginResult == ResponseType.Cancel) { return; } LoginDialog.Destroy(); scopeLoginTime.Dispose(); QSSaaS.Session.StartSessionRefresh(); //Прописываем системную валюту CurrencyWorks.CurrencyShortFomat = "{0:C}"; CurrencyWorks.CurrencyShortName = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol; CreateBaseConfig(); //Настройка базы AppDIContainer = startupContainer.BeginLifetimeScope(AutofacClassConfig); //Создаем постоянный контейнер unhandledExceptionHandler.UpdateDependencies(AppDIContainer); //Настройка удаления Configure.ConfigureDeletion(); #if !DEBUG //Инициализируем телеметрию var applicationInfo = new ApplicationVersionInfo(); MainTelemetry.Product = applicationInfo.ProductName; MainTelemetry.Edition = applicationInfo.Modification; MainTelemetry.Version = applicationInfo.Version.ToString(); MainTelemetry.IsDemo = Login.ApplicationDemoServer == QSMain.connectionDB.DataSource; var appConfig = QSMachineConfig.MachineConfig.ConfigSource.Configs["Application"]; if (appConfig != null) { MainTelemetry.DoNotTrack = appConfig.GetBoolean("DoNotTrack", false); } MainTelemetry.StartUpdateByTimer(600); #else MainTelemetry.DoNotTrack = true; #endif //Запускаем программу MainWin = new MainWindow(); MainWin.Title += string.Format(" (БД: {0})", LoginDialog.SelectedConnection); if (QSMain.User.Login == "root") { return; } MainWin.Show(); Application.Run(); if (!MainTelemetry.SendingError) { MainTelemetry.SendTimeout = TimeSpan.FromSeconds(2); MainTelemetry.SendTelemetry(); } QSSaaS.Session.StopSessionRefresh(); AppDIContainer.Dispose(); startupContainer.Dispose(); }