Esempio n. 1
0
 public BusMessage(Bus.Channel channel, JObject data, MessageScope scope)
 {
     Data = data;
     Channel = channel;
     Scope = scope;
     Origin = "5";
 }
Esempio n. 2
0
 private void Update()
 {
     // Forward incoming SMS ?
     if (PackageHost.ContainsSetting("ForwardIncomingSMSTo") && !string.IsNullOrEmpty(PackageHost.GetSettingValue("ForwardIncomingSMSTo")) && this.router.Notification.UnreadMessage > 0)
     {
         foreach (Message sms in this.router.SMS.List.Messages)
         {
             if (sms.Status == Message.Smstat.Unread)
             {
                 PackageHost.WriteInfo($"Forwarding incoming SMS from {sms.Phone}");
                 MessageScope.Create(MessageScope.ScopeType.Group, PackageHost.GetSettingValue("ForwardIncomingSMSTo"))
                 .GetProxy()
                 .IncomingSMS(new { Number = sms.Phone, Text = sms.Content, sms.Date, sms.Priority });
                 if (PackageHost.GetSettingValue <bool>("KeepSMSCopy"))
                 {
                     this.router.SetSMSRead(sms.Index);
                 }
                 else
                 {
                     this.router.DeleteSMS(sms.Index);
                 }
             }
         }
     }
     // Update StateObjects
     this.PushStateObject <DeviceSignal>(() => this.router.DeviceSignal);
     this.PushStateObject <MonitoringStatus>(() => this.router.MonitoringStatus);
     this.PushStateObject <MonthlyStatistics>(() => this.router.MonthlyStatistics);
     this.PushStateObject <PinStatus>(() => this.router.PinStatus);
     this.PushStateObject <PLMNInformations>(() => this.router.PLMNInformations);
     this.PushStateObject <TrafficStatistics>(() => this.router.TrafficStatistics);
     this.PushStateObject <WlanBasicSettings>(() => this.router.WlanBasicSettings);
     this.PushStateObject <Notification>(() => this.router.Notification);
     this.PushStateObject <SMSList>(() => this.router.SMS);
 }
Esempio n. 3
0
        private void OnValueChanged(object sender, StateObjectChangedEventArgs e)
        {
            //récupération des nouvelles valeurs
            PackageHost.WriteInfo("values are : {0}", this.PushValues.DynamicValue);
            latitude  = e.NewState.DynamicValue.Latitude;
            longitude = e.NewState.DynamicValue.Longitude;
            login     = e.NewState.DynamicValue.Login;
            pass      = e.NewState.DynamicValue.Pass;
            myGuid    = Auth(pass, login, latitude, longitude);
            String myGuidString = myGuid.ToString();

            PackageHost.WriteInfo("generated token : {0}", myGuid);
            PackageHost.WriteInfo("Sending generated token");

            if (myGuid != Guid.Empty) //si token valide généré par Auth, envoi à la Raspberry
            {
                //communication avec la Raspberry
                MessageScope.Create("ConstellationPackagePython2").OnSagaResponse((response) =>
                {
                    //premier envoi du token, récupération de ce même token
                    PackageHost.WriteInfo("Sending generated token");
                    PackageHost.WriteInfo("Raspberry response : {0}", response);
                    String responseC = myGuidString + "fr42kilj8";   //deuxième envoi du token + clé de sécurite
                    PackageHost.WriteInfo(" Sending token + key ");
                    PackageHost.SendMessage(MessageScope.Create("ConstellationPackagePython2"), "reponse", responseC);
                }).GetProxy().question <String>(myGuidString);
            }
        }
Esempio n. 4
0
 public BusMessage(Bus.Channel channel, JObject data, MessageScope scope)
 {
     Data    = data;
     Channel = channel;
     Scope   = scope;
     Origin  = "5";
 }
