//*****************************************************************************
// Description.....WS-Transfer Activity
//
// Author..........Roman Kiss, rkiss@pathcom.com
// Copyright © 2007 ATZ Consulting Inc. (see included license.rtf file)
//
// Date Created: 07/12/07
//
// Date Modified By Description
//-----------------------------------------------------------------------------
// 07/12/07 Roman Kiss Initial Revision
//*****************************************************************************
//
#region Namespaces
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections.Generic;
using System.Collections;
using System.Drawing;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.ServiceModel.Channels;
//
using RKiss.ESB;
using RKiss.WSTransfer;
#endregion
namespace RKiss.WSTransferActivity
{
[ToolboxItem(typeof(ActivityToolboxItem))]
[Designer(typeof(WSRTActivityDesigner), typeof(IDesigner))]
public partial class WSRT_Create: SequenceActivity
{
public WSRT_Create()
{
InitializeComponent();
}
protected override void InitializeProperties()
{
base.InitializeProperties();
this.Autobinding();
ResourceDescriptor = new ResourceDescriptor();
}
public virtual void Autobinding()
{
#region Autobinding to the parent ReceiveActivity
Activity searchParent = this.Parent;
//while (searchParent != null)
//{
// if (typeof(ReceiveActivity).IsAssignableFrom(searchParent.GetType()))
// {
// if (!this.IsBindingSet(WSRT_Create.CreateRequestProperty) && searchParent.IsBindingSet(ReceiveActivity..ParameterBindings["request"]))
// {
// this.SetBinding(WSRT_Create.CreateRequestProperty, searchParent.GetBinding(ReceiveActivity.ParameterBindingsProperty["request"]));
// }
// if (!this.IsBindingSet(WSRT_Create.CreateResponseProperty) && searchParent.IsBindingSet(ReceiveActivity.ParameterBindingsProperty["(ReturnValue)"]))
// {
// this.SetBinding(WSRT_Create.CreateResponseProperty, searchParent.GetBinding(ReceiveActivity.ParameterBindingsProperty["(ReturnValue)"]));
// }
// break;
// }
// else
// {
// searchParent = searchParent.Parent;
// }
//}
#endregion
}
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
{
// pre-processing
if (CreateRequest == null)
{
CreateRequest = RKiss.WSTransfer.CreateRequest.Create(MessageRequest);
}
if (CreateRequest.IsResourceTransfer)
{
ResourceDescriptor.Created = CreateRequest.Metadata.Lifetime.TerminateAt.CurrentTime;
ResourceDescriptor.Expires = CreateRequest.Metadata.Lifetime.TerminateAt.TerminationTime;
}
else
{
ResourceDescriptor.Created = DateTime.Now;
ResourceDescriptor.Expires = DateTime.MaxValue;
}
ResourceDescriptor.Name = ResourceName;
ResourceDescriptor.Topic = ResourceTopic;
// processing
ActivityExecutionStatus status = base.Execute(executionContext);
// post-processing
List<AddressHeader> list = new List<AddressHeader>();
list.Add(AddressHeader.CreateAddressHeader(ResourceDescriptor.DataContractName, ResourceDescriptor.DataContractNamespace, ResourceDescriptor));
AddressHeaderCollection ahc = new AddressHeaderCollection(new AddressHeaderCollection(list));
Uri uriTo = string.IsNullOrEmpty(ResourceUri) ? OperationContext.Current.IncomingMessageHeaders.To : new Uri(ResourceUri);
EndpointAddress resourceEndpointAddress = new EndpointAddress(uriTo, (EndpointIdentity)null, ahc);
CreateResponse = new CreateResponse(CreateRequest.IsResourceTransfer, resourceEndpointAddress);
if (MessageRequest != null)
{
MessageResponse = CreateResponse.CreateMessage();
}
return status;
}
#region Properties
public static DependencyProperty MessageRequestProperty = DependencyProperty.Register("MessageRequest", typeof(Message), typeof(WSRT_Create));
[DescriptionAttribute("UnTyped Message Request")]
[CategoryAttribute("Message")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public Message MessageRequest
{
get
{
return ((Message)(base.GetValue(WSRT_Create.MessageRequestProperty)));
}
set
{
base.SetValue(WSRT_Create.MessageRequestProperty, value);
}
}
public static DependencyProperty MessageResponseProperty = DependencyProperty.Register("MessageResponse", typeof(Message), typeof(WSRT_Create));
[DescriptionAttribute("UnTyped Message Response")]
[CategoryAttribute("Message")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public Message MessageResponse
{
get
{
return ((Message)(base.GetValue(WSRT_Create.MessageResponseProperty)));
}
set
{
base.SetValue(WSRT_Create.MessageResponseProperty, value);
}
}
public static DependencyProperty CreateRequestProperty = DependencyProperty.Register("CreateRequest", typeof(CreateRequest), typeof(WSRT_Create));
[DescriptionAttribute("CreateRequest")]
[CategoryAttribute("Message")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public CreateRequest CreateRequest
{
get
{
return ((CreateRequest)(base.GetValue(WSRT_Create.CreateRequestProperty)));
}
set
{
base.SetValue(WSRT_Create.CreateRequestProperty, value);
}
}
public static DependencyProperty CreateResponseProperty = DependencyProperty.Register("CreateResponse", typeof(CreateResponse), typeof(WSRT_Create));
[DescriptionAttribute("CreateResponse")]
[CategoryAttribute("Message")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public CreateResponse CreateResponse
{
get
{
return ((CreateResponse)(base.GetValue(WSRT_Create.CreateResponseProperty)));
}
set
{
base.SetValue(WSRT_Create.CreateResponseProperty, value);
}
}
public static DependencyProperty ResourceDescriptorProperty = DependencyProperty.Register("ResourceDescriptor", typeof(ResourceDescriptor), typeof(WSRT_Create));
[DescriptionAttribute("ResourceDescriptor")]
[CategoryAttribute("Resource")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public ResourceDescriptor ResourceDescriptor
{
get
{
return ((ResourceDescriptor)(base.GetValue(WSRT_Create.ResourceDescriptorProperty)));
}
set
{
base.SetValue(WSRT_Create.ResourceDescriptorProperty, value);
}
}
public static DependencyProperty ResourceUriProperty = DependencyProperty.Register("ResourceUri", typeof(string), typeof(WSRT_Create));
[DescriptionAttribute("ResourceUri")]
[CategoryAttribute("Resource")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public string ResourceUri
{
get
{
return ((string)(base.GetValue(WSRT_Create.ResourceUriProperty)));
}
set
{
base.SetValue(WSRT_Create.ResourceUriProperty, value);
}
}
public static DependencyProperty ResourceKeyProperty = DependencyProperty.Register("ResourceKey", typeof(string), typeof(WSRT_Create));
[DescriptionAttribute("ResourceKey")]
[CategoryAttribute("Resource")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public string ResourceKey
{
get
{
return ((string)(base.GetValue(WSRT_Create.ResourceKeyProperty)));
}
set
{
base.SetValue(WSRT_Create.ResourceKeyProperty, value);
}
}
[DescriptionAttribute("ResourceName")]
[CategoryAttribute("Resource")]
[BrowsableAttribute(true)]
public string ResourceName { get; set; }
[DescriptionAttribute("ResourceTopic")]
[CategoryAttribute("Resource")]
[BrowsableAttribute(true)]
public string ResourceTopic { get; set; }
#endregion
}
#region WSRTActivityDesigner
[ActivityDesignerTheme(typeof(WSRTActivityTheme))]
public sealed class WSRTActivityDesigner : SequenceDesigner
{
}
public sealed class WSRTActivityTheme : CompositeDesignerTheme
{
// Methods
public WSRTActivityTheme(WorkflowTheme theme)
: base(theme)
{
this.ShowDropShadow = false;
this.ConnectorStartCap = LineAnchor.None;
this.ConnectorEndCap = LineAnchor.ArrowAnchor;
this.ForeColor = Color.FromArgb(0xff, 0x80, 0, 0);
this.BorderColor = Color.FromArgb(255, 197, 138); // Color.FromArgb(0xff, 0xe0, 0xe0, 0xe0);
this.BorderStyle = DashStyle.Solid; //DashStyle.Dash;
this.BackColorStart = Color.FromArgb(255, 242, 242); // Color.FromArgb(0, 0, 0, 0);
this.BackColorEnd = Color.FromArgb(255, 225, 225); // Color.FromArgb(0, 0, 0, 0);
base.BackgroundStyle = LinearGradientMode.Vertical;
}
}
#endregion
}