crm操作安全字段

using System;

using Microsoft.Xrm.Sdk;

using Microsoft.Xrm.Sdk.Messages;

/// <summary>

/// 安全字段

/// </summary>

public class FieldSecurityProfileHelper

{

public static readonly string entityName = "fieldsecurityprofile";

public static readonly string FieldPermission = "FieldPermission";

public Guid fieldSecurityProfileId = Guid.Empty;

public Guid fieldPermissionId = Guid.Empty;

/// <summary>

/// 创建安全字段

/// </summary>

public void Create(IOrganizationService service)

{

Entity en = new Entity() { LogicalName = entityName };

en["name"] = "new_name";

fieldSecurityProfileId = service.Create(en);

}

/// <summary>

/// 给安全字段添加团队

/// </summary>

/// <param name="service">服务</param>

/// <param name="teamId">团队</param>

public void AddTeam(IOrganizationService service,Guid teamId)

{

AssociateRequest request = new AssociateRequest();

request.Relationship = new Relationship("teamprofiles_association");

request.Target = new EntityReference() { LogicalName = entityName,Id = fieldSecurityProfileId };

request.RelatedEntities = new EntityReferenceCollection();

request.RelatedEntities.Add(new EntityReference() { LogicalName = "team" ,Id = teamId });

service.Execute(request);

}

/// <summary>

/// 给安全字段移除团队

/// </summary>

/// <param name="service">服务</param>

/// <param name="teamId">团队</param>

public void RemoveTeam(IOrganizationService service, Guid teamId)

{

DisassociateRequest request = new DisassociateRequest();

request.Relationship = new Relationship("teamprofiles_association");

request.Target = new EntityReference() { LogicalName = entityName, Id = fieldSecurityProfileId };

request.RelatedEntities = new EntityReferenceCollection();

request.RelatedEntities.Add(new EntityReference() { LogicalName = "team", Id = teamId });

service.Execute(request);

}

/// <summary>

/// 给安全字段添加用户

/// </summary>

/// <param name="service">服务</param>

/// <param name="teamId">用户</param>

public void AddUser(IOrganizationService service,Guid userId)

{

AssociateRequest request = new AssociateRequest();

request.Relationship = new Relationship("systemuserprofiles_association");

request.Target = new EntityReference() { LogicalName = entityName, Id = fieldSecurityProfileId };

request.RelatedEntities = new EntityReferenceCollection();

request.RelatedEntities.Add(new EntityReference() { LogicalName = "systemuser", Id = userId });

service.Execute(request);

}

/// <summary>

/// 给安全字段移除用户

/// </summary>

/// <param name="service">服务</param>

/// <param name="teamId">用户</param>

public void RemoveUser(IOrganizationService service,Guid userId)

{

DisassociateRequest request = new DisassociateRequest();

request.Relationship = new Relationship("systemuserprofiles_association");

request.Target = new EntityReference() { LogicalName = entityName, Id = fieldSecurityProfileId };

request.RelatedEntities = new EntityReferenceCollection();

request.RelatedEntities.Add(new EntityReference() { LogicalName = "systemuser", Id = userId });

service.Execute(request);

}

/// <summary>

/// 把安全字段和实体关联

/// </summary>

/// <param name="service">服务</param>

/// <param name="entity">实体</param>

public void CreateAttribute(IOrganizationService service,string entity)

{

Entity en = new Entity() { LogicalName = FieldPermission };

//实体名称

en["entityname"] = entity;

en["canread"] = new OptionSetValue(FieldPermissionType.Allowed);

en["attributelogicalname"] = "new_attributename";

en["fieldsecurityprofileid"] = new EntityReference() { LogicalName = entityName,Id = fieldSecurityProfileId };

fieldSecurityProfileId = service.Create(en);

}

/// <summary>

/// 删除实体里面的安全字段

/// </summary>

/// <param name="service">服务</param>

public void RemoveAttribute(IOrganizationService service)

{

service.Delete(FieldPermission, fieldSecurityProfileId);

}

/// <summary>

/// 删除安全字段

/// </summary>

public void Delete(IOrganizationService service)

{

service.Delete(entityName, fieldSecurityProfileId);

}

}

