2010. 4. 19. 16:35

dll 참조를 한다. (설치경로 참조)
 - Common.Logging.dll 1.2.0.0
 - Common.Logging.Log4Net.dll 1.2.0.2
 - log4net.dll 1.2.10.0

logging adaper에는 4가지의 로그를 설정할 수 있다.
 - NoOpLoggerFactoryAdapter : 설정없이 기본으로 사용된다.
 - ConsoleOutLoggerFactoryAdapter : console창에 로그가 나타난다.
 - TraceLoggerFactoryAdapter : System.Diagnostics.Trace for logging output 과 동일하다.
 - Log4NetLoggerFactoryAdapter : 

app.config 파일에서 아래와 같이 설정이 가능하다.

▲ configSection 설정
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <sectionGroup name="common">
      <section name="logging" type="Common.Logging.ConfigurationSectionHandler,              Common.Logging" />
    </sectionGroup>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
  </configSections>
   ...
</configuration>


▲ Common.Logging.Simple.TraceLoggerFactoryAdapter, Common.Logging 설정방식
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections ...>
   ...
    <common>
      <logging>
        <factoryAdapter type="Common.Logging.Simple.TraceLoggerFactoryAdapter, Common.Logging">
          <arg key="level" value="DEBUG" />
          <arg key="showLogName" value="true" />
          <arg key="showDataTime" value="true" />
          <arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:fff" />
        </factoryAdapter>
      </logging>
    </common>
   ...
</configuration>

▲ Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging 설정방식
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections ...>
   ...
  <common>
    <logging>
      <factoryAdapter type="Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging">
        <arg key="level" value="DEBUG" />
        <arg key="showLogName" value="true" />
        <arg key="showDataTime" value="true" />
        <arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:fff" />
      </factoryAdapter>
    </logging>
  </common>
   ...
</configuration>

▲ Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net 설정방식

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections ...>
   ...
  <common>
    <logging>
      <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
        <!-- choices are INLINE, FILE, FILE-WATCH, EXTERNAL-->
        <!-- otherwise BasicConfigurer.Configure is used   -->
        <!-- log4net configuration file is specified with key configFile-->
        <arg key="configType" value="INLINE" />
      </factoryAdapter>
    </logging>
  </common>
   ...
  <log4net debug="false">
    <root>
      <!-- TRACE, DEBUG, ERROR, FATAL, INFO, WARN -->
      <level value="ERROR"/>
      <appender-ref ref="RollingLogFileAppender_Piggy"/>
    </root>

    <logger name="HelloApp.Program">
      <level value="ERROR" />
    </logger>

    <logger name="Spring">
      <level value="INFO" />
    </logger>

    <appender name="LogFileAppender" type="log4net.Appender.FileAppender">
      <param name="File" value="Logs\Application.log.txt"/>
      <param name="datePattern" value="MM-dd HH:mm"/>
      <param name="AppendToFile" value="true"/>
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n"/>                         </layout>
    </appender>
    <appender name="HttpTraceAppender" type="log4net.Appender.ASPNetTraceAppender">
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n"/>
      </layout>
    </appender>
    <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n"/>
      </layout>
    </appender>
    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
      <param name="File" value="Logs\Log.txt"/>
      <param name="AppendToFile" value="true"/>
      <param name="MaxSizeRollBackups" value="10"/>
      <param name="MaximumFileSize" value="5MB"/>
      <param name="RollingStyle" value="Size"/>
      <param name="StaticLogFileName" value="true"/>
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n"/>
      </layout>
    </appender>
    <appender name="RollingLogFileAppender_Piggy"                                                      
                    type="log4net.Appender.RollingFileAppender">
      <param name="File" value="Logs\ExceptionLog"/>
      <param name="AppendToFile" value="true"/>
      <param name="MaxSizeRollBackups" value="10"/>
      <param name="MaximumFileSize" value="5MB"/>
      <param name="RollingStyle" value="Date"/>
      <param name="StaticLogFileName" value="false"/>
      <param name="DatePattern" value="yyyyMMdd&quot;.log&quot;"/>
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n"/>
      </layout>
    </appender>
  </log4net>
   로그를 찍는방법에는 종류는 4가지가 있다.
        - INLINE
        - FILE
        - FILE-WATCH
        - EXTERNAL

▲  c#에서 사용
using Common.Logging;
.......
ILog Log = LogManager.GetLogger(네임스페이스.클래스명);
Log.Debug("Debug");
Log.Fatal("Fatal");
Log.Error("Error");
Log.Info("Info");
Log.Warn("Warn");

참고
Posted by CoolDragon
2010. 4. 19. 11:55
DI를 하기위한 spring.net에서 제공하는 object 기본 생성 방식은 아래같다.
아래와 같은 방법외에 더 있다면 있는데로 추가하도록 하겠다.

▲ dll 참조추가
 - Spring.Core

▲ configSection 설정
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <sectionGroup name="spring">
      <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
      <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
    </sectionGroup>
  </configSections>
   ...
</configuration>


