예제 #1
0
        /* ---
         *
         *  FUNCIONES PROPIAS DE LA VISTA
         *
         *
         * --- */

        /*  ------------ BUSQUEDA ------------ */

        // Busqueda de la pestaña uno, genera una lista de imagenes o de vistas previas de tableros
        private void MainSearch_Click(object sender, RoutedEventArgs e)
        {
            string searchText = MainSearchbox.Text;

            string[] search = PrepareTextForSearching(searchText);

            List <Model.ImageItem> itemsToShow = new List <Model.ImageItem>();

            bool check = ImagesOrDashboards.IsChecked.Value;

            this.IsEnabled       = false;
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
            Task.Run(() => {
                if (check == true)
                {
                    SearchForDashboardLocally(itemsToShow, search);
                    if (itemsToShow.Count() == 0)
                    {
                        try
                        {
                            Controller.BusinessLayer businessLayer = new Controller.BusinessLayer(dataAccess.ConfigDictionary["Address"],
                                                                                                  Int32.Parse(dataAccess.ConfigDictionary["Port"]));
                            SearchForDashboardInServer(itemsToShow, businessLayer, search, searchCanvas);
                        }
                        catch
                        {
                            string messageText      = "No es posible conectarse con el servidor o no se recibe respuesta";
                            string caption          = "No hay conexion";
                            MessageBoxButton button = MessageBoxButton.OK;
                            MessageBoxImage icon    = MessageBoxImage.Warning;
                            MessageBox.Show(messageText, caption, button, icon);
                        }
                    }
                }
                // Si el checkbox no está checkeado, se buscan imagenes
                else
                {
                    SearchImages(itemsToShow, search);
                }

                this.Dispatcher.Invoke(() =>
                {
                    itemsToShow             = itemsToShow.OrderBy(o => o.Title).ToList();
                    list_Images.ItemsSource = itemsToShow;

                    searchCanvas.Children.Clear();

                    MainSearchbox.Text   = "";
                    this.IsEnabled       = true;
                    Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow;
                });
            });
        }
예제 #2
0
 /// <summary>
 /// Guarda todas las imagenes de los dashboard que vienen del servidor como imagenes temporales
 /// </summary>
 /// <param name="businessLayer">Controlador de negocio</param>
 /// <param name="dashboard">Objeto tablero</param>
 private void SaveImagesFromDashboard(Controller.BusinessLayer businessLayer, Dashboard dashboard)
 {
     foreach (PictoManagementVocabulary.Image image in dashboard.Images)
     {
         string[] title = new string[1];
         title[0] = image.Title;
         List <Model.ImageItem> imageItems = SearchForImagesLocally(title);
         if (imageItems.Count > 0)
         {
             continue;
         }
         else
         {
             imageItems = SearchForImagesInServer(businessLayer, title);
         }
     }
 }
예제 #3
0
        /// <summary>
        /// Busca imagenes en el servidor, las guarda en el directorio temporal y las pasa a la lista de imagenes a mostrar
        /// </summary>
        /// <param name="businessLayer">Controlador de negocio</param>
        /// <param name="images">Array de imagenes a buscar</param>
        /// <returns>Lista de imagenes a mostrar en la lista</returns>
        private List <Model.ImageItem> SearchForImagesInServer(Controller.BusinessLayer businessLayer, string[] images)
        {
            List <Model.ImageItem> serverImages = new List <Model.ImageItem>();

            PictoManagementVocabulary.Image[] imagesFromServer = businessLayer.RequestImages(images);

            foreach (PictoManagementVocabulary.Image img in imagesFromServer)
            {
                dataAccess.SaveNewTemporalImage(img.Title, img.FileBase64);
                string imgPath = dataAccess.ConfigDictionary["Temp"] + img.Title + ".png";
                if (File.Exists(imgPath))
                {
                    this.Dispatcher.Invoke(() => serverImages.Add(new Model.ImageItem(img.Title, imgPath, false)));
                }
            }

            return(serverImages);
        }
예제 #4
0
 /// <summary>
 /// Realiza una busqueda de imagenes en el servidor y en local
 /// </summary>
 /// <param name="itemsToShow">Lista en la que se guardaran los resultados</param>
 /// <param name="search">Textos a buscar</param>
 private void SearchImages(List <Model.ImageItem> itemsToShow, string[] search)
 {
     itemsToShow.AddRange(SearchForImagesLocally(search));
     string[] searchServer = LeftImages(itemsToShow, search);
     if (searchServer != null)
     {
         try
         {
             Controller.BusinessLayer businessLayer = new Controller.BusinessLayer(dataAccess.ConfigDictionary["Address"],
                                                                                   Int32.Parse(dataAccess.ConfigDictionary["Port"]));
             itemsToShow.AddRange(SearchForImagesInServer(businessLayer, searchServer));
         }
         catch
         {
             string           messageText = "No es posible conectarse con el servidor o no se recibe respuesta";
             string           caption     = "No hay conexion";
             MessageBoxButton button      = MessageBoxButton.OK;
             MessageBoxImage  icon        = MessageBoxImage.Warning;
             MessageBox.Show(messageText, caption, button, icon);
         }
     }
 }
