Exemplo n.º 1
0
        public string ComposeMissingImage(object DTO)
        {
            string missingImageHtml = "";

            if (DTO as PlantInventoryDTO != null)
            {
                PlantInventoryDTO piDTO = DTO as PlantInventoryDTO;

                missingImageHtml = "<h1> Plant  Missing Image </h1>" +
                                   "<div> This plant record is missing an image - use the EO Mobile App or EO Admin app to add an appropriate image </div>" +
                                   "<br/>" +
                                   "<div> Plant Information </div>" +
                                   "<div> Plant ID: " + piDTO.Plant.PlantId.ToString() + "</div>" +
                                   "<div> Plant Name: " + piDTO.Plant.PlantName + "</div>" +
                                   "<div> Type Name: " + piDTO.Plant.PlantTypeName + "</div>" +
                                   "<div> Size: " + piDTO.Plant.PlantSize + "</div>";
            }
            else if (DTO as ContainerInventoryDTO != null)
            {
                ContainerInventoryDTO ciDTO = DTO as ContainerInventoryDTO;

                missingImageHtml = "<h1> Container Missing Image </h1>" +
                                   "<div> This container record is missing an image - use the EO Mobile App or EO Admin app to add an appropriate image </div>" +
                                   "<br/>" +
                                   "<div> Container Information </div>" +
                                   "<div> Container ID: " + ciDTO.Container.ContainerId.ToString() + "</div>" +
                                   "<div> Plant Name: " + ciDTO.Container.ContainerName + "</div>" +
                                   "<div> Type Name: " + ciDTO.Container.ContainerTypeName + "</div>" +
                                   "<div> Size: " + ciDTO.Container.ContainerSize + "</div>";
            }
            else if (DTO as MaterialInventoryDTO != null)
            {
                MaterialInventoryDTO miDTO = DTO as MaterialInventoryDTO;

                missingImageHtml = "<h1> Material Missing Image </h1>" +
                                   "<div> This material record is missing an image - use the EO Mobile App or EO Admin app to add an appropriate image </div>" +
                                   "<br/>" +
                                   "<div> Material Information </div>" +
                                   "<div> Material ID: " + miDTO.Material.MaterialId.ToString() + "</div>" +
                                   "<div> Material Name: " + miDTO.Material.MaterialName + "</div>" +
                                   "<div> Type Name: " + miDTO.Material.MaterialTypeName + "</div>" +
                                   "<div> Size: " + miDTO.Material.MaterialSize + "</div>";
            }

            else if (DTO as FoliageInventoryDTO != null)
            {
                FoliageInventoryDTO fiDTO = DTO as FoliageInventoryDTO;

                missingImageHtml = "<h1> Foliage Missing Image </h1>" +
                                   "<div> This foliage record is missing an image - use the EO Mobile App or EO Admin app to add an appropriate image </div>" +
                                   "<br/>" +
                                   "<div> Foliage Information </div>" +
                                   "<div> Foliage ID: " + fiDTO.Foliage.FoliageId.ToString() + "</div>" +
                                   "<div> Foliage Name: " + fiDTO.Foliage.FoliageName + "</div>" +
                                   "<div> Type Name: " + fiDTO.Foliage.FoliageTypeName + "</div>" +
                                   "<div> Size: " + fiDTO.Foliage.FoliageSize + "</div>";
            }

            return(missingImageHtml);
        }
Exemplo n.º 2
0
        private void ShowImage(object sender, RoutedEventArgs e)
        {
            Button            b = sender as Button;
            PlantInventoryDTO plantInventoryDTO = b.CommandParameter as PlantInventoryDTO;

            MainWindow wnd = Application.Current.MainWindow as MainWindow;


            GetByteArrayResponse imageResponse = wnd.GetImage(plantInventoryDTO.ImageId);
            ImageWindow          imageWindow   = new ImageWindow();

            imageWindow.Top  = Application.Current.MainWindow.Top + 200;
            imageWindow.Left = Application.Current.MainWindow.Left + 200;

            if (imageResponse.ImageData != null && imageResponse.ImageData.Length > 0)
            {
                BitmapImage image = new BitmapImage();
                using (var mem = new System.IO.MemoryStream(imageResponse.ImageData))
                {
                    mem.Position = 0;
                    image.BeginInit();
                    image.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
                    image.CacheOption   = BitmapCacheOption.OnLoad;
                    image.StreamSource  = mem;
                    image.EndInit();
                }
                image.Freeze();

                imageWindow.ImageBox.Source = image;
            }

            imageWindow.Owner = wnd;
            imageWindow.ShowDialog();
        }
Exemplo n.º 3
0
        private void DeletePlant(object sender, RoutedEventArgs e)
        {
            Button            b = sender as Button;
            PlantInventoryDTO plantInventoryDTO = b.CommandParameter as PlantInventoryDTO;

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://localhost:9000/");
            //client.DefaultRequestHeaders.Add("appkey", "myapp_key");
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

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

            string jsonData = JsonConvert.SerializeObject(plantInventoryDTO.Plant.PlantId);
            var    content  = new StringContent(jsonData, Encoding.UTF8, "application/json");
            HttpResponseMessage httpResponse = client.PostAsync("api/Login/DeletePlant", content).Result;

            if (httpResponse.IsSuccessStatusCode)
            {
                Stream       streamData = httpResponse.Content.ReadAsStreamAsync().Result;
                StreamReader strReader  = new StreamReader(streamData);
                string       strData    = strReader.ReadToEnd();
                strReader.Close();

                plantList.Remove(plantInventoryDTO);

                list3.Remove(plantInventoryDTO);
                this.PlantInventoryListView.ItemsSource = null;
                this.PlantInventoryListView.ItemsSource = list3;

                //ApiResponse apiResponse = JsonConvert.DeserializeObject<ApiResponse>(strData);

                //if (apiResponse.Messages.Count > 0)
                //{
                //    StringBuilder sb = new StringBuilder();
                //    foreach (KeyValuePair<string, List<string>> messages in apiResponse.Messages)
                //    {
                //        foreach (string msg in messages.Value)
                //        {
                //            sb.AppendLine(msg);
                //        }
                //    }

                //    MessageBox.Show(sb.ToString());
                //}
            }
            else
            {
                MessageBox.Show("Error deleting plant");
            }
        }
Exemplo n.º 4
0
        private void ViewImage_Clicked(object sender, EventArgs e)
        {
            IReadOnlyList <Rg.Plugins.Popup.Pages.PopupPage> popupStack = Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopupStack;

            //One at a time, please
            if (popupStack != null && popupStack.Count > 0)
            {
                return;
            }

            Button b = sender as Button;

            b.IsEnabled = false;

            try
            {
                PlantInventoryDTO plant = (PlantInventoryDTO)((Button)sender).BindingContext;

                if (plant != null)
                {
                    long plantImageId = ((App)App.Current).MissingImageId;
                    if (plant.ImageId != 0)
                    {
                        plantImageId = plant.ImageId;
                    }

                    EOImgData img = ((App)App.Current).GetImage(plantImageId);

                    if (plantImageId == ((App)App.Current).MissingImageId)
                    {
                        MessagingCenter.Send <PlantInventoryDTO>(plant, "PlantMissingImage");
                    }

                    ((App)App.Current).GetServiceCodeById(plant.Inventory.ServiceCodeId).ContinueWith(a => ShowImage(img, a.Result));
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                b.IsEnabled = true;
            }
        }