コード例 #1
0
        /// <summary>
        /// Filters out the sender.
        /// </summary>
        /// <param name="cachedReceiverList">List of all potential recipients.</param>
        /// <param name="iMessage">The message being sent.</param>
        /// <returns>List of all recipients being called.</returns>
        public object[] GetReceivers(object[] cachedReceiverList, System.Runtime.Remoting.Messaging.IMessage iMessage)
        {
            object[] resultList         = new object[cachedReceiverList.Length];
            int      resultListPosition = 0;

            // by all receivers
            for (int i = 0; i < cachedReceiverList.Length; i++)
            {
                // get ReceiverInfo instance
                ReceiverInfo receiverInfo = cachedReceiverList[i] as ReceiverInfo;
                if (receiverInfo == null)
                {
                    continue;
                }

                // fetch the session
                ISessionSupport session = (ISessionSupport)receiverInfo.Tag;

                // and check on the call condition
                if ((string)session["UserId"] != this._userId)
                {
                    resultList[resultListPosition++] = receiverInfo;
                }
            }

            return(resultList);
        }
コード例 #2
0
    /// <summary>
    /// Returns receivers that should be called.
    /// </summary>
    /// <param name="cachedReceiverList">All registered receivers (read-only cached array).</param>
    /// <param name="iMessage">The call.</param>
    /// <returns>Receivers that will be called.</returns>
    public object[] GetReceivers(object[] cachedReceiverList,
                                 IMessage iMessage)
    {
        // get string immediately from the call
        IMethodCallMessage iMethodCallMessage =
            (IMethodCallMessage)iMessage;
        IEnumerable <long> ids = iMethodCallMessage.Args[0] as IEnumerable <long>;

        if (ids == null)
        {
            return((new List <object>(cachedReceiverList)).ToArray());
        }

        // construct result list that will contain filtered receivers
        object[] resultList         = new object[cachedReceiverList.Length];
        int      resultListPosition = 0;

        AuthorizationService authSvc = (AuthorizationService)ServerEnvironment.AuthorizationService;

        // go though all the receivers
        for (int i = 0; i < cachedReceiverList.Length; i++)
        {
            // get the next receiver
            ReceiverInfo receiverInfo = cachedReceiverList[i] as ReceiverInfo;
            if (receiverInfo == null)
            {
                continue;
            }

            // obtain its session
            ISessionSupport session = (ISessionSupport)receiverInfo.Tag;
            User            u       = authSvc.GetUser(session["id"] as SessionId);
            if ((u == null) || (!u.UserRoleID.HasValue))
            {
                continue;
            }

            if (!((UserRoleId)(u.UserRoleID.Value) == UserRoleId.GlobalAdmin) && !_svc.Dao.IsPermittedAll(u, true))
            {
                List <string> pNames  = new List <string>();
                List <object> pValues = new List <object>();
                string        idList  = QueryUtils.GenIDList(ids, pNames, pValues);
                int           idCount = pValues.Count;
                IList         list    =
                    _svc.Dao.FindByNamedParam(new string[] { "entity.ID" }, null, string.Format("entity.ID IN ({0})", idList),
                                              null, pNames.ToArray(), pValues.ToArray(), true, u);
                if ((list == null) || (list.Count == 0))
                {
                    continue;
                }

                if (idCount != list.Count)
                {
                    List <long> newIds = new List <long>(list.Count);
                    foreach (long id in list)
                    {
                        newIds.Add(id);
                    }
                    iMethodCallMessage.Args[0] = newIds;
                }
            }

            resultList[resultListPosition++] = receiverInfo;
        }

        return(resultList);
    }