public void SoapEvent(BasicEvent evt)
 {
     soapNeededTimer?.Close();
     soapNeededStopTimer?.Close();
     _soapIcon = false;
     TriggerUpdate();
 }
 private void Awake()
 {
     m_EventDispatcher = FindObjectOfType <EventDispatcher>();
     onScoreChanged    = new BasicEvent <int>();
     onCoinsChanged    = new BasicEvent <int>();
     isGameOver        = true;
 }
        public BasicEvent GetEvent(string eventName)
        {
            BasicEvent basicEvent = null;

            eventDict.TryGetValue(eventName, out basicEvent);
            return(basicEvent);
        }
Esempio n. 4
0
    private void OnLastRoundAnswer(BasicEvent e)
    {
        bool isLastRound = (bool)e.Data;

        // End game, show results
        if (isLastRound)
        {
            timeText.text      = "0";
            markerText.enabled = false;
            isRoundActive      = false;
            overPannelFade.StartFadeIn(0.3f);
            qaPannelFade.StartFadeOut(0.3f);
            roundsPannelFade.StartFadeOut(0.3f);

            // Save last score
            user.LastScore = playerScore;
            UserLocal.SaveUserData(user);

            // Send score to database
            EventManager.TriggerEvent(Constants.ON_SEND_DATA_TO_DATABASE, new BasicEvent(user));

            // Show proper feedback
            if (win)
            {
                winText.enabled  = true;
                loseText.enabled = false;
            }
            else
            {
                winText.enabled  = false;
                loseText.enabled = true;
            }
        }
    }
Esempio n. 5
0
        public async Task Process(BasicEvent @event)
        {
            switch (@event)
            {
            case PutRecordsEvent <T> putRecordsEvent:
                await ProcessPutRecordsEvent(putRecordsEvent);

                break;

            case RemoveRecordsEvent <T> removeRecordsEvent:
                await ProcessRemoveRecordsEvent(removeRecordsEvent);

                break;

            case RemoveRecordsByConditionEvent <T> removeRecordsByConditionEvent:
                await ProcessRemoveRecordsByConditionEvent(removeRecordsByConditionEvent);

                break;

            case CleanRecordsEvent <T> cleanRecordsEvent:
                await ProcessCleanRecordsEvent(cleanRecordsEvent);

                break;
            }
        }
Esempio n. 6
0
        internal static void ProcessExtendedMembership(BasicEvent newEvent)
        {
            // This function handles the case when a membership has been extended for a year.

            BasicPerson  victim       = Person.FromIdentity(newEvent.VictimPersonId);
            BasicPerson  perpetrator  = Person.FromIdentity(newEvent.PerpetratorPersonId);
            Organization organization = Organization.FromIdentity(newEvent.OrganizationId);
            Geography    node         = Geography.FromIdentity(newEvent.GeographyId);

            int[] concernedPeopleId = PirateWeb.Logic.Collections.Roles.GetAllUpwardRoleHolders(newEvent.OrganizationId, newEvent.GeographyId);

            // TODO HERE: Filter to only get the interested people in this event

            string body =
                "A membership was extended within your area of authority.\r\n\r\n" +
                "Person:       " + victim.Name + "\r\n" +
                "Organization: " + organization.Name + "\r\n" +
                "Geography:    " + node.Name + "\r\n\r\n" +
                "Event source: " + newEvent.EventSource.ToString() + "\r\n";

            People concernedPeople = PirateWeb.Logic.Collections.People.FromIdentities(concernedPeopleId);

            new PirateWeb.Utility.Mail.MailTransmitter("PirateWeb", "*****@*****.**",
                                                       "Extended Membership: [" + victim.Name + "] - [" + organization.NameShort + "], [" + node.Name + "]",
                                                       body, concernedPeople, true).Send();
        }
Esempio n. 7
0
    public void RaiseTest()
    {
        var c1 = new BasicComponent();

        c1.AddHandler <BasicEvent>(_ => { });
        var c2 = new BasicComponent();

        c2.AddHandler <BasicEvent>(_ => { });
        var e  = new BasicEvent();
        var ee = new EventExchange(new BasicLogExchange());

        ee.Attach(c1);
        ee.Attach(c2);

        Assert.Equal(0, c1.Handled);
        Assert.Equal(0, c2.Handled);

        c1.Raise(e);

        Assert.Equal(0, c1.Handled); // Components shouldn't see their own events.
        Assert.Equal(1, c2.Handled);

        var recipients = ee.EnumerateRecipients(typeof(BasicEvent)).ToList();

        Assert.Collection(recipients,
                          x => Assert.Equal(x, c1),
                          x => Assert.Equal(x, c2));
    }
Esempio n. 8
0
    public void DisableHandlerTest()
    {
        var c = new BasicComponent();
        var e = new BasicEvent();
        var x = new EventExchange(new BasicLogExchange());

        c.AddHandler <BasicEvent>(_ => { });

        c.Attach(x);
        Assert.Equal(0, c.Handled);

        c.Receive(e, this);
        Assert.Equal(1, c.Handled);

        c.AddHandler <BasicEvent>(_ => { });
        c.Receive(e, this);
        Assert.Equal(2, c.Handled);

        c.RemoveHandler <BasicEvent>();
        c.Receive(e, this);
        Assert.Equal(2, c.Handled);

        c.AddHandler <BasicEvent>(_ => { });
        c.Receive(e, this);
        Assert.Equal(3, c.Handled);

        c.AddHandler <BasicEvent>(_ => throw new InvalidOperationException()); // Registering a handler for an event that's already handled should be a no-op
        c.Receive(e, this);
        Assert.Equal(4, c.Handled);
    }
