예제 #1
0
        public string SendRequest(string site, methodType method, string contentType, string postData)
        {
            WebRequest request = WebRequest.Create(site);

            request.Method = method.ToString();
            byte[] byteArray = Encoding.UTF8.GetBytes(postData);
            request.ContentType   = contentType;
            request.ContentLength = byteArray.Length;

            Stream dataStream = request.GetRequestStream();

            dataStream.Write(byteArray, 0, byteArray.Length);
            dataStream.Close();

            WebResponse response = request.GetResponse();

            Console.WriteLine(((HttpWebResponse)response).StatusDescription);
            dataStream = response.GetResponseStream();
            StreamReader reader             = new StreamReader(dataStream);
            string       responseFromServer = reader.ReadToEnd();

            Console.WriteLine(responseFromServer);

            reader.Close();
            dataStream.Close();
            response.Close();

            return(responseFromServer);
        }
예제 #2
0
 ScriptType(string name, string _namespace, methodType type)
 {
     Name      = name;
     Namespace = _namespace;
     Type      = type;
 }
예제 #3
0
        public RequestInfo(string uri, Object data, contentType type = contentType.JSON, methodType mtd = methodType.e_GET)
        {
            this.RequestURI = uri;
            this.Method     = mtd;
            switch (type)
            {
            case contentType.JSON:
                this.Content = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, GetMediaType(type));
                break;

            case contentType.XML:
                break;
            }
        }
예제 #4
0
 public static async Task <int> addTransactionLog(int userId, string username, transactionType type, transactionStatus status, methodType method, string email, decimal amount)
 {
     if (type == transactionType.sell)
     {
         return(await databaseManager.updateQuery($"INSERT INTO transactions (userId, email, username, amount, type, method, status, confirmDate) VALUES ('{userId}', '{email}', '{username}', '{amount}', '{( int ) type}', '{( int ) method}', '{(int)status}',  DATE_ADD(now(), INTERVAL 10 DAY) ) ").Execute( ));
     }
     else
     {
         return(await databaseManager.updateQuery($"INSERT INTO transactions (userId, email, username, amount, type, method, status, confirmDate) VALUES ('{userId}', '{email}', '{username}', '{amount}', '{( int ) type}', '{( int ) method}', '{( int ) status}',  CURRENT_DATE() ) ").Execute( ));
     }
 }
예제 #5
0
 public RequestInfo(string uri, methodType mtd = methodType.e_GET)
 {
     this.RequestURI = uri;
     this.Method     = mtd;
 }