public void TestGetPages(string filePath, PreviewOptions.FormatEnum?format = null, List <int?> pageNumbersToConvert = null,
                                 bool withoutAnnotations = false, int width       = 0, int height = 0,
                                 bool renderComments     = false, string password = null)
        {
            var fileInfo = new Model.FileInfo
            {
                FilePath = filePath,
                Password = password
            };
            var options = new PreviewOptions
            {
                FileInfo       = fileInfo,
                Format         = format,
                Height         = height,
                Width          = width,
                PageNumbers    = pageNumbersToConvert,
                RenderComments = renderComments
            };
            var request = new GetPagesRequest(options);
            var result  = PreviewApi.GetPages(request);

            Assert.NotNull(result);
            Assert.Greater(result.TotalCount, 0);
            Assert.NotNull(result.Entries);
            Assert.Greater(result.Entries.Count, 0);
        }
        public void TestDeletePages(string filePath)
        {
            var fileInfo = new Model.FileInfo
            {
                FilePath = filePath
            };

            PreviewApi.DeletePages(new DeletePagesRequest(fileInfo));
        }
Beispiel #3
0
        public void TestExtract(string filePath)
        {
            var fileInfo = new Model.FileInfo {
                FilePath = filePath
            };
            var annotations = AnnotateApi.Extract(new ExtractRequest(fileInfo));

            Assert.AreNotEqual(null, annotations);
            Assert.Greater(annotations.Count, 0);
            Assert.IsInstanceOf(typeof(AnnotationInfo), annotations[0]);
        }
        public void TestGetInfo(string filePath, string password = null)
        {
            var fileInfo = new Model.FileInfo
            {
                FilePath = filePath,
                Password = password
            };
            var request = new GetInfoRequest(fileInfo);
            var info    = InfoApi.GetInfo(request);

            Assert.NotNull(info);
            Assert.AreEqual(filePath, info.Path);
        }
        public void TestGetInfoReturnsFileNotFound()
        {
            // Arrange
            var fileInfo = new Model.FileInfo
            {
                FilePath = TestFiles.NotExist.FullName,
                Password = TestFiles.NotExist.Password
            };
            var request = new GetInfoRequest(fileInfo);

            // Act & Assert
            var ex = Assert.Throws <ApiException>(() => {
                InfoApi.GetInfo(request);
            });

            Assert.AreEqual("Specified file not found", ex.Message);
        }
Beispiel #6
0
        public void TestAddAnnotationsManyPages(string filePath)
        {
            var fileInfo = new Model.FileInfo
            {
                FilePath = filePath
            };
            var options = new AnnotateOptions
            {
                FileInfo    = fileInfo,
                Annotations = GetAnnotationsManyPages(),
                OutputPath  = $"{DefaultOutputPath}/{Path.GetFileName(filePath)}"
            };
            var request = new AnnotateRequest(options);
            var result  = AnnotateApi.Annotate(request);

            Assert.IsNotNull(result);
            Assert.IsNotEmpty(result.Href);
        }
Beispiel #7
0
        public void TestAddDirect(string filePath, string annotationTypes = null, bool annotatedPages = false, int firstPage = -1, int lastPage = -1, string password = null)
        {
            var fileInfo = new Model.FileInfo
            {
                FilePath = filePath,
                Password = password
            };
            var options = new AnnotateOptions
            {
                FileInfo           = fileInfo,
                Annotations        = GetAnnotations(),
                FirstPage          = firstPage,
                LastPage           = lastPage,
                OnlyAnnotatedPages = annotatedPages
            };
            var request = new AnnotateDirectRequest(options);
            var result  = AnnotateApi.AnnotateDirect(request);

            Assert.IsNotNull(result);
            Assert.IsInstanceOf(typeof(Stream), result);
        }
        protected void SaveFileNode(TreeNode node, bool forceUpdate = false)
        {
            if (node.Tag == null)
            {
                string folderName = string.Format("{0}\\{1}", this.PortableAppFolder, node.FullPath);
                if (!Directory.Exists(folderName))
                {
                    Directory.CreateDirectory(folderName);
                }
            }
            else if (node.Tag is Model.FileInfo)
            {
                Model.FileInfo fileInfo = node.Tag as Model.FileInfo;
                string         fileName = string.Format("{0}\\{1}", this.PortableAppFolder, node.GetFullPath());
                if (fileName.ToLower() != fileInfo.AbsolutePath.ToLower() || forceUpdate)
                {
                    if (File.Exists(fileInfo.AbsolutePath))
                    {
                        File.Copy(fileInfo.AbsolutePath, fileName, true);
                    }
                }
            }
            //else if(node.Tag is Model.FolderInfo)
            //{
            //    Model.FolderInfo folderInfo = node.Tag as Model.FolderInfo;
            //    if (!Directory.Exists(folderInfo.FolderName))
            //    {
            //        Directory.CreateDirectory(folderInfo.FolderName);
            //    }
            //}

            if (node.Nodes.Count > 0)
            {
                foreach (TreeNode childNode in node.Nodes)
                {
                    SaveFileNode(childNode, forceUpdate);
                }
            }
        }
        public async Task <IActionResult> Post(IFormFile file)
        {
            if (file == null)
            {
                return(BadRequest());
            }
            string uploadsFolder = Directory.GetCurrentDirectory() + "\\UploadFile";
            string fileName      = file.FileName;
            string filePath      = uploadsFolder + "\\" + fileName;

            if (file.Length > 0)
            {
                using (var stream = new FileStream(filePath, FileMode.Create))
                    await file.CopyToAsync(stream);
            }
            Model.FileInfo info = new Model.FileInfo();
            info.FilePath = filePath;
            info.FileName = fileName;
            _context.FileInfos.Add(info);
            _context.SaveChanges();
            // Process uploaded files

            return(Ok(new { count = 1, path = filePath }));
        }
Beispiel #10
0
 public static void SaveInfo(string fileid,string passkey,string fileName,string MIME,string Ext,int FileLength,string op)
 {
     var session = NH.NHHelper.OpenSession();
     using (session)
     {
         FileStation.Util.Model.FileInfo f = new Model.FileInfo();
         f.Op = op;
         f.PassKey = passkey;
         f.UploadDateTime = DateTime.Now;
         f.MIME = MIME;
         f.FileName = fileName;
         f.FileLength = FileLength;
         f.FileId = fileid;
         f.Ext = Ext;
         session.SaveOrUpdate(f);
         
     }
 }
Beispiel #11
0
 public void CreateFileInfo(Model.FileInfo fileInfo)
 {
     Add(fileInfo);
     Save();
 }