Esempio n. 9
0
    public void BasicComponentTest()
    {
        var c = new BasicComponent();

        c.AddHandler <BasicEvent>(_ => { });
        var e = new BasicEvent();
        var x = new EventExchange(new BasicLogExchange());

        Assert.Equal(0, c.Handled);
        Assert.True(c.IsActive);

        c.Receive(e, this);
        Assert.Equal(0, c.Handled); // Handlers don't fire if component isn't attached

        c.Attach(x);
        c.Receive(e, this);
        Assert.Equal(1, c.Handled);

        c.Attach(x);
        c.Attach(x);
        c.Attach(x);
        c.Attach(x);
        c.Receive(e, this);
        Assert.Equal(2, c.Handled);

        c.Remove();
        c.Receive(e, this);
        Assert.Equal(2, c.Handled);

        c.Remove();
        c.Remove();
        c.Receive(e, this);
        Assert.Equal(2, c.Handled);
    }
Esempio n. 10
0
        internal static void ProcessReceivedPayment(BasicEvent newEvent)
        {
            // Set membership expiry to one year from today's expiry

            // First, find this particular membership

            Membership renewedMembership = null;
            bool       foundExisting     = false;

            try
            {
                renewedMembership = Membership.FromBasic(Memberships.GetMembership(newEvent.VictimPersonId, newEvent.OrganizationId));
                foundExisting     = true;
            }
            catch (ArgumentException) { }              // an exception here means there was no active membership

            if (foundExisting)
            {
                Person   person  = renewedMembership.Person;
                DateTime expires = renewedMembership.Expires;

                ChurnData.LogRetention(person.Identity, renewedMembership.OrganizationId, expires);
                Events.CreateEvent(EventSource.CustomServiceInterface, EventType.ExtendedMembership, person.Identity, renewedMembership.OrganizationId, person.GeographyId, person.Identity, 0, string.Empty);

                expires = expires.AddYears(1);


                // If the membership is in organization 1, then propagate the expiry to every other org this person is a member of

                // Cheat and assume Swedish. In the future, take this from a template.

                string mailBody =
                    "Tack för att du har valt att förnya ditt medlemskap och fortsätta vara en del av piratrörelsen i " +
                    "Sverige! Ditt medlemskap går nu ut " + expires.ToString("yyyy-MM-dd") + ", och gäller följande föreningar:\r\n\r\n";

                Memberships memberships = person.GetMemberships();

                foreach (Membership membership in memberships)
                {
                    if (membership.Organization.Inherits(1) || membership.OrganizationId == 1)
                    {
                        membership.Expires = expires;
                        mailBody          += membership.Organization.Name + "\r\n";
                    }
                }

                mailBody += "\r\nOm du har några frågor, så kontakta gärna Medlemsservice på [email protected]. Återigen, " +
                            "välkommen att vara med i vårt fortsatta arbete!\r\n";

                new PirateWeb.Utility.Mail.MailTransmitter("Piratpartiet Medlemsservice", "*****@*****.**", "Piratpartiet: Ditt medlemskap är förnyat",
                                                           mailBody, person).Send();
            }
            else
            {
                // This person's membership has expired, so he/she needs a new one.

                // TODO
            }
        }
        private void loadDefault()
        {
            defaultResource = new ResourceHandle("default", this);
            IEvent evt = new BasicEvent();

            defaultResource.Load(evt);
            evt.Wait();
        }
Esempio n. 12
0
    private void OnIsLastRound(BasicEvent e)
    {
        // Check if its last round, skip to next round internally
        NextRoundData();

        // Answer with isLastRound check to Game Controller
        EventManager.TriggerEvent(Constants.LAST_ROUND_ANSWER, new BasicEvent(lastRound));
    }
Esempio n. 13
0
    /// <summary>
    /// On player score changed. Updates screen text
    /// </summary>
    /// <param name="e">Event information. Enemy score</param>
    void OnRaiseScore(BasicEvent e)
    {
        var intScore = (int)e.Data;

        totalScore += intScore;

        score.text = totalScore.ToString();
    }
Esempio n. 14
0
        /// <summary>
        /// 기본 이벤트 처리함수
        /// </summary>
        /// <param name="Key">키</param>
        public void BasicEventHandle(BasicEvent basicEvent)
        {
            var basicEv = _basicEventTable.GetBasicEvent(basicEvent.ToString());

            if (basicEv != null)
            {
                basicEv.onEvents.Invoke();
            }
        }
        public void TriggerEvent(string eventName, GameObject src, EventArgs args)
        {
            BasicEvent basicEvent = GetEvent(eventName);

            Debug.Log("in manager, triggering event");
            if (basicEvent != null)
            {
                Debug.Log("in manager, got event, triggered");
                basicEvent.Invoke(src, args);
            }
        }
