예제 #1
0
        public XmlNode GetReader(string key)
        {
            var xo = new XmlOutput()
                     .XmlDeclaration()
                     .Node("NETBOX-API").Attribute("sessionid", SessionID).Within()
                     .Node("COMMAND").Attribute("name", "GetReader").Attribute("num", "1").Within()
                     .Node("PARAMS").Within()
                     .Node("READERKEY").InnerText(key);

            var sw = new StringWriter();
            var tx = new XmlTextWriter(sw);

            xo.GetXmlDocument().WriteTo(tx);

            var doc = HttpPost(xo);

            var node = doc.SelectSingleNode("NETBOX/RESPONSE/DETAILS/READER");

            if (CallWasSuccessful(doc) && node != null)
            {
                return(node);
            }

            return(null);
        }
예제 #2
0
        public string[] GetLevelIDS()
        {
            string[] ids = null;

            var xo = new XmlOutput()
                     .XmlDeclaration()
                     .Node("NETBOX-API").Attribute("sessionid", SessionID).Within()
                     .Node("COMMAND").Attribute("name", "GetAccessLevels").Attribute("num", "1").Within()
                     .Node("PARAMS").Within()
                     .Node("WANTKEY").InnerText("TRUE");

            var sw = new StringWriter();
            var tx = new XmlTextWriter(sw);

            xo.GetXmlDocument().WriteTo(tx);

            var doc = HttpPost(xo);

            if (CallWasSuccessful(doc))
            {
                var results = doc.GetElementsByTagName("ACCESSLEVEL");
                if (results.Count > 0)
                {
                    ids = new string[results.Count];
                    for (var x = 0; x < results.Count; x++)
                    {
                        ids[x] = results[x].InnerText;
                    }
                }
            }

            return(ids);
        }
예제 #3
0
        public XmlNode GetPortal(string key)
        {
            key = key.Trim();
            var xo = new XmlOutput()
                     .XmlDeclaration()
                     .Node("NETBOX-API").Attribute("sessionid", SessionID).Within()
                     .Node("COMMAND").Attribute("name", "GetPortals").Attribute("num", "1").Within()
                     .Node("PARAMS").Within()
                     .Node("STARTFROMKEY").InnerText(key);

            var sw = new StringWriter();
            var tx = new XmlTextWriter(sw);

            xo.GetXmlDocument().WriteTo(tx);

            var doc = HttpPost(xo);

            var node = doc.SelectSingleNode("NETBOX/RESPONSE/DETAILS/PORTALS/PORTAL");

            if (CallWasSuccessful(doc) && node != null && node["PORTALKEY"].InnerText == key)
            {
                return(node);
            }

            return(null);
        }
예제 #4
0
        public XmlNode GetPicture(string userID)
        {
            var xo = new XmlOutput()
                     .XmlDeclaration()
                     .Node("NETBOX-API").Attribute("sessionid", SessionID).Within()
                     .Node("COMMAND").Attribute("name", "GetPicture").Attribute("num", "1").Within()
                     .Node("PARAMS").Within()
                     .Node("PERSONID").InnerText(userID)
                     .Node("ALLPARTITIONS").InnerText("TRUE");

            var sw = new StringWriter();
            var tx = new XmlTextWriter(sw);

            xo.GetXmlDocument().WriteTo(tx);

            var doc = HttpPost(xo);

            if (CallWasSuccessful(doc))
            {
                XmlNode details = doc["NETBOX"]["RESPONSE"]["DETAILS"];
                return(details);
            }

            return(null);
        }
예제 #5
0
        public XmlNode GetAccessLevel(string key)
        {
            XmlOutput xo = new XmlOutput()
                           .XmlDeclaration()
                           .Node("NETBOX-API").Attribute("sessionid", _sessionID).Within()
                           .Node("COMMAND").Attribute("name", "GetAccessLevel").Attribute("num", "1").Within()
                           .Node("PARAMS").Within()
                           .Node("ACCESSLEVELKEY").InnerText(key);


            StringWriter  sw = new StringWriter();
            XmlTextWriter tx = new XmlTextWriter(sw);

            xo.GetXmlDocument().WriteTo(tx);

            //string data = sw.ToString();


            XmlDocument doc = HttpPost(xo);

            if (CallWasSuccessful(doc))
            {
                XmlNode details = doc["NETBOX"]["RESPONSE"]["DETAILS"];
                return(details);
            }
            else
            {
            }

            return(null);
        }
