static void SetEnvVersion(Session session) { if (session["EnvVersion"].IsEmpty()) { session["EnvVersion"] = AppSearch.IniFileValue(Environment.ExpandEnvironmentVariables(@"%windir%\win.ini"), "System", "Version") ?? "<unknown>"; } }
static void CheckCompatibility(SetupEventArgs e) { if (e.IsInstalling) { var conflictingProductCode = "{1D6432B4-E24D-405E-A4AB-D7E6D088C111}"; if (AppSearch.IsProductInstalled(conflictingProductCode)) { string msg = "Installed '{0}' is incompatible with this product.\n" + "Setup will be aborted." .FormatWith(AppSearch.GetProductName(conflictingProductCode) ?? conflictingProductCode); MessageBox.Show(msg, "Setup"); e.Result = ActionResult.UserExit; } } }
static void CheckCompatibility(SetupEventArgs e) { //MessageBox.Show("Hello World! (CLR: v" + Environment.Version + ")", "Embedded Managed UI (" + ((IntPtr.Size == 8) ? "x64" : "x86") + ")"); if (e.IsInstalling) { var conflictingProductCode = "{1D6432B4-E24D-405E-A4AB-D7E6D088C111}"; if (AppSearch.IsProductInstalled(conflictingProductCode)) { string msg = string.Format("Installed '{0}' is incompatible with this product.\n" + "Setup will be aborted.", AppSearch.GetProductName(conflictingProductCode) ?? conflictingProductCode); MessageBox.Show(msg, "Setup"); e.Result = ActionResult.UserExit; } } }
[Fact] //xUnit/VSTest runtime doesn't play nice with MSI interop when debugging public void AppSearchTest() { var keyExist = AppSearch.RegKeyExists(Registry.LocalMachine, @"System\CurrentControlSet\services"); var fakeKeyExist = AppSearch.RegKeyExists(Registry.LocalMachine, "TTTT"); var regValue = AppSearch.GetRegValue(Registry.ClassesRoot, ".txt", null); var code = AppSearch.GetProductCode("Windows Live Photo Common"); var name = AppSearch.GetProductName("{1D6432B4-E24D-405E-A4AB-D7E6D088CBC9}"); var installed = AppSearch.IsProductInstalled("{1D6432B4-E24D-405E-A4AB-D7E6D088CBC9}"); var products = AppSearch.GetProducts(); Assert.True(keyExist); Assert.False(fakeKeyExist); Assert.Equal("txtfile", regValue); Assert.Equal("{1D6432B4-E24D-405E-A4AB-D7E6D088CBC9}", code.FirstOrDefault()); Assert.Equal("Windows Live Photo Common", name); Assert.True(installed); //may fail on some machines Assert.True(products.Any()); }
private static void WebAdmin_Project_BeforeInstall(SetupEventArgs e) { string backupConfigPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "Web.config"); Version installedVersion = AppSearch.GetProductVersionFromUpgradeCode(e.UpgradeCode); if (installedVersion != null && e.IsModifying && !e.IsUninstalling) { try { string configPath = $"{e.Session["INSTALLDIR"]}Web.config"; System.IO.File.Copy(configPath, backupConfigPath); } catch (Exception ex) { e.Session.Log($"ERROR : {ex.Message}"); } } else if (e.IsUpgrading && System.IO.File.Exists(backupConfigPath)) { e.Session.Log($"Load {backupConfigPath}"); var doc = XDocument.Load(backupConfigPath); var elt = doc.Root.Element("connectionStrings").Elements("add").Single(x => x.Attribute("name").Value == "KsmedEntities"); e.Session["DATASOURCE"] = elt.Attribute("connectionString").Value.Split(';') .Single(_ => _.StartsWith("Data Source")).Split('=')[1]; elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "ApiServerUri"); e.Session["API_LOCATION"] = elt.Attribute("value").Value; elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "FileServerUri"); e.Session["FILESERVER_LOCATION"] = elt.Attribute("value").Value; System.IO.File.Delete(backupConfigPath); } }
public async Task <IActionResult> OnPostDataAsync(int page, int rows, AppSearch where) { var data = await _service.GetListAsync(page, rows, where, null); return(PagerData(data.items, page, rows, data.count)); }
static void project_BeforeInstall(SetupEventArgs e) { MessageBox.Show(e.ToString(), "BeforeInstall " + AppSearch.GetProductVersionFromUpgradeCode(e.UpgradeCode)); }
private static void Project_BeforeInstall(SetupEventArgs e) { string backupConfigPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "KL².exe.config"); Version installedVersion = AppSearch.GetProductVersionFromUpgradeCode(e.UpgradeCode); e.Session.Log($"Installed version : {installedVersion}"); if (installedVersion != null && e.IsModifying && !e.IsUninstalling) { try { string configPath = $"{e.Session["INSTALLDIR"]}KL².exe.config"; e.Session.Log($"Load {configPath}"); var doc = XDocument.Load(configPath); e.Session.Log($"Get API_LOCATION"); var elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "ApiServerUri"); e.Session.Log($"API_LOCATION : {elt.Attribute("value").Value}"); e.Session.Log($"Get FILESERVER_LOCATION"); elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "FileServerUri"); e.Session.Log($"FILESERVER_LOCATION : {elt.Attribute("value").Value}"); e.Session.Log($"Get SYNCPATH"); elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SyncPath"); e.Session.Log($"SYNCPATH : {elt.Attribute("value").Value}"); e.Session.Log($"Get SENDREPORT"); elt = doc.Root.Element("userSettings").Element("KProcess.Ksmed.Presentation.Shell.Settings").Elements("setting").Single(x => x.Attribute("name").Value == "SendReport"); e.Session.Log($"SENDREPORT : {(elt.Element("value").Value == "True" ? "yes" : "no")}"); e.Session.Log($"Get MUTE"); elt = doc.Root.Element("userSettings").Element("KProcess.Ksmed.Presentation.Shell.Settings").Elements("setting").Single(x => x.Attribute("name").Value == "Mute"); e.Session.Log($"MUTE : {(elt.Element("value").Value == "True" ? "yes" : "no")}"); System.IO.File.Copy(configPath, backupConfigPath); } catch (Exception ex) { e.Session.Log($"ERROR : {ex.Message}"); } } else if (e.IsUpgrading && System.IO.File.Exists(backupConfigPath)) { e.Session.Log($"Load {backupConfigPath}"); var doc = XDocument.Load(backupConfigPath); e.Session.Log($"Get API_LOCATION"); var elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "ApiServerUri"); e.Session["API_LOCATION"] = elt.Attribute("value").Value; e.Session.Log($"API_LOCATION : {e.Session["API_LOCATION"]}"); e.Session.Log($"Get FILESERVER_LOCATION"); elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "FileServerUri"); e.Session["FILESERVER_LOCATION"] = elt.Attribute("value").Value; e.Session.Log($"FILESERVER_LOCATION : {e.Session["FILESERVER_LOCATION"]}"); e.Session.Log($"Get SYNCPATH"); elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SyncPath"); e.Session["SYNCPATH"] = elt.Attribute("value").Value; e.Session.Log($"SYNCPATH : {e.Session["SYNCPATH"]}"); e.Session.Log($"Get SENDREPORT"); elt = doc.Root.Element("userSettings").Element("KProcess.Ksmed.Presentation.Shell.Settings").Elements("setting").Single(x => x.Attribute("name").Value == "SendReport"); e.Session["SENDREPORT"] = elt.Element("value").Value == "True" ? "yes" : "no"; e.Session.Log($"SENDREPORT : {e.Session["SENDREPORT"]}"); e.Session.Log($"Get MUTE"); elt = doc.Root.Element("userSettings").Element("KProcess.Ksmed.Presentation.Shell.Settings").Elements("setting").Single(x => x.Attribute("name").Value == "Mute"); e.Session["MUTE"] = elt.Element("value").Value == "True" ? "yes" : "no"; e.Session.Log($"MUTE : {e.Session["MUTE"]}"); System.IO.File.Delete(backupConfigPath); } }
private static void FileServer_Project_BeforeInstall(SetupEventArgs e) { string backupConfigPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "Kprocess.KL2.FileServer.exe.config"); Version installedVersion = AppSearch.GetProductVersionFromUpgradeCode(e.UpgradeCode); if (installedVersion != null && e.IsModifying && !e.IsUninstalling) { try { string configPath = $"{e.Session["INSTALLDIR"]}Kprocess.KL2.FileServer.exe.config"; System.IO.File.Copy(configPath, backupConfigPath); } catch (Exception ex) { e.Session.Log($"ERROR : {ex.Message}"); } } else if (e.IsUpgrading && System.IO.File.Exists(backupConfigPath)) { e.Session.Log($"Load {backupConfigPath}"); var doc = XDocument.Load(backupConfigPath); var elt = doc.Root.Element("connectionStrings").Elements("add").Single(x => x.Attribute("name").Value == "KsmedEntities"); e.Session["DATASOURCE"] = elt.Attribute("connectionString").Value.Split(';') .Single(_ => _.StartsWith("Data Source")).Split('=')[1]; elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "ApplicationUrl"); e.Session["APPLICATION_URL"] = elt.Attribute("value").Value; elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "FileProvider"); e.Session["FILE_PROVIDER"] = elt.Attribute("value").Value; if (e.Session["FILE_PROVIDER"] == "SFtp") { elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SFtp_Server"); e.Session["SERVER"] = elt.Attribute("value").Value; elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SFtp_Port"); e.Session["PORT"] = elt.Attribute("value").Value; elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SFtp_User"); e.Session["USER"] = elt.Attribute("value").Value; elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SFtp_Password"); e.Session["PASSWORD"] = elt.Attribute("value").Value; elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SFtp_PublishedFilesDirectory"); e.Session["PUBLISHED_DIR"] = elt.Attribute("value").Value; elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SFtp_UploadedFilesDirectory"); e.Session["UPLOADED_DIR"] = elt.Attribute("value").Value; } else if (e.Session["FILE_PROVIDER"] == "Local") { elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "Local_PublishedFilesDirectory"); e.Session["PUBLISHED_DIR"] = elt.Attribute("value").Value; elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "Local_UploadedFilesDirectory"); e.Session["UPLOADED_DIR"] = elt.Attribute("value").Value; } System.IO.File.Delete(backupConfigPath); } }
private IQueryable <DocEntityApp> _ExecSearch(AppSearch request, DocQuery query) { request = InitSearch <App, AppSearch>(request); IQueryable <DocEntityApp> entities = null; query.Run(session => { entities = query.SelectAll <DocEntityApp>(); if (!DocTools.IsNullOrEmpty(request.FullTextSearch)) { var fts = new AppFullTextSearch(request); entities = GetFullTextSearch <DocEntityApp, AppFullTextSearch>(fts, entities); } if (null != request.Ids && request.Ids.Any()) { entities = entities.Where(en => en.Id.In(request.Ids)); } if (!DocTools.IsNullOrEmpty(request.Updated)) { entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date); } if (!DocTools.IsNullOrEmpty(request.UpdatedBefore)) { entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore); } if (!DocTools.IsNullOrEmpty(request.UpdatedAfter)) { entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter); } if (!DocTools.IsNullOrEmpty(request.Created)) { entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date); } if (!DocTools.IsNullOrEmpty(request.CreatedBefore)) { entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore); } if (!DocTools.IsNullOrEmpty(request.CreatedAfter)) { entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter); } if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.APP, nameof(Reference.Archived), DocConstantPermission.VIEW)) { entities = entities.Where(en => en.Archived.In(request.Archived)); } else { entities = entities.Where(en => !en.Archived); } if (true == request.Locked?.Any()) { entities = entities.Where(en => en.Locked.In(request.Locked)); } if (!DocTools.IsNullOrEmpty(request.Description)) { entities = entities.Where(en => en.Description.Contains(request.Description)); } if (!DocTools.IsNullOrEmpty(request.Descriptions)) { entities = entities.Where(en => en.Description.In(request.Descriptions)); } if (!DocTools.IsNullOrEmpty(request.Name)) { entities = entities.Where(en => en.Name.Contains(request.Name)); } if (!DocTools.IsNullOrEmpty(request.Names)) { entities = entities.Where(en => en.Name.In(request.Names)); } if (true == request.PagesIds?.Any()) { entities = entities.Where(en => en.Pages.Any(r => r.Id.In(request.PagesIds))); } if (true == request.RolesIds?.Any()) { entities = entities.Where(en => en.Roles.Any(r => r.Id.In(request.RolesIds))); } if (true == request.ScopesIds?.Any()) { entities = entities.Where(en => en.Scopes.Any(r => r.Id.In(request.ScopesIds))); } entities = ApplyFilters <DocEntityApp, AppSearch>(request, entities); if (request.Skip > 0) { entities = entities.Skip(request.Skip.Value); } if (request.Take > 0) { entities = entities.Take(request.Take.Value); } if (true == request?.OrderBy?.Any()) { entities = entities.OrderBy(request.OrderBy); } if (true == request?.OrderByDesc?.Any()) { entities = entities.OrderByDescending(request.OrderByDesc); } }); return(entities); }
public object Get(AppSearch request) => GetSearchResultWithCache <App, DocEntityApp, AppSearch>(DocConstantModelName.APP, request, _ExecSearch);
public object Post(AppSearch request) => Get(request);
private static void Project_BeforeInstall(SetupEventArgs e) { string backupConfigPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "Kprocess.KL2.TabletClient.exe.config"); string serviceBackupConfigPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "Kprocess.KL2.SyncService.exe.config"); Version installedVersion = AppSearch.GetProductVersionFromUpgradeCode(e.UpgradeCode); if (installedVersion != null && e.IsModifying && !e.IsUninstalling) { try { // Tablet string configPath = $"{e.Session["INSTALLDIR"]}Kprocess.KL2.TabletClient.exe.config"; e.Session.Log($"Load {configPath}"); var doc = XDocument.Load(configPath); e.Session.Log($"Get API_LOCATION"); var elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "ApiServerUri"); e.Session.Log($"API_LOCATION : {elt.Attribute("value").Value}"); e.Session.Log($"Get FILESERVER_LOCATION"); elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "FileServerUri"); e.Session.Log($"FILESERVER_LOCATION : {elt.Attribute("value").Value}"); e.Session.Log($"Get SYNCPATH"); elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SyncPath"); e.Session.Log($"SYNCPATH : {elt.Attribute("value").Value}"); System.IO.File.Copy(configPath, backupConfigPath); // SyncService configPath = $"{e.Session["INSTALLDIR"]}Kprocess.KL2.SyncService.exe.config"; e.Session.Log($"Load {configPath}"); doc = XDocument.Load(configPath); e.Session.Log($"Get API_LOCATION"); elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "ApiServerUri"); e.Session.Log($"API_LOCATION : {elt.Attribute("value").Value}"); e.Session.Log($"Get SYNCPATH"); elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SyncPath"); e.Session.Log($"SYNCPATH : {elt.Attribute("value").Value}"); e.Session.Log($"Get SYNC_INTERVAL"); elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SyncInterval"); e.Session.Log($"SYNC_INTERVAL : {elt.Attribute("value").Value}"); System.IO.File.Copy(configPath, serviceBackupConfigPath); } catch (Exception ex) { e.Session.Log($"ERROR : {ex.Message}"); } } else if (e.IsUpgrading && System.IO.File.Exists(backupConfigPath) && System.IO.File.Exists(serviceBackupConfigPath)) { // Tablet e.Session.Log($"Load {backupConfigPath}"); var doc = XDocument.Load(backupConfigPath); e.Session.Log($"Get API_LOCATION"); var elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "ApiServerUri"); e.Session["API_LOCATION"] = elt.Attribute("value").Value; e.Session.Log($"API_LOCATION : {e.Session["API_LOCATION"]}"); e.Session.Log($"Get FILESERVER_LOCATION"); elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "FileServerUri"); e.Session["FILESERVER_LOCATION"] = elt.Attribute("value").Value; e.Session.Log($"FILESERVER_LOCATION : {e.Session["FILESERVER_LOCATION"]}"); e.Session.Log($"Get SYNCPATH"); elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SyncPath"); e.Session["SYNCPATH"] = elt.Attribute("value").Value; e.Session.Log($"SYNCPATH : {e.Session["SYNCPATH"]}"); System.IO.File.Delete(backupConfigPath); // SyncService e.Session.Log($"Load {serviceBackupConfigPath}"); doc = XDocument.Load(serviceBackupConfigPath); e.Session.Log($"Get API_LOCATION"); elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "ApiServerUri"); e.Session["API_LOCATION"] = elt.Attribute("value").Value; e.Session.Log($"API_LOCATION : {e.Session["API_LOCATION"]}"); e.Session.Log($"Get SYNCPATH"); elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SyncPath"); e.Session["SYNCPATH"] = elt.Attribute("value").Value; e.Session.Log($"SYNCPATH : {e.Session["SYNCPATH"]}"); e.Session.Log($"Get SYNC_INTERVAL"); elt = doc.Root.Element("appSettings").Elements("add").Single(x => x.Attribute("key").Value == "SyncInterval"); e.Session["SYNC_INTERVAL"] = elt.Attribute("value").Value; e.Session.Log($"SYNC_INTERVAL : {e.Session["SYNC_INTERVAL"]}"); System.IO.File.Delete(serviceBackupConfigPath); } }