Example #1
0
        private static void DoWork(AddAttendeesFromTag model)
        {
            var db  = DbUtil.Create(model.host);
            var cul = db.Setting("Culture", "en-US");

            Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(cul);

            LongRunningOp lop = null;

            foreach (var pid in model.pids)
            {
                db.Dispose();
                db = DbUtil.Create(model.host);
                if (model.AddAsMembers)
                {
                    OrganizationMember.InsertOrgMembers(db, model.OrgId, pid,
                                                        MemberTypeCode.Member, model.JoinDate, null, false);
                }
                db.RecordAttendance(model.Id, pid, true);
                lop = FetchLongRunningOp(db, model.Id, Op);
                Debug.Assert(lop != null, "r != null");
                lop.Processed++;
                db.SubmitChanges();
            }
            // finished
            lop           = FetchLongRunningOp(db, model.Id, Op);
            lop.Completed = DateTime.Now;
            db.SubmitChanges();
        }
        public static void DoWork(RepairTransactionsOrgs model)
        {
            var db = DbUtil.Create(model.host);

            db.CommandTimeout = 2200;
            var cul = db.Setting("Culture", "en-US");

            Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(cul);
            LongRunningOp lop = null;

            foreach (var orginfo in model.orginfos)
            {
                db.RepairTransactionsOrgs(orginfo.Id);
                lop = FetchLongRunningOp(db, model.Id, Op);
                Debug.Assert(lop != null, "r != null");
                lop.Processed++;
                lop.CustomMessage = $"Working on {orginfo.Name} ({orginfo.Id})";
                db.SubmitChanges();
            }
            // finished
            lop           = FetchLongRunningOp(db, model.Id, Op);
            lop.Completed = DateTime.Now;
            db.SubmitChanges();
        }
Example #3
0
        public void Process(CMSDataContext db)
        {
            var lop = new LongRunningOp
            {
                Started   = DateTime.Now,
                Count     = Orgs.Split(',').Length,
                Processed = 0,
                Id        = Id,
                Operation = Op
            };

            db.LongRunningOps.InsertOnSubmit(lop);
            db.SubmitChanges();
            Tasks.Task.Run(() => DoWork(this));
        }
Example #4
0
        private static void DoWork(AddToOrgFromTag model)
        {
            Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
            var db  = DbUtil.Create(model.host);
            var cul = db.Setting("Culture", "en-US");

            Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(cul);

            LongRunningOp lop = null;

            foreach (var pid in model.pids)
            {
                db.Dispose();
                db = DbUtil.Create(model.host);
                switch (model.Group)
                {
                case GroupSelectCode.Member:
                    OrganizationMember.InsertOrgMembers(db, model.Id, pid, MemberTypeCode.Member, DateTime.Now, null, pending: false);
                    break;

                case GroupSelectCode.Pending:
                    OrganizationMember.InsertOrgMembers(db, model.Id, pid, MemberTypeCode.Member, DateTime.Now, null, pending: true);
                    break;

                case GroupSelectCode.Prospect:
                    OrganizationMember.InsertOrgMembers(db, model.Id, pid, MemberTypeCode.Prospect, DateTime.Now, null, pending: false);
                    break;

                case GroupSelectCode.Inactive:
                    OrganizationMember.InsertOrgMembers(db, model.Id, pid, MemberTypeCode.InActive, DateTime.Now, DateTime.Now, pending: false);
                    break;

                case GroupSelectCode.Previous:
                    Organization.AddAsPreviousMember(db, model.Id, pid, model.OrgName, MemberTypeCode.InActive, DateTime.Now, DateTime.Now, model.UserId);
                    break;
                }
                lop = FetchLongRunningOp(db, model.Id, Op);
                Debug.Assert(lop != null, "r != null");
                lop.Processed++;
                db.SubmitChanges();
                db.LogActivity($"Org{model.GroupName} AddFromTag", model.Id, pid);
            }
            // finished
            lop           = FetchLongRunningOp(db, model.Id, Op);
            lop.Completed = DateTime.Now;
            db.SubmitChanges();
        }
