/// <summary> /// Get current assembly version /// </summary> /// <returns></returns> public static string GetCurrentAssemblyVersion() { string localAssembly = FCMXmlConfig.Read(FCMConstant.fcmConfigXml.LocalAssemblyFolder); string serverAssembly = FCMXmlConfig.Read(FCMConstant.fcmConfigXml.ServerAssemblyFolder); string LocalPath = @localAssembly; string LocalPathMainAssembly = @LocalPath + "fcm.exe"; AssemblyName localAssemblyName = new AssemblyName(); string versionLocal = ""; // Get the local version of the assembly if (File.Exists(LocalPathMainAssembly)) { localAssemblyName = AssemblyName.GetAssemblyName(LocalPathMainAssembly); versionLocal = localAssemblyName.Version.ToString(); } return(versionLocal); }
public AssemblyLoader() { AssemblyIsLoaded = false; string localAssembly = FCMXmlConfig.Read(fcmConfigXml.LocalAssemblyFolder); string serverAssembly = FCMXmlConfig.Read(fcmConfigXml.ServerAssemblyFolder); if (string.IsNullOrEmpty(localAssembly)) { MessageBox.Show("FCMConfig.xml is not setup correctly - missing Local Assembly Folder."); return; } if (string.IsNullOrEmpty(serverAssembly)) { MessageBox.Show("FCMConfig.xml is not setup correctly - missing Server Assembly Folder."); return; } // Get local assemblies folder location // LocalPath = @"C:\Program Files\fcm\"; LocalPath = @localAssembly; // LocalPathMainAssembly = @"C:\Program Files\fcm\fcm.exe"; LocalPathMainAssembly = @LocalPath + "fcm.exe"; // Get server assemblies folder location // ServerPath = @"C:\Users\MACHADO\Dropbox\FCM\fcm\bin\Debug\"; ServerPath = @serverAssembly; // ServerPathMainAssembly = @"C:\Users\MACHADO\Dropbox\FCM\fcm\bin\Debug\fcm.exe"; ServerPathMainAssembly = @ServerPath + "fcm.exe"; AssemblyName localAssemblyName = new AssemblyName(); AssemblyName serverAssemblyName = new AssemblyName(); string versionLocal = ""; string versionServer = ""; // Get the local version of the assembly if (File.Exists(LocalPathMainAssembly)) { localAssemblyName = AssemblyName.GetAssemblyName(LocalPathMainAssembly); versionLocal = localAssemblyName.Version.ToString(); } // Get the server version of the assembly if (!File.Exists(ServerPathMainAssembly)) { MessageBox.Show("Error. Server version not found. Path= " + ServerPathMainAssembly); return; } serverAssemblyName = AssemblyName.GetAssemblyName(ServerPathMainAssembly); versionServer = serverAssemblyName.Version.ToString(); if (versionLocal == versionServer) { // All good AssemblyCanBeLoaded = true; return; } MessageBox.Show("Version will be upgraded. " + versionServer); // At this point the files are not the same, need to replace the local files. // // Check if files are there var filesInServer = Directory.GetFiles(ServerPath); foreach (var serverfile in filesInServer) { string sfile = serverfile.Replace("\\", ","); var partsOfFile = sfile.Split(','); var filename = partsOfFile[partsOfFile.Length - 1]; string localFilePathName = LocalPath + filename; string serverFilePathName = ServerPath + filename; if (File.Exists(localFilePathName)) { // Copy Server files // try { File.Delete(localFilePathName); } catch (Exception ex) { MessageBox.Show("Error deleting file " + localFilePathName + " " + ex.ToString()); } } try { File.Copy(serverFilePathName, localFilePathName); } catch (Exception ex) { MessageBox.Show("Error copying file " + serverFilePathName + " " + ex.ToString()); } } AssemblyCanBeLoaded = true; }
private void Logon_Load(object sender, EventArgs e) { // Retrieve inital config information // // 1) Connection String // // ConnString.ConnectionString = FCMXmlConfig.Read(FCMConstant.fcmConfigXml.ConnectionString); txtConnection.Text = ConnString.ConnectionStringLocal; txtServerConnection.Text = ConnString.ConnectionStringServer; int st = 0; st = ConnString.ConnectionStringLocal.IndexOf("Data Source"); if (st >= 0) { int en = ConnString.ConnectionStringLocal.IndexOf(";"); txtConnection.Text = ConnString.ConnectionStringLocal.Substring(st, en - st); int st1 = ConnString.ConnectionStringServer.IndexOf("Data Source"); int en1 = ConnString.ConnectionStringServer.IndexOf(";"); txtServerConnection.Text = ConnString.ConnectionStringServer.Substring(st1, en1 - st1); } else { st = ConnString.ConnectionStringLocal.IndexOf("Server"); if (st >= 0) { int en = ConnString.ConnectionStringLocal.IndexOf(";"); txtConnection.Text = ConnString.ConnectionStringLocal.Substring(st, en - st); int st1 = ConnString.ConnectionStringServer.IndexOf("Server"); int en1 = ConnString.ConnectionStringServer.IndexOf(";"); txtServerConnection.Text = ConnString.ConnectionStringServer.Substring(st1, en1 - st1); } } // ConnString.ConnectionString = ConnString.ConnectionStringLocal; // Get last user id //ProcessRequestCodeValues cv = new ProcessRequestCodeValues(); //cv.FKCodeType = "LASTINFO"; //cv.ID = "USERID"; //cv.Read(false); //txtUserID.Text = cv.ValueExtended; // Enable/ Disable dbs using xml // string enableLocalDB = FCMXmlConfig.Read(FCMConstant.fcmConfigXml.EnableLocalDB); string enableServerDB = FCMXmlConfig.Read(FCMConstant.fcmConfigXml.EnableServerDB); string defaultDB = FCMXmlConfig.Read(FCMConstant.fcmConfigXml.DefaultDB); rbLocal.Enabled = false; rbServer.Enabled = false; if (enableLocalDB == "Y") { rbLocal.Enabled = true; } if (enableServerDB == "Y") { rbServer.Enabled = true; } if (defaultDB == "Server") { if (enableServerDB == "Y") { rbServer.Checked = true; } } else if (enableLocalDB == "Y") { rbLocal.Checked = true; } // txtUserID.Focus(); }