通过创建Marketing list的方式来创建Quick Campaign

 因为CRM Service不能直接创建web service ,当有时候需要创建的时候N多个phone call的时候,就不得不一个一个的创建,下面是一个通过创建marketing list 的方式来创建Quick campaign , 从而批量的创建phone call activities.

  1. #region CreatePhoneCallInstances
  2.         public phonecall CreatePhoneCallInstance(string subject, string description, string due)
  3.         {
  4.             //new instance of phonecall
  5.             phonecall call = new phonecall();
  6.             call.subject = subject;
  7.             call.description = description;
  8.             CrmDateTime dueDate = new CrmDateTime();
  9.             dueDate.Value = due;
  10.             call.scheduledend = dueDate;
  11.             CrmDateTime actualStartDate = new CrmDateTime();
  12.             actualStartDate.Value = DateTime.Now.ToString();
  13.             call.actualstart = actualStartDate;
  14.             CrmBoolean frequent = new CrmBoolean();
  15.             frequent.Value = false;
  16.             call.new_frequent = frequent;
  17.             return call;
  18.         }
  19.         #endregion
  20.         #region CreatPhoneCallActivity
  21.         public void CreateMarketingListActivity(string name, string subject, string description, string due, string assignto,List<AccountInfo> accountInfoList, CrmService service)
  22.         {
  23.             try
  24.             {
  25.                 //create a marketing list
  26.                 list list = new list();
  27.                 list.listname = name;
  28.                 list.membertype = new CrmNumber();
  29.                 list.membertype.Value = 1;
  30.                 list.createdfromcode = new Picklist();
  31.                 list.createdfromcode.Value = 1;                
  32.                 Guid listId = service.Create(list);
  33.                 // add member
  34.                 AddMemberListRequest addMembersReq = new AddMemberListRequest();
  35.                 foreach (AccountInfo account in accountInfoList)
  36.                 {
  37.                     if (account.AllowPhone)
  38.                     {
  39.                         addMembersReq.EntityId = new Guid(account.AccountID);
  40.                         addMembersReq.ListId = listId;
  41.                         service.Execute(addMembersReq);
  42.                     }
  43.                 }
  44.                 //
  45.                 phonecall phone = this.CreatePhoneCallInstance(subject, description, due);
  46.                 CreateActivitiesListRequest req = new CreateActivitiesListRequest();
  47.                 req.Activity = phone;
  48.                 req.FriendlyName = name;
  49.                 req.ListId = listId;
  50.                 req.Propagate = true;
  51.                 req.OwnershipOptions = assignto == "0" ? PropagationOwnershipOptions.Caller : PropagationOwnershipOptions.ListMemberOwner;
  52.                 CreateActivitiesListResponse response = (CreateActivitiesListResponse)service.Execute(req);
  53.             }
  54.             catch (System.Web.Services.Protocols.SoapException ex)
  55.             {
  56.                 throw ex;
  57.             }
  58.             catch (Exception exe)
  59.             {
  60.                 throw exe;
  61.             }
  62.         }
  63.         #endregion
如上所示了,:)。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值