Example #5
0
        public void Process(CMSDataContext db)
        {
            var lop = new LongRunningOp
            {
                Started   = DateTime.Now,
                Count     = db.OrganizationMembers.Count(m => m.OrganizationId == Id),
                Processed = 0,
                Id        = Id,
                Operation = Op
            };

            db.LongRunningOps.InsertOnSubmit(lop);
            db.SubmitChanges();

            Tasks.Task.Run(() => DoWork(host, Id));
        }
Example #6
0
        public void Process(CMSDataContext db)
        {
            var lop = new LongRunningOp
            {
                Started   = DateTime.Now,
                Count     = db.OrganizationMembers.Count(m => m.OrganizationId == Id),
                Processed = 0,
                Id        = Id,
                Operation = Op
            };

            db.LongRunningOps.InsertOnSubmit(lop);
            db.SubmitChanges();

            HostingEnvironment.QueueBackgroundWorkItem(ct => DoWork(host, Id));
        }
Example #7
0
        private void DoWork(OrgSearchDrop model)
        {
            Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
            var db  = DbUtil.Create(model.host);
            var cul = db.Setting("Culture", "en-US");

            Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(cul);

            LongRunningOp lop = null;

            foreach (var orginfo in model.orginfos)
            {
                var pids = (from m in db.OrganizationMembers
                            where m.OrganizationId == orginfo.Id
                            select m.PeopleId
                            ).ToList();
                var n = 0;
                foreach (var pid in pids)
                {
                    n++;
                    db.Dispose();
                    db = DbUtil.Create(model.host);
                    var om = db.OrganizationMembers.Single(mm => mm.PeopleId == pid && mm.OrganizationId == orginfo.Id);
                    if (DropDate.HasValue)
                    {
                        om.Drop(db, DropDate.Value);
                    }
                    else
                    {
                        om.Drop(db);
                    }
                    lop = FetchLongRunningOp(db, model.Id, Op);
                    Debug.Assert(lop != null, "r != null");
                    lop.Processed++;
                    lop.CustomMessage = $"Working on {orginfo.Name}, {n}/{pids.Count}";
                    db.SubmitChanges();
                }
                var o = db.LoadOrganizationById(orginfo.Id);
                o.OrganizationStatusId = CmsData.Codes.OrgStatusCode.Inactive;
                db.SubmitChanges();
            }
            // finished
            lop           = FetchLongRunningOp(db, model.Id, Op);
            lop.Completed = DateTime.Now;
            db.SubmitChanges();
        }
Example #8
0
        public void Process(CMSDataContext db)
        {
            // running has not started yet, start it on a separate thread
            pids = FetchPeopleIds(db, Tag.Value.ToInt()).ToList();
            var lop = new LongRunningOp()
            {
                Started   = DateTime.Now,
                Count     = pids.Count,
                Processed = 0,
                Id        = Id,
                Operation = Op,
            };

            db.LongRunningOps.InsertOnSubmit(lop);
            db.SubmitChanges();
            Tasks.Task.Run(() => DoWork(this));
        }
        public void Process(CMSDataContext db)
        {
            // running has not started yet, start it on a separate thread
            orginfos = JsonConvert.DeserializeObject <List <OrgInfo> >(Orgs);
            var lop = new LongRunningOp()
            {
                Started   = DateTime.Now,
                Count     = orginfos.Count,
                Processed = 0,
                Id        = Id,
                Operation = Op,
            };

            db.LongRunningOps.InsertOnSubmit(lop);
            db.SubmitChanges();
            HostingEnvironment.QueueBackgroundWorkItem(ct => DoWork(this));
        }