Esempio n. 5
0
        public TimeAndPlace GetWakeUpHour()
        {
            var TimeReveil = new TimeAndPlace();
            List <EventnTraffic> ListEvent = Events.DynamicValue.ToObject <List <EventnTraffic> >();

            foreach (var evenement in ListEvent)
            {
                if (DateTime.Now < DateTime.Parse(evenement.DateDebut))
                {
                    PackageHost.WriteInfo("Le prochain évènement est le {0}", evenement.DateDebut.ToString());
                    TimeReveil.Time = DateTime.Parse(evenement.DateDebut);
                    try
                    {
                        TimeReveil.TimeTraffic = TimeSpan.Parse(evenement.TimeTrafficFromHouse.ToString());
                        TimeReveil.Place       = evenement.Lieu;
                    }
                    catch
                    {
                        var title = "Absence lieu pour le lendemain";
                        var body  = "Aucun lieu n'a été enregistré pour demain, le temps de trajet ne sera pas pris en compte";
                        PackageHost.SendMessage(MessageScope.Create("PushBullet"), "PushNote", new object[] { title as System.String, body as System.String });
                        TimeReveil.TimeTraffic = new TimeSpan();
                    }
                    return(TimeReveil);
                }
            }
            return(TimeReveil);
        }
        public override void OnStart()
        {
            PackageHost.WriteInfo("Package starting - IsRunning: {0} - IsConnected: {1}", PackageHost.IsRunning, PackageHost.IsConnected);

            while (PackageHost.IsRunning)
            {
                int Heure  = DateTime.Now.Hour;
                int Minute = DateTime.Now.Minute;

                if (DateTime.Now.Date != dateProcessedFeeding.Date && Heure == 13 && Minute == 30)
                {
                    dateProcessedFeeding = DateTime.Now;
                    PackageHost.SendMessage(MessageScope.Create("FishtNess"), "Feeding", null);
                }

                if (DateTime.Now.Date != dateProcessedSwitchON.Date && Heure == 11 && Minute == 30)
                {
                    dateProcessedSwitchON = DateTime.Now;
                    PackageHost.SendMessage(MessageScope.Create("FishtNess"), "SwitchState", true);
                }

                if (DateTime.Now.Date != dateProcessedSwitchOFF.Date && Heure == 21 && Minute == 30)
                {
                    dateProcessedSwitchOFF = DateTime.Now;
                    PackageHost.SendMessage(MessageScope.Create("FishtNess"), "SwitchState", false);
                }


                if (DateTime.Now.Date != dateProcessedPushBullet1.Date && Heure == 8)
                {
                    dateProcessedPushBullet1 = DateTime.Now;
                    PackageHost.CreateMessageProxy("PushBullet").PushNote("ATTENTION", "La température de l'aquarium est : {0}°C.", this.Temperature.DynamicValue);
                }

                else if (DateTime.Now.Date != dateProcessedPushBullet2.Date && Heure == 15)
                {
                    dateProcessedPushBullet2 = DateTime.Now;
                    PackageHost.CreateMessageProxy("PushBullet").PushNote("ATTENTION", "La température de l'aquarium est : {0}°C.", this.Temperature.DynamicValue);
                }

                else if (DateTime.Now.Date != dateProcessedPushBullet3.Date && Heure == 8)
                {
                    dateProcessedPushBullet3 = DateTime.Now;
                    PackageHost.CreateMessageProxy("PushBullet").PushNote("ATTENTION", "L'acidite (pH) de l'aquarium est : {0}.", this.Acidity.DynamicValue);
                }

                else if (DateTime.Now.Date != dateProcessedPushBullet4.Date && Heure == 15)
                {
                    dateProcessedPushBullet4 = DateTime.Now;
                    PackageHost.CreateMessageProxy("PushBullet").PushNote("ATTENTION", "L'acidite (pH) de l'aquarium est : {0}.", this.Acidity.DynamicValue);
                }



                Thread.Sleep(PackageHost.GetSettingValue <int>("Interval"));
            }
        }
