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);
 }
Beispiel #2
0
        public static void RecordAttend(CMSDataContext Db, int PeopleId, int OrgId, bool Present, DateTime dt)
        {
            var q = from o in Db.Organizations
                    where o.OrganizationId == OrgId
                    let p = Db.People.Single(pp => pp.PeopleId == PeopleId)
                            select new
            {
                o.Location,
                OrgEntryPoint = o.EntryPointId,
                p.EntryPointId,
            };
            var info = q.Single();

            if (info.EntryPointId == null)
            {
                var p = Db.LoadPersonById(PeopleId);
                if (info.OrgEntryPoint > 0)
                {
                    p.EntryPointId = info.OrgEntryPoint;
                    Db.SubmitChanges();
                }
            }
            int ntries = 6;

            while (true)
            {
                try
                {
                    Db.RecordAttendance(OrgId, PeopleId, dt, Present, info.Location);
                    return;
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 1205)
                    {
                        if (--ntries > 0)
                        {
                            System.Threading.Thread.Sleep(500);
                            continue;
                        }
                    }
                    throw;
                }
            }
        }
Beispiel #3
0
		public static string RecordAttendance(CMSDataContext Db, int PeopleId, int MeetingId, bool attended)
		{
			int ntries = 6;
			while (true)
			{
				try
				{
        			return Db.RecordAttendance(MeetingId, PeopleId, attended);
				}
				catch (SqlException ex)
				{
					if (ex.Number == 1205)
						if (--ntries > 0)
						{
							System.Threading.Thread.Sleep(500);
							continue;
						}
					throw;
				}
			}
		}
Beispiel #4
0
        public static string RecordAttendance(CMSDataContext Db, int PeopleId, int MeetingId, bool attended)
        {
            int ntries = 6;

            while (true)
            {
                try
                {
                    return(Db.RecordAttendance(MeetingId, PeopleId, attended));
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 1205)
                    {
                        if (--ntries > 0)
                        {
                            System.Threading.Thread.Sleep(500);
                            continue;
                        }
                    }
                    throw;
                }
            }
        }
Beispiel #5
0
		public static void RecordAttend(CMSDataContext Db, int PeopleId, int OrgId, bool Present, DateTime dt)
		{
			var q = from o in Db.Organizations
					where o.OrganizationId == OrgId
					let p = Db.People.Single(pp => pp.PeopleId == PeopleId)
					select new
					{
						o.Location,
						OrgEntryPoint = o.EntryPointId,
						p.EntryPointId,
					};
			var info = q.Single();
			if (info.EntryPointId == null)
			{
				var p = Db.LoadPersonById(PeopleId);
			    if (info.OrgEntryPoint > 0)
			    {
			        p.EntryPointId = info.OrgEntryPoint;
			        Db.SubmitChanges();
			    }
			}
			int ntries = 6;
			while (true)
			{
				try
				{
        		    Db.RecordAttendance(OrgId, PeopleId, dt, Present, info.Location);
				    return;
				}
				catch (SqlException ex)
				{
					if (ex.Number == 1205)
						if (--ntries > 0)
						{
							System.Threading.Thread.Sleep(500);
							continue;
						}
					throw;
				}
			}
		}