Exemple #1
0
            private void Initialize(Event e)
            {
                var ce = e as ConfigEvent;

                this.Config = ce;
                bool expectError = false;

                try
                {
                    switch (ce.Test)
                    {
                    case TestType.CustomTimer:
                        this.StartTimer(TimeSpan.FromMilliseconds(1), customEvent: new MyTimeoutEvent());
                        break;

                    case TestType.CustomPeriodicTimer:
                        this.StartPeriodicTimer(TimeSpan.FromMilliseconds(1), TimeSpan.FromMilliseconds(1), customEvent: new MyTimeoutEvent());
                        break;

                    default:
                        break;
                    }
                }
                catch (AssertionFailureException ex)
                {
                    this.Logger.WriteLine(LogSeverity.Error, ex.Message);
                    ce.Tcs.SetResult(expectError is true);
                    this.RaiseHaltEvent();
                }
            }
Exemple #2
0
 private void Client_onNewConfiguration(object obj, ConfigEvent configArgs)
 {
     if (this.Config == null)
     {
         this.Config       = configArgs.Config;
         this.canStartGame = true;
     }
 }
Exemple #3
0
        /// <summary>
        /// This method is called for every Lambda invocation. This method takes in an Config event object and can be used
        /// to respond to Config notifications.
        /// </summary>
        /// <param name="evnt"></param>
        /// <param name="context"></param>
        /// <returns>Nothing</returns>
        public async Task FunctionHandler(ConfigEvent evnt, ILambdaContext context)
        {
            Console.WriteLine("inside function handler...");
            Amazon.RegionEndpoint     region = Amazon.RegionEndpoint.GetBySystemName(System.Environment.GetEnvironmentVariable(AWS_REGION_PROPERTY));
            AmazonConfigServiceClient configServiceClient = new AmazonConfigServiceClient(region);

            await DoHandle(evnt, context, configServiceClient);
        }
Exemple #4
0
 public void OnCanvasClick(object sender, MouseButtonEventArgs e)
 {
     if (PerAddNEvent == true)
     {
         ConfigEvent ne = AddNewEvent(NewEventType);
         ne.SetPos((int)e.GetPosition((Canvas)sender).X - 75, (int)e.GetPosition((Canvas)sender).Y - 35);
         designer.Client.Children.Add(ne.GetShowItem());
         PerAddNEvent = false;
         Proj.win_main.AddNEvent.IsChecked = false;
         Proj.win_main.AddSEvent.IsChecked = false;
     }
 }
Exemple #5
0
        /// <summary>
        /// 添加一个事件
        /// </summary>
        /// <param name="eType"></param>
        public ConfigEvent AddNewEvent(string eType)
        {
            ConfigEvent newE = null;

            switch (eType)
            {
            case "NormalEvent":
                newE = new ConfigEvent(eType);
                break;

            case "SubProcess":
                newE = new ConfigSubEvent(eType);
                break;

            case "StartEvent":
                newE = new ConfigEvent(eType);
                break;

            case "EndEvent":
                newE = new ConfigEvent(eType);
                break;

            case "LoopEvent":
                newE = new ConfigLoopEvent(eType);
                break;

            default:
                newE = null;
                break;
            }
            if (newE == null)
            {
                return(null);
            }

            newE.name        = "event" + for_events.ToString();
            newE.description = "event" + for_events.ToString();
            newE.OnSelected += this.Proj.win_main.OnConfigItem_Selected;
            if (eType != "StartEvent" && eType != "EndEvent")
            {
                newE.OnRightButtonUp += ((MainWindow)Application.Current.MainWindow).pop_itemmenu;
            }
            wf_itmes.Add(newE);
            for_events += 1;
            return(newE);
        }
Exemple #6
0
 public void LoadConfigs()
 {
     foreach (string path in ResourcesManager.CsvDict.Keys)
     {
         ReadCsv config = ResourcesManager.CsvDict[path];
         for (int i = 3; i < config.GetRow(); i++)
         {
             if (path.Contains("Scene.csv"))
             {
                 ConfigScene data = new ConfigScene(config, i);
                 this.CfgScene.Add(data._id, data);
             }
             else if (path.Contains("Story.csv"))
             {
                 ConfigStory data = new ConfigStory(config, i);
                 this.CfgStory.Add(data._id, data);
             }
             else if (path.Contains("Event.csv"))
             {
                 ConfigEvent data = new ConfigEvent(config, i);
                 this.CfgEvent.Add(data._id, data);
             }
             else if (path.Contains("Item.csv"))
             {
                 ConfigItem data = new ConfigItem(config, i);
                 this.CfgItem.Add(data._id, data);
             }
             else if (path.Contains("Drop.csv"))
             {
                 ConfigDrop data = new ConfigDrop(config, i);
                 this.CfgDrop.Add(data._id, data);
             }
             else if (path.Contains("Monster.csv"))
             {
                 ConfigMonster data = new ConfigMonster(config, i);
                 this.CfgMonster.Add(data._id, data);
             }
             else if (path.Contains("Equipment.csv"))
             {
                 ConfigEquipment data = new ConfigEquipment(config, i);
                 this.CfgEquipment.Add(data._id, data);
             }
         }
     }
 }