Esempio n. 16
0
        public void TestBasicPropagation()
        {
            var @event = new BasicEvent {
                Original = 1
            };
            var binder = new BasicStaticEventBinder();
            var engine = new DefaultEventEngine <IGameContext>(new StandardKernel(), new[] { binder });

            engine.Fire(null, @event);
            Assert.Equal(1, @event.HitValue);
        }
        public BasicEvent AddEvent(string eventName)
        {
            BasicEvent newEvent = GetEvent(eventName);

            if (newEvent == null)
            {
                newEvent = new BasicEvent();
                eventDict.Add(eventName, newEvent);
            }
            return(newEvent);
        }
Esempio n. 18
0
    private void OnCurrentDataReceived(BasicEvent e)
    {
        currentRoundData = (RoundData)e.Data;
        questionPool     = currentRoundData.Questions;

        timeRemaining = questionPool [0].TimeLimit;

        // After 2 secs show questions, start the game!
        Invoke("StartRound", 2f);
        // Show first question
        Invoke("ShowQuestion", 2f);
    }
Esempio n. 19
0
    void Damaged(BasicEvent e)
    {
        Debug.Log("Setting damage of " + e.Data + " points");

        lives -= (int)e.Data;

        // Ouch...
        if (lives <= 0)
        {
            Bacon();
        }
    }
Esempio n. 20
0
        public static void AddTween(ColorTweener tweener, ColorTweenPositionUpdate updateCallback, BasicEvent endCallback = null)
        {
            _colorTweens.Add(tweener);

            tweener.PositionChanged += new PositionChangedHandler<Color>((value) => updateCallback(value));
            tweener.Ended += () =>
            {
                if (endCallback != null) endCallback();

                _colorTweens.Remove(tweener);
            };
        }
Esempio n. 21
0
        internal static void ProcessAddedMember(BasicEvent newEvent)
        {
            // This function handles the case when a new member has been added. Several things are hardcoded
            // for UP at this point.

            Person       victim       = Person.FromIdentity(newEvent.VictimPersonId);
            Person       perpetrator  = Person.FromIdentity(newEvent.PerpetratorPersonId);
            Organization organization = Organization.FromIdentity(newEvent.OrganizationId);
            Geography    geography    = Geography.FromIdentity(newEvent.GeographyId);

            int[] concernedPeopleId = PirateWeb.Logic.Collections.Roles.GetAllUpwardRoleHolders(newEvent.OrganizationId, newEvent.GeographyId);

            // TODO HERE: Filter to only get the interested people in this event

            string body =
                "A new member has appeared within your area of authority.\r\n\r\n" +
                "Person:       " + victim.Name + "\r\n" +
                "Organization: " + organization.Name + "\r\n" +
                "Geography:    " + geography.Name + "\r\n\r\n" +
                "Event source: " + newEvent.EventSource.ToString() + "\r\n\r\n";

            if (newEvent.EventSource == EventSource.PirateWeb)
            {
                body += "This member was added manually by " + perpetrator.Name + ".\r\n\r\n";
            }

            // Send welcoming mails

            string mailsSent = MailResolver.CreateWelcomeMail(victim, organization);

            body += "Welcoming automails sent:\r\n" + mailsSent +
                    "\r\nTo add an automatic welcome mail for your organization and geography, " +
                    "go to PirateWeb, Communications, Triggered Automails, Automail type \"Welcome\".\r\n\r\n";

            // Add some hardcoded things for UP

            if (organization.Inherits(2))
            {
                int membersTotal = Organization.FromIdentity(2).GetTree().GetMemberCount();
                int membersHere  = organization.GetMemberCount();

                body += "Member count for Ung Pirat SE: " + membersTotal.ToString("#,##0") + "\r\n" +
                        "Member count for " + organization.Name + ": " + membersHere.ToString("#,##0") + "\r\n";
            }


            People concernedPeople = PirateWeb.Logic.Collections.People.FromIdentities(concernedPeopleId);

            new PirateWeb.Utility.Mail.MailTransmitter("PirateWeb", "*****@*****.**",
                                                       "New Member: [" + victim.Name + "] - [" + organization.NameShort + "], [" + geography.Name + "]",
                                                       body, concernedPeople, true).Send();
        }
 public void Write(TProtocol oprot)
 {
     oprot.IncrementRecursionDepth();
     try
     {
         TStruct struc = new TStruct("TDDIInternalFailureUnion");
         oprot.WriteStructBegin(struc);
         TField field = new TField();
         if (InternalFailure != null && __isset.InternalFailure)
         {
             field.Name = "InternalFailure";
             field.Type = TType.Struct;
             field.ID   = 1;
             oprot.WriteFieldBegin(field);
             InternalFailure.Write(oprot);
             oprot.WriteFieldEnd();
         }
         if (BasicEvent != null && __isset.BasicEvent)
         {
             field.Name = "BasicEvent";
             field.Type = TType.Struct;
             field.ID   = 2;
             oprot.WriteFieldBegin(field);
             BasicEvent.Write(oprot);
             oprot.WriteFieldEnd();
         }
         if (FMEAFailure != null && __isset.FMEAFailure)
         {
             field.Name = "FMEAFailure";
             field.Type = TType.Struct;
             field.ID   = 3;
             oprot.WriteFieldBegin(field);
             FMEAFailure.Write(oprot);
             oprot.WriteFieldEnd();
         }
         if (FailState != null && __isset.FailState)
         {
             field.Name = "FailState";
             field.Type = TType.Struct;
             field.ID   = 4;
             oprot.WriteFieldBegin(field);
             FailState.Write(oprot);
             oprot.WriteFieldEnd();
         }
         oprot.WriteFieldStop();
         oprot.WriteStructEnd();
     }
     finally
     {
         oprot.DecrementRecursionDepth();
     }
 }
        private async Task <BasicEvent> AddOrUpdateBasicEvent(BasicIntegrationEvent @event)
        {
            var basicEvent = new BasicEvent
            {
                EventId      = @event.Id,
                Message      = @event.Message,
                CreationDate = @event.CreationDate
            };

            await this.repository.Insert(basicEvent);

            return(basicEvent);
        }
