Setting Permissions on a Process Action form  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Setting Permissions on a Process Action form

Postby SBarnes » Tue Jul 11, 2017 1:40 pm

Hi Mike,

Is there a similar form to JiwaFinancials.Jiwa.JiwaApplication.SecurityUI.SetPermissions that is used for a Maintenance form to set permissions that can be use on a custom built process action form or is there a way to use JiwaFinancials.Jiwa.JiwaApplication.SecurityUI.SetPermissions to do it?

Thanks
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Setting Permissions on a Process Action form

Postby Mike.Sheen » Sun Jul 16, 2017 12:35 pm

SBarnes wrote:Hi Mike,

Is there a similar form to JiwaFinancials.Jiwa.JiwaApplication.SecurityUI.SetPermissions that is used for a Maintenance form to set permissions that can be use on a custom built process action form or is there a way to use JiwaFinancials.Jiwa.JiwaApplication.SecurityUI.SetPermissions to do it?

Thanks

If your form inherits from JiwaFinancials.Jiwa.ProcessAction.UserInterface then you get that all for free - you should see a Utilities tab on the ribbon and a Set Permissions group and tool, and when you click the tool it loads the set permissions form and handles everything for you.

Some of our forms (like sales order processing) which do inherit from JiwaFinancials.Jiwa.ProcessAction.UserInterface has explicit code to hide the Utilities tab because we figured there was not much point to setting permissions on that form - either you can load it or you cannot - but if we didn't do that, it would have the permissions capabilities exposed.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Setting Permissions on a Process Action form

Postby SBarnes » Sun Jul 16, 2017 1:09 pm

Hi Mike,

In a different plugin where I did a maintenance screen it as you said "all work for free" but not the process action, if I don't try and have some code to bring up the form on the process action nothing happens.

I'll go back and check everything and see if it works, the plugin in question is you CRM dashboard that I converted from vb.net to c# as a proof of concept for something I have to do for a customer that will involves graphs etc. but working with purchasing as I'm not keen on having to do it in VB. :) and also wanted to use it as a testing environment.

If I can't figure it out I'll post the plugin as the next post as I just wanted to know if the permissions will work as it will be necessary in the customers graph screen in terms of what can be seen.

Thanks
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Setting Permissions on a Process Action form

Postby SBarnes » Tue Jul 25, 2017 8:35 am

Hi Mike,

I've attached the plugin that won't allow setting of permissions currently it does nothing when you press the permissions button but if you uncomment the two sections with SetPermissionsForControls in them the screen will show up but it produces a duplicate key error when you try and save anything this is on Jiwa 7.182.

Any help you can give would be appreciated.
Attachments
Plugin CRM as C#.xml
(166.36 KiB) Downloaded 91 times
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Setting Permissions on a Process Action form

Postby SBarnes » Fri Aug 18, 2017 6:11 pm

This would now be under 7.185
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Setting Permissions on a Process Action form

Postby Mike.Sheen » Sat Aug 19, 2017 12:12 pm

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();
            }
        }
    }
}
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Setting Permissions on a Process Action form

Postby SBarnes » Sat Aug 19, 2017 12:40 pm

Hi Mike,

Thanks, I'll have a look at the code, interestingly the duplicate error was what I was getting also when I had the permissions code I introduced uncommented also.

If I am reading your bug report correctly you are saying the if I don't use both JiwaFinancials.Jiwa.JiwaDashboardUI.DashboardPanel and JiwaFinancials.Jiwa.JiwaDashboardUI.IndicatorPanel on the form but just the standard infragistics controls it will all work (in theory)?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Setting Permissions on a Process Action form

Postby Mike.Sheen » Sat Aug 19, 2017 1:38 pm

SBarnes wrote:you are saying the if I don't use both JiwaFinancials.Jiwa.JiwaDashboardUI.DashboardPanel and JiwaFinancials.Jiwa.JiwaDashboardUI.IndicatorPanel on the form but just the standard infragistics controls it will all work (in theory)?


I think it would be safe to make that assumption - all other Jiwa forms besides the dashboard (which never had permissions enabled and thus was not tested for that) use standard infragistics controls, windows controls, farpoint spread controls, and so on without issue - It's just those two pesky controls DashboardPanel and IndicatorPanel.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Setting Permissions on a Process Action form  Topic is solved

Postby Mike.Sheen » Tue Aug 22, 2017 8:06 pm

DEV-6194 has now been filled and will be in the next Dev build - 7.00.186.00.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Setting Permissions on a Process Action form

Postby SBarnes » Tue Aug 22, 2017 8:39 pm

That's Excellent thanks.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 11 guests

cron