通過創建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
如上所示了,:)。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章