Пример #1
0
        /// <summary>
        /// 将HashObject转换为指定类型TEntity的对象
        /// </summary>
        /// <typeparam name="TEntity">将要转换的目标对象类型</typeparam>
        /// <param name="data">将要进行类型转换的数据源</param>
        /// <returns>指定类型为TEntity的对象</returns>
        public static TEntity ToEntity <TEntity>(this IHashMap data) where TEntity : class, new()
        {
            return(EntityFactory.GetEntity <TEntity, IHashMap>(data, (ho, key) =>
            {
                // 这种方式数据较多的情况下性能比较差
                if (ho.ContainsKey(key))
                {
                    return ho.Get <object>(key);
                }
                return null;


                /* 部分机器性能有问题,先还原回去
                 * try
                 * {
                 *  return ho[key];
                 * }
                 * catch
                 * {
                 *  Logging.Log.Info("error.............");
                 *  return null;
                 * }
                 */
            }));
        }
Пример #2
0
        internal void GetDetailsData(string cookies, List <HashMap> billDataList, SendDetailState detailSetate = null)
        {
            if (string.IsNullOrEmpty(cookies))
            {
                throw new Exception("请输入cookies");
            }
            string user = GetUser(cookies);
            Dictionary <ulong, string> dictionary = new Dictionary <ulong, string>();
            JsonSerializer             serializer = JsonSerializer.CreateInstance();

            for (int i = 0; i < billDataList.Count; i++)
            {
                IHashMap item     = billDataList[i];
                string   status   = item.Get <string>("status");
                HashMap  tempHash = serializer.Deserialize <HashMap>(item["content"].ToString());
                if (tempHash == null)
                {
                    continue;
                }
                ArrayList array = (ArrayList)((HashMap)tempHash["statusInfo"])["operations"];

                foreach (HashMap aitem in array)
                {
                    if (!"详情".Equals(aitem.Get <string>("text")))
                    {
                        continue;
                    }
                    string url  = string.Format("https:{0}", aitem.Get <string>("url"));
                    string tbid = item.Get <string>("tbid");

                    HashMap detail = GetBillDetail(tbid, url, cookies, i + 1, billDataList.Count, detailSetate);
                    //if (detail == null)//下载出错,直接移除
                    //{
                    //    billDataList.RemoveAt(i);
                    //    i--;
                    //}
                    item.Add("detail", detail);
                    break;
                }
            }
        }
Пример #3
0
 //hash转json串
 public String HashMapJson(IHashMap map)
 {
     return(JsonConvert.SerializeObject(map));
 }