/// <summary>Hit when the user user clicks the Connect button.</summary> /// <param name="sender">btnConnect</param> /// <param name="e">RoutedEventArgs</param> private void btnConnect_Click(object sender, RoutedEventArgs e) { if (e != null) { e.Handled = true; } try { bool tag = (bool)this.btnConnect.Tag; if (tag) { this._client = null; //Set form. this.grdEntry.IsEnabled = true; this.barProg.IsIndeterminate = false; this.barProg.Value = 0; this.btnConnect.Content = "_Get Projects"; this.btnConnect.Tag = false; this.txtStatus.Text = ""; this.txtStatus.ToolTip = null; } else { if (this.txbServer.Text.ToLowerInvariant().EndsWith(".asmx") || this.txbServer.Text.ToLowerInvariant().EndsWith(".aspx") || this.txbServer.Text.ToLowerInvariant().EndsWith(".svc")) { MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_NewProject_URLErrorMessage"), StaticFuncs.getCultureResource.GetString("app_NewProject_URLError"), MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { //Start the connections. this.barProg.IsIndeterminate = true; this.barProg.Foreground = (Brush) new System.Windows.Media.BrushConverter().ConvertFrom(StaticFuncs.getCultureResource.GetString("app_Colors_StyledBarColor")); this.grdEntry.IsEnabled = false; this.btnConnect.Content = "_Cancel"; this.btnConnect.Tag = true; this.txtStatus.Text = "Connecting to server..."; this.cmbProjectList.Items.Clear(); this.grdAvailProjs.IsEnabled = false; //Create new client. this._client = StaticFuncs.CreateClient(this.txbServer.Text.Trim()); this._client.Connection_Authenticate2Completed += new EventHandler <Connection_Authenticate2CompletedEventArgs>(_client_CommunicationFinished); this._client.User_RetrieveByUserNameCompleted += new EventHandler <User_RetrieveByUserNameCompletedEventArgs>(_client_CommunicationFinished); this._client.Project_RetrieveCompleted += new EventHandler <Project_RetrieveCompletedEventArgs>(_client_CommunicationFinished); this._client.Connection_Authenticate2Async(this.txbUserID.Text, this.txbUserPass.Password, StaticFuncs.getCultureResource.GetString("app_ReportName")); } } } catch (Exception ex) { Logger.LogMessage(ex, "btnConnect_Click()"); MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary>Hit when the user wants to save the task.</summary> /// <param name="sender">The save button.</param> /// <param name="e">RoutedEventArgs</param> private void btnSave_Click(object sender, RoutedEventArgs e) { if (e != null) { e.Handled = true; } try { this.barSavingIncident.Value = -5; this.barSavingIncident.Maximum = 0; this.barSavingIncident.Minimum = -5; if (this._isFieldChanged || this._isWkfChanged || this._isResChanged || this._isDescChanged) { //Clear highlights. this.workflow_ClearAllRequiredHighlights(); //Set working flag. this.IsSaving = true; //Get the new values from the form.. RemoteIncident newIncident = this.save_GetFromFields(); if (newIncident != null && this.workflow_CheckRequiredFields()) { //Create a client, and save task and resolution.. ImportExportClient clientSave = StaticFuncs.CreateClient(((SpiraProject)this._ArtifactDetails.ArtifactParentProject.ArtifactTag).ServerURL.ToString()); clientSave.Connection_Authenticate2Completed += clientSave_Connection_Authenticate2Completed; clientSave.Connection_ConnectToProjectCompleted += clientSave_Connection_ConnectToProjectCompleted; clientSave.Incident_UpdateCompleted += clientSave_Incident_UpdateCompleted; clientSave.Incident_AddCommentsCompleted += clientSave_Incident_AddCommentsCompleted; clientSave.Connection_DisconnectCompleted += clientSave_Connection_DisconnectCompleted; //Fire off the connection. this._clientNumSaving = 1; clientSave.Connection_Authenticate2Async(((SpiraProject)this._ArtifactDetails.ArtifactParentProject.ArtifactTag).UserName, ((SpiraProject)this._ArtifactDetails.ArtifactParentProject.ArtifactTag).UserPass, StaticFuncs.getCultureResource.GetString("app_ReportName"), this._clientNum++); } else { //Display message saying that some required fields aren't filled out. MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_RequiredFieldsMessage"), StaticFuncs.getCultureResource.GetString("app_General_RequiredFields"), MessageBoxButton.OK, MessageBoxImage.Error); } } } catch (Exception ex) { Logger.LogMessage(ex, "btnSave_Click()"); MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error); } if (this._clientNumSaving == 0) { this.IsSaving = false; } }
/// <summary> /// Opens the artifact in a web browser /// </summary> /// <param name="treeViewArtifact"></param> public void OpenDetailsToolWindow(TreeViewArtifact treeViewArtifact) { string METHOD = CLASS + "OpenDetailsToolWindow"; try { //We need to get the URL, and then launch it. string strUrl = ((SpiraProject)treeViewArtifact.ArtifactParentProject.ArtifactTag).ServerURL.ToString(); Business.SpiraTeam_Client.SoapServiceClient client = StaticFuncs.CreateClient(strUrl); if (treeViewArtifact.ArtifactType != Inflectra.SpiraTest.IDEIntegration.VisualStudio2012.Business.TreeViewArtifact.ArtifactTypeEnum.None) { //Users need to use the resource URL string strArtUrl; if (treeViewArtifact.ArtifactType == Inflectra.SpiraTest.IDEIntegration.VisualStudio2012.Business.TreeViewArtifact.ArtifactTypeEnum.User) { //Resources = -11, strArtUrl = client.System_GetArtifactUrl(/*Resources*/ -11, treeViewArtifact.ArtifactParentProject.ArtifactId, treeViewArtifact.ArtifactId, null); } else { strArtUrl = client.System_GetArtifactUrl((int)treeViewArtifact.ArtifactType, treeViewArtifact.ArtifactParentProject.ArtifactId, treeViewArtifact.ArtifactId, null); } //In case the API hasn't been updated to return the full URL.. if (strArtUrl.StartsWith("~")) { strUrl = strArtUrl.Replace("~", strUrl); } try { System.Diagnostics.Process.Start(strUrl); } catch (Exception ex) { Logger.LogMessage(ex); MessageBox.Show("Error launching browser.", "Launch URL", MessageBoxButton.OK, MessageBoxImage.Warning); } } } catch (Exception ex) { Logger.LogMessage(ex, "OpenDetailsToolWindow()"); MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error); } }
private void InitNullEvents() { OnAfterOpenSolution += () => { address = SpiraContext.BaseUri.ToString(); id = SpiraContext.Login; password = SpiraContext.Password; //Create new client. this._client = StaticFuncs.CreateClient(address.Trim()); this._client.Connection_Authenticate2Completed += new EventHandler <Connection_Authenticate2CompletedEventArgs>(_client_CommunicationFinished); this._client.User_RetrieveByUserNameCompleted += new EventHandler <User_RetrieveByUserNameCompletedEventArgs>(_client_CommunicationFinished); this._client.Project_RetrieveCompleted += new EventHandler <Project_RetrieveCompletedEventArgs>(_client_CommunicationFinished); this._client.Connection_Authenticate2Async(id, password, StaticFuncs.getCultureResource.GetString("app_ReportName")); }; }
/// <summary>Called when the user changes the workflow step, pulls enabled/required fields.</summary> private void workflow_ChangeWorkflowStep() { try { //This is a potentially different workflow, so create the client to go out and get fields. ImportExportClient wkfClient = StaticFuncs.CreateClient(this._Project.ServerURL.ToString()); wkfClient.Connection_Authenticate2Completed += new EventHandler <Connection_Authenticate2CompletedEventArgs>(wkfClient_Connection_Authenticate2Completed); wkfClient.Connection_ConnectToProjectCompleted += new EventHandler <Connection_ConnectToProjectCompletedEventArgs>(wkfClient_Connection_ConnectToProjectCompleted); wkfClient.Incident_RetrieveWorkflowFieldsCompleted += new EventHandler <Incident_RetrieveWorkflowFieldsCompletedEventArgs>(wkfClient_Incident_RetrieveWorkflowFieldsCompleted); wkfClient.Incident_RetrieveWorkflowCustomPropertiesCompleted += new EventHandler <Incident_RetrieveWorkflowCustomPropertiesCompletedEventArgs>(wkfClient_Incident_RetrieveWorkflowCustomPropertiesCompleted); //Connect. this._clientNumRunning = 1; wkfClient.Connection_Authenticate2Async(this._Project.UserName, this._Project.UserPass, StaticFuncs.getCultureResource.GetString("app_ReportName")); } catch (Exception ex) { Logger.LogMessage(ex, "workflow_ChangeWorkflowStep()"); MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error); } }
public frmNewSpiraProject() { try { InitializeComponent(); //Set the title & icon. this.Title = Business.StaticFuncs.getCultureResource.GetString("strNewSpiraProject"); try { System.Drawing.Icon ico = (System.Drawing.Icon)Business.StaticFuncs.getCultureResource.GetObject("icoLogo"); MemoryStream icoStr = new MemoryStream(); ico.Save(icoStr); icoStr.Seek(0, SeekOrigin.Begin); this.Icon = BitmapFrame.Create(icoStr); } catch (Exception ex) { Logger.LogMessage(ex); } //Set initial colors and form status. this.barProg.Foreground = (Brush) new System.Windows.Media.BrushConverter().ConvertFrom(Business.StaticFuncs.getCultureResource.GetString("app_Colors_StyledBarNormal")); this.barProg.IsIndeterminate = false; this.barProg.Value = 0; this.grdAvailProjs.IsEnabled = false; this.grdEntry.IsEnabled = true; this.btnConnect.Tag = false; this.btnConnect.Click += new RoutedEventHandler(btnConnect_Click); int num = this.cmbProjectList.Items.Add("-- No Projects Available --"); this.cmbProjectList.SelectedIndex = num; this.cmbProjectList.SelectionChanged += new SelectionChangedEventHandler(cmbProjectList_SelectionChanged); //See if we have initial values to load in for this solution if (SpiraContext.HasSolutionProps) { this.txbServer.Text = SpiraContext.BaseUri.ToString(); if (!String.IsNullOrEmpty(SpiraContext.Login) && !String.IsNullOrEmpty(SpiraContext.Password)) { this.txbUserID.Text = SpiraContext.Login; this.txbUserPass.Password = SpiraContext.Password; //Start the connections. this.barProg.IsIndeterminate = true; this.barProg.Foreground = (Brush) new System.Windows.Media.BrushConverter().ConvertFrom(StaticFuncs.getCultureResource.GetString("app_Colors_StyledBarColor")); this.grdEntry.IsEnabled = false; this.btnConnect.Content = "_Cancel"; this.btnConnect.Tag = true; this.txtStatus.Text = "Connecting to server..."; this.cmbProjectList.Items.Clear(); this.grdAvailProjs.IsEnabled = false; //Create new client. this._client = StaticFuncs.CreateClient(this.txbServer.Text.Trim()); this._client.Connection_Authenticate2Completed += new EventHandler <Connection_Authenticate2CompletedEventArgs>(_client_CommunicationFinished); this._client.User_RetrieveByUserNameCompleted += new EventHandler <User_RetrieveByUserNameCompletedEventArgs>(_client_CommunicationFinished); this._client.Project_RetrieveCompleted += new EventHandler <Project_RetrieveCompletedEventArgs>(_client_CommunicationFinished); this._client.Connection_Authenticate2Async(this.txbUserID.Text, this.txbUserPass.Password, StaticFuncs.getCultureResource.GetString("app_ReportName")); } } } catch (Exception ex) { Logger.LogMessage(ex, "InitializeComponent()"); MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error); } }