public dynamic Invoke(DynamicViewPoint point, InvokeMemberBinder binder, object[] args) { string location = point.Location; string idValue = args.Length == 1 ? Convert.ToString(args[0]) : ""; GetDataRequest request = new GetDataRequest { Credentials = GetCredentials(), Filter = new DataFilter { Location = location, Criteria = new [] {new FilterEntry {Name = "Id", Value = idValue}}, }, View = new GetDataView { Module = point.AmplaModule }, OutputOptions = new GetDataOutputOptions { ResolveIdentifiers = true }, }; GetDataResponse response = WebServiceClient.GetData(request); List<dynamic> records = new List<dynamic>(); IAmplaBinding binding = new AmplaGetDataBinding(response, records); if (binding.Validate() && binding.Bind()) { return records.FirstOrDefault(); } return null; }
public Task<List<SerializableDynamicObject>> GetDataAsync(Query query) { var request = new GetDataRequest { Query = query }; return _requestTask.Get(request) .Select(x => x.Results.ToList(), _scheduler.Task.TPL); }
public void GetDataWithNoMetaDataReturnsZeroColumns() { SimpleDataWebServiceClient webServiceClient = new SimpleDataWebServiceClient(module, location); webServiceClient.GetViewFunc = ProductionViews.StandardView; GetDataRequest request = new GetDataRequest { Credentials = CreateCredentials(), Filter = new DataFilter { Location = location, Criteria = new FilterEntry[0] }, View = new GetDataView { Context = NavigationContext.Plant, Mode = NavigationMode.Location, Module = AmplaModules.Production }, Metadata = false, OutputOptions = new GetDataOutputOptions { ResolveIdentifiers = false }, }; GetDataResponse response = webServiceClient.GetData(request); Assert.That(response.RowSets, Is.Not.Empty); Assert.That(response.RowSets[0].Columns, Is.Null); }
public void GetData_ResolveIdentifiers_True() { InMemoryRecord record = DowntimeRecords.NewRecord().MarkAsNew(); record.SetFieldIdValue("Cause", "Shutdown", 100); record.SetFieldIdValue("Classification", "Unplanned Process", 200); SimpleDataWebServiceClient webServiceClient = new SimpleDataWebServiceClient(record.Module, record.Location); record.SaveTo(webServiceClient); Assert.That(webServiceClient.DatabaseRecords, Is.Not.Empty); string recordId = Convert.ToString(webServiceClient.DatabaseRecords[0].RecordId); GetDataRequest request = new GetDataRequest { Credentials = CreateCredentials(), Filter = new DataFilter {Location = record.Location, Criteria = new [] { new FilterEntry {Name = "Id", Value = recordId}}}, View = new GetDataView { Context = NavigationContext.Plant, Mode = NavigationMode.Location, Module = AmplaModules.Downtime}, Metadata = true, OutputOptions = new GetDataOutputOptions {ResolveIdentifiers = true} }; GetDataResponse response = webServiceClient.GetData(request); AssertResponseContainsValue(response, "Cause", "Shutdown"); AssertResponseContainsValue(response, "Classification", "Unplanned Process"); }
public void GetDataReturnsLocation() { SimpleDataWebServiceClient webServiceClient = new SimpleDataWebServiceClient(module, location); InMemoryRecord record = ProductionRecords.NewRecord().MarkAsNew(); SubmitDataRequest submitRequest = new SubmitDataRequest { Credentials = CreateCredentials(), SubmitDataRecords = new[] { record.ConvertToSubmitDataRecord() } }; SubmitDataResponse submitResponse = webServiceClient.SubmitData(submitRequest); Assert.That(submitResponse.DataSubmissionResults, Is.Not.Null); Assert.That(submitResponse.DataSubmissionResults.Length, Is.EqualTo(1)); Assert.That(submitResponse.DataSubmissionResults[0].RecordAction, Is.EqualTo(RecordAction.Insert)); Assert.That(submitResponse.DataSubmissionResults[0].SetId, Is.GreaterThan(100)); string recordId = Convert.ToString(submitResponse.DataSubmissionResults[0].SetId); Assert.That(webServiceClient.DatabaseRecords.Count, Is.EqualTo(1)); Assert.That(webServiceClient.DatabaseRecords[0].Location, Is.EqualTo(location)); GetDataRequest request = new GetDataRequest { Credentials = CreateCredentials(), Filter = new DataFilter { Location = record.Location, Criteria = new[] { new FilterEntry { Name = "Id", Value = recordId } } }, View = new GetDataView { Context = NavigationContext.Plant, Mode = NavigationMode.Location, Module = AmplaModules.Production }, Metadata = true, OutputOptions = new GetDataOutputOptions { ResolveIdentifiers = false }, }; GetDataResponse response = webServiceClient.GetData(request); AssertResponseContainsValue(response, "Duration", "90"); AssertResponseContainsValue(response, "Location", location); }