Beispiel #1
0
        public void Email(string savedquery, int queuedBy, string fromaddr, string fromname, string subject, string body, bool transactional = false)
        {
            var from = new MailAddress(fromaddr, fromname);
            var qB   = Db.QueryBuilderClauses.FirstOrDefault(c => c.Description == savedquery && c.SavedBy == "public");

            if (qB == null)
            {
                return;
            }
            var q = Db.PeopleQuery(qB.QueryId);

            if (qB.ParentsOf)
            {
                q = Db.PersonQueryParents(q);
            }

            q = from p in q
                where p.EmailAddress != null
                where p.EmailAddress != ""
                where (p.SendEmailAddress1 ?? true) || (p.SendEmailAddress2 ?? false)
                select p;
            var tag        = Db.PopulateSpecialTag(q, DbUtil.TagTypeId_Emailer);
            var emailqueue = Db.CreateQueue(queuedBy, from, subject, body, null, tag.Id, false);

            Db.SendPeopleEmail(emailqueue.Id);
        }
 public ActionResult Start(int tag, int meetingid, bool addasmembers)
 {
     var runningtotals = new AddToOrgFromTagRun
     {
         Started = DateTime.Now,
         Count = 0,
         Processed = 0,
         Orgid = meetingid
     };
     DbUtil.Db.AddToOrgFromTagRuns.InsertOnSubmit(runningtotals);
     DbUtil.Db.SubmitChanges();
     var host = Util.Host;
     var qid = DbUtil.Db.FetchLastQuery().Id;
     System.Threading.Tasks.Task.Factory.StartNew(() =>
     {
         System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.BelowNormal;
         var Db = new CMSDataContext(Util.GetConnectionString(host));
         IEnumerable<int> q = null;
         if (tag == -1) // (last query)
             q = Db.PeopleQuery(qid).Select(pp => pp.PeopleId);
         else
             q = from t in Db.TagPeople
                 where t.Id == tag
                 select t.PeopleId;
         var pids = q.ToList();
         var meeting = Db.Meetings.SingleOrDefault(mm => mm.MeetingId == meetingid);
         var joindate = meeting.MeetingDate.Value.AddMinutes(-1);
         var orgid = meeting.OrganizationId;
         foreach (var pid in pids)
         {
             Db.Dispose();
             Db = new CMSDataContext(Util.GetConnectionString(host));
             if (addasmembers)
                 OrganizationMember.InsertOrgMembers(Db,
                     orgid, pid, MemberTypeCode.Member, joindate, null, false);
             Db.RecordAttendance(meetingid, pid, true);
             var r = Db.AddToOrgFromTagRuns.Where(mm => mm.Orgid == meetingid).OrderByDescending(mm => mm.Id).First();
             r.Processed++;
             r.Count = pids.Count;
             Db.SubmitChanges();
         }
         var rr = Db.AddToOrgFromTagRuns.Where(mm => mm.Orgid == meetingid).OrderByDescending(mm => mm.Id).First();
         rr.Completed = DateTime.Now;
         Db.SubmitChanges();
         Db.UpdateMainFellowship(orgid);
     });
     return Redirect("/AddAttendeesFromTag/Progress/" + meetingid);
 }
 public ActionResult Start(int tag, int orgid, bool pending = false, bool prospect = false)
 {
     var runningtotals = new AddToOrgFromTagRun
     {
         Started = DateTime.Now,
         Count = 0,
         Processed = 0,
         Orgid = orgid
     };
     DbUtil.Db.AddToOrgFromTagRuns.InsertOnSubmit(runningtotals);
     DbUtil.Db.SubmitChanges();
     var host = Util.Host;
     var qid = DbUtil.Db.FetchLastQuery().Id;
     System.Threading.Tasks.Task.Factory.StartNew(() =>
     {
         Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
         var Db = new CMSDataContext(Util.GetConnectionString(host));
         var cul = Db.Setting("Culture", "en-US");
         Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
         Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cul);
         IEnumerable<int> q = null;
         if (tag == -1) // (last query)
             q = Db.PeopleQuery(qid).Select(pp => pp.PeopleId);
         else
             q = from t in Db.TagPeople
                 where t.Id == tag
                 select t.PeopleId;
         var pids = q.ToList();
         foreach (var pid in pids)
         {
             Db.Dispose();
             Db = new CMSDataContext(Util.GetConnectionString(host));
             OrganizationMember.InsertOrgMembers(Db, orgid, pid,
                 prospect ? MemberTypeCode.Prospect : MemberTypeCode.Member,
                 DateTime.Now, null, pending);
             var r = Db.AddToOrgFromTagRuns.Where(mm => mm.Orgid == orgid).OrderByDescending(mm => mm.Id).First();
             r.Processed++;
             r.Count = pids.Count;
             Db.SubmitChanges();
         }
         var rr = Db.AddToOrgFromTagRuns.Where(mm => mm.Orgid == orgid).OrderByDescending(mm => mm.Id).First();
         rr.Completed = DateTime.Now;
         Db.SubmitChanges();
         Db.UpdateMainFellowship(orgid);
     });
     return Redirect("/AddToOrgFromTag/Progress/" + orgid);
 }
