Ejemplo n.º 1
0
        /// <summary>
        /// 获取到所有的订单数据
        /// </summary>
        /// <returns></returns>
        public List <Order> GetOrders()
        {
            var nonce     = DataTransfer.GetNonce();
            var timestamp = DataTransfer.GetTimeStamp();
            var staffid   = "#9793932i82`/";
            //使用HttpClientHelper获取所有数据
            //singture参数是有时间戳+随机数+秘钥+数据
            string jsonStr = HttpClientHelper2.SendRequest("api/OrderAPI/GetOrders", "get", timestamp, nonce.ToString(), timestamp + nonce + staffid);

            //string jsonStr = HttpClientHelper.Send("get", "api/OrderAPI/GetOrders", null);
            //将json数据转化为list集合 并返回
            if (jsonStr != "未知原因,失败")
            {
                return(JsonConvert.DeserializeObject <List <Order> >(jsonStr));;
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        public void Edit(Order order)
        {
            //获取随机数
            var nonce = DataTransfer.GetNonce();
            //获取时间戳
            var timestamp = DataTransfer.GetTimeStamp();
            //秘钥
            var staffid = "#9793932i82`/";
            //data数据有时间戳+随机数+秘钥+传入数据
            var singture = timestamp + nonce + staffid;
            //反射获取传递的属性和值
            Type type = typeof(Order);

            //获取所有属性
            PropertyInfo[] pros = type.GetProperties();
            //定义一个有序字典
            SortedDictionary <string, string> pairs = new SortedDictionary <string, string>();

            //遍历属性
            foreach (var item in pros)
            {
                //将order属性和属性值放入字典
                pairs.Add(item.Name.ToString(), item.GetValue(order, null).ToString());
            }
            //进行有序排列
            foreach (var item in pairs.OrderBy(o => o.Key))
            {
                //data数据+到stigture
                singture += item.Key + item.Value.ToString();
            }
            //json序列化
            string str = JsonConvert.SerializeObject(order);
            //使用HttpClientHelper获取所有数据
            string jsonStr = HttpClientHelper2.SendRequest("api/OrderAPI/Upt", "put", timestamp, nonce.ToString(), singture, str);
            //string jsonStr = HttpClientHelper.Send("put", "api/OrderAPI/Upt", str);
        }
        public static async Task <PostDetailDTO> GetPostDetailDTOAsync(string postId, string cookie)
        {
            PostDetailDTO postDetailDTO = new PostDetailDTO();

            try
            {
                string link = "https://www.facebook.com/groups/" + ModifyLink(postId).Item1 + "/permalink/" + ModifyLink(postId).Item2;
                //var html = await HttpClientHelper.SendRequestAsync(link, cookie);
                HttpClientHelper2 clientHelper2 = new HttpClientHelper2();
                var html = await clientHelper2.SendRequestAsync(link, cookie);

                string name                 = Regex.Match(html, "data-hovercard-prefer-more-content-show=\"1\" data-hovercard-referer=\"(.*?)\" role=\"button\">(.*?)</a></span>").Groups[2].Value;
                string uid                  = Regex.Match(html, "data-hovercard=\"/ajax/hovercard/user.php\\?id=(.*?)&amp;").Groups[1].Value;
                string reactionCount        = Regex.Match(html, "reaction_count:{count:(.*?)},").Groups[1].Value;
                string reactionCountLIKE    = Regex.Match(html, "reaction_type:\"LIKE\"},i18n_reaction_count:\"(.*?)\"").Groups[1].Value;
                string reactionCountLOVE    = Regex.Match(html, "reaction_type:\"LOVE\"},i18n_reaction_count:\"(.*?)\"").Groups[1].Value;
                string reactionCountWOW     = Regex.Match(html, "reaction_type:\"WOW\"},i18n_reaction_count:\"(.*?)\"").Groups[1].Value;
                string reactionCountSUPPORT = Regex.Match(html, "reaction_type:\"SUPPORT\"},i18n_reaction_count:\"(.*?)\"").Groups[1].Value;
                string reactionCountHAHA    = Regex.Match(html, "reaction_type:\"HAHA\"},i18n_reaction_count:\"(.*?)\"").Groups[1].Value;
                string reactionCountSAD     = Regex.Match(html, "reaction_type:\"SORRY\"},i18n_reaction_count:\"(.*?)\"").Groups[1].Value;
                string reactionCountANGRY   = Regex.Match(html, "reaction_type:\"ANGER\"},i18n_reaction_count:\"(.*?)\"").Groups[1].Value;
                string shareCount           = Regex.Match(html, "share_count:{count:(.*?)}").Groups[1].Value;
                string commentCount         = Regex.Match(html, "comment_count:{total_count:(.*?)}").Groups[1].Value;

                if (string.IsNullOrEmpty(name))
                {
                    name = Regex.Match(html, "\"__typename\":\"User\",\"name\":\"(.*?)\"").NextMatch().Groups[1].Value;
                    if (string.IsNullOrEmpty(name))
                    {
                        name = Regex.Match(html, "\"__typename\":\"User\",\"name\":\"(.*?)\"").Groups[1].Value;
                    }
                    name                 = Regex.Unescape(name);
                    uid                  = Regex.Match(html, "\"owning_profile\":{\"__typename\":\"User\",\"id\":\"(.*?)\"}").Groups[1].Value;
                    reactionCount        = Regex.Match(html, "\"reaction_count\":{\"count\":(.*?),").Groups[1].Value;
                    reactionCountLIKE    = Regex.Match(html, "\"reaction_type\":\"LIKE\",\"id\":\"(.*?)\"},\"reaction_count\":(.*?)}").Groups[2].Value;
                    reactionCountLOVE    = Regex.Match(html, "\"reaction_type\":\"LOVE\",\"id\":\"(.*?)\"},\"reaction_count\":(.*?)}").Groups[2].Value;
                    reactionCountWOW     = Regex.Match(html, "\"reaction_type\":\"WOW\",\"id\":\"(.*?)\"},\"reaction_count\":(.*?)}").Groups[2].Value;
                    reactionCountSUPPORT = Regex.Match(html, "\"reaction_type\":\"SUPPORT\",\"id\":\"(.*?)\"},\"reaction_count\":(.*?)}").Groups[2].Value;
                    reactionCountHAHA    = Regex.Match(html, "\"reaction_type\":\"HAHA\",\"id\":\"(.*?)\"},\"reaction_count\":(.*?)}").Groups[2].Value;
                    reactionCountSAD     = Regex.Match(html, "\"reaction_type\":\"SORRY\",\"id\":\"(.*?)\"},\"reaction_count\":(.*?)}").Groups[2].Value;
                    reactionCountANGRY   = Regex.Match(html, "\"reaction_type\":\"ANGER\",\"id\":\"(.*?)\"},\"reaction_count\":(.*?)}").Groups[2].Value;
                    shareCount           = Regex.Match(html, "\"share_count\":{\"count\":(.*?),").Groups[1].Value;
                    commentCount         = Regex.Match(html, "\"comment_count\":{\"total_count\":(.*?)},").Groups[1].Value;
                }



                postDetailDTO.Name = name;
                postDetailDTO.UID  = TryConvertToLong(uid);
                postDetailDTO.ReactionTotalCount = TryConvertToLong(reactionCount);
                postDetailDTO.LikeCount          = TryConvertToLong(reactionCountLIKE);
                postDetailDTO.LoveCount          = TryConvertToLong(reactionCountLOVE);
                postDetailDTO.WowCount           = TryConvertToLong(reactionCountWOW);
                postDetailDTO.SupportCount       = TryConvertToLong(reactionCountSUPPORT);
                postDetailDTO.HahaCount          = TryConvertToLong(reactionCountHAHA);
                postDetailDTO.SadCount           = TryConvertToLong(reactionCountSAD);
                postDetailDTO.AngryCount         = TryConvertToLong(reactionCountANGRY);
                postDetailDTO.ShareCount         = TryConvertToLong(shareCount);
                postDetailDTO.CommentCount       = TryConvertToLong(commentCount);
            }
            catch (Exception e)
            {
            }
            return(postDetailDTO);
        }