예제 #1
0
        void UploadAssociates()
        {
            RSMDataModelDataContext db = new RSMDataModelDataContext();


            var people = (from p in db.Persons
                          where p.NeedsUpload == true
                          select p);

            if (people.Count() > 0)
            {
                try
                {
                    S2API api = new S2API(_s2URI, _s2RSMAccount, _s2RSMPassword);
                    foreach (Person p in people)
                    {
                        if (api.SavePerson(p))
                        {
                            p.NeedsUpload = false;
                        }
                    }
                    api.LogOut();
                }
                catch (Exception e)
                {
                    WriteToEventLogError("Exception thrown uploading people: " + e.ToString());
                }
                db.SubmitChanges();
            }
        }
예제 #2
0
        private void ExportAll()
        {
            S2API api = new S2API("http://64.129.189.200/goforms/nbapi", "admin", "admin");
            RSMDataModelDataContext db = new RSMDataModelDataContext();

            foreach (Person person in db.Persons)
            {
                api.SavePerson(person);
            }
            txtOutput.Text = "Done exporting";
        }
예제 #3
0
        private void ExportAll()
        {
            var api = new S2API(S2APIUrl, S2APIUser, S2APIPassword, false);

            using (var db = new RSMDataModelDataContext())
            {
                foreach (var person in db.Persons)
                {
                    api.SavePerson(person);
                }
            }

            txtOutput.Text = "Done exporting";
        }
예제 #4
0
        public bool ProcessPerson(Person person, S2API api)
        {
            // First let's remove any existing automatically added role.
            var thisPersonRoles = from r in _context.PeopleRoles
                                  where r.PersonID == person.PersonID
                                  select r;

            if (thisPersonRoles.Count() > 0)
            {
                _context.PeopleRoles.DeleteAllOnSubmit(thisPersonRoles);
            }

            if (person.Active)
            {
                // Find the rules that apply to this person.
                var rules = (from r in _context.JCLRoleRules
                             where (((r.JobCode == "0") || (r.JobCode == person.JobCode)) &&
                                    ((r.DeptID == "0") || (r.DeptID == person.DeptID)) &&
                                    ((r.Location == 0) || (r.Locations.LocationName == person.Facility)))
                             select r);


                // Assemble the roles into a distinct list
                HashSet <int>  distinctRoleIDs = new HashSet <int>();
                HashSet <Role> distinctRoles   = new HashSet <Role>();
                foreach (JCLRole role in rules.SelectMany(rule => rule.JCLRoles))
                {
                    distinctRoles.Add(role.Role);
                    distinctRoleIDs.Add(role.RoleID);
                }

                if (api == null)
                {
                    person.NeedsUpload = true;
                }

                person.NeedsRulePass = false;
                // Add them to the employee
                foreach (Role role in distinctRoles)
                {
                    person.PeopleRoles.Add(new PeopleRole(person, role));
                }
            }
            else
            {
                if (api == null)
                {
                    person.NeedsUpload = true;
                }

                person.NeedsRulePass = false;
            }

            _context.SubmitChanges();

            if (api != null)
            {
                try
                {
                    api.SavePerson(person);
                    person.NeedsUpload = false;
                    _context.SubmitChanges();
                }
                catch (Exception)
                {
                }
            }

            return(true);
        }