Beispiel #4
0
 public static int AddTasks(CMSDataContext Db, Guid qid)
 {
     var q = Db.PeopleQuery(qid);
     int qCount = q.Count();
     if (qCount > 100)
         return qCount;
     foreach (var p in q)
     {
         var t = new Task
         {
             ListId = GetRequiredTaskList(Db, "InBox", Util.UserPeopleId.Value).Id,
             OwnerId = Util.UserPeopleId.Value,
             Description = "Please Contact",
             ForceCompleteWContact = true,
             StatusId = TaskStatusCode.Active,
         };
         p.TasksAboutPerson.Add(t);
     }
     DbUtil.Db.SubmitChanges();
     return qCount;
 }
Beispiel #5
0
        public static int AddTasks(CMSDataContext Db, Guid qid)
        {
            var q      = Db.PeopleQuery(qid);
            int qCount = q.Count();

            if (qCount > 100)
            {
                return(qCount);
            }
            foreach (var p in q)
            {
                var t = new Task
                {
                    ListId                = Task.GetRequiredTaskList(Db, "InBox", Util.UserPeopleId.Value).Id,
                    OwnerId               = Util.UserPeopleId.Value,
                    Description           = "Please Contact",
                    ForceCompleteWContact = true,
                    StatusId              = TaskStatusCode.Active,
                };
                p.TasksAboutPerson.Add(t);
            }
            DbUtil.Db.SubmitChanges();
            return(qCount);
        }
Beispiel #6
0
 public void UpdateQueryStatsAsync()
 {
     AsyncManager.OutstandingOperations.Increment();
     string host = Util.Host;
     var uid = Util.UserId;
     ThreadPool.QueueUserWorkItem((e) =>
     {
         Util.SessionId = Guid.NewGuid().ToString();
         var Db = new CMSDataContext(Util.GetConnectionString(host));
         var d = DateTime.Today.Subtract(DateTime.Parse("1/1/1900")).Days;
         var list = Db.QueryStats.Where(ss => ss.RunId == d);
         foreach (var a in Db.QueryStatClauses())
         {
             var st = list.SingleOrDefault(ss => ss.StatId == a[0]);
             if (st == null)
             {
                 st = new QueryStat { StatId = a[0], Description = a[1], RunId = d, Runtime = DateTime.Now };
                 Db.QueryStats.InsertOnSubmit(st);
             }
             st.Count = Db.PeopleQuery(a[0] + ":" + a[1]).Count();
             Db.SubmitChanges();
         }
         AsyncManager.OutstandingOperations.Decrement();
     });
 }
        public void Email2(Guid qid, int queuedBy, string fromAddr, string fromName, string subject, string body)
        {
            var q = db.PeopleQuery(qid);

            Email2(q, queuedBy, fromAddr, fromName, subject, body);
        }
Beispiel #8
0
 public void Results2Async()
 {
     AsyncManager.OutstandingOperations.Increment();
     string host = Util.Host;
     ThreadPool.QueueUserWorkItem((e) =>
     {
         var Db = new CMSDataContext(Util.GetConnectionString(host));
         Db.DeleteQueryBitTags();
         foreach (var a in Db.StatusFlags())
         {
             var t = Db.FetchOrCreateSystemTag(a[0]);
             Db.TagAll(Db.PeopleQuery(a[0] + ":" + a[1]), t);
             Db.SubmitChanges();
         }
         AsyncManager.OutstandingOperations.Decrement();
     });
 }
Beispiel #9
0
        internal static Expression SavedQuery(ParameterExpression parm,
            CMSDataContext Db,
            string QueryIdDesc,
            CompareType op,
            bool tf)
        {
            var a = QueryIdDesc.SplitStr(":", 2);
            var qid = a[0].ToInt();
            var savedquery = Db.QueryBuilderClauses.SingleOrDefault(q =>
                q.QueryId == qid);
            if (savedquery == null)
                return AlwaysFalse(parm);

            var q2 = Db.PeopleQuery(qid).Select(pp => pp.PeopleId);
            var tag = Db.PopulateTemporaryTag(q2);

            Expression<Func<Person, bool>> pred = p => p.Tags.Any(t => t.Id == tag.Id);
            Expression expr = Expression.Invoke(pred, parm);
            return expr;
        }