<iframe src="./Agre.htm" frameborder="0" width="300" height="300" leftmargin="0" topmargin="0"
scrolling="auto"></iframe>
Silverlight 4.0 에서 제공하는 Print 기능은 너무너무너무 간단하게 구현이 가능합니다.

우선 using System.Windows.Printing; 를 추가해 줍니다.

Print Event 함수 안에 들어갈 소스내용은 아래와 같습니다. ㅎㅎ

PrintDocument docToPrint = new PrintDocument();
docToPrint.BeginPrint += (s, args) => // Print 수행전 사용할 함수
{
               
};
docToPrint.PrintPage += (s, args) =>  // Print 수행중 사용할 함수
{
      args.PageVisual = txtPrint; // 출력할 페이지 UIElement 설정
};
docToPrint.EndPrint += (s, args) => // Print 종료후 사용할 함수
{
 
};

docToPrint.Print("Print"); // Print 시작

'Silverlight > Tip' 카테고리의 다른 글

DataGrid 해당 Column Sorting 기능 넣기  (0) 2010.10.12
Silverlight Tip Site  (0) 2010.07.28
WebService 연동 DataList 출력하기  (0) 2010.07.28

using System.Net.Mail;

MailAddress from = new MailAddress("[보내는사람 이메일 주소]", "[이름]");
MailAddress to = new MailAddress("[받는사람 이메일 주소]", "[이름]");
MailMessage message = new MailMessage(from, to);

message.Subject = "[ 이메일 제목 ]";
message.IsBodyHtml = true;  // Html 형식으로 보냄설정.
message.Body = "[이메일 내용]";

SmtpClient smtp = new SmtpClient("[메일서버]");

smtp.UseDefaultCredentials = false; // 시스템에 설정된 인증 정보를 사용하지 않는다.
smtp.EnableSsl = false;  // SSL을 사용한다.
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Credentials = new System.Net.NetworkCredential("[이메일서버 아이디]", "[이메일서버 패스워드]");


[방법 1]

Context context = new Context();
LoadOperation<Movie> load = context.Load(jobcontext.MovieQuery());
List<Movie> list = load.Entities.ToList();    -- ERROR 데이터가 들어오지 않는다.
Grid.ItemsSource = load.Entities;  -- Data Binding 되어 들어간다.

[방법 2]
private void load()
{

Context context = new Context();
LoadOperation<Movie> load = context.Load(jobcontext.MovieQuery());
List<Movie> list = load.Entities.ToList();    -- ERROR 데이터가 들어오지 않는다.
Grid.ItemsSource = load.Entities;  -- Data Binding 되어 들어간다.

context .Load<Rm_rmsx_009i_3_Model>(context .MovieQuery(), DatasLoaded, false);
}

public void DatasLoaded(LoadOperation<Movie> lo)
{
     List<Rm_rmsx_009i_3_Model> list = sp3context.Rm_rmsx_009i_3_Models.ToList();
     Grid.ItemsSource = list;  -- List로 받아도 데이터가 들어간다.
}

[방법 3] 람다식을 사용해 보자.

Context context = new Context();

EntityQuery<Movie> query = context .MovieQuery();
            context .Load<Movie>(query).Completed += (sender, args) =>
            {
                List<Movie> list = ((LoadOperation<Movie>)sender).Entities.ToList();
                Grid.ItemsSource = list;   -- Succes
            };

진행 순서

1. metadata 생성
    [MetadataTypeAttribute(typeof(rm_login_1_Result.rm_login_1_ResultMetadata))]
    public partial class rm_login_1_Result
    {
        internal sealed class rm_login_1_ResultMetadata
        {
            [Key]
            public string user_user { get; set; }
        }
    }

2. SP 호출
        public ObjectResult<URCSilverlight.Web.rm_login_1_Result> GetLoginCheck(string UserID, string UserPwd)
        {
            return this.ObjectContext.rm_login_1(UserID, UserPwd);
        }
출처 : http://forums.silverlight.net/forums/p/168648/381609.aspx#381609

public System.Data.Objects.ObjectResult<SP1_Result> SP1()
        {
            System.Data.Objects.ObjectResult<SP1_Result> result = this.ObjectContext.SP1();
            return result;
        }

When I compile the project, I only got one error saying SP1_Result does not have a Key. So I added a SP1_Result metadata class and tagged the Key field:


[MetadataTypeAttribute(typeof(SP1_Result.SP1_ResultMetadata))]
    public partial class SP1_Result
    {
        internal sealed class SP1_ResultMetadata
        {
            [Key]
            public int MyId;
        }
    }

After this, I can compile without problem. When I checked Client Side generated code, I can see SP1_Result is generated as Entity class. DomainContext.SP1Query  and DomainContext.SP1_Results are available.

