コード例 #1
0
        public async Task <HttpContent> ProcessAgentWork(Payload Payload, AuthenticationResponse AuthenticationResponse, PushTopic PushTopic)
        {
            SalesforceObjects.AgentWork AgentWork = JsonConvert.DeserializeObject <SalesforceObjects.AgentWork> (JsonConvert.SerializeObject(PushTopic.SObject));
            string SObjectPrefix = AgentWork.WorkItemId.Substring(0, 3);
            Dictionary <string, string> PrefixList = await this.RetrieveSObjects(AuthenticationResponse);

            string   SObjectType = PrefixList.Where(Prefix => Prefix.Key == SObjectPrefix).FirstOrDefault().Value;
            WorkItem WorkItem    = new WorkItem(AgentWork.WorkItemId, SObjectType);

            PicklistValue[] Statuses = await this.RetrieveStatuses(AuthenticationResponse);

            string status = Statuses[AgentWork.Status].Label;
            User   User   = await RetrieveUser(AuthenticationResponse, AgentWork.UserId);

            string          UserName        = User.Name;
            AgentWorkStatus AgentWorkStatus = this.GetAgentStatus(status);
            AgentWork       _AgentWork      = new AgentWork(AgentWork.Id, AgentWork.CreatedDate.ToString(), AgentWork.CreatedDate.ToString(), "update", AgentWorkStatus, WorkItem, UserName, AgentWork.UserId);

            Payload.agentWork = _AgentWork;
            string Content = JsonConvert.SerializeObject(Payload);

            return(new StringContent(Content, Encoding.UTF8, "application/json"));
        }
コード例 #2
0
        public async Task <Dictionary <string, object> > CreateAgentWork(AuthenticationResponse Auth, AgentWork AgentWork, Dictionary <string, object> PendingServiceRouting)
        {
            try {
                HttpRequestMessage CreateAgentWork =
                    new HttpRequestMessage(HttpMethod.Post, Auth.instance_url + "/services/data/v45.0/sobjects/AgentWork/");
                CreateAgentWork.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Auth.access_token);
                NewAgentWorkParams NewAgentWorkParams = new NewAgentWorkParams(PendingServiceRouting["Id"].ToString(), PendingServiceRouting["ServiceChannelId"].ToString(), AgentWork.userId, PendingServiceRouting["WorkItemId"].ToString());
                string             Content            = JsonConvert.SerializeObject(NewAgentWorkParams);
                var HttpContent = new StringContent(Content, Encoding.UTF8, "application/json");
                CreateAgentWork.Content = HttpContent;
                HttpResponseMessage CreateAgentWorkResponse =
                    await httpClient.SendAsync(CreateAgentWork);

                Dictionary <string, object> response = JsonConvert.DeserializeObject <Dictionary <string, object> > (
                    await CreateAgentWorkResponse.Content.ReadAsStringAsync());
                return(response);
            } catch (Exception ex) {
                throw ex;
            }
        }