Exemple #1
0
        private static void GetPermissionInfoUIByLocal(V_UserMenuPermission Menu)
        {
            try
            {
                string strEmployeeID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;

                List <SMT.SaaS.LocalData.V_UserPermissionUI> userPermissionUIs = new List <SMT.SaaS.LocalData.V_UserPermissionUI>();

                List <V_UserPermUILocal>    userPermUILocals = V_UserPermUILocalVM.GetAllV_UserPermUILocal(strEmployeeID);
                List <V_CustomerPermission> customerPerms    = V_CustomerPermissionVM.GetAllV_CustomerPermission(strEmployeeID);
                List <V_PermissionValue>    permissionValues = V_PermissionValueVM.GetAllV_PermissionValue(strEmployeeID);
                List <V_OrgObject>          v_OrgObjects     = V_OrgObjectVM.GetAllV_OrgObject(strEmployeeID);

                if (userPermUILocals == null)
                {
                    return;
                }

                foreach (var item in userPermUILocals)
                {
                    if (item.EntityMenuID != null)
                    {
                        if (ViewModel.Context.CacheMenuPermissionList == null)
                        {
                            ViewModel.Context.CacheMenuPermissionList = new List <string>();
                        }

                        SMT.SaaS.LocalData.V_UserPermissionUI userPermissionUI = item.CloneObject <SMT.SaaS.LocalData.V_UserPermissionUI>(new SMT.SaaS.LocalData.V_UserPermissionUI());

                        V_CustomerPermission v_cusPerm = null;
                        foreach (var p in customerPerms)
                        {
                            if (p.UserModuleID != item.UserModuleID)
                            {
                                continue;
                            }

                            v_cusPerm = p;
                            break;
                        }

                        if (v_cusPerm == null)
                        {
                            userPermissionUIs.Add(userPermissionUI);
                            continue;
                        }

                        userPermissionUI.CustomerPermission = v_cusPerm.CloneObject <SMT.SaaS.LocalData.CustomerPermission>(new SMT.SaaS.LocalData.CustomerPermission());
                        List <SMT.SaaS.LocalData.PermissionValue> permValues = new List <SaaS.LocalData.PermissionValue>();
                        foreach (var d in permissionValues)
                        {
                            if (v_cusPerm == null)
                            {
                                break;
                            }

                            if (d.UserModuleID != v_cusPerm.UserModuleID)
                            {
                                continue;
                            }

                            SMT.SaaS.LocalData.PermissionValue  permValue  = d.CloneObject <SMT.SaaS.LocalData.PermissionValue>(new SaaS.LocalData.PermissionValue());
                            List <SMT.SaaS.LocalData.OrgObject> orgObjects = new List <SaaS.LocalData.OrgObject>();
                            foreach (var o in v_OrgObjects)
                            {
                                if (v_cusPerm == null)
                                {
                                    break;
                                }

                                if (o.UserModuleID != d.UserModuleID)
                                {
                                    continue;
                                }

                                SMT.SaaS.LocalData.OrgObject orgObject = o.CloneObject <SMT.SaaS.LocalData.OrgObject>(new SaaS.LocalData.OrgObject());
                                orgObjects.Add(orgObject);
                            }
                            permValue.OrgObjects.AddRange(orgObjects);
                            permValues.Add(permValue);
                        }

                        userPermissionUI.CustomerPermission.PermissionValue.AddRange(permValues);
                    }
                }
                if (userPermissionUIs != null)
                {
                    foreach (var u in userPermissionUIs)
                    {
                        if (SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.PermissionInfoUI == null)
                        {
                            SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.PermissionInfoUI = new List <SaaS.LocalData.V_UserPermissionUI>();
                        }

                        if (!SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.PermissionInfoUI.Contains(u))
                        {
                            SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.PermissionInfoUI.Add(u);
                        }
                    }
                }

                if (ViewModel.Context.CacheMenuPermissionList.Contains(Menu.ENTITYMENUID) == false)
                {
                    ViewModel.Context.CacheMenuPermissionList.Add(Menu.ENTITYMENUID);
                }
            }
            catch (Exception ex)
            {
                SMT.SAAS.Main.CurrentContext.AppContext.logAndShow(ex.ToString());
            }
            finally
            {
                if (OnGetUserMenuPermissionCompleted != null)
                {
                    OnGetUserMenuPermissionCompleted(null, EventArgs.Empty);
                }
            }
        }
