블로그 이미지
SQL Server VS. 석이 minsouk@hotmail.com MSSQL 쿼리성능 관련해 궁금한 사항이 있다면 언제나 누구나 TeamViewer + Line (네이버 japan 메신저) 에 minsouk1 추가 후 연락주세요~ 010-9967-0955 보미아빠

카테고리

보미아빠, 석이 (452)
밥벌이 (16)
싸이클 (1)
일상 (1)
Total218,709
Today6
Yesterday85

달력

« » 2018.09
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            

공지사항

delete

분류없음 / 2018.09.12 11:37

set nocount on 


declare @rowcount varchar(100) ;

while (1=1)

begin 

delete top (1000) t from perfmon t where machinename is null 

select @rowcount = @@rowcount 

if @rowcount = 0 break; 

RAISERROR(@rowcount, 0, 1) WITH NOWAIT

waitfor delay '00:00:00.200'

end 



Posted by 보미아빠

helppage

분류없음 / 2018.09.11 15:42

Install-Package Microsoft.AspNet.WebApi.HelpPage

Adding Help Documentation to a Web API REST Service

http://localhost:54212/Help

REST POST Build a REST Service in Visual Studio 2015 Part 1

Posted by 보미아빠

ncp c# apicall sample

분류없음 / 2018.08.30 14:19

using System;

using System.Collections.Generic;

using System.Threading.Tasks;

using System.Text;

using System.Net.Http;

using System.Threading;

using System.Diagnostics;

using System.Security.Cryptography;


namespace APITest

{

    public class Config

    {

        private static readonly Lazy<Config> lazy =

            new Lazy<Config>(() => new Config(), LazyThreadSafetyMode.ExecutionAndPublication);


        public static Config Instance { get { return lazy.Value; } }

        

        public string apiKey

        {

            get { return "apiGwKey"; }

        }

        public string accessKey

        {

            get { return "accessKey"; }

        }

        public string secureKey

        {

            get { return "secureKey"; }

        }

        public string ncpUrl

        {

            get { return @"https://ncloud.apigw.ntruss.com/clouddb/v1/"; }

        }

    }


    class Program

    {

        static void Main(string[] args)

        {

            Config config = Config.Instance;

            var postParams = new List<KeyValuePair<string, string>>();

            postParams.Add(new KeyValuePair<string, string>("dbKindCode", "MSSQL"));

            postParams.Add(new KeyValuePair<string, string>("responseFormatType", "json"));


            AsyncCall asyncCall = new AsyncCall();

            Task<string> t = asyncCall.NCloudApiCall("getCloudDBConfigGroupList", postParams, config.apiKey, config.accessKey, config.secureKey, config.ncpUrl);

            t.Wait();


            Console.WriteLine(t.Result);

        }

    }

    


    class AsyncCall

    {

        public async Task<string> NCloudApiCall(string action, List<KeyValuePair<string, string>> postParams, string apiKey, string accessKey, string secureKey, string ncpUrl)

        {

            string responseString = string.Empty;

            try

            {


                HttpClient client = Client.Instance.getClient();

                string timestamp = string.Empty;

                string sig = Auth.Instance.makePostSignature(action, ref timestamp, apiKey, accessKey, secureKey);


                string url = ncpUrl + action;

                var content = new FormUrlEncodedContent(postParams);


                client.DefaultRequestHeaders.Add("x-ncp-apigw-timestamp", timestamp);

                client.DefaultRequestHeaders.Add("x-ncp-apigw-api-key", apiKey);

                client.DefaultRequestHeaders.Add("x-ncp-iam-access-key", accessKey);

                client.DefaultRequestHeaders.Add("x-ncp-apigw-signature-v1", sig);


                var response = await client.PostAsync(url, content);

                responseString = await response.Content.ReadAsStringAsync();

            }

            catch (Exception e)

            {

                Console.WriteLine(e.Message);

            }

            return responseString;

        }

    }


    class Auth

    {

        private static readonly Lazy<Auth> lazy =

            new Lazy<Auth>(() => new Auth(), LazyThreadSafetyMode.ExecutionAndPublication);


        public static Auth Instance { get { return lazy.Value; } }


        public string makePostSignature(string action, ref string stringtimestamp, string apiKey, string accessKey, string secureKey)

        {

            if (string.IsNullOrEmpty(action))

                return "parameter error";


            long timestamp = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds;

            string space = " ";

            string newLine = "\n";

            string method = "POST";

            string url = @"/clouddb/v1/" + action;

            stringtimestamp = timestamp.ToString();


            string message = new StringBuilder()

                .Append(method)

                .Append(space)

                .Append(url)

                .Append(newLine)

                .Append(stringtimestamp)

                .Append(newLine)

                .Append(apiKey)

                .Append(newLine)

                .Append(accessKey)

                .ToString();


            Debug.WriteLine(message);


            byte[] secretKey = Encoding.UTF8.GetBytes(secureKey);

            HMACSHA256 hmac = new HMACSHA256(secretKey);

            hmac.Initialize();

            byte[] bytes = Encoding.UTF8.GetBytes(message);

            byte[] rawHmac = hmac.ComputeHash(bytes);


            Debug.WriteLine(Convert.ToBase64String(rawHmac));

            return Convert.ToBase64String(rawHmac);

        }

    }


    class Client

    {

        private static readonly Lazy<Client> lazy =

            new Lazy<Client>(() => new Client(), LazyThreadSafetyMode.ExecutionAndPublication);


        public static Client Instance { get { return lazy.Value; } }


        private readonly HttpClient client = new HttpClient();


        public HttpClient getClient()

        {

            return client;

        }

    }

}



Posted by 보미아빠

최근에 달린 댓글

최근에 받은 트랙백

글 보관함