public async Task IncidentCrud() { // Create an incident // // Arrange var testId = Guid.NewGuid().ToString(); var incident = new Incident { Description = "Incident description: " + testId, ShortDescription = "Incident short description: " + testId, }; // Act var createdIncident = await Client.CreateAsync(incident).ConfigureAwait(false); // Assert createdIncident.Should().NotBeNull(); createdIncident.Description.Should().Be("Incident description: " + testId); createdIncident.ShortDescription.Should().Be("Incident short description: " + testId); createdIncident.SysId.Should().NotBeNullOrEmpty(); createdIncident.Number.Should().NotBeNullOrEmpty(); Logger.LogInformation("SysId: " + createdIncident.SysId); Logger.LogInformation("Number: " + createdIncident.Number); // Update an incident // // Arrange var reFetchedIncident = await Client.GetByIdAsync <Incident>(createdIncident.SysId).ConfigureAwait(false); reFetchedIncident.Should().NotBeNull(); reFetchedIncident !.SysId.Should().Be(createdIncident.SysId); // Act reFetchedIncident.Comments = "Some new comment text " + testId; await Client.UpdateAsync(reFetchedIncident).ConfigureAwait(false); reFetchedIncident.Comments = "Some other comment text " + testId; await Client.UpdateAsync(reFetchedIncident).ConfigureAwait(false); // Assert var incidentAfterUpdate = await Client.GetByIdAsync <Incident>(createdIncident.SysId).ConfigureAwait(false); incidentAfterUpdate.Should().NotBeNull(); incidentAfterUpdate !.SysId.Should().Be(createdIncident.SysId); // Delete the incident // await Client.DeleteAsync <Incident>(createdIncident.SysId).ConfigureAwait(false); }
protected override System.Drawing.Image Execute(CodeActivityContext context) { try { string ip = "localhost"; string port = Port.Get <string>(context); string db = dbName.Get <string>(context); string version = Version.Get <string>(context); string group = Group.Get <string>(context); string entity = Entity.Get <string>(context); string function = Function.Get <string>(context); int merchId = MerchId.Get <int>(context); int fpid = FPId.Get <int>(context); int sysId = SysId.Get <int>(context); int formId = FormId.Get <int>(context); string serviceKey = ServiceKey.Get <string>(context); int imageId = ImageId.Get <int>(context); string url = string.Format("http://{0}:{1}/{2}/{3}/{4}/{5}/{6}?MerchId={7}&SysId={8}&FormId={9}&FPId={10}&key={11}&ImageId={12}", ip, port, db, version, group, entity, function, merchId, sysId, formId, fpid, serviceKey, imageId); HttpClient client = new HttpClient(); Task <HttpResponseMessage> message = client.GetAsync(url); message.Wait(); Task <string> messageResult = message.Result.Content.ReadAsStringAsync(); messageResult.Wait(); System.Drawing.Image result = null; byte[] imageByteArray = Convert.FromBase64String(messageResult.Result.Replace("\"", "")); using (MemoryStream stream = new MemoryStream(imageByteArray)) { result = System.Drawing.Image.FromStream(stream); } return(result); } catch (Exception ex) { throw ex; } }