Exemple #7
0
    public override void OnEnable()
    {
        int eventId = Process.Instance.CurEventData._id;

        MyLog.Log("show event ui:" + eventId);
        mEventInfo = ConfigManager.Instance.ReqEvent(eventId);
        if (mEventInfo != null)
        {
            mText.text    = mEventInfo._desc;
            mBtn1.visible = mEventInfo._resultList.Count > 0;
            mBtn1.text    = mEventInfo._resultList.Count > 0 ? mEventInfo._resultList[0].resultDesc : "";
            mBtn2.visible = mEventInfo._resultList.Count > 1;
            mBtn2.text    = mEventInfo._resultList.Count > 1 ? mEventInfo._resultList[1].resultDesc : "";
        }
        else
        {
            MyLog.LogError("Event " + eventId + " not exist.");
        }
    }
Exemple #8
0
        private async Task DoHandle(ConfigEvent configEvent, ILambdaContext context, AmazonConfigServiceClient configServiceClient)
        {
            JObject ruleParamsObj;
            JObject configItem;

            if (configEvent.RuleParameters != null)
            {
                ruleParamsObj = JObject.Parse(configEvent.RuleParameters.ToString());
            }
            else
            {
                ruleParamsObj = new JObject();
            }

            JObject invokingEventObj = JObject.Parse(configEvent.InvokingEvent.ToString());

            if (invokingEventObj["configurationItem"] != null)
            {
                configItem = JObject.Parse(invokingEventObj[CONFIGURATION_ITEM].ToString());
            }
            else
            {
                configItem = new JObject();
            }

            FailForIncompatibleEventTypes(invokingEventObj);
            ComplianceType myCompliance = ComplianceType.NOT_APPLICABLE;

            if (!IsEventNotApplicable(configItem, configEvent.EventLeftScope))
            {
                myCompliance = RuleCode.EvaluateCompliance(invokingEventObj, ruleParamsObj, context);
            }

            // Associates the evaluation result with the AWS account published in the event.
            Evaluation evaluation = new Evaluation {
                ComplianceResourceId   = GetResourceId(configItem),
                ComplianceResourceType = GetResourceType(configItem),
                OrderingTimestamp      = GetCiCapturedTime(configItem),
                ComplianceType         = myCompliance
            };

            await DoPutEvaluations(configServiceClient, configEvent, evaluation);
        }
Exemple #9
0
        // Sends the evaluation results to AWS Config.
        private async Task DoPutEvaluations(AmazonConfigServiceClient configClient, ConfigEvent configEvent, Evaluation evaluation)
        {
            Console.WriteLine("inside DoPutEvaluations...");
            PutEvaluationsRequest req = new PutEvaluationsRequest();

            req.Evaluations.Add(evaluation);
            req.ResultToken = configEvent.ResultToken;


            Task <PutEvaluationsResponse> taskResp = configClient.PutEvaluationsAsync(req);
            PutEvaluationsResponse        response = await taskResp;

            // Ends the function execution if any evaluation results are not successfully reported.
            if (response.FailedEvaluations.Count > 0)
            {
                throw new Exception(String.Format(
                                        "The following evaluations were not successfully reported to AWS Config: %s",
                                        response.FailedEvaluations));
            }
        }