예제 #5
0
        /*  ------------ CREAR TABLERO A PARTIR DE UNO EXISTENTE ------------ */

        private void SearchExistingDashboard_Click(object sender, RoutedEventArgs e)
        {
            string searchText = DashboardSearchbox.Text;

            string[] search = PrepareTextForSearching(searchText);

            List <Model.ImageItem> itemsToShow = new List <Model.ImageItem>();

            this.IsEnabled       = false;
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
            Task.Run(() => {
                try
                {
                    Controller.BusinessLayer businessLayer = new Controller.BusinessLayer(dataAccess.ConfigDictionary["Address"],
                                                                                          Int32.Parse(dataAccess.ConfigDictionary["Port"]));
                    SearchForDashboardInServer(itemsToShow, businessLayer, search, canvasCreateExisting);
                }
                catch
                {
                    string messageText      = "No es posible conectarse con el servidor o no se recibe respuesta";
                    string caption          = "No hay conexion";
                    MessageBoxButton button = MessageBoxButton.OK;
                    MessageBoxImage icon    = MessageBoxImage.Warning;
                    MessageBox.Show(messageText, caption, button, icon);
                }

                this.Dispatcher.Invoke(() =>
                {
                    itemsToShow = itemsToShow.OrderBy(o => o.Title).ToList();
                    dashboards_fromServer.ItemsSource = itemsToShow;
                    EditSelectedDashboard.IsEnabled   = true;

                    this.IsEnabled       = true;
                    Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow;
                });
            });
        }
예제 #6
0
        /// <summary>
        /// Prepara y envia el contenido de un dashboard al servidor
        /// </summary>
        /// <param name="title">Nombre del dashboard</param>
        /// <param name="imagesToDashboard">Pictogramas que contiene el dashboard</param>
        public void PrepareDashboardForServer(string title, List <Model.ImageItem> imagesToDashboard)
        {
            string dashboardRequest = title;

            foreach (Model.ImageItem imageItem in imagesToDashboard)
            {
                dashboardRequest = dashboardRequest + "," + imageItem.Title;
            }

            try
            {
                Controller.BusinessLayer businessLayer = new Controller.BusinessLayer(dataAccess.ConfigDictionary["Address"],
                                                                                      Int32.Parse(dataAccess.ConfigDictionary["Port"]));
                businessLayer.SendDashboard(dashboardRequest);
            }
            catch
            {
                string           messageText = "No es posible conectarse con el servidor o no se recibe respuesta";
                string           caption     = "No hay conexion";
                MessageBoxButton button      = MessageBoxButton.OK;
                MessageBoxImage  icon        = MessageBoxImage.Warning;
                MessageBox.Show(messageText, caption, button, icon);
            }
        }
예제 #7
0
        /// <summary>
        /// Busca los tableros solicitados en el servidor
        /// </summary>
        /// <param name="businessLayer">Controlador de negocio</param>
        /// <param name="dashboardNames">Array con el nombre de los tableros buscados</param>
        /// <returns>Retorna una lista con las vistas previas del tablero</returns>
        private void SearchForDashboardInServer(List <Model.ImageItem> dashboardList, Controller.BusinessLayer businessLayer,
                                                string[] dashboardNames, Canvas canvas)
        {
            List <Model.ImageItem> dashboardImages     = new List <Model.ImageItem>();
            List <Dashboard>       dashboardsToProcess = new List <Dashboard>();
            List <Dashboard>       dashboardsResult    = new List <Dashboard>();

            foreach (string dashboardName in dashboardNames)
            {
                dashboardsToProcess.AddRange(businessLayer.GetDashboard(dashboardName));
                foreach (Dashboard dashboard in dashboardsToProcess)
                {
                    SaveImagesFromDashboard(businessLayer, dashboard);
                }
                dashboardsResult.AddRange(dashboardsToProcess);
                dashboardsToProcess = new List <Dashboard>();
            }

            foreach (Dashboard dash in dashboardsResult)
            {
                List <string>          images            = new List <string>();
                List <Model.ImageItem> imagesInDashboard = new List <Model.ImageItem>();

                foreach (PictoManagementVocabulary.Image image in dash.Images)
                {
                    images.Add(image.Title);
                }
                string[] imgArray = images.ToArray();
                SearchImages(imagesInDashboard, imgArray);

                this.Dispatcher.Invoke(() => CreateDashboard(imagesInDashboard, canvas));
                canvas.Dispatcher.Invoke(() => { }, DispatcherPriority.Render);
                this.Dispatcher.Invoke(() => SaveDashboardFromCanvas(canvas, dash.Name, true));
                dataAccess.IncludeDashboardInTemporalList(dash);

                string dashboardPath = dataAccess.ConfigDictionary["DashboardsTemp"] + dash.Name + ".png";
                this.Dispatcher.Invoke(() => dashboardImages.Add(new Model.ImageItem(dash.Name, dashboardPath, false)));
            }
            if (dashboardImages != null)
            {
                dashboardList.AddRange(dashboardImages);
            }
        }