コード例 #1
0
        //
        // GET: /mylibrary/
        public ActionResult Index(int specid = 0, int oid = 0, int fid = 0, string selaction = null, string sort = "date", string searchfolder = "", string page = "", int start = 1)
        {
            int            qsSpecId           = specid;
            MyLibraryModel MainMyLibraryModel = new MyLibraryModel();
            var            UserSpecialityList = MyLibraryBL.GetUserSpecialities(CurrentUser.UserId);

            if (qsSpecId == 0)
            {
                qsSpecId = UserSpecialityList.Select(n => n.SpecialityId).FirstOrDefault();
            }
            var UserFolderList = MyLibraryBL.GetUserFolderList(qsSpecId, CurrentUser.UserId);

            MainMyLibraryModel.AllUserFolders      = UserFolderList;
            MainMyLibraryModel.AllUserSpecialities = UserSpecialityList;
            ViewBag.SpecId = qsSpecId;
            ViewBag.PrimarySpecialityId = UserSpecialityList.Select(n => n.SpecialityId).FirstOrDefault();

            // For Citation

            if (selaction == "saved")
            {
                MainMyLibraryModel.Citations = MyLibraryBL.GetCitations(fid, CurrentUser.UserId);
                if (MainMyLibraryModel.Citations.Count > 0)
                {
                    MainMyLibraryModel.CitationDetails = MyLibraryBL.GetCitationDetails(MainMyLibraryModel.Citations, sort, CurrentUser.UserId, 2);
                }
                else
                {
                    MainMyLibraryModel.CitationDetails = null;
                }
            }
            else if (selaction == "editor")
            {
                MainMyLibraryModel.PMIDs     = MyLibraryBL.GetEditorsChoicePMids(fid);
                MainMyLibraryModel.Citations = MyLibraryBL.GetEditorsChoiceCitations(fid, CurrentUser.UserId);
                if (MainMyLibraryModel.Citations.Count > 0)
                {
                    MainMyLibraryModel.CitationDetails = MyLibraryBL.GetCitationDetails(MainMyLibraryModel.Citations, sort, CurrentUser.UserId, 2);
                }
                else
                {
                    MainMyLibraryModel.CitationDetails = null;
                }
            }

            else if (selaction == "seminal")
            {
                MainMyLibraryModel.PMIDs     = MyLibraryBL.GetSeminalPMids(fid);
                MainMyLibraryModel.Citations = MyLibraryBL.GetSeminalCitations(fid, CurrentUser.UserId);
                if (MainMyLibraryModel.Citations.Count > 0)
                {
                    MainMyLibraryModel.CitationDetails = MyLibraryBL.GetCitationDetails(MainMyLibraryModel.Citations, sort, CurrentUser.UserId, 2);
                }
                else
                {
                    MainMyLibraryModel.CitationDetails = null;
                }
            }

            else if (selaction == "sponsor")
            {
                MainMyLibraryModel.PMIDs     = MyLibraryBL.GetSponsorPMids(fid);
                MainMyLibraryModel.Citations = MyLibraryBL.GetSponsorCitations(fid, CurrentUser.UserId);
                if (MainMyLibraryModel.Citations.Count > 0)
                {
                    MainMyLibraryModel.CitationDetails = MyLibraryBL.GetCitationDetails(MainMyLibraryModel.Citations, sort, CurrentUser.UserId, 2);
                }
                else
                {
                    MainMyLibraryModel.CitationDetails = null;
                }
            }

            else if (selaction == "acr")
            {
                MainMyLibraryModel.AcrDocumentsMyLibraryList = MyLibraryBL.getAcrDocumentsList(fid);
            }

            if (!string.IsNullOrEmpty(searchfolder))
            {
                MainMyLibraryModel.CitationDetails = MainMyLibraryModel.CitationDetails.Where(c => c.pmid.ToString() == searchfolder || (c.AuthorList ?? "").Contains(searchfolder) || (c.ArticleTitle ?? "").Contains(searchfolder) || (c.MedlinePgn ?? "").Contains(searchfolder) || (c.MedlineTA ?? "").Contains(searchfolder)).ToList();
            }

            if (MainMyLibraryModel.CitationDetails != null)
            {
                MainMyLibraryModel.CitationDetailsTotal = MainMyLibraryModel.CitationDetails;
                MainMyLibraryModel.CitationDetails      = MainMyLibraryModel.CitationDetailsTotal.Skip(start - 1).Take(25).ToList();

                using (Cogent3Entities entity = new Cogent3Entities())
                {
                    foreach (var item in MainMyLibraryModel.CitationDetails)
                    {
                        if ((!item.unicodeFixed.HasValue) || (item.unicodeFixed == false))
                        {
                            if ((item.ArticleTitle ?? "").Contains("?") || (item.ArticleTitle ?? "").Contains("="))
                            {
                                List <string> ArticleTitleWithNoIssue = MyLibraryBL.GetAbstractWithNoIssue(item.pmid);

                                if (ArticleTitleWithNoIssue.Count == 2)
                                {
                                    item.ArticleTitle = ArticleTitleWithNoIssue[1];

                                    int PMID       = Convert.ToInt32(item.pmid);
                                    var IwideTable = (from iw in entity.iWides where iw.PMID == item.pmid select iw).FirstOrDefault();

                                    if (IwideTable != null)
                                    {                                    //AbstractArticleTitleNew[0] is for Abstract Text and AbstractArticleTitleNew[1] is for Article Title;;
                                        item.ArticleTitle              = ArticleTitleWithNoIssue[1];
                                        IwideTable.ArticleTitle        = ArticleTitleWithNoIssue[1];
                                        entity.Entry(IwideTable).State = EntityState.Modified;
                                    }

                                    var IwideNewTable = (from iw in entity.iWideNews where iw.PMID == item.pmid select iw).FirstOrDefault();

                                    if (IwideNewTable != null)
                                    {
                                        item.ArticleTitle                 = ArticleTitleWithNoIssue[1];
                                        IwideNewTable.ArticleTitle        = ArticleTitleWithNoIssue[1];
                                        entity.Entry(IwideNewTable).State = EntityState.Modified;
                                    }
                                }
                            }
                        }
                    }

                    entity.SaveChanges();
                }
            }

            return(View(MainMyLibraryModel));
        }