Example #1
0
        public void AddMissingDocs(ISet <string> searchPropIds, string fileName)
        {
            if (searchPropIds != null)
            {
                IEnumerable <DocStatusView> status = this.GetDocsStatus().ToList().Where(doc => searchPropIds.Contains(doc.PropertyId.ToString()));
                DbSet <Document>            docs   = this.GetDocuments();
                foreach (DocStatusView docStt in status)
                {
                    foreach (DocTypeEnum type in Enum.GetValues(typeof(DocTypeEnum)).Cast <DocTypeEnum>())
                    {
                        if (!IsExisting(type, docStt))
                        {
                            var doc = docs.Add(new Document {
                                Id       = Guid.NewGuid(), PropertyId = docStt.PropertyId, DocType = type.ToString(),
                                FileName = DocMgmtHelper.GetFilePathAndName(fileName)[1]
                            });
                            string password = DocMgmtHelper.GetPassword(doc.Id.ToString(), doc.PropertyId.ToString());
                            doc.DocBlob = ZipHelper.ZipFileWithPassword(password, fileName);
                        }
                    }
                }

                dbContext.SaveChanges();
            }
        }
Example #2
0
        public ActionResult ZipFile()
        {
            string docLoc    = ConfigurationManager.AppSettings["DocLocation"];
            string localPath = Server.MapPath(docLoc);
            string fileName  = DocMgmtHelper.GetFilePathAndName(localPath)[1];

            byte[] zipped   = Utilities.ZipHelper.ZipFileWithPassword("123", localPath);
            byte[] unzipped = Utilities.ZipHelper.ExtractFileFromZip(zipped, "123", fileName);

            return(File(unzipped, "application/octet-stream", "test.docx"));
        }
Example #3
0
        public ActionResult DownloadDoc(Guid?docId, string docType)
        {
            string   docLoc    = ConfigurationManager.AppSettings["DocLocation"];
            string   localPath = Server.MapPath(docLoc);
            string   fileName  = DocMgmtHelper.GetFilePathAndName(localPath)[1];
            Document doc       = repoService.GetDocuments().First(d => d.Id == docId && d.DocType.ToString().Equals(docType));

            string pswd = DocMgmtHelper.GetPassword(doc.Id.ToString(), doc.PropertyId.ToString());

            byte[] unzipped = Utilities.ZipHelper.ExtractFileFromZip(doc.DocBlob, pswd, fileName);
            return(File(unzipped, "application/octet-stream", fileName));
        }