Esempio n. 24
0
    /// <summary>
    /// On player score changed. Updates screen text
    /// </summary>
    /// <param name="e">Event information. Player score</param>
    void OnRaiseScore(BasicEvent e)
    {
        var intScore = (int)e.Data;

        currentScore += intScore;

        if (currentScore >= scoreToWin)
        {
            Persistence.SetMaxValue("Score", currentScore);
            EventManager.TriggerEvent(Common.ON_WIN_GAME);
            execute = false;
        }
    }
Esempio n. 25
0
        private void loadDefault()
        {
            defaultResource = new ResourceHandle("default", this);
            IEvent evt = new BasicEvent();

            defaultResource.Load(evt);
            EventState state = evt.Wait();

            if (state == EventState.Failed)
            {
                throw new NotSupportedException("Default Resource was not loaded properly");
            }
        }
Esempio n. 26
0
        public Wait(float delay, BasicEvent callBack)
        {
            EventTimer eventTimer = new EventTimer(delay);

            eventTimer.AddEvent(100, () =>
            {
                callBack();

                SceneManager.CurrentScene.RemoveNode(eventTimer);
            });

            SceneManager.CurrentScene.AddNode(eventTimer);
        }
Esempio n. 27
0
        public void Dispose()
        {
            if (Default != null)
            {
                IEvent evt = new BasicEvent();

                queue.Add(() =>
                {
                    defaultResource.Unload(evt);
                    defaultResource = null;
                });
                evt.Wait();
            }
        }
Esempio n. 28
0
    /// <summary>
    /// On player lives changed. Updates screen text
    /// </summary>
    /// <param name="e">Event information. Player lives updated</param>
    void OnLivesChanged(BasicEvent e)
    {
        var intLives = (int)e.Data;

        healthBar.fillAmount = (float)intLives / (float)initialLives;

        if (!blinking && healthBar.fillAmount <= lowHealth)
        {
            blinking = true;
            healthBar.GetComponent <Animator>().SetTrigger("Blink");
        }

        lives.text = intLives.ToString();
    }
Esempio n. 29
0
        public void TestFilteredPropagationOutOfOrder()
        {
            var event1 = new BasicEvent {
                Original = 1
            };
            var event2 = new BasicEvent {
                Original = 2
            };
            var binder = new FilteredStaticEventBinder();
            var engine = new DefaultEventEngine <IGameContext>(new StandardKernel(), new[] { binder });

            engine.Fire(null, event2);
            Assert.NotEqual(2, event2.HitValue);
            engine.Fire(null, event1);
            Assert.Equal(1, event1.HitValue);
        }
        public void BindEvent(string eventName, UnityAction <GameObject, EventArgs> listener)
        {
            Debug.Log("In manager, binding event");

            BasicEvent tmpEvent = GetEvent(eventName);

            if (tmpEvent != null)
            {
                tmpEvent.AddListener(listener);
            }
            else
            {
                tmpEvent = AddEvent(eventName);
                tmpEvent.AddListener(listener);
            }
        }
Esempio n. 31
0
        static void Main(string[] args)
        {
            //EEPROMEXAMPLE
            Network network = new Network();

            network.AddNode();
            network.Nodes[0].NodeShield.AddTimeEvent(new TimeEvent(new Event(), 11, 11, 05));
            network.Nodes[0].NodeShield.AddTimeEvent(new TimeEvent(new Event(0xFF, new Byte[4] {
                0x55, 0x55, 0x55, 0x55
            }), 11, 11, 30));
            network.Nodes[0].NodeShield.AddTimeEvent(new TimeEvent(new Event(0xFF, new Byte[4] {
                0x11, 0x22, 0x33, 0x44
            }), 11, 11, 15));
            var add = network.Nodes[0].NodeAddress;

            BasicEvent be = new BasicEvent(new Event());

            be.TimeRestrictions.Add(new TimeRestriction(11, 00, 00, 12, 00, 00));
            be.TimeRestrictions.Add(new TimeRestriction(13, 00, 00, 14, 00, 00));

            network.Nodes[0].NodeShield.Connectors[2].Directions[0].PinEvents.Add(be);
            network.Nodes[0].NodeShield.Connectors[2].Directions[0].PinEvents.Add(new BasicEvent(new Event()));
            Generator generatorEEPROM = new Generator(network, add);

            byte[] EEPROM = generatorEEPROM.GenerateEEPROM();
            //guardamos el bin
            File.WriteAllBytes("ex.bin", EEPROM);
            //guardamos el hex
            Binary.SaveBin2Hex(EEPROM);
            Console.WriteLine("DONE");
            Console.ReadLine();



            ////MODULE EXAMPLE
            //PluginLoader ml = new PluginLoader();
            ////Llamo al método "method" de cada módulo
            //foreach (IPlugin m in ml.Modules)
            //{
            //    m.method();
            //}
            ////END MODULE
            //Console.WriteLine("End");
            //Console.ReadLine();
        }
