private void pluginsList_SelectedIndexChanged(object sender, EventArgs e) { if (pluginsList.SelectedItems.Count > 0) { AssemblyListViewItem alvi = this.pluginsList.SelectedItems[0] as AssemblyListViewItem; this.updatePlugin.Enabled = alvi.HasUpdateUrl; } }
private void AddAssemblyButton_Click(System.Object sender, System.EventArgs e) { Cursor csr = null; Database db; SqlAssembly asm; UserDefinedFunction udf; UserDefinedFunctionParameter parm; ListViewItem AssemblyListViewItem; try { csr = this.Cursor; // Save the old cursor this.Cursor = Cursors.WaitCursor; // Display the waiting cursor // Get selected database db = (Database)DatabasesComboBox.SelectedItem; asm = new SqlAssembly(db, "UtilityConversion"); asm.Owner = "dbo"; asm.AssemblySecurityLevel = AssemblySecurityLevel.Safe; // This allows the assembly to be on a different server from SQL Server // Use string array version which serializes the assembly asm.Create(new String[] { AssemblyFileTextBox.Text }); udf = new UserDefinedFunction(db, "StringToInt32"); udf.TextMode = false; udf.ImplementationType = ImplementationType.SqlClr; udf.AssemblyName = "UtilityConversion"; udf.ClassName = "Microsoft.Samples.SqlServer.Conversions"; udf.MethodName = "StringToInt32"; udf.FunctionType = UserDefinedFunctionType.Scalar; udf.DataType = DataType.Int; parm = new UserDefinedFunctionParameter(udf, "@Input"); udf.Parameters.Add(parm); parm.DataType = DataType.NVarChar(255); udf.Create(); ShowAssemblies(true); // Select the assembly just added AssemblyListViewItem = AssembliesListView.FindItemWithText( asm.Name); AssemblyListViewItem.Selected = true; AssemblyListViewItem.EnsureVisible(); } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { this.Cursor = csr; // Restore the original cursor } }
private void browseButton_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog() { Filter = "Assemblies|*.exe;*.dll" }; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var item = new AssemblyListViewItem(FileVersionInfo.GetVersionInfo(ofd.FileName)); listView1.Items.Add(item); item.Checked = true; item.Selected = true; item.EnsureVisible(); } }
private void updatePlugin_Click(object sender, EventArgs e) { if (this.pluginsList.SelectedItems.Count > 0) { AssemblyListViewItem alvi = this.pluginsList.SelectedItems[0] as AssemblyListViewItem; ApplicationUpdater au = new ApplicationUpdater(); au.Version = alvi.Version; this.pluginUpdateStatus.Text = "Checking updates for " + alvi.Text; au.UpdateAvailable += new EventHandler <UpdatesAvailableEventArgs> (delegate(object s, UpdatesAvailableEventArgs uae) { ApplicationUpdater ai = (ApplicationUpdater)s; ai.UpdateName = alvi.Text; this.pluginUpdateStatus.Text = "Updates available..."; if (ai.UpdatesAvailable) { UpdateInformationForm uif = new UpdateInformationForm(ai); if (uif.ShowDialog(null) == DialogResult.OK) { string thisPath = this.GetType().Assembly.Location; string attrString = string.Format(CCNetConfig.Core.Util.UserSettings.UpdateSettings.LaunchArgumentsFormat, CCNetConfig.Core.Util.UserSettings.UpdateSettings.UpdateCheckType, thisPath, ai.UpdateInfoList.GetLatestVersion()); Process.Start(Path.Combine(Application.StartupPath, CCNetConfig.Core.Util.UserSettings.UpdateSettings.UpdaterApplication), attrString); Application.Exit(); } } }); au.UpdateException += new EventHandler <ExceptionEventArgs> (delegate(object s, ExceptionEventArgs ex) { MessageBox.Show(ex.Exception.Message, "Update of plugin error"); }); au.CheckForUpdatesByUrl(alvi.UpdateUrl); this.pluginUpdateStatus.Text = string.Empty; } }