crm操作安全字段

时间: 2024-11-12 02:42:31

crm操作安全字段的相关文章

oracle 下操作blob字段是否会产生大量redo

操作blob字段是否会产生大量redo,答案是不会.以下来做一个实验,測试数据库版本号是11.2.0.1.0: --创建一张表做測试之用 create table test_blob ( id number, tupian blob ); import java.io.FileInputStream; import java.io.OutputStream; import java.sql.Connection; import java.sql.DriverManager; import jav

crm操作业务部门

using System; using System.Linq; using Microsoft.Xrm.Sdk; using Microsoft.Crm.Sdk.Messages; using System.Collections.Generic; using Microsoft.Xrm.Sdk.Messages; /// <summary> /// 操作业务部门 /// </summary> public class BusinessUnitHelper { public st

crm操作权限

using System; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Query; using System.Collections.Generic; using Microsoft.Crm.Sdk.Messages; /// <summary> /// 权限 /// </summary> public class PrivilegeHelper { public static readonly string entityNa

Mysql字段操作—增加字段、删除字段、修改字段名、修改字段类型(约束条件) 【转】

1.增加字段:    alter table   tablename    add   new_field_id   type   not null default '0';     例:     alter table mmanapp_mmanmedia add appid_id integer not null default 372; 增加主键: alter table  tabelname   add   new_field_id   type    default 0 not null

mysql数据表的基本操作:表结构操作,字段操作

本节介绍: 表结构操作 创建数据表. 查看数据表和查看字段. 修改数据表结构 删除数据表 字段操作 新增字段. 修改字段数据类型.位置或属性. 重命名字段 删除字段 首发时间:2018-02-18  21:31 表结构操作 创建数据表: 语法  : create table [if not exists] 表名( 字段名字 数据类型, 字段名字 数据类型 )[表选项]; 表选项  : 字符集:charset表中存储数据的字符集 校对集:colloate表中用来校对数据的校对集 存储引擎  :en

【转载】JDBC操作LOB字段

转自:http://www.cnblogs.com/tengtao93/p/4984689.html 1.LOB(Large Objects)大对象,是用来存储大量的二进制和文本数据的一种数据类型(一个LOB字段可存储多达4GB的数据) --LOB分类两种类型:1)内部LOB: 2)外部LOB: --内部LOB将数据以字节流的形式存储在数据库的内部.因而,内部LOB的许多操作都可以参与事务,也可以像处理普通数据一样对其进行备份和恢复操作: --Oracle支持三种类型的内部LOB:1)BLOB(

crm操作商机实体

using System; using Microsoft.Xrm.Sdk; using Microsoft.Crm.Sdk.Messages; public class OpportunityHelper { public static readonly string entityName = "opportunity"; public Guid opportunityId = Guid.Empty; /// <summary> /// 创建商机 /// </sum

表操作及字段查询

模型层 单表操作 1. all(): 查询所有结果 2. filter(**kwargs): 它包含了与所给筛选条件相匹配的对象 3.get(**kwargs): 返回与所给筛选条件相匹配的对象,返回结果有且只有一个,如果符合筛选条件的对象超过一个或者没有都会抛出错误. 4. exclude(**kwargs): 它包含了与所给筛选条件不匹配的对象.类似于取反. 5. values(*field): 返回一个ValueQuerySet——一个特殊的QuerySet,运行后得到的并不是一系列mod

1122 django属性操作orm字段数据操作

目录 1. 静态文件的配置 手动静态文件的访问资源 静态文件的动态绑定 2.request方法 2.1 请求方式 2.2 获取前端的请求方式 request.method 2.3 request方法 request.method request.POST request.GET .get方法 3. pycharm连接MySQL 4. django连接MySQL数据库 4.1.配置文件配置 4.2.指定使用的数据库连接模块 5.django orm简介 5.1 基本概念 1. orm对象关系映射