Exemplo n.º 1
0
        public void UpdateMap()
        {
            foreach (RoomObject RObj in UpdatableObject)
            {
                RObj.Update();
            }
            MForm.Processing = Process.SetDust;
            Random r = new Random();

            MForm.SRForm.Random(r.Next(-10, 2), null);
            MForm.Processing = Process.None;
            Display.Refresh();
        }
        private GingerHttpRequestMessage GetRequest(NodePlatformAction platformAction)
        {
            GingerHttpRequestMessage Request = new GingerHttpRequestMessage();

            Request.URL = new Uri(platformAction.InputParams["EndPointURL"].ToString());

            if (platformAction.ActionType == "ActWebAPISoap")
            {
                Request.Method      = "POST";
                Request.ContentType = "XML";
            }
            else
            {
                Request.Method      = platformAction.InputParams["RequestType"].ToString();
                Request.ContentType = platformAction.InputParams.ContainsKey("ContentType") ? platformAction.InputParams["ContentType"].ToString() : "";

                if (platformAction.InputParams["RequestKeyValues"] is Newtonsoft.Json.Linq.JArray RObj)
                {
                    Request.RequestKeyValues = new List <RestAPIKeyBodyValues>();
                    foreach (Newtonsoft.Json.Linq.JToken Jt in RObj.Children())
                    {
                        RestAPIKeyBodyValues RKV = new RestAPIKeyBodyValues();

                        if (Jt["ValueType"].ToString() == "1")
                        {
                            RKV.ValueType = RestAPIKeyBodyValues.eValueType.File;

                            Byte[] FileBytes = (Byte[])Jt["FileBytes"];
                            string Path      = Jt["Value"].ToString();
                            RKV.Filename = System.IO.Path.GetFileName(Path);



                            ByteArrayContent fileContent = new ByteArrayContent(FileBytes);
                            fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data");
                            RKV.Content = fileContent;
                        }
                        RKV.Value = Jt["Value"].ToString();
                        RKV.Param = Jt["Param"].ToString();



                        Request.RequestKeyValues.Add(RKV);
                    }
                }
            }
            Request.BodyString = platformAction.InputParams.ContainsKey("RequestBody") ? platformAction.InputParams["RequestBody"].ToString() : "";



            if (platformAction.InputParams["Headers"] is Newtonsoft.Json.Linq.JObject JsonObj)
            {
                foreach (Newtonsoft.Json.Linq.JProperty Jt in JsonObj.Children())
                {
                    Request.Headers.Add(new KeyValuePair <string, string>(Jt.Name, Jt.Value.ToString()));
                }
            }


            return(Request);
        }