Exemplo n.º 1
0
 private void Sort_Button_Click(object sender, RoutedEventArgs e)
 {
     if (path != null)
     {
         DirectoryInfo files = new DirectoryInfo(path);
         foreach (FileInfo file in files.GetFiles())
         {
             try
             {
                 foreach (CategoryClass Category in CategoryList)
                 {
                     if (Category.Formats.Contains(file.Extension) && FileException.Contains(file.Name) == false)
                     {
                         Directory.CreateDirectory($@"{path}\{Category.Name}\");
                         fullDirectoryFile = $@"{file.DirectoryName}\{file.Name}";
                         File.Move(fullDirectoryFile, $@"{path}\{Category.Name}\{file.Name}");
                     }
                 }
             }
             catch
             {
                 //Это нужно чтобы обходить файлы, которые заняты другим процессом
             }
         }
         GreetingLab.SetResourceReference(TextBlock.TextProperty, "l_Succ");
     }
     else
     {
         GreetingLab.SetResourceReference(TextBlock.TextProperty, "l_PathError");
     }
 }
Exemplo n.º 2
0
        public ICollection <ImageDTO> GetImagesNameAndSaveOnServer(IEnumerable <HttpPostedFileBase> files)
        {
            if (files != null)
            {
                string[] ext = { ".jpg", ".jpeg", ".png", ".gif" };

                LinkedList <ImageDTO> images = new LinkedList <ImageDTO>();

                foreach (var file in files)
                {
                    var fileExt = Path.GetExtension(file.FileName);

                    if (!ext.Contains(fileExt))
                    {
                        throw FileException.UnpropriateFileExtension(fileExt);
                    }

                    images.AddLast(new ImageDTO()
                    {
                        ImageUrl = Path.GetFileName(file.FileName)
                    });
                    file.SaveAs(Path.Combine(Server.MapPath(@"~/App_Data"), file.FileName));
                }

                return(images);
            }

            return(null);
        }
Exemplo n.º 3
0
        /// <summary>プロジェクトの異常処理</summary>
        void App_DispatcherUnhandledException(object sender,
                                              DispatcherUnhandledExceptionEventArgs e)
        {
            if (e.Exception is DBException)
            {
                DBException ex = (DBException)e.Exception;
                LogInfo.WriteErrorLog(ex.MessageID, ex);
                LogInfo.WriteFatalLog(ex.InnerException);
                CommonDialog.ShowErrorDialog(ex.MessageID);
            }
            else if (e.Exception is FileException)
            {
                FileException ex = (FileException)e.Exception;
                LogInfo.WriteErrorLog(ex.MessageID, ex.InnerException);
                CommonDialog.ShowErrorDialog(ex.MessageID);
            }
            else if (e.Exception is BaseException)
            {
                BaseException ex = (BaseException)e.Exception;
                LogInfo.WriteErrorLog(ex.MessageID, ex.InnerException);
                CommonDialog.ShowErrorDialog(ex.MessageID);
            }
            else
            {
                LogInfo.WriteErrorLog(Consts.SYSERR_003, e.Exception);
                CommonDialog.ShowErrorDialog(Consts.SYSERR_003);
            }


            e.Handled = true;
        }
Exemplo n.º 4
0
        void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            MessageBoxResult result;

            Exception exception = (Exception)e.ExceptionObject;

            if (exception is DBException)
            {
                DBException ex = (DBException)exception;
                LogInfo.WriteErrorLog(ex.MessageID, ex);
                LogInfo.WriteFatalLog(ex.InnerException);
                result = CommonDialog.ShowErrorDialog(ex.MessageID);
            }
            else if (exception is FileException)
            {
                FileException ex = (FileException)exception;
                LogInfo.WriteErrorLog(ex.MessageID, ex.InnerException);
                result = CommonDialog.ShowErrorDialog(ex.MessageID);
            }
            else if (exception is BaseException)
            {
                BaseException ex = (BaseException)exception;
                LogInfo.WriteErrorLog(ex.MessageID, ex.InnerException);
                result = CommonDialog.ShowErrorDialog(ex.MessageID);
            }
            else
            {
                LogInfo.WriteErrorLog(Consts.SYSERR_003, exception);
                result = CommonDialog.ShowErrorDialog(Consts.SYSERR_003);
            }
            if (result == MessageBoxResult.OK)
            {
                Environment.Exit(ERROR_EXIT_CODE);
            }
        }
