Beispiel #1
0
        protected void notifySubscribers(LiftContext ctx)
        {
            Organization org = Organization.Current;

            OrgEmail oe = new OrgEmail();

            oe.organization_id.Value = org.id.Value;
            oe = oe.doSingleObjectQuery <OrgEmail>("select");

            Request r = new Request();

            r.id.Value = ctx.getInt("request_id");
            List <Request> rlist = r.doQuery <Request>("get_most_recent_update");


            StringBuilder body = new StringBuilder();

            string title = string.Empty;

            foreach (Request u in rlist)
            {
                if (title.Length == 0)
                {
                    title = u.title.Value;
                }

                body.Append("From: ");
                body.Append(u.from.Value);
                body.Append(" (");
                body.Append(u.from_email.Value);
                body.Append(")");
                // body.Append(u.getDateTime("post_date").ToString("G"));  // times are in utc - needs to be converted to subscriber tz
                body.Append("\r\n\r\n");
                body.Append(u.description.Value);
                body.Append("\r\n\r\n");
            }

            Email e = new Email();

            e.from = org.getFromEmail();
            e.Body = body.ToString();

            e.subject = "Update: " + title;

            Subscription s = new Subscription();

            s.request_id.Value = ctx.getInt("request_id");
            DataSet subsribers = s.doQuery("get_subscribers");

            if (DatabasePersist.hasData(subsribers))
            {
                foreach (DataRow subscriber in subsribers.Tables[0].Rows)
                {
                    e.clearRecipients();
                    e.addTo(subscriber["email"].ToString());
                    e.send();
                }
            }
        }
Beispiel #2
0
        public void notify(int requestId)
        {
            System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(notify_proc));

            LiftContext ctx = new LiftContext();

            ctx["request_id"] = requestId;

            thread.Start(ctx);
        }
Beispiel #3
0
        protected void notify_proc(object ctxObj)
        {
            LiftContext ctx = (LiftContext)ctxObj;

            ctx.setCtx();

            notifySubscribers(ctx);
            notifyEncouragers(ctx);

            ctx.clearCtx();
        }
Beispiel #4
0
        protected void notifyEncouragers(LiftContext ctx)
        {
            Organization org = Organization.Current;

            Request r = new Request();

            r.id.Value = ctx.getInt("request_id");
            r          = r.doSingleObjectQuery <Request>("getobject");

            if (r.needs_encouragement.Value == 1)
            {
                OrgEmail oe = new OrgEmail();
                oe.organization_id.Value = org.id.Value;
                oe = oe.doSingleObjectQuery <OrgEmail>("select");

                Email e = new Email();
                e.from = org.getFromEmail();
                e.addTo(oe.encourager_email_to.Value);
                e.subject  = "New Encouragement Request: ";
                e.subject += r.title.Value;

                StringBuilder body = new StringBuilder();
                if (r.listed.Value == 0)
                {
                    body.Append("*** PRIVATE ***\r\n\r\n");
                }
                body.Append("REQUEST ID: "); body.Append(r.id.Value); body.Append("\r\n\r\n");
                body.Append("TITLE\r\n"); body.Append(r.title.Value); body.Append("\r\n\r\n");
                body.Append("DESCRIPTION\r\n"); body.Append(r.description.Value); body.Append("\r\n\r\n");
                body.Append("POST DATE\r\n"); body.Append(r.post_date.Value.ToString("G")); body.Append("\r\n\r\n");
                // body.Append("IS FOR\r\n"); body.Append(r.is_for.Value); body.Append("\r\n");
                // body.Append("IS APPROVED\r\n"); body.Append(r.is_approved.Value.ToString("G")); body.Append("\r\n");
                body.Append("LAST ACTION\r\n"); body.Append(r.last_action.Value.ToString("G")); body.Append("\r\n\r\n");
                body.Append("FROM\r\n"); body.Append(r.from.Value); body.Append("\r\n\r\n");
                body.Append("FROM EMAIL\r\n"); body.Append(r.from_email.Value); body.Append("\r\n\r\n");
                body.Append("ENCOURAGEMENT ADDRESS\r\n"); body.Append(r.encouragement_address.Value); body.Append("\r\n\r\n");
                //body.Append("ENCOURAGEMENT EMAIL\r\n"); body.Append(r.encouragement_email.Value); body.Append("\r\n\r\n");
                body.Append("ENCOURAGEMENT PHONE\r\n"); body.Append(r.encouragement_phone.Value); body.Append("\r\n\r\n");

                e.Body = body.ToString();
                e.send();

                r.Clear();
                r.id.Value = id;
                r.needs_encouragement.Value = 0;
                r.doCommand("update");
            }
        }