Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        private static void FillRoleUsers(string roleName, OguDataCollection <IUser> users)
        {
            SOARole role = new SOARole(roleName);

            WfRoleResourceDescriptor roleResource = new WfRoleResourceDescriptor(role);

            roleResource.FillUsers(users);
        }
        public override void ClientToServer(WfClientResourceDescriptor client, ref WfResourceDescriptor server)
        {
            SOARole role = new SOARole(((WfClientRoleResourceDescriptor)client).FullCodeName);

            if (server == null)
            {
                server = new WfRoleResourceDescriptor(role);
            }
            else
            {
                ((WfRoleResourceDescriptor)server).Role = role;
            }
        }
        public override void ServerToClient(WfResourceDescriptor server, ref WfClientResourceDescriptor client)
        {
            WfRoleResourceDescriptor roleDesp = (WfRoleResourceDescriptor)server;

            if (roleDesp.Role != null)
            {
                if (client == null)
                {
                    client = new WfClientRoleResourceDescriptor(roleDesp.Role.FullCodeName);
                }
                else
                {
                    ((WfClientRoleResourceDescriptor)client).FullCodeName = roleDesp.Role.FullCodeName;
                }
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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, "错误");
            }
        }
        /// <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);
        }