示例#1
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();
        }
示例#2
0
        private static void DoWork(AddToOrgFromTag model)
        {
            var db  = CMSDataContext.Create(model.Host);
            var cul = db.Setting("Culture", "en-US");

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

            LongRunningOperation lop = null;

            foreach (var pid in model.pids)
            {
                switch (model.filter.GroupSelect)
                {
                case GroupSelectCode.Member:
                    OrganizationMember.InsertOrgMembers(db, model.OrgId, pid, MemberTypeCode.Member, DateTime.Now, null, pending: false);
                    break;

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

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

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

                case GroupSelectCode.Previous:
                    Organization.AddAsPreviousMember(db, model.OrgId, pid, model.OrgName, MemberTypeCode.InActive, DateTime.Now, DateTime.Now, model.UserId);
                    break;
                }
                lop = FetchLongRunningOperation(db, Op, model.QueryId);
                Debug.Assert(lop != null, "r != null");
                lop.Processed++;
                db.SubmitChanges();
                db.LogActivity($"Org{model.DisplayGroup} AddFromTag", model.OrgId, pid);
            }
            // finished
            lop           = FetchLongRunningOperation(db, Op, model.QueryId);
            lop.Completed = DateTime.Now;
            db.SubmitChanges();
        }