public string[] GetEntryOperazioni(DateTime dt) { string[] entries = null; try { BasicHttpBinding myBinding = new BasicHttpBinding(); EndpointAddress myEndpoint = new EndpointAddress(_addr); ChannelFactory <IGestoreSicurezza> myChannelFactory = new ChannelFactory <IGestoreSicurezza>(myBinding, myEndpoint); // Create a channel. IGestoreSicurezza clientGestoreSicurezza = myChannelFactory.CreateChannel(); entries = clientGestoreSicurezza.GetEntryOperazioni(dt); ((IClientChannel)clientGestoreSicurezza).Close(); myChannelFactory.Close(); } catch (Exception e) { //System.Windows.Forms.MessageBox.Show(e.Message); //doNothing } return(entries); }
public string[] GetEntryAccessiInterval(DateTime dt1, DateTime dt2) { string[] entries = null; try { BasicHttpBinding myBinding = new BasicHttpBinding(); EndpointAddress myEndpoint = new EndpointAddress(_addr); ChannelFactory <IGestoreSicurezza> myChannelFactory = new ChannelFactory <IGestoreSicurezza>(myBinding, myEndpoint); // Create a channel. IGestoreSicurezza clientGestoreSicurezza = myChannelFactory.CreateChannel(); DateTime fine = new DateTime(dt2.Year, dt2.Month, dt2.Day, 23, 59, 59); entries = clientGestoreSicurezza.GetEntryAccessiInterval(dt1, fine); ((IClientChannel)clientGestoreSicurezza).Close(); myChannelFactory.Close(); //System.Windows.Forms.MessageBox.Show(dt.ToString() + " " + entries.Length.ToString()); } catch (Exception e) { //System.Windows.Forms.MessageBox.Show(e.Message); //doNothing } return(entries); }
static void Main(string[] args) { BrokerClient client = new BrokerClient(); string host = null; try { Console.WriteLine("Richiesta inviata"); host = client.GestisciLogin("gestoreMarco", "gestoreMarco", "gestoreSicurezza"); Console.WriteLine(host); } catch (FaultException <AccessFault> e) { Console.WriteLine(e.Detail.Message); } Console.ReadLine(); client.Close(); EntryOperazione e1 = new EntryOperazione { DataOra = DateTime.Now, Username = "******", Luogo = "Bologna", TipoOperazione = "salvataggio lista personale" }; EntryOperazione e2 = new EntryOperazione { DataOra = DateTime.Now, Username = "******", Luogo = "Bologna", TipoOperazione = "creazione lista personale" }; EntryOperazione[] entries = new EntryOperazione[2]; entries[0] = e1; entries[1] = e2; try { if (host != null) { DateTime dateTimeStart = new DateTime(2018, 6, 17); DateTime dateTimeStop = new DateTime(2018, 6, 18); BasicHttpBinding myBinding = new BasicHttpBinding(); EndpointAddress myEndpoint = new EndpointAddress(host); ChannelFactory <IGestoreSicurezza> myChannelFactory = new ChannelFactory <IGestoreSicurezza>(myBinding, myEndpoint); // Create a channel. IGestoreSicurezza clientGestoreSicurezza = myChannelFactory.CreateChannel(); //clientGestoreSicurezza.PrintLogOperazioni(entries); //Console.WriteLine("scrittura log avvenuta con successo!"); List <string> operazioni = clientGestoreSicurezza.GetEntryOperazioni(dateTimeStart).OfType <string>().ToList(); foreach (string op in operazioni) { Console.WriteLine(op); } ((IClientChannel)clientGestoreSicurezza).Close(); Console.ReadLine(); } } catch (FaultException <BookFault> e) { Console.WriteLine(e.Detail.Message); } }