예제 #1
0
        public bool AddSolarPacItem(AzureFunction function, SolarPacItem solarPacItem)
        {
            var restRequest = new RestRequest(Method.POST);

            restRequest.Resource = $"/{function.Url}";
            JsonObject jsonObj = new JsonObject();

            jsonObj.Add("InverterId", solarPacItem.inverterId);
            jsonObj.Add("Pac", solarPacItem.pac);
            restRequest.RequestFormat = DataFormat.Json;
            string jsonPayload = System.Text.Json.JsonSerializer.Serialize(jsonObj, _JsonSerializerOptions);

            restRequest.AddParameter("application/json; charset=utf-8", jsonPayload, ParameterType.RequestBody);

            //invio la richiesta
            var resultRestRequest = _RestClient.Execute(restRequest);

            //gestione del response
            if (resultRestRequest.StatusCode == System.Net.HttpStatusCode.OK)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        // Use this for initialization
        void Start()
        {
            if (canvas == null)
            {
                Debug.unityLogger.LogError(kTAG, "Attach 'canvas' property to root Canvas game object in hierarchy.");
                return;
            }

            if (messageViewPrefab == null)
            {
                Debug.unityLogger.LogError(kTAG, "To use the message view the associated prefabs must be attached.");
                return;
            }

            client         = AzureFunctionClient.Create(account);
            messageService = new AzureFunction(messageFunction, client, key);
        }
예제 #3
0
        public SolarPacItem GetLastSolarPacItem(AzureFunction function, int inverterId)
        {
            var restRequest = new RestRequest(Method.POST);

            restRequest.Resource = $"/{function.Url}";
            JsonObject jsonObj = new JsonObject();

            jsonObj.Add("InverterId", inverterId);
            restRequest.RequestFormat = DataFormat.Json;
            string jsonPayload = System.Text.Json.JsonSerializer.Serialize(jsonObj, _JsonSerializerOptions);

            restRequest.AddParameter("application/json; charset=utf-8", jsonPayload, ParameterType.RequestBody);

            //invio la richiesta
            var resultRestRequest = _RestClient.Execute(restRequest);

            //gestione del response
            if (resultRestRequest.StatusCode == System.Net.HttpStatusCode.OK)
            {
                if (string.IsNullOrWhiteSpace(resultRestRequest.Content))
                {
                    //no itempac
                    return(null);
                }
                try
                {
                    //deserialize the response
                    var itemPac = System.Text.Json.JsonSerializer.Deserialize <SolarPacItem>(resultRestRequest.Content);
                    return(itemPac);
                }
                catch (System.Exception ex)
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
예제 #4
0
        public override ICloudCredentials GetCredentialsForRule(Rule rule, string arn)
        {
            if (rule == null || rule.LambdaProperties == null)
            {
                return new AzureCredentials()
                       {
                           FuncObject = null, Cloud = (ICloudForCreds)this
                       }
            }
            ;

            System.Runtime.Serialization.Json.DataContractJsonSerializer jss = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(AzureFunction));

            System.IO.MemoryStream ms = new System.IO.MemoryStream(System.Text.ASCIIEncoding.ASCII.GetBytes(rule.LambdaProperties));

            AzureFunction func = (AzureFunction)jss.ReadObject(ms);

            return(new AzureCredentials()
            {
                FuncObject = func, Cloud = (ICloudForCreds)this
            });
        }
    }
예제 #5
0
        // Use this for initialization
        void Start()
        {
            if (canvas == null)
            {
                Debug.unityLogger.LogError(kTAG, "Attach 'canvas' property to root Canvas game object in hierarchy.");
                return;
            }

            if (string.IsNullOrEmpty(account) || string.IsNullOrEmpty(leaderboardKey) || string.IsNullOrEmpty(scoreKey))
            {
                Debug.unityLogger.LogError(kTAG, "Azure Function account and key required.");
                return;
            }

            if (tableViewPrefab == null || tableViewCellPrefab == null)
            {
                Debug.unityLogger.LogError(kTAG, "To use the table view the associated prefabs must be attached.");
                return;
            }

            client             = AzureFunctionClient.Create(account);
            leaderboardService = new AzureFunction(leaderboardFunction, client, leaderboardKey);
            scoreService       = new AzureFunction(scoreFunction, client, scoreKey);
        }