Example #1
0
        public void DeleteRole()
        {
            DataSet dsReturn = new DataSet();

            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();
                if (null != serverFactory)
                {
                    dsReturn  = serverFactory.CreateIRoleEngine().DeleteRole(_roleKey);
                    _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                }
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
        }
Example #2
0
        public void SaveRole(bool isNew)
        {
            DataSet   dsReturn  = new DataSet();
            DataSet   ds        = new DataSet();
            Hashtable hashTable = new Hashtable();
            DataTable dataTable = new DataTable();

            if (isNew)
            {
                hashTable.Add(RBAC_ROLE_FIELDS.FIELD_ROLE_KEY, _roleKey);
                hashTable.Add(RBAC_ROLE_FIELDS.FIELD_ROLE_NAME, _roleName);
                hashTable.Add(RBAC_ROLE_FIELDS.FIELD_DESCRIPTIONS, _description);
                hashTable.Add(RBAC_ROLE_FIELDS.FIELD_REMARK, _remark);
                hashTable.Add(RBAC_ROLE_FIELDS.FIELD_CREATOR, Creator);
                hashTable.Add(RBAC_ROLE_FIELDS.FIELD_CREATE_TIMEZONE, CreateTimeZone);
                dataTable           = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(hashTable);
                dataTable.TableName = RBAC_ROLE_FIELDS.DATABASE_TABLE_NAME;
                ds.Tables.Add(dataTable);
            }
            else
            {
                //update
                if (IsDirty)
                {
                    if (DirtyList.Count > 0)
                    {
                        foreach (string key in DirtyList.Keys)
                        {
                            hashTable.Add(key, DirtyList[key].FieldNewValue);
                        }
                        hashTable.Add(RBAC_ROLE_FIELDS.FIELD_ROLE_KEY, _roleKey);
                        dataTable           = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(hashTable);
                        dataTable.TableName = RBAC_ROLE_FIELDS.DATABASE_TABLE_NAME;
                        ds.Tables.Add(dataTable);
                    }
                }
            }
            try
            {
                IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();
                if (null != serverFactory)
                {
                    if (isNew)
                    {
                        dsReturn = serverFactory.CreateIRoleEngine().AddRole(ds);
                    }
                    else
                    {
                        dsReturn = serverFactory.CreateIRoleEngine().UpdateRole(ds);
                    }
                    _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn);
                }
            }
            catch (Exception ex)
            {
                _errorMsg = ex.Message;
            }
            finally
            {
                CallRemotingService.UnregisterChannel();
            }
        }