Ejemplo n.º 1
0
        private void SetReaderGpoStates(ReaderRecord reader, bool state)
        {
            var result = _client.SendRequest(new SetReaderGpoStates(reader.Id, new[]
            {
                new GpoStateRecord(1, state),
                new GpoStateRecord(2, state),
                new GpoStateRecord(3, state),
                new GpoStateRecord(4, state),
            }));

            Console.WriteLine("Reader: {0} ({1}). GPO ports: 1, 2, 3, 4, value: {2}, status: {3}", reader.Name,
                              reader.Id, state, result.Status);
        }
Ejemplo n.º 2
0
        public static List <ReaderRecord> ReadRecords(string host, string logname, CriteriaHandle handle = null)
        {
            List <string> fileContents = new List <string>();
            FtpWebRequest rq           = (FtpWebRequest)FtpWebRequest.Create("ftp://" + host + "/" + logname);

            rq.Method      = WebRequestMethods.Ftp.DownloadFile;
            rq.Credentials = new NetworkCredential("anonymous", "");
            Stream       resp      = rq.GetResponse().GetResponseStream(); //rq.GetRequestStream();
            StreamReader ftpReader = new StreamReader(resp);

            string fileLine = null;

            while ((fileLine = ftpReader.ReadLine()) != null)
            {
                if (handle != null)
                {
                    if (!handle(fileLine))
                    {
                        continue;
                    }
                }
                fileContents.Add(fileLine);
            }
            ftpReader.Close();
            resp.Close();

            List <ReaderRecord> records = new List <ReaderRecord>();

            foreach (string line in fileContents)
            {
                ReaderRecord rec = ReaderRecord.Parse(line);
                if (rec != null)
                {
                    records.Add(rec);
                }
            }
            return(records);
        }
Ejemplo n.º 3
0
        private void SetReaderGpoStates(ReaderRecord reader, bool state)
        {
            var result = _client.SendRequest(new SetReaderGpoStates(reader.Id, new[]
                {
                    new GpoStateRecord(1, state),
                    new GpoStateRecord(2, state),
                    new GpoStateRecord(3, state),
                    new GpoStateRecord(4, state),
                }));

            Console.WriteLine("Reader: {0} ({1}). GPO ports: 1, 2, 3, 4, value: {2}, status: {3}", reader.Name,
                reader.Id, state, result.Status);
        }