This is caused by the BusinessLogic property of the form being null.
The tool click handler for the base form is a bit defensive and won't process the permission tool click if that is null - but it doesn't actually need it to be anything.
So, your work around is you set it to something - I downloaded your plugin and added this line to your Setup method of the CRMCS class, after the _ToDoList was created :
- Code: Select all
base.BusinessLogic = _ToDoList; // Need to set BusinessLogic to something, or set permissions button won't do anything
And then it worked.
However, a new issue is revealed - when you save the permissions set, you'll get a duplicate key error. This is caused by the Dashboard controls having child controls which should be omitted from the permissionable controls, but are not and results in a duplicate key value as there are multiple controls with the same name for the same form.
I've logged
DEV-6194 to address this.
And if you're bored, a while ago I wrote a dashboard (also in C#) and came up with a new pattern for handling the asynchronous nature which I think is a bit neater than the background worker - the code below is everything except the designer code. I wanted to spend a bit more time on it and eliminate the Tasks completely and use async await everywhere, but couldn't quite get that done in the time I had - Async spreads like a virus into all method signatures!
- Code: Select all
#region "Dashboard"
namespace Safeman
{
public class Dashboard : JiwaFinancials.Jiwa.JiwaApplication.ProcessAction.UserInterface
{
public Dashboard()
{
InitializeComponent();
this.Text = "Safeman Embroidery Dashboard";
}
public override void SetupBeforeHandlers()
{
base.SetupBeforeHandlers();
this.MdiParent = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.MDIParentForm;
}
public override void Setup()
{
base.Setup();
SetupForm();
AddHandlers();
}
public override void SetToolBar(bool EditMode)
{
base.SetToolBar(EditMode);
UltraToolbarsManager1.Tools["ID_RecordRefresh"].SharedProps.Enabled = true;
}
public override void AddHandlers()
{
this.Shown += Form_Shown;
UltraToolbarsManager1.ToolClick += UltraToolbarsManager1_ToolClick1;
base.AddHandlers();
}
public void SetupForm()
{
UltraToolbarsManager1.Tools["ID_RecordProcess"].SharedProps.Visible = false;
SetupWindow();
SetupControls();
}
async private void Form_Shown(object sender, System.EventArgs e)
{
await RunTasks();
}
public void SetupControls()
{
UltraToolbarsManager1.Tools["ID_RecordRefresh"].SharedProps.Enabled = false;
SalesLast30DaysIndicatorPanel.StoredProcName = "usp_SAFEMAN_Dashboard_Indicator_EmbroiderySalesLast30Days";
SalesLast30DaysIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@SP_AsAtDate", System.Data.SqlDbType.DateTime) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.SysDateTime });
SalesLast30DaysIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@HR_Staff_StaffID", System.Data.SqlDbType.Char) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.Staff.RecID });
SalesLast30DaysIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@IN_Logical_LogicalID", System.Data.SqlDbType.Char) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.CurrentLogicalWarehouse.IN_LogicalID });
SalesLast30DaysIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@StackScale", System.Data.SqlDbType.Int) { Value = 5 });
SalesAwaitingWorkOrdersindicatorPanel.StoredProcName = "usp_SAFEMAN_Dashboard_Indicator_EmbroiderySalesAwaitingWorkOrders";
SalesAwaitingWorkOrdersindicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@SP_AsAtDate", System.Data.SqlDbType.DateTime) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.SysDateTime });
SalesAwaitingWorkOrdersindicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@HR_Staff_StaffID", System.Data.SqlDbType.Char) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.Staff.RecID });
SalesAwaitingWorkOrdersindicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@IN_Logical_LogicalID", System.Data.SqlDbType.Char) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.CurrentLogicalWarehouse.IN_LogicalID });
SalesAwaitingWorkOrdersindicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@StackScale", System.Data.SqlDbType.Int) { Value = 5 });
SalesReadyToCompleteIndicatorPanel.StoredProcName = "usp_SAFEMAN_Dashboard_Indicator_EmbroiderySalesReadyToComplete";
SalesReadyToCompleteIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@SP_AsAtDate", System.Data.SqlDbType.DateTime) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.SysDateTime });
SalesReadyToCompleteIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@HR_Staff_StaffID", System.Data.SqlDbType.Char) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.Staff.RecID });
SalesReadyToCompleteIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@IN_Logical_LogicalID", System.Data.SqlDbType.Char) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.CurrentLogicalWarehouse.IN_LogicalID });
SalesReadyToCompleteIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@StackScale", System.Data.SqlDbType.Int) { Value = 5 });
WorkOrdersAwaitingPOCreationIndicatorPanel.StoredProcName = "usp_SAFEMAN_Dashboard_Indicator_EmbroideryWorkOrdersAwaitingPurchaseOrders";
WorkOrdersAwaitingPOCreationIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@SP_AsAtDate", System.Data.SqlDbType.DateTime) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.SysDateTime });
WorkOrdersAwaitingPOCreationIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@HR_Staff_StaffID", System.Data.SqlDbType.Char) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.Staff.RecID });
WorkOrdersAwaitingPOCreationIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@IN_Logical_LogicalID", System.Data.SqlDbType.Char) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.CurrentLogicalWarehouse.IN_LogicalID });
WorkOrdersAwaitingPOCreationIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@StackScale", System.Data.SqlDbType.Int) { Value = 5 });
WorkOrdersReadyToCompleteIndicatorPanel.StoredProcName = "usp_SAFEMAN_Dashboard_Indicator_EmbroideryWorkOrdersReadyToComplete";
WorkOrdersReadyToCompleteIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@SP_AsAtDate", System.Data.SqlDbType.DateTime) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.SysDateTime });
WorkOrdersReadyToCompleteIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@HR_Staff_StaffID", System.Data.SqlDbType.Char) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.Staff.RecID });
WorkOrdersReadyToCompleteIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@IN_Logical_LogicalID", System.Data.SqlDbType.Char) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.CurrentLogicalWarehouse.IN_LogicalID });
WorkOrdersReadyToCompleteIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@StackScale", System.Data.SqlDbType.Int) { Value = 5 });
PurchaseOrdersReadyToSendIndicatorPanel.StoredProcName = "usp_SAFEMAN_Dashboard_Indicator_EmbroideryPurchaseOrdersReadyToSend";
PurchaseOrdersReadyToSendIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@SP_AsAtDate", System.Data.SqlDbType.DateTime) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.SysDateTime });
PurchaseOrdersReadyToSendIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@HR_Staff_StaffID", System.Data.SqlDbType.Char) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.Staff.RecID });
PurchaseOrdersReadyToSendIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@IN_Logical_LogicalID", System.Data.SqlDbType.Char) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.CurrentLogicalWarehouse.IN_LogicalID });
PurchaseOrdersReadyToSendIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@StackScale", System.Data.SqlDbType.Int) { Value = 5 });
PurchaseOrdersAtEmbroiderersIndicatorPanel.StoredProcName = "usp_SAFEMAN_Dashboard_Indicator_EmbroideryPurchaseOrdersAtEmbroiderers";
PurchaseOrdersAtEmbroiderersIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@SP_AsAtDate", System.Data.SqlDbType.DateTime) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.SysDateTime });
PurchaseOrdersAtEmbroiderersIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@HR_Staff_StaffID", System.Data.SqlDbType.Char) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.Staff.RecID });
PurchaseOrdersAtEmbroiderersIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@IN_Logical_LogicalID", System.Data.SqlDbType.Char) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.CurrentLogicalWarehouse.IN_LogicalID });
PurchaseOrdersAtEmbroiderersIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@StackScale", System.Data.SqlDbType.Int) { Value = 5 });
GRNsOpenIndicatorPanel.StoredProcName = "usp_SAFEMAN_Dashboard_Indicator_EmbroideryGRNsOpen";
GRNsOpenIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@SP_AsAtDate", System.Data.SqlDbType.DateTime) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.SysDateTime });
GRNsOpenIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@HR_Staff_StaffID", System.Data.SqlDbType.Char) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.Staff.RecID });
GRNsOpenIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@IN_Logical_LogicalID", System.Data.SqlDbType.Char) { Value = JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.CurrentLogicalWarehouse.IN_LogicalID });
GRNsOpenIndicatorPanel.SQLParameters.Add(new System.Data.SqlClient.SqlParameter("@StackScale", System.Data.SqlDbType.Int) { Value = 5 });
}
async public void UltraToolbarsManager1_ToolClick1(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
{
switch (e.Tool.Key)
{
case "ID_RecordRefresh":
//re - read
UltraToolbarsManager1.Tools["ID_RecordRefresh"].SharedProps.Enabled = false;
await RunTasks();
break;
}
}
public async System.Threading.Tasks.Task RunTasks()
{
var useWaitCursor = this.UseWaitCursor;
try
{
this.UseWaitCursor = true;
var tasks = new List<System.Threading.Tasks.Task>();
tasks.Add(System.Threading.Tasks.Task.Run(() => IndicatorPanel_Read(SalesLast30DaysIndicatorPanel)));
tasks.Add(System.Threading.Tasks.Task.Run(() => IndicatorPanel_Read(SalesAwaitingWorkOrdersindicatorPanel)));
tasks.Add(System.Threading.Tasks.Task.Run(() => IndicatorPanel_Read(SalesReadyToCompleteIndicatorPanel)));
tasks.Add(System.Threading.Tasks.Task.Run(() => IndicatorPanel_Read(WorkOrdersAwaitingPOCreationIndicatorPanel)));
tasks.Add(System.Threading.Tasks.Task.Run(() => IndicatorPanel_Read(WorkOrdersReadyToCompleteIndicatorPanel)));
tasks.Add(System.Threading.Tasks.Task.Run(() => IndicatorPanel_Read(PurchaseOrdersReadyToSendIndicatorPanel)));
tasks.Add(System.Threading.Tasks.Task.Run(() => IndicatorPanel_Read(PurchaseOrdersAtEmbroiderersIndicatorPanel)));
tasks.Add(System.Threading.Tasks.Task.Run(() => IndicatorPanel_Read(GRNsOpenIndicatorPanel)));
await System.Threading.Tasks.Task.WhenAll(tasks.ToArray());
}
finally
{
UltraToolbarsManager1.Tools["ID_RecordRefresh"].SharedProps.Enabled = true;
this.UseWaitCursor = useWaitCursor;
}
}
public delegate void IndicatorPanel_Read_Delegate(JiwaFinancials.Jiwa.JiwaDashboardUI.IndicatorPanel IndicatorPanel);
public void IndicatorPanel_Read(JiwaFinancials.Jiwa.JiwaDashboardUI.IndicatorPanel IndicatorPanel)
{
if (this.InvokeRequired)
{
IndicatorPanel_Read_Delegate delegateMethod = new IndicatorPanel_Read_Delegate(IndicatorPanel_Read);
this.Invoke(delegateMethod, new object[] { IndicatorPanel });
}
else
{
IndicatorPanel.Read();
}
}
}
}