Esempio n. 7
0
        public void ModeAuto()
        {
            TimeAndPlace WakeUp = GetWakeUpHour();
            TimeSpan     prep_time = new TimeSpan();
            string       title, body;

            try
            {
                prep_time = new TimeSpan(0, int.Parse(PackageHost.GetSettingValue("TpsPrep")), 0);
            }
            catch
            {
                prep_time = new TimeSpan(0, 45, 0);
                PackageHost.WriteWarn("Paramètre du temps de préparation non récupéré, le temps de 45mn sera considéré");
            }
            Alarme NewAlarm = new Alarme();

            NewAlarm.IsRinging      = false;
            NewAlarm.TimeFirstEvent = WakeUp.Time.ToString();

            if (WakeUp.Time.Subtract(DateTime.Now) < new TimeSpan(1, 0, 0, 0)) //Si le réveil doit sonner dans + de 24h on active pas encore l'alarme et on attends le refresh journalier
            {
                if (WakeUp.TimeTraffic != new TimeSpan())
                {
                    WakeUp.Time           = WakeUp.Time.Subtract(prep_time + WakeUp.TimeTraffic);
                    NewAlarm.TimeTraffic  = WakeUp.TimeTraffic.ToString();
                    NewAlarm.AlarmHour    = WakeUp.Time.Hour;
                    NewAlarm.AlarmMinutes = WakeUp.Time.Minute;
                    title = "Alarme en mode automatique";
                    body  = string.Format("L'alarme sonnera à {0}:{1}", NewAlarm.AlarmHour.ToString("00"), NewAlarm.AlarmMinutes.ToString("00"));
                    PackageHost.SendMessage(MessageScope.Create("PushBullet"), "PushNote", new object[] { title as System.String, body as System.String });
                    ChangeAlarm(NewAlarm);
                    return;
                }
                else
                {
                    title = "Erreur temps de trajet";
                    body  = "Impossible de récuperer le temps de trajet, le temps de trajet ne sera pas pris en compte";
                    PackageHost.SendMessage(MessageScope.Create("PushBullet"), "PushNote", new object[] { title as System.String, body as System.String });
                    WakeUp.Time           = WakeUp.Time.Subtract(prep_time);
                    NewAlarm.AlarmHour    = WakeUp.Time.Hour;
                    NewAlarm.AlarmMinutes = WakeUp.Time.Minute;
                    NewAlarm.TimeTraffic  = new TimeSpan().ToString();
                    ChangeAlarm(NewAlarm);
                    return;
                }
            }
            else
            {
                PackageHost.WriteInfo("Pas de réveil automatique prévu d'ici les 24h prochaines heures !");
            }
        }
