잊지 않겠습니다.

'분류 전체보기'에 해당되는 글 430건

  1. 2009.01.08 Pro LINQ (03)
  2. 2009.01.07 Pro LINQ (02)
  3. 2009.01.07 Pro LINQ (01)
  4. 2009.01.07 사다리 게임
  5. 2009.01.07 비스타 탐색기 오류 수정 방법
  6. 2009.01.07 WM_NULL message의 이용
  7. 2009.01.07 Windows Server Core System
  8. 2009.01.07 Wceload.exe
  9. 2009.01.07 Windows Mobile 교육 - 3rd day
  10. 2009.01.07 Windows Mobile 교육 - 2rd day

Pro LINQ (03)

Book 2009. 1. 8. 00:28
먼저 설명된 select, take 등이 지연된 operation이라면, 모든 Action이 호출즉시 나오게 된다. 이럴 경우에는 LINQ가 가진 속도의 장점을 잃어버리게 된다. 그렇지만 모든 객체를 한번에 얻어와서 일을 처리하게 될 경우에는 보다더 용의하게 된다. 

    public class DataContextLinq
    {
        public void QueryDatas()
        {
            NorthwindDataContext dbContext = new NorthwindDataContext(@"Data Source=Y2K\SQLEXPRESS;Initial Catalog=AdventureWorks;Integrated Security=True");
            dbContext.Log = Console.Out;

            Console.WriteLine("Queried datas - Start");
            var products = (from p in dbContext.Products where p.Color == "Red" select p.Name).ToList();
            Console.WriteLine("Queried datas - End");
            
            Console.WriteLine("Deferred Operation - Start");
            foreach(string productName in products)
            {
                Console.WriteLine(productName);
            }
        }
    }

결과는 다음과 같다. 

차이를 보면, 값을 얻어오는 순간 모든 Query가 실행이 되고, 전 값을 다 얻어오게 된다. 
nondeferred operation은 다음과 같다. 

ToArray()
ToList()
ToDictionary()
ToLookup()
First()
FirstOrDefault()
LastOrDefault()
Single()
SingleOrDefault()
ElementAt()
Sum()
Max()
Min()
etc.... 


경우에 따라 deferred operation과 non-deferred operation의 사용을 달리해줄 필요가 있다. 많은 양의 데이터를 가지고 온다면 deferred operation이 속도 면에서 더 나은 선택이 되지만, 많은 데이터에 대해서 일괄처리를 하게 될 경우에는 non-deferred operation이 선택이 될 수 있다. 











Posted by Y2K
,

Pro LINQ (02)

Book 2009. 1. 7. 18:50
LINQ에서 사용되는 select, where, selectmany는 지연된 동작(deferred operation)을 행한다.

LINQ query가 실행하는 동시에 각 객체를 얻어내고 실행하는 것이 아닌, 결과가 이용될 때에 각각의 객체를 얻어오는 형식이 된다. 

다음과 같은 예제 LINQ query를 보면..
    public class DataContextLinq
    {
        public void QueryDatas()
        {
            NorthwindDataContext dbContext = new NorthwindDataContext(@"Data Source=Y2K\SQLEXPRESS;Initial Catalog=AdventureWorks;Integrated Security=True");
            dbContext.Log = Console.Out;

            Console.WriteLine("Queried datas - Start");
            var products = from p in dbContext.Products where p.Color == "Red" select p;
            Console.WriteLine("Queried datas - End");

            Console.WriteLine("Deferred Operation - Start");
            foreach(Product product in products)
            {
                Console.WriteLine(product.Name);
            }
        }
    }

여기에서 var products = from p in dbContext.Products where p.Color == "Red" select p; 에서 검색이 이루어지는 것이 아닌, 각 객체를 얻어낼 때에 그 Query를 던지게 된다. 결과는 다음과 같다. 



이는 foreach 문에서 기존의 DataReader에서 MoveNext() 구문을 호출하게 되는 것과 동일하게 움직이게 된다. 
또한 값을 처음호출할때, DB에 대한 Connection을 연결하기 때문에, DBContext 객체의 경우에는 생성 및 삭제에서 조금 덜 엄격한 IDispose role을 따르게 된다. 
Posted by Y2K
,

Pro LINQ (01)

