Ejemplo n.º 1
0
 /// <summary>
 /// 写入云日志
 /// </summary>
 /// <param name="position"></param>
 /// <param name="msg"></param>
 /// <param name="param"></param>
 /// <param name="remark"></param>
 /// <param name="summary"></param>
 /// <param name="typeID"></param>
 /// <param name="typeName"></param>
 /// <returns></returns>
 public RES SaveLog(string position, string msg, string param, string remark, string summary, int typeID, string typeName)
 {
     try
     {
         var log = new { CreateTime = DateTime.Now, Position = position, Msg = msg, Param = param, Remark = remark, Summary = summary, TypeID = typeID, TypeName = typeName, AppID = this.appId };
         var res = HTTP.POST("http://localhost:6003/LogAPI.ashx", null, JSON.ToJson(new
         {
             TargetClass     = "YunLog",
             Method          = "Save",
             Param           = new { },
             InputParamArray = new string[] { JSON.ToJson(log) }
         }));
         return(RES.OK(res));
     }
     catch (Exception ex)
     {
         return(RES.FAIL(ex.Message));
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 从url中保存一个原始文章
 /// </summary>
 /// <param name="url"></param>
 /// <param name="headers"></param>
 /// <returns></returns>
 public RES SaveArticleFromUrl(string url, string headers)
 {
     try
     {
         var content = HTTP.Get(url, string.IsNullOrWhiteSpace(headers) ? null: JSON.ToObject <Dictionary <string, string> >(headers));
         var inst    = new YunArticle();
         inst.ID         = Guid.NewGuid();
         inst.Status     = (int)ENUM.实体状态.可用;
         inst.Title      = null;
         inst.Url        = url;
         inst.Content    = content;
         inst.CreateTime = DateTime.Now;
         inst.UpdateTime = DateTime.Now;
         var db = ModelEF.GetInst();
         db.YunArticles.Add(inst);
         db.SaveChangesAsync();
         return(RES.OK(inst));
     }
     catch (Exception ex)
     {
         return(RES.FAIL(ex.Message));
     }
 }