Example #1
0
        public async Task <ActionResult <DataElementList> > GetMany(int instanceOwnerPartyId, Guid instanceGuid)
        {
            string instanceId = $"{instanceOwnerPartyId}/{instanceGuid}";

            if (instanceOwnerPartyId == 0)
            {
                return(BadRequest("Missing parameter value: instanceOwnerPartyId can not be empty"));
            }

            // check if instance id exist and user is allowed to change the instance data
            (Instance instance, ActionResult errorResult) = await GetInstanceAsync(instanceId, instanceOwnerPartyId);

            if (instance == null)
            {
                return(errorResult);
            }

            List <DataElement> dataElements;

            dataElements = await _dataRepository.ReadAll(instanceGuid);

            DataElementList dataElementList = new DataElementList {
                DataElements = dataElements
            };

            return(Ok(dataElementList));
        }
Example #2
0
        public async Task <ActionResult <DataElementList> > ConfirmDownloadAll(int instanceOwnerPartyId, Guid instanceGuid)
        {
            List <DataElement> dataElements = await _dataRepository.ReadAll(instanceGuid);

            // check if data has been downloaded
            foreach (DataElement element in dataElements)
            {
                // check if it has been downloaded
                List <DateTime> downloaded = element.AppOwner?.Downloaded;
                if (downloaded == null || downloaded.Count == 0)
                {
                    return(Conflict($"Data element {instanceOwnerPartyId}/{instanceGuid}/data/{element.Id} is not recorded downloaded by app owner. Please download first."));
                }
            }

            List <DataElement> resultElements = new List <DataElement>();

            foreach (DataElement element in dataElements)
            {
                DataElement updatedElement = await SetConfirmedDataAndUpdateDataElement(element, DateTime.UtcNow);

                resultElements.Add(updatedElement);
            }

            DataElementList dataElementList = new DataElementList {
                DataElements = resultElements
            };

            return(Ok(dataElementList));
        }
Example #3
0
        public async void Put_ConfirmDownload_OnAllData_Ok()
        {
            if (!blobSetup)
            {
                await EnsureValidStorage();
            }

            List <DataElement> dataElements = await CreateInstanceWithData(2);

            Assert.NotNull(dataElements);

            string instanceId = $"{testInstanceOwnerId}/{dataElements[0].InstanceGuid}";

            string      dataPathWithData = $"{versionPrefix}/instances/{instanceId}/dataelements";
            HttpContent content          = new StringContent(string.Empty);

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _validToken);
            HttpResponseMessage getResponse = await client.PutAsync($"{dataPathWithData}/confirmDownload", content);

            getResponse.EnsureSuccessStatusCode();

            string json = await getResponse.Content.ReadAsStringAsync();

            DataElementList actual = JsonConvert.DeserializeObject <DataElementList>(json);

            Assert.Equal(2, actual.DataElements.Count);
            Assert.NotNull(actual.DataElements[0].AppOwner.DownloadConfirmed);
            Assert.NotNull(actual.DataElements[1].AppOwner.DownloadConfirmed);
        }
Example #4
0
        private void LayoutEditor_Load(object sender, EventArgs e)
        {
            doHeader();

            DataElementList dataElements = DataElementList.Standard;

            foreach (DataElement element in dataElements)
            {
                comboFunction.Items.Add(element);
            }

            txtLayoutName.Text = m_LayoutName;
            if (layoutBindingSource.Count > 0)
            {
                layoutBindingSource.Position = 0;
            }
            layoutBindingSource.ResetCurrentItem();
        }