Example #1
0
        public GetMaterialResponse GetMaterialsByType(long materialTypeId)
        {
            GetMaterialResponse materials = new GetMaterialResponse();

            try
            {
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri(((App)App.Current).LAN_Address);
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                client.DefaultRequestHeaders.Add("EO-Header", User + " : " + Pwd);

                HttpResponseMessage httpResponse =
                    client.GetAsync("api/Login/GetMaterialsByType?materialTypeId=" + materialTypeId).Result;
                if (httpResponse.IsSuccessStatusCode)
                {
                    Stream       streamData = httpResponse.Content.ReadAsStreamAsync().Result;
                    StreamReader strReader  = new StreamReader(streamData);
                    string       strData    = strReader.ReadToEnd();
                    strReader.Close();
                    materials = JsonConvert.DeserializeObject <GetMaterialResponse>(strData);
                }
                else
                {
                    MessageBox.Show("There was an error retreiving materials");
                }
            }
            catch (Exception ex)
            {
                Exception ex2 = new Exception("Admin - GetMaterialsByType", ex);
                ((App)App.Current).LogError(ex2.Message, "material type id = " + materialTypeId.ToString());
            }

            return(materials);
        }
Example #2
0
        private void MaterialsByTypeLoaded(long selectedValue, GetMaterialResponse response)
        {
            materials = response.MaterialInventoryList;

            ObservableCollection <KeyValuePair <long, string> > list2 = new ObservableCollection <KeyValuePair <long, string> >();

            foreach (MaterialInventoryDTO resp in materials)
            {
                list2.Add(new KeyValuePair <long, string>(resp.Material.MaterialId, resp.Material.MaterialName));
            }

            ObservableCollection <MaterialInventoryDTO> mDTO = new ObservableCollection <MaterialInventoryDTO>();

            foreach (MaterialInventoryDTO m in materials.Where(a => a.Material.MaterialTypeId == selectedValue))
            {
                mDTO.Add(m);
            }

            Device.BeginInvokeOnMainThread(() =>
            {
                MaterialName.ItemsSource = list2;

                materialListView.ItemsSource = mDTO;
            });
        }
        private GetMaterialResponse GetMaterials()
        {
            GetMaterialResponse materials = new GetMaterialResponse();

            try
            {
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri("http://localhost:9000/");
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                client.DefaultRequestHeaders.Add("EO-Header", wnd.User + " : " + wnd.Pwd);

                HttpResponseMessage httpResponse =
                    client.GetAsync("api/Login/GetMaterials").Result;
                if (httpResponse.IsSuccessStatusCode)
                {
                    Stream       streamData = httpResponse.Content.ReadAsStreamAsync().Result;
                    StreamReader strReader  = new StreamReader(streamData);
                    string       strData    = strReader.ReadToEnd();
                    strReader.Close();
                    materials = JsonConvert.DeserializeObject <GetMaterialResponse>(strData);
                }
                else
                {
                    MessageBox.Show("There was an error retreiving materials");
                }
            }
            catch (Exception ex)
            {
            }

            return(materials);
        }
Example #4
0
        public async Task <GetMaterialResponse> GetMaterialsByType(long typeId)
        {
            GenericGetRequest   request  = new GenericGetRequest("GetMaterialsByType", "materialTypeId", typeId);
            GetMaterialResponse response = await GetRequest <GetMaterialResponse>(request);

            return(response);
        }
Example #5
0
        public async Task <GetMaterialResponse> GetMaterials()
        {
            GenericGetRequest   request  = new GenericGetRequest("GetMaterials", String.Empty, 0);
            GetMaterialResponse response = await GetRequest <GetMaterialResponse>(request);

            return(response);
        }
Example #6
0
        private void MaterialsLoaded(GetMaterialResponse response)
        {
            materials = response.MaterialInventoryList;

            foreach (MaterialInventoryDTO m in materials)
            {
                list2.Add(m);
            }

            Device.BeginInvokeOnMainThread(() =>
            {
                materialListView.ItemsSource = list2;
            });
        }
Example #7
0
        public static GetMaterialResponse Unmarshall(UnmarshallerContext context)
        {
            GetMaterialResponse getMaterialResponse = new GetMaterialResponse();

            getMaterialResponse.HttpResponse = context.HttpResponse;
            getMaterialResponse.RequestId    = context.StringValue("GetMaterial.RequestId");

            GetMaterialResponse.GetMaterial_Material material = new GetMaterialResponse.GetMaterial_Material();
            material.MaterialId  = context.StringValue("GetMaterial.Material.MaterialId");
            material.Title       = context.StringValue("GetMaterial.Material.Title");
            material.Tags        = context.StringValue("GetMaterial.Material.Tags");
            material.Status      = context.StringValue("GetMaterial.Material.Status");
            material.Size        = context.LongValue("GetMaterial.Material.Size");
            material.Duration    = context.FloatValue("GetMaterial.Material.Duration");
            material.Description = context.StringValue("GetMaterial.Material.Description");
            material.CustomerId  = context.LongValue("GetMaterial.Material.CustomerId");
            material.CreateTime  = context.StringValue("GetMaterial.Material.CreateTime");
            material.ModifyTime  = context.StringValue("GetMaterial.Material.ModifyTime");
            material.CoverURL    = context.StringValue("GetMaterial.Material.CoverURL");
            material.CateId      = context.IntegerValue("GetMaterial.Material.CateId");
            material.CateName    = context.StringValue("GetMaterial.Material.CateName");
            material.Source      = context.StringValue("GetMaterial.Material.Source");

            List <string> material_snapshots = new List <string>();

            for (int i = 0; i < context.Length("GetMaterial.Material.Snapshots.Length"); i++)
            {
                material_snapshots.Add(context.StringValue("GetMaterial.Material.Snapshots[" + i + "]"));
            }
            material.Snapshots = material_snapshots;

            List <string> material_tiles = new List <string>();

            for (int i = 0; i < context.Length("GetMaterial.Material.Tiles.Length"); i++)
            {
                material_tiles.Add(context.StringValue("GetMaterial.Material.Tiles[" + i + "]"));
            }
            material.Tiles = material_tiles;
            getMaterialResponse.Material = material;

            return(getMaterialResponse);
        }
        private void MaterialsByTypeLoaded(ObservableCollection <ArrangementInventoryFilteredItem> list1, string name, string size, GetMaterialResponse response)
        {
            materials = response.MaterialInventoryList;

            List <MaterialInventoryDTO> filtered = new List <MaterialInventoryDTO>();

            filtered.AddRange(materials);

            if (!String.IsNullOrEmpty(name))
            {
                filtered = materials.Where(a => a.Material.MaterialName.Contains(name)).ToList();
            }

            foreach (MaterialInventoryDTO m in filtered)
            {
                list1.Add(new ArrangementInventoryFilteredItem()
                {
                    Id              = m.Inventory.InventoryId,
                    Type            = m.Inventory.InventoryName,
                    InventoryTypeId = m.Inventory.InventoryTypeId,
                    Name            = m.Material.MaterialName,
                    Size            = m.Material.MaterialSize,
                    ServiceCodeId   = m.Inventory.ServiceCodeId,
                    ServiceCode     = m.Inventory.ServiceCodeName,
                    ImageId         = m.ImageId
                });
            }

            Device.BeginInvokeOnMainThread(() =>
            {
                ArrangementInventoryList.ItemsSource = list1;
            });
        }