Hello There;
I would ike to filter my resource by current user in XAF. I have used the workaround discussed on B132403 bug report. It works fine apparently. However, when I try to create a new resource and assign this resource to my new appointment, all the resources are loaded to the Schedular control. the controller which I have used is below. Also, Instead of creating new MyResource class, I have added User Attribute to my Resource class and re-builded the BaseImpl project.
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.Base.General;
using DevExpress.ExpressApp.Scheduler.Win;
using DevExpress.XtraScheduler;
using DevExpress.Xpo;
using DevExpress.Data.Filtering;
namespace XPOCRM.Module.Win.ViewControllers
{
public partial class SchedulerFilterController : ViewController
{
public SchedulerFilterController()
{
TargetObjectType = typeof(IEvent);
TargetViewType = ViewType.ListView;
}
protected override void OnActivated()
{
base.OnActivated();
SchedulerListEditor editor = ((ListView)View).Editor as SchedulerListEditor;
editor.ResourceDataSourceCreating += new System.EventHandler<DevExpress.ExpressApp.Scheduler.ResourceDataSourceCreatingEventArgs>(editor_ResourceDataSourceCreating);
View.ControlsCreated += new System.EventHandler(this.View_ControlsCreated);
}
protected override void OnDeactivating()
{
base.OnDeactivating();
View.ControlsCreated -= new System.EventHandler(this.View_ControlsCreated);
SchedulerListEditor editor = ((ListView)View).Editor as SchedulerListEditor;
editor.ResourceDataSourceCreating -= new System.EventHandler<DevExpress.ExpressApp.Scheduler.ResourceDataSourceCreatingEventArgs>(editor_ResourceDataSourceCreating);
}
private void View_ControlsCreated(object sender, System.EventArgs e)
{
DoFilter();
}
void editor_ResourceDataSourceCreating(object sender, DevExpress.ExpressApp.Scheduler.ResourceDataSourceCreatingEventArgs e)
{
SchedulerListEditor editor = (SchedulerListEditor)sender;
SchedulerControl scheduler = (SchedulerControl)editor.Scheduler;
scheduler.BeginUpdate();
try
{
XPCollection<DevExpress.Persistent.BaseImpl.Resource> resources = new XPCollection<DevExpress.Persistent.BaseImpl.Resource>(ObjectSpace.Session);
resources.Criteria = CriteriaOperator.Parse("User.Oid=?", SecuritySystem.CurrentUserId);
e.DataSource = resources;
e.Handled = true;
}
finally
{
scheduler.EndUpdate();
}
}
private void DoFilter()
{
if (((ListView)View).Editor is SchedulerListEditor)
{
SchedulerListEditor editor = (SchedulerListEditor)((ListView)View).Editor;
SchedulerControl scheduler = (SchedulerControl)editor.Scheduler;
scheduler.BeginUpdate();
try
{
XPCollection resources = editor.ResourcesDataSource as XPCollection;
if (resources != null)
{
resources.Criteria = CriteriaOperator.Parse("User.Oid=?", SecuritySystem.CurrentUserId);
}
}
finally
{
scheduler.EndUpdate();
}
}
}
}
}
What am I doing wrong in this case?
Best Regards
Mesut KOSUCU
Alanis Morissette - "We'll love you just the way you are if you're perfect."
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Hello Mesut,
Thank you for the report. We have reproduced this problem and it looks like a bug. This requires additional research from our side. So, we have also converted your question to the Bug report with the same ID.
Unfortunately, there is no good workaround for this problem. We are working on this. Please bear with us.
Thanks,
Dennis
Dennis
thanks for the reply. no problem
I can implement it whenever it is ready to use;)
hope to hear from u soon.