Example #1
0
 //Quality Anchor
 public ActionResult QualityAnchor()
 {
     if (Session["UserName"] == null || Session["Role"].ToString().ToLower() != "quality anchor")
     {
         log.Warn("Quality Anchor trying to access other roles");
         return(View("Authorization"));
     }
     else
     {
         try
         {
             QPMapper <QPMasterPool, Models.QPMasterPool> mapObj = new QPMapper <QPMasterPool, Models.QPMasterPool>();
             var dal = new QP_Repository();
             var doc = dal.GetDocumentsQualityAnchor(Session["UserName"].ToString());
             List <Models.QPMasterPool> documentList = new List <Models.QPMasterPool>();
             if (doc.Any())
             {
                 foreach (var item in doc)
                 {
                     documentList.Add(mapObj.Translate(item));
                 }
             }
             return(View(documentList));
         }
         catch (Exception)
         {
             log.Error("Could not fetch documents for Quality Anchor");
             return(View("DocumentError"));
         }
     }
 }
Example #2
0
        //View_Profile Functions
        #region


        public ActionResult ViewProfile(Models.Users userModel)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Login"));
            }
            else
            {
                var dal = new QP_Repository();
                QPMapper <User, Models.Users> mapObj = new QPMapper <User, Models.Users>();
                var user = dal.GetUserDetails(Session["UserName"].ToString());
                userModel         = mapObj.Translate(user);
                ViewBag.TrackName = dal.GetTrackName(Convert.ToInt32(userModel.TrackId));
                ViewBag.QPAnchor  = dal.GetQPAnchor(Convert.ToInt32(userModel.TrackId));
                ViewBag.Count     = dal.GetDocumentsForProfile(Session["UserName"].ToString());
                return(View(userModel));
            }
        }
Example #3
0
        public ActionResult QualityAnchorReject(string qpDocId)
        {
            QPMapper <Models.QPMasterPool, QPMasterPool> mapObj = new QPMapper <Models.QPMasterPool, QPMasterPool>();
            var dal = new QP_Repository();

            Models.QPMasterPool doc = new Models.QPMasterPool();
            doc.QPDocId     = qpDocId;
            doc.Status      = "A";
            doc.UpdationLog = DateTime.Now;
            bool status = dal.QPReject(mapObj.Translate(doc));

            if (status)
            {
                return(RedirectToAction("QualityAnchor"));
            }
            else
            {
                return(View("UnableToReviewerReject"));
            }
        }
Example #4
0
        //Get-Versions of Documents
        #region
        public ActionResult GetVersions(string qpDocId)
        {
            QPMapper <QPVersion, Models.QPVersion> mapObj = new QPMapper <QPVersion, Models.QPVersion>();
            var dal = new QP_Repository();
            List <Models.QPVersion> qpVersion = new List <Models.QPVersion>();

            try
            {
                var versionList = dal.GetVersions(qpDocId);
                foreach (var item in versionList)
                {
                    qpVersion.Add(mapObj.Translate(item));
                }
            }
            catch (Exception)
            {
                qpVersion = null;
            }
            return(View(qpVersion));
        }
Example #5
0
        public ActionResult ReUploadDoc(Models.QPMasterPool qpObj, HttpPostedFileBase reUpload)
        {
            var allowedExtensions = new[] { ".docx" };
            var extension         = Path.GetExtension(reUpload.FileName);

            qpObj.UpdationLog  = DateTime.Now;
            qpObj.Status       = "R";
            qpObj.DocumentName = reUpload.FileName;
            var dal = new QP_Repository();
            QPMapper <Models.QPMasterPool, QPMasterPool> mapObj = new QPMapper <Models.QPMasterPool, QPMasterPool>();

            try
            {
                if (reUpload != null && allowedExtensions.Contains(extension))
                {
                    qpObj.Document = new byte[reUpload.ContentLength];
                    reUpload.InputStream.Read(qpObj.Document, 0, reUpload.ContentLength);
                    bool status = dal.UpdateDocumentMaster(mapObj.Translate(qpObj));
                    if (status)
                    {
                        log.Info("Document uploaded successfully");
                        return(RedirectToAction("Author"));
                    }
                    else
                    {
                        log.Error("Document failed to upload");
                        return(View("UnableToUpload"));
                    }
                }
                else
                {
                    log.Error("Document failed to upload because of invalid file");
                    return(View("InvalidFile"));
                }
            }
            catch (Exception)
            {
                log.Error("Document failed to upload");
                return(View("UnableToUpload"));
            }
        }
Example #6
0
 public ActionResult QPAnchorSelect()
 {
     try
     {
         QPMapper <QPMasterPool, Models.QPMasterPool> mapObj = new QPMapper <QPMasterPool, Models.QPMasterPool>();
         var dal = new QP_Repository();
         var doc = dal.QPAnchorSelect();
         List <Models.QPMasterPool> downloadDoc = new List <Models.QPMasterPool>();
         if (doc.Any())
         {
             foreach (var item in doc)
             {
                 downloadDoc.Add(mapObj.Translate(item));
             }
         }
         return(View(downloadDoc));
     }
     catch (Exception)
     {
         return(View("DocumentError"));
     }
 }