Exemplo n.º 5
0
        public void FileException()
        {
            var ex1 = new FileException("MyMessage1");
            var ex2 = new FileException("MyMessage2", ex1);

            Assert.AreEqual(ex1, ex2.InnerException);
            Assert.AreEqual("MyMessage2", ex2.Message);
        }
Exemplo n.º 6
0
 private void Keyboard(object sender, Input.KeyEventArgs e)
 {
     if (e.Key == Input.Key.Delete && FileExcep_ListView.SelectedItem != null)
     {
         FileException.RemoveAt(FileException.IndexOf(FileExcep_ListView.SelectedItem.ToString()));
         FileExcep_ListView.ItemsSource = null;
         FileExcep_ListView.ItemsSource = FileException;
     }
 }
Exemplo n.º 7
0
 private void Minus_Button_Click(object sender, RoutedEventArgs e)
 {
     if (FileExcep_ListView.SelectedItem == null && FileException.Count != 0)
     {
         FileException.RemoveAt(FileException.IndexOf(FileException.Last()));
     }
     else if (FileException.Count > 0)
     {
         FileException.RemoveAt(FileException.IndexOf(FileExcep_ListView.SelectedItem.ToString()));
     }
     FileExcep_ListView.ItemsSource = null;
     FileExcep_ListView.ItemsSource = FileException;
 }
Exemplo n.º 8
0
        public ImageDTO GetImageByName(string imageName)
        {
            string[] ext = { ".jpg", ".jpeg", ".png", ".gif" };

            ImageDTO image = Mapper.Map <Image, ImageDTO>(
                UnitOfWork.ArticleRepository.GetAll()
                .SelectMany(a => a.Images).FirstOrDefault(i =>
                                                          Path.GetFileNameWithoutExtension(i.ImageUrl) == imageName)
                );

            if (image == null)
            {
                throw FileException.FileNameNotExists(imageName);
            }

            return(image);
        }
Exemplo n.º 9
0
 private void Select_Button_Click(object sender, RoutedEventArgs e)
 {
     using (OpenFileDialog selectFile = new OpenFileDialog())
     {
         selectFile.Multiselect = true;
         if (selectFile.ShowDialog() == DialogResult.OK)
         {
             foreach (string file in selectFile.SafeFileNames)
             {
                 if (FileException.Contains(file) == false)
                 {
                     FileException.Add(file);
                 }
             }
             FileExcep_ListView.ItemsSource = null;
             FileExcep_ListView.ItemsSource = FileException;
         }
     }
 }
Exemplo n.º 10
0
        public object GetInvalidExportRecords()
        {
            var query =
                $@"select fe.file_exception_id, fe.file_id, f.[name],f.source,fe.business_date,reference, record from file_exception fe
                            inner join [file] f on fe.file_id = f.id
                            order by business_date desc";

            var dataTable = sqlHelper.GetDataTable(query, CommandType.Text);
            List <FileException> fileExceptions = new List <FileException>();

            foreach (DataRow row in dataTable.Rows)
            {
                FileException fEx = new FileException();
                fEx.businessDate    = (DateTime)row["business_date"];
                fEx.fileId          = row["file_id"] == DBNull.Value ? 0 : (int)row["file_id"];
                fEx.fileExceptionId = (int)row["file_exception_id"];
                fEx.reference       = (string)row["reference"];
                fEx.fileName        = (string)row["name"];
                fEx.record          = (string)row["record"];
                fEx.source          = (string)row["source"];
                fileExceptions.Add(fEx);
            }

            var groupedExceptions = fileExceptions.GroupBy(x => x.fileId).Select(x => new
            {
                FileId          = x.Key,
                FileExceptionId = x.FirstOrDefault().fileExceptionId,
                BusinessDate    = x.FirstOrDefault().businessDate,
                FileName        = x.FirstOrDefault().fileName,
                Exceptions      = x.Count(),
                Source          = x.FirstOrDefault().source,
                ExceptionList   = x.Select(y => new
                {
                    Reference = y.reference,
                    Record    = y.record
                }).ToList()
            }).ToList();

            //var jsonResult = JsonConvert.SerializeObject(dataTable);
            //dynamic json = JsonConvert.DeserializeObject(jsonResult);
            return(Utils.Wrap(true, groupedExceptions));
        }
Exemplo n.º 11
0
 public void FileExceptionConstructors() => Assert.DoesNotThrow(() =>
 {
     FileException e = new FileException();
     e = new FileException(string.Empty);
     e = new FileException(string.Empty, null);
 });