Exemple #1
0
        /// <summary>
        /// PDF Template For Document Detail Page
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        // [Route("document/PDFTemplate/{id}")]
        public ActionResult PDFTemplate(string vID)
        {
            string id         = vID.ToString();
            Guid   documentID = Guid.Empty;

            if (!string.IsNullOrEmpty(id))
            {
                Guid.TryParse(id, out documentID);
            }

            if (documentID == null || documentID == Guid.Empty)
            {
                return(Redirect("/"));
            }

            var  model    = new DocumentDetailModel();
            bool isExists = model.Populate(documentID, urlPathForDoc);

            if (!isExists)
            {
                return(Redirect("/"));
            }

            //Populate Share Link
            string currentURL = Request.Url.ToString();

            model.PopulateShare(currentURL);


            ViewBag.PageTitle       = model.RecordLanguage.Name;
            ViewBag.PageDescription = string.Empty;
            ViewBag.PageKeywords    = string.Empty;

            return(View("~/Views/Document/PDFFormat.cshtml", model));
        }
Exemple #2
0
        public ActionResult Index(string id, string urlFriendlyName)
        {
            Guid documentID = Guid.Empty;

            if (!string.IsNullOrEmpty(id))
            {
                Guid.TryParse(id, out documentID);
            }

            if (documentID == null || documentID == Guid.Empty)
            {
                return(Redirect("/"));
            }

            urlPathForDoc = Request.Url.ToString();
            try
            {
                string d = Request.UrlReferrer.ToString();
            }
            catch { }
            var  model    = new DocumentDetailModel();
            bool isExists = model.Populate(documentID, urlPathForDoc);

            if (!isExists)
            {
                return(Redirect("/"));
            }

            //Populate Share Link
            string currentURL = Request.Url.ToString();

            model.PopulateShare(currentURL);


            ViewBag.PageTitle       = model.RecordLanguage.Name;
            ViewBag.PageDescription = string.Empty;
            ViewBag.PageKeywords    = string.Empty;

            return(View("~/Views/Document/Index.cshtml", model));
        }
Exemple #3
0
        public ActionResult download(string id, string isPublic)
        {
            try
            {//intracen
                string UrlReferrerForDoc = Request.UrlReferrer.ToString();
                bool   contains          = UrlReferrerForDoc.Contains("intracen");
                if (contains == false)
                {
                    urlPathForDoc = UrlReferrerForDoc;
                }
            }
            catch { }
            if (isPublic == "ITCdownload")
            {
                //Authorization checking
                if (AppSettingsUtility.GetBool(AppSettingsKeys.EnableAuthorization) && Session[SiteConstants.SESSION_USER_AUTHORIZED] == null)
                {
                    string logonURL  = AppSettingsUtility.GetString(AppSettingsKeys.LogOnURL);
                    string returnURL = HttpUtility.UrlEncode(Request.Url.ToString());
                    string domain    = Request.Url.Host;
                    logonURL = logonURL.Replace("[returnURL]", returnURL).Replace("[authDomain]", domain);
                    return(Redirect(logonURL));
                }
            }

            if (System.Web.HttpContext.Current.Session[SiteConstants.SESSION_USER] != null)
            {
                TSM.Entity.User user = (TSM.Entity.User)System.Web.HttpContext.Current.Session[SiteConstants.SESSION_USER];

                string mail     = user.Email;
                string host     = mail.Split('@')[1].ToString();
                string mailCred = "intracen.org"; // "intracen.org";

                if (host != mailCred)
                {
                    return(Content("<script language='javascript' type='text/javascript'>alert('You are not authorized to download the document.'); window.close();</script>"));
                }
            }

            string zipFolderPath = Server.MapPath("~/UploadedFiles/Documents/tempZip/");
            string zipFilePath   = "document_" + DateTime.Now.Ticks.ToString() + ".zip";

            if (!Directory.Exists(zipFolderPath))
            {
                Directory.CreateDirectory(zipFolderPath);
            }

            string folderPath = Server.MapPath("~/UploadedFiles/Documents/");

            Guid recordID = Guid.Empty;

            if (!string.IsNullOrEmpty(id))
            {
                Guid.TryParse(id, out recordID);
            }

            if (recordID == null || recordID == Guid.Empty)
            {
                return(Redirect("/"));
            }

            var documents = RecordService.GetDocuments(recordID);

            if (documents == null || documents.Count == 0)
            {
                return(Redirect("/"));
            }

            List <string> files = new List <string>();

            foreach (var document in documents)
            {
                string file = folderPath + document.Path;
                files.Add(file);
            }
            string ZipFile = zipFolderPath + zipFilePath;

            ZipHelper.WriteZipFile(files, ZipFile, 6);

            byte[] fileBytes = System.IO.File.ReadAllBytes(ZipFile);
            string fileName  = "document.zip";

            Guid documentID = Guid.Empty;

            if (!string.IsNullOrEmpty(id))
            {
                Guid.TryParse(id, out documentID);
            }
            var  model    = new DocumentDetailModel();
            bool isExists = model.Populate(documentID, urlPathForDoc);

            model.ZipFilePath = ZipFile.ToString();
            model.LoginStat   = "Y";

            return(View("~/Views/Document/Index.cshtml", model));
        }