/// <summary>
		/// 获取所有管理员用户信息
		/// </summary>
		/// <returns></returns>
		public static IEnumerable<IUser> GetAllUsers()
		{
			/*
			RolesDefineConfig rolesConfig = RolesDefineConfig.GetConfig().;

			List<string> roleNames = new List<string>();

			foreach (RolesDefine roleDefine in rolesConfig.RolesDefineCollection)
			{
				roleNames.Add(roleDefine.Name);
			}
			               
			IRole[] roles = rolesConfig.GetRolesInstances(roleNames.ToArray()); */

			IRole[] roles = RolesDefineConfig.GetConfig().RolesDefineCollection["ProcessAdmin"].GetRolesInstances();

			Dictionary<string, IUser> allUsers = new Dictionary<string, IUser>();

			foreach (IRole role in roles)
			{
				WfRoleResourceDescriptor roleDescriptor = new WfRoleResourceDescriptor(role);
				WfResourceDescriptorCollection roleDescriptors = new WfResourceDescriptorCollection(roleDescriptor);
				roleDescriptors.Add(roleDescriptor);

				OguDataCollection<IUser> roleUsers = roleDescriptors.ToUsers();

				foreach (IUser user in roleUsers)
				{
					if (allUsers.ContainsKey(user.ID) == false)
						allUsers.Add(user.ID, user);
				}
			}

			return allUsers.Values;
		}
Beispiel #2
0
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            WfRoleResourceDescriptor roleResourceDesp = (WfRoleResourceDescriptor)obj;

            IDictionary <string, object> dictionary = base.Serialize(obj, serializer);

            dictionary.Add("Role", roleResourceDesp.Role);
            return(dictionary);
        }
Beispiel #3
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            WfRoleResourceDescriptor roleResourceDesp = (WfRoleResourceDescriptor)base.Deserialize(dictionary, type, serializer);
            IRole role = JSONSerializerExecute.Deserialize <OguRole>(dictionary["Role"]);

            roleResourceDesp.Role = role;

            return(roleResourceDesp);
        }
		protected void btnConfirm_Click(object sender, EventArgs e)
		{
			try
			{
				IRole role = GetSelectedRole(ddlApps.SelectedValue, ddlRoles.SelectedValue);

				role.NullCheck("应用或角色的代码名称不能为空");

				WfRoleResourceDescriptor roleRes = new WfRoleResourceDescriptor(role);

				resultData.Value = JSONSerializerExecute.Serialize(roleRes);

				Page.ClientScript.RegisterStartupScript(this.GetType(), "returnRole",
					string.Format("window.returnValue = $get('resultData').value; top.close();"),
					true);
			}
			catch (System.Exception ex)
			{
				WebUtility.ShowClientError(ex.Message, ex.StackTrace, "错误");
			}
		}
		public void WfRoleResourceDescriptorConverterTest()
		{
			WfConverterHelper.RegisterConverters();

			IUser user = (IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object;

			RoleCollection roleColl = user.Roles["OGU_ADMIN"];

			WfRoleResourceDescriptor roleResourceDesp = new WfRoleResourceDescriptor(roleColl[0]);
			string result = JSONSerializerExecute.Serialize(roleResourceDesp);
			Console.WriteLine(result);
			WfRoleResourceDescriptor deserializedRoleDesp = JSONSerializerExecute.Deserialize<WfRoleResourceDescriptor>(result);

			string reSerialized = JSONSerializerExecute.Serialize(deserializedRoleDesp);

			Assert.AreEqual(result, reSerialized);

			ResourceConverterTest(roleResourceDesp);

		}
        /// <summary>
        /// 创建带分支流程的模版。为了测试XElement序列化,里面需要包含角色、资源、条件等内容
        /// </summary>
        /// <returns></returns>
        public static IWfProcessDescriptor CreateProcessDescriptorForXElementSerialization()
        {
            IWfProcessDescriptor processDesp = CreateSimpleProcessDescriptorWithBranchTemplate();

            IWfActivityDescriptor normalActivity = processDesp.Activities["NormalActivity"];

            string roleDesp = RolesDefineConfig.GetConfig().RolesDefineCollection["testRole"].Roles;

            OguRole role = new OguRole(roleDesp);

            WfRoleResourceDescriptor roleResource = new WfRoleResourceDescriptor(role);
            normalActivity.EnterEventReceivers.Add(roleResource);

            WfDynamicResourceDescriptor dynResource = new WfDynamicResourceDescriptor();
            dynResource.Condition.Expression = "Leader";
            normalActivity.LeaveEventReceivers.Add(dynResource);

            processDesp.CancelEventReceivers.Add(dynResource);

            WfRelativeLinkDescriptor relLink = new WfRelativeLinkDescriptor("TestUrl");

            relLink.Category = "Test";
            relLink.Url = "http://localhost/www.baidu.com";

            processDesp.RelativeLinks.Add(relLink);

            return processDesp;
        }
Beispiel #7
0
		public void QueryRoleUserByContext()
		{
			SOARole role = PrepareSOARole();

			WfRoleResourceDescriptor roleDescriptor = new WfRoleResourceDescriptor(role);
			WfResourceDescriptorCollection roles = new WfResourceDescriptorCollection();

			roles.Add(roleDescriptor);

			Dictionary<string, object> parameters = new Dictionary<string, object>();

			parameters["CostCenter"] = "1002";
			parameters["FormType"] = "Form1";

			WfApplicationParametersContext.CreateContext(parameters);

			OguDataCollection<IUser> users = roles.ToUsers();

			Assert.AreEqual(4, users.Count);
		}