Example #1
0
        public void testgetAllReviews()
        {
            ITaxonRepository   Taxon = new TaxonRepository();
            IGenericRepository gen   = new GenericRepository();

            // ViewData["Review"] = Taxon.getAllReviews();


            IList <ReviewDesc> reviews = Taxon.getAllReviews();

            int count = reviews.Count;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    reviews[i].TaxonName = Taxon.getReviewTaxonName(reviews[i].ID, reviews[i].Taxontype, reviews[i].Kingdom);
                }
            }

            //ReviewDesc r = reviews[0];

            Assert.AreEqual(reviews[0].TaxonName, "test");

            //Assert.AreEqual(count,0);
        }
Example #2
0
        public void test_Sp_getTaxonSelected()
        {
            ITaxonRepository taxon = new TaxonRepository();

            string test = taxon.getReviewTaxonName(25, UpdateUtils.PHYLUM, UpdateUtils.ANIMALS);

            Assert.AreEqual(test, "test");
        }
Example #3
0
        private IList <ReviewDesc> GetAllReviews(int?pageIndex)
        {
            ITaxonRepository  Taxon   = new TaxonRepository();
            IReviewRepository reviews = new ReviewRepository();
            // IList<ReviewDesc> review = Taxon.GetAllReviews();

            int currentIndex = (int)(pageIndex ?? 1);

            //int count = review.Count;
            // int count = Taxon.getAllReviews().Count;
            SqlQuery query = Select.AllColumnsFrom <VwAllReview>();
            int      count = query.GetRecordCount();

            ViewData["TotalItemCount"] = count;
            ViewData["PageNumber"]     = currentIndex;
            ViewData["PageSize"]       = UpdateUtils.DEFAULT_PAGE_SIZE;

            IList <ReviewDesc> review = Taxon.GetAllReviewsPaged(currentIndex, UpdateUtils.DEFAULT_PAGE_SIZE);

            var sortedReviews = from r in review
                                orderby r.CtyShort
                                select r;

            int pagedCount = review.Count;

            if (pagedCount > 0)
            {
                for (int i = 0; i < pagedCount; i++)
                {
                    review[i].TaxonName = Taxon.getReviewTaxonName(review[i].ID, review[i].Taxontype,
                                                                   review[i].Kingdom);

                    review[i].Paragraph = Taxon.getParagraphStagePerReview(review[i].ID);

                    review[i].Concern      = reviews.getConcernForReview(review[i].ID);
                    review[i].DeadlineDate = Taxon.getDeadlineDatePerReview(review[i].ID);
                }
            }

            if (pagedCount <= 0)
            {
                review = null;
            }
            return(review);
        }
Example #4
0
        /**
         * This function should construct and send the email finally
         *
         * NOT FINISHED!!!
         */
        private void build_send_and_log_message(SigtradeUser user, MessageTemplate template, ParagraphActionCollection paras)
        {
            //create the mail message
            MailMessage mail = new MailMessage();

            //set the addresses
            mail.From = new MailAddress("*****@*****.**");

            //Finding user through membership Api

            MembershipUser my_user = Membership.GetUser(new Guid(user.userid));

            mail.To.Add(my_user.Email);
            //mail.To.Add(user); //MUST USE MEMBERSHIP API TO FIND USER AND PROFILE SETTINGS (INCL EMAIL) NOT WORKING

            //set the content
            mail.Subject = template.Title;
            StringBuilder emailBody = new StringBuilder();

            var userProfile = Profile.GetProfile(my_user.UserName);

            mail.Body = template.Body;
            emailBody.AppendLine("Dear " + userProfile.first_name + ' ' + userProfile.last_name);
            emailBody.AppendLine(template.Body);

            //Need to get the paragraph details
            IReviewRepository reviews = new ReviewRepository();
            ITaxonRepository  taxon   = new TaxonRepository();

            foreach (ParagraphAction para in paras)
            {
                var review    = reviews.getSingleReview(para.ReviewID);
                var paragraph = reviews.getSinglePALib(para.PALibID);
                review.TaxonName = taxon.getReviewTaxonName(review.ID, review.Taxontype, review.Kingdom);
                //mail.Body = mail.Body.Concat(para.DeadlineDate.ToString()); //SOME SORT OF WARNING HERE!
                var review_type = review.TaxonName + " [" + review.CtyShort + "]";
                emailBody.AppendLine("Review:" + review_type);
                emailBody.AppendLine("Paragraph details: " + paragraph.Action + " (" + ((DateTime)para.DeadlineDate).ToShortDateString() + ')');
                emailBody.AppendLine();
                //mail.Body = mail.Body;
            }
            emailBody.AppendLine();
            emailBody.AppendLine(Resources.SigTrade.emailFooter);
            mail.Body = emailBody.ToString();

            //send the message
            SmtpClient smtp = new SmtpClient(UpdateUtils.SMTP_RELAY_SERVER, 25);

            try
            {
                smtp.Send(mail);
            }
            catch (SmtpException e)
            {
            }


            //HERE WE SHOULD WRITE TO THE LOG TABLE.
            //Prepare the MessageLog object
            MessageLog log = new MessageLog();

            log.SentTo = my_user.Email;
            log.SentAt = DateTime.Today;
            log.Title  = template.Title;
            log.Body   = emailBody.ToString();
            write_to_message_log(log);
        }