public static void AddListBoxEntry(Session session, string propertyName, int order, string value, string text) { Record newEntry = new Record(4); newEntry[0] = propertyName; newEntry[1] = order; newEntry[2] = value; newEntry[3] = text; try { Microsoft.Deployment.WindowsInstaller.View listBoxView = session.Database.OpenView("SELECT * FROM ComboBox"); //`Property`, `Order`, `Value`, `Text` listBoxView.Execute(); listBoxView.Modify(ViewModifyMode.InsertTemporary, newEntry); listBoxView.Close(); } catch (InstallerException ix) { //RecurseLogInstallerException(session, ix, 0); session.Log(ix.Message); } }
public static ActionResult FillDBServerNameAction(Session xiSession) { Microsoft.Deployment.WindowsInstaller.View lView = xiSession.Database.OpenView("SELECT * FROM ComboBox"); lView.Execute(); int lIndex = 1; string HostName = Dns.GetHostName(); ServiceController[] services = ServiceController.GetServices(); //从机器服务列表中找到本机的SqlServer引擎 foreach (ServiceController s in services) { if (s.Status != ServiceControllerStatus.Running) { continue; } if (s.ServiceName.ToLower().IndexOf("mssql$") != -1) { Record lRecord = xiSession.Database.CreateRecord(4); lRecord.SetString(1, "DBSERVER"); lRecord.SetInteger(2, lIndex); lRecord.SetString(3, HostName + "\\" + s.ServiceName.Substring(s.ServiceName.IndexOf("$") + 1)); // Use lWebsiteName only if you want to look up the site by name. lRecord.SetString(3, HostName + "\\" + s.ServiceName.Substring(s.ServiceName.IndexOf("$") + 1)); lView.Modify(ViewModifyMode.InsertTemporary, lRecord); if (lIndex == 1) { xiSession["DBSERVER"] = HostName + "\\" + s.ServiceName.Substring(s.ServiceName.IndexOf("$") + 1); } lIndex++; } else if (s.ServiceName.ToLower() == "mssqlserver") { Record lRecord = xiSession.Database.CreateRecord(4); lRecord.SetString(1, "DBSERVER"); lRecord.SetInteger(2, lIndex); lRecord.SetString(3, HostName); // Use lWebsiteName only if you want to look up the site by name. lRecord.SetString(3, HostName); lView.Modify(ViewModifyMode.InsertTemporary, lRecord); if (lIndex == 1) { xiSession["DBSERVER"] = HostName; } lIndex++; } } lView.Close(); return(ActionResult.Success); }
private static ActionResult EnumSqlServersIntoComboBox(Session session, IEnumerable <DataRow> rows) { try { //Debugger.Break(); session.Log("EnumSQLServers: Begin"); View view = session.Database.OpenView("DELETE FROM ComboBox WHERE ComboBox.Property='DATABASE_SERVER'"); view.Execute(); view = session.Database.OpenView("SELECT * FROM ComboBox"); view.Execute(); Int32 index = 1; session.Log("EnumSQLServers: Enumerating SQL servers"); foreach (DataRow row in rows) { String serverName = row["Name"].ToString(); // Create a record for this web site. All I care about is // the name so use it for fields three and four. session.Log("EnumSQLServers: Processing SQL server: {0}", serverName); Record record = session.Database.CreateRecord(4); record.SetString(1, "DATABASE_SERVER"); record.SetInteger(2, index); record.SetString(3, serverName); record.SetString(4, serverName); session.Log("EnumSQLServers: Adding record"); view.Modify(ViewModifyMode.InsertTemporary, record); index++; } view.Close(); session.Log("EnumSQLServers: End"); } catch (Exception ex) { session.Log("EnumSQLServers: exception: {0}", ex.Message); throw; } return(ActionResult.Success); }
public static ActionResult PopulateRegistrarList(Session session) { string wixProperty = "REGISTRAR_REGISTRAR"; string logPrefix = "UDDNSQuery.PopulateRegistrarList: "; session.Log(logPrefix + "Method begin."); // Nuke the combobox and initialize the View. Microsoft.Deployment.WindowsInstaller.View comboBoxView = session.Database.OpenView( "DELETE FROM ComboBox WHERE ComboBox.Property = '{0}'", new string[] { wixProperty, } ); comboBoxView.Execute(); comboBoxView = session.Database.OpenView("SELECT * FROM ComboBox"); comboBoxView.Execute(); session.Log(logPrefix + String.Format("ComboBox {0} purged.", wixProperty)); // Populate the combobox. http://msdn.microsoft.com/en-us/library/windows/desktop/aa367872(v=vs.85).aspx int i = 0; Record comboBoxItem; string entry; foreach (string name in QueryAPIIndex.I.Registrars.Keys) { i++; entry = String.Format("{0} ({1})", name, QueryAPIIndex.I.Registrars[name]); comboBoxItem = session.Database.CreateRecord(4); comboBoxItem.SetString(1, wixProperty); // Property name. comboBoxItem.SetInteger(2, i); // Order. comboBoxItem.SetString(3, name); // Value of item. comboBoxItem.SetString(4, entry); // Text to represent item. comboBoxView.Modify(ViewModifyMode.InsertTemporary, comboBoxItem); session.Log(logPrefix + String.Format("ComboBox {0} new entry: {1}", wixProperty, entry)); } session.Log(logPrefix + "Method end."); return(ActionResult.Success); }
private static void StoreWebSiteDataInListBoxTable(DirectoryEntry webSite, int order, View listBoxView) { Record newListBoxRecord = new Record(4); newListBoxRecord[1] = "WEBSITE"; newListBoxRecord[2] = order; newListBoxRecord[3] = webSite.Name; newListBoxRecord[4] = webSite.Properties["ServerComment"].Value; listBoxView.Modify(ViewModifyMode.InsertTemporary, newListBoxRecord); }
private static void StoreWebSiteDataInAvailableWebSitesTable(DirectoryEntry webSite, View availableWSView) { //Get Ip, Port and Header from server bindings string[] serverBindings = ((string)webSite.Properties["ServerBindings"].Value).Split(':'); string ip = serverBindings[0]; string port = serverBindings[1]; string header = serverBindings[2]; Record newFoundWebSiteRecord = new Record(5); newFoundWebSiteRecord[1] = webSite.Name; newFoundWebSiteRecord[2] = webSite.Properties["ServerComment"].Value; newFoundWebSiteRecord[3] = port; newFoundWebSiteRecord[4] = ip; newFoundWebSiteRecord[5] = header; availableWSView.Modify(ViewModifyMode.InsertTemporary, newFoundWebSiteRecord); }