Example #1
0
        private void GetPictureFromS2Click(object sender, EventArgs e)
        {
            var api = new S2API(S2APIUrl, S2APIUser, S2APIPassword, false);

            var nd        = api.GetPicture("0");
            var fileName  = nd["PICTUREURL"].InnerText;
            var imageData = Convert.FromBase64String(nd["PICTURE"].InnerText);

            var text = fileName;

            Image image;

            using (var imageStream = new MemoryStream(imageData))
            {
                image = Image.FromStream(imageStream);
            }

            //using (var stream = new FileStream(fileName, FileMode.Create))
            //{
            //    using (var writer = new BinaryWriter(stream))
            //    {
            //        writer.Write(imageData);
            //        writer.Close();
            //    }
            //}

            AssignView(text, image);
        }
Example #2
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();
            }
        }
Example #3
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            S2API      api      = new S2API("http://64.129.189.200/goforms/nbapi", "admin", "admin");
            S2Importer importer = new S2Importer(api);

            importer.ImportLevels();
        }
Example #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            S2API   api    = new S2API("http://64.129.189.200/goforms/nbapi", "admin", "admin");
            XmlNode nd     = api.GetPerson("0");
            string  imgURL = nd["PICTUREURL"].InnerText;

            txtOutput.Text = nd.InnerXml;
        }
Example #5
0
        private void ImportLevelsFromS2Click(object sender, EventArgs e)
        {
            var api = new S2API(S2APIUrl, S2APIUser, S2APIPassword, false);

            var importer = new S2Importer(api);

            importer.ImportLevels();
        }
Example #6
0
        private void GetLevelOneFromS2Click(object sender, EventArgs e)
        {
            var api = new S2API(S2APIUrl, S2APIUser, S2APIPassword, false);

            var text = api.GetAccessLevel("2").InnerXml;

            AssignView(text, null);
        }
Example #7
0
        private void GetLevelIDsFromS2Click(object sender, EventArgs e)
        {
            var api = new S2API(S2APIUrl, S2APIUser, S2APIPassword, false);

            var text = ConvertStringArrayToString(api.GetLevelIDS());

            AssignView(text, null);
        }
Example #8
0
        private void GetPersonClick(object sender, EventArgs e)
        {
            var api = new S2API(S2APIUrl, S2APIUser, S2APIPassword, false);

            var nd     = api.GetPerson("0");
            var imgUrl = nd["PICTUREURL"].InnerText;

            var text = IndentXMLString(nd.OuterXml);

            AssignView(text, null);
        }
Example #9
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";
        }
Example #10
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";
        }
        public bool ProcessDirtyPeople(S2API api)
        {
            // Loop through all the people that have changes that effect rules and process them

            var people = (from p in _context.Persons
                          where p.NeedsRulePass == true
                          select p);

            foreach (Person person in people)
            {
                ProcessPerson(person, api);
            }

            return(true);
        }
Example #12
0
        private void button9_Click(object sender, EventArgs e)
        {
            S2API   api      = new S2API("http://10.1.1.233/goforms/nbapi", "admin", "072159245241245031239120017047219193126250124056");
            XmlNode nd       = api.GetPicture("4086");
            string  fileName = nd["PICTUREURL"].InnerText;

            byte[] imageData = Convert.FromBase64String(nd["PICTURE"].InnerText);
            txtOutput.Text = fileName;

            using (FileStream stream = new FileStream(fileName, FileMode.Create))
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    writer.Write(imageData);
                    writer.Close();
                }
            }
        }
Example #13
0
        void ImportS2Levels()
        {
            S2API      api   = new S2API(_s2URI, _s2RSMAccount, _s2RSMPassword);
            S2Importer imp   = new S2Importer(api);
            int        count = 0;

            try
            {
                count = imp.ImportLevels();
            }
            catch (Exception e)
            {
                WriteToEventLogError("Error importing levels from S2: " + e.ToString());
            }

            if (count > 0)
            {
                WriteToEventLog(string.Format("Imported {0} levels from S2 hardware at {1}.", count, _s2URI));
            }
        }
Example #14
0
        public Result <UserSession> Login(string username, string password, string uri, bool encryptedPassword = true)
        {
            var result = Result <UserSession> .Success();

            try
            {
                S2 = new S2API(uri, username, password, encryptedPassword);
            }
            catch (Exception e)
            {
                return(result.Fail(e.ToString()));
            }

            var session = new UserSession()
            {
                Username = username,
                Id       = S2.SessionID
            };

            UserSession   = session;
            result.Entity = session;
            return(result);
        }
Example #15
0
        private void btnLevel1_Click(object sender, EventArgs e)
        {
            S2API api = new S2API("http://64.129.189.200/goforms/nbapi", "admin", "admin");

            txtOutput.Text = api.GetAccessLevel("2").InnerXml;
        }
Example #16
0
        private void btnLevels_Click(object sender, EventArgs e)
        {
            S2API api = new S2API("http://64.129.189.200/goforms/nbapi", "admin", "admin");

            txtOutput.Text = ConvertStringArrayToString(api.GetLevelIDS());
        }
        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);
        }