I'm trying Devexpress DC Technology.In early releases DC not support some futures but last release support(For example Scheduller). Shortly I create new DC class and it implement IResource interface. Like this:
[DomainComponent]
[DefaultClassOptions]
[ImageName("Employee")]
[XafDisplayName("Employee")]
public interface IEmployee : IResource
{
[RuleRequiredField]
string Name { get; set; }
[RuleRequiredField]
string Surname { get; set; }
string FullName { get; }
new object Id { get; }
new string Caption { get; set; }
int Color { get; set; }
new int OleColor { get; }
}
[DomainLogic(typeof(IEmployee))]
public class EmployeeLogic
{
public static void AfterChange_Name(IEmployee instance)
{
if (string.IsNullOrEmpty(instance.Caption))
instance.Caption = instance.FullName;
}
public static void AfterChange_Surname(IEmployee instance)
{
if (string.IsNullOrEmpty(instance.Caption))
instance.Caption = instance.FullName;
}
public static object Get_Id(IEmployee instance)
{
return ((XPObject)instance).Oid;
}
public static string Get_FullName(IEmployee instance)
{
return string.Format("{0} {1}", instance.Name, instance.Surname);
}
public static int Get_OleColor(IEmployee instance)
{
return ColorTranslator.ToOle(Color.FromArgb(instance.Color));
}
}
My question is how can show color property editor at rune time?
P.S. Without use DC Technology, actually we don't need do any thing for this:
[Persistent("Color")]
[Browsable(false)]
public Int32 color;
[NonPersistent]
[DisplayName("Renk")]
public Color Color
{
get { return Color.FromArgb(color); }
set
{
color = value.ToArgb();
OnChanged("Color");
}
}
UPDATE:
Also, before i write same type code and if I remember correctly when we write BO that inherit from resource, this recorce become resource for event BO automaticallly. But now i'm using DC tecnology and i think there is one more step i need to do. But i don't imagine.
We have closed this ticket because another page addresses its subject:
DC - Provide a way to write logic that should be executed after the associated collection is changed (the AfterListChanged method)
Hi Aytac,
ColorPropertyEditor is designed to edit Color type properties, but this type cannot be persisted by default. Please create a non-persistent Color type property and implement domain logic methods that perform the conversion. To assign events to resources, associate your IEvent component with your IResource component and implement domain logic methods for the IEvent.ResourceId property to create an XML resource string based on associated resources. I recommend that you refer to example How to create fully custom Role, User, Event, Resource classes for use with the Security and Scheduler modules. Utilize a similar approach for domain components. Please try the attached classes and let me know if this helps.
Thanks,
Michael.
Hi Michael,
Thanks for your sample code and detailed explanation. I'm working on it. If i encounter any problem, i'll contact you again.
Have a nice day.
You are welcome, Aytac.
Please feel free to contact us if you need any additional assistance. We will be happy to help you.
Thanks,
Michael.
Hi again Michael,
I want to ask a question about DC's. When we want to implement any property's change event we are writing like this:
public static void AfterChange_<property>(<domain component> instance) {}
if we want to do this for IList<domain component> type property how can i code it?
Thanks.
Hi Aytac,
These properties are usually read-only, so AfterChange_ methods make no sense for them. I suppose you wish to handle changes within a collection. This functionality is not currently available. We have a corresponding suggestion: DC - Provide a way to write logic that should be executed after the associated collection is changed (the AfterListChanged method).
See also:
DC: afterchange on a collection won't fire.
Thanks,
Michael.
Hi,
Ok i'll examine your links. Maybe would be more accurate to ask the following way;
I want to schedule one event to many employee at the same time. For this situation i think we have to write employee collection property in event dc. So when in edit mode event dc, user can be add many resource(employee) or remove some resource. At this time we have to refresh event ResourceId property. How can i do this?
Thanks.
Hi again Michael,
No need to answer my previous post. Links exactly related my problem. This is very interesting, actually devex don't skip like this type situations. This suggestions maded 5 mounths ago, i hope within a short time period this problem will be solve. For now, are you have any temporary suggestion?
Thanks.
Hi Michael,
Before post you sended to me a sample in Q228964.ZIP.
I exemine it and i see there is a problem about update employee from resource string.
Exactly I don't understand why? Steps:
1.set breakpoint to update Set_ResourceId,
2.Go schedular list view and do mouse right click any resource(employee) area,
3.At that time debuging start up(i think xaf scheduler module automatically setting resıurce), we enter Set_ResourceId, our resource variable null and new value = "<ResourceIds>\r\n<ResourceId Type="System.Int32" Value="1" />\r\n</ResourceIds>". our resource value changing with new value and we call updatemployee procedure.
4.In updateEmployee procedure occur exception:
Unable to create an instance of the "System.Int32" type.
Reason: "Constructor on type 'System.Int32' not found."
.ctor(System.String) is absent.,
stack trace: " at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at DevExpress.ExpressApp.DC.TypeInfo.CreateInstance(Object[] args)"
end stack trace
SO we can't set employee…
Please help.
Thanks.
Hi Aytac,
I am afraid I cannot promise that suggestion S37232 will be implemented in the next release because we have faced some difficulties in this area. There is no workaround either. Nevertheless, we consider this functionality important and will do our best to find a solution as soon as possible.
To overcome an exception in my example, please modify the UpdateEmployee method as follows:
private void UpdateEmployee(IPersistentEvent instance) { IObjectSpace os = ObjectSpace.FindObjectSpaceByObject(instance); try { if (!String.IsNullOrEmpty(_resource)) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(_resource); foreach (XmlNode xmlNode in xmlDocument.DocumentElement.ChildNodes) { ITypeInfo ti = os.TypesInfo.FindTypeInfo(xmlNode.Attributes["Type"].Value); if (ti != null) { object key = Convert.ChangeType(xmlNode.Attributes["Value"].Value, ti.Type); instance.Employee = os.GetObjectByKey<IEmployee>(key); } } } } catch { } }
Thanks,
Michael.
Hi Michael,
I am sorry to heard these words from you. But I'm trusting devex team, I'm sure you will solve problem as soon as possible.
Also right now, I don't have any problem or question about schedular. Thanks for your helps, I'm very pleased.
Ahead if i need your support again, i'll open new question post(not private) because of all users can be see.
Take care.
Hi Aytac,
Unless I am mistaken, this ticket does not contain any sensitive information. If you do not have objections, we can make it public, too.
Thanks,
Michael.
Hi Michael,
Yes, please make it public.
Thanks.
Thank you very much.
You're welcome.