Esempio n. 32
0
    void OnRemoteDataReceived(BasicEvent e)
    {
        string jsonData = (string)e.Data;

        JsonParser          parser          = new JsonParser(jsonData);
        List <QuestionData> questionsParsed = parser.Parse();

        // 6 questions per round * 3 difficulty levels = 18 questions stored per round
        int numberQuestions = Constants.QUESTIONS_PER_ROUND * EnumUtil.GetCount <Constants.Levels> ();

        // For all rounds
        for (int i = 0; i < Constants.NUM_ROUNDS; i++)
        {
            // Create a set of questions based on parsed data
            allRoundData [i]          = new RoundData();
            allRoundData[i].Questions = new QuestionData [numberQuestions];

            // For all the questions on round
            // Index on parsed data list, first row starts on 0 second row starts on 6 ...
            int index = i * Constants.QUESTIONS_PER_ROUND;
            for (int j = 0; j < numberQuestions; j++)
            {
                // Create a question
                allRoundData [i].Questions [j] = new QuestionData();

                // Get question from parsed data
                allRoundData [i].Questions [j] = questionsParsed [index];

                // Get next index, on chunks of 6 questions
                if ((j > 0) && ((j + 1) % Constants.QUESTIONS_PER_ROUND) == 0)
                {
                    index += (Constants.QUESTIONS_PER_ROUND + 1);
                }
                else
                {
                    index++;
                }
            }
        }

        // Send current round to Game Controller
        EventManager.TriggerEvent(Constants.ON_CURRENT_DATA_RECEIVED, new BasicEvent(GetCurrentRoundData()));
    }
Esempio n. 33
0
		internal static void ProcessAddedRole (BasicEvent newEvent)
		{
			// This function handles the case when a new role has been added to a point in the organization.

			Person victim = null;
			Person perpetrator = null;
			Organization organization = null;
			Geography geography = null;
			RoleType roleType = RoleType.Unknown;

			try
			{
				victim = Person.FromIdentity(newEvent.VictimPersonId);
				perpetrator = Person.FromIdentity(newEvent.PerpetratorPersonId);
				organization = Organization.FromIdentity(newEvent.OrganizationId);
				geography = Geography.FromIdentity(newEvent.GeographyId);
				roleType = (RoleType) newEvent.ParameterInt;
			}
			catch (Exception)
			{
				// if any of these fail, one of the necessary components (for example, the role) was already deleted.

				return;
			}

			int[] concernedPeopleId = PirateWeb.Logic.Collections.Roles.GetAllUpwardRoleHolders(newEvent.OrganizationId, newEvent.GeographyId);

			// TODO HERE: Filter to only get the interested people in this event

			People concernedPeople = PirateWeb.Logic.Collections.People.FromIdentities(concernedPeopleId);

			new PirateWeb.Utility.Mail.MailTransmitter("PirateWeb", "*****@*****.**",
				"New Role: [" + victim.Name + "] - [" + organization.NameShort + "], [" + geography.Name + "], [" + roleType.ToString() + "]",
				"A new role was assigned on PirateWeb within your area of authority.\r\n\r\n" +
				"Person:       " + victim.Name + "\r\n" + 
				"Organization: " + organization.Name + "\r\n" + 
				"Geography:    " + geography.Name + "\r\n" +
				"Role Name:    " + roleType.ToString() + "\r\n\r\n" +
				"This role was assigned by " + perpetrator.Name + ".\r\n", concernedPeople, true).
				Send();
		}
Esempio n. 34
0
        static void Main(string[] args)
        {
            //EEPROMEXAMPLE
            Network network = new Network();
            network.AddNode();
            network.Nodes[0].NodeShield.AddTimeEvent(new TimeEvent(new Event(), 11, 11, 05));
            network.Nodes[0].NodeShield.AddTimeEvent(new TimeEvent(new Event(0xFF, new Byte[4] { 0x55, 0x55, 0x55, 0x55 }), 11, 11, 30));
            network.Nodes[0].NodeShield.AddTimeEvent(new TimeEvent(new Event(0xFF, new Byte[4] { 0x11, 0x22, 0x33, 0x44 }), 11, 11, 15));
            var add = network.Nodes[0].NodeAddress;

            BasicEvent be = new BasicEvent(new Event());
            be.TimeRestrictions.Add(new TimeRestriction(11, 00, 00, 12, 00, 00));
            be.TimeRestrictions.Add(new TimeRestriction(13, 00, 00, 14, 00, 00));

            network.Nodes[0].NodeShield.Connectors[2].Directions[0].PinEvents.Add(be);
            network.Nodes[0].NodeShield.Connectors[2].Directions[0].PinEvents.Add(new BasicEvent(new Event()));
            Generator generatorEEPROM = new Generator(network, add);
            byte[] EEPROM = generatorEEPROM.GenerateEEPROM();
            //guardamos el bin
            File.WriteAllBytes("ex.bin", EEPROM);
            //guardamos el hex
            Binary.SaveBin2Hex(EEPROM);
            Console.WriteLine("DONE");
            Console.ReadLine();

            ////MODULE EXAMPLE
            //PluginLoader ml = new PluginLoader();
            ////Llamo al método "method" de cada módulo
            //foreach (IPlugin m in ml.Modules)
            //{
            //    m.method();
            //}
            ////END MODULE
            //Console.WriteLine("End");
            //Console.ReadLine();
        }
