2017. 2. 24. 12:39

어떤 현업께서 IIS가 자동으로 설치가 가능하냐고 물었다. (다 되는건 아니니까 난 안된다고 했다. ㅋㅋ)

OS의 지원 여부에 따라서 command line 또는 powershell로 설치가 가능 할 것 같다. 이 기능을 이용하여 OS가 부팅되면 IIS의 설치여부를 비교하여 설치 명령어를 실행시키면 되지 않을까 하는게 본 필자의 생각이다.


1) 필자는 C# 을 주로 다루는 개발자이므로 아래의 코드와 같이 레지스트리를 비교하여 IIS설치여부를 비교한다.

private static bool IsIisInstalled() => Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp", "VersionString", null) != null;

※ HKLM\Software\Microsoft\InetStp\MajorVersion 레지스트리를 통해 설치버전도 비교 가능



2) command에서 사용할 수 있는 설치명령어로 IIS를 설치한다.

pkgmgr은 deprecated 되었다고 해서 DISM을 사용하라고 하는데 내 OS(Windows 10)에서는 설치가 가능했다.

다른 OS버전에서는 사용이 가능한지는 해당 OS에서 적용해봐야지 알 수 있을 것 같다.


일반권한으로 실행해도 가능

c:\> start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-ApplicationDevelopment;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-NetFxExtensibility45;IIS-ASPNET45;NetFx4Extended-ASPNET45;IIS-NetFxExtensibility;IIS-ASPNET;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-RequestMonitor;IIS-Security;IIS-RequestFiltering;IIS-HttpCompressionStatic;IIS-WebServerManagementTools;IIS-ManagementConsole;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI


관리자권한으로 실행

c:\> START /WAIT DISM /Online /Enable-Feature /FeatureName:IIS-ApplicationDevelopment /FeatureName:IIS-ASP /FeatureName:IIS-ASPNET /FeatureName:IIS-ASPNET45 /FeatureName:IIS-BasicAuthentication /FeatureName:IIS-CGI /FeatureName:IIS-ClientCertificateMappingAuthentication /FeatureName:IIS-CommonHttpFeatures /FeatureName:IIS-CustomLogging /FeatureName:IIS-DefaultDocument /FeatureName:IIS-DigestAuthentication /FeatureName:IIS-DirectoryBrowsing /FeatureName:IIS-FTPExtensibility /FeatureName:IIS-FTPServer /FeatureName:IIS-FTPSvc /FeatureName:IIS-HealthAndDiagnostics /FeatureName:IIS-HostableWebCore /FeatureName:IIS-HttpCompressionDynamic /FeatureName:IIS-HttpCompressionStatic /FeatureName:IIS-HttpErrors /FeatureName:IIS-HttpLogging /FeatureName:IIS-HttpRedirect /FeatureName:IIS-HttpTracing /FeatureName:IIS-IIS6ManagementCompatibility /FeatureName:IIS-IISCertificateMappingAuthentication /FeatureName:IIS-IPSecurity /FeatureName:IIS-ISAPIExtensions /FeatureName:IIS-ISAPIFilter /FeatureName:IIS-LegacyScripts /FeatureName:IIS-LegacySnapIn /FeatureName:IIS-LoggingLibraries /FeatureName:IIS-ManagementConsole /FeatureName:IIS-ManagementScriptingTools /FeatureName:IIS-ManagementService /FeatureName:IIS-Metabase /FeatureName:IIS-NetFxExtensibility /FeatureName:IIS-NetFxExtensibility45 /FeatureName:IIS-ODBCLogging /FeatureName:IIS-Performance /FeatureName:IIS-RequestFiltering /FeatureName:IIS-RequestMonitor /FeatureName:IIS-Security /FeatureName:IIS-ServerSideIncludes /FeatureName:IIS-StaticContent /FeatureName:IIS-URLAuthorization /FeatureName:IIS-WebDAV /FeatureName:IIS-WebServer /FeatureName:IIS-WebServerManagementTools /FeatureName:IIS-WebServerRole /FeatureName:IIS-WindowsAuthentication /FeatureName:IIS-WMICompatibility /FeatureName:WAS-ConfigurationAPI /FeatureName:WAS-NetFxEnvironment /FeatureName:WAS-ProcessModel /FeatureName:WAS-WindowsActivationService


