예제 #1
0
        /// <summary>
        /// Заполнение словаря параметров resolveContext значениями идентификаторов группы, пользователя, роли
        /// </summary>
        public void FillResolveContext(SessionContext sessionContext, BaseResolveContext resolveContext, Options options)
        {
            // Для повышения быстродействия значения идентификаторов можно закэшировать
            var           userId        = sessionContext.UserInfo.EmployeeId;
            var           unit          = sessionContext.UserInfo.Employee.Unit;
            var           unitId        = sessionContext.ObjectContext.GetObjectRef <StaffUnit>(unit).Id;
            StaffEmployee staffEmployee = sessionContext.ObjectContext.GetObject <StaffEmployee>(userId);
            IStaffService staffService  = sessionContext.ObjectContext.GetService <IStaffService>();
            StringBuilder roleIdList    = new StringBuilder();
            StringBuilder groupIdList   = new StringBuilder();

            foreach (StaffGroup group in staffService.FindEmployeeGroups(staffEmployee))
            {
                var groupId = sessionContext.ObjectContext.GetObjectRef <StaffGroup>(group).Id;
                groupIdList.Append(string.Concat(groupId, ";"));
            }
            foreach (StaffRole role in staffService.FindEmployeeRoles(staffEmployee))
            {
                var roleId = sessionContext.ObjectContext.GetObjectRef <StaffRole>(role).Id;
                roleIdList.Append(string.Concat(roleId, ";"));
            }

            resolveContext.Parameters.Add(Constants.ConditionTypes.UnitConditionType, unitId.ToString());
            resolveContext.Parameters.Add(Constants.ConditionTypes.RolesConditionType, roleIdList.ToString());
            resolveContext.Parameters.Add(Constants.ConditionTypes.GroupsConditionType, groupIdList.ToString());
        }
예제 #2
0
        /// <summary>
        /// Сравнение переданного в функцию значения (value), с тем значением, которое было добавлено в словарь параметров resolveContext
        /// </summary>
        public bool ResolveConditionType(SessionContext sessionContext, BaseResolveContext resolveContext, Guid conditionTypeId, string value)
        {
            if (conditionTypeId == Constants.ConditionTypes.GroupsConditionType)
            {
                if (value == null)
                {
                    return(true);
                }

                if (resolveContext.Parameters.TryGetValue(Constants.ConditionTypes.GroupsConditionType, out var groupValue))
                {
                    return(groupValue.Contains(value));
                }
                else
                {
                    DocsVision.Platform.WebClient.Diagnostics.Trace.TraceVerbose($"ResolveContext doesn't contains option with id = {Constants.ConditionTypes.GroupsConditionType}");
                }
            }
            if (conditionTypeId == Constants.ConditionTypes.UnitConditionType)
            {
                if (value == null)
                {
                    return(true);
                }

                if (resolveContext.Parameters.TryGetValue(Constants.ConditionTypes.UnitConditionType, out var unitValue))
                {
                    return(value == unitValue);
                }
                else
                {
                    DocsVision.Platform.WebClient.Diagnostics.Trace.TraceVerbose($"ResolveContext doesn't contains option with id = {Constants.ConditionTypes.UnitConditionType}");
                }
            }
            if (conditionTypeId == Constants.ConditionTypes.RolesConditionType)
            {
                if (value == null)
                {
                    return(true);
                }

                if (resolveContext.Parameters.TryGetValue(Constants.ConditionTypes.RolesConditionType, out var roleValue))
                {
                    return(roleValue.Contains(value));
                }
                else
                {
                    DocsVision.Platform.WebClient.Diagnostics.Trace.TraceVerbose($"ResolveContext doesn't contains option with id = {Constants.ConditionTypes.UnitConditionType}");
                }
            }

            return(false);
        }
예제 #3
0
 public string GetLocation(SessionContext sessionContext, BaseResolveContext resolveContext, bool specific)
 {
     return(String.Empty);
 }
예제 #4
0
 public bool CheckLayoutAvailability(SessionContext sessionContext, BaseResolveContext resolveContext, out string messsage)
 {
     messsage = null;
     return(true);
 }
예제 #5
0
        public bool SupportContext(SessionContext sessionContext, BaseResolveContext resolveContext)
        {
            bool isSupportContext = false;

            return(isSupportContext);
        }