首页 > 其他分享 >Dynamics CRM 2013 批处理

Dynamics CRM 2013 批处理

时间:2024-04-22 09:12:03浏览次数:30  
标签:account Console Target service Entity new Dynamics 2013 CRM

GetService

using System;
using System.Configuration;
using Microsoft.Xrm.Client;
using Microsoft.Xrm.Client.Services;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
            ConnectionStringSettings settings = new ConnectionStringSettings("ConnString", connectionString);
            CrmConnection crmConn = new CrmConnection(settings);
            IOrganizationService service = new OrganizationService(crmConn);
            Entity entity = service.Retrieve("account", new Guid(""), new ColumnSet(true));
            Console.ReadKey();
        }
    }
}    

CreateRequest

Entity account = new Entity("account")
{
     Attributes = {
         //String primary name
         {"name","张三" },
         //Yes/No column
         {"creditonhold", false },
         // DateTime
         {"lastusedincampaign", new DateTime(2023, 1, 1) },
         // Double
         {"address1_latitude",47.642311},
         {"address1_longitude",-122.136841},
         // Integer
         {"numberofemployees", 500 },
         // Money
         {"revenue",new Money(new decimal(5000000.00))},
         // Choice column: Preferred Customer
         {"accountcategorycode",new OptionSetValue(1)}
     }
};
//Create the account
CreateRequest request = new CreateRequest()
{
    Target = account
};
var response = (CreateResponse)service.Execute(request);
Console.WriteLine($"Created record ID: {response.id}");

RetrieveRequest

string tableLogicalName = "account";
string id = "271027A5-56FD-EE11-B4ED-005056A99CFC";
Guid accountid = new Guid(id);

RetrieveRequest request = new RetrieveRequest()
{
    ColumnSet = new ColumnSet(
        "accountcategorycode",
        "address1_latitude",
        "address1_longitude",
        "creditonhold",
        "numberofemployees",
        "primarycontactid",
        "revenue",
        "name"
    ),
    Target = new EntityReference(tableLogicalName, accountid)
};

var response = (RetrieveResponse)service.Execute(request);

UpdateRequest

Entity account = new Entity("account");
account.Id = new Guid("271027A5-56FD-EE11-B4ED-005056A99CFC");
account["name"] = "李四";

//Update the account
UpdateRequest update = new UpdateRequest()
{
    Target = account
};
(UpdateResponse)service.Execute(update);

DeleteRequest

EntityReference erAccount = new EntityReference("account", new Guid("271027A5-56FD-EE11-B4ED-005056A99CFC"));
//Delete the account
DeleteRequest delete = new DeleteRequest()
{
    Target = erAccount
};
(DeleteResponse)service.Execute(delete);

ExecuteMultipleRequest

以下示例仅为展示,并不可直接运行

//集合总数建议每次不超过1000条
OrganizationRequestCollection requests = new OrganizationRequestCollection();
requests.Add(new CreateRequest() { Target = new Entity() });
requests.Add(new UpdateRequest() { Target = new Entity() });
requests.Add(new DeleteRequest() { Target = new EntityReference() });
ExecuteMultipleRequest request = new ExecuteMultipleRequest()
{
    Settings = new ExecuteMultipleSettings
    {
        ContinueOnError = true,//该值指示如果正在处理的当前请求返回错误,是否应继续执行 Requests 集合中的消息请求。
        ReturnResponses = true//该值指示是否应返回对已处理的每个消息请求的响应。
    },
    Requests = requests
};
var response = (ExecuteMultipleResponse)service.Execute(request);
response.Responses.ToList().ForEach(x =>
{
    if (x.Fault != null)
    {

        Console.WriteLine($"Request {x.RequestIndex} failed with error: {x.Fault.Message}");
    }
    else
    {
        switch (x.Response.ResponseName)
        {
            case "Create":
                var createResponse = (CreateResponse)x.Response;
                Console.WriteLine($"Created record with ID:{createResponse.id}");
                break;
            case "Update":
                Console.WriteLine("Record updated.");
                break;
            case "Delete":
                Console.WriteLine("Record deleted.");
                break;
        }
    }
});

标签:account,Console,Target,service,Entity,new,Dynamics,2013,CRM
From: https://www.cnblogs.com/YuYangBlogs/p/18146124

