/// <summary> /// The URI was fired from unknown client (outside NAV client). /// </summary> /// <param name="uri">The URI.</param> private static void RunFromUnknown(string uri) { var fileVersion = NAV_URI_Extender.GetVersionFromMapping(uri); if (String.IsNullOrEmpty(fileVersion) && uri.ToLower().Contains("?buildversion=")) { fileVersion = NAV_URI_Extender.GetVersionFromUri(uri); // We need to remove the version string, NAV6 does not like it // in NAV7 it is ignored uri = uri.Replace("?buildversion=" + fileVersion, ""); } if (String.IsNullOrEmpty(fileVersion)) { string defaultPath = (String)Microsoft.Win32.Registry.GetValue(@"HKEY_CLASSES_ROOT\DYNAMICSNAV\Shell\Open\Command", "Default", ""); defaultPath = defaultPath.Replace("\"%1\"", ""); string version = System.Diagnostics.FileVersionInfo.GetVersionInfo(defaultPath).FileVersion; RunForVersion(uri, defaultPath, fileVersion, false); return; } else { foreach (String navVersionFolder in GetNavVersionFolders()) { if (RunForVersion(uri, navVersionFolder, fileVersion, false)) { return; } } } }
/// <summary> /// The URI was fired from NAV client. /// </summary> /// <param name="uri">The URI.</param> /// <param name="pid">The NAV client pid.</param> /// <param name="activeProcessFolder">The active process folder.</param> /// <param name="path">The path.</param> private static void RunFromClient(string uri, uint pid, String activeProcessFolder, String path) { var versionInfo = FileVersionInfo.GetVersionInfo(activeProcessFolder); var fileVersion = versionInfo.FileVersion; if (pid != 0) { // Only trigger GetExtendedUri if uri does not contain service tier server and instance if (uri.Contains("////")) { var newUri = NAV_URI_Extender.GetExtendedUri(new Uri(uri), pid); if (newUri != null) { uri = newUri.ToString(); } } } NAVClient2URI.UpdateVersion(uri, fileVersion); if (File.Exists(path + "Microsoft.Dynamics.Nav.Client.x86.exe")) //Runs the client from same folder as calling process { var navClient = NAVClientFactory.GetObject(fileVersion); navClient.Path = path + "Microsoft.Dynamics.Nav.Client.x86.exe"; navClient.Uri = uri; RunProcess(navClient); return; } else { if (File.Exists(path + "Microsoft.Dynamics.Nav.Client.exe")) //Runs the client from same folder as calling process { var navClient = NAVClientFactory.GetObject(fileVersion); navClient.Path = path + "Microsoft.Dynamics.Nav.Client.exe"; navClient.Uri = uri; RunProcess(navClient); return; } } RunForVersion(uri, activeProcessFolder, fileVersion); }