Exemplo n.º 1
0
        public static IList <int> GetOperationsForObject(SECURED_OBJECT_TYPE objectType, int userID, int?objectID, DateTime?targetDate)
        {
            using (var c = ServerModel.AcruireOpenedConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    var at = objectType.GetSecurityAtr();
                    cmd.CommandText = at.GetRetrieveOperationsForObjectProcName();
                    cmd.Parameters.Assign(new { UserID = userID, TargetDate = targetDate });
                    cmd.Parameters.AddWithValue(at.Name + "ID", objectID);

                    return(cmd.FullReadInts());
                }
            }
        }
Exemplo n.º 2
0
        private static IList <int> GetIDsFromPermissionsForGroupInternal(SECURED_OBJECT_TYPE objectType, int groupID, int?operationID, DateTime?targetDate, string columnName)
        {
            using (var c = ServerModel.AcruireOpenedConnection())
            {
                using (var cmd = c.CreateCommand())
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    var at = objectType.GetSecurityAtr();
                    cmd.CommandText = at.GetRetrievePermissionsForGroupProcName();
                    cmd.Parameters.Assign(new { GroupID = groupID, TargetDate = targetDate });
                    cmd.Parameters.AddWithValue(at.Name + "OperationID", operationID);

                    var r = cmd.FullReadInts(columnName);
                    r.RemoveDuplicates();
                    return(r);
                }
            }
        }
Exemplo n.º 3
0
        public static void Initialize()
        {
            using (Logger.Scope(Translations.PermissionsManager_Initialize_Initializing_Security))
            {
                if (IsInitialized())
                {
                    throw new DMError(Translations.PermissionsManager_Initialize__0__is_already_initialized, typeof(PermissionsManager).Name);
                }
                ID = Guid.NewGuid();

                using (var cn = ServerModel.AcruireOpenedConnection())
                {
                    using (var c = cn.CreateCommand())
                    {
                        CreateDBVersionFunc(c);

                        foreach (var f in typeof(SECURED_OBJECT_TYPE).GetFields())
                        {
                            if (f.IsSpecialName)
                            {
                                continue;
                            }

                            Logger.WriteLine(f.Name);

                            var a = f.GetAtr <SecuredObjectTypeAttribute>();
                            CheckSupport(a.RuntimeClass, typeof(ISecuredDataObject));
                            CheckSupport(a.OperationsClass, typeof(IFxDataObject));
                            CheckSupport(a.OperationsClass, typeof(INamedDataObject));

                            CreateGetOperationsForObjectProc(a, c);
                            CreateGetPermissionsForUser(a, c);
                            CreateCheckPermissionProc(a, c);
                            CreateGetPermissionsForGroup(a, c);
                        }
                    }
                }
            }
        }