コード例 #1
0
        private void LoadRefreshView()
        {
            _listStoreModelPermissionItem.Clear();

            //UserProfile _currentXPObject = (UserProfile)_dataSource.Lookup(new Guid("" + TreeView.Model.GetValue(_treeIter, _modelFirstCustomFieldIndex)));
            SYS_UserProfile _currentXPObject = (SYS_UserProfile)FrameworkUtils.GetXPGuidObject(GlobalFramework.SessionXpo, typeof(SYS_UserProfile), new Guid("" + TreeView.Model.GetValue(_treeIter, _modelFirstCustomFieldIndex)));

            for (int i = 0; i < _xpCollectionUserPermissionItem.Count; i++)
            {
                bool tmpCurrentValue = false;
                SYS_UserPermissionItem tmpUserPermissionItem = ((SYS_UserPermissionItem)_xpCollectionUserPermissionItem[i]);

                try
                {
                    for (int j = 0; j < _xpCollectionUserPermissionProfile.Count; j++)
                    {
                        SYS_UserPermissionProfile tmpUserPermissionProfile = ((SYS_UserPermissionProfile)_xpCollectionUserPermissionProfile[j]);
                        if (tmpUserPermissionProfile.UserProfile != null && tmpUserPermissionProfile.PermissionItem != null)
                        {
                            if ((tmpUserPermissionProfile.UserProfile.Oid == _currentXPObject.Oid) &&
                                (tmpUserPermissionProfile.PermissionItem.Oid == tmpUserPermissionItem.Oid))
                            {
                                tmpCurrentValue = tmpUserPermissionProfile.Granted;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message, ex);
                }
                _listStoreModelPermissionItem.AppendValues("" + tmpUserPermissionItem.Oid, tmpUserPermissionItem.Designation, tmpCurrentValue);
            }
        }
コード例 #2
0
        private void UpdateState(string pOid, bool pNewValue)
        {
            //UserProfile _currentXPObject = (UserProfile)_dataSource.Lookup(new Guid("" + TreeView.Model.GetValue(_treeIter, _modelFirstCustomFieldIndex)));
            SYS_UserProfile _currentXPObject = (SYS_UserProfile)FrameworkUtils.GetXPGuidObject(GlobalFramework.SessionXpo, typeof(SYS_UserProfile), new Guid("" + TreeView.Model.GetValue(_treeIter, _modelFirstCustomFieldIndex)));

            SYS_UserPermissionProfile tmpUserPermissionProfileUpdate = null;// (UserPermissionProfile)_xpCollection2.Lookup(new Guid("" + pOid));

            bool needToInsert = true;

            for (int i = 0; i < _xpCollectionUserPermissionItem.Count; i++)
            {
                SYS_UserPermissionItem tmpUserPermissionItem = ((SYS_UserPermissionItem)_xpCollectionUserPermissionItem[i]);

                try
                {
                    if (tmpUserPermissionItem.Oid == new Guid("" + pOid))
                    {
                        for (int j = 0; j < _xpCollectionUserPermissionProfile.Count; j++)
                        {
                            SYS_UserPermissionProfile tmpUserPermissionProfile = ((SYS_UserPermissionProfile)_xpCollectionUserPermissionProfile[j]);

                            if ((tmpUserPermissionProfile.UserProfile != null) && (tmpUserPermissionProfile.PermissionItem != null))
                            {
                                if ((tmpUserPermissionProfile.UserProfile.Oid == _currentXPObject.Oid) &&
                                    (tmpUserPermissionProfile.PermissionItem.Oid == tmpUserPermissionItem.Oid))
                                {
                                    needToInsert = true;
                                    //((UserPermissionProfile)_xpCollection3[j]).Disabled = !pNewValue;
                                    //((UserPermissionProfile)_xpCollectionUserPermissionProfile[j]).Delete();
                                    //Mario Fix: Get Fresh Object else Gives Object Deleted Stress
                                    tmpUserPermissionProfile = (SYS_UserPermissionProfile)FrameworkUtils.GetXPGuidObject(GlobalFramework.SessionXpo, typeof(SYS_UserPermissionProfile), tmpUserPermissionProfile.Oid);
                                    tmpUserPermissionProfile.Delete();
                                    _xpCollectionUserPermissionProfile.Reload();
                                }
                            }
                        }

                        if (needToInsert)
                        {
                            tmpUserPermissionProfileUpdate = (SYS_UserPermissionProfile)Activator.CreateInstance(_xpObjectTypeUserPermissionProfile, GlobalFramework.SessionXpo);
                            tmpUserPermissionProfileUpdate.Reload();
                            tmpUserPermissionProfileUpdate.UserProfile = _currentXPObject;
                            //Mario Fix: Get Fresh Object else Gives Object Deleted Stress
                            tmpUserPermissionItem = (SYS_UserPermissionItem)FrameworkUtils.GetXPGuidObject(GlobalFramework.SessionXpo, typeof(SYS_UserPermissionItem), tmpUserPermissionItem.Oid);
                            tmpUserPermissionProfileUpdate.PermissionItem = tmpUserPermissionItem;
                            tmpUserPermissionProfileUpdate.Granted        = !pNewValue;
                            tmpUserPermissionProfileUpdate.Save();
                            _xpCollectionUserPermissionProfile.Reload();
                        }
                        else
                        {
                        }
                    }
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message, ex);
                }
            }
        }