Esempio n. 1
0
        public static void DoMoveWork(MoveOrgMembersModel model)
        {
            var statusContext = CMSDataContext.Create(model.Host);
            var workerContext = CMSDataContext.Create(model.Host);

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

            Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul);
            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(cul);
            LongRunningOperation lop = FetchLongRunningOperation(statusContext, Op, model.QueryId);
            var orgsPeople           = new Dictionary <int, List <int> >();

            foreach (var i in model.List) // {personId}.{organizationId}
            {
                var a = i.Split('.');
                if (a.Length != 2)
                {
                    continue;
                }

                var orgId = a[1].ToInt();

                if (orgId == model.TargetId)
                {
                    continue;
                }

                if (!orgsPeople.ContainsKey(orgId))
                {
                    orgsPeople[orgId] = new List <int>();
                }
                orgsPeople[orgId].Add(a[0].ToInt());
            }

            foreach (var oid in orgsPeople.Keys)
            {
                var peopleIds = orgsPeople[oid];
                foreach (var pid in peopleIds)
                {
                    OrganizationMember.MoveToOrg(workerContext, CMSImageDataContext.Create(workerContext.Host), pid, oid, model.TargetId, model.MoveRegistrationData, model.ChangeMemberType == true ? model.MoveToMemberTypeId : -1);
                    if (lop != null)
                    {
                        lop.Processed++;
                        lop.CustomMessage = $"Working from {pid},{oid} to {model.TargetId}";
                        statusContext.SubmitChanges();
                    }
                }
                BackgroundRepairTransactions(model.repairExe, oid, workerContext);
            }
            BackgroundRepairTransactions(model.repairExe, model.TargetId, workerContext);
            // finished
            if (lop != null)
            {
                lop.Completed = DateTime.Now;
                statusContext.SubmitChanges();
            }
            workerContext.UpdateMainFellowship(model.TargetId);
        }
Esempio n. 2
0
        public string Move(int toid, CMSDataContext db)
        {
            if (!PeopleId.HasValue || !OrgId.HasValue)
            {
                return("not moved");
            }

            OrganizationMember.MoveToOrg(db, CMSImageDataContext.Create(db.Host), PeopleId.Value, OrgId.Value, toid, MoveRegistrationData);
            DbUtil.LogActivity("OrgMem Move to " + toid, OrgId, PeopleId);

            var repairExe = HttpContextFactory.Current.Server.MapPath("~/bin/RepairOrg.exe");

            MoveOrgMembersModel.BackgroundRepairTransactions(repairExe, toid, db);
            MoveOrgMembersModel.BackgroundRepairTransactions(repairExe, OrgId.Value, db);
            return("moved");
        }
Esempio n. 3
0
        public static void DoMoveWork(MoveOrgMembersModel model)
        {
            var jobStatusContext = DbUtil.Create(model.Host);
            var jobWorkerContext = DbUtil.Create(model.Host);

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

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

            foreach (var i in model.List) // {personId}.{organizationId}
            {
                var a = i.Split('.');
                if (a.Length != 2)
                {
                    continue;
                }

                var pid = a[0].ToInt();
                var oid = a[1].ToInt();

                if (oid == model.TargetId)
                {
                    continue;
                }

                OrganizationMember.MoveToOrg(jobWorkerContext, pid, oid, model.TargetId, model.MoveRegistrationData, model.ChangeMemberType == true ? model.MoveToMemberTypeId : -1);
                //Once member has been inserted into the new Organization then update member in Organizations as enrolled / not enrolled accordingly
                jobWorkerContext.RepairTransactions(oid);
                jobWorkerContext.RepairTransactions(model.TargetId);
                lop = FetchLongRunningOperation(jobStatusContext, Op, model.QueryId);
                Debug.Assert(lop != null, "r != null");
                lop.Processed++;
                lop.CustomMessage = $"Working from {pid},{oid} to {model.TargetId}";
                jobStatusContext.SubmitChanges();
            }
            // finished
            lop           = FetchLongRunningOperation(jobStatusContext, Op, model.QueryId);
            lop.Completed = DateTime.Now;
            jobStatusContext.SubmitChanges();
            jobWorkerContext.UpdateMainFellowship(model.TargetId);
        }
Esempio n. 4
0
        public static void DoMoveWork(MoveOrgMembersModel 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);
            LongRunningOperation lop = null;

            foreach (var i in model.List)
            {
                var a = i.Split('.');
                if (a.Length != 2)
                {
                    continue;
                }
                var pid = a[0].ToInt();
                var oid = a[1].ToInt();

                if (oid == model.TargetId)
                {
                    continue;
                }
                OrganizationMember.MoveToOrg(db, pid, oid, model.TargetId, model.MoveRegistrationData, model.ChangeMemberType == true ? model.MoveToMemberTypeId : -1);
                lop = FetchLongRunningOperation(db, Op, model.QueryId);
                Debug.Assert(lop != null, "r != null");
                lop.Processed++;
                lop.CustomMessage = $"Working from {pid},{oid} to {model.TargetId}";
                db.SubmitChanges();
            }
            // finished
            lop           = FetchLongRunningOperation(db, Op, model.QueryId);
            lop.Completed = DateTime.Now;
            db.SubmitChanges();
            db.UpdateMainFellowship(model.TargetId);
        }