Esempio n. 1
0
 private void GetPpvkFileInfo(FileTransferInfo fileTransferInfo)
 {
     try
     {
         var directory = _settings[ArgsKeyList.BackUpPath];
         var path      = $"{directory}\\{fileTransferInfo.Id}.details";
         if (!File.Exists(path))
         {
             return;
         }
         var json = File.ReadAllText(path);
         var pfi  = new PpvkFileInfo().LoadFromJson(json);
         pfi.SaveToDbTime = DateTime.Now;
         _context.FileInfos.Add(pfi);
         _context.SaveChanges();
     }
     catch (Exception e)
     {
         _console.AddException(e);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Производит операцию над файлом, согласно назначению класса.
        /// </summary>
        /// <param name="fileTransferInfo">Информация о классе.</param>
        /// <returns>Обработанный класс.</returns>
        protected override FileTransferInfo DetailedProc(FileTransferInfo fileTransferInfo)
        {
            try
            {
                var info      = new PpvkFileInfo(fileTransferInfo);
                var directory = _settings[ArgsKeyList.BackUpPath];
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                var path = $"{directory}\\{fileTransferInfo.Id}.details";
                File.WriteAllText(path, info.ToJson());
                return(fileTransferInfo);
            }
            catch (Exception e)
            {
                _console.AddException(e);
                return(null);
            }
        }