Exemple #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);
        }
Exemple #2
0
        public ActionResult ScansBin()
        {
            ScansRepository   repository = new ScansRepository();
            ScansBinViewModel viewModel  = new ScansBinViewModel()
            {
                ScansList = repository.GetBinScansList()
            };

            return(View(viewModel));
        }
Exemple #3
0
        public DateTime GetImportDate(Guid scanGuid)
        {
            var sp = new ScansRepository().GetScans().Where(s => s.ScanID == scanGuid).FirstOrDefault();

            if (sp == null || !sp.importDate.HasValue)
            {
                return(new DateTime());
            }
            return(sp.importDate.Value);
        }
Exemple #4
0
        public string GetFileName(Guid scanGuid)
        {
            var sp = new ScansRepository().GetScans().Where(s => s.ScanID == scanGuid).FirstOrDefault();

            if (sp == null)
            {
                return(string.Empty);
            }
            return(sp.FileName);
        }
Exemple #5
0
        public JsonResult DeleteScanFromRecycleBin(Guid scanID)
        {
            bool result = true;

            try
            {
                ScansRepository repository = new ScansRepository();
                repository.DeleteScanFromRecycleBin(scanID);
            }
            catch { result = false; }

            return(Json(result));
        }
Exemple #6
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));
        }
Exemple #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"));
        }
Exemple #8
0
 public VersionBrowserViewModel(Guid scanGuid)
 {
     _repository = new ScansRepository();
     Scan        = new ScansRepository().GetScan(scanGuid);
 }
Exemple #9
0
 public VersionBrowserViewModel()
 {
     _repository = new ScansRepository();
 }
Exemple #10
0
        public ActionResult Edit(Guid documentID, string selectedScans, string DocumentNumber, string CaseNumber,
                                 DateTime?Date, int?CategoryID, int?TypeID, string sendersIDs, string Description, string Submit, int?Type2ID, string Tags, bool?Flag1)
        {
            if (Submit.Equals("Zapisz"))
            {
                DocumentDetails details  = _repository.GetDocumentDetails(documentID);
                Document        document = _repository.GetDocument(documentID);

                if (AppContext.AllowScansWrite())
                {
                    ScansRepository scansRepository = new ScansRepository();

                    #region Add/Remove scans
                    List <Guid> scansIDs      = new List <Guid>();
                    List <Guid> scansToAdd    = new List <Guid>();
                    List <Guid> scansToRemove = new List <Guid>();

                    foreach (string g in selectedScans.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        Guid guid;
                        try
                        {
                            guid = new Guid(g);
                            if (!details.ScanIDs.Contains(guid))
                            {
                                scansToAdd.Add(guid);
                            }
                        }
                        catch (FormatException)
                        {
                            break;
                        }
                        scansIDs.Add(guid);
                    }

                    foreach (Guid guid in details.ScanIDs)
                    {
                        if (!scansIDs.Contains(guid))
                        {
                            scansToRemove.Add(guid);
                        }
                    }

                    _repository.SetDocumentScans(scansToAdd, documentID);
                    _repository.RemoveDocumentScans(scansToRemove);
                    #endregion
                }

                if (AppContext.AllowInfoTypeOneWrite())
                {
                    details.InfoTypeOne.DocumentNumber = DocumentNumber;
                    details.InfoTypeOne.CaseNumber     = CaseNumber;
                    details.InfoTypeOne.Date           = Date;
                    details.InfoTypeOne.CategoryID     = CategoryID;
                    details.InfoTypeOne.TypeID         = TypeID;
                    details.InfoTypeOne.Type2ID        = Type2ID;
                    details.InfoTypeOne.Tags           = Tags;
                }

                if (AppContext.AllowInfoTypeTwoWrite())
                {
                    string[] senderIDs = sendersIDs.Split(',');
                    _repository.RemoveSenders(documentID);
                    foreach (string sid in senderIDs)
                    {
                        int tmp;
                        if (!int.TryParse(sid, out tmp))
                        {
                            continue;
                        }
                        _repository.AddSender(documentID, tmp);
                    }

                    details.InfoTypeTwo.Description = Description;
                    details.InfoTypeTwo.Flag1       = Flag1 ?? false;
                }

                document.Editor = AppContext.GetUserGuid();

                _repository.SubmitChanges();
            }

            return(RedirectToAction("Details", new { documentID = documentID }));
        }