public XElement WelcomeCall(string pcidssId, string callerId, string lastCall, string tel2) { try { crmService = new XrmServices(); if (!string.IsNullOrEmpty(pcidssId)) { Entity contact = Contact.GetContactById(pcidssId, crmService); if (contact.Id != Guid.Empty) { crmService.GetService().Create(new Entity("phonecall") { Attributes = new AttributeCollection() { new KeyValuePair <string, object>("regardingobjectid", contact.ToEntityReference()), new KeyValuePair <string, object>("new_callid", callerId), new KeyValuePair <string, object>("new_iswelcomecall", true), new KeyValuePair <string, object>("scheduledstart", DateTime.Now), new KeyValuePair <string, object>("new_secondphonenumber", bool.Parse(tel2)), new KeyValuePair <string, object>("new_lastcall", bool.Parse(lastCall)), } }); result.AddResultElement("url", XrmUtility.FormatUrl(contact.Id, contact.LogicalName.ToLower())); result.AddResultElement("status", contact.GetAttributeValue <OptionSetValue>("statuscode").Value); returnCode = (int)CustomReturnCode.Success; } else { returnCode = (int)CustomReturnCode.CustomerNotFound; } } else { returnCode = (int)CustomReturnCode.CustomerNotFound; } result.SetError(returnCode, customError.getErrorMessage(returnCode)); } catch (Exception ex) { result.SetError((int)CustomReturnCode.Unknown, ex.Message, ex); } Dispose(); return(result.getXml((Method == "post") ? new List <string> { pcidssId, callerId } : null)); }
public XElement UpdateEmailByExchangeId(string messageId, string domainName = "", string userName = "") { //return new XElement("root"); //return new XElement(""); //string resultMessage = string.Empty; bool ownerChanged = false; try { crmService = new XrmServices(); string user = domainName + "\\" + userName; EntityReference email = Activity.GetEmailById(messageId, crmService); if (email != null && email.Id != Guid.Empty) { //Activity.ReopenActivity(email, crmService); XrmUtility.ChangeOwner(email, SystemUser.GetUserFromLogin(user, crmService), crmService); Entity updateEmail = new Entity("email"); updateEmail.Id = email.Id; //Status du mail à "A traiter" updateEmail.Attributes.Add("new_status", new OptionSetValue(100000000)); crmService.Update(updateEmail); //Activity.CloseActivity(email, crmService); ownerChanged = true; // resultMessage = XrmUtility.FormatUrl(email.Id, email.LogicalName.ToLower()); } else { returnCode = (int)CustomReturnCode.MailNotFound; } result.SetError(returnCode, customError.getErrorMessage(returnCode)); } catch (Exception ex) { result.SetError((int)CustomReturnCode.Unknown, ex.Message, ex); } result.AddResultElement("value", ownerChanged); return(result.getXml((Method == "post") ? new List <string> { messageId, domainName, userName } : null)); //return resultMessage; }