Esempio n. 1
0
        /// <summary>
        /// populates the additional info all records have into a table
        /// </summary>
        /// <param name="Document_ID">The document Id</param>
        /// <param name="navBarGroup">Optional: The category name of the clicked navBar item</param>
        /// <param name="navBarItem">Optional: The document type name of the clicked navBar item</param>
        /// <returns>a partial view table inserted into the main table asynchronously</returns>
        public ActionResult MiscData([Bind(Prefix = "documentId")] string Document_ID, string navBarGroup, string navBarItem)
        {
            MiscPublicData documentData = null;

            documentData = documentRepository
                           .GetMiscPublicData(Document_ID);

            ViewData["currentNav"]      = navBarGroup;
            ViewData["currentNavTitle"] = navBarItem;

            return(PartialView(documentData));
        }
Esempio n. 2
0
        public ActionResult MiscData([Bind(Prefix = "documentId")] string Document_ID, string navBarGroup, string navBarItem)
        {
            //declare and instantiate the original full MiscPublicData data for the client
            MiscPublicData documentData = null;

            documentData = documentRepository
                           .GetMiscPublicData(Document_ID);

            if (documentData != null)
            {
                ViewData["currentNav"]      = navBarGroup;
                ViewData["currentNavTitle"] = navBarItem;

                return(PartialView(documentData));
            }
            else
            {
                return(HttpNotFound());
            }
        }
Esempio n. 3
0
        public MiscPublicData GetMiscPublicData(string id)
        {
            //should be able to create a function to do this repetitive code from both functions

            int documentNumberInt = Int32.Parse(id);

            var documentData = (from d in _db.tbl_Document.AsNoTracking() //.AsNoTracking reduces resources by making this read only
                                                                          //not every document will have a corrosponding docReference
                                join dr in _db.tbl_DocReference on d.Document_ID equals dr.Document_ID into ps
                                where d.Document_ID == documentNumberInt
                                from dr in ps.DefaultIfEmpty()
                                select new
            {
                d.Document_ID,
                d.Division_CD,
                d.CreatorFirstName,
                d.CreatorLastName,
                d.LastUser_DT,
                d.Reason,
                d.Recipient,
                d.tbl_DocReference
            }).First();
            //instead of doing .First(), should be a better way of bringing over just 1 record since they SHOULD(?) all be the same, probably a better LINQ statement
            //torn between making a subclass for docReference to pull those 3 properties from, or just use the full dataset.

            MiscPublicData mpd = new MiscPublicData();

            mpd.Document_ID   = documentData.Document_ID;
            mpd.Branch        = documentData.Division_CD;
            mpd.Creator       = documentData.CreatorFirstName + " " + documentData.CreatorLastName;
            mpd.ArchiveTime   = documentData.LastUser_DT;
            mpd.Reason        = documentData.Reason;
            mpd.Recipient     = documentData.Recipient;
            mpd.DocReferences = documentData.tbl_DocReference;

            return(mpd);
        }
Esempio n. 4
0
        /// <summary>
        /// Gathers additional secondary fields for the document in question
        /// </summary>
        /// <param name="id">Document Id</param>
        /// <returns>MiscPublicData with additional info of the document</returns>
        public MiscPublicData GetMiscPublicData(string id)
        {
            try {
                //should be able to create a function to do this repetitive code from both functions

                int documentNumberInt = Int32.Parse(id);

                //not every document will have a corrosponding docReference
                var documentData = (from d in _db.tbl_Document.AsNoTracking() //.AsNoTracking reduces resources by making this read only
                                    join dr in _db.tbl_DocReference on d.Document_ID equals dr.Document_ID into ps
                                    where d.Document_ID == documentNumberInt
                                    from dr in ps.DefaultIfEmpty()
                                    select new
                {
                    d.Document_ID,
                    d.Division_CD,
                    d.CreatorFirstName,
                    d.CreatorLastName,
                    d.LastUser_DT,
                    d.Reason,
                    d.Recipient,
                    Value = d.ArchivedFile != null ? SqlFunctions.DataLength(d.ArchivedFile).Value : 0,                     //Value is the byte size of file, should rename
                    //a 0 byte size will mean filesize is unobtainable, logic added in view to show this
                    //Additional information: This function can only be invoked from LINQ to Entities.
                    d.tbl_DocReference
                }).First();
                //instead of doing .First(), should be a better way of bringing over just 1 record since they SHOULD(?) all be the same, probably a better LINQ statement
                //torn between making a subclass for docReference to pull those 3 properties from, or just use the full dataset.

                MiscPublicData mpd = new MiscPublicData();

                mpd.Document_ID   = documentData.Document_ID;
                mpd.Branch        = documentData.Division_CD;
                mpd.Creator       = documentData.CreatorFirstName + " " + documentData.CreatorLastName;
                mpd.ArchiveTime   = documentData.LastUser_DT;
                mpd.Reason        = documentData.Reason;
                mpd.Recipient     = documentData.Recipient;
                mpd.FileSize      = (documentData.Value) / 1000;
                mpd.DocReferences = documentData.tbl_DocReference;

                return(mpd);
            }
            catch (FormatException e)
            {
                FormatException exception = new FormatException("Document Id must be a positive integer", e);
                exception.HelpLink            = "Please check over the provided information and try again.";
                exception.Data["Document ID"] = id;

                throw exception;
            }
            catch (InvalidOperationException e)
            {
                InvalidOperationException exception = new InvalidOperationException("There was an issue connecting to the database", e);
                exception.HelpLink = "Please contact Support through ServiceNow.";

                throw exception;
            }
            catch (Exception e)
            {
                //maybe write more here
                throw new Exception("There seems to be an issue.", e);
            }
        }