/// <inheritdoc/>
        public async Task<FileDetails> GetDetailsForFileById(int id)
        {
            FileDetails details = null;

            using (var connection = new SqlConnection(connectionString))
            {
                using (var command = new SqlCommand("GetFileMetaDatabyId", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddWithValue("Id", id);

                    await connection.OpenAsync();

                    using (var reader = await command.ExecuteReaderAsync())
                    {
                        if (await reader.ReadAsync())
                        {
                            details = new FileDetails();
                            details.ApplicationName = reader["ApplicationName"].ToString();
                            details.FileName = reader["FileName"].ToString();
                            details.FileId = (int)reader["Id"];
                            details.MimeType = reader["MimeType"].ToString();
                            details.StoragePath = reader["InternalStoragePath"].ToString();
                            details.Checksum = reader["Checksum"].ToString();
                            details.DateStoredUtc = (DateTime)reader["DateStoredUtc"];
                        }
                    }
                }
            }

            return details;
        }
Exemplo n.º 2
0
    public static FileDetails[] GetFiles()
    {
        string path = Application.persistentDataPath + "/saves/";

        if (Directory.Exists(path) == false)
        {
            return(null);
        }

        Debug.Log("Directory exists");

        DirectoryInfo dir = new DirectoryInfo(path);

        //Debug.Log(dir.FullName);

        FileInfo[] files = dir.GetFiles("*.dat");

        //Debug.Log("Files count = " + files.Length);

        FileStream      stream;
        BinaryFormatter bf = new BinaryFormatter();

        FileDetails[] details = new FileDetails[files.Length];
        for (int i = 0; i < files.Length; i++)
        {
            stream     = new FileStream(files[i].FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            details[i] = (FileDetails)bf.Deserialize(stream);
            stream.Close();
        }

        return(details);
    }
Exemplo n.º 3
0
        public async Task <FileDetails> UpdateFileDetailsAsync(FileDetails details)
        {
            var collection = fileInfoDB.GetCollection <FileDetails>(fileInfoDbName);
            var results    = await collection.FindAsync(fileInfo => fileInfo.Id.Equals(details.Id));

            FileDetails odlFileDetails = await results.FirstOrDefaultAsync();

            if (odlFileDetails == null)
            {
                throw new GridFSFileNotFoundException(details.Id);
            }
            var filter = Builders <FileDetails> .Filter.Eq("Id", details.Id);

            var update = Builders <FileDetails> .Update
                         .Set("Name", details.Name ?? odlFileDetails.Name)
                         .Set("Description", details.Description ?? odlFileDetails.Description)
                         .Set("AddedBy", details.AddedBy ?? odlFileDetails.AddedBy)
                         .Set("Tags", details.Tags ?? odlFileDetails.Tags)
                         .CurrentDate("LastModified");

            await collection.UpdateOneAsync(filter, update);

            results = await collection.FindAsync(fileInfo => fileInfo.Id.Equals(details.Id));

            return(await results.FirstOrDefaultAsync());
        }
Exemplo n.º 4
0
    private static void GetFileDetails()
    {
        try
        {
            Console.WriteLine("-----------*******Ожидание информации о файле*******-----------");

            // Получаем информацию о файле
            receiveBytes = receivingUdpClient.Receive(ref RemoteIpEndPoint);
            Console.WriteLine("----Информация о файле получена!");

            XmlSerializer fileSerializer = new XmlSerializer(typeof(FileDetails));
            MemoryStream  stream1        = new MemoryStream();

            // Считываем информацию о файле
            stream1.Write(receiveBytes, 0, receiveBytes.Length);
            stream1.Position = 0;

            // Вызываем метод Deserialize
            fileDet = (FileDetails)fileSerializer.Deserialize(stream1);
            Console.WriteLine("Получен файл типа ." + fileDet.FILETYPE +
                              " имеющий размер " + fileDet.FILESIZE.ToString() + " байт");
        }
        catch (Exception eR)
        {
            Console.WriteLine(eR.ToString());
        }
    }
Exemplo n.º 5
0
        public List <FileDetails> GetFiles(List <ObjectId> fileIds)
        {
            List <FileDetails> fileDetails = null;
            var files = _fileRepository.GetFiles(fileIds);

            if (files != null && files.Any())
            {
                fileDetails = new List <FileDetails>();
                fileDetails = files.Select(t =>
                {
                    var fileViewModel = new FileDetails
                    {
                        FileId       = t.FileId.ToString(),
                        ContentType  = t.ContentType,
                        CreatedDate  = t.CreatedDate,
                        Description  = t.Description,
                        IsActive     = t.IsActive,
                        Name         = t.Name,
                        Title        = t.Title,
                        ModifiedDate = t.ModifiedDate
                    };
                    return(fileViewModel);
                }).ToList();
            }
            return(fileDetails);
        }
Exemplo n.º 6
0
        public async Task <ActionResult <FileDetailsViewModels> > UpdateFileDetails(FileDetails details, string id)
        {
            details.Id = id;
            var fileDetails = await _storageService.UpdateFileDetailsAsync(id, details);

            return(Ok(ViewModelsMapper.ConvertFileDetailsToFileDetailsViewModels(fileDetails)));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Migrates all the stored files and page attachments from a Provider to another.
        /// </summary>
        /// <param name="source">The source Provider.</param>
        /// <param name="destination">The destination Provider.</param>
        /// <param name="settingsProvider">The settings storage provider that handles permissions.</param>
        public static void MigrateFilesStorageProviderData(IFilesStorageProviderV30 source, IFilesStorageProviderV30 destination, ISettingsStorageProviderV30 settingsProvider)
        {
            // Directories
            MigrateDirectories(source, destination, "/", settingsProvider);

            // Attachments
            foreach (string page in source.GetPagesWithAttachments())
            {
                PageInfo pageInfo = new PageInfo(page, null, DateTime.Now);

                string[] attachments = source.ListPageAttachments(pageInfo);

                foreach (string attachment in attachments)
                {
                    // Copy file content
                    using (MemoryStream ms = new MemoryStream(1048576)) {
                        source.RetrievePageAttachment(pageInfo, attachment, ms, false);
                        ms.Seek(0, SeekOrigin.Begin);
                        destination.StorePageAttachment(pageInfo, attachment, ms, false);
                    }

                    // Copy download count
                    FileDetails fileDetails = source.GetPageAttachmentDetails(pageInfo, attachment);
                    destination.SetPageAttachmentRetrievalCount(pageInfo, attachment, fileDetails.RetrievalCount);

                    // Delete attachment
                    source.DeletePageAttachment(pageInfo, attachment);
                }
            }
        }
Exemplo n.º 8
0
        private void VerifyFile(FileAggregate source, FileDetails fileDetails)
        {
            var fileModel = source.GetFile();

            fileDetails.FileId.ShouldBe(fileModel.FileId);
            fileDetails.FileImportLogId.ShouldBe(fileModel.FileImportLogId);
            fileDetails.FileLocation.ShouldBe(fileModel.FileLocation);
            fileDetails.FileProfileId.ShouldBe(fileModel.FileProfileId);
            fileDetails.MerchantId.ShouldBe(fileModel.MerchantId);
            fileDetails.ProcessingCompleted.ShouldBe(fileModel.ProcessingCompleted);
            fileDetails.UserId.ShouldBe(fileModel.UserId);
            fileDetails.EstateId.ShouldBe(fileModel.EstateId);

            fileDetails.ProcessingSummary.ShouldNotBeNull();
            fileDetails.ProcessingSummary.FailedLines.ShouldBe(fileModel.ProcessingSummary.FailedLines);
            fileDetails.ProcessingSummary.IgnoredLines.ShouldBe(fileModel.ProcessingSummary.IgnoredLines);
            fileDetails.ProcessingSummary.NotProcessedLines.ShouldBe(fileModel.ProcessingSummary.NotProcessedLines);
            fileDetails.ProcessingSummary.SuccessfullyProcessedLines.ShouldBe(fileModel.ProcessingSummary.SuccessfullyProcessedLines);
            fileDetails.ProcessingSummary.TotalLines.ShouldBe(fileModel.ProcessingSummary.TotalLines);

            foreach (FileLine fileModelFileLine in fileModel.FileLines)
            {
                FileLine?fileLineToVerify = fileDetails.FileLines.SingleOrDefault(f => f.LineNumber == fileModelFileLine.LineNumber);
                fileLineToVerify.ShouldNotBeNull();
                fileLineToVerify.LineData.ShouldBe(fileModelFileLine.LineData);
                fileLineToVerify.TransactionId.ShouldBe(fileModelFileLine.TransactionId);
                fileLineToVerify.ProcessingResult.ShouldBe(fileModelFileLine.ProcessingResult);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Finds the provider that has a page attachment.
        /// </summary>
        /// <param name="wiki">The wiki.</param>
        /// <param name="pageFullName">The page full name.</param>
        /// <param name="attachmentName">The name of the attachment.</param>
        /// <returns>The provider that has the attachment, or <c>null</c> if the attachment could not be found.</returns>
        public static IFilesStorageProviderV40 FindPageAttachmentProvider(string wiki, string pageFullName, string attachmentName)
        {
            if (pageFullName == null)
            {
                throw new ArgumentNullException("page");
            }
            if (attachmentName == null)
            {
                throw new ArgumentNullException("attachmentName");
            }
            if (attachmentName.Length == 0)
            {
                throw new ArgumentException("Attachment Name cannot be empty", "attachmentName");
            }

            foreach (IFilesStorageProviderV40 provider in Collectors.CollectorsBox.FilesProviderCollector.GetAllProviders(wiki))
            {
                FileDetails details = provider.GetPageAttachmentDetails(pageFullName, attachmentName);
                if (details != null)
                {
                    return(provider);
                }
            }

            return(null);
        }
        public void GetFileDetails()
        {
            try
            {
                tbxStatus.Text += "Wait resive file details\n";
                receiveBytes = udpClient.Receive(ref IpEndPoint);
                tbxStatus.Text  += "file details resived\n";

                XmlSerializer fileSerializer = new XmlSerializer(typeof(FileDetails));
                MemoryStream stream1 = new MemoryStream();

                stream1.Write(receiveBytes, 0, receiveBytes.Length);
                stream1.Position = 0;

                fileDet = (FileDetails)fileSerializer.Deserialize(stream1);

                tbxStatus.Text += "Recived file type ." + fileDet.FILETYPE +
                    " file size " + fileDet.FILESIZE.ToString() + " bytes\n";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

            }
        }
Exemplo n.º 11
0
        public IDictionary <string, IList <FileDetails> > UploadMultipleList(IEnumerable <IFormFile> filelist1,
                                                                             IEnumerable <IFormFile> filelist2)
        {
            var fileDetailsDict = new Dictionary <string, IList <FileDetails> >
            {
                { "filelist1", new List <FileDetails>() },
                { "filelist2", new List <FileDetails>() }
            };
            var fileDetailsList = new List <FileDetails>();

            foreach (var file in filelist1.Concat(filelist2))
            {
                var parsedContentDisposition = ContentDispositionHeaderValue.Parse(file.ContentDisposition);
                using (var reader = new StreamReader(file.OpenReadStream()))
                {
                    var fileContent = reader.ReadToEnd();
                    var fileDetails = new FileDetails
                    {
                        Filename = parsedContentDisposition.FileName,
                        Content  = fileContent
                    };
                    fileDetailsDict[parsedContentDisposition.Name].Add(fileDetails);
                }
            }

            return(fileDetailsDict);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Finds the provider that has a file.
        /// </summary>
        /// <param name="fullName">The full name of the file.</param>
        /// <returns>The provider that has the file, or <c>null</c> if the file could not be found.</returns>
        public static IFilesStorageProviderV30 FindFileProvider(string fullName)
        {
            if (fullName == null)
            {
                throw new ArgumentNullException("fullName");
            }

            if (string.IsNullOrEmpty(fullName))
            {
                throw new ArgumentException("Full Name cannot be empty", "fullName");
            }

            fullName = NormalizeFullName(fullName);

            foreach (IFilesStorageProviderV30 provider in Collectors.FilesProviderCollector.AllProviders)
            {
                FileDetails details = provider.GetFileDetails(fullName);
                if (details != null)
                {
                    return(provider);
                }
            }

            return(null);
        }
Exemplo n.º 13
0
        private List<FileDetails> ConstructFileMD5List()
        {
            List<FileDetails> fileList = new List<FileDetails>();

            if (Directory.Exists(GlobalSettings.Instance.SavePath))
            {
                string[] files = Directory.GetFiles(GlobalSettings.Instance.SavePath);

                //Parallel.ForEach(files, new ParallelOptions { MaxDegreeOfParallelism = 2 }, currentFile =>
                //{
                //    FileDetails details = new FileDetails();
                //    details.FileMD5 = UtilityFunctions.GetMD5HashFromFile(currentFile);
                //    details.FilePath = currentFile;

                //    fileList.Add(details);
                //}
                //);

                foreach (string file in files)
                {
                    FileDetails details = new FileDetails();
                    details.FileMD5 = UtilityFunctions.GetMD5HashFromFile(file);
                    details.FilePath = file;

                    fileList.Add(details);
                }
            }

            return fileList;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Gets the details of a page attachment.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <param name="attachmentName">The name of the attachment.</param>
        /// <returns>The details of the attachment, or <c>null</c> if the attachment could not be found.</returns>
        public static FileDetails GetPageAttachmentDetails(PageInfo page, string attachmentName)
        {
            if (page == null)
            {
                throw new ArgumentNullException("page");
            }
            if (attachmentName == null)
            {
                throw new ArgumentNullException("attachmentName");
            }
            if (attachmentName.Length == 0)
            {
                throw new ArgumentException("Attachment Name cannot be empty", "attachmentName");
            }

            foreach (IFilesStorageProviderV30 provider in Collectors.FilesProviderCollector.AllProviders)
            {
                FileDetails details = provider.GetPageAttachmentDetails(page, attachmentName);
                if (details != null)
                {
                    return(details);
                }
            }

            return(null);
        }
Exemplo n.º 15
0
        public override FileDetails LoadText(PrayerSect pSect)
        {
            //_fileEnd = string.Format("feasts.{0}_{1}.txt", GetSeasonString(), _sectionOfDay);
            _fileEnd = string.Format("feasts.{0}", GetSeasonString(_sectionOfDay));
            //if (!_fileEnd.EndsWith(".txt"))
            //    Debug.WriteLine($"{_Tag}.LoadText: _fileEnd = {_fileEnd}");

            FileDetails fileDetails = new FileDetails();

            if (pSect == PrayerSect.AllSections)
            {
                fileDetails.Add(LoadIntro());
                fileDetails.Add(LoadPraise());
                fileDetails.Add(base.LoadText(pSect));
            }
            else
            {
                switch (pSect)
                {
                case PrayerSect.Intro:
                    fileDetails.Add(LoadIntro());
                    break;

                case PrayerSect.Praise:
                    fileDetails.Add(LoadPraise());
                    break;

                default:
                    fileDetails.Add(base.LoadText(pSect));
                    break;
                }
            }

            return(fileDetails);
        }
Exemplo n.º 16
0
        FileDetails LoadIntro()
        {
            FileDetails fileDetails = new FileDetails();

            if (_testMode)
            {
                fileDetails.AddText($"<p/><b>{_Tag} - 1. Intro</b><p/>");
            }
            if (_morning)
            {
                //string filebase = string.Format("{0}.{1}", _base, _baseName[PrayerSect.Intro]);
                //string filename = string.Format("{0}.{1}", filebase, _fileEnd);

                string filenamePart2 = string.Format("{0}.{1}", _baseName[PrayerSect.Intro], _fileEnd);
                fileDetails.Add(base.LoadIntro(filenamePart2));                                                 // Load 1.Intro.morning/evening_opening.txt
                string filename = string.Format("{0}.{1}", _base, filenamePart2);
                fileDetails.Add(LoadFile(filename, PrayerSect.Intro));
            }
            else
            {
                fileDetails.Add(base.LoadIntro(""));                                                 // Load 1.Intro.morning/evening_opening.txt
            }

            return(fileDetails);
        }
Exemplo n.º 17
0
        bool Transfers_PublicSearch(ulong key, FileDetails details)
        {
            // shouldnt be called, transfer starts directly
            Debug.Assert(false);

            return(false);
        }
Exemplo n.º 18
0
        private void GenerateAndMergeFilesAsync(UniqueRandom uniqueRandom)
        {
            var inputFileDetails = new FileDetails(this.Input);

            this.GenerateFiles(uniqueRandom, inputFileDetails);
            this.MergeFiles(inputFileDetails, uniqueRandom.SubRanges.Count);
        }
Exemplo n.º 19
0
        public static async Task <FileDetails?> GetFileDetailsAsync(string filename)
        {
            FileDetails?        nullable;
            bool                flag;
            FileDetailsResult_t?fileDetails = await SteamApps.Internal.GetFileDetails(filename);

            FileDetailsResult_t?nullable1 = fileDetails;

            fileDetails = null;
            flag        = (!nullable1.HasValue ? true : nullable1.Value.Result != Result.OK);
            if (!flag)
            {
                FileDetails fileDetail = new FileDetails()
                {
                    SizeInBytes = nullable1.Value.FileSize,
                    Flags       = nullable1.Value.Flags
                };
                byte[] fileSHA = nullable1.Value.FileSHA;
                fileDetail.Sha1 = String.Join("",
                                              from x in fileSHA
                                              select x.ToString("x"));
                nullable = new FileDetails?(fileDetail);
            }
            else
            {
                nullable = null;
            }
            return(nullable);
        }
Exemplo n.º 20
0
        public static Viewer CreateViewer(FileDetails file)
        {
            IDictionary <int, IViewerFactory> priorities = new SortedDictionary <int, IViewerFactory>();

            foreach (IViewerFactory factory in factories)
            {
                if (factory.Enabled)
                {
                    int priority = factory.GetExtensionPriority(file.Extension);
                    if (priority >= 0)
                    {
                        priorities[-priority] = factory;
                    }
                }
            }

            foreach (KeyValuePair <int, IViewerFactory> kvp in priorities)
            {
                if (kvp.Value.CanDisplayFile(file))
                {
                    Viewer viewer = kvp.Value.CreateViewer();
                    viewer.File = file;
                    return(viewer);
                }
            }
            return(null);
        }
Exemplo n.º 21
0
    private static void GetFileDetails()
    {
        try
        {
            Console.WriteLine("-----------*******Waiting info about file*******-----------");

            // Получаем информацию о файле
            receiveBytes = receivingUdpClient.Receive(ref RemoteIpEndPoint);
            Console.WriteLine("----Information about file was get!");

            XmlSerializer fileSerializer = new XmlSerializer(typeof(FileDetails));
            MemoryStream  stream1        = new MemoryStream();

            // Считываем информацию о файле
            stream1.Write(receiveBytes, 0, receiveBytes.Length);
            stream1.Position = 0;

            // Вызываем метод Deserialize
            fileDet = (FileDetails)fileSerializer.Deserialize(stream1);
            Console.WriteLine("File got as" + fileDet.FILETYPE +
                              " have size " + fileDet.FILESIZE.ToString() + " byte");
        }
        catch (Exception eR)
        {
            Console.WriteLine(eR.ToString());
        }
    }
        public void TEST_VERSION_NEGATIVE()
        {
            FileDetails fileDetails = new FileDetails(@"C:\Test.txt");

            Assert.IsNull(fileDetails.Version());
            Assert.AreNotEqual("0.1.23", fileDetails.Version(), "Test case failed.");
        }
Exemplo n.º 23
0
        public void CreationTest()
        {
            string      testFilePath = MakeTempFile();
            FileDetails testFile     = new FileDetails(testFilePath);

            Assert.NotNull(testFile);
        }
Exemplo n.º 24
0
        private void ItemSelected(object sender, EventArgs e)
        {
            ListViewItem item = listView.SelectedItems[0];
            FileDetails  file = (FileDetails)item.Tag;

            if (tabs.ContainsKey(file))
            {
                viewers.SelectedTab = tabs[file];
            }
            else
            {
                Viewer viewer = Viewer.CreateViewer(file);
                if (viewer != null)
                {
                    BpTabPage newpage = new BpTabPage();
                    newpage.Text       = viewer.Title;
                    newpage.ImageIndex = item.ImageIndex;
                    tabs[file]         = newpage;
                    viewers.Controls.Add(newpage);
                    viewers.SelectedTab = newpage;
                    newpage.Controls.Add(viewer);
                    viewer.Dock = DockStyle.Fill;
                }
                else
                {
                    MessageBox.Show("No viewer capable of displaying this file is included.", "Cannot view file", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
        }
Exemplo n.º 25
0
        public async Task <ActionResult <FileDetailsViewModels> > UploadFile([FromForm] UploadImageCommand imageCommand)
        {
            var file = imageCommand.File;

            if (file.Length > 0)
            {
                var details = new FileDetails
                {
                    Size         = file.Length,
                    Name         = file.FileName,
                    AddedDate    = DateTime.UtcNow,
                    LastModified = DateTime.UtcNow,
                    ContentType  = file.ContentType,
                    Description  = imageCommand.Description,
                    Tags         = imageCommand.Tags
                };

                var fileDetails = await _storageService.UploadFileAsync(file.OpenReadStream(), details);

                return(Ok(ViewModelsMapper.ConvertFileDetailsToFileDetailsViewModels(fileDetails)));
            }
            else
            {
                return(BadRequest("File is required."));
            }
        }
 public ExtractedFileDetailsForm(string filePath)
 {
     InitializeComponent();
     this.fileDetails = new FileDetails(filePath);
     this.fileDetailsPropertyGrid.SelectedObject = this.fileDetails;
     this.Text = this.fileDetails.Name;
 }
Exemplo n.º 27
0
        private void LoadExcel()
        {
            try
            {
                string   path          = Properties.Settings.Default.loadPath;
                string   directoryName = string.Empty;
                var      dirDetails    = Directory.GetDirectories(path);
                string[] dirNames      = System.Enum.GetNames(typeof(DirectoryNames));

                foreach (string dir in dirDetails)
                {
                    if (dir.Contains(DirectoryNames.LookupModelExcel.ToString()))
                    {
                        directoryName = DirectoryNames.LookupModelExcel.ToString();
                        string[] files = Directory.GetFiles(dir);
                        foreach (string file in files)
                        {
                            string fileName = Path.GetFileName(file);
                            File.Move(dir + "\\" + fileName, Properties.Settings.Default.progressPath + directoryName + "\\" + fileName);
                            ls = new LookupServices();
                            FileDetails fd = new FileDetails();
                            fd.FileName      = fileName;
                            fd.DirectoryName = directoryName;
                            HttpResponseMessage res = ls.InsertLookupData(fd);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                WriteToFile(ex.Message);
            }
        }
        public void FileAggregate_RecordFileLineAsRejected_FileLineUpdatedAsRejected()
        {
            FileAggregate fileAggregate = FileAggregate.Create(TestData.FileId);

            fileAggregate.CreateFile(TestData.FileImportLogId, TestData.EstateId, TestData.MerchantId, TestData.UserId,
                                     TestData.FileProfileId, TestData.FileLocation, TestData.FileUploadedDateTime);
            fileAggregate.AddFileLine(TestData.FileLine);
            fileAggregate.RecordFileLineAsRejected(TestData.LineNumber, TestData.RejectionReason);

            FileDetails fileDetails = fileAggregate.GetFile();

            fileDetails.FileLines.ShouldNotBeNull();
            fileDetails.FileLines.ShouldNotBeEmpty();
            fileDetails.FileLines.ShouldHaveSingleItem();
            fileDetails.FileLines.Single().LineNumber.ShouldBe(1);
            fileDetails.FileLines.Single().LineData.ShouldBe(TestData.FileLine);
            fileDetails.FileLines.Single().ProcessingResult.ShouldBe(ProcessingResult.Rejected);
            fileDetails.FileLines.Single().RejectedReason.ShouldBe(TestData.RejectionReason);
            fileDetails.ProcessingCompleted.ShouldBeTrue();
            fileDetails.ProcessingSummary.ShouldNotBeNull();
            fileDetails.ProcessingSummary.TotalLines.ShouldBe(1);
            fileDetails.ProcessingSummary.NotProcessedLines.ShouldBe(0);
            fileDetails.ProcessingSummary.FailedLines.ShouldBe(0);
            fileDetails.ProcessingSummary.SuccessfullyProcessedLines.ShouldBe(0);
            fileDetails.ProcessingSummary.IgnoredLines.ShouldBe(0);
            fileDetails.ProcessingSummary.RejectedLines.ShouldBe(1);
        }
Exemplo n.º 29
0
        private async Task GetFiles(string fileName)
        {
            CheckAllFiles.Content = "Go Started";

            FileDetailsHolderService fileDetailsHolderService = ServiceLocator.Instance.GetService <FileDetailsHolderService>();

            // fileDetailsHolderService.Details.Clear();

            string[] files = Directory.GetFiles(fileName, "*.*", SearchOption.AllDirectories);

            await Task.Run(() =>
            {
                foreach (string file in files)
                {
                    if (!fileDetailsHolderService.Details.Any(x => x.FullFilePath == file))
                    {
                        FileDetails fd = new FileDetails(file);
                        fileDetailsHolderService.Details.Add(fd);
                        ShowDetails.Add(fd);
                    }
                }
            });

            CheckAllFiles.Content = "Go Done";
        }
Exemplo n.º 30
0
        public ActionResult SaveFiles(HttpPostedFileBase file)
        {
            FileDetails model = new FileDetails();

            if (file != null && file.ContentLength > 0)
            {
                using (Stream fs = file.InputStream)
                {
                    using (BinaryReader br = new BinaryReader(fs))
                    {
                        model.Image = br.ReadBytes((Int32)fs.Length);
                    }
                }
                try
                {
                    string path = Path.Combine(Server.MapPath("~/App_Data"), Path.GetFileName(file.FileName));
                    //file.SaveAs(path);
                    ViewBag.Message = "File uploaded successfully";
                }
                catch (Exception ex)
                {
                    ViewBag.Message = "ERROR:" + ex.Message.ToString();
                }
            }
            else
            {
                ViewBag.Message = "You have not specified a file.";
            }
            return(View("Index", model));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,FileName,Extension,ServiceRequestId")] FileDetails fileDetails)
        {
            if (id != fileDetails.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(fileDetails);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FileDetailsExists(fileDetails.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ServiceRequestId"] = new SelectList(_context.ServiceRequests, "Id", "RequestDescription", fileDetails.ServiceRequestId);
            return(View(fileDetails));
        }
        public void GetFile_Return_File()
        {
            // Arrange
            var fileName    = "Test.pdf";
            var contentType = "application/pdf";

            byte[]            bytes       = Encoding.ASCII.GetBytes("This is test file string");
            FileContentResult fileContent = new FileContentResult(bytes, contentType);

            fileContent.FileDownloadName = fileName;
            FileDetails _file = new FileDetails()
            {
                FileName    = fileName,
                ContentType = contentType,
                Content     = fileContent.FileContents
            };

            this._mockBblobService.Setup(x => x.CheckFileBlobExistsAsync(It.IsAny <string>())).Returns(true);
            this._mockBblobService.Setup(x => x.GetFileBlobAsync(It.IsAny <string>())).Returns(() => Task.FromResult(_file));
            this._fileController = new FileController(this._mockBblobService.Object, this._mockLogger.Object, this._mockFileConfigOptions.Object);


            // Act
            var actual   = this._fileController.GetFile(fileName).Result as FileContentResult;
            var expected = fileContent;

            // Assert
            Assert.IsType <FileContentResult>(actual);
            Assert.Equal(expected.ContentType, actual.ContentType);
        }
Exemplo n.º 33
0
        private void ReceivePublicDetails(RudpSession session, ShareCollection file)
        {
            ShareCollection collection;

            if (!Collections.SafeTryGetValue(session.UserID, out collection))
            {
                return;
            }

            collection.Key  = file.Key;
            collection.Size = file.Size;
            collection.Hash = file.Hash;

            foreach (DhtClient done in collection.ToRequest.Where(t => t.ClientID == session.ClientID).ToArray())
            {
                collection.ToRequest.Remove(done);
            }


            FileDetails details = new FileDetails(ServiceID, DataTypePublic, file.Hash, file.Size, null);

            object[] args = new object[] { collection, (object)session.ClientID };


            DhtClient  client   = new DhtClient(session.UserID, session.ClientID);
            OpTransfer transfer = Core.Transfers.StartDownload(client.UserID, details, GetPublicPath(collection), new EndDownloadHandler(CollectionDownloadFinished), args);

            transfer.AddPeer(client);
            transfer.DoSearch = false;

            collection.Status = "Starting List Download";
        }
Exemplo n.º 34
0
        private static void GetFileDetails()
        {
            try
            {
                Console.WriteLine("-----------*******Ожидание информации о файле*******-----------");

                // Получаем информацию о файле
                receiveBytes = receivingUdpClient.Receive(ref RemoteIpEndPoint);
                Console.WriteLine("----Информация о файле получена!");

                XmlSerializer fileSerializer = new XmlSerializer(typeof(FileDetails));
                MemoryStream stream1 = new MemoryStream();

                // Считываем информацию о файле
                stream1.Write(receiveBytes, 0, receiveBytes.Length);
                stream1.Position = 0;

                // Вызываем метод Deserialize
                fileDet = (FileDetails)fileSerializer.Deserialize(stream1);
                Console.WriteLine("Получен файл типа ." + fileDet.FILETYPE +
                    " имеющий размер " + fileDet.FILESIZE.ToString() + " байт");
            }
            catch (Exception eR)
            {
                Console.WriteLine(eR.ToString());
            }
        }
Exemplo n.º 35
0
 public CustomFileDetails(FileDetails fd)
 {
     this.Name = fd.Name;
     this.FullName = fd.FullName;
     this.Extension = fd.Extension;
     this.Format = fd.Format;
     this.LastAccessTime = fd.LastAccessTime;
     this.LastWriteTime = fd.LastWriteTime;
     this.CreationTime = fd.CreationTime;
     this.Length = fd.Length;
 }
Exemplo n.º 36
0
        public static void WriteZipFile(List<FileDetails> filesToZip, string path,string manifestPath,string manifest )
        {
            int compression = 9;
          
            FileDetails fd = new FileDetails(manifest, manifestPath,manifestPath);
            filesToZip.Insert(0,fd);

            foreach (FileDetails obj in filesToZip)
                if (!File.Exists(obj.FilePath))
                    throw new ArgumentException(string.Format("The File {0} does not exist!", obj.FileName));

            Object _locker=new Object();
            lock(_locker)
            {
                Crc32 crc32 = new Crc32();
                ZipOutputStream stream = new ZipOutputStream(File.Create(path));
                stream.SetLevel(compression);
                for (int i = 0; i < filesToZip.Count; i++)
                {
                    ZipEntry entry = new ZipEntry(filesToZip[i].FolderInfo + "/" + filesToZip[i].FileName);
                    entry.DateTime = DateTime.Now;
                    if (i == 0)
                    {
                        entry = new ZipEntry(manifest);
                    }

                    using (FileStream fs = File.OpenRead(filesToZip[i].FilePath))
                    {
                        byte[] buffer = new byte[fs.Length];
                        fs.Read(buffer, 0, buffer.Length);
                        entry.Size = fs.Length;
                        fs.Close();
                        crc32.Reset();
                        crc32.Update(buffer);
                        entry.Crc = crc32.Value;
                        stream.PutNextEntry(entry);
                        stream.Write(buffer, 0, buffer.Length);
                    }
                }
                stream.Finish();
                stream.Close();
                DeleteManifest(manifestPath);
            }
            

          

           
        }
Exemplo n.º 37
0
        private OpTransfer StartTransfer(DhtClient client, SharedFile file)
        {
            FileDetails details = new FileDetails(ServiceID, DataTypeShare, file.Hash, file.Size, null);
            object[] args = new object[] { file };

            OpTransfer transfer = Core.Transfers.StartDownload(client.UserID, details, args, new EndDownloadHandler(FileDownloadFinished));

            transfer.AddPeer(client);

            file.TransferStatus =  "Starting download from " + Core.GetName(client.UserID);

            return transfer;
        }
Exemplo n.º 38
0
        bool Transfers_FileSearch(ulong key, FileDetails details)
        {
            bool found = false;

            Local.Files.LockReading(() =>
            {
                if (Local.Files.Any(f => f.Size == details.Size && Utilities.MemCompare(f.Hash, details.Hash)))
                    found = true;
            });

            return found;
        }
Exemplo n.º 39
0
        string Transfers_PublicRequest(ulong key, FileDetails details)
        {
            ShareCollection collection;
            if (!Collections.SafeTryGetValue(key, out collection))
                return null;

            if (collection.Size != details.Size || !Utilities.MemCompare(collection.Hash, details.Hash))
                return null;

            return GetPublicPath(collection);
        }
Exemplo n.º 40
0
        bool Transfers_PublicSearch(ulong key, FileDetails details)
        {
            // shouldnt be called, transfer starts directly
            Debug.Assert(false);

            return false;
        }
Exemplo n.º 41
0
        private void ReceivePublicDetails(RudpSession session, ShareCollection file)
        {
            ShareCollection collection;
            if (!Collections.SafeTryGetValue(session.UserID, out collection))
                return;

            collection.Key = file.Key;
            collection.Size = file.Size;
            collection.Hash = file.Hash;

            foreach (DhtClient done in collection.ToRequest.Where(t => t.ClientID == session.ClientID).ToArray())
                collection.ToRequest.Remove(done);

            FileDetails details = new FileDetails(ServiceID, DataTypePublic, file.Hash, file.Size, null);
            object[] args = new object[] { collection, (object) session.ClientID };

            DhtClient client = new DhtClient(session.UserID, session.ClientID);
            OpTransfer transfer = Core.Transfers.StartDownload(client.UserID, details, args, new EndDownloadHandler(CollectionDownloadFinished));
            transfer.AddPeer(client);
            transfer.DoSearch = false;

            collection.Status = "Starting List Download";
        }
Exemplo n.º 42
0
 public List<FileDetails> GetSelectedLanguageFiles(string cultureCode, List<FileDetails> localeList, string filePath, string extension)
 {
     System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(Server.MapPath(filePath));
     System.IO.FileInfo[] basefiles = di.GetFiles(extension);
     foreach (System.IO.FileInfo fi in basefiles)
     {
         FileDetails fd = new FileDetails();
         fd.FileName = fi.Name;
         fd.FilePath = fi.FullName;
         fd.FolderInfo = di.Name;
         localeList.Add(fd);
     }
     return(DirectoryWalkThrough(di, localeList, cultureCode, extension, filePath.Replace("~/", "")));
 }
Exemplo n.º 43
0
    public List<FileDetails> DirectoryWalkThrough(System.IO.DirectoryInfo di, List<FileDetails> localeList, string cultureCode, string extension, string filePath)
    {
        System.IO.FileInfo[] basefiles = di.GetFiles(extension);
        foreach (System.IO.FileInfo fi in basefiles)
        {
            FileDetails fd = new FileDetails();
            fd.FileName = fi.Name;
            fd.FilePath = fi.FullName;

            int indexStart = fi.FullName.IndexOf(filePath);
            int indexEnd = fi.FullName.LastIndexOf("\\");

            fd.FolderInfo = fi.FullName.Substring(indexStart, indexEnd - indexStart);
            localeList.Add(fd);
        }
        foreach (System.IO.DirectoryInfo di_child in di.GetDirectories())
        {
            localeList = DirectoryWalkThrough(di_child, localeList, cultureCode, extension, filePath);
        }

        List<FileDetails> selectedResxList = new List<FileDetails>();
        foreach (FileDetails obj in localeList)
        {
            if (obj.FileName.Contains(cultureCode))
            {
                selectedResxList.Add(new FileDetails(obj.FileName, obj.FilePath, obj.FolderInfo));
            }
        }
        return selectedResxList;
    }
Exemplo n.º 44
0
 private bool CheckFileDetails(FileDetails details)
 {
     return File.Exists (details.filepath);
 }
Exemplo n.º 45
0
        private void GetFileFromAsm(string filename,
					     out FileDetails details)
        {
            System.Reflection.Assembly asm =
                System.Reflection.Assembly.
                GetExecutingAssembly ();
            Stream asmstream =
                asm.GetManifestResourceStream (filename);
            string tmpfile = Path.GetTempFileName ();
            Stream stream =
                new FileStream (tmpfile, FileMode.Append,
                        FileAccess.Write);
            byte[]buf = new byte[1024];
            int nread;
            int ntotal = 0;
            while ((nread =
                asmstream.Read (buf, 0, buf.Length)) > 0) {
                stream.Write (buf, 0, nread);
                ntotal += nread;
            }
            asmstream.Close ();
            stream.Close ();
            details.filepath = tmpfile;
            details.length = ntotal;
        }
Exemplo n.º 46
0
        string Transfers_FileRequest(ulong key, FileDetails details)
        {
            SharedFile share = null;

            Local.Files.LockReading(() =>
            {
                share = Local.Files.Where(f => f.Size == details.Size && Utilities.MemCompare(f.Hash, details.Hash)).FirstOrDefault();
            });

            if (share != null && share.Completed)
                return GetFilePath(share);

            return null;
        }