public static void ProcessTranscripts(ParaEntityList<Chat> chats)
        {
            foreach (var chat in chats)
            {
                var transcripts = Service.GetChatTranscript(chat.Id);
                if (transcripts != null) foreach (var message in transcripts)
                {
                    //Do something

                    //The message from the Customer/CSR
                    var text = message.Text;

                    //The name of the CSR if there is one
                    var csr = message.Csr;

                    //The name of the Customer if there is one, only one Customer or Csr will be populated
                    var customer = message.Customer;

                    //Note: The actual Customer ID can be retrieved from the Chat object

                    //The timestamp
                    var timestamp = message.Timestamp;

                    //If the chat is internal, IE only Csrs can view the message, the message will be falgged as internal
                    var visbleToCsrsOnly = message.Internal;
                }
            }
        }
示例#2
0
        public static void ProcessTranscripts(ParaEntityList <Chat> chats)
        {
            foreach (var chat in chats)
            {
                var transcripts = Service.GetChatTranscript(chat.Id);
                if (transcripts != null)
                {
                    foreach (var message in transcripts)
                    {
                        //Do something

                        //The message from the Customer/CSR
                        var text = message.Text;

                        //The name of the CSR if there is one
                        var csr = message.Csr;

                        //The name of the Customer if there is one, only one Customer or Csr will be populated
                        var customer = message.Customer;

                        //Note: The actual Customer ID can be retrieved from the Chat object

                        //The timestamp
                        var timestamp = message.Timestamp;

                        //If the chat is internal, IE only Csrs can view the message, the message will be falgged as internal
                        var visbleToCsrsOnly = message.Internal;
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// Fills a Role list object
        /// </summary>
        /// <param name="creds"></param>
        /// <param name="query"></param>
        /// <param name="module"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        internal static ParaEntityList <TEntity> ApiGetEntityList <TModule, TEntity>(ParaCredentials creds,
                                                                                     ParaQuery query)
            where TModule : ParaEntity
            where TEntity : ParaEntityBaseProperties
        {
            var rolesList = new ParaEntityList <TEntity>();
            var ar        = ApiCallFactory.ObjectSecondLevelGetList <TModule, TEntity>(creds, query.BuildQueryArguments());

            if (ar.HasException == false)
            {
                //...Customer/status is sending "entities" not "Entities", which breaks the parser. Unwind and fix the XML
                var xmlStr = ar.XmlReceived.OuterXml;
                if (xmlStr.Contains("<entities"))
                {
                    xmlStr         = xmlStr.Replace("<entities", "<Entities");
                    xmlStr         = xmlStr.Replace("entities>", "Entities>");
                    ar.XmlReceived = ParseXmlDoc(xmlStr);
                }

                rolesList = ParaEntityParser.FillList <TEntity>(ar.XmlReceived);
            }
            rolesList.ApiCallResponse = ar;

            // Checking if the system needs to recursively call all of the data returned.
            if (query.RetrieveAllRecords)
            {
                var continueCalling = true;
                while (continueCalling)
                {
                    if (rolesList.TotalItems > rolesList.Data.Count)
                    {
                        // We still need to pull data
                        // Getting next page's data
                        query.PageNumber = query.PageNumber + 1;

                        ar = ApiCallFactory.ObjectSecondLevelGetList <TModule, TEntity>(creds,
                                                                                        query.BuildQueryArguments());

                        var objectlist = ParaEntityParser.FillList <TEntity>(ar.XmlReceived);

                        if (objectlist.Data.Count == 0)
                        {
                            continueCalling = false;
                        }

                        rolesList.Data.AddRange(objectlist.Data);
                        rolesList.ResultsReturned = rolesList.Data.Count;
                        rolesList.PageNumber      = query.PageNumber;
                    }
                    else
                    {
                        // That is it, pulled all the items.
                        continueCalling           = false;
                        rolesList.ApiCallResponse = ar;
                    }
                }
            }

            return(rolesList);
        }
示例#4
0
        internal static ParaEntityList <ParaObjects.Download> ApiGetDownloadEntityList(ParaCredentials pc)
        {
            var entityList = new ParaEntityList <ParaObjects.Download>();
            var ar         = ApiCallFactory.ObjectGetList <ParaObjects.Download>(pc, new ArrayList());

            if (ar.HasException == false)
            {
                entityList = ParaEntityParser.FillListDownload(ar.XmlReceived);
            }
            entityList.ApiCallResponse = ar;

            return(entityList);
        }
示例#5
0
        public ParaEntityList <TFolder> GetList <TFolder>(FolderQuery query)
            where TFolder : Folder, new()
        {
            var folderList = new ParaEntityList <TFolder>();
            var ar         = ApiCallFactory.ObjectGetList <TFolder>(Credentials, query.BuildQueryArguments());

            if (ar.HasException == false)
            {
                folderList = ParaEntityParser.FillList <TFolder>(ar.XmlReceived);
            }
            folderList.ApiCallResponse = ar;

            // Checking if the system needs to recursively call all of the data returned.
            if (query.RetrieveAllRecords)
            {
                bool continueCalling = true;
                while (continueCalling)
                {
                    if (folderList.TotalItems > folderList.Data.Count)
                    {
                        // We still need to pull data

                        // Getting next page's data
                        query.PageNumber = query.PageNumber + 1;

                        ar = ApiCallFactory.ObjectGetList <TFolder>(Credentials, query.BuildQueryArguments());

                        var objectlist = ParaEntityParser.FillList <TFolder>(ar.XmlReceived);

                        if (objectlist.Data.Count == 0)
                        {
                            continueCalling = false;
                        }

                        folderList.Data.AddRange(objectlist.Data);
                        folderList.ResultsReturned = folderList.Data.Count;
                        folderList.PageNumber      = query.PageNumber;
                    }
                    else
                    {
                        // That is it, pulled all the items.
                        continueCalling            = false;
                        folderList.ApiCallResponse = ar;
                    }
                }
            }

            return(folderList);
        }
示例#6
0
        private static ParaEntityList <T> RetrieveAllEntities <T>(ParaCredentials pc, ParaEntityQuery query)
            where T : ParaEntity, new()
        {
            ApiCallResponse ar;
            var             entityList = new ParaEntityList <T>();

            ar = ApiCallFactory.ObjectGetList <T>(pc, query.BuildQueryArguments());
            if (ar.HasException == false)
            {
                entityList = ParaEntityParser.FillList <T>(ar.XmlReceived);
            }
            entityList.ApiCallResponse = ar;

            var continueCalling = true;

            while (continueCalling)
            {
                if (entityList.TotalItems > entityList.Data.Count)
                {
                    // We still need to pull data
                    // Getting next page's data
                    query.PageNumber = query.PageNumber + 1;

                    ar = ApiCallFactory.ObjectGetList <T>(pc, query.BuildQueryArguments());
                    if (ar.HasException == false)
                    {
                        var objectlist = ParaEntityParser.FillList <T>(ar.XmlReceived);
                        entityList.Data.AddRange(objectlist.Data);
                        entityList.ResultsReturned = entityList.Data.Count;
                        entityList.PageNumber      = query.PageNumber;
                    }
                    else
                    {
                        // There is an error processing request
                        entityList.ApiCallResponse = ar;
                        continueCalling            = false;
                    }
                }
                else
                {
                    // That is it, pulled all the items.
                    continueCalling            = false;
                    entityList.ApiCallResponse = ar;
                }
            }

            return(entityList);
        }
示例#7
0
        private static ParaEntityList <ParaObjects.Chat> RetrieveAllEntitites(ParaCredentials creds, ChatQuery query)
        {
            var chatList = new ParaEntityList <ParaObjects.Chat>();
            var ar       = ApiCallFactory.ObjectGetList <ParaObjects.Chat>(creds, query.BuildQueryArguments());

            if (ar.HasException == false)
            {
                chatList = ParaEntityParser.FillList <ParaObjects.Chat>(ar.XmlReceived);
            }
            chatList.ApiCallResponse = ar;

            bool continueCalling = true;

            while (continueCalling)
            {
                if (chatList.TotalItems > chatList.Data.Count)
                {
                    // We still need to pull data

                    // Getting next page's data
                    query.PageNumber = query.PageNumber + 1;

                    ar = ApiCallFactory.ObjectGetList <ParaObjects.Chat>(creds, query.BuildQueryArguments());
                    if (ar.HasException == false)
                    {
                        chatList.Data.AddRange(ParaEntityParser.FillList <ParaObjects.Chat>(ar.XmlReceived).Data);
                        chatList.ResultsReturned = chatList.Data.Count;
                        chatList.PageNumber      = query.PageNumber;
                    }
                    else
                    {
                        continueCalling          = false;
                        chatList.ApiCallResponse = ar;
                        break;
                    }
                }
                else
                {
                    // That is it, pulled all the items.
                    continueCalling          = false;
                    chatList.ApiCallResponse = ar;
                }
            }

            return(chatList);
        }
示例#8
0
        internal static ParaEntityList <ParaObjects.Download> ApiGetDownloadEntityList(ParaCredentials pc, DownloadQuery query)
        {
            var entityList = new ParaEntityList <ParaObjects.Download>();

            // Checking if the system needs to recursively call all of the data returned.
            if (query.RetrieveAllRecords)
            {
                entityList = RetrieveAllDownloadEntities(pc, query);
            }
            else
            {
                var ar = ApiCallFactory.ObjectGetList <ParaObjects.Download>(pc, query.BuildQueryArguments());
                if (ar.HasException == false)
                {
                    entityList = ParaEntityParser.FillListDownload(ar.XmlReceived);
                }
                entityList.ApiCallResponse = ar;
            }

            return(entityList);
        }
        /// <summary>
        /// Download module can have a config that changes the schema...
        /// This does the same as the generic ApiGetEntityList method, but overwrites the XML to account for the changing schema
        /// Specific node is "Folder" vs "Folders"
        /// </summary>
        /// <param name="xmlDoc"></param>
        /// <returns></returns>
        public static ParaEntityList <Download> FillListDownload(XmlDocument xmlDoc)
        {
            //Generate the paged data parsed object. Data prop will be empty
            var list    = new ParaEntityList <Download>();
            var docNode = xmlDoc.DocumentElement;

            //Fill the list of entities
            foreach (XmlNode xn in docNode.ChildNodes)
            {
                var xDoc = new XmlDocument();
                xDoc.LoadXml(xn.OuterXml);
                var hasMultipleDownloadFolders = HasMultipleFoldersAndConvert(xDoc);
                var dl = EntityFill <Download>(xDoc);
                dl.MultipleFolders = hasMultipleDownloadFolders;

                list.Data.Add(dl);
            }

            using (var nodeReader = new XmlNodeReader(xmlDoc))
            {
                //We need to manually parse total and results for PagedData object
                nodeReader.MoveToContent();
                var xml = XDocument.Load(nodeReader);

                var totalAttr = xml.Root.Attribute("total");
                list.TotalItems = totalAttr != null?int.Parse(totalAttr.Value) : 0;

                var resultsAttr = xml.Root.Attribute("results");
                list.ResultsReturned = resultsAttr != null?int.Parse(resultsAttr.Value) : 0;

                var pageAttr = xml.Root.Attribute("page");
                list.PageNumber = pageAttr != null?int.Parse(pageAttr.Value) : 0;

                var pageSizeAttr = xml.Root.Attribute("page-size");
                list.PageSize = pageSizeAttr != null?int.Parse(pageSizeAttr.Value) : 0;
            }

            return(list);
        }
示例#10
0
        private static ParaEntityList <ParaObjects.Chat> FillList(ParaCredentials creds, Boolean includeTranscripts,
                                                                  ChatQuery query)
        {
            if (query == null)
            {
                query = new ChatQuery();
            }
            var chatList = new ParaEntityList <ParaObjects.Chat>();

            // Checking if the system needs to recursively call all of the data returned.
            if (query.RetrieveAllRecords)
            {
                chatList = RetrieveAllEntitites(creds, query);
            }
            else
            {
                var ar = ApiCallFactory.ObjectGetList <ParaObjects.Chat>(creds, query.BuildQueryArguments());
                if (ar.HasException == false)
                {
                    chatList = ParaEntityParser.FillList <ParaObjects.Chat>(ar.XmlReceived);
                }
                chatList.ApiCallResponse = ar;
            }

            if (includeTranscripts)
            {
                var service = new ParaService(creds);
                //Fetch transcripts for each chat. Each request is another API call...
                foreach (var chat in chatList)
                {
                    chat.Transcript = service.GetChatTranscript(chat.Id);
                }
            }

            return(chatList);
        }