Exemplo n.º 1
0
 public static BizIndex CopyFromBizMQ(BizMQ mq)
 {
     if (mq == null || string.IsNullOrEmpty(mq.Id) || Guid.Parse(mq.Id).Equals(Guid.Empty))
         return null;
     BizIndex ret = new BizIndex();
     foreach (System.Reflection.PropertyInfo pi in ret.GetType().GetProperties())
     {
         object value = mq.GetType().GetProperty(pi.Name).GetValue(mq);
         if(value!=null)
             pi.SetValue(ret, value);
     }
     return ret;
 }
Exemplo n.º 2
0
 public static bool AddOrUpdateBiz(BizIndex obj)
 {
     try
     {
         var result = _client.Search<BizIndex>(s => s.Query(q => q.QueryString(ss => ss.Query("Id:" + obj.Id))));
         BizIndex l = obj;
         if (result.Total >= 1)
         {
             string _id = result.Hits.First().Id;
             var r = _client.Update<BizIndex>((u) =>
             {
                 u.Id(_id);
                 u.Doc(obj);
                 u.Index(_config.IndexName);
                 return u;
             });
             return r.IsValid;
         }
         else
         {
             var resoponse = _client.Index<BizIndex>(l, (i) => { i.Index(_config.IndexName); return i; });
             return resoponse.Created;
         }
     }
     catch (Exception ex)
     {
         LogError(ex);
     }
     return false;
 }