private void RunEnable(Object obj) { bWorking = true; EMButton button = (EMButton)((Object[])obj)[0]; Extension extension = (Extension)((Object[])obj)[1]; if (null != extension) { extension.Errors.Clear(); extension.Valid = true; string file = installationPath + "\\lib\\" + extension.Name; string command = "cd \"" + installationPath + "\\lib\""; command += " & move /Y \"" + file + "._dll\" \"" + file + ".dll\""; file = installationPath + "\\lib\\" + extension.Name; command += " & move /Y \"" + file + "._xml\" \"" + file + ".xml\""; extension.UACcommand(command); if (CheckAccess()) { if (extension.Valid) { button.SetState(EMButton.eState.INSTALLED); foreach (Extension extensionWeb in webExtension.extensions) { if (extension.Name == extensionWeb.Name && extension.SBVersion == SBVersion && extension.ExtVersion != extensionWeb.ExtVersion) { button.SetState(EMButton.eState.UPDATE); } } } GetButtonExtensionLists(); MakeButtons(); SetButtonExtensionLists(); } else { Dispatcher.Invoke(() => { if (extension.Valid) { button.SetState(EMButton.eState.INSTALLED); foreach (Extension extensionWeb in webExtension.extensions) { if (extension.Name == extensionWeb.Name && extension.SBVersion == SBVersion && extension.ExtVersion != extensionWeb.ExtVersion) { button.SetState(EMButton.eState.UPDATE); } } } GetButtonExtensionLists(); MakeButtons(); SetButtonExtensionLists(); }); } } bWorking = false; }
private void MakeButtons() { webExtension.Load(databasePath); localExtension.Load(installationPath); double top = 20; EMButtons.Clear(); foreach (Extension extensionWeb in webExtension.extensions) { if (extensionWeb.SBVersion == SBVersion) { EMButton.eState state = EMButton.eState.INSTALL; foreach (Extension extensionLocal in localExtension.extensions) { extensionLocal.InstalledVersion = extensionLocal.ExtVersion; // Web and local have the same name - assumed the same extension - we will ignore one of them if (extensionLocal.Name == extensionWeb.Name) { state = EMButton.eState.UPDATE; extensionWeb.InstalledVersion = extensionLocal.InstalledVersion; // Ignore local (include web) if identical since web has access to download and descriptionn etc if (extensionLocal.ExtVersion == extensionWeb.ExtVersion) { extensionLocal.SBVersion = null; if (File.Exists(installationPath + "\\lib\\" + extensionLocal.Name + ".dll")) { state = EMButton.eState.INSTALLED; } else { state = EMButton.eState.DISABLED; } } // Include local (ignore web) if web version is less than local installed else if (IsVersionLess(extensionWeb.ExtVersion, extensionLocal.ExtVersion)) { state = EMButton.eState.NONE; } // Ignore local (include web) if web version is greater than local installed else { extensionLocal.SBVersion = null; if (!File.Exists(installationPath + "\\lib\\" + extensionLocal.Name + ".dll")) { state = EMButton.eState.DISABLED; } extensionLocal.SBVersion = null; } break; } } if (state != EMButton.eState.NONE) { EMButton button = AddButton(extensionWeb, 50, top); button.SetState(state); EMButtons.Add(button); top += 50; } } } bool test = false; //Test to create the different types int i = 0; foreach (Extension extensionLocal in localExtension.extensions) { if (extensionLocal.SBVersion == SBVersion) { EMButton button = AddButton(extensionLocal, 50, top); button.SetState(EMButton.eState.INSTALLED); if (!File.Exists(installationPath + "\\lib\\" + extensionLocal.Name + ".dll")) { button.SetState(EMButton.eState.DISABLED); } EMButtons.Add(button); top += 50; } else if (test && null != extensionLocal.SBVersion) { EMButton button = AddButton(extensionLocal, 50, top); if (i == 0) { button.SetState(EMButton.eState.DISABLED); } else if (i == 1) { button.SetState(EMButton.eState.INSTALL); } else if (i == 2) { button.SetState(EMButton.eState.INSTALLED); } else { button.SetState(EMButton.eState.UPDATE); } i++; EMButtons.Add(button); top += 50; } } grid.Height = top; }