Example #1
0
        private ObservableCollection <CommandViewModel> createPeriodCommands()
        {
            var cmdList = new ObservableCollection <CommandViewModel>();

            if (userService.IsUserPermissionGranted(typeof(IPeriodController), "ShowPeriodList", userAuthorizedActions))
            {
                cmdList.Add(
                    new CommandViewModel(LocalizedResources.PeriodListSubMenu, new DelegateCommand(
                                             () =>
                {
                    controller.ShowBusyIndicator("در حال بارگذاری ماجول...");
                    controller.GetRemoteInstance <IPeriodController>(
                        (res, exp) =>
                    {
                        controller.HideBusyIndicator();
                        if (res != null)
                        {
                            res.ShowPeriodList(isShiftPressed);
                        }
                        else if (exp != null)
                        {
                            controller.HandleException(exp);
                        }
                    });
                }
                                             )));
            }

            if (userService.IsUserPermissionGranted(typeof(IPeriodController), "ShowUnitInPeriodTreeView", userAuthorizedActions))
            {
                cmdList.Add(
                    new CommandViewModel(" واحد های سازمانی در دوره جاری", new DelegateCommand(
                                             () =>
                {
                    controller.ShowBusyIndicator("در حال بارگذاری ماجول...");
                    controller.GetRemoteInstance <IPeriodController>(
                        (res, exp) =>
                    {
                        controller.HideBusyIndicator();
                        if (res != null)
                        {
                            var activePeriod = createActivePeriodDTOWithAction();
                            if (activePeriod == null)
                            {
                                return;
                            }
                            res.ShowUnitInPeriodTreeView(activePeriod, isShiftPressed);
                        }
                        else if (exp != null)
                        {
                            controller.HandleException(exp);
                        }
                    });
                }
                                             )));
            }

            if (userService.IsUserPermissionGranted(typeof(IPeriodController), "ShowUnitIndexInPeriodTreeView",
                                                    userAuthorizedActions))
            {
                cmdList.Add(
                    new CommandViewModel(" مدیریت شاخص سازمانی در دوره جاری", new DelegateCommand(
                                             () =>
                {
                    controller.ShowBusyIndicator("در حال بارگذاری ماجول...");
                    controller.GetRemoteInstance <IPeriodController>(
                        (res, exp) =>
                    {
                        controller.HideBusyIndicator();
                        if (res != null)
                        {
                            var activePeriod = createActivePeriodDTOWithAction();
                            if (activePeriod == null)
                            {
                                return;
                            }
                            res.ShowUnitIndexInPeriodTreeView(activePeriod, isShiftPressed);
                        }
                        else if (exp != null)
                        {
                            controller.HandleException(exp);
                        }
                    });
                }
                                             )));
            }

            if (userService.IsUserPermissionGranted(typeof(IPeriodController), "ShowJobInPeriodListView",
                                                    userAuthorizedActions))
            {
                cmdList.Add(
                    new CommandViewModel("مدیریت مشاغل در دوره جاری", new DelegateCommand(
                                             () =>
                {
                    controller.ShowBusyIndicator("در حال بارگذاری ماجول...");
                    controller.GetRemoteInstance <IPeriodController>(
                        (res, exp) =>
                    {
                        controller.HideBusyIndicator();
                        if (res != null)
                        {
                            var activePeriod = createActivePeriodDTOWithAction();
                            if (activePeriod == null)
                            {
                                return;
                            }
                            res.ShowJobInPeriodListView(activePeriod, isShiftPressed);
                        }
                        else if (exp != null)
                        {
                            controller.HandleException(exp);
                        }
                    });
                }
                                             )));
            }

            if (userService.IsUserPermissionGranted(typeof(IPeriodController), "ShowJobIndexInPeriodTreeView",
                                                    userAuthorizedActions))
            {
                cmdList.Add(
                    new CommandViewModel(" مدیریت شاخص در دوره جاری", new DelegateCommand(
                                             () =>
                {
                    controller.ShowBusyIndicator("در حال بارگذاری ماجول...");
                    controller.GetRemoteInstance <IPeriodController>(
                        (res, exp) =>
                    {
                        controller.HideBusyIndicator();
                        if (res != null)
                        {
                            var activePeriod = createActivePeriodDTOWithAction();
                            if (activePeriod == null)
                            {
                                return;
                            }
                            res.ShowJobIndexInPeriodTreeView(activePeriod, isShiftPressed);
                        }
                        else if (exp != null)
                        {
                            controller.HandleException(exp);
                        }
                    });
                }
                                             )));
            }

            if (userService.IsUserPermissionGranted(typeof(IPeriodController), "ShowJobPositionInPeriodTreeView",
                                                    userAuthorizedActions))
            {
                cmdList.Add(
                    new CommandViewModel(" مدیریت پست ها در دوره جاری", new DelegateCommand(
                                             () =>
                {
                    controller.ShowBusyIndicator("در حال بارگذاری ماجول...");
                    controller.GetRemoteInstance <IPeriodController>(
                        (res, exp) =>
                    {
                        controller.HideBusyIndicator();
                        if (res != null)
                        {
                            var activePeriod = createActivePeriodDTOWithAction();
                            if (activePeriod == null)
                            {
                                return;
                            }
                            res.ShowJobPositionInPeriodTreeView(activePeriod, isShiftPressed);
                        }
                        else if (exp != null)
                        {
                            controller.HandleException(exp);
                        }
                    });
                }
                                             )));
            }

            if (userService.IsUserPermissionGranted(typeof(IEmployeeController), "ShowEmployeeListView",
                                                    userAuthorizedActions))
            {
                cmdList.Add(
                    new CommandViewModel(LocalizedResources.EmployeeListSubMenu, new DelegateCommand(
                                             () =>
                {
                    controller.ShowBusyIndicator("در حال بارگذاری ماجول...");
                    controller.GetRemoteInstance <IEmployeeController>(
                        (res, exp) =>
                    {
                        controller.HideBusyIndicator();
                        if (res != null)
                        {
                            var activePeriod = createActivePeriodDTOWithAction();
                            if (activePeriod == null)
                            {
                                return;
                            }
                            res.ShowEmployeeListView(CurrentPeriod, isShiftPressed);
                        }
                        else if (exp != null)
                        {
                            controller.HandleException(exp);
                        }
                    });
                }
                                             )));
            }

            if (userService.IsUserPermissionGranted(typeof(IPeriodController), "ShowCalculationListView",
                                                    userAuthorizedActions))
            {
                cmdList.Add(
                    new CommandViewModel(" مدیریت محاسبات در دوره جاری", new DelegateCommand(
                                             () =>
                {
                    controller.ShowBusyIndicator("در حال بارگذاری ماجول...");
                    controller.GetRemoteInstance <IPeriodController>(
                        (res, exp) =>
                    {
                        controller.HideBusyIndicator();
                        if (res != null)
                        {
                            var activePeriod = createActivePeriodDTOWithAction();
                            if (activePeriod == null)
                            {
                                return;
                            }
                            res.ShowCalculationListView(activePeriod, isShiftPressed);
                        }
                        else if (exp != null)
                        {
                            controller.HandleException(exp);
                        }
                    });
                }
                                             )));
            }
            return(cmdList);
        }