▲ object 설정

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections ...>

  <!-- 1. 같은 config 내에서 object 설정-->
  <spring>
    <context>
      <resource uri="config://spring/objects" />
    </context>
    <objects xmlns="http://www.springframework.net">
      <object name="name" type="namespace.class_name, assembly_name" singleton="true/false" />
      ...
    </objects>

  <!-- 2. 포함리소스 방식 -->
  <spring>
    <context>
      <resource uri="assembly://Spring.IocQuickStart.MovieFinder/
                         Spring.IocQuickStart.MovieFinder/AppContext.xml"/>
    </context>
  </spring>

  <!-- 3. object 별로 xml 분리하여 설정 -->
  <spring>
    <context>
      <resource uri="~/Config/CommonObjects.xml"/>

      <resource uri="~/Config/Production/Services.xml"/>

      <resource uri="file://%PROGRAMFILES%/myapp/ioc.config" />
    </context>
  </spring>

</configuration>

2번으로 할 경우는 필히 잊지말고 관련파일을 해당프로젝트(assembly)에 포함리소스로 변경해주어야 한다.



1,2,3을 혼용해서 사용이 가능한지 모르겠지만 개인적으로 3번처럼 구성하는게 좋아보인다.


▲ config에서 객체생성
  - 기본객체 생성
  - 프로퍼티 형식으로 객체 주입하여 생성
  - constructor의 생성자에 인자로 객체생성 방법

c#
using Spring.Context;
using Spring.Context.Support;
...
IApplicationContext ctx = ContextRegistry.GetContext();
IHello hello = (IHello)ctx.GetObject("MyHello");  // config의 object의 name과 일치
string result = hello.Say("CoolDragon");
Console.WriteLine(result);


Posted by CoolDragon
2010. 4. 19. 11:35
Spring.Net 프레임워크를 사용하기 위해 
app.config 또는 web.config에서 SectionGroup을 선언해주어야 한다.

그리고 이 선언을 통하여 하단부에 SectionGroup에 대한 본문(?)을 생성해야한다.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
     <!-- 어플리케이션에서 사용될 object를 생성하기 위한 설정  -->
    <sectionGroup name="spring">
      <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
      <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
    </sectionGroup>
    <sectionGroup name="common">
      <!-- 스프링 프레임워크에서 실행되는 로그를 보기위한 설정  -->
      <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
    </sectionGroup>
     <!-- 어플리케이션에서 찍고싶은 로그를 원하는 형태로 설정  -->
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
  </configSections>
...
</configuration>


Posted by CoolDragon
2010. 4. 14. 16:40

1. COM+ 개발
2. 개발 완료 후 서버에 Component 등록
   - 개발중에 snk를 생성하여 전역어셈블리캐쉬(GAC)에 등록한다.
   - regasm 명령어로 레지스트리 등록
3. 등록확인 
   - COM+는 제어판 > 구성요소 서비스에서 클래스명이 확인이 가능
   - COM은 레지스트리에서 GUID키값에서 ProgID에서 클래스명을 확인 가능
4. component 클래스명 및 interface를 확인
5. asp에서 아래 처럼 사용하면 된다.사용하기
<%
set complus   = Server.CreateObject("ComPlusExample.ComPlusClass")

Response.Write complus.PerformAddition(10, 30) & "<br/>"
Response.Write complus.PerformSubtraction(10, 30) & "<br/>"
%>


Posted by CoolDragon
2010. 4. 13. 11:23
asp.net ajax control toolkit를 사용하고자 한다면 
ScriptManager 관련 스크립트를 선언해주어야 한다.

아래와 같은 스크립트중 한가지를 사용하면 된다.

<asp:ScriptManager ID="ScriptManager1" runat="server" />
 - asp.net 에서 기본으로 제공

<ajaxToolkit:ToolkitScriptManager ID="ScriptManager1"  runat="server" />
 - ajax control toolkit 설치후 사용

그리고 두가지의 차이점은 정확히 모르는 관계로 성능적인 측면에 관련된 블로그를 참고하면 되겠다~
아래 성능으로만 보면 ajaxToolkit을 사용하는게 나은거 같은데 무조건 조은건지.... 해석해야하나..ㅋ


* 사용에 따른 Rendering


* Rendering에 따른 파일 다운로드
Posted by CoolDragon
2010. 4. 7. 20:03
asp.net에서 마스터페이지에 아래와 같이 설정이 되어있더라도
<form id="form1" runat="server">
..
</form>

렌더링된 결과를 보면  form태그의 id는 aspnetForm으로 자동 변경된다.
이를 방지하고 자신이 값으로 id를 지정하고 싶다면.. 첨부한 파일을 참고하길 바란다~

그럼 화이팅~
Posted by CoolDragon
2010. 4. 2. 12:44
c#문법으로 작성된 코드~

// 유입경로
Response.Write("HTTP_REFERER=" + Request.ServerVariables["HTTP_REFERER"]);
Response.Write("<br/>");
Response.Write("AbsoluteUri=" + Request.UrlReferrer.AbsoluteUri);
Response.Write("<br/>");
            
// 클라이언트 IP
Response.Write("REMOTE_ADDR=" + Request.ServerVariables["REMOTE_ADDR"]);
Response.Write("<br/>");            
Response.Write("UserHostAddress=" + Request.UserHostAddress);
Response.Write("<br/>");
            
