예제 #1
0
        public HttpResponseMessage Get(int id)
        {
            string errMsg = "";

            Model.Signature signature = BLL.SignatureManager.GetSignatureById(id, out errMsg);
            HttpStatusCode  status;
            string          json;

            //errMsg = "网络繁忙,请稍稍再度";
            if (errMsg.Length > 0)
            {
                status = (HttpStatusCode)422;
                var msg = new
                {
                    errors = new
                    {
                        ServerSideError = errMsg
                    }
                };
                json = JsonConvert.SerializeObject(msg);
            }
            else
            {
                status = HttpStatusCode.OK;
                var msg2 = new
                {
                    signature = signature
                };
                json = JsonConvert.SerializeObject(msg2);
            }
            return(new HttpResponseMessage(status)
            {
                Content = new StringContent(json, System.Text.Encoding.GetEncoding("UTF-8"), "application/json")
            });
        }
예제 #2
0
 /// <summary>
 /// 获取签字内容
 /// </summary>
 /// <param name="id"></param>
 /// <param name="errMsg"></param>
 /// <returns></returns>
 public static Model.Signature GetSignatureById(int id, out string errMsg)
 {
     errMsg = "";
     try
     {
         string         sql  = "";
         SqlParameter[] para = new SqlParameter[]
         {
             new SqlParameter("@Id", id)
         };
         sql = "select * from [Signature] where Id = @Id";
         DataTable       dt        = DBHelper.ExecuteGetDataTable(CommandType.Text, sql, para);
         Model.Signature signature = null;
         if (dt.Rows.Count > 0)
         {
             DataRow dr = dt.Rows[0];
             string  tempBase64String = Convert.ToBase64String((byte[])dr["Sign"]);
             signature = new Signature
             {
                 Id          = (int)dr["Id"],
                 Name        = (string)dr["Name"],
                 Sign        = tempBase64String,
                 Creater     = (int)dr["Creater"],
                 CreatedDate = (DateTime)dr["CreatedDate"]
             };
         }
         else
         {
             errMsg = "该签字不存在或已被删除";
         }
         return(signature);;
     }
     catch (Exception ex)
     {
         errMsg = ex.Message;
         return(null);
     }
 }
예제 #3
0
 /// <summary>
 /// 添加驾驶员签名
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool AddSignature(ref Model.Signature model, out string errMsg)
 {
     return(SignatureService.AddSignature(ref model, out errMsg));
 }