Esempio n. 35
0
 public CustomTask(BasicEvent basicEvent)
 {
     _customAction = basicEvent;
 }
Esempio n. 36
0
		internal static void ProcessExpenseCreated (BasicEvent newEvent)
		{
			Person expenser = Person.FromIdentity(newEvent.VictimPersonId);
			Organization organization = Organization.FromIdentity(newEvent.OrganizationId);
			Geography geography = Geography.FromIdentity(newEvent.GeographyId);
			Expense expense = Expense.FromIdentity(newEvent.ParameterInt);

			int[] concernedPeopleId = PirateWeb.Logic.Collections.Roles.GetAllUpwardRoleHolders(newEvent.OrganizationId, newEvent.GeographyId);

			// TODO HERE: Filter to only get the interested people in this event

			string body =
				"An expense was filed for reimbursement within your area of authority.\r\n\r\n" +
				"Claimer:      " + expenser.Name + "\r\n" +
				"Organization: " + organization.Name + "\r\n" +
				"Geography:    " + geography.Name + "\r\n\r\n" +
				"Expense Date: " + expense.ExpenseDate.ToLongDateString() + "\r\n" +
				"Description:  " + expense.Description + "\r\n" +
				"Amount:       " + expense.Amount.ToString ("#,##0.00") + "\r\n\r\n" +
				"Event source: " + newEvent.EventSource.ToString() + "\r\n\r\n";

			Expenses orgExpenses = Expenses.FromOrganization(organization);

			decimal total = 0.0m;
			foreach (Expense localExpense in orgExpenses)
			{
				if (localExpense.Open)
				{
					total += localExpense.Amount;
				}
			}

			body += "The total outstanding expense claims for this organization currently amount to " + total.ToString("#,##0.00") + ".\r\n\r\n";

			People concernedPeople = PirateWeb.Logic.Collections.People.FromIdentities(concernedPeopleId);

			new PirateWeb.Utility.Mail.MailTransmitter("PirateWeb", "*****@*****.**",
				"New Expense Claim: [" + expenser.Name + "], [" + organization.NameShort + "], [" + expense.Amount.ToString ("#,##0.00") + "]",
				body, concernedPeople, true).Send();

		}
Esempio n. 37
0
		internal static void ProcessExtendedMembership(BasicEvent newEvent)
		{
			// This function handles the case when a membership has been extended for a year.

			BasicPerson victim = Person.FromIdentity(newEvent.VictimPersonId);
			BasicPerson perpetrator = Person.FromIdentity(newEvent.PerpetratorPersonId);
			Organization organization = Organization.FromIdentity(newEvent.OrganizationId);
			Geography node = Geography.FromIdentity(newEvent.GeographyId);

			int[] concernedPeopleId = PirateWeb.Logic.Collections.Roles.GetAllUpwardRoleHolders(newEvent.OrganizationId, newEvent.GeographyId);

			// TODO HERE: Filter to only get the interested people in this event

			string body =
				"A membership was extended within your area of authority.\r\n\r\n" +
				"Person:       " + victim.Name + "\r\n" +
				"Organization: " + organization.Name + "\r\n" +
				"Geography:    " + node.Name + "\r\n\r\n" +
				"Event source: " + newEvent.EventSource.ToString() + "\r\n";

			People concernedPeople = PirateWeb.Logic.Collections.People.FromIdentities(concernedPeopleId);

			new PirateWeb.Utility.Mail.MailTransmitter("PirateWeb", "*****@*****.**",
				"Extended Membership: [" + victim.Name + "] - [" + organization.NameShort + "], [" + node.Name + "]",
				body, concernedPeople, true).Send();
		}