Esempio n. 8
0
 public void ModeManuel()
 {
     if (int.Parse(ParametresServeur.DynamicValue.AlarmHour.ToString()) > 0 && int.Parse(ParametresServeur.DynamicValue.AlarmMinutes.ToString()) > 0)
     {
         PackageHost.WriteInfo("Mode de réveil = 1");
         Alarme NewAlarm = new Alarme();
         NewAlarm.IsRinging    = false;
         NewAlarm.AlarmHour    = int.Parse(ParametresServeur.DynamicValue.ManualAlarmHour.ToString());
         NewAlarm.AlarmMinutes = int.Parse(ParametresServeur.DynamicValue.ManualAlarmMinute.ToString());
         var title = "Alarme en mode manuel";
         var body  = string.Format("L'alarme sonnera à {0}:{1}", NewAlarm.AlarmHour.ToString("00"), NewAlarm.AlarmMinutes.ToString("00"));
         PackageHost.SendMessage(MessageScope.Create("PushBullet"), "PushNote", new object[] { title as System.String, body as System.String });
         ChangeAlarm(NewAlarm);
         return;
     }
     else
     {
         var title = "Erreur mode manuel";
         var body  = string.Format("L'heure entrée pour le mode manuel n'est pas correct !");
         PackageHost.SendMessage(MessageScope.Create("PushBullet"), "PushNote", new object[] { title as System.String, body as System.String });
     }
 }
 /// <summary>
 /// Create a PushBulletScope to a specific package
 /// </summary>
 /// <param name="package">The package</param>
 public static PushBulletScope CreatePushBulletScope(this WhenShouldIGo.MyConstellation.Packages package)
 {
     return(MessageScope.Create(MessageScope.ScopeType.Package, package.GetRealName()).ToPushBulletScope());
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PushBulletScope"/> class.
 /// </summary>
 /// <param name="scope">The scope.</param>
 public PushBulletScope(MessageScope scope)
 {
     this.currentScope = scope;
 }
 /// <summary>
 /// Create a PushBulletScope
 /// </summary>
 /// <param name="scope">The Constellation MessageScope</param>
 public static PushBulletScope ToPushBulletScope(this MessageScope scope)
 {
     return(new PushBulletScope(scope));
 }
 /// <summary>
 /// Create a PushBulletScope to all packages of the specified sentinel
 /// </summary>
 /// <param name="sentinel">The sentinel</param>
 public static PushBulletScope CreatePushBulletScope(this WhenShouldIGo.MyConstellation.Sentinels sentinel)
 {
     return(MessageScope.Create(MessageScope.ScopeType.Sentinel, sentinel.GetRealName()).ToPushBulletScope());
 }
 /// <summary>
 /// Create a MyfirstPackageScope to all packages of the specified sentinel
 /// </summary>
 /// <param name="sentinel">The sentinel</param>
 public static MyfirstPackageScope CreateMyfirstPackageScope(this ConstellationPackageConsole2.MyConstellation.Sentinels sentinel)
 {
     return(MessageScope.Create(MessageScope.ScopeType.Sentinel, sentinel.GetRealName()).ToMyfirstPackageScope());
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GoogleTrafficScope"/> class.
 /// </summary>
 /// <param name="scope">The scope.</param>
 public GoogleTrafficScope(MessageScope scope)
 {
     this.currentScope = scope;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageBroker"/> class.
 /// </summary>
 public MessageBroker()
 {
     this.scope = MessageScope.Low;
 }
Esempio n. 16
0
 public void PreDispatch(IConsumeContext context)
 {
     MessageScope.BeginScope();
 }
Esempio n. 17
0
        /// <summary>
        /// Called when start the package.
        /// </summary>
        public override void OnStart()
        {
            PackageHost.WriteInfo("Initializing Paradox package");

            // The group where send AlarmEvent message is the name of the package's instance
            this.scopeParadox = MessageScope.Create(MessageScope.ScopeType.Group, PackageHost.PackageInstanceName);

            // Create the Paradox API manager
            this.paradox = new ParadoxManager(PackageHost.GetSettingValue("PortCom"), PackageHost.GetSettingValue <int>("PortBaudRate"));

            // When the PRT3 connection changed
            bool connectionFail = false;

            this.paradox.Interface.ConnectionStateChanged += (s, e) =>
            {
                // Disconnection
                if (!this.paradox.Interface.IsConnected)
                {
                    if (connectionFail) // already fail ?
                    {
                        PackageHost.WriteInfo("Error unable to reconnect to the PRT3 Serial interface : shutdown package !");
                        PackageHost.Shutdown();
                    }
                    else // first disconnection, try to reconnect if still running
                    {
                        PackageHost.WriteWarn("Serial interface is disconnected" + (PackageHost.IsRunning ? " : trying to reconnect" : "."));
                        if (PackageHost.IsRunning)
                        {
                            connectionFail = true;
                            this.paradox.Interface.Connect();
                        }
                    }
                }
                // Reconnection
                else
                {
                    connectionFail = false;
                    PackageHost.WriteInfo("PRT3 Serial interface is reconnected : RefreshAll");
                    this.RefreshAll();
                }
                // Raise Constellation event
                this.scopeParadox.GetProxy().AlarmEvent(new { Type = "ConnectionStateChanged", State = this.paradox.Interface.IsConnected });
            };

            // Raise initial Constellation event
            this.scopeParadox.GetProxy().AlarmEvent(new { Type = "ConnectionStateChanged", State = this.paradox.Interface.IsConnected });

            // Refresh all when the package is reconnected to Constellation
            PackageHost.ConnectionStateChanged += (s, e) =>
            {
                if (PackageHost.IsConnected)
                {
                    PackageHost.WriteInfo("Package is reconnected : RefreshAll");
                    this.RefreshAll();
                }
            };

            // Interface error
            this.paradox.Interface.InterfaceError += (s, e) =>
            {
                // Write error
                PackageHost.WriteError("PRT3 Serial interface error : {0}", e.Exception.ToString());
                // Raise Constellation event
                this.scopeParadox.GetProxy().AlarmEvent(new { Type = "InterfaceError", Exception = e.Exception.Message });
            };

            // Message logging
            try
            {
                if (!string.IsNullOrEmpty(PackageHost.GetSettingValue("MessagesLogFilePath")) &&
                    !string.IsNullOrEmpty(Path.GetFileName(PackageHost.GetSettingValue("MessagesLogFilePath"))))
                {
                    BlockingCollection <string> logMessages = new BlockingCollection <string>();
                    this.paradox.Interface.MessageReceived += (s, e) => logMessages.Add(e.Date.ToString("dd/MM/yyyy HH:mm:ss.fff") + " < " + e.Message);
                    this.paradox.Interface.MessageSent     += (s, e) => logMessages.Add(e.Date.ToString("dd/MM/yyyy HH:mm:ss.fff") + " > " + e.Message);
                    Task.Factory.StartNew(() =>
                    {
                        while (PackageHost.IsRunning)
                        {
                            foreach (var msg in logMessages.GetConsumingEnumerable())
                            {
                                try
                                {
                                    File.AppendAllText(
                                        PackageHost.GetSettingValue("MessagesLogFilePath").Replace(".log", "." + DateTime.Now.ToString("yyyy-MM-dd") + ".log"),
                                        msg + Environment.NewLine);
                                }
                                catch { }
                            }
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                PackageHost.WriteError("Error with the Paradox message logging : {0}", ex.Message);
            }

            // Label received
            this.paradox.UserLabelReceived += (s, e) => this.PushItem <UserInfo>(e.UserId, o => o.UpdateName(e.Label));
            this.paradox.ZoneLabelReceived += (s, e) => this.PushItem <ZoneInfo>((int)e.Zone, o => o.UpdateName(e.Label));
            this.paradox.AreaLabelReceived += (s, e) => this.PushItem <AreaInfo>((int)e.Area, o => o.UpdateName(e.Label));

            // Area Status changed
            this.paradox.AreaStatusChanged += (s, e) => this.PushItem <AreaInfo>((int)e.Area, o =>
            {
                o.HasTrouble      = e.HasTrouble;
                o.InAlarm         = e.InAlarm;
                o.IsInProgramming = e.IsInProgramming;
                o.IsFullArmed     = (e.Status == AreaStatus.Armed) || (e.Status == AreaStatus.ForceArmed);
                o.IsReady         = e.IsReady;
                o.IsStayArmed     = e.Status == AreaStatus.StayArmed;
                o.LastActivity    = e.MessageDate;
                o.Strobe          = e.Strobe;
            });

            // Zone Status changed
            this.paradox.ZoneStatusChanged += (s, e) => this.PushItem <ZoneInfo>((int)e.Zone, o =>
            {
                o.InAlarm         = e.InAlarm;
                o.InFireAlarm     = e.InFireAlarm;
                o.IsOpen          = e.Status == ZoneStatus.Open;
                o.IsTamper        = e.Status == ZoneStatus.Tampered;
                o.LowBattery      = e.LowBattery;
                o.SupervisionLost = e.SupervisionLost;
                o.LastActivity    = e.MessageDate;
            });

            // Zone changed
            this.paradox.EventManager.ZoneChanged += (s, e) => this.PushItem <ZoneInfo>((int)e.Zone, o =>
            {
                o.IsOpen       = e.EventGroup == EventGroup.ZoneOpen;
                o.IsTamper     = e.EventGroup == EventGroup.ZoneTampered;
                o.LastActivity = e.MessageDate;
            });

            // Zone in alarm
            this.paradox.EventManager.ZoneInAlarm += (s, e) => this.PushItem <ZoneInfo>((int)e.Zone, o =>
            {
                o.InAlarm      = true;
                o.LastActivity = e.MessageDate;
            });
            this.paradox.EventManager.ZoneAlarmRestored += (s, e) => this.PushItem <ZoneInfo>((int)e.Zone, o =>
            {
                o.InAlarm      = false;
                o.LastActivity = e.MessageDate;
            });

            // Log all Paradox system events to Constellation
            this.paradox.SystemEventReceived += (s, e) => PackageHost.WriteInfo("SystemEventReceived: {0}", e.ToString());

            // User enter code on keypad
            this.paradox.EventManager.UserCodeEnteredOnKeypad += (s, e) =>
            {
                string userId = "UserInfo" + e.UserId;
                if (items.ContainsKey(userId))
                {
                    PackageHost.WriteInfo(items[userId].Name + " entered code on keyboard ");
                }
                this.PushItem <UserInfo>(e.UserId, o => o.LastActivity = e.MessageDate);
            };

            // Status changed
            this.paradox.EventManager.Status1Changed += (s, e) =>
            {
                if (e.StatusType == Status1EventType.Armed || e.StatusType == Status1EventType.ForceArmed || e.StatusType == Status1EventType.InstantArmed || e.StatusType == Status1EventType.StayArmed)
                {
                    this.scopeParadox.GetProxy().AlarmEvent(new { Type = "Armed", Status = e.StatusType.ToString(), Date = e.MessageDate, Text = e.MessageText });
                }
                else if (e.StatusType == Status1EventType.AudibleAlarm || e.StatusType == Status1EventType.SilentAlarm || e.StatusType == Status1EventType.StrobeAlarm)
                {
                    this.RefreshArea(e.Area);
                    this.scopeParadox.GetProxy().AlarmEvent(new { Type = "Alarm", Status = e.StatusType.ToString(), Date = e.MessageDate, Text = e.MessageText });
                }
                PackageHost.PushStateObject("Status1", new { Status = e.StatusType.ToString() });
            };
            this.paradox.EventManager.Status2Changed += (s, e) => PackageHost.PushStateObject("Status2", new { Status = e.StatusType.ToString() });

            // Arming & disarming events
            this.paradox.EventManager.Arming += (s, e) =>
            {
                this.RefreshArea(e.Area);
                this.scopeParadox.GetProxy().AlarmEvent(new { Type = "Arming", User = items["UserInfo" + e.UserId], Date = e.MessageDate, Text = e.MessageText });
            };
            this.paradox.EventManager.Disarming += (s, e) =>
            {
                this.RefreshArea(e.Area);
                this.scopeParadox.GetProxy().AlarmEvent(new { Type = "Disarming", User = items["UserInfo" + e.UserId], Date = e.MessageDate, Text = e.MessageText });
            };

            // Other events
            this.paradox.EventManager.UserCodeEnteredOnKeypad += (s, e) => this.scopeParadox.GetProxy().AlarmEvent(new { Type = "UserCodeEnteredOnKeypad", User = items["UserInfo" + e.UserId], Date = e.MessageDate, Text = e.MessageText });
            this.paradox.EventManager.SpecialArming           += (s, e) => this.scopeParadox.GetProxy().AlarmEvent(new { Type = "SpecialArming", ArmingType = e.ArmingType.ToString(), Date = e.MessageDate, Text = e.MessageText });
            this.paradox.EventManager.AccessDenied            += (s, e) => this.scopeParadox.GetProxy().AlarmEvent(new { Type = "AccessDenied", User = items["UserInfo" + e.UserId], Date = e.MessageDate, Text = e.MessageText });
            this.paradox.EventManager.AccessGranted           += (s, e) => this.scopeParadox.GetProxy().AlarmEvent(new { Type = "AccessGranted", User = items["UserInfo" + e.UserId], Date = e.MessageDate, Text = e.MessageText });
            this.paradox.EventManager.AlarmCancelled          += (s, e) => this.scopeParadox.GetProxy().AlarmEvent(new { Type = "AlarmCancelled", User = items["UserInfo" + e.UserId], Date = e.MessageDate, Text = e.MessageText });
            this.paradox.EventManager.NonReportableEvent      += (s, e) => this.scopeParadox.GetProxy().AlarmEvent(new { Type = "NonReportableEvent", Event = e.Event.ToString(), Date = e.MessageDate, Text = e.MessageText });
            this.paradox.EventManager.ZoneInAlarm             += (s, e) => this.scopeParadox.GetProxy().AlarmEvent(new { Type = "ZoneInAlarm", Zone = items["ZoneInfo" + (int)e.Zone], Date = e.MessageDate, Text = e.MessageText });
            this.paradox.EventManager.ZoneAlarmRestored       += (s, e) => this.scopeParadox.GetProxy().AlarmEvent(new { Type = "ZoneAlarmRestored", Zone = items["ZoneInfo" + (int)e.Zone], Date = e.MessageDate, Text = e.MessageText });
            this.paradox.EventManager.ZoneChanged             += (s, e) => this.scopeParadox.GetProxy().AlarmEvent(new { Type = "ZoneChanged", Zone = items["ZoneInfo" + (int)e.Zone], Date = e.MessageDate, Text = e.MessageText });

            // Refresh all
            this.RefreshAll();

            // Initialization OK
            PackageHost.WriteInfo("Paradox System is loaded");
        }
 /// <summary>
 /// Create a MyfirstPackageScope to a specific package
 /// </summary>
 /// <param name="package">The package</param>
 public static MyfirstPackageScope CreateMyfirstPackageScope(this ConstellationPackageConsole2.MyConstellation.Packages package)
 {
     return(MessageScope.Create(MessageScope.ScopeType.Package, package.GetRealName()).ToMyfirstPackageScope());
 }
 /// <summary>
 /// Creates the message scope to the specified sentinel.
 /// </summary>
 /// <param name="sentinel">The sentinel.</param>
 /// <returns>MessageScope</returns>
 public static MessageScope CreateScope(this Sentinels sentinel)
 {
     return(MessageScope.Create(MessageScope.ScopeType.Sentinel, sentinel.GetRealName()));
 }
 /// <summary>
 /// Create a PushBulletScope to a specific package
 /// </summary>
 /// <param name="package">The package</param>
 public static PushBulletScope CreatePushBulletScope(this RemoteWebcam.MyConstellation.PackageInstances package)
 {
     return(MessageScope.Create(MessageScope.ScopeType.Package, package.GetRealName()).ToPushBulletScope());
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MyfirstPackageScope"/> class.
 /// </summary>
 /// <param name="scope">The scope.</param>
 public MyfirstPackageScope(MessageScope scope)
 {
     this.currentScope = scope;
 }
Esempio n. 22
0
 private void reset()
 {
     PackageHost.SendMessage(MessageScope.Create("ConstellationPackagePython2"), "reset", null);
 }
Esempio n. 23
0
        //fonction d'authentification
        private Guid Auth(String pass, String login, Double latitude, Double longitude)
        {
            //communication avec le serveur
            PackageHost.WriteInfo("Sending data to server");
            WebRequest request = WebRequest.Create("http://192.168.137.121/phpproj18/test.php");

            request.Method = "POST";
            //envoi données au serveur + identité du package
            string postData = "login="******"&passwd=" + pass + "&latitude=" + latitude + "&longitude=" + longitude + "&sender=123";

            byte[] byteArray = Encoding.UTF8.GetBytes(postData);
            request.ContentType   = "application/x-www-form-urlencoded";
            request.ContentLength = byteArray.Length;
            Stream dataStream = request.GetRequestStream();

            dataStream.Write(byteArray, 0, byteArray.Length);
            dataStream.Close();
            WebResponse response = request.GetResponse();

            Console.WriteLine(((HttpWebResponse)response).StatusDescription);
            dataStream = response.GetResponseStream();
            StreamReader reader = new StreamReader(dataStream);
            //récupération de la réponse serveur
            string responseFromServer = reader.ReadToEnd();

            Console.WriteLine(responseFromServer);

            //cas selon la réponse du serveur
            if (responseFromServer == "youshallpass")
            {
                //accès autorisé, génération d'un token valide
                Guid g;
                g = Guid.NewGuid();
                Console.WriteLine(g);
                if (push == true)
                {
                    PackageHost.SendMessage(MessageScope.Create("PushBullet"), "PushNote", new object[] { "Safe Opening Request", "Access Granted" });
                }
                PackageHost.WriteInfo("Server response : Access Granted");
                reader.Close();
                dataStream.Close();
                response.Close();
                return(g);
            }
            if (responseFromServer == "login")
            {
                //erreur de login, génération d'un token nul
                Guid l = Guid.Empty;;
                Console.WriteLine(l);
                PackageHost.WriteInfo("Server response : Wrong Credentials, access denied");
                if (push == true)
                {
                    PackageHost.SendMessage(MessageScope.Create("PushBullet"), "PushNote", new object[] { "Safe Opening Request", "Wrong Credentials, access denied" });
                }
                reader.Close();
                dataStream.Close();
                response.Close();
                reset();
                return(l);
            }
            if (responseFromServer == "coord")
            {
                //erreur de position, génération d'un token nul
                Guid g = Guid.Empty;;
                Console.WriteLine(g);
                PackageHost.WriteInfo("Server response : Wrong location, access denied");
                if (push)
                {
                    PackageHost.SendMessage(MessageScope.Create("PushBullet"), "PushNote", new object[] { "Safe Opening Request", "Wrong Location, access denied" });
                }
                reader.Close();
                dataStream.Close();
                response.Close();
                reset();
                return(g);
            }
            if (responseFromServer == "lock")
            {
                //système verouillé par l'administrateur, génération d'un token nul
                Guid q = Guid.Empty;;
                Console.WriteLine(q);
                PackageHost.WriteInfo("Server response : System Locked, access denied");
                if (push == true)
                {
                    PackageHost.SendMessage(MessageScope.Create("PushBullet"), "PushNote", new object[] { "Safe Opening Request", "System Locked by admin, access denied" });
                }
                reader.Close();
                dataStream.Close();
                response.Close();
                reset();
                return(q);
            }
            //autre cas
            reader.Close();
            dataStream.Close();
            response.Close();
            Console.WriteLine(responseFromServer);
            Guid w = Guid.NewGuid();

            //Guid w = Guid.Empty;
            Console.WriteLine(w);
            PackageHost.WriteInfo("Server response : granted");
            if (push == true)
            {
                PackageHost.SendMessage(MessageScope.Create("PushBullet"), "PushNote", new object[] { "Safe Opening Request", "Unexpected error" });
            }
            reset();
            return(w);
        }
 /// <summary>
 /// Creates the message scope to the specified package.
 /// </summary>
 /// <param name="package">The package.</param>
 /// <returns>MessageScope</returns>
 public static MessageScope CreateScope(this Packages package)
 {
     return(MessageScope.Create(MessageScope.ScopeType.Package, package.GetRealName()));
 }
Esempio n. 25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageHelper"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="message">The message.</param>
 /// <param name="scope">The scope.</param>
 public MessageHelper(ViewContext context, string message, MessageScope scope)
 {
     this.Context = context;
     this.Message = message;
     this.Scope = scope;
 }
Esempio n. 26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageVerbosityAttribute"/> class.
 /// </summary>
 /// <param name="scoping">The scoping.</param>
 public MessageVerbosityAttribute(MessageScope scoping)
 {
     this.Scope = scoping;
 }
Esempio n. 27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageViewModel"/> class.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="scope">The scope.</param>
 public MessageViewModel(string message, MessageScope scope)
 {
     this.Message = message;
     this.Scope = scope;
 }
Esempio n. 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageHelper"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="scope">The scope.</param>
 /// <param name="messages">The messages.</param>
 public MessageHelper(ViewContext context, MessageScope scope, IList<string> messages)
 {
     this.Context = context;
     this.Scope = scope;
     this.Messages = messages;
 }
Esempio n. 29
0
 /// <summary>
 /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider"
 /// /> and <see cref="ignoreCase" />
 /// </summary>
 /// <param name="sourceValue">the <see cref="System.Object"/> to convert from</param>
 /// <param name="destinationType">the <see cref="System.Type" /> to convert to</param>
 /// <param name="formatProvider">not used by this TypeConverter.</param>
 /// <param name="ignoreCase">when set to <c>true</c>, will ignore the case when converting.</param>
 /// <returns>
 /// an instance of <see cref="MessageScope" />, or <c>null</c> if there is no suitable conversion.
 /// </returns>
 public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => MessageScope.CreateFrom(sourceValue);
Esempio n. 30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageVerbosityAttribute"/> class.
 /// </summary>
 /// <param name="scoping">The scoping.</param>
 public MessageVerbosityAttribute(MessageScope scoping)
 {
     this.Scope = scoping;
 }
 /// <summary>
 /// Create a GoogleTrafficScope
 /// </summary>
 /// <param name="scope">The Constellation MessageScope</param>
 public static GoogleTrafficScope ToGoogleTrafficScope(this MessageScope scope)
 {
     return(new GoogleTrafficScope(scope));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageBroker"/> class.
 /// </summary>
 /// <param name="verbosityScope">The verbosity scope.</param>
 public MessageBroker(MessageScope verbosityScope)
 {
     this.scope = verbosityScope;
 }
 /// <summary>
 /// Create a GoogleTrafficScope to all packages of the specified sentinel
 /// </summary>
 /// <param name="sentinel">The sentinel</param>
 public static GoogleTrafficScope CreateGoogleTrafficScope(this WhenShouldIGo.MyConstellation.Sentinels sentinel)
 {
     return(MessageScope.Create(MessageScope.ScopeType.Sentinel, sentinel.GetRealName()).ToGoogleTrafficScope());
 }
Esempio n. 34
0
 public void PostDispatch(IConsumeContext context)
 {
     MessageScope.EndScope();
 }
 /// <summary>
 /// Create a GoogleTrafficScope to a specific package
 /// </summary>
 /// <param name="package">The package</param>
 public static GoogleTrafficScope CreateGoogleTrafficScope(this WhenShouldIGo.MyConstellation.Packages package)
 {
     return(MessageScope.Create(MessageScope.ScopeType.Package, package.GetRealName()).ToGoogleTrafficScope());
 }