Example #10
0
        public static void DoWork(ValidateAddress model)
        {
            Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
            var db  = DbUtil.Create(model.host);
            var cul = db.Setting("Culture", "en-US");

            Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(cul);

            LongRunningOp lop = null;

            foreach (var pid in model.pids)
            {
                db.Dispose();
                var fsb = new List <ChangeDetail>();
                db = DbUtil.Create(model.host);
                var f   = db.LoadFamilyByPersonId(pid);
                var ret = AddressVerify.LookupAddress(f.AddressLineOne, f.AddressLineTwo, f.CityName, f.StateCode, f.ZipCode);
                if (ret.found != false && !ret.error.HasValue() && ret.Line1 != "error")
                {
                    f.UpdateValue(fsb, "AddressLineOne", ret.Line1);
                    f.UpdateValue(fsb, "AddressLineTwo", ret.Line2);
                    f.UpdateValue(fsb, "CityName", ret.City);
                    f.UpdateValue(fsb, "StateCode", ret.State);
                    f.UpdateValue(fsb, "ZipCode", ret.Zip.GetDigits());
                    var rc = db.FindResCode(ret.Zip, null);
                    f.UpdateValue(fsb, "ResCodeId", rc.ToString());
                }
                else
                {
                    f.UpdateValue(fsb, "ZipCode", f.ZipCode.Zip5());
                }

                lop = FetchLongRunningOp(db, model.Id, Op);
                Debug.Assert(lop != null, "r != null");
                lop.Processed++;
                f.LogChanges(db, fsb, pid, Util.UserPeopleId ?? 0);
                db.SubmitChanges();
                //Thread.Sleep(1000);
            }
            // finished
            lop           = FetchLongRunningOp(db, model.Id, Op);
            lop.Completed = DateTime.Now;
            db.SubmitChanges();
        }
Example #11
0
        public void Process(CMSDataContext db)
        {
            // running has not started yet, start it on a separate thread
            pids    = (from p in People(db.CurrentOrg) select p.PeopleId.Value).ToList();
            Started = DateTime.Now;
            var lop = new LongRunningOp()
            {
                Started   = Started,
                Count     = pids.Count,
                Processed = 0,
                Id        = Id,
                Operation = Op,
            };

            db.LongRunningOps.InsertOnSubmit(lop);
            db.SubmitChanges();
            Task.Run(() => DoWork(this));
        }
Example #12
0
        public void Process(CMSDataContext db)
        {
            pids = FetchPeopleIds(db, Tag.Value.ToInt()).ToList();

            var lop = new LongRunningOp
            {
                Started   = DateTime.Now,
                Count     = pids.Count,
                Processed = 0,
                Id        = Id,
                Operation = Op,
            };

            db.LongRunningOps.InsertOnSubmit(lop);
            db.SubmitChanges();

            HostingEnvironment.QueueBackgroundWorkItem(ct => DoWork(this));
        }
Example #13
0
        public void Process(CMSDataContext db)
        {
            // running has not started yet, start it on a separate thread
            pids    = (from p in People(db.CurrentOrg) select p.PeopleId.Value).ToList();
            Started = DateTime.Now;
            var lop = new LongRunningOp()
            {
                Started   = Started,
                Count     = pids.Count,
                Processed = 0,
                Id        = Id,
                Operation = Op,
            };

            db.LogActivity($"OrgDrop {lop.Count} records", Id, uid: UserId);
            db.LongRunningOps.InsertOnSubmit(lop);
            db.SubmitChanges();
            HostingEnvironment.QueueBackgroundWorkItem(ct => DoWork(this));
        }
Example #14
0
        public void Process(CMSDataContext db)
        {
            var q = from a in db.Attends
                    where a.MeetingId == Id
                    where a.AttendanceFlag || a.EffAttendFlag == true
                    select a.PeopleId;

            pids = q.ToList();
            var lop = new LongRunningOp()
            {
                Started   = DateTime.Now,
                Count     = pids.Count,
                Processed = 0,
                Id        = Id,
                Operation = Op,
            };

            db.LongRunningOps.InsertOnSubmit(lop);
            db.SubmitChanges();
            HostingEnvironment.QueueBackgroundWorkItem(ct => DoWork(this));
        }