Esempio n. 38
0
		internal static void ProcessAddedMember (BasicEvent newEvent)
		{
			// This function handles the case when a new member has been added. Several things are hardcoded
			// for UP at this point.

			Person victim = Person.FromIdentity(newEvent.VictimPersonId);
			Person perpetrator = Person.FromIdentity(newEvent.PerpetratorPersonId);
			Organization organization = Organization.FromIdentity(newEvent.OrganizationId);
			Geography geography = Geography.FromIdentity(newEvent.GeographyId);

			int[] concernedPeopleId = PirateWeb.Logic.Collections.Roles.GetAllUpwardRoleHolders(newEvent.OrganizationId, newEvent.GeographyId);

			// TODO HERE: Filter to only get the interested people in this event

			string body =
				"A new member has appeared within your area of authority.\r\n\r\n" +
				"Person:       " + victim.Name + "\r\n" +
				"Organization: " + organization.Name + "\r\n" +
				"Geography:    " + geography.Name + "\r\n\r\n" +
				"Event source: " + newEvent.EventSource.ToString() + "\r\n\r\n";

			if (newEvent.EventSource == EventSource.PirateWeb)
			{
				body += "This member was added manually by " + perpetrator.Name + ".\r\n\r\n";
			}

			// Send welcoming mails

			string mailsSent = MailResolver.CreateWelcomeMail (victim, organization);

			body += "Welcoming automails sent:\r\n" + mailsSent + 
				"\r\nTo add an automatic welcome mail for your organization and geography, " +
				"go to PirateWeb, Communications, Triggered Automails, Automail type \"Welcome\".\r\n\r\n";

			// Add some hardcoded things for UP

			if (organization.Inherits (2))
			{
				int membersTotal = Organization.FromIdentity (2).GetTree().GetMemberCount();
				int membersHere = organization.GetMemberCount();

				body += "Member count for Ung Pirat SE: " + membersTotal.ToString("#,##0") + "\r\n" +
					"Member count for " + organization.Name + ": " + membersHere.ToString("#,##0") + "\r\n";
			}


			People concernedPeople = PirateWeb.Logic.Collections.People.FromIdentities(concernedPeopleId);

			new PirateWeb.Utility.Mail.MailTransmitter("PirateWeb", "*****@*****.**",
				"New Member: [" + victim.Name + "] - [" + organization.NameShort + "], [" + geography.Name + "]",
				body, concernedPeople, true).Send();

		}
Esempio n. 39
0
		internal static void ProcessTerminatedMembership(BasicEvent newEvent)
		{
			// This function handles the case when a membership has been terminated. Several things are hardcoded
			// for UP at this point.

			Person victim = Person.FromIdentity(newEvent.VictimPersonId);
			Person perpetrator = Person.FromIdentity(newEvent.PerpetratorPersonId);
			Organization organization = Organization.FromIdentity (newEvent.OrganizationId);
			Geography node = Geography.FromIdentity(newEvent.GeographyId);

			int[] concernedPeopleId = PirateWeb.Logic.Collections.Roles.GetAllUpwardRoleHolders(newEvent.OrganizationId, newEvent.GeographyId);

			// TODO HERE: Filter to only get the interested people in this event

			string body =
				"A membership was lost within your area of authority.\r\n\r\n" +
				"Person:       " + victim.Name + "\r\n" +
				"Organization: " + organization.Name + "\r\n" +
				"Geography:    " + node.Name + "\r\n\r\n" +
				"Event source: " + newEvent.EventSource.ToString() + "\r\n";

			// Add some hardcoded things for UP

			if (organization.Inherits(2))
			{
				int membersTotal = Organization.FromIdentity(2).GetTree().GetMemberCount();
				int membersHere = organization.GetMemberCount();

				body += "Member count for Ung Pirat SE: " + membersTotal.ToString("#,##0") + "\r\n" +
					"Member count for " + organization.Name + ": " + membersHere.ToString("#,##0") + "\r\n";
			}


			People concernedPeople = PirateWeb.Logic.Collections.People.FromIdentities(concernedPeopleId);

			new PirateWeb.Utility.Mail.MailTransmitter("PirateWeb", "*****@*****.**",
				"Lost Membership: [" + victim.Name + "] - [" + organization.NameShort + "], [" + node.Name + "]",
				body, concernedPeople, true).Send();
		}
Esempio n. 40
0
        public static void LoadScreenTheaded(string key, BasicEvent onComplete)
        {
            Scene sceneToLoad = Scenes[key];

            if (!sceneToLoad.LoadManager.IsLoaded)
            {
                BackgroundWorker backgroundLoad = new BackgroundWorker();

                backgroundLoad.DoWork += (sender, args) =>
                {
                    if (SceneManager.OnSceneLoadStart != null) SceneManager.OnSceneLoadStart(sceneToLoad);

                    sceneToLoad.Setup();
                    sceneToLoad.LoadScene();
                };

                backgroundLoad.RunWorkerCompleted += (sender, args) =>
                {
                    if (SceneManager.OnSceneLoadEnd != null) SceneManager.OnSceneLoadEnd(sceneToLoad);

                    onComplete();
                };

                backgroundLoad.RunWorkerAsync();
            }
            else
            {
                onComplete();
            }
        }
