示例#1
0
        /// <summary>Hit when the user selects to launch the URL in the browser.</summary>
        /// <param name="sender">MenuItem</param>
        /// <param name="e">RoutedEventArgs</param>
        private void mnuOpenWeb_Click(object sender, RoutedEventArgs e)
        {
            e.Handled = true;

            //We need to get the URL, and then launch it.
            string strUrl = ((SpiraProject)this.ArtifactParentProject.ArtifactTag).ServerURL.ToString();

            Business.SpiraTeam_Client.ImportExportClient client = StaticFuncs.CreateClient(strUrl);

            if (this.ArtifactType != ArtifactTypeEnum.None)
            {
                string strArtUrl = client.System_GetArtifactUrl((int)this.ArtifactType, this.ArtifactParentProject.ArtifactId, this.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);
                }
            }
        }
        /// <summary>Refreshes project name if necessary.</summary>
        private void refreshProject()
        {
            //Only run if it's not set.
            if ((this.ProjectName == "Project" || string.IsNullOrEmpty(this.ProjectName)) || this.UserID == -1)
            {
                try
                {
                    SoapServiceClient client = StaticFuncs.CreateClient(this.ServerURL.ToString());

                    //Connect and get the project information.
                    if (client.Connection_Authenticate2(this.UserName, this.UserPass, StaticFuncs.getCultureResource.GetString("app_ReportName")))
                    {
                        //Connected, get project and user information.
                        this.ProjectName = client.Project_RetrieveById(this.ProjectId).Name;
                        this.UserID      = client.User_RetrieveByUserName(this.UserName, false).UserId.Value;
                    }
                }
                catch
                { }
            }
        }