コード例 #1
0
        private void generateObjChat(dynamic results, ref List<objChat> _objchat, objPassValue objPassValue,ref bool endprocess)
        { 
            if (objPassValue.nodetype == node.mother) {
                results = results.conversations;
            }
            foreach (dynamic result in results.data) 
            { 
               var _obj_id = result.id;
               var _updatetime = result.updated_time;

               DateTime _update = DateTime.Parse(_updatetime);  //"2016-09-09T10:17:46+0000"  

               if (objPassValue.startDate >= _update)
                {// วันที่ update facebook <  วันที่เริ่ม
                    endprocess = false;
                    break; 
                }
                foreach (var g in result.messages.data)
                { // วน message    
                        var _comment = "";
                        if (g.message == "")
                        {
                            dynamic _obattact = g[6].data[0];
                            if (_obattact[0] == null)
                            { //sticker   
                                _comment += "<img class=\"_comment_sticker\" src='" + g[6].data[0].link + "' />";
                            }
                            else
                            {
                                dynamic _filetype = _obattact.mime_type;
                                if (_filetype.Contains("image")) // image attact
                                {
                                    var _urlimage = g[6][0][0].image_data.url;
                                    _comment += "<img class=\"_comment_picture\" src='" + _urlimage + "' />";
                                }
                                else
                                {
                                    _comment += ";[@attachfile][name=" + g[6][0][0].name + "]" + g[6][0][0].file_url;
                                }
                            }
                        }
                        else
                        {
                            _comment = g.message;
                        }

                        var gto = g.to.data[0].id;
                        var gnameto = g.to.data[0].name;
                        var gform = g.from.id;
                        var gnamefrom = g.from.name;
                        var createdate = g.created_time;
                        var _post_id = g.id;

                        DateTime _createdate = DateTime.Parse(createdate);
                        if (objPassValue.startDate >=  _createdate   )
                        { 
                            break;// node การสนทนาข้างในวันที่เริ่มต้องมากกว่าวันที่ สร้าง
                        } 
                        string _phone = (gform == "55269232341" ? "" : matchPhone(_comment));

                        _objchat.Add(new objChat()
                        {
                            id_facebook = gform,
                            name_facebook = gnamefrom,
                            comment = _comment,
                            phone = _phone,
                            action_date = createdate,
                            id_facebook_to = gto,
                            name_facebook_to = gnameto,
                            action_status = "inbox",
                            obj_id = _obj_id,
                            post_id = _post_id
                        });
                    } 
            }
        }
コード例 #2
0
        private void queryConversation(ref List<objChat> _objchat, objPassValue objPassValue, String url)
        {// recusive in Node next
            dynamic results = excuteGraph(url);

            String _next = "";
            if (objPassValue.nodetype == node.mother)  
                _next = results.conversations.paging.next;
            else
                _next = results.paging.next; 

            bool _enprocess = true;
            generateObjChat(results, ref _objchat, objPassValue, ref _enprocess);

            string g = "";
            if (_enprocess == true)
            {
                objPassValue.nodetype = node.child;
                queryConversation(ref _objchat, objPassValue, _next); 
            } 
        }