相关文章

  • P5897 [IOI2013] wombats
    MyBlogsP5897[IOI2013]wombats有点恐怖。首先\(R,C\)很不平衡,考虑用一棵竖着的线段树维护较大的\(R\)维,每个节点上需要存的是\(C\timesC\)的数组\(d\),\(d_{i,j}\)表示该节点的最上面一行第\(i\)个到最下面一行第\(j\)个的最短路。因为已经处理好了左右儿子内......
  • P5610 [Ynoi2013] 大学
    [Ynoi2013]大学-洛谷傻逼卡常题发现自己基础数据结构用的还不是很熟练,并没有想到一开始的\(set\)做法,更不用提后面的并查集优化了首先每个数最多被进行\(O(\logA)\)次有效除法,如果我们找到区间中哪些数要被除后直接暴力用树状数组单点修改,可以做到\(O(n\logn......
  • P5607 [Ynoi2013] 无力回天 NOI2017
    [Ynoi2013]无力回天NOI2017-洛谷看到题目可以想到线性基线性基可以做到\(O(\logA)\)加入,\(O(\logA)\)查询,\(O(\log^2A)\)合并考虑直接暴力的用线段树维护每个节点的线性基,可以做到\(O(n\logn\log^2A)\)但有区间修改?差分转单点修,发现线性基\(a_{[l......
  • 【Linux】虚拟化技术docker搭建SuitoCRM系统及汉化
    CRM系统CRM(CustomerRelationshipManagement,客户关系管理)系统是一种用于管理和优化企业与客户关系的软件工具。在商业竞争激烈的现代社会中,CRM系统已成为许多企业提高销售、增强客户满意度和实现持续增长的重要工具。本文将介绍CRM系统的概念、功能以及其在企业中的重要性......
  • Nginx 文件名逻辑漏洞(CVE-2013-4547)复现
    漏洞原理影响范围:Nginx0.8.41~1.4.3影响范围:Nginx1.5.0~1.5.7Nginx在解析php文件的时候通常在配置文件中如下配置location~\.php${roothtml;includefastcgi_params;fastcgi_passphp:9000;......
  • P8600 [蓝桥杯 2013 省 B] 连号区间数 and CF526F
    问题转化很容易就能把原问题转化成:求满足Max-Min=r-l的区间个数暴力解法根据上面得到的性质,我们可以暴力枚举区间,来判断当前区间是否满足性质#include<iostream>#include<stdio.h>#include<algorithm>#include<string>#include<cmath>#include<string.h>#def......
  • 洛谷题单指南-图的基本应用-P1983 [NOIP2013 普及组] 车站分级
    原题链接:https://www.luogu.com.cn/problem/P1983题意解读:由于“如果这趟车次停靠了火车站x,则始发站、终点站之间所有级别大于等于火车站x的都必须停靠”。因此,在始发站和终点站之间,能停靠的车站都是级别较高的,没有停靠的车站都是级别较低的,计算最少有多少个不同级别。解题思路:......
  • Camera KMD ISP学习笔记(7)-CRM pipeline delay和V4L2 Event
    学习资料来源:https://deepinout.com/camx-kmd/camera-kmd-isp-subsystem-intro.html仅用于个人学习,侵联删 Realtimepipeline或实时Pipeline,在这个Pipeilne上的硬件设备有一些特点:实时,实时是指streamon后一直在出图,如下图的蓝色线(flash和actuator不会出图,但也是挂载到Realt......
  • P1967 [NOIP2013 提高组] 货车运输 题解
    P1967[NOIP2013提高组]货车运输原题地址思路:由于题目要求的是使两点之间的最小边权最大,所以可以构造最大生成树(最大生成树一定是最大瓶颈生成树,而瓶颈生成树上两点之间的路径,在原图中的所有路径中,最小边权仍然最大,即满足题目要求,详见https://oi-wiki.org/graph/mst/#性质),......
  • C108 整体二分+树状数组(区修+区查)P3332 [ZJOI2013] K大数查询
    视频链接:C108整体二分+树状数组(区修+区查)P3332[ZJOI2013]K大数查询_哔哩哔哩_bilibili   参考:C82树状数组区修+区查P3372线段树1-董晓-博客园(cnblogs.com)LuoguP3332[ZJOI2013]K大数查询//整体二分+树状数组(区修+区查)O(n*logn*logn)#include<iost......