Beispiel #1
0
        /// <summary>
        /// Method called on delete click to delete an AclGroup.
        /// </summary>
        /// <param name="sender">The object sender of the event.</param>
        /// <param name="e">Routed event arguments.</param>
        public override void DeleteItems_Click(object sender, RoutedEventArgs e)
        {
            // Check if an AclGroup is founded.
            if (SelectedItem != null && SelectedItem.IsDefault == false)
            {
                // Alert user for acceptation.
                MessageBoxResult result = MessageBox.Show
                                          (
                    String.Format(
                        Dialogs.Properties.Translations.MessageBox_Acceptation_DeleteGeneric,
                        Local.Properties.Translations.Group,
                        SelectedItem.Name
                        ),
                    Local.Properties.Translations.ApplicationName,
                    MessageBoxButton.YesNoCancel
                                          );

                // If accepted, try to update page model AclGroup collection.
                if (result == MessageBoxResult.Yes)
                {
                    NotifyDeleted(SelectedItem);
                }
            }
            else if (SelectedItem != null && SelectedItem.IsDefault == true)
            {
                log.Info("Default User Group cannot be delete !");
            }
            else
            {
                log.Error("User not found !");
                MessageBoxs.Warning("User not found !");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Method called on edit click event to navigate to an AclGroup edit window.
        /// </summary>
        /// <param name="sender">The object sender of the event.</param>
        /// <param name="e">Routed event arguments.</param>
        public override void EditItem_Click(object sender, RoutedEventArgs e)
        {
            // Check if an AclGroup is founded.
            if (SelectedItem != null)
            {
                // Show open file dialog box
                WindowFormAclGroupLayout dlg = new WindowFormAclGroupLayout(SelectedItem);
                bool?result = dlg.ShowDialog();

                // Process open file dialog box results
                if (result == true)
                {
                    NotifyChanged(dlg.NewFormData);
                }
                else
                {
                    NotifyCanceled(dlg.NewFormData);
                }
            }
            else
            {
                string message = string.Format("{0} not found !", nameof(AclGroupEntity));
                log.Warn(message);
                MessageBoxs.Warning(message);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Method called on edit click to navigate to a Section edit window.
        /// </summary>
        /// <param name="sender">The object sender of the event.</param>
        /// <param name="e">Routed event arguments.</param>
        public override void EditItem_Click(object sender, RoutedEventArgs e)
        {
            // Check if an AclGroup is founded.
            if (SelectedItem != null)
            {
                // Show open file dialog box
                using (WindowFormSectionLayout dlg = new WindowFormSectionLayout(SelectedItem))
                {
                    bool?result = dlg.ShowDialog();

                    // Process open file dialog box results
                    if (result == true)
                    {
                        NotifyChanged(dlg.NewForm);
                    }
                    else
                    {
                        NotifyCanceled(dlg.NewForm);
                    }
                }
            }
            else
            {
                string message = Exceptions.GetReferenceNull(nameof(SelectedItem), typeof(SectionEntity)).Message;
                log.Warn(message);
                MessageBoxs.Warning(message);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Method called on delete click to delete a User.
        /// </summary>
        /// <param name="sender">The object sender of the event.</param>
        /// <param name="e">Routed event arguments.</param>
        public override void DeleteItems_Click(object sender, RoutedEventArgs e)
        {
            if (SelectedItem != null)
            {
                // Alert user for acceptation.
                MessageBoxResult result = MessageBox.Show
                                          (

                    String.Format(
                        Dialogs.Properties.Translations.MessageBox_Acceptation_DeleteGeneric,
                        Local.Properties.Translations.User,
                        SelectedItem.Name
                        ),
                    Local.Properties.Translations.ApplicationName,
                    MessageBoxButton.YesNoCancel
                                          );

                // If accepted, try to update page model collection.
                if (result == MessageBoxResult.Yes)
                {
                    NotifyDeleted(SelectedItem);
                }
            }
            else
            {
                string message = string.Format("{0} not found !", nameof(UserEntity));
                log.Warn(message);
                MessageBoxs.Warning(message);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Method called on delete click to delete a Section.
        /// </summary>
        /// <param name="sender">The object sender of the event.</param>
        /// <param name="e">Routed event arguments.</param>
        public override void DeleteItems_Click(object sender, RoutedEventArgs e)
        {
            // Check if an AclGroup is founded.
            if (SelectedItem != null)
            {
                // Alert user for acceptation.
                MessageBoxResult result = MessageBox.Show
                                          (

                    String.Format(
                        Dialogs.Properties.Translations.MessageBox_Acceptation_DeleteGeneric,
                        Local.Properties.Translations.Section,
                        SelectedItem.Name
                        ),
                    Local.Properties.Translations.ApplicationName,
                    MessageBoxButton.YesNoCancel
                                          );

                // If accepted, try to update page model collection.
                if (result == MessageBoxResult.Yes)
                {
                    NotifyDeleted(SelectedItem);
                }
            }
            else
            {
                string message = Exceptions.GetReferenceNull(nameof(SelectedItem), typeof(SectionEntity)).Message;
                log.Warn(message);
                MessageBoxs.Warning(message);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Method to start the server.
        /// </summary>
        public static void Start()
        {
            // Check if the server is started.
            if (!HttpWebServerApplication.IsStarted)
            {
                try
                {
                    // Try to get server informations
                    ServerData server = ApplicationBase.Options.Remote.Servers.FindDefaultFirst();

                    if (server != null)
                    {
                        HttpWebServerApplication.Start(server.Host, server.Port);
                        log.Info(Properties.Logs.ServerStarted);
                    }

                    NotifyServerStarted();
                }
                catch (Exception ex)
                {
                    log.Error(ex.Output(), ex);
                    MessageBoxs.Warning(ex.Output(), ex.GetType().Name);

                    NotifyServerFailed();
                }
            }
            else
            {
                log.Warn("Server is already started.");
            }
        }
Beispiel #7
0
        /// <summary>
        /// Method called on delete click to delete a Album.
        /// </summary>
        /// <param name="sender">The <see cref="object"/> sender of the event.</param>
        /// <param name="e">Routed event arguments <see cref="RoutedEventArgs"/>.</param>
        public override void DeleteItems_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Start to busy application.
                MessageBoxs.IsBusy = true;
                log.Warn("Deleting Album. Please wait...");

                // Check if an AclGroup is founded.
                if (SelectedItem != null)
                {
                    // Alert user for acceptation.
                    MessageBoxResult result = MessageBox.Show
                                              (
                        String.Format(
                            Dialogs.Properties.Translations.MessageBox_Acceptation_DeleteGeneric,
                            Local.Properties.Translations.Album,
                            SelectedItem.Name
                            ),
                        Local.Properties.Translations.ApplicationName,
                        MessageBoxButton.YesNoCancel
                                              );

                    // If accepted, try to update page model collection.
                    if (result == MessageBoxResult.Yes)
                    {
                        NotifyDeleted(SelectedItem);
                    }
                }
                else
                {
                    string message = $"{typeof(AlbumEntity).Name} not found !";
                    log.Warn(message);
                    MessageBoxs.Warning(message);
                }
            }

            catch (Exception ex)
            {
                log.Error(ex.Output(), ex);
                MessageBoxs.Error(ex.Output());
            }

            // Stop to busy application.
            finally
            {
                log.Warn("Deleting Album. Please wait...");
                MessageBoxs.IsBusy = false;
            }
        }
Beispiel #8
0
        /// <summary>
        /// Method called on edit <see cref="AlbumEntity"/> click event.
        /// </summary>
        /// <param name="sender">The <see cref="object"/> sender of the event.</param>
        /// <param name="e">Routed event arguments <see cref="RoutedEventArgs"/>.</param>
        public override void EditItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Start to busy application.
                MessageBoxs.IsBusy = true;
                log.Warn("Editing Album informations. Please wait...");

                // Check if an AclGroup is founded.
                if (SelectedItem != null)
                {
                    // Show open file dialog box
                    WindowFormAlbumLayout dlg = new WindowFormAlbumLayout(SelectedItem);
                    bool?result = dlg.ShowDialog();

                    // Process open file dialog box results
                    if (result == true)
                    {
                        NotifyChanged(dlg.NewForm);
                    }
                    else
                    {
                        NotifyCanceled(dlg.NewForm);
                    }

                    log.Warn("Editing Album informations. Done.");
                }
                else
                {
                    string message = $"{typeof(AlbumEntity).Name} not found !";
                    log.Warn(message);
                    MessageBoxs.Warning(message);
                }
            }

            catch (Exception ex)
            {
                log.Error(ex.Output(), ex);
                MessageBoxs.Error(ex.Output());
            }

            // Stop to busy application.
            finally
            {
                MessageBoxs.IsBusy = false;
            }
        }
Beispiel #9
0
        /// <summary>
        /// Method called on delete click event to delete a Album.
        /// </summary>
        /// <param name="sender">The object sender of the event.</param>
        /// <param name="e">Routed event arguments.</param>
        public async override void DeleteItems_Click(object sender, RoutedEventArgs e)
        {
            // Check if the selected items list is not null.
            if (SelectedItems == null)
            {
                NullReferenceException ex = Exceptions.GetReferenceNull(nameof(SelectedItems), typeof(IEnumerable <AlbumEntity>));
                log.Warn(ex.Output(), ex);
                MessageBoxs.Warning(ex.Output());
                return;
            }

            // Alert user for acceptation.
            MessageBoxResult result = MessageBox.Show
                                      (
                String.Format(Fotootof.Layouts.Dialogs.Properties.Translations.MessageBox_Acceptation_DeleteGeneric, Local.Properties.Translations.Album, SelectedItems.Count),
                Local.Properties.Translations.ApplicationName,
                MessageBoxButton.YesNoCancel
                                      );

            // If not accept, do nothing at this moment.
            if (result != MessageBoxResult.Yes)
            {
                return;
            }

            // If accepted, try to update page model collection.
            try
            {
                // Start to busy application.
                MessageBoxs.IsBusy = true;
                log.Warn("Deleting Album(s). Please wait...");

                // Delete item from database.
                await AlbumEntityCollection.DbDeleteAsync(SelectedItems);

                // Important : No need to defer for list view items refresh.
                log.Warn("Updating Album(s) list view items...");
                foreach (AlbumEntity item in SelectedItems)
                {
                    Items.Remove(item);
                }

                // Refresh of the list view items source.
                log.Warn("Refreshing Album(s) list view...");
                ItemsCollection.Items.Refresh();

                // Raise the on delete event.
                log.Warn("Refreshing Album(s) list view...");
                NotifyDeleted(SelectedItems.ToArray());
            }

            catch (Exception ex)
            {
                log.Error(ex.Output(), ex);
                MessageBoxs.Error(ex.Output());
            }

            // Stop to busy application.
            finally
            {
                log.Warn("Deleting Album(s). Done.");
                MessageBoxs.IsBusy = false;
            }
        }