private void CommandBinding_DeleteFile2(object sender, ExecutedRoutedEventArgs e)
        {
            object obj = e.Parameter;

            if (obj == null)
            {
                return;
            }

            try
            {
                if (obj.GetType() == typeof(DuplicateFileVM))
                {
                    DuplicateFileVM df = obj as DuplicateFileVM;

                    MessageBoxResult res = MessageBox.Show(string.Format(Properties.Resources.DuplicateFiles_ConfirmDelete),
                                                           Properties.Resources.Confirm, MessageBoxButton.YesNo, MessageBoxImage.Warning);

                    if (res == MessageBoxResult.Yes)
                    {
                        this.Cursor = Cursors.Wait;
                        string result = JMMServerVM.Instance.clientBinaryHTTP.DeleteDuplicateFile(df.DuplicateFileID, 2);
                        if (result.Length > 0)
                        {
                            MessageBox.Show(result, Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        else
                        {
                            DuplicateFilesCollection.Remove(df);
                            FileCount = DuplicateFilesCollection.Count;
                            //RefreshDuplicateFiles();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
                this.Cursor = Cursors.Arrow;
            }
        }
        private void CommandBinding_DeleteFileDB(object sender, ExecutedRoutedEventArgs e)
        {
            object obj = e.Parameter;

            if (obj == null)
            {
                return;
            }

            try
            {
                if (obj.GetType() == typeof(VM_DuplicateFile))
                {
                    VM_DuplicateFile df = obj as VM_DuplicateFile;

                    MessageBoxResult res = MessageBox.Show(string.Format(Shoko.Commons.Properties.Resources.DuplicateFiles_DeleteEntry),
                                                           Shoko.Commons.Properties.Resources.Confirm, MessageBoxButton.YesNo, MessageBoxImage.Question);

                    if (res == MessageBoxResult.Yes)
                    {
                        Cursor = Cursors.Wait;
                        string result = VM_ShokoServer.Instance.ShokoServices.DeleteDuplicateFile(df.DuplicateFileID, 0);
                        if (result.Length > 0)
                        {
                            MessageBox.Show(result, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        else
                        {
                            DuplicateFilesCollection.Remove(df);
                            FileCount = DuplicateFilesCollection.Count;
                            //RefreshDuplicateFiles();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
                Cursor = Cursors.Arrow;
            }
        }
Ejemplo n.º 3
0
        private void CommandBinding_DeleteFile1(object sender, ExecutedRoutedEventArgs e)
        {
            object obj = e.Parameter;

            if (obj == null)
            {
                return;
            }

            try
            {
                if (obj.GetType() == typeof(DuplicateFileVM))
                {
                    DuplicateFileVM df = obj as DuplicateFileVM;

                    MessageBoxResult res = MessageBox.Show(string.Format("Are you sure you want to delete this file, the physical video file will also be deleted"),
                                                           "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Warning);

                    if (res == MessageBoxResult.Yes)
                    {
                        this.Cursor = Cursors.Wait;
                        string result = JMMServerVM.Instance.clientBinaryHTTP.DeleteDuplicateFile(df.DuplicateFileID, 1);
                        if (result.Length > 0)
                        {
                            MessageBox.Show(result, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        else
                        {
                            DuplicateFilesCollection.Remove(df);
                            FileCount = DuplicateFilesCollection.Count;
                            //RefreshDuplicateFiles();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
                this.Cursor = Cursors.Arrow;
            }
        }