The query function also can be written as :

 public IQueryable<SP1_Result> SP1()
        {
            return this.ObjectContext.SP1().AsQueryable();            
        }

 

Silverlight Tip Site

  1. Silverlight Show : http://www.silverlightshow.net/

  2. Silverlight : http://www.silverlight.net/community/

원문 : http://msdn.microsoft.com/ko-kr/library/system.servicemodel.domainservices.client(VS.91).aspx

System.ServiceModel.DomainServices.Client Namespace

Provides classes that are used from the client project for interacting with domain services.

Classes

  Class Description
Public class ChangeSetEntry Represents a domain operation to be performed on an entity.
Public class DomainClient Serves as the base class for all DomainClient implementations.
Public class DomainClientResult Represents the result of a DomainClient operation.
Public class DomainContext A DomainContext is a stateful client-side representation of a domain service, providing access to all the functionality of the service.
Public class DomainException Indicates that an unrecoverable error has occurred during the execution of a domain operation.
Public class DomainOperationException Indicates that at least one error has occurred during the processing of the domain operations on the server.
Public class DomainServiceFault Provides a message type used to communicate exception results between the server and the client.
Public class Entity Base class for all entity types.
Public class EntityAction Represents a custom method invocation on an entity.
Public class EntityChangeSet Represents a collection of changes to the Entity.
Public class EntityCollection(Of TEntity) Represents a collection of associated entities.
Public class EntityCollectionChangedEventArgs(Of TEntity) Provides event arguments for strongly typed add or remove notifications for the collections that contain entities.
Public class EntityConflict Represents an entity conflict.
Public class EntityContainer Represents a cache of entities in the form of a collection of EntitySet objects.
Public class EntityKey Base class for a key that represents a unique entity identity. The key is suitable for hashing.
Public class EntityQuery Represents a query method invocation.
Public class EntityQuery(Of TEntity) Represents a LINQ query over a collection of entities.
Public class EntityQueryable Contains the static extension methods that implement a subset of the LINQ pattern for EntityQuery.
Public class EntityRef(Of TEntity) Represents a reference to an associated entity.
Public class EntitySet Represents a collection of Entity instances.
Public class EntitySet(Of TEntity) Represents a collection of Entity instances that provides change tracking and other services.
Public class InvokeArgs Represents the information required to call an invoke operation.
Public class InvokeCompletedResult Represents the result of an invoke operation.
Public class InvokeOperation Represents an asynchronous invoke operation.
Public class InvokeOperation(Of TValue) Represents an asynchronous invoke operation.
Public class LoadOperation Represents an asynchronous load operation.
Public class LoadOperation(Of TEntity) Represents an asynchronous load operation.
Public class OperationBase Represents an asynchronous operation.
Public class QueryCompletedResult Represents the result of a query operation.
Public class QueryResult Message type used to communicate query results between the server and the client.
Public class QueryResult(Of T) Message type used to communicate query results between the server and client.
Public class SubmitCompletedResult Represents the result of a submit operation.
Public class SubmitOperation Represents an asynchronous submit operation.
Public class ValidationResultInfo Contains information about the error that occurred during execution of an operation on the server.
Public class WebDomainClient(Of TContract) Provides the default domain client implementation using WCF.


Enumerations

  Enumeration Description
Public enumeration EntityOperationType Describes the types of operations that can be performed on an Entity.
Public enumeration EntitySetOperations Enumeration of the types of operations permitted on an EntitySet.
Public enumeration EntityState Describes the possible states for an Entity.
Public enumeration LoadBehavior Specifies control identity cache behavior when loading entities.
Public enumeration OperationErrorStatus Describes the errors that occur during an operation.

1. DomainService 부분
        [Query]
        public IQueryable<Task> GetTasks()   // 자동생성 부분
        {
            return this.ObjectContext.Tasks;
        }

        public Task GetTask(int taskId)  // 추가된 함수 부분
        {
            return this.ObjectContext.Tasks.FirstOrDefault(t => t.TaskId == taskId);
        }



2. xaml 파일 비하인드 코드 cs 파일에 들어갈 소스
TasksDomainContext context = new TasksDomainContext();
            taskDataGrid.ItemsSource = context.Tasks;

            // 원본 Select 문에서 조건 삽입시
EntityQuery<Task> query = context.GetTasksQuery(); // LINQ 쿼리문 받아오기
LoadOperation<Task> loadOp = context.Load(query.Where(t=>t.TaskId == 1)); // 쿼리문 실행

// 조건 설정되 있는 함수 호출시
            EntityQuery<Task> p = context.GetTaskQuery(123);
            LoadOperation<Task> loadOp2 = context.Load(p);

+ Recent posts