/// <summary>Hit when the user wants to merge their changes with the concurrent task.</summary> /// <param name="sender">btnConcurrencyMergeYes</param> /// <param name="e">RoutedEventArgs</param> private void btnConcurrencyMergeYes_Click(object sender, RoutedEventArgs e) { try { e.Handled = true; //Get the client. ImportExportClient client = ((dynamic)sender).Tag as ImportExportClient; if (client != null) { //Switch screens again... this.display_SetOverlayWindow(this.panelSaving, System.Windows.Visibility.Visible); this.display_SetOverlayWindow(this.panelError, System.Windows.Visibility.Hidden); this.barSavingReq.Value--; //Re-launch the saving.. RemoteRequirement reqMerged = StaticFuncs.MergeWithConcurrency(this.save_GetFromFields(), this._Requirement, this._RequirementConcurrent); this._clientNumSaving++; client.Requirement_UpdateAsync(reqMerged, this._clientNum++); } } catch (Exception ex) { Logger.LogMessage(ex, "btnConcurrencyMergeYes_Click()"); MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <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 if we hit a concurrency issue, and have to compare values.</summary> /// <param name="sender">ImportExportClient</param> /// <param name="e">Incident_RetrieveByIdCompletedEventArgs</param> private void client_Requirement_RetrieveByIdCompleted(object sender, Requirement_RetrieveByIdCompletedEventArgs e) { const string METHOD = CLASS + "client_Requirement_RetrieveByIdCompleted()"; Logger.LogTrace_EnterMethod(METHOD + " " + this._clientNumSaving.ToString() + " clients running."); try { ImportExportClient client = (sender as ImportExportClient); this._clientNumSaving--; this.barSavingReq.Value++; if (!e.Cancelled) { if (e.Error == null) { //We got new information here. Let's see if it can be merged. bool canBeMerged = this.save_CheckIfConcurrencyCanBeMerged(e.Result); this._RequirementConcurrent = e.Result; if (canBeMerged) { this.gridLoadingError.Visibility = System.Windows.Visibility.Collapsed; this.gridSavingConcurrencyMerge.Visibility = System.Windows.Visibility.Visible; this.gridSavingConcurrencyNoMerge.Visibility = System.Windows.Visibility.Collapsed; this.display_SetOverlayWindow(this.panelSaving, System.Windows.Visibility.Hidden); this.display_SetOverlayWindow(this.panelError, System.Windows.Visibility.Visible); //Save the client to the 'Merge' button. this.btnConcurrencyMergeYes.Tag = sender; } else { //TODO: Display error message here, tell users they must refresh their data. this.gridLoadingError.Visibility = System.Windows.Visibility.Collapsed; this.gridSavingConcurrencyMerge.Visibility = System.Windows.Visibility.Collapsed; this.gridSavingConcurrencyNoMerge.Visibility = System.Windows.Visibility.Visible; this.display_SetOverlayWindow(this.panelSaving, System.Windows.Visibility.Hidden); this.display_SetOverlayWindow(this.panelError, System.Windows.Visibility.Visible); } } else { //We even errored on retrieving information. Somethin's really wrong here. //Display error. Logger.LogMessage(e.Error, "Getting updated Concurrency Incident"); } } } catch (Exception ex) { Logger.LogMessage(ex, METHOD); MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error); } Logger.LogTrace_ExitMethod(METHOD + " " + this._clientNumSaving.ToString() + " clients left."); }
/// <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>Creates a web client for use.</summary> /// <param name="serverAddress">The base address of the server.</param> /// <returns>ImportExportClient</returns> public static ImportExportClient CreateClient(string serverAddress) { ImportExportClient retClient = null; try { //The endpoint address. EndpointAddress EndPtAddr = new EndpointAddress(new Uri(serverAddress + Settings.Default.app_ServiceURI)); //Create the soap client. BasicHttpBinding wsDualHttp = new BasicHttpBinding(); wsDualHttp.CloseTimeout = TimeSpan.FromMinutes(1); wsDualHttp.OpenTimeout = TimeSpan.FromMinutes(1); wsDualHttp.ReceiveTimeout = TimeSpan.FromMinutes(1); wsDualHttp.SendTimeout = TimeSpan.FromMinutes(1); wsDualHttp.BypassProxyOnLocal = false; wsDualHttp.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; wsDualHttp.MaxBufferPoolSize = Int32.MaxValue; wsDualHttp.MaxReceivedMessageSize = Int32.MaxValue; wsDualHttp.MessageEncoding = WSMessageEncoding.Text; wsDualHttp.TextEncoding = Encoding.UTF8; wsDualHttp.UseDefaultWebProxy = true; wsDualHttp.ReaderQuotas.MaxDepth = Int32.MaxValue; wsDualHttp.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; wsDualHttp.ReaderQuotas.MaxArrayLength = Int32.MaxValue; wsDualHttp.ReaderQuotas.MaxBytesPerRead = Int32.MaxValue; wsDualHttp.ReaderQuotas.MaxNameTableCharCount = Int32.MaxValue; wsDualHttp.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.Certificate; wsDualHttp.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default; wsDualHttp.Security.Mode = BasicHttpSecurityMode.None; wsDualHttp.AllowCookies = true; wsDualHttp.TransferMode = TransferMode.Streamed; //Configure for alternative connection types. if (EndPtAddr.Uri.Scheme == "https") { wsDualHttp.Security.Mode = BasicHttpSecurityMode.Transport; wsDualHttp.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; //Allow self-signed certificates Inflectra.SpiraTest.IDEIntegration.VisualStudio2012.Business.Spira_ImportExport.PermissiveCertificatePolicy.Enact(""); } retClient = new SpiraTeam_Client.ImportExportClient(wsDualHttp, EndPtAddr); } catch (Exception ex) { Logger.LogMessage(ex); retClient = null; } return(retClient); }
/// <summary>Hit when we're authenticated to the server.</summary> /// <param name="sender">ImportExportClient</param> /// <param name="e">Connection_Authenticate2CompletedEventArgs</param> private void clientSave_Connection_Authenticate2Completed(object sender, Connection_Authenticate2CompletedEventArgs e) { const string METHOD = CLASS + "clientSave_Connection_Authenticate2Completed()"; Logger.LogTrace_EnterMethod(METHOD + " " + this._clientNumSaving.ToString() + " clients running."); try { ImportExportClient client = (sender as ImportExportClient); this._clientNumSaving--; this.barSavingReq.Value++; if (!e.Cancelled) { if (e.Error == null) { if (e.Result) { //Connect to the progect ID. this._clientNumSaving++; client.Connection_ConnectToProjectAsync(((SpiraProject)this._ArtifactDetails.ArtifactParentProject.ArtifactTag).ProjectID, this._clientNum++); } else { //TODO: Show Error. //Cancel calls. this._clientNumSaving++; client.Connection_DisconnectAsync(this._clientNum++); } } else { //TODO: Show Error. //Cancel calls. this._clientNumSaving++; client.Connection_DisconnectAsync(this._clientNum++); } } //See if it's okay to reload. this.save_CheckIfOkayToLoad(); } catch (Exception ex) { Logger.LogMessage(ex, METHOD); MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error); } Logger.LogTrace_ExitMethod(METHOD + " " + this._clientNumSaving.ToString() + " clients left."); }
/// <summary>Hit when we've completed connecting to the project. </summary> /// <param name="sender">ImportExporClient</param> /// <param name="e">Connection_ConnectToProjectCompletedEventArgs</param> private void wkfClient_Connection_ConnectToProjectCompleted(object sender, Connection_ConnectToProjectCompletedEventArgs e) { try { const string METHOD = CLASS + "wkfClient_Connection_ConnectToProjectCompleted()"; Logger.LogTrace(METHOD + " ENTER."); this._clientNumRunning--; this.barLoadingIncident.Value++; if (sender is ImportExportClient) { ImportExportClient client = sender as ImportExportClient; if (!e.Cancelled) { if (e.Error == null && e.Result) { //Get the current status/type.. int intStatus = ((this._IncSelectedStatus.HasValue) ? this._IncSelectedStatus.Value : this._IncCurrentStatus.Value); int intType = ((this._IncSelectedType.HasValue) ? this._IncSelectedType.Value : this._IncCurrentType.Value); //Get the current workflow fields here. this._clientNumRunning += 2; client.Incident_RetrieveWorkflowCustomPropertiesAsync(intType, intStatus, this._clientNum++); client.Incident_RetrieveWorkflowFieldsAsync(intType, intStatus, this._clientNum++); } else { if (e.Error != null) { Logger.LogMessage(e.Error); } else { Logger.LogMessage(METHOD, "Could not log in.", System.Diagnostics.EventLogEntryType.Error); } } } } Logger.LogTrace_ExitMethod(METHOD + " Clients - Running: " + this._clientNumRunning.ToString() + ", Total: " + this._clientNum.ToString()); } catch (Exception ex) { Logger.LogMessage(ex, "wkfClient_Connection_ConnectToProjectCompleted()"); MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error); } }
public TestBase(string baseUrlPrefix) { Http = new HttpStub(); var connection = new IS24Connection { HttpFactory = new HttpFactory(Http), BaseUrlPrefix = baseUrlPrefix, AccessToken = "AccessToken", AccessTokenSecret = "AccessTokenSecret", ConsumerKey = "ConsumerKey", ConsumerSecret = "ConsumerSecret" }; Client = new ImportExportClient(connection); }
/// <summary>Hit when we've successfully connected to the server.</summary> /// <param name="sender">ImportExporClient</param> /// <param name="e">Connection_Authenticate2CompletedEventArgs</param> private void wkfClient_Connection_Authenticate2Completed(object sender, Connection_Authenticate2CompletedEventArgs e) { try { const string METHOD = CLASS + "wkfClient_Connection_Authenticate2Completed()"; Logger.LogTrace(METHOD + " ENTER."); this._clientNumRunning--; this.barLoadingIncident.Value++; if (sender is ImportExportClient) { ImportExportClient client = sender as ImportExportClient; if (!e.Cancelled) { if (e.Error == null && e.Result) { //Connect to our project. this._clientNumRunning++; client.Connection_ConnectToProjectAsync(((SpiraProject)this._ArtifactDetails.ArtifactParentProject.ArtifactTag).ProjectID, this._clientNum++); } else { if (e.Error != null) { Logger.LogMessage(e.Error); } else { Logger.LogMessage(METHOD, "Could not log in.", System.Diagnostics.EventLogEntryType.Error); } } } } Logger.LogTrace_ExitMethod(METHOD + " Clients - Running: " + this._clientNumRunning.ToString() + ", Total: " + this._clientNum.ToString()); } catch (Exception ex) { Logger.LogMessage(ex, "wkfClient_Connection_Authenticate2Completed()"); MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <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 { ImportExportClient 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).UserId.Value; } } catch { } } }
/// <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); } }
/// <summary>Hit when we're finished adding a resolution.</summary> /// <param name="sender">ImportExportClient</param> /// <param name="e">Incident_AddResolutionsCompletedEventArgs</param> private void clientSave_Requirement_CreateCommentCompleted(object sender, Requirement_CreateCommentCompletedEventArgs e) { const string METHOD = CLASS + "clientSave_Requirement_CreateCommentCompleted()"; Logger.LogTrace_EnterMethod(METHOD + " " + this._clientNumSaving.ToString() + " clients running."); try { ImportExportClient client = (sender as ImportExportClient); this._clientNumSaving--; this.barSavingReq.Value++; if (!e.Cancelled) { if (e.Error != null) { //Log message. Logger.LogMessage(e.Error, "Adding Comment to Requirement"); //Display error that the item saved, but adding the new resolution didn't. MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_AddCommentErrorMessage"), StaticFuncs.getCultureResource.GetString("app_General_UpdateError"), MessageBoxButton.OK, MessageBoxImage.Error); } //Regardless of what happens, we're disconnecting here. this._clientNumSaving++; client.Connection_DisconnectAsync(this._clientNum++); } //See if it's okay to reload. this.save_CheckIfOkayToLoad(); } catch (Exception ex) { Logger.LogMessage(ex, METHOD); MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error); } Logger.LogTrace(METHOD + " " + this._clientNumSaving.ToString() + " clients left."); }
public async Task NotifyAsync(TeamFoundationRequestContext requestContext, INotification notification, BotElement bot, EventRuleElement matchingRule) { string URL = bot.GetSetting("spiraURL"); string user = bot.GetSetting("spiraUser"); string password = bot.GetSetting("spiraPassw"); string projVers = bot.GetSetting("spiraPvers"); string projNumber = bot.GetSetting("spiraPnumber"); int status = 0; int projectId; Int32.TryParse(projNumber, out projectId); //Check that it is the correct kind of notification if (notification is BuildCompletionNotification) { BuildCompletionNotification buildCompletionNotification = (BuildCompletionNotification)notification; if (buildCompletionNotification.IsSuccessful) { status = 2; //sucess } else if (buildCompletionNotification.BuildStatus.ToString() == "Failed") { status = 1; //failed } else if (buildCompletionNotification.BuildStatus.ToString() == "PartiallySucceeded") { status = 3; //unstable } else if (buildCompletionNotification.BuildStatus.ToString() == "Stopped") { status = 4; //aborted } else { TeamFoundationApplicationCore.Log(requestContext, ":: SpiraTeam Plugin for TFS:: The current build finished with a not supported" + " status, please check TFS logs to see detailed information.", 0, EventLogEntryType.Warning); } DateTime date = buildCompletionNotification.StartTime; String sname = buildCompletionNotification.ProjectName + " #" + buildCompletionNotification.BuildNumber; String description = ("Information retrieved from TFS : Build requested by " + buildCompletionNotification.UserName + "<br/> from Team " + buildCompletionNotification.TeamNames + "<br/> and project collection " + buildCompletionNotification.TeamProjectCollection + "<br/> for " + sname + "<br/> with URL " + buildCompletionNotification.BuildUrl + "<br/> located at " + buildCompletionNotification.DropLocation + "<br/> Build Started at " + buildCompletionNotification.StartTime + "<br/> Build finished at " + buildCompletionNotification.FinishTime + "<br/> Status " + buildCompletionNotification.BuildStatus); //List<int> incidentIds; var locationService = requestContext.GetService <TeamFoundationLocationService>(); string baseUrl = String.Format("{0}/", locationService.GetAccessMapping(requestContext, "PublicAccessMapping").AccessPoint); TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(baseUrl)); VersionControlServer sourceControl = tpc.GetService <VersionControlServer>(); int revisionId = sourceControl.GetLatestChangesetId(); //SPIRA CODE Uri uri = new Uri(URL + URL_SUFFIX); ImportExportClient spiraClient = SpiraClientFactory.CreateClient(uri); bool success = spiraClient.Connection_Authenticate2(user, password, "TFS Notifier for SpiraTeam v. 1.0.0"); if (!success) { TeamFoundationApplicationCore.Log(requestContext, ":: SpiraTeam Plugin for TFS :: Unable to connect to the Spira server, please verify" + " the provided information in the configuration file.", 0, EventLogEntryType.Error); } success = spiraClient.Connection_ConnectToProject(projectId); if (!success) { TeamFoundationApplicationCore.Log(requestContext, ":: SpiraTeam Plugin for TFS :: The project Id you specified either does not exist," + "or your user does not have access to it! Please verify the configuration file.", 0, EventLogEntryType.Error); } RemoteRelease[] releases = spiraClient.Release_Retrieve(true); RemoteRelease release = releases.FirstOrDefault(r => r.VersionNumber == projVers); if (release != null) { List <RemoteBuildSourceCode> revisions = new List <RemoteBuildSourceCode>(); RemoteBuildSourceCode revision = new RemoteBuildSourceCode(); revision.RevisionKey = revisionId.ToString(); revisions.Add(revision); RemoteBuild newBuild = new RemoteBuild(); newBuild.Name = sname; newBuild.BuildStatusId = status; newBuild.Description = description; newBuild.CreationDate = date; newBuild.Revisions = revisions.ToArray(); newBuild.ReleaseId = release.ReleaseId.Value; spiraClient.Build_Create(newBuild); await Task.Delay(10); } else { TeamFoundationApplicationCore.Log(requestContext, ":: SpiraTeam Plugin for TFS :: The release version number you specified does not " + "exist in the current project! Please verify the configuration file.", 0, EventLogEntryType.Error); } } }
private static async Task TestAsync(Config config) { var connection = new IS24Connection { ConsumerKey = config.ConsumerKey, ConsumerSecret = config.ConsumerSecret, AccessToken = config.AccessToken, AccessTokenSecret = config.AccessSecret, BaseUrlPrefix = @"https://rest.sandbox-immobilienscout24.de/restapi/api" }; var searchResource = new SearchResource(connection); var query = new RadiusQuery { Latitude = 52.49023, Longitude = 13.35939, Radius = 1, RealEstateType = RealEstateType.APARTMENT_RENT, Parameters = new { Price = new DecimalRange { Max = 1000 }, LivingSpace = new DecimalRange { Min = 100 }, NumberOfRooms = new DecimalRange { Min = 4 }, Equipment = "balcony" }, Channel = new HomepageChannel("me") }; var results = await searchResource.Search(query); var api = new ImportExportClient(connection); RealtorContactDetails contact = null; try { contact = await api.Contacts.GetAsync("Hans Meiser", isExternal : true); } catch (IS24Exception ex) { if (ex.Messages.Message.First().MessageCode != MessageCode.ERROR_RESOURCE_NOT_FOUND) { throw; } } if (contact == null) { contact = new RealtorContactDetails { Lastname = "Meiser", Firstname = "Hans", Address = new Address { Street = "Hauptstraße", HouseNumber = "1", Postcode = "10827", City = "Berlin", InternationalCountryRegion = new CountryRegion { Country = CountryCode.DEU, Region = "Berlin" } }, Email = "*****@*****.**", ExternalId = "Hans Meiser" }; await api.Contacts.CreateAsync(contact); contact.Address.HouseNumber = "1a"; await api.Contacts.UpdateAsync(contact); } IRealEstate realEstate = null; try { realEstate = await api.RealEstates.GetAsync("Hauptstraße 1", isExternal : true); } catch (IS24Exception ex) { if (ex.Messages.Message.First().MessageCode != MessageCode.ERROR_RESOURCE_NOT_FOUND) { throw; } } if (realEstate == null) { var re = new ApartmentRent { Contact = new RealEstateContact { Id = contact.Id }, ExternalId = "Hauptstraße 1", Title = "IS24RestApi Test", Address = new Wgs84Address { Street = "Hauptstraße", HouseNumber = "1", City = "Berlin", Postcode = "10827" }, BaseRent = 500.0, LivingSpace = 100.0, NumberOfRooms = 4.0, ShowAddress = true, Courtage = new CourtageInfo { HasCourtage = YesNoNotApplicableType.NO } }; await api.RealEstates.CreateAsync(re); re.BaseRent += 100.0; await api.RealEstates.UpdateAsync(re); realEstate = new RealEstateItem(re, connection); } else { var re = (ApartmentRent)realEstate.RealEstate; re.BaseRent += 100.0; await api.RealEstates.UpdateAsync(re); re.BaseRent -= 100.0; await api.RealEstates.UpdateAsync(re); } var projects = await api.RealEstateProjects.GetAllAsync(); if (projects.RealEstateProject.Any()) { var project = projects.RealEstateProject.First(); var entries = await api.RealEstateProjects.GetAllAsync(project.Id.Value); if (!entries.RealEstateProjectEntry.Any(e => e.RealEstateId.Value == realEstate.RealEstate.Id.Value)) { await api.RealEstateProjects.AddAsync(project.Id.Value, realEstate.RealEstate); } } var placement = await realEstate.PremiumPlacements.GetAsync(); var a1 = new KeyValuePair <Attachment, string>(new Picture { Title = "Zimmer 1", Floorplan = false, TitlePicture = true }, @"..\..\..\test.jpg"); var a2 = new KeyValuePair <Attachment, string>(new Picture { Title = "Zimmer 2" }, @"..\..\..\test.jpg"); var a3 = new KeyValuePair <Attachment, string>(new Picture { Title = "Zimmer 3" }, @"..\..\..\test.jpg"); var pdf = new KeyValuePair <Attachment, string>(new PDFDocument { Title = "Test" }, @"..\..\..\test.pdf"); var video = new KeyValuePair <Attachment, string>(new StreamingVideo { Title = "Video" }, @"..\..\..\test.avi"); var link = new KeyValuePair <Attachment, string>(new Link { Title = "Test", Url = "http://www.example.com/" }, null); var atts = new[] { video, a1, pdf, a2, link, a3 }; await realEstate.Attachments.UpdateAsync(atts); var res = new List <RealEstate>(); await api.RealEstates.GetAsync().ForEachAsync(x => res.Add(x.RealEstate)); }
public void Ctor_ConnectionMock_RealEstatesConnectionIsSet() { var client = new ImportExportClient(connection); Assert.Equal(connection, client.RealEstates.Connection); }
public void Ctor_ConnectionMock_PublishConnectionIsSet() { var client = new ImportExportClient(connection); Assert.Equal(connection, client.Publish.Connection); }
public void Ctor_ConnectionMock_ConnectionConnectionMock() { var client = new ImportExportClient(connection); Assert.Equal(connection, client.Connection); }
/// <summary>Hit when we're finished updating the main information.</summary> /// <param name="sender">ImportExportClient</param> /// <param name="e">AsyncCompletedEventArgs</param> private void clientSave_Requirement_UpdateCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { const string METHOD = CLASS + "clientSave_Requirement_UpdateCompleted()"; Logger.LogTrace_EnterMethod(METHOD + " " + this._clientNumSaving.ToString() + " running."); try { ImportExportClient client = (sender as ImportExportClient); this._clientNumSaving--; this.barSavingReq.Value++; if (!e.Cancelled) { if (e.Error == null) { //See if we need to add a resolution. if (this._isResChanged) { //We need to save a resolution. RemoteComment newRes = new RemoteComment(); newRes.CreationDate = DateTime.Now.ToUniversalTime(); newRes.UserId = ((SpiraProject)this._ArtifactDetails.ArtifactParentProject.ArtifactTag).UserID; newRes.ArtifactId = this._ArtifactDetails.ArtifactId; newRes.Text = this.cntrlResolution.HTMLText; this._clientNumSaving++; client.Requirement_CreateCommentAsync(newRes, this._clientNum++); } else { //We're finished. this.barSavingReq.Value++; this._clientNumSaving++; client.Connection_DisconnectAsync(this._clientNum++); } } else { //Log error. Logger.LogMessage(e.Error, "Saving Incident Changes to Database"); //If we get a concurrency error, get the current data. if (e.Error is FaultException <ServiceFaultMessage> && ((FaultException <ServiceFaultMessage>)e.Error).Detail.Type == "DataAccessConcurrencyException") { client.Requirement_RetrieveByIdCompleted += new EventHandler <Requirement_RetrieveByIdCompletedEventArgs>(client_Requirement_RetrieveByIdCompleted); //Fire it off. this._clientNumSaving++; client.Requirement_RetrieveByIdAsync(this._ArtifactDetails.ArtifactId, this._clientNum++); } else { //Display the error screen here. //Cancel calls. this._clientNumSaving++; client.Connection_DisconnectAsync(this._clientNum++); } } } //See if it's okay to reload. this.save_CheckIfOkayToLoad(); } catch (Exception ex) { Logger.LogMessage(ex, METHOD); MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error); } Logger.LogTrace_ExitMethod(METHOD + " " + this._clientNumSaving.ToString() + " clients left."); }
public void Ctor_ConnectionMock_ContactsConnectionIsSet() { var client = new ImportExportClient(connection); Assert.Equal(connection, client.Contacts.Connection); }
/// <summary>Hit when we're finished connecting to the project.</summary> /// <param name="sender">ImportExportClient</param> /// <param name="e">Connection_ConnectToProjectCompletedEventArgs</param> private void clientSave_Connection_ConnectToProjectCompleted(object sender, Connection_ConnectToProjectCompletedEventArgs e) { const string METHOD = CLASS + "clientSave_Connection_ConnectToProjectCompleted()"; Logger.LogTrace_EnterMethod(METHOD + " " + this._clientNumSaving.ToString() + " clients running."); try { ImportExportClient client = (sender as ImportExportClient); this._clientNumSaving--; this.barSavingReq.Value++; if (!e.Cancelled) { if (e.Error == null) { if (e.Result) { //Get the new RemoteIncident RemoteRequirement newRequirement = this.save_GetFromFields(); if (newRequirement != null) { //Fire off our update calls. this._clientNumSaving++; client.Requirement_UpdateAsync(newRequirement, this._clientNum++); } else { //TODO: Show Error. //Cancel calls. this._clientNumSaving++; client.Connection_DisconnectAsync(this._clientNum++); } } else { //TODO: Show Error. //Cancel calls. this._clientNumSaving++; client.Connection_DisconnectAsync(this._clientNum++); } } else { //TODO: Show Error. //Cancel calls. this._clientNumSaving++; client.Connection_DisconnectAsync(this._clientNum++); } } //See if it's okay to reload. this.save_CheckIfOkayToLoad(); } catch (Exception ex) { Logger.LogMessage(ex, METHOD); MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error); } Logger.LogTrace_ExitMethod(METHOD + " " + this._clientNumSaving.ToString() + " clients left."); }
private static async Task TestAsync() { var config = RestSharp.SimpleJson.DeserializeObject <Config>(File.ReadAllText("config.json")); var connection = new IS24Connection { ConsumerKey = config.ConsumerKey, ConsumerSecret = config.ConsumerSecret, AccessToken = config.AccessToken, AccessTokenSecret = config.AccessSecret, BaseUrlPrefix = @"http://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0" }; var api = new ImportExportClient(connection); RealtorContactDetails contact = null; try { contact = await api.Contacts.GetAsync("Hans Meiser", isExternal : true); } catch (IS24Exception ex) { if (ex.Messages.message.First().messageCode != MessageCode.ERROR_RESOURCE_NOT_FOUND) { throw; } } if (contact == null) { contact = new RealtorContactDetails { lastname = "Meiser", firstname = "Hans", email = "*****@*****.**", address = new Address { street = "Hauptstraße", houseNumber = "1", postcode = "10827", city = "Berlin", internationalCountryRegion = new CountryRegion { country = CountryCode.DEU, region = "Berlin" } }, externalId = "Hans Meiser" }; await api.Contacts.CreateAsync(contact); contact.address.houseNumber = "1a"; await api.Contacts.UpdateAsync(contact); } IRealEstate realEstate = null; try { realEstate = await api.RealEstates.GetAsync("Hauptstraße 1", isExternal : true); } catch (IS24Exception ex) { if (ex.Messages.message.First().messageCode != MessageCode.ERROR_RESOURCE_NOT_FOUND) { throw; } } if (realEstate == null) { var re = new ApartmentRent { contact = new RealEstateContact { id = contact.id, idSpecified = true }, externalId = "Hauptstraße 1", title = "IS24RestApi Test", address = new Wgs84Address { street = "Hauptstraße", houseNumber = "1", city = "Berlin", postcode = "10827" }, baseRent = 500.0, livingSpace = 100.0, numberOfRooms = 4.0, showAddress = true, courtage = new CourtageInfo { hasCourtage = YesNoNotApplicableType.NO } }; await api.RealEstates.CreateAsync(re); re.baseRent += 100.0; await api.RealEstates.UpdateAsync(re); realEstate = new RealEstateItem(re, connection); } var atts = await realEstate.Attachments.GetAsync(); if (atts == null || !atts.Any()) { var att = new Picture { floorplan = false, titlePicture = true, title = "Zimmer", }; await realEstate.Attachments.CreateAsync(att, @"..\..\test.jpg"); att.title = "Zimmer 1"; await realEstate.Attachments.UpdateAsync(att); } await api.Publish.PublishAsync(realEstate.RealEstate); await api.Publish.UnpublishAsync(realEstate.RealEstate); var res = new List <RealEstate>(); await api.RealEstates.GetAsync().ForEachAsync(x => res.Add(x.RealEstate)); }
public void Ctor_ConnectionMock_PublishChannelsConnectionIsSet() { var client = new ImportExportClient(connection); Assert.Equal(connection, client.PublishChannels.Connection); }