Beispiel #1
0
        public async Task <ActionResult <IEnumerable <TipoPantalla> > > PutEsquemasSqlSentence(SentenciaSql sentencia)
        {
            sentencia = ExtraUtils.GenerarSqlSelect(typeof(TipoPantalla), sentencia, _context);

            if (sentencia.Parametros == null || sentencia.Parametros.Length == 0)
            {
                return(await _context.TipoPantallaDbSet.FromSqlRaw(sentencia.Sentencia).ToListAsync().ConfigureAwait(true));
            }
            else
            {
                return(await _context.TipoPantallaDbSet.FromSqlRaw(sentencia.Sentencia, ExtraUtils.ConvertirAParamPostgres(sentencia.Parametros.ToList()).ToArray()).ToListAsync().ConfigureAwait(true));
            }
        }
Beispiel #2
0
        //https://bitso.com/api_info#ledger
        public Operation[] GetLedger(OperationType operationType, string marker = "", string sort = "desc", int limit = 25)
        {
            var operationTypeUrl = string.Empty;

            switch (operationType)
            {
            case OperationType.Fee: operationTypeUrl = "/fees"; break;

            case OperationType.Funding: operationTypeUrl = "/fundings"; break;

            case OperationType.Withdrawal: operationTypeUrl = "/withdrawals"; break;

            case OperationType.Trade: operationTypeUrl = "/trades"; break;
            }

            var rawResponse = BitsoClient.SendRequest("ledger" + operationTypeUrl + ExtraUtils.BuildQueryString("marker", marker, "sort", sort, "limit", limit.ToString()), "GET");

            var responseArray = JsonConvert.DeserializeObject <JArray>(rawResponse);
            var operations    = new Operation[responseArray.Count];
            var index         = 0;

            foreach (var operation in responseArray)
            {
                switch (operation["operation"].ToString())
                {
                case "trade": operations[index] = JsonConvert.DeserializeObject <TradeOperation>(operation.ToString()); break;

                case "funding": operations[index] = JsonConvert.DeserializeObject <FundingOperation>(operation.ToString()); break;

                case "fee": operations[index] = JsonConvert.DeserializeObject <FeeOperation>(operation.ToString()); break;

                case "withdrawal": operations[index] = JsonConvert.DeserializeObject <WithdrawalOperation>(operation.ToString()); break;

                default: operations[index] = JsonConvert.DeserializeObject <Operation>(operation.ToString()); break;
                }
                index++;
            }
            return(operations);
        }