Example #7
0
 public ActionResult CreateQP(FormCollection frm)
 {
     try
     {
         QPMapper <Models.QPMasterPool, QPMasterPool> mapObj = new QPMapper <Models.QPMasterPool, QPMasterPool>();
         int    trackId          = Convert.ToInt32(frm["Track"]);
         int    focusAreaId      = Convert.ToInt32(frm["FocusArea"]);
         int    moduleId         = Convert.ToInt32(frm["Module"]);
         byte[] newdoc           = null;
         var    dal              = new QP_Repository();
         Models.QPMasterPool obj = new Models.QPMasterPool();
         obj.Author        = frm["Author"];
         obj.Comments      = frm["Comments"];
         obj.CreationLog   = DateTime.Now;
         obj.Document      = newdoc;
         obj.DocumentName  = dal.GetDocName(trackId, focusAreaId, moduleId);
         obj.ModuleId      = moduleId;
         obj.QPDocId       = dal.GetDocId();
         obj.QualityAnchor = frm["QualityAnchor"];
         obj.Reviewer      = frm["Reviewer"];
         obj.Status        = "A";
         obj.UpdationLog   = null;
         bool status = dal.AddDocument(mapObj.Translate(obj));
         if (status)
         {
             return(RedirectToAction("QPAnchor"));
         }
         else
         {
             return(View("UnableToCreateQP"));
         }
     }
     catch (Exception)
     {
         return(View("UnableToCreateQP"));
     }
 }
Example #8
0
 public ActionResult PostLogin(Models.Users user)
 {
     if (ModelState.IsValid)
     {
         try
         {
             QPMapper <Models.Users, User> mapObj = new QPMapper <Models.Users, QP_Management_DataAccessLayer.User>();
             var    dal    = new QP_Repository();
             string status = null;
             status = dal.CheckLogin(mapObj.Translate(user));
             if (status != null)
             {
                 if (status == "not exists")
                 {
                     log.Error("Invalid Account");
                     Session["user"] = "******";
                     return(View("Login"));
                 }
                 else
                 {
                     Session["UserName"] = user.UserName;
                     Session["Role"]     = status;
                     if (status == "author")
                     {
                         log.Info("Logged in as Author");
                         return(RedirectToAction("Author"));
                     }
                     else if (status == "reviewer")
                     {
                         log.Info("Logged in as Reviewer");
                         return(RedirectToAction("Reviewer"));
                     }
                     else if (status == "quality anchor")
                     {
                         log.Info("Logged in as QualityAnchor");
                         return(RedirectToAction("QualityAnchor"));
                     }
                     else if (status == "qp anchor")
                     {
                         log.Info("Logged in as QPAnchor");
                         return(RedirectToAction("QPAnchor"));
                     }
                     else
                     {
                         log.Error("Invalid Password");
                         Session["password"] = "******";
                         return(View("Login"));
                     }
                 }
             }
             else
             {
                 return(View("UnableToLogin"));
             }
         }
         catch (Exception)
         {
             return(View("UnableToLogin"));
         }
     }
     else
     {
         return(View());
     }
 }
Example #9
0
        public ActionResult Editor(Models.Editor doc, FormCollection frm)
        {
            var          dal   = new QP_Repository();
            QPMasterPool qpObj = new QPMasterPool();

            qpObj             = dal.DocumentDetails(doc.DocId);
            qpObj.UpdationLog = DateTime.Now;
            QPMapper <Models.QPMasterPool, QPMasterPool> mapObj = new QPMapper <Models.QPMasterPool, QPMasterPool>();

            try
            {
                if (Session["Role"].ToString().ToLower() == "author")
                {
                    qpObj.Status = "R";
                }
                else
                {
                    qpObj.Status = "A";
                }
            }
            catch (Exception)
            {
                return(RedirectToAction("Login"));
            }

            try
            {
                var htmlPath = Path.GetTempFileName().Replace(".tmp", ".htm");
                var docxPath = Path.GetTempFileName().Replace(".tmp", ".docx");
                System.IO.File.WriteAllText(htmlPath, doc.HtmlContent);
                ComponentInfo.SetLicense("FREE-LIMITED-KEY");
                ComponentInfo.FreeLimitReached += (sender, e) => e.FreeLimitReachedAction = FreeLimitReachedAction.ContinueAsTrial;
                DocumentModel.Load(htmlPath).Save(docxPath);

                if (frm.Count == 5 && frm["Comment"] != null)
                {
                    docxPath = AsposePost(docxPath, frm["Comment"]);
                    if (docxPath == "undone")
                    {
                        return(View("Error"));
                    }
                }

                var docbytes = System.IO.File.ReadAllBytes(docxPath);
                qpObj.Document = docbytes;

                bool status = dal.UpdateDocumentMaster(qpObj);

                if (status)
                {
                    if (Session["Role"].ToString().ToLower() == "author")
                    {
                        return(RedirectToAction("Author"));
                    }
                    else if (Session["Role"].ToString().ToLower() == "reviewer")
                    {
                        return(RedirectToAction("Reviewer"));
                    }
                    else if (Session["Role"].ToString().ToLower() == "quality anchor")
                    {
                        return(RedirectToAction("QualityAnchor"));
                    }
                    else
                    {
                        return(View("Authorization"));
                    }
                }
                else
                {
                    return(View("UnableToUpload"));
                }
            }
            catch (Exception)
            {
                return(View("UnableToUpload"));
            }
        }