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
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
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;
}
}
}
[bot 만들기]
텔레그램 안에서 BotFather 친구 맺음
/start
/newbot
yourbotname
yourbotname_bot
Use this token to access the HTTP API:
0000000:VVVhJhOKsTl_2Vppzc93OKsOd0PpLVcVZlM
For a description of the Bot API, see this page: https://core.telegram.org/bots/api
/token
@yourbotname_bot
[그룹만들어 봇 초대하기]
인간 사용자가 그룹을 만들어
봇 사용자가 그룹을 찾아 들어감 Add to Group
[봇이 들어간 group 내 사용자 리스트 구하기]
https://api.telegram.org/bot00000000:fdsafdsafda_dsafdsafdas/getUpdates
id 양수는 개인
id 음수는 그룹
-- 이제 코딩
https://github.com/TelegramBots/Telegram.Bot.Examples/blob/master/Telegram.Bot.Examples.Echo/Program.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telegram.Bot;
using Telegram.Bot.Args;
using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.InlineQueryResults;
using Telegram.Bot.Types.ReplyMarkups;
namespace telegramtest2
{
class Program
{
private static readonly TelegramBotClient Bot = new Telegram.Bot.TelegramBotClient("botid");
//private static readonly TelegramBotClient Bot = new Telegram.Bot.TelegramBotClient("botid");
static void Main(string[] args)
{
Bot.OnMessage += Bot_OnMessage;
var me = Bot.GetMeAsync().Result;
Console.Title = me.Username;
//SendMsg(5646546464565, "메롱2");
/// Recv Start
Bot.StartReceiving();
Console.ReadLine();
/// Recv Stop
Bot.StopReceiving();
Console.ReadKey();
}
private static async void SendMsg(long chatId, string message)
{
await Bot.SendTextMessageAsync(chatId, message);
}
private static async void Bot_OnMessage(object sender, Telegram.Bot.Args.MessageEventArgs messageEventArgs)
{
var message = messageEventArgs.Message;
if (message.Text.StartsWith("/cmd"))
{
Console.WriteLine(message.Chat.Id);
Debug.WriteLine(message.Chat.Id);
await Bot.SendTextMessageAsync(message.Chat.Id, "나한테 일시키기 마라");
}
}
}
}
class Program
{
static void Main(string[] args)
{
List<Task<string>> lists = new List<Task<string>>();
Program p = new Program();
lists.Add(p.Run2());
lists.Add(p.Run());
foreach (var a in lists)
a.Wait(); // 모두 기다리고 출력
foreach (var a in lists)
Console.WriteLine(a.Result); // 5초 응답
}
async Task<string> Run()
{
var a = Task.Delay(1000);
var b = Task.Delay(1000);
var c = Task.Delay(1000);
var d = Task.Delay(1000);
var e = Task.Delay(1000);
await a;
await b;
await c;
await d;
await e;
Thread.Sleep(3000); // 전체 처리시간 4초
return DateTime.Now.ToString();
}
async Task<string> Run2()
{
await Task.Delay(1000);
await Task.Delay(1000);
await Task.Delay(1000);
await Task.Delay(1000);
await Task.Delay(1000); // 전체 처리시간 5초
return DateTime.Now.ToString();
}
}
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//using System.Configuration;
//using System.Threading;
//namespace ConsoleApp1
//{
// public class EvenNumberEventArgs : EventArgs
// {
// public EvenNumberEventArgs(int i)
// {
// this.I = i;
// }
// public int I { get; set; }
// }
// class Program
// {
// static void Main(string[] args)
// {
// new Program().Run();
// }
// void Run()
// {
// Config config = Config.Instance;
// EventProcess ep = new EventProcess();
// //Console.WriteLine(config.SampleApplication);
// for (int i = 0; i < 10; i++)
// {
// config.NumberCheck(i);
// }
// }
// }
// public sealed class Config
// {
// private static readonly Lazy<Config> lazy =
// new Lazy<Config>(() => new Config(), LazyThreadSafetyMode.ExecutionAndPublication);
// public static Config Instance { get { return lazy.Value; } }
// private Config()
// {
// //this.SampleApplication = ConfigurationManager.AppSettings["sampleApplication"];
// }
// //public string SampleApplication { get; } = string.Empty;
// public event EventHandler<EvenNumberEventArgs> MyEvent;
// public void NumberCheck(int i)
// {
// if (i % 2 == 0)
// MyEvent?.Invoke(this, new EvenNumberEventArgs(i));
// }
// }
// class EventProcess
// {
// public EventProcess()
// {
// Config.Instance.MyEvent += EvenNumber;
// }
// void EvenNumber(object o, EvenNumberEventArgs args)
// {
// Console.WriteLine(o.GetType());
// Console.WriteLine(string.Format("this is even Number : {0}", args.I));
// }
// }
//}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
new Program().Run();
}
void Run()
{
Config config = Config.Instance;
new EventProcess();
//Console.WriteLine(config.SampleApplication);
for (int i = 0; i < 10; i++)
{
config.NumberCheck(i);
}
}
}
public sealed class Config
{
private static readonly Lazy<Config> lazy =
new Lazy<Config>(() => new Config(), LazyThreadSafetyMode.ExecutionAndPublication);
public static Config Instance { get { return lazy.Value; } }
private Config()
{
//this.SampleApplication = ConfigurationManager.AppSettings["sampleApplication"];
}
public Action<object, EvenNumberEventArgs> MyEvent;
public void NumberCheck(int i)
{
if (i % 2 == 0)
MyEvent?.Invoke(this, new EvenNumberEventArgs(i));
}
public class EvenNumberEventArgs : EventArgs
{
public EvenNumberEventArgs(int i)
{
this.I = i;
}
public int I { get; set; }
}
}
class EventProcess
{
public EventProcess()
{
Config.Instance.MyEvent += EvenNumber;
}
void EvenNumber(object o, Config.EvenNumberEventArgs args)
{
Console.WriteLine(o.GetType());
Console.WriteLine(string.Format("this is even Number : {0}", args.I));
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ObserverGoFCSharp2
{
class Program
{
static void Main(string[] args)
{
var ep = new EventPublisher();
var eo1 = new EventObserver1(ep);
var eo2 = new EventObserver2(ep);
eo1.EventAttach();
eo2.EventAttach();
ep.Run();
}
}
class EventPublisher // Subject // 나는 모르겠고 이런일이 있었어 니가 알아서 해~
{
//public event EventHandler<MyEventArgs> MyEvent;
public Action <object, MyEventArgs> MyEvent;
public EventPublisher()
{
}
public void Run()
{
for (int i = 0; i < 20; i++)
{
if (i % 2 == 0)
{
//Console.WriteLine($"even number : {i}");
MyEvent?.Invoke(this, new MyEventArgs
{
ArgType = "even number",
ArgData1 = i
});
}
else
{
//Console.WriteLine($"odd number : {i}");
MyEvent?.Invoke(this, new MyEventArgs
{
ArgType = "odd number",
ArgData1 = i
});
}
}
}
public class MyEventArgs : EventArgs
{
public string ArgType { get; set; }
public int ArgData1 { get; set; }
}
}
class EventObserver1 // 오 ~ 짝수네~ 하고 실행
{
EventPublisher ep;
public EventObserver1(EventPublisher ep)
{
this.ep = ep;
}
public void EventAttach()
{
this.ep.MyEvent += ObserverCallback;
}
public void EventDetach()
{
this.ep.MyEvent -= ObserverCallback;
}
private void ObserverCallback(object sender, EventPublisher.MyEventArgs args)
{
if (args.ArgType.Equals("even number", StringComparison.OrdinalIgnoreCase))
{
if (args.ArgData1 > 5)
EventDetach();
Console.WriteLine($"even number : {args.ArgData1}");
}
}
}
class EventObserver2 // 오 ~ 홀수네~ 하고 실행, 10 이 넘으면 그만 수신할래....까지 찍힘
{
EventPublisher ep;
public EventObserver2(EventPublisher ep)
{
this.ep = ep;
}
public void EventAttach()
{
this.ep.MyEvent += ObserverCallback;
}
public void EventDetach()
{
this.ep.MyEvent -= ObserverCallback;
}
private void ObserverCallback(object sender, EventPublisher.MyEventArgs args)
{
if (args.ArgType.Equals("odd number", StringComparison.OrdinalIgnoreCase))
{
if (args.ArgData1 > 10)
EventDetach();
Console.WriteLine($"odd number : {args.ArgData1}");
}
}
}
}
/****** Object: UserDefinedFunction [dbo].[F_NUMERIC_TO_BASE_N] Script Date: 5/29/2018 6:07:05 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create function [dbo].[F_NUMERIC_TO_BASE_N]
(
@Number numeric(32,0),
@Base int
)
returns varchar(110)
as
/*
Function: F_NUMERIC_TO_BASE_N
Function F_NUMERIC_TO_BASE_N converts a numeric(32,0) value, @Number,
to a string of digits in number base @Base,
where @Base is between 2 and 36.
Output digits greater than 9 are represented by
uppercase letters A through Z, where A = 10 through Z = 35.
If input parameter @Number is negative, the output string
will have a minus sign in the leftmost position.
Any non-null numeric(32,0) value for parameter @Number is valid:
-99999999999999999999999999999999 through
99999999999999999999999999999999.
If input parameters @Number or @Base are null,
or @Base is not between 2 and 36,
then the function returns a null value.
*/
begin
declare @Work_Number numeric(38,0)
declare @Modulus int
declare @Digits varchar(36)
declare @Output_String varchar(110)
if @Number is null or @Base is null or @Base < 2 or @Base > 36
begin
return null
end
set @Digits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
set @Output_String = ''
set @Work_Number = @Number
while 1=1
begin
Set @Modulus = convert(int,abs(@Work_Number-(round(@Work_Number/@Base,0,1)*@Base)))
set @Output_String = substring(@Digits,@Modulus+1,1) + @Output_String
set @Work_Number = round(@Work_Number/@Base,0,1)
if @Work_Number = 0 break
end -- end while
if @Number < 0 set @Output_String = '-'+@Output_String
return @Output_String
end
GO
declare @times bigint = 1
declare @top_count bigint = 1000
select dbo.[F_NUMERIC_TO_BASE_N](@times * 100000000 + rn * 1000 , 32)
from
(
select top (@top_count) row_number() over (order by (select 1)) rn
from sysobjects a
cross join sysobjects b
cross join sysobjects c
) a
https://m.blog.naver.com/PostView.nhn?blogId=lauf1&logNo=220781453020&proxyReferer=https%3A%2F%2Fwww.google.co.kr%2F
ista-d torrent
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace mtest2
{
class Config
{
public class Item : IEquatable<Item>
{
private readonly string _X;
private readonly string _Y;
public Item(string x, string y)
{
_X = x;
_Y = y;
}
public string X
{
get { return _X; }
}
public string Y
{
get { return _Y; }
}
public override int GetHashCode()
{
return _X.GetHashCode() ^ _Y.GetHashCode();
}
public bool Equals(Item other)
{
if (_X != other._X)
return false;
return _Y == other._Y;
}
}
}
}
// tuple 이용하기 .net 4.0 이상 조오타~~~
//-----------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace mtest2
{
class Program
{
static void Main(string[] args)
{
Dictionary<Tuple<string, string>, string> dicReloadedItems = new Dictionary<Tuple<string, string>, string>();
Dictionary<Tuple<string, string>, string> dicCurrentItems = new Dictionary<Tuple<string, string>, string>();
dicReloadedItems.Add(new Tuple<string, string>("1key", "1value"), "dic.1value");
dicReloadedItems.Add(new Tuple<string, string>("2key", "2value"), "dic.2value");
dicReloadedItems.Add(new Tuple<string, string>("3key", "3value"), "dic.3value");
dicCurrentItems.Add(new Tuple<string, string>("3key", "3value"), "dic.3value");
dicCurrentItems.Add(new Tuple<string, string>("4key", "4value"), "dic.4value");
foreach (var dicReloadedItem in dicReloadedItems)
{
if (!dicCurrentItems.ContainsKey(dicReloadedItem.Key))
{
Console.WriteLine(string.Format("a{0}, {1}", dicReloadedItem.Key.Item1, dicReloadedItem.Key.Item2));
}
}
Console.ReadKey();
}
}
}
디폴트 인스턴스에 모든 traceflag 를 다 지우고 변수에 있는것들만 추가해준다.
#Get SQL Server Instance Path:
$TraceFlags = "-T1117 -T1118"
$SQLService = "SQL Server (MSSQLSERVER)";
$SQLInstancePath = "";
$SQLServiceName = ((Get-Service | WHERE { $_.DisplayName -eq $SQLService }).Name).Trim();
If ($SQLServiceName.contains("`$")) { $SQLServiceName = $SQLServiceName.SubString($SQLServiceName.IndexOf("`$")+1,$SQLServiceName.Length-$SQLServiceName.IndexOf("`$")-1) }
foreach ($i in (get-itemproperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server").InstalledInstances)
{
If ( ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL").$i).contains($SQLServiceName) )
{ $SQLInstancePath = "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\"+`
(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL").$i}
}
$SQLInstancePath
#Delete All Param
$ParamCount = (Get-ItemProperty "$SQLInstancePath\MSSQLServer\Parameters" | Select SQLArg* | Format-List | Out-String ).Split(":").Count -8
for ($i=0; $i -le $ParamCount; $i++)
{
$ParamNumber = $i + 3
Remove-ItemProperty -Path "$SQLInstancePath\MSSQLServer\Parameters" -Name ("SQLArg$ParamNumber")
}
#Add New Param
$ParamNumber = 3
$TraceFlags.Split(" ") | ForEach {
$ParamValue = "$_"
New-ItemProperty -Path "$SQLInstancePath\MSSQLServer\Parameters" -Name ("SQLArg$ParamNumber") -Value $ParamValue -PropertyType String -Force | Out-Null
$ParamNumber++
}
(Get-ItemProperty "$SQLInstancePath\MSSQLServer\Parameters" | Select SQLArg* | Format-List | Out-String ).trim() -replace "SQLArg","`tSQLArg"