Beispiel #3
0
        public string SendRequest(string url, string method, bool signRequest = true, string body = null)
        {
            if (string.IsNullOrEmpty(BITSO_API_VERSION))
            {
                Console.WriteLine("Se necesita establecer en ambiente");
            }

            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(BITSO_BASE_URL + BITSO_API_VERSION + url);

            if (signRequest)
            {
                long   nonce   = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                string message = nonce + method + BITSO_API_VERSION + url + body;

                string signature  = ExtraUtils.HMACSHA256(message, BITSO_SECRET);
                string authHeader = $"Bitso {BITSO_KEY}:{nonce}:{signature}";

                httpWebRequest.Headers.Add(HttpRequestHeader.Authorization, authHeader);
            }

            httpWebRequest.Method      = method;
            httpWebRequest.ContentType = "application/json";

            if (!string.IsNullOrEmpty(body))
            {
                using (Stream req = httpWebRequest.GetRequestStream())
                {
                    byte[] bodyBytes = Encoding.UTF8.GetBytes(body);
                    req.Write(bodyBytes, 0, bodyBytes.Length);
                }
            }

            string response = string.Empty;

            try
            {
                using (WebResponse res = httpWebRequest.GetResponse())
                {
                    using (Stream strReader = res.GetResponseStream())
                    {
                        using (StreamReader objReader = new StreamReader(strReader))
                        {
                            response = objReader.ReadToEnd();
                        }
                    }
                }
            }
            catch (WebException ex)
            {
                using (HttpWebResponse res = (HttpWebResponse)ex.Response)
                {
                    if (res == null)
                    {
                        throw new BitsoException("No response was returned from Bitso.", "0");
                    }

                    using (var str = res.GetResponseStream())
                    {
                        using (StreamReader reader = new StreamReader(str))
                        {
                            response = reader.ReadToEnd();

                            if (res.StatusCode == HttpStatusCode.NotFound && response.StartsWith("<"))
                            {
                                throw new BitsoException("The requested resource was not found.", "-1");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new BitsoException(ex.Message, "0");
            }

            if (string.IsNullOrEmpty(response) || response.StartsWith("<"))
            {
                throw new BitsoException("A malformed response was returned from Bitso.", "-1");
            }

            JObject responseObj = JsonConvert.DeserializeObject <JObject>(response);

            if (responseObj == null)
            {
                throw new BitsoException("No response was returned from Bitso.", "0");
            }

            if (responseObj["success"].Value <bool>())
            {
                if (method == "GET" && url == "balance") //This was hardcoded to mantain consistency in the response
                {
                    return(responseObj["payload"]["balances"].ToString());
                }

                return(responseObj["payload"].ToString());
            }

            throw new BitsoException(responseObj["error"]["message"].ToString(), responseObj["error"]["code"].ToString());
        }
Beispiel #4
0
        public void Read(NetInfo gameNet, string _mode)
        {
            this.mode = _mode;
            if (gameNet == null)
            {
                return;
            }

            nodeMeshes    = new CSMesh[gameNet.m_nodes.Length];
            segmentMeshes = new CSMesh[gameNet.m_segments.Length];

            Debug.Log("gamenetName" + gameNet.name);

            var netname = ExtraUtils.FormatNetworkName();

            //get elevation?
            Debug.Log("mode " + mode);

            if (_mode == "Basic")
            {
                _mode = "";
            }
            else
            {
                _mode = " " + _mode;
            }

            for (int i = 0; i < nodeMeshes.Length; i++)
            {
                nodeMeshes[i]       = new CSMesh();
                nodeMeshes[i].index = i;
                if (i != 0)
                {
                    nodeMeshes[i].name    = netname + "_mesh" + (i + 1) + _mode;
                    nodeMeshes[i].texture = netname + "_mesh" + (i + 1) + _mode;
                }
                else
                {
                    nodeMeshes[i].name    = netname + _mode;
                    nodeMeshes[i].texture = netname + _mode;
                }
                Debug.Log("nodemesh1");
                nodeMeshes[i].name    = nodeMeshes[i].name + "_node";
                nodeMeshes[i].texture = nodeMeshes[i].texture + "_node";

                nodeMeshes[i].shader = gameNet.m_nodes[i].m_material.shader.name;

                for (int d = 0; d < 3; d++)
                {
                    nodeMeshes[i].color[d] = gameNet.m_nodes[i].m_material.color[d];
                }
                Debug.Log("nodemesh2");
            }
            Debug.Log("segmesh1");
            for (int i = 0; i < segmentMeshes.Length; i++)
            {
                segmentMeshes[i] = new CSMesh();
                Debug.Log("segmesh2");
                segmentMeshes[i].index = i;
                if (i != 0)
                {
                    segmentMeshes[i].name    = netname + "_mesh" + (i + 1) + _mode;
                    segmentMeshes[i].texture = netname + "_mesh" + (i + 1) + _mode;
                    Debug.Log("segmesh3");
                }
                else
                {
                    segmentMeshes[i].name    = netname + _mode;
                    segmentMeshes[i].texture = netname + _mode;
                }

                //Debug.Log("segmesh4");
                segmentMeshes[i].shader = gameNet.m_segments[i].m_material.shader.name;


                for (int d = 0; d < 3; d++)
                {
                    segmentMeshes[i].color[d] = gameNet.m_segments[i].m_material.color[d];
                }
            }


            //hack for dumped slope and tunnel meshes - removes first entry in list
            Debug.Log("_mode: " + _mode);
            if (_mode == " Slope" || _mode == " Tunnel")
            {
                CSMesh[] tempnodeMeshes    = nodeMeshes;
                CSMesh[] tempsegmentMeshes = segmentMeshes;

                nodeMeshes = new CSMesh[gameNet.m_nodes.Length - 1];
                for (int i = 0; i < nodeMeshes.Length; i++)
                {
                    nodeMeshes[i] = tempnodeMeshes[i + 1];
                }
                segmentMeshes = new CSMesh[gameNet.m_segments.Length - 1];
                for (int i = 0; i < segmentMeshes.Length; i++)
                {
                    segmentMeshes[i] = tempsegmentMeshes[i + 1];
                }
            }
        }
Beispiel #5
0
        //https://bitso.com/api_info#open-orders
        public OpenOrder[] GetOpenOrders(string book = "btc_mxn", string marker = "", string sort = "desc", int limit = 25)
        {
            var rawResponse = BitsoClient.SendRequest("open_orders" + ExtraUtils.BuildQueryString("book", book, "marker", marker, "sort", sort, "limit", limit.ToString()), "GET");

            return(JsonConvert.DeserializeObject <OpenOrder[]>(rawResponse));
        }
Beispiel #6
0
        public void ExportNetInfoXML()
        {
            Debug.Log("roadimporter xml begin");

            TextWriter writer = new StreamWriter(Path.Combine(Path.Combine(DataLocation.addonsPath, "Import"), $"{ExtraUtils.FormatNetworkName() + "_data"}.xml"));

            Debug.Log(loadedPrefab.GetType());

            if (loadedPrefab.m_netAI.GetType() == typeof(RoadAI))
            {
                RoadAssetInfo roadAsset = new RoadAssetInfo();
                roadAsset.ReadFromGame(loadedPrefab);

                XmlSerializer ser = new XmlSerializer(typeof(RoadImporterXML.RoadAssetInfo));
                ser.Serialize(writer, roadAsset);
            }
            else if (loadedPrefab.m_netAI.GetType() == typeof(TrainTrackAI))
            {
                TrainTrackAssetInfo trainAsset = new TrainTrackAssetInfo();
                trainAsset.ReadFromGame(loadedPrefab);

                XmlSerializer ser = new XmlSerializer(typeof(RoadImporterXML.TrainTrackAssetInfo));
                ser.Serialize(writer, trainAsset);
            }
            else
            {
                throw new NotImplementedException("NetInfo XML Export Error!");
            }
            writer.Close();
            Debug.Log("success!!!");
        }