예제 #6
0
        private XmlDocument HttpPost(XmlOutput xmlData)
        {
            // parameters: name1=value1&name2=value2
            var webRequest = WebRequest.Create(_uri);

            var sw = new StringWriter();
            var tx = new XmlTextWriter(sw);

            xmlData.GetXmlDocument().WriteTo(tx);

            var data = sw.ToString();

            webRequest.ContentType = "application/x-www-form-urlencoded";
            webRequest.Method      = "POST";

            var    bytes = Encoding.ASCII.GetBytes("APIcommand=" + data);
            Stream os    = null;

            try
            {
                // send the Post
                webRequest.ContentLength = bytes.Length;          //Count bytes to send
                os = webRequest.GetRequestStream();
                os.Write(bytes, 0, bytes.Length);                 //Send it
            }
            catch (WebException)
            {
                return(null);
            }
            finally
            {
                if (os != null)
                {
                    os.Close();
                }
            }

            try
            {
                // get the response
                var webResponse = webRequest.GetResponse();

                // ReSharper disable AssignNullToNotNullAttribute
                var sr = new StreamReader(webResponse.GetResponseStream());
                // ReSharper restore AssignNullToNotNullAttribute

                var doc = new XmlDocument();
                LastResponse = sr.ReadToEnd().Trim();
                doc.LoadXml(LastResponse);
                return(doc);
            }
            catch (Exception e)
            {
                EventLog.WriteEntry("R1SM", string.Format("Error getting S2 response {0}", e.Message), EventLogEntryType.Error);
            }
            return(null);
        }
예제 #7
0
        public XmlNode SearchPersonData(string id = null, string startingKey = null, PersonState state = PersonState.All)
        {
            var xo = new XmlOutput()
                     .XmlDeclaration()
                     .Node("NETBOX-API").Attribute("sessionid", SessionID).Within()
                     .Node("COMMAND").Attribute("name", "SearchPersonData").Attribute("num", "1").Within()
                     .Node("PARAMS").Within()
                     .Node("ALLPARTITIONS").InnerText("TRUE");

            if (!string.IsNullOrEmpty(id))
            {
                xo.Node("PERSONID").InnerText(id);
            }

            if (!string.IsNullOrEmpty(startingKey))
            {
                xo.Node("STARTFROMKEY").InnerText(startingKey);
            }

            var deleted = "ALL";

            if (state == PersonState.Deleted)
            {
                deleted = "TRUE";
            }
            else if (state == PersonState.NotDeleted)
            {
                deleted = "FALSE";
            }

            xo.Node("DELETED").InnerText(deleted);

            var sw = new StringWriter();
            var tx = new XmlTextWriter(sw);

            xo.GetXmlDocument().WriteTo(tx);

            var doc = HttpPost(xo);

            if (CallWasSuccessful(doc))
            {
                XmlNode details = doc["NETBOX"]["RESPONSE"]["DETAILS"];
                return(details);
            }

            return(null);
        }
예제 #8
0
        public XmlNode GetAccessHistory(DateTime from, string nextId = null, string startFromId = null)
        {
            var xo = new XmlOutput()
                     .XmlDeclaration()
                     .Node("NETBOX-API").Attribute("sessionid", SessionID).Within()
                     .Node("COMMAND").Attribute("name", "GetAccessHistory").Attribute("num", "1").Within();

            var param = xo.Node("PARAMS").Within();

            param.Node("OLDESTDTTM").InnerText(from.ToString(DateFormat));
            //optional NEWESTDTTM

            if (nextId != null || startFromId != null)
            {
                if (!string.IsNullOrEmpty(nextId))
                {
                    param.Node("STARTLOGID").InnerText(nextId);
                }

                if (!string.IsNullOrEmpty(startFromId))
                {
                    param.Node("AFTERLOGID").InnerText(startFromId);
                }
            }

            var sw = new StringWriter();
            var tx = new XmlTextWriter(sw);

            xo.GetXmlDocument().WriteTo(tx);

            var doc = HttpPost(xo);

            var code = doc.SelectSingleNode("NETBOX/RESPONSE/CODE");

            if (code != null &&
                (code.InnerXml == "SUCCESS" || code.InnerXml == "NOT FOUND"))
            {
                return(code.InnerXml == "SUCCESS" ? doc["NETBOX"]["RESPONSE"]["DETAILS"] : code);
            }

            return(null);
        }
        public XmlDocument GetXml()
        {
            XmlOutput xo = new XmlOutput()
                           .XmlDeclaration()
                           .Node("package").Attribute("xmlns", "http://soap.sforce.com/2006/04/metadata").Within();

            foreach (var salesForceChange in Types)
            {
                XmlOutput xmlOutput = xo.Node("types").Within();
                foreach (var member in salesForceChange.Members)
                {
                    xmlOutput.Node("members").InnerText(member);
                }
                xmlOutput.Node("name").InnerText(salesForceChange.Name)
                .EndWithin();
            }

            xo.EndWithin()
            .Node("version").InnerText(this.Version);

            return(xo.GetXmlDocument());
        }
        public XmlDocument GetXml()
        {
            XmlOutput xo = new XmlOutput()
           .XmlDeclaration()
           .Node("package").Attribute("xmlns", "http://soap.sforce.com/2006/04/metadata").Within();

            foreach (var salesForceChange in Types)
            {
                XmlOutput xmlOutput = xo.Node("types").Within();
                foreach (var member in salesForceChange.Members)
                {
                    xmlOutput.Node("members").InnerText(member);
                }
                xmlOutput.Node("name").InnerText(salesForceChange.Name)
                       .EndWithin();
            }

            xo.EndWithin()
            .Node("version").InnerText(this.Version);

            return xo.GetXmlDocument();
        }