// 사용 브라우저 체크
Response.Write("HTTP_USER_AGENT=" + Request.ServerVariables["HTTP_USER_AGENT"]);
Response.Write("<br/>");
Response.Write("Browser=" + Request.Browser.Browser);
Response.Write("<br/>");

// 브라우저의 사용 언어
Response.Write("http_accept_language=" + Request.ServerVariables["http_accept_language"]);
Response.Write("<br/>");
Posted by CoolDragon
2010. 3. 16. 16:06
아직 이해단계라 별다른 소스는 없다. 
별로 대단한 것은 없지만 나중에 다시 상기해야 할 것이기에 정리하여 블로깅 한다.

--------------------------선언하기--------------------------
MyJS = function()
{
// private 변수
var _value = "";
MyJS.prototype.init();
}

// 초기화
MyJS.prototype.init = function()
{
_value = "test";
}

MyJS.prototype.toString = function()
{
_value = "기본 toString override를 한다.";
}

// 값을 가져온다.
MyJS.prototype. GetValue = function()
{
return _value;
}

// 값을 설정한다.
MyJS.prototype.SetValue = function(value)
{
      _value = value;
}

------------------------사용하기------------------------
var myJs = new MyJS();
myJs.SetValue("클래스스타일 자바스크립트");
var value = myJs.GetValue();


조금 더 자세하고 상세한 자바스크립트는 아래 링크를 살짝 참고한다.(영어다 소스만 보자 ㅋ)
Posted by CoolDragon
2009. 11. 2. 10:26
ASP.NET에서 동적으로 자바스크립트를 추가하기는 어렵지 않다.




[비하인드 코드]

        protected void Page_Load(object sender, EventArgs e)
        {
            // <form> 태그 뒤에 include되는 자바스크립트 파일 포함
            ClientScript.RegisterClientScriptInclude(typeof(Page), "script", "http://localhost/test.js");
            // <form> 태그 뒤에 자바스크립트 포함
            ClientScript.RegisterClientScriptBlock(typeof(Page), "script1", "<script>test('test1');</script>");
            // </form> 태그 앞에 자바스크립트 포함
            ClientScript.RegisterStartupScript(typeof(Page), "script2", "<script>test('test2');</script>");
        }


[소스보기 코드]
...
<form name="form1" method="post" action="WebForm2.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2MTY2ODcyMjlkZL22/OKqbu9X9AK4DAtdxYHrs6Rj" />
</div>
<script src="http://localhost/test.js" type="text/javascript"></script>
<script>test('test1');</script>
    <div>
    .......
    </div>
   
<script>test('test2');</script>
</form>
.....


단.. 유념해야할 사항은 여는 form태그에 뒤에 생성되냐 닫는 form 태그 앞에 생성되냐에
따라 정상적으로 실행되는 자바스크립트가 있을수도 있지만 html이 생성되지 않은 컨트롤에
접근하는 코드가 존재하면 오류가 발생할 수도 있다.
Posted by CoolDragon
2009. 10. 28. 14:39

포스트를 열심히 올리고자 마음 먹었지만
전혀 올리지 못 하고있었다. (마음만 앞섰을 뿐이고.. 그리고 귀찮았을 뿐이고..)
뭐 암튼 간만에 포스팅을 한다.

c#에서 DataTable 클래스에서 DataTable끼리의 Merge와 Sort가 있다. (그 밖에도 많겠지...)

대략 소스와 주석으로 설명을 대신하고자 한다.

 private void button1_Click(object sender, EventArgs e)
        {
            DataTable dt = GetData(1, 3);
            DataTable dt2 = GetData(2, 5);

// Merge
            DataTable dt3 = dt.Copy();
            dt3.PrimaryKey = new DataColumn[] { dt3.Columns["A"] };
            dt3.Merge(dt2);

// Sort
            DataView view = dt3.DefaultView;
            view.Sort = "B DESC, A ASC, C DESC";

            this.dataGridView1.DataSource = dt;
            this.dataGridView2.DataSource = dt2;
            this.dataGridView3.DataSource = view.ToTable();
        }

        DataTable GetData(int from, int to)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("A");
            dt.Columns.Add("B");
            dt.Columns.Add("C");
            Random rnd = new Random((int)DateTime.Now.Ticks);
            for (int i = from; i <= to; i++)
            {
                DataRow dr = dt.NewRow();
                dr["A"] = i;
                dr["B"] = rnd.Next(1, 5);
                dr["C"] = rnd.Next(1, 5);
                dt.Rows.Add(dr);
            }
            return dt;
        }


추가적인 설명으로
a.Merge(b); 처럼 Merge할 경우 b테이블의 데이터를 a테이블에 포함시키는 거라 할 수 있다.
만약 DataTable의 PrimaryKey 설정을 한다면 b테이블 데이터중 a테이블의 Key 컬럼과 중복되는 데이터를 제외한 데이터가 a테이블로 포함된다. (이해를 돕고자 이미지를 첨부)

PrimaryKey 설정 전

PrimaryKey 설정 후






Posted by CoolDragon