Exemple #2
0
        private void GetPermissionInfoUIByLocal()
        {
            string strEmployeeID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;

            List <SMT.SaaS.LocalData.V_UserPermissionUI> userPermissionUIs = new List <SMT.SaaS.LocalData.V_UserPermissionUI>();

            List <V_UserPermUILocal>    userPermUILocals = V_UserPermUILocalVM.GetAllV_UserPermUILocal(strEmployeeID);
            List <V_CustomerPermission> customerPerms    = V_CustomerPermissionVM.GetAllV_CustomerPermission(strEmployeeID);
            List <V_PermissionValue>    permissionValues = V_PermissionValueVM.GetAllV_PermissionValue(strEmployeeID);
            List <V_OrgObject>          v_OrgObjects     = V_OrgObjectVM.GetAllV_OrgObject(strEmployeeID);

            if (userPermUILocals == null)
            {
                return;
            }

            foreach (var item in userPermUILocals)
            {
                if (item.EntityMenuID != null)
                {
                    if (ViewModel.Context.CacheMenuPermissionList == null)
                    {
                        ViewModel.Context.CacheMenuPermissionList = new List <string>();
                    }

                    SMT.SaaS.LocalData.V_UserPermissionUI userPermissionUI = item.CloneObject <SMT.SaaS.LocalData.V_UserPermissionUI>(new SMT.SaaS.LocalData.V_UserPermissionUI());

                    V_CustomerPermission v_cusPerm = null;
                    foreach (var p in customerPerms)
                    {
                        if (p.UserModuleID != item.UserModuleID)
                        {
                            continue;
                        }

                        v_cusPerm = p;
                        break;
                    }

                    if (v_cusPerm == null)
                    {
                        userPermissionUIs.Add(userPermissionUI);
                        continue;
                    }

                    userPermissionUI.CustomerPermission = v_cusPerm.CloneObject <SMT.SaaS.LocalData.CustomerPermission>(new SMT.SaaS.LocalData.CustomerPermission());
                    List <SMT.SaaS.LocalData.PermissionValue> permValues = new List <SaaS.LocalData.PermissionValue>();
                    foreach (var d in permissionValues)
                    {
                        if (v_cusPerm == null)
                        {
                            break;
                        }

                        if (d.UserModuleID != v_cusPerm.UserModuleID)
                        {
                            continue;
                        }

                        SMT.SaaS.LocalData.PermissionValue  permValue  = d.CloneObject <SMT.SaaS.LocalData.PermissionValue>(new SaaS.LocalData.PermissionValue());
                        List <SMT.SaaS.LocalData.OrgObject> orgObjects = new List <SaaS.LocalData.OrgObject>();
                        foreach (var o in v_OrgObjects)
                        {
                            if (v_cusPerm == null)
                            {
                                break;
                            }

                            if (o.UserModuleID != d.UserModuleID)
                            {
                                continue;
                            }

                            SMT.SaaS.LocalData.OrgObject orgObject = o.CloneObject <SMT.SaaS.LocalData.OrgObject>(new SaaS.LocalData.OrgObject());
                            orgObjects.Add(orgObject);
                        }
                        permValue.OrgObjects.AddRange(orgObjects);
                        permValues.Add(permValue);
                    }

                    userPermissionUI.CustomerPermission.PermissionValue.AddRange(permValues);
                }
            }

            foreach (var u in userPermissionUIs)
            {
                if (SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.PermissionInfoUI == null)
                {
                    SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.PermissionInfoUI = new List <SaaS.LocalData.V_UserPermissionUI>();
                }

                if (!SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.PermissionInfoUI.Contains(u))
                {
                    SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.PermissionInfoUI.Add(u);
                }
            }

            if (ViewModel.Context.CacheMenuPermissionList.Contains(_currentClickModule.ModuleID) == false)
            {
                ViewModel.Context.CacheMenuPermissionList.Add(_currentClickModule.ModuleID);
            }

            GetModuleContent(_currentClickModule.ModuleName, _currentClickModule.Description);
        }