Ejemplo n.º 1
0
        public void http_client_adv()
        {
            var j = new JsonParser();

            string url      = "https://openbookmobile.etoro.com/api/login";
            string header   = @"Content-Type::application/x-www-form-urlencoded; charset=utf-8,, User-Agent::OpenBook/2.1 (iPad Simulator; iOS 7.1; Scale/2.00)";
            string mode     = "POST";
            string postdata = @"username=socialalert15&Password=123456m&appName=iOS&ver=2.1";
            string str      = "m=" + mode + " h=" + header + " u=" + url + " p=" + postdata;


            //string dbapiResult = HttpRequestExtensions.GetHTTPrequest(url);

            j.AddKeyToMemory(Constants.Memory, HttpRequestExtensions.GetHTTPrequestPost(str));

            string line = @"$$Token j= Token";

            j.VariableFunctions(line);

            str  = j.replaceVariable("$$Token");
            line = "https://openbookmobile.etoro.com/api/market?username=socialalert15&symbol=GOOG&appName=iOS&ver=2.1&period=180&code=en-gb&token=$$Token";
            j.AddKeyToMemory(Constants.Memory, HttpRequestExtensions.GetHTTPrequest(line));
            line = @"$$MarketValue j= MarketValue";
            j.VariableFunctions(line);
            str = j.replaceVariable("$$MarketValue");

            line = @"$$StockSummary j= StockSummary";
            j.VariableFunctions(line);
            str = j.replaceVariable("$$StockSummary");
        }
Ejemplo n.º 2
0
        public void http_client()
        {
            var j = new JsonParser();
            //string url = "https://fapi-real.etoro.com/instruments.json";
            string url = "https://fapi-real.etoro.com/instruments/1";

            //string dbapiResult = HttpRequestExtensions.GetHTTPrequest(url);

            j.AddKeyToMemory(Constants.Memory, HttpRequestExtensions.GetHTTPrequest(url));


            string line = @"$$instrumentData j= InstrumentName";

            j.VariableFunctions(line);

            string str = j.replaceVariable("$$instrumentData");


            j.VariableFunctions("$$DataSource = " + str);

            str = j.replaceVariable("$$memory");

            line = @"$$instrumentData j= InstrumentName ==> $$DataSource";
            j.VariableFunctions(line);
            str = j.replaceVariable("$$instrumentData");
        }
Ejemplo n.º 3
0
        public void ReplaceVariable()
        {
            var     j   = new JsonParser();
            Boolean res = j.AddConfigToMemory("");
            string  a   = @"aaaaaaaaaaaaaaaaaaaaa $$AppiumServerHost ~ $$app-package\ ~  bbbbbbbbbbbbb";

            a = j.replaceVariable(a);
            Console.Write(a);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// VSH execute command line sql command
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public string ExecuteCMDQuery(string line)
        {
            //c=$$DataSource1 t=$$InitialDataTable cmd=select $$col from $$table $$db_serch
            string command    = "";
            string connection = "";
            string init_table = "";
            string mode       = "select";

            string returnval = string.Empty;

            Regex rem = new Regex(@"(,|;)?\s*$");
            Regex nl  = new Regex(@"\n\n");


            var jp = new JsonParser();


            line = jp.replaceVariable(line);
            //s= -- server
            //t= -- table
            //c= -- command


            Match match = Regex.Match(line, @"c=\s*((\w+).*?)(\s+s=|\s+t=|\s*$)", RegexOptions.IgnoreCase);

            if (match.Success)
            {
                command = match.Groups[1].Value;
                command = rem.Replace(command, "");
                mode    = match.Groups[2].Value;
                mode    = mode.ToLower();
            }
            else
            {
                return("ERROR: DB command not found");
            }

            match = Regex.Match(line, @"s=\s*(.*?)(\s+c=|\s+t=|\s*$)", RegexOptions.IgnoreCase);
            if (match.Success)
            {
                connection = match.Groups[1].Value;
                connection = rem.Replace(connection, "");
            }
            else
            {
                return("ERROR: DB connection string not found");
            }

            match = Regex.Match(line, @"t=\s*(.*?)(\s+c=|\s+s=|\s*$)", RegexOptions.IgnoreCase);
            if (match.Success)
            {
                init_table = match.Groups[1].Value;
                init_table = rem.Replace(init_table, "");
            }

            //add init table to connection string (if table exists)
            if (init_table != string.Empty)
            {
                connection = connection + ";" + init_table;
            }

            var con = new SqlConnection(connection);

            try
            {
                using (SqlCommand cmd = new SqlCommand(command, con))
                {
                    con.Open();

                    if (mode == "select")
                    {
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                string row_line = "";

                                for (int i = 0; i < reader.FieldCount; i++)
                                {
                                    row_line += reader.GetValue(i) + ", ";
                                }
                                row_line   = rem.Replace(row_line, "\n");
                                returnval += row_line;
                            }
                            returnval = nl.Replace(returnval, "\n");
                        }
                    }
                    else
                    {
                        object data = cmd.ExecuteScalar();
                        if (data != null)
                        {
                            returnval = data.ToString().Trim();
                            returnval = mode + " action : OK";
                        }
                    }
                }
            }
            catch (SqlException ex)
            {
                returnval = ex.ToString();
            }
            return(returnval);
        }