示例#1
0
        public ActionResult UploadScanVersion(Guid originalID, Guid documentID, HttpPostedFileBase file)
        {
            if (file != null)
            {
                ScansRepository scanRepo    = new ScansRepository();
                Scan            visibleScan = scanRepo.GetScan(originalID);

                //jeœli skan jest dodany do dokumentu podczas tej edycji, to nie mam jeszcze przypisanego ID dokumentu
                if (!visibleScan.DocumentID.HasValue)
                {
                    _repository.SetDocumentScan(visibleScan.ScanID, documentID);
                    _repository.SubmitChanges();
                }

                if (visibleScan.OriginalScanID.HasValue)
                {
                    originalID = visibleScan.OriginalScanID.Value;
                }

                ScanBrowser browser = ScanBrowserFactory.Create();
                byte[]      content = new byte[file.ContentLength];
                file.InputStream.Read(content, 0, file.ContentLength);
                ScanInfo info = browser.GetScanFromFile(content, file.FileName);
                try
                {
                    _repository.AddScanVersion(originalID, info.FileName, info.MimeType, info.Scan, info.ScanPreview ?? new byte[0], "image/png", info.ScanZoom ?? new byte[0], AppContext.GetCID());
                }
                catch { }
            }

            return(RedirectToAction("Edit", new { documentID = documentID }));// (result);
        }
示例#2
0
        public ActionResult RenderPreview(Guid scanGuid, int?rotation)
        {
            ScanPreviewViewModel viewModel = new ScanPreviewViewModel()
            {
                Scan     = _repository.GetScan(scanGuid),
                Rotation = rotation ?? 0
            };

            return(PartialView("ScanPreviewUserControl", viewModel));
        }
示例#3
0
        public ActionResult SplitFile(Guid?scanGuid)
        {
            if (scanGuid.HasValue)
            {
                ScanBrowser     browser        = ScanBrowserFactory.Create();
                ScansRepository scanRepository = new ScansRepository();
                Scan            scan           = scanRepository.GetScan(scanGuid.Value);

                byte[]   fileContent = scan.ScanContent.ToArray();
                string[] fileName    = scan.FileName.Split('.');
                string   mimeType    = scan.MimeType;

                MemoryStream stream = new MemoryStream();
                stream.Write(fileContent, 0, fileContent.Length);


                LicensingManager.LicenseKey = "lL+mtKWhtKOnrbSjuqS0p6W6paa6ra2trQ==";

                Winnovative.PdfCreator.Document sourcedoc = new Winnovative.PdfCreator.Document(stream);
                stream.Close();

                using (TransactionScope transaction = new TransactionScope())
                {
                    if (sourcedoc != null && sourcedoc.Pages.Count > 1)
                    {
                        for (int i = 0; i < sourcedoc.Pages.Count; i++)
                        {
                            Winnovative.PdfCreator.Document newdoc = SplitPdf.ExtractPages(sourcedoc, i, 1);

                            string   newFileName = string.Join(string.Format("_{0}.", (i + 1)), fileName);
                            ScanInfo newscan     = browser.GetScanFromFile(newdoc.Save(), newFileName);
                            ScansHelper.AddScan(newscan);
                        }

                        scanRepository.DeleteScanFromRecycleBin(scan.ScanID);
                    }

                    transaction.Complete();
                }
            }


            return(RedirectToAction("Index"));
        }