Пример #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 static void GetScansFromFolder()
        {
            scans = ScanBrowserFactory.Create();
            if (IsProcessing)
            {
                return;
            }
            IsProcessing = true;
            try
            {
                IList <ScanInfo> scansToProcess = scans.GetScans(true);

                foreach (ScanInfo scan in scansToProcess)
                {
                    AddScan(scan);
                    scans.RemoveScan(scan.FullFileName);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Unable to process scan: " + ex.Message + "/" + ((ex.InnerException != null) ? ex.InnerException.Message : ""));
                throw;
            }
            finally
            {
                IsProcessing = false;
            }
        }
Пример #3
0
        public JsonResult RefreshAvailableScans()
        {
            ScanBrowser scans = ScanBrowserFactory.Create();

            int[] data = new int[2];

            data[0] = scans.GetScansCount(true);
            data[1] = scans.GetScansCount(false);

            return(Json(data));
        }
Пример #4
0
        public ActionResult Edit(Guid documentID)
        {
            ScansRepository scansRepository = new ScansRepository();

            ScanBrowser scans = ScanBrowserFactory.Create();

            DocumentEditViewModel viewModel = new DocumentEditViewModel()
            {
                AllowDocumentDisplay = true,
                Details           = _repository.GetDocumentDetails(documentID),
                Categories        = _dictRepository.GetCategories().ToList(),
                Senders           = _dictRepository.GetSenders().ToList(),
                Types2            = _dictRepository.GetTypes2().ToList(),
                ScanSelectorModel = new ScanSelectorViewModel()
                {
                    AvailableScans  = scansRepository.GetAvailableScans().ToList(),
                    AllScansCount   = scans.GetScansCount(true),
                    KnownScansCount = scans.GetScansCount(false)
                }
            };

            #region Check if user can display this document
            if (viewModel.Details.Document == null)
            {
                viewModel.AllowDocumentDisplay = false;
                viewModel.DenyMessage          = "Dokument nie istnieje.";
            }
            else if (!AppContext.GetCIDs().Contains(viewModel.Details.Document.ClientID))
            {
                viewModel.AllowDocumentDisplay = false;
                viewModel.DenyMessage          = "Nie masz uprawnieñ do tego dokumentu.";
            }
            else
            {
                if (viewModel.Details.Document.ClientID != AppContext.GetCID())
                {
                    AppContext.ChangeClient(viewModel.Details.Document.ClientID);
                }
            }
            #endregion

            if (viewModel.Details.InfoTypeOne != null && viewModel.Details.InfoTypeOne.CategoryID.HasValue)
            {
                viewModel.Types = _dictRepository.GetTypes(viewModel.Details.InfoTypeOne.CategoryID.Value).ToList();
            }

            return(View(viewModel));
        }
Пример #5
0
        public ActionResult UploadScan()
        {
            for (int i = 0; i < Request.Files.Count; i++)
            {
                HttpPostedFileBase file = Request.Files[i];
                if (file != null)
                {
                    ScanBrowser browser = ScanBrowserFactory.Create();
                    byte[]      content = new byte[file.ContentLength];
                    file.InputStream.Read(content, 0, file.ContentLength);
                    ScanInfo info = browser.GetScanFromFile(content, file.FileName);

                    Guid scanId = ScansHelper.AddScan(info);
                }
            }
            return(RedirectToAction("Index"));
        }
Пример #6
0
        public ActionResult UploadScan(Guid documentID, HttpPostedFileBase file)
        {
            if (file != null)
            {
                ScanBrowser browser = ScanBrowserFactory.Create();
                byte[]      content = new byte[file.ContentLength];
                file.InputStream.Read(content, 0, file.ContentLength);
                ScanInfo info = browser.GetScanFromFile(content, file.FileName);

                Guid scanId = ScansHelper.AddScan(info);

                _repository.SetDocumentScan(scanId, documentID);
                _repository.SubmitChanges();
            }

            return(RedirectToAction("Edit", new { documentID = documentID }));// (result);
        }
Пример #7
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"));
        }
Пример #8
0
        // [Authorize]
        public ActionResult Index(Guid?documentID)
        {
            DictionaryRepository dictRepository = new DictionaryRepository();

            ScanBrowser    scans     = ScanBrowserFactory.Create();
            ScansViewModel viewModel = new ScansViewModel();

            viewModel.AllScansCount   = scans.GetScansCount(true);
            viewModel.KnownScansCount = scans.GetScansCount(false);
            viewModel.AvailableScans  = _repository.GetAvailableScans().ToList();//Context.AvailableScans.OrderByDescending(s=>s.ImportDate).ToList();
            viewModel.Categories      = dictRepository.GetCategories().ToList();
            viewModel.Types2          = dictRepository.GetTypes2().ToList();
            viewModel.Senders         = dictRepository.GetSenders().OrderBy(s => s.LastName).ThenBy(s => s.FirstName).ToList();

            if (documentID.HasValue)
            {
                viewModel.DocumentID = documentID;
            }

            return(View(viewModel));
        }
Пример #9
0
        //QUOTA [Quota(QuotaType = QuotaTypes.ScansTotalSize)]
        public ActionResult FlashUpload(string token, HttpPostedFileBase FileData)
        {
            FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(token);

            if (ticket != null)
            {
                var identity = new FormsIdentity(ticket);
                if (identity.IsAuthenticated)
                {
                    HttpPostedFileBase file = FileData;
                    if (file != null)
                    {
                        ScanBrowser browser = ScanBrowserFactory.Create();
                        byte[]      content = new byte[file.ContentLength];
                        file.InputStream.Read(content, 0, file.ContentLength);
                        ScanInfo info = browser.GetScanFromFile(content, file.FileName);

                        Guid scanId = ScansHelper.AddScan(info);
                    }
                }
            }
            return(RedirectToAction("Index"));
        }