※ 이외에 다른방법은 분명히 있을 것이 분명하므로 이것만이 정답은 아님을 말씀드립니다.


참고:

http://stackoverflow.com/questions/37846864/how-to-know-iis-installed-or-not-programmatically

http://stackoverflow.com/questions/32097336/programmatically-enable-install-iis

Posted by CoolDragon
2017. 1. 11. 10:47

로또 번호 수집기

LottNumberoCollector.zip



1. HttpClient를 이용하여 html 다운로딩 후

2. HttpAgilityPack 패키지를 이용한 HTML 파싱


Posted by CoolDragon
2016. 11. 2. 17:57

When you create a project on Gitlab, you have to set ssh key on it.

Let's see how to set on the page.


1. Create public SSH Key

 - by git bash

 - by PuttyGen

   1) Download PuttyGen

   2) Click Generate button and rolling mouse on the application

   3) Copy the SSH Key on the red box (public key)

2. Register SSH Key on GitLab

  Move to "Profile Settings" page

"Click SSH Keys" Link

Paste the SSH Key that you copied on the textbox that it has been created


※ PrivateKey has to be kept for push and pull command. In SourceTree, PrivateKey can be set as below.




Posted by CoolDragon
2016. 11. 2. 15:09

A few years ago, I tried to set up Jenkins on Windows server for projects written in c#. However, I've almost forgotten to use them. So I am going to build a deployment system that uses Git and Jenkins.


Step)

- [Jenkins] Installation on Window

- [Jenkins] Configuration

- [Jenkins] Build source code

- [Jenkins] Deployment


Here's the first step.


1) Download

https://jenkins.io/

When you unzip the downloaded file, there is an install file named "jenkins.msi".


2) Install

2.1) Wizard

You'd better change install directory that does not include space.


2.2) Jenkins

After installation, a web browser shows up and, keep setting basic configurations of Jenkins.

Customize Jenkins

- Install suggested plugins: automatically install plugins

- Select plugins to install: manually install plugins


Completed install of Jenkins

If you want to change the basic port(8080), it can be changed to "C:\Jenkins\jenkins.xml" file, and Jenkins service must restart.


※ If you want to use git, install git on the same server.

Posted by CoolDragon
2016. 10. 26. 13:28

1.Windows

1) java sdk 설치

 - download: http://java.sun.com

 - 환경변수 설정

   JAVA_HOME 변수 추가: jdk 설치 경로

   Path 설정: ~~~;%JAVA_HOME%\bin; 추가


2) Tomcat

  - download: http://tomcat.apache.org

  - 압축풀면 해당 경로가 사용경로가 된다.


3) 이클립스 설치

 - download: http://www.eclipse.org (Eclipse IDE for Java EE Developers)

 - 이클립스 tomcat 서버 연동

   > Wiindow > Show View > Other... 메뉴 선택 후 화면에서 Server 선택

   > Servers 탭에서 "No servers are available. Click this link to create a new server... 를 클릭 후 설치한 Apache 버전을 선택후 Next > Tomcat installation directory를 선택 tomcat 설치 경로를 설정, JRE는 jre1.8.0_xxx로 변경 한 후 Finish

   > Servers 에서 Tomcat vx.x Server at localhost를 클릭하여 tomcat 설정

     >> Server Locations에서 "Use Tomcat installation (takes control of Tomcat installation)을 선택

     >> Server Options 에서 "Publish module contexts to separate XML files를 체크

     >> Ports 에서 HTTP/1.1를 8080에서 다른포트(8181)를 선택


2. Linux




Posted by CoolDragon
2016. 6. 20. 14:03

Syntax

- IF ELSE 구문

CASE 구문

- Truncate Table


Function

- DATETIME_FORMAT()

- IFNULL()

CONCAT

STR_TO_DATE

LPAD

LAST_INSERT_ID

Posted by CoolDragon
2016. 5. 26. 14:17