Example #15
0
        private void DoWork(OrgDrop model)
        {
            Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
            var db  = DbUtil.Create(model.host);
            var cul = db.Setting("Culture", "en-US");

            Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(cul);

            LongRunningOp lop = null;

            foreach (var pid in pids)
            {
                db.Dispose();
                db = DbUtil.Create(model.host);
                var om = db.OrganizationMembers.Single(mm => mm.PeopleId == pid && mm.OrganizationId == Id);
                if (DropDate.HasValue)
                {
                    om.Drop(db, DropDate.Value);
                }
                else
                {
                    om.Drop(db);
                }
                db.SubmitChanges();
                if (RemoveFromEnrollmentHistory)
                {
                    db.ExecuteCommand("DELETE dbo.EnrollmentTransaction WHERE PeopleId = {0} AND OrganizationId = {1}", pid, Id);
                }
                lop = FetchLongRunningOp(db, model.Id, Op);
                Debug.Assert(lop != null, "r != null");
                lop.Processed++;
                db.SubmitChanges();
                db.LogActivity($"Org{Group} Drop{(RemoveFromEnrollmentHistory ? " w/history" : "")}", Id, pid, UserId);
            }
            // finished
            lop           = FetchLongRunningOp(db, model.Id, Op);
            lop.Completed = DateTime.Now;
            db.SubmitChanges();
        }
Example #16
0
        private static void DoWork(DeleteMeeting model)
        {
            Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
            var db  = DbUtil.Create(model.host);
            var cul = db.Setting("Culture", "en-US");

            Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(cul);

            LongRunningOp lop = null;

            foreach (var pid in model.pids)
            {
                db.Dispose();
                db = DbUtil.Create(model.host);
                Attend.RecordAttendance(db, pid, model.Id, false);
                lop = FetchLongRunningOp(db, model.Id, Op);
                Debug.Assert(lop != null, "r != null");
                lop.Processed++;
                db.SubmitChanges();
            }
            db.ExecuteCommand(@"
DELETE dbo.SubRequest 
FROM dbo.SubRequest sr
JOIN dbo.Attend a ON a.AttendId = sr.AttendId
WHERE a.MeetingId = {0}
", model.Id);
            db.ExecuteCommand("DELETE dbo.VolRequest WHERE MeetingId = {0}", model.Id);
            db.ExecuteCommand("DELETE dbo.attend WHERE MeetingId = {0}", model.Id);
            db.ExecuteCommand("DELETE dbo.MeetingExtra WHERE MeetingId = {0}", model.Id);
            db.ExecuteCommand("DELETE dbo.meetings WHERE MeetingId = {0}", model.Id);

            db.SubmitChanges();

            // finished
            lop           = FetchLongRunningOp(db, model.Id, Op);
            lop.Completed = DateTime.Now;
            db.SubmitChanges();
        }
Example #17
0
        public static void DoWork(RepairTransactionsOrgs model)
        {
            Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
            var db  = DbUtil.Create(model.host);
            var cul = db.Setting("Culture", "en-US");

            Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(cul);
            LongRunningOp lop = null;

            foreach (var oid in model.Orgs.Split(',').Select(mm => mm.ToInt()))
            {
                db.RepairTransactionsOrgs(oid);
                lop = FetchLongRunningOp(db, model.Id, Op);
                Debug.Assert(lop != null, "r != null");
                lop.Processed++;
                db.SubmitChanges();
            }
            // finished
            lop           = FetchLongRunningOp(db, model.Id, Op);
            lop.Completed = DateTime.Now;
            db.SubmitChanges();
        }