private void CommitCRMHandle() { try { string p_name = "CommitCRM"; string displayName; RegistryKey key; key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"); RepairShoprUtils.LogWriteLineinHTML("Reading CommitCRM Install Location from RegistryKey", MessageSource.Initialization, "", messageType.Information); foreach (String keyName in key.GetSubKeyNames()) { RegistryKey subkey = key.OpenSubKey(keyName); displayName = subkey.GetValue("DisplayName") as string; if (p_name.Equals(displayName, StringComparison.OrdinalIgnoreCase) == true) { installedLocation = subkey.GetValue("InstallLocation") as string;//return true; RepairShoprUtils.LogWriteLineinHTML(string.Format("CommitCRM Install Directiory is '{0}'", installedLocation), MessageSource.Initialization, "", messageType.Information); RepairShoprUtils.LogWriteLineinHTML("Setting CommitCRM Parameter such as DLL folder and DB Folder", MessageSource.Initialization, "", messageType.Information); CommitCRM.Config config = new CommitCRM.Config(); config.AppName = "RepairShopr"; config.CommitDllFolder = Path.Combine(installedLocation, "ThirdParty", "UserDev"); config.CommitDbFolder = Path.Combine(installedLocation, "db"); CommitCRM.Application.Initialize(config); RepairShoprUtils.LogWriteLineinHTML("Successfully configure CommitCRM ", MessageSource.Initialization, "", messageType.Information); break; } } } catch (CommitCRM.Exception exc) { RepairShoprUtils.LogWriteLineinHTML("Failed to Configure CommitCRM", MessageSource.Initialization, exc.Message, messageType.Error); } }
private void CommitCRMHandle() { try { bool folderExist = false; if (!string.IsNullOrEmpty(Properties.Settings.Default.InstalledLocation)) { folderExist = Directory.Exists(Properties.Settings.Default.InstalledLocation); } if (!folderExist) { string p_name = "CommitCRM"; string installedLocation = null; RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"); RepairShoprUtils.LogWriteLineinHTML("Reading CommitCRM Install Location from RegistryKey", MessageSource.Initialization, "", messageType.Information); foreach (var keyName in key.GetSubKeyNames()) { RegistryKey subkey = key.OpenSubKey(keyName); var displayName = subkey.GetValue("DisplayName") as string; if (p_name.Equals(displayName, StringComparison.OrdinalIgnoreCase) == true) { installedLocation = subkey.GetValue("InstallLocation") as string; RepairShoprUtils.LogWriteLineinHTML(string.Format("CommitCRM Install Directiory is '{0}'", installedLocation), MessageSource.Initialization, "", messageType.Information); break; } } if (string.IsNullOrEmpty(installedLocation)) { if (MessageBox.Show("CommitCRM location is not found. Would you like to browse it now?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { var dialog = new FolderBrowserDialog(); dialog.ShowNewFolderButton = false; if (dialog.ShowDialog() == DialogResult.OK) { installedLocation = dialog.SelectedPath; } } } Properties.Settings.Default.InstalledLocation = installedLocation; Properties.Settings.Default.Save(); if (string.IsNullOrEmpty(Properties.Settings.Default.InstalledLocation)) { RepairShoprUtils.LogWriteLineinHTML("CommitCRM is not configured", MessageSource.Initialization, "", messageType.Information); return; } } RepairShoprUtils.LogWriteLineinHTML("Setting CommitCRM Parameter such as DLL folder and DB Folder", MessageSource.Initialization, "", messageType.Information); var config = new CommitCRM.Config(); config.AppName = "RepairShopr"; config.CommitDllFolder = Path.Combine(Properties.Settings.Default.InstalledLocation, "ThirdParty", "UserDev"); config.CommitDbFolder = Path.Combine(Properties.Settings.Default.InstalledLocation, "db"); CommitCRM.Application.Initialize(config); RepairShoprUtils.LogWriteLineinHTML("Successfully configure CommitCRM", MessageSource.Initialization, "", messageType.Information); } catch (CommitCRM.Exception exc) { RepairShoprUtils.LogWriteLineinHTML("Failed to Configure CommitCRM", MessageSource.Initialization, exc.Message, messageType.Error); } }