/// <summary> /// Check if the current version of the client is up to date and where it is /// </summary> /// <param name="localIniPath"></param> /// <param name="localIniFile"></param> /// <param name="clientDeploymentDir"></param> /// <param name="remoteIniPath"></param> /// <param name="remoteIniFile"></param> /// <param name="logActivity"></param> /// <returns></returns> public static bool ClientVersionIsUpToDate( out string localIniPath, out IniFile localIniFile, out string clientDeploymentDir, out string remoteIniPath, out IniFile remoteIniFile, bool logActivity) { StreamReader sr = null; string localBinDir = null; localIniPath = ""; localIniFile = null; clientDeploymentDir = ""; remoteIniPath = ""; remoteIniFile = null; try { if (logActivity) { DebugLog.Message("Getting local & remote deployment Ids..."); } localIniPath = DefaultMobiusClientFolder + @"\MobiusClient.ini"; // ini file on client if (!File.Exists(localIniPath)) { localIniPath = Application.StartupPath + @"\MobiusClient.ini"; // ini file on client if (!File.Exists(localIniPath)) { return(true); } } localIniFile = new IniFile(localIniPath, "Mobius"); string localDeploymentId = localIniFile.Read("DeploymentId", "UnknownLocalDeployment"); if (logActivity) { DebugLog.Message("LocalDeploymentId: " + localDeploymentId); } clientDeploymentDir = localIniFile.Read("ClientDeploymentDir", DefaultMobiusClientFolder); if (logActivity) { DebugLog.Message("ClientDeploymentDir: " + clientDeploymentDir); } string remoteBinDir = localIniFile.Read("ServerBinDir"); // bin directory on server where things are if (Lex.IsNullOrEmpty(remoteBinDir)) { throw new Exception("ServerBinDir not defined in " + localIniPath); } remoteIniPath = remoteBinDir + @"\MobiusClient.ini"; // ini file on server try // be sure we can read remote inifile & trap any error { sr = new StreamReader(remoteIniPath); sr.Close(); remoteIniFile = new IniFile(remoteIniPath, "Mobius"); if (remoteIniFile == null) { throw new Exception("Null IniFile Object"); } } catch (Exception ex) { throw new Exception("Can't open remote inifile: " + remoteIniPath + ", " + ex.Message); } string remoteDeploymentId = remoteIniFile.Read("DeploymentId", "UnknownRemoteDeployment"); bool deploymentIdsMatch = (localDeploymentId == remoteDeploymentId); // local & remote deployment ids the same? if (logActivity) { DebugLog.Message("RemoteDeploymentId: " + remoteDeploymentId); } // Get current client deployment dir string clientExePath = clientDeploymentDir + @"\MobiusClient.exe"; // make sure executable is there if (!File.Exists(clientExePath)) { return(false); } if (!deploymentIdsMatch) { return(false); // local & remote deployment ids the same? } return(true); // up to date } catch (Exception ex) { if (logActivity) { string msg = "Client version check failed\r\n" + ex.Message + "\r\n" + ex.StackTrace; DebugLog.Message(msg); MessageBox.Show(msg); } return(true); // say true if error } }