Esempio n. 41
0
		internal static void ProcessReceivedPayment(BasicEvent newEvent)
		{
			// Set membership expiry to one year from today's expiry

			// First, find this particular membership
			
			Membership renewedMembership = null;
			bool foundExisting = false;
			try
			{
				renewedMembership = Membership.FromBasic(Memberships.GetMembership(newEvent.VictimPersonId, newEvent.OrganizationId));
				foundExisting = true;
			}
			catch (ArgumentException) { }  // an exception here means there was no active membership

			if (foundExisting)
			{
				Person person = renewedMembership.Person;
				DateTime expires = renewedMembership.Expires;

				ChurnData.LogRetention(person.Identity, renewedMembership.OrganizationId, expires);
				Events.CreateEvent(EventSource.CustomServiceInterface, EventType.ExtendedMembership, person.Identity, renewedMembership.OrganizationId, person.GeographyId, person.Identity, 0, string.Empty);

				expires = expires.AddYears(1);


				// If the membership is in organization 1, then propagate the expiry to every other org this person is a member of

				// Cheat and assume Swedish. In the future, take this from a template.

				string mailBody =
					"Tack för att du har valt att förnya ditt medlemskap och fortsätta vara en del av piratrörelsen i " +
					"Sverige! Ditt medlemskap går nu ut " + expires.ToString("yyyy-MM-dd") + ", och gäller följande föreningar:\r\n\r\n";

				Memberships memberships = person.GetMemberships();

				foreach (Membership membership in memberships)
				{
					if (membership.Organization.Inherits(1) || membership.OrganizationId == 1)
					{
						membership.Expires = expires;
						mailBody += membership.Organization.Name + "\r\n";
					}
				}

				mailBody += "\r\nOm du har några frågor, så kontakta gärna Medlemsservice på [email protected]. Återigen, " +
					"välkommen att vara med i vårt fortsatta arbete!\r\n";

				new PirateWeb.Utility.Mail.MailTransmitter("Piratpartiet Medlemsservice", "*****@*****.**", "Piratpartiet: Ditt medlemskap är förnyat",
					mailBody, person).Send();
			}
			else
			{
				// This person's membership has expired, so he/she needs a new one.

				// TODO

			}
		}
Esempio n. 42
0
		internal static void ProcessExpenseChanged(BasicEvent newEvent)
		{
			Person expenser = Person.FromIdentity(newEvent.VictimPersonId);
			Organization organization = Organization.FromIdentity(newEvent.OrganizationId);
			Geography geography = Geography.FromIdentity(newEvent.GeographyId);
			Expense expense = Expense.FromIdentity(newEvent.ParameterInt);
			ExpenseEventType eventType = (ExpenseEventType) Enum.Parse(typeof(ExpenseEventType), newEvent.ParameterText);

			// HACK: This assumes eventType is ExpenseEventType.Approved.

			string body =
				"Receipts for an expense has been received by the treasurer and will be repaid shortly, typically in 5-10 days.\r\n\r\n" +
				"Expense #:     " + expense.Identity.ToString() + "\r\n" +
				"Expense Date:  " + expense.ExpenseDate.ToLongDateString() + "\r\n" +
				"Description:   " + expense.Description + "\r\n" +
				"Amount:        " + expense.Amount.ToString("#,##0.00") + "\r\n\r\n";

			new PirateWeb.Utility.Mail.MailTransmitter("PirateWeb", "*****@*****.**",
				"Expense Approved: " + expense.Description + ", " + expense.Amount.ToString("#,##0.00"),
				body, expense.Claimer, true).Send();

		}
Esempio n. 43
0
		public static void ProcessExpensesRepaidClosed (BasicEvent newEvent)
		{
			Person expenser = Person.FromIdentity(newEvent.VictimPersonId);
			Person payer = Person.FromIdentity(newEvent.PerpetratorPersonId);

			// The ParameterText field is like a,b,c,d where a..d are expense IDs

			string[] idStrings = newEvent.ParameterText.Split(',');

			Expenses expenses = new Expenses();
			decimal totalAmount = 0.0m;

			foreach (string idString in idStrings)
			{
				Expense newExpense = Expense.FromIdentity(Int32.Parse(idString));
				totalAmount += newExpense.Amount;
				expenses.Add (newExpense);
			}

			string body = "The following expenses, totaling " + totalAmount.ToString ("#,##0.00") + ", have been repaid to your registered account, " + expenser.BankName + " " + expenser.BankAccount + ".\r\n\r\n";

			body += FormatExpenseLine ("#", "Description", "Amount");
			body += FormatExpenseLine ("===", "========================================", "=========");

			foreach (Expense expense in expenses)
			{
				body += FormatExpenseLine (expense.Identity.ToString(), expense.Description, expense.Amount.ToString ("#,##0.00"));
			}

			body += FormatExpenseLine ("---", "----------------------------------------", "---------");

			body += FormatExpenseLine (string.Empty, "TOTAL", totalAmount.ToString ("#,##0.00"));

			body += "\r\nIf you see any problems with this, please contact the treasurer, " + payer.Name + ", at " + payer.PPMailAddress + ". Thank you for helping the pirate movement succeed.\r\n";

			new PirateWeb.Utility.Mail.MailTransmitter("PirateWeb", "*****@*****.**",
				"Expenses Repaid: " + totalAmount.ToString("#,##0.00"), body, expenser, true).Send();
		}
Esempio n. 44
0
        public void AddEvent(int timePercent, BasicEvent basicEvent)
        {
            if (!_timeLineEvents.ContainsKey(timePercent)) _timeLineEvents.Add(timePercent, new List<BasicEvent>());

            _timeLineEvents[timePercent].Add(basicEvent);
        }
Esempio n. 45
0
 public void AddTask(BasicEvent customAction)
 {
     AddTask(new CustomTask(customAction));
 }