public Form1() { InitializeComponent(); //ottengo l'instanza del servizio try { jimbeService = new ServiceController("JimbeService"); } catch (Exception) { MessageBox.Show("Servizio non trovato, assicurati di averlo installato"); notifyIcon1.Icon = Properties.Resources.flag_red; Application.Exit(); } if (jimbeService.Status == ServiceControllerStatus.Running) { //servizio attivo //mi collego al servizio tramite wcf per ottenere la locazione attuale try { _proxy = ProxyFactory.GetProxy(Properties.Settings.Default.Url_TryApp); } catch (Exception) { attivatoreToolStripMenuItem.Text = "Attiva LocalizeMe"; locationName = "LocalizeMe non attivo"; notifyIcon1.Icon = Properties.Resources.flag_red; notifyIcon1.Text = locationName; } actualLocation = _proxy.GetCurrentLocation(); attivatoreToolStripMenuItem.Text = "Disattiva LocalizeMe"; if (actualLocation == null) { //locazione non trovata locationName = "nessuna locazione individuata"; notifyIcon1.Icon = Properties.Resources.flag_blue; notifyIcon1.Text = locationName; } else { //locazione trovata locationName = actualLocation.Name; notifyIcon1.Icon = Properties.Resources.flag_green; } } else { attivatoreToolStripMenuItem.Text = "Attiva LocalizeMe"; locationName = "LocalizeMe non attivo"; notifyIcon1.Icon = Properties.Resources.flag_red; } }
public bool DeleteLocation(Location location) { var repository = _repositoryFactory.CreateRepository<Guid, CoreEntity.Location>(); CoreEntity.Location corelocation = _engine.Map<DTO.Location, CoreEntity.Location>(location); var todelete = repository.FindBy(x => x.Name.Equals(corelocation.Name)); if (ReferenceEquals(todelete, null)) return false; lock (_serviceManager) { if (repository.Delete(todelete)) { _logger.Debug("Delete location " + corelocation.Name + corelocation.Description); return true; } return false; } }
void StoreLocation_f() { if (NameLocationStr == null) NameLocationStr = "Location senza nome"; if (DescriptionLocationStr == null) DescriptionLocationStr = "nessuna descrizione disponibile"; Location loc_tmp=new Location(); loc_tmp.Name = NameLocationStr; loc_tmp.Description = DescriptionLocationStr; loc_tmp.TasksList=new List<Task>(); if(TasksList!=null) foreach (var startProcess in TasksList) { loc_tmp.TasksList.Add(startProcess); } var result = _proxy.InsertLocation(loc_tmp); if (!result.Result && result.Conflict != null) { _proxy.DeleteLocation(result.Conflict); _proxy.InsertLocation(loc_tmp); } NameLocationStr = ""; DescriptionLocationStr = ""; }
internal void ModifyLocation(Location loccc) { if (loccc != null) { NameLocationStr = loccc.Name; DescriptionLocationStr = loccc.Description; if (loccc.TasksList != null) { TasksList = new ObservableCollection<StartProcess>(); foreach (var startProcess in loccc.TasksList) { TasksList.Add((StartProcess)startProcess); } } LocationSensorList = loccc.SensorsList; LocationStatisticList = loccc.StatisticsList; tmpupLocation = loccc; } }
public void SaveLocationChanges() { Location newLoc = new Location(); newLoc.Name = NameLocationStr; newLoc.Description = DescriptionLocationStr; newLoc.SensorsList = LocationSensorList; newLoc.StatisticsList = LocationStatisticList; if (TasksList != null) { newLoc.TasksList = new List<Task>(TasksList); } else newLoc.TasksList = null; _proxy.UpdateLocation(tmpupLocation, newLoc); NameLocationStr = ""; DescriptionLocationStr = ""; }
public void delete_location(Location loc) { if (loc != null) foreach (var tmploc in LocationsList) { if (tmploc.Name.Equals(loc.Name)) { _proxy.DeleteLocation(tmploc); LocationsList.Remove(tmploc); break; } } }
private void timer1_Tick(object sender, EventArgs e) { jimbeService = new ServiceController("JimbeService"); _proxy = ProxyFactory.GetProxy(Properties.Settings.Default.Url_TryApp); //controlla che il servizio รจ attivo e prende la locazione attuale aggiornando l'icona come serve if (jimbeService.Status != ServiceControllerStatus.StopPending && jimbeService.Status != ServiceControllerStatus.Stopped) { attivatoreToolStripMenuItem.Text = "Disattiva LocalizeMe"; //servizio attivo //mi collego al servizio tramite wcf per ottenere la locazione attuale try { actualLocation = _proxy.GetCurrentLocation(); } catch(Exception){} if (actualLocation == null) { //locazione non trovata locationName = "nessuna locazione individuata"; notifyIcon1.Icon = Properties.Resources.flag_blue; notifyIcon1.Text = locationName; } else { //locazione trovata locationName = actualLocation.Name; notifyIcon1.Icon = Properties.Resources.flag_green; notifyIcon1.Text = locationName; } } else { attivatoreToolStripMenuItem.Text = "Attiva LocalizeMe"; locationName = "LocalizeMe non attivo"; notifyIcon1.Icon = Properties.Resources.flag_red; notifyIcon1.Text = locationName; } attivatoreToolStripMenuItem.Enabled = true; }
private static void printLocation(Location location) { Console.WriteLine("Location: " + location.Name + " " + location.Description); foreach (var statistic in location.StatisticsList) { Console.WriteLine("\tStatistic: " + statistic.Start + " " + statistic.End); } Console.WriteLine("-------------------"); foreach (var task in location.TasksList) { Console.WriteLine("\tTask: " + task.GetType() + " " + task.Type); } }
static void Main(string[] args) { var wsDualHttpBinding = new WSDualHttpBinding(); wsDualHttpBinding.ClientBaseAddress = new Uri("http://localhost:9091/JimbeClient"); var _channelFactory = new ChannelFactory<ILocationService>(wsDualHttpBinding, "http://localhost:9090/Jimbe"); ILocationService proxy = _channelFactory.CreateChannel(); IList<Task> tasks= new List<Task>(); var locations = proxy.GetLocations(); if (locations==null) Console.WriteLine("No Locations"); else foreach (var location1 in locations) { printLocation(location1); } // tasks.Add(new StartProcess() // { // ProcessName = "http://www.google.it", // Type = Task.TaskType.Spot // }); tasks.Add(new MessageInfo() { Message = "Delayed 10s", Type = Task.TaskType.Delayed, Delay = new TimeSpan(0,0,10) }); // tasks.Add(new MessageInfo() // { // Message = "Periodic 5s", // Type = Task.TaskType.Periodic, // Delay = new TimeSpan(0, 0, 5) // }); var location = new Location() { Description = "location1", Name = "location1", TasksList = tasks }; Console.WriteLine(location.Name+" "+location.Description+" Insert new location"); Console.ReadLine(); proxy.InsertLocation(location); Console.WriteLine("Read location"); Console.ReadLine(); var current = proxy.GetCurrentLocation(); if (current!=null) { printLocation(current); } Console.ReadLine(); Console.WriteLine("Inserted second location"); location = new Location() { Name = "location2", Description = "location2" }; proxy.InsertLocation(location); Console.ReadLine(); current=proxy.GetCurrentLocation(); printLocation(current); Console.WriteLine("Press enter to delete location"); Console.ReadLine(); proxy.DeleteLocation(current); locations = proxy.GetLocations(); if (locations == null) Console.WriteLine("No Locations"); else foreach (var location1 in locations) { printLocation(location1); } }