Exemple #10
0
            private void Initialize(Event e)
            {
                var ce = e as ConfigEvent;

                this.Config       = ce;
                this.Config.Count = 0;
                switch (ce.Test)
                {
                case TestType.CustomTimer:
                    this.StartTimer(TimeSpan.FromMilliseconds(1), customEvent: new MyTimeoutEvent());
                    break;

                case TestType.CustomPeriodicTimer:
                    this.StartPeriodicTimer(TimeSpan.FromMilliseconds(1), TimeSpan.FromMilliseconds(1), customEvent: new MyTimeoutEvent());
                    break;

                default:
                    break;
                }
            }
        public async Task TestActorInheritance()
        {
            var runtime = RuntimeFactory.Create();
            var config  = new ConfigEvent();
            var actor   = runtime.CreateActor(typeof(ActorSubclass), config);

            runtime.SendEvent(actor, new E1());
            runtime.SendEvent(actor, new E2());
            runtime.SendEvent(actor, new E3());
            runtime.SendEvent(actor, new E4());
            runtime.SendEvent(actor, new CompletedEvent());
            await config.Completed.Task;

            var actual   = NormalizeNewLines(config.Log.ToString());
            var expected = NormalizeNewLines(@"ActorSubclass handling E1
ActorSubclass handling E2
BaseActor handling E3
Inherited handling of E4
");

            Assert.Equal(expected, actual);
        }
Exemple #12
0
        public void InitStartAndEnd()
        {
            //start
            ConfigEvent newSE = new ConfigEvent("StartEvent");

            newSE.name        = "Start";
            newSE.description = "Start";
            newSE.OnSelected += this.Proj.win_main.OnConfigItem_Selected;
            newSE.SetPos(50, 50);
            wf_itmes.Add(newSE);
            this.designer.Client.Children.Add(newSE.GetShowItem());

            //end
            ConfigEvent newEE = new ConfigEvent("EndEvent");

            newEE.name        = "End";
            newEE.description = "End";
            newEE.OnSelected += this.Proj.win_main.OnConfigItem_Selected;
            newEE.SetPos(50, 150);
            wf_itmes.Add(newEE);
            this.designer.Client.Children.Add(newEE.GetShowItem());
        }
Exemple #13
0
 public string FunctionHandler(ConfigEvent inputData)
 {
     return(inputData.ConfigRuleName);
 }
Exemple #14
0
 public override void OnConfigChange(ConfigEvent Event, MessageInfo Errors, DBObject OldObject)
 {
     base.OnConfigChange(Event, Errors, OldObject);
 }
Exemple #15
0
        public bool LoadWorkFlow(XmlElement source)
        {
            //params
            XmlElement  pars_xml = (XmlElement)source.SelectSingleNode("params");
            XmlNodeList parss    = pars_xml.SelectNodes("param");

            foreach (XmlNode xn in parss)
            {
                XmlElement xe   = (XmlElement)xn;
                bool       flag = false;

                foreach (param pa in params_table)
                {
                    if (pa.Name == xe.GetAttribute("name"))
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag == false)
                {
                    params_table.Add(new param()
                    {
                        Name = xe.GetAttribute("name"),
                        Type = xe.GetAttribute("type"),
                        Desc = xe.GetAttribute("desc")
                    });
                }
            }

            //ConfigItem
            XmlElement items_xml = (XmlElement)source.SelectSingleNode("configitems");

            foreach (XmlNode xn1 in items_xml.SelectNodes("item"))
            {
                XmlElement xe1 = (XmlElement)xn1;
                if (xe1.GetAttribute("item_type") == "event")
                {
                    ConfigEvent ce = AddNewEvent(xe1.GetAttribute("event_type"));
                    ce.authority = xe1.GetAttribute("authority");
                    ce.GetShowItem().Margin = new Thickness(
                        Convert.ToDouble(((XmlElement)xe1.SelectSingleNode("shape")).GetAttribute("margin").Split(',')[0]),
                        Convert.ToDouble(((XmlElement)xe1.SelectSingleNode("shape")).GetAttribute("margin").Split(',')[1]),
                        Convert.ToDouble(((XmlElement)xe1.SelectSingleNode("shape")).GetAttribute("margin").Split(',')[1]),
                        Convert.ToDouble(((XmlElement)xe1.SelectSingleNode("shape")).GetAttribute("margin").Split(',')[1]));
                    ce.CurrentAction = ((XmlElement)xe1.SelectSingleNode("actions")).GetAttribute("currentaction");

                    XmlElement ba = (XmlElement)(xe1.SelectSingleNode("actions").SelectSingleNode("beforeaction"));
                    XmlElement aa = (XmlElement)(xe1.SelectSingleNode("actions").SelectSingleNode("afteraction"));
                    if (ba != null) //新版本
                    {
                        ce.BeforeAction.url = ba.GetAttribute("url");
                        XmlNodeList act_pars = ba.SelectSingleNode("action_params").SelectNodes("param");
                        ce.BeforeAction.action_params.Clear();
                        foreach (XmlNode parxn in act_pars)
                        {
                            ce.BeforeAction.action_params[((XmlElement)parxn).GetAttribute("name")] = ((XmlElement)parxn).InnerText;
                        }


                        ce.AfterAction.url = aa.GetAttribute("url");
                        XmlNodeList act_pars1 = aa.SelectSingleNode("action_params").SelectNodes("param");
                        ce.AfterAction.action_params.Clear();
                        foreach (XmlNode parxn in act_pars1)
                        {
                            ce.AfterAction.action_params[((XmlElement)parxn).GetAttribute("name")] = ((XmlElement)parxn).InnerText;
                        }
                    }
                    else
                    {
                        ce.BeforeAction.url = ((XmlElement)xe1.SelectSingleNode("actions")).GetAttribute("beforeaction");
                        ce.AfterAction.url  = ((XmlElement)xe1.SelectSingleNode("actions")).GetAttribute("afteraction");
                    }

                    XmlNodeList parsss = xn1.SelectSingleNode("link_params").SelectNodes("param");
                    foreach (XmlNode xn2 in parsss)
                    {
                        ce.LinkParams.Add(((XmlElement)xn2).GetAttribute("name"), ((XmlElement)xn2).GetAttribute("app_reserve"));
                    }
                    ce.name        = xe1.GetAttribute("name");
                    ce.description = xe1.GetAttribute("desc");

                    //time_out
                    XmlNode time_out = xn1.SelectSingleNode("time_out");
                    if (time_out != null)
                    {
                        Dictionary <string, object> timeout_setting = (ce.Time_Out as Dictionary <string, object>);
                        XmlNode time_start = time_out.SelectSingleNode("start");
                        if (time_start == null)
                        {
                            timeout_setting["start"] = "";
                        }
                        else
                        {
                            timeout_setting["start"] = time_start.InnerText;
                        }

                        XmlNode time_offset = time_out.SelectSingleNode("offset");
                        if (time_offset == null || time_offset.InnerText == "")
                        {
                            timeout_setting["offset"] = (null as TimeSpan?);
                        }
                        else
                        {
                            TimeSpan?ts = TimeSpan.Parse(time_offset.InnerText);
                            timeout_setting["offset"] = ts;
                        }

                        XmlNode time_exact = time_out.SelectSingleNode("exact");
                        if (time_exact == null || time_exact.InnerText == "")
                        {
                            timeout_setting["exact"] = (null as DateTime?);
                        }
                        else
                        {
                            DateTime?dt = DateTime.Parse(time_exact.InnerText);
                            timeout_setting["exact"] = dt;
                        }

                        XmlNode time_action = time_out.SelectSingleNode("action");
                        if (time_action == null)
                        {
                            timeout_setting["action"] = "";
                        }
                        else
                        {
                            timeout_setting["action"] = time_action.InnerText;
                        }

                        XmlNode time_callback = time_out.SelectSingleNode("callback");
                        if (time_callback == null)
                        {
                            timeout_setting["callback"] = "";
                        }
                        else
                        {
                            timeout_setting["callback"] = time_callback.InnerText;
                        }
                    }

                    if (ce.GetType().Name == "ConfigSubEvent")
                    {
                        ((ConfigSubEvent)ce).SetWorkModel(((XmlElement)xe1.SelectSingleNode("LinkWorkflow")).GetAttribute("model"));
                        ((ConfigSubEvent)ce).LinkWorkFLow = ((XmlElement)xe1.SelectSingleNode("LinkWorkflow")).GetAttribute("name");

                        XmlNodeList param_transfer = ((XmlElement)xe1.SelectSingleNode("LinkWorkflow")).SelectNodes("ParamTransfer");
                        foreach (XmlNode pt in param_transfer)
                        {
                            ((ConfigSubEvent)ce).ParamTransfer.Add(new paramtransfer_item()
                            {
                                parent    = ((XmlElement)pt).GetAttribute("source"),
                                child     = ((XmlElement)pt).GetAttribute("dest"),
                                direction = ((XmlElement)pt).GetAttribute("direction") == "from" ? transfer_direction.from : transfer_direction.to
                            });
                        }
                    }

                    if (ce.GetType().Name == "ConfigLoopEvent")
                    {
                        ((ConfigLoopEvent)ce).LoopCondition = (xe1.SelectSingleNode("LoopSetting").SelectSingleNode("condition") as XmlElement).InnerText;
                        ((ConfigLoopEvent)ce).TimeWaiting   = (xe1.SelectSingleNode("LoopSetting").SelectSingleNode("waiting_time") as XmlElement).InnerText;
                    }

                    designer.Client.Children.Add(ce.GetShowItem());
                }
            }

            //flow
            foreach (XmlNode xn3 in items_xml.SelectNodes("item"))
            {
                XmlElement xe2 = (XmlElement)xn3;
                if (xe2.GetAttribute("item_type") == "flow")
                {
                    ConfigFlow cf = new ConfigFlow();
                    foreach (ConfigItem ci in wf_itmes)
                    {
                        if ((ci.GetType().Name == "ConfigEvent" || ci.GetType().Name == "ConfigSubEvent" || ci.GetType().Name == "ConfigLoopEvent") &&
                            ci.name == ((XmlElement)xe2.SelectSingleNode("shape")).GetAttribute("source"))
                        {
                            cf.Start = (ConfigEvent)ci;
                            ((ConfigEvent)ci).AttachFlows(cf);
                        }
                        if ((ci.GetType().Name == "ConfigEvent" || ci.GetType().Name == "ConfigSubEvent" || ci.GetType().Name == "ConfigLoopEvent") &&
                            ci.name == ((XmlElement)xe2.SelectSingleNode("shape")).GetAttribute("dest"))
                        {
                            cf.End = (ConfigEvent)ci;
                            ((ConfigEvent)ci).AttachFlows(cf);
                        }
                    }
                    cf.Express          = xe2.GetAttribute("condition");
                    cf.OnSelected      += this.Proj.win_main.OnConfigItem_Selected;
                    cf.OnRightButtonUp += ((MainWindow)Application.Current.MainWindow).pop_itemmenu;
                    designer.Client.Children.Add(cf.GetShowItem());
                    cf.Connect();
                    wf_itmes.Add(cf);
                }
            }
            for_events = Convert.ToInt32(((XmlElement)source.SelectSingleNode("for_events")).GetAttribute("value"));
            return(true);
        }
 private static void Handle(ConfigEvent configEvent)
 {
     Console.WriteLine($"AWS Config rule - {configEvent.ConfigRuleName}");
     Console.WriteLine($"Invoking event JSON - {configEvent.InvokingEvent}");
     Console.WriteLine($"Event version - {configEvent.Version}");
 }
    /// <summary>
    /// Lit les trames sur le stream et les interpretes
    /// </summary>
    private void ReceiveData()//IAsyncResult ar
    {
        try
        {
            while (this.receiveThreadRunning == true)
            {
                if (this.udpReceiver != null)
                {
                    TrameId id;

                    var trame = this.udpReceiver.Receive(ref this.receiveEndPoint);//this.udpReceiver.EndReceive(ar, ref this.receiveEndPoint);
                    // Analyse la trame qui à été reçue
                    var result = FrameDeconstruct.Deconstruct(trame, out id);

                    // En fonction de la trame il faut adopter le bon comprtement
                    // Dans certains cas il faut lever des évenements dans d'autres il faut garder des valeurs en mémoire
                    switch (id)
                    {
                    case TrameId.Configuration:
                        if (this.onNewConfiguration != null)
                        {
                            this.configReceived = true;
                            ConfigEvent configArgs = new ConfigEvent(result as ReaLabConfiguration);
                            this.onNewConfiguration(this, configArgs);
                        }
                        break;

                    case TrameId.Positions:
                        if (this.onNewPositions != null)
                        {
                            PointEvent pointArgs = new PointEvent(result as PointData);
                            this.onNewPositions(this, pointArgs);
                        }
                        break;

                    case TrameId.Positions2:
                        if (this.onNewPositions2 != null)
                        {
                            PointEvent pointArgs = new PointEvent(result as PointData);
                            this.onNewPositions2(this, pointArgs);
                        }
                        break;

                    case TrameId.Forces:
                        if (this.onNewForces != null)
                        {
                            PointEvent pointArgs = new PointEvent(result as PointData);
                            this.onNewForces(this, pointArgs);
                        }
                        break;

                    case TrameId.Forces2:
                        if (this.onNewForces2 != null)
                        {
                            PointEvent pointArgs = new PointEvent(result as PointData);
                            this.onNewForces2(this, pointArgs);
                        }
                        break;

                    case TrameId.PauseGame:
                        if (this.onPause != null)
                        {
                            this.onPause(this, EventArgs.Empty);
                        }
                        break;

                    case TrameId.StopGame:
                        if (this.onStop != null)
                        {
                            this.onStop(this, EventArgs.Empty);
                        }
                        break;

                    case TrameId.SetValue:
                        string key  = (result as ValueData).Key;
                        object data = (result as ValueData).Data;
                        if (this.values.ContainsKey(key))
                        {
                            this.values.Remove(key);
                        }

                        this.values.Add(key, data);
                        break;

                    case TrameId.Null:
                        break;

                    default:
                        break;
                    }
                }

                //this.udpReceiver.BeginReceive(this.ReceiveData, this.udpReceiver);
                Thread.Sleep(1);
            }
        }
        catch (Exception ex)
        {
        }
    }