Book 2009. 1. 7. 18:13
LINQ(Language-Integrated Query)는 .NET Programmer들에게 프로그램의 개발방향을 새로 만들어줬다고 해도 과언이 아니다. 무엇보다 그전까지 사용하고 있던 모든 DB에 대한 O/R mapping을 쓸데 없게 만들어버린 것 뿐 아니라 모든 데이터에 대한 객체화를 만들 수 있었다는 점에서 LINQ의 위대함이 더 보이는 것 같다. 

검색, 정렬, 다른 객체와의 Join, Grouping 모든 것을 다 LINQ를 통해서 할 수 있다는 점은 LINQ에 대한 매력을 더욱더 가지고 오게 한다. 

먼저 간단한 Hello LINQ 소스를 보면..

    public class HelloLinq
    {
        public void Hello()
        {
            string[] greetings = { "Hello world", "hello LINQ", "Hello Apress" };
            var items = from s in greetings where s.EndsWith("LINQ") select s;

            foreach(string item in items)
            {
                Console.WriteLine(item);
            }
        }
    }

    public class XmlLinq
    {
        public void FindBook()
        {
            XElement books =
                XElement.Parse(
                    @"<books>
                        <book>
                        <title>Pro LINQ: Language Integrated Query in C# 2008</title>
                        <author>Joe Rattz</author>
                        </book>
                        <book>
                        <title>Pro WF: Windows Workflow in .NET 3.0</title>
                        <author>Bruce Bukovics</author>
                        </book>
                        <book>
                        <title>Pro C# 2005 and the .NET 2.0 Platform, Third Edition</title>
                        <author>Andrew Troelsen</author>
                        </book>
                        </books>");
            var titles = from book in books.Elements("book")  
                         where (string)book.Element("author") == "Joe Rattz" select book.Element("title");
            foreach(var title in titles)
            {
                Console.WriteLine(title.Value);
            }
        }
    }

데이터 array, XML, List<object> 모든것에 대한 검색 및 데이터의 selection을 다 할 수 있다. 

흔히, LINQ를 DB에서만 보는 경향이 많은데... (이건 DB Metal의 이유가 가장 클것 같다.) LINQ는 데이터에 대한 검색이라고 할 수 있다. 모든 데이터에 대한. 

LINQ는 다음과 같이 구성되어있다. 

  • LINQ to Object : IEnumerable<T>에 대한 검색 제공
  • LINQ to XML : System.Xml.Linq에서 XML에 대한 LINQ query 검색 제공
  • LINQ to SQL : DB와 연결
  • LINQ to DataSet : ASP .NET 또는 WinForm에서 주로 사용되는 DataSet과의 연결






Posted by Y2K
,

사다리 게임

.NET Framework 2009. 1. 7. 13:34


저녁시간에 사다리 타는 것을 이야기하던것이 갑자기 생각나서 집에서 뚝딱 거리면서 만들어본것.

 

NodePoint -> NodePointGroup -> LadderGame 으로 소유하는 것으로 구조를 꾸미고,

NodePoint에서는 각 Node에서의 정보 저장

NodePointGroup에서는 Node간의 관계에 대한 정보

LadderGame에서는 각각의 Node를 움직이고, 게임의 초기화를 하는 것으로 구성.

 

Windows Form으로 간단히 구성

LadderGameDisplay라는 UserController를 이용해서 사다리 게임을 Display

 

졸면서, 옆에 KGB 3병 먹으면서 짠 알콜 코드. ㅋㅋㅋ

이제 이름을 각각 넣는것과 마지막 부분에 걸리는 내용을 넣으면 되는데..

사용자 입력 부분이라서 가장 귀찮은 코드가 될것 같음. LINQ 이용해서 DB에도 연결을 시켜볼까.. 고민도 되고. ㅋㅋ

Posted by Y2K
,
윈도 비스타에서는 탐색기 등에서 각 폴더를 폴더의 유형별로 사용자가 보기 쉽게
템플릿을 지정할 수 있도록 하는 기능을 가지고 있습니다.

음악 폴더의 경우는 제목/가수/앨범 번호 등이 나오게 하고
사진이나 비디오의 경우 '찍은 날짜'를 볼 수 있도록 해줍니다.

그런데, 어느날 부터 인지 C:\와 C:\Program Files\와 같이 폴더 유형 보기를 바꿀 수 없는 폴더 들이
음악 폴더로 지정이 되어 사람을 귀찮게 하더군요.
이런 저런 방법을 써서 바꾸려고 했지만 전혀 바꿀 수가 없었습니다.
사용하는데 큰 지장은 없지만 은근히 신경 쓰여서 인터넷을 뒤져보았습니다.
국내에서는 찾기 힘들었고 구글을 통해 외국 포럼에서 해결하였는데
안타깝게도 전체 폴더에 대한 저장되어 있는 유형을 모두 날려야 하는 방법입니다.

그래도 C:\와 C:\Program Files\ 같은 시스템 폴더의 경우에도
유형이 사진 폴더나 음악 폴더 등으로 잘못 나오는 일은 해결 되었습니다.

방법은 다음과 같습니다.

1. 시작 버튼을 누른다.
2. 검색 시작에 'regedit' +'엔터'를 입력한다.
3. 사용자 계정 컨트롤이 실행
되는 경우 확인을 클릭한다.
4. 레지스트리 편집기의 왼쪽에서 다음을 찾아 이동한다.
HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags
5. Bags를 선택한 뒤 오른쪽버튼을 눌러 삭제한다.
6. (바로 위에 있을 것으로 예상되지만) 다음을 찾아 이동한다.
HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\BagMRU
7. 마찬가지로 삭제한다.
8. 레지스트리 편집기를 종료한다.
9. 윈도우 로그오프 후 컴퓨터를 다시 시작한다. (레지스트리 키를 재생성하기 위함)
10. 윈도우 탐색기에서 '메뉴-도구-폴더옵션'에서 '보기'옵션을 선택한 뒤  '각 폴더의 보기 설정 기억'이 해제되어 있는 경우 체크한다.

BagMRU의 경우 이런 설정 기억이 저장되는 사이즈를 지정하는 것 같은데
자세한 내용은 다음 참고 링크를 참조 하세요.

출처 : http://www.mydigitallife.info/2007/1...t-clean-state/
참고 : http://www.mydigitallife.info/2007/1...e-memory-size/
Posted by Y2K
,
1.요약

특정 Thread 나 Window 에 아무런 영향을 끼치지 않으면서 단순히 그 Thread 나 Window 가 살아있는지를 확인하고 싶을때 이 메세지를 사용한다.

2.본문

MSDN 의 '색인' 에는 나와있지 않지만, 윈도우 메세지 종류에 WM_NULL 이라는 메세지가 존재한다. MSDN 이나 다른 책에서 WM_NULL 메세지를 benign message 라고 소개하고 있다.

WinUser.H 파일에 아래와 같이 정의되어 있다.

#define WM_NULL                         0x0000

이 메세지는 메세지 큐에 날라가긴 하지만, 어느 윈도우에서도 이 메세지를 처리하지 않기 때문에 그냥 메세지 큐에 들어가기만 하는 메세지이다.  그럼 윈도우는 왜 이런 메세지를 만들어 놓은 것일까?

Debugging Application 에서 보면 이 메세지를 정지해있는 혹은 메세지큐가 idle 상태에 있는 thread 를 깨우기 위해서  사용하고 있다. 또한 해당 윈도우가 정상적으로 메세지를 받을 수 있는 상태인지 단순히 확인만 하고 싶을때 사용한다.

3.예제

PostMessage(m_hwndTarget, WM_NULL, 0,0); // 일반 메세지 보내는것과 같습니다.

Posted by Y2K
,

MS에서 기존 Server에서 GUI 를 비롯한 Server에서 필요하지 않다고 생각되는 모든 기능을 제거한 UNIX와 비슷한 CMD 환경에서의 서버 운영체제

  

설치 : 기존 설치에서 ServerCore로 선택하고 설치하면 끝

  

System 설정
  • oclist : role, package에 대한 list 제공
  • ocsetup : role, package, feature의 설치
  • scregedit : servercore에서의 registery editor
  • dcpromo : Active Directory

  

ServerCore System의 활용
  • DNS Server, File Server, Media Server, Hyper-V로 이용 가능
  • Web Server의 경우에는 현재 php, html 만이 지원 가능
  • .NET Framework가 없기 때문에 MS SQL 및 IIS에서 ASP .NET이 지원되지 않는다.

  

ServerCore System에서의 개발
  • .NET Framework가 없기 때문에, 기존의 개발 방법이 많이 틀려짐.
  • ServerCore용 .NET Framework가 개발 될 것이라는 이야기가 있음 (MS IIS Team)
  • python, perl, ruby가 잘 돌아감
  • .NET Framework 기반의 PowerShell 역시 사용 불가
  • WMIC, WinRM을 기반으로 서버 관리 필요 : WMIC 및 WinRM은 이제 막 나오는 시기이기 때문에 거의 문서나 정보가 전무한 상태.
Posted by Y2K
,

Wceload.exe

OS 자료들 2009. 1. 7. 13:32

I've been asked for assistance with the following issue today. A developer has a CAB that he wants to install on the device without using CeAppMgr, from his own setup application. In addition he wanted to force the installation to the storage card if present.

This task involves several steps:

  1. Copy CAB to the device
  2. Detect storage card presence
  3. Launch wceload.exe to install the cab

1. Copying CAB to the device.

I would use cecopy (from Windows Mobile Developer Power Toys) or RAPI (CeCreateFile, CeWriteFile). If working with managed code, I suggest OpenNETCF.Communications library, or RapiDeploy tool

2. Detecting storage card presence.

While on the device side the preferred method is to use FindFirstFlashCard/FindNextFlashCard, these functions do not have Rapi equivalent. From the desktop side use CeFindAllFiles/FAF_FOLDERS_ONLY (or CeFindFirstFile/CeFindNextFile) to search the root directory and enumerate all files for having FILE_ATTRIBUTE_DIRECTORY and FILE_ATTRIBUTE_TEMPORARY combination of attributes (0x110).

3. Launch wceload.exe to install the cab

This is the interesting part. Here is a list of command-line switches that wceload.exe supports:

  • /delete - if value = 0 do not delete cab after install
  • /noui - perform a silent operation. Do not ask if it is ok to overwrite the exiting files
  • /nouninstall - do not create a .uninstall file. The applciation entry will not appear in Remove Programs list
  • /askdest - will force wceload to display a dialog that allows user to select installaltion location and some other things
  • /noaskdest - install specified applications to specified locations (see below)

 


Dialog displayed by wceload when /askdest is specified

The /noaskdest switch is the most inetersting of them all. When you specify it, wceload ignores the rest of the command line. Instead it checks the following registry location - [HKEY_LOCAL_MACHINE\SOFTWARE\Apps\Microsoft Application Installer\Install]

The key contents are key/value pairs:
[CAB file path] = [CAB destination directory]
e.g. \Storage Card\MyApp.CAB = \Storage Card\Program Files\My App

wceload will try to install the cab specified in the value name to the location specified in the value value. Below is the sample registry content:

To reiterate: in order to install a cab to the memory card, one needs to:

  1. Copy CAB to the device (e.g. to the memory card)
  2. Create a registry value on the device specifying the cab location and cab destination
  3. Launch wceload.exe with /noaskdest parameter
Posted by Y2K
,

인증 및 보안

신원(Identity)을 통한 보안

실행권한 계층

  • Privileged
    • 모든 API 호출 가능
    • Registry Write
    • File Write (all Directories)
    • 인증서 설치 가능
    • Trusted
  • Normal
  • Locked
    • 실행 권한 없음
    • 모든 S/W의 실행 제한

인증서

인증서 + app -(Signtool.exe) = signed application

  • Priviliged, normal 권한
  • Priviliged 계약상의 권한이 있음
  • Mobile2Market 인증서 : windows에서 인증을 받은 상태
    • MS에서의 조건이 있는 상태
Two Tier
  • Privileged
  • Normal
  • Blocked 
One Tier
  • Privilieged
  • Blocked
Posted by Y2K
,

Track 4. Program 개발 &  Device

Managed Program Development and Device
Native Code
  • Win32 API
  • C, C++
  • 성능 극대화 가능
  • 단독 실행 가능
Managed Code
  • .NET CF
  • C#
  • Visual Basic .NET
  • 단독 실행 불가능 : CF 1.0(2MB), CF 2.0(5MB)
SQL Server 2005 Compact Edition
  • Compact, Mobile 모두 가능
  • Mobile < Compact 

  

Track 5. 기업형 Mobile 아키텍쳐

모바일 통신 환경
  • 연결성 Mobile 환경 : SKT와 같은 망에 연결된 상태(wireless, CDMA)
  • 비연결성 Mobile 환경 : PC에 Cradle에 연결된 상태

  

무선 Protocol 통신 속도
  • 배터리 파워를 고려
  • Communication HW 고려
  • 통신 비용 고려

  

DB 연결 방법
  • ADO 
  • OLE DB : 훨씬 빠르지만, Win32에서만 사용 가능

  

CDMA 관련 문제 고려
  • 통신 장애
  • Roll back, Transaction 반드시 고려할것!
Posted by Y2K
,