protected void BindGrid()
        {
            MessageTemplateCollection messageTemplateCollection = MessageManager.GetAllMessageTemplates();

            gvMessageTemplates.DataSource = messageTemplateCollection;
            gvMessageTemplates.DataBind();
        }
 public MessageTemplateCollection FetchAll()
 {
     MessageTemplateCollection coll = new MessageTemplateCollection();
     Query qry = new Query(MessageTemplate.Schema);
     coll.LoadAndCloseReader(qry.ExecuteReader());
     return coll;
 }
Beispiel #3
0
        //
        // GET: /Message/SendAlerts
        public ActionResult SendAlerts()
        {
            //GET UNIQUE LIST OF ALL USERS WHO HAVE ACTIVE PARAGRAPHS (PARAGRAPH.COMPLETE=0)
            IList <SigtradeUser> users_with_active_paragraphs = DB.Select("UserID")
                                                                .From(UsersParagraphLink.Schema)
                                                                .InnerJoin(ParagraphAction.IdColumn, UsersParagraphLink.SourceIDColumn)
                                                                .Where("Deleted")
                                                                .IsNotEqualTo(true)
                                                                .And("Completed")
                                                                .IsEqualTo(false).Distinct()
                                                                .ExecuteTypedList <SigtradeUser>();
            //GET ALL TEMPLATES
            MessageTemplateCollection messages_to_send = DB.Select()
                                                         .From(MessageTemplate.Schema)
                                                         .Where("Deleted").IsNotEqualTo(true)
                                                         .And("MessageType").IsEqualTo('A')
                                                         .ExecuteAsCollection <MessageTemplateCollection>();

            //FOR EACH TEMPLATE - WARNING - GONNA BE SLOW.
            foreach (MessageTemplate template in messages_to_send)
            {
                //FOR EACH USER
                foreach (SigtradeUser user in users_with_active_paragraphs)
                {
                    //GET ALL ACTIVE PARAS FOR USER
                    ParagraphActionCollection active_paragraphs = DB.Select("PALibID", "ReviewID", "DeadlineDate", "UserID")
                                                                  .From(ParagraphAction.Schema)
                                                                  .InnerJoin(UsersParagraphLink.SourceIDColumn, ParagraphAction.IdColumn)
                                                                  .WhereExpression("UserID").IsEqualTo(user.userid)
                                                                  .Distinct()
                                                                  .ExecuteAsCollection <ParagraphActionCollection>();

                    //ONLY ATTEMPT EMAIL IF THE USER HAS ACTIVE PARAS
                    if (active_paragraphs.Count() > 0)
                    {
                        ParagraphActionCollection paras_for_email = new ParagraphActionCollection();

                        //STRIP OUT ALL THE PARAS THAT SHOULD BE SENT IN ALERT - MOVE UP TO SQL LATER
                        foreach (ParagraphAction action in active_paragraphs)
                        {
                            if (should_send((DateTime)action.DeadlineDate, template.DaysDelta))
                            {
                                paras_for_email.Add(action);
                            }
                        }

                        //FINALLY, IF WE SHOULD SEND AN ALERT TO THE USER, BUILD AND SEND
                        if (paras_for_email.Count() > 0)
                        {
                            build_send_and_log_message(user, template, paras_for_email);
                        }
                    }
                }
            }

            return(View());
        }
 public MessageTemplateCollection FetchByQuery(Query qry)
 {
     MessageTemplateCollection coll = new MessageTemplateCollection();
     coll.LoadAndCloseReader(qry.ExecuteReader());
     return coll;
 }
 public MessageTemplateCollection FetchByID(object Id)
 {
     MessageTemplateCollection coll = new MessageTemplateCollection().Where("id", Id).Load();
     return coll;
 }