c#에서의 정규식

string tmp = System.Text.RegularExpressions.Regex.Replace("abce!@#%123123가나다라", "[^0-9a-zA-Zㄱ-힗]+", "");

Posted by CoolDragon
2016. 5. 25. 12:20

아래 코드를 입력하면 클래스 오브젝트를 XML 또는 JSON 타입으로 리턴시켜준다.

[Global.aspx]

public class Global : HttpApplication
{
    void Application_Start(object sender, EventArgs e)
    {
        // 응용 프로그램 시작 시 실행되는 코드
        AreaRegistration.RegisterAllAreas();
        GlobalConfiguration.Configure(WebApiConfig.Register);
        RouteConfig.RegisterRoutes(RouteTable.Routes);

        // Content-type 전역지정
        GlobalConfiguration.Configuration.Formatters.Clear();
        //GlobalConfiguration.Configuration.Formatters.Add(new System.Net.Http.Formatting.XmlMediaTypeFormatter());
        GlobalConfiguration.Configuration.Formatters.Add(new System.Net.Http.Formatting.JsonMediaTypeFormatter());
    }
}


Posted by CoolDragon
2016. 5. 12. 18:03

$ sudo wget "URL"

Posted by CoolDragon
2016. 5. 12. 15:22

1. 다운로드

리눅스 및 맥, 윈도우즈등 다양한 플랫폼을 지원한다.

http://www.planetcassandra.org/cassandra/


2. 설치

윈도우환경에서 개발할 것이므로 윈도우 MSI installer를 다운로드받고 설치를 한다. 설치 과정은 특별히 선택할게 없었다.

설치 후 윈도우 메뉴에서 아래의 이미지처럼 설치 결과를 확인할 수 있다.

3. 실행 및 데이터베이스 생성

Cassandra CQL Shell을 실행하면 카산드라 콘솔이 생성되며 아래의 스크립트를 추가해본다. 

(본 블로거도 카산드라 초보이므로 카산드라 웹사이트에서 참고하여 대충 만들었다.)

CREATE KEYSPACE demo
  WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };

CREATE TABLE demo.users (
  lastname text PRIMARY KEY,
  age int,
  city text,
  email text,
  firstname text
);

DROP TABLE demo.users;

4. C# 프로젝트

Nu-Get을 통하여 driver를 설치

Install-Package CassandraCSharpDriver
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cassandra;

namespace CassandraSample
{
    class Program
    {
        static void Main(string[] args)
        {
            Cluster cluster = Cluster.Builder().AddContactPoint("127.0.0.1").Build();
            ISession session = cluster.Connect("demo");

            session.Execute("insert into users (lastname, age, city, email, firstname) values ('Jones', 35, 'Austin', 'bob@example.com', 'Bob')");

            Row result = session.Execute("select * from users where lastname = 'Jones'").First();
            Console.WriteLine("{0} {1}", result["firstname"], result["age"]);
            Console.ReadLine();

            session.Execute("update users set age = 36 where lastname = 'Jones'");
            Row result2 = session.Execute("select * from users where lastname = 'Jones'").First();
            Console.WriteLine("{0} {1}", result2["firstname"], result2["age"]);
            Console.ReadLine();

            session.Execute("delete from users where lastname = 'Jones'");
            RowSet rows = session.Execute("select * from users");
            foreach (Row row in rows)
                Console.WriteLine("{0} {1}", result2["firstname"], result2["age"]);

            Console.ReadLine();
        }
    }
}

5. 결론

그냥 실행만 해보는 수준이다 보니 카산드라가 다른 NoSQL이나 MSSQL과 같은 DB에서 지원하는 기능을 얼마나 지원해주고 더 나은 부분을 확인은 할 수 없었다. 다만, 위에 보는 거와 같이 쉽게 연동이 가능해 보이며 ANSI SQL을 지원하기에 이미 MSSQL, ORACLE, MYSQL의 DB를 사용해본 사람이라면 쉽게 접근할 수 있지 않을까 싶다.


Reference: https://academy.datastax.com/resources/getting-started-apache-cassandra-and-c-net

Posted by CoolDragon