二开案例.WebApi给富文本字段赋值原创
91人赞赏了该文章
466次浏览
编辑于2024年08月11日 10:09:28
1、在测试单据上增加富文本字段,标识为F_UNW_RichText_qtr
2、富文件字段值为Base64编码的html格式数据。
void Main() { string url = "k3cloud地址"; string dbid = "669bc2b10f1cb9"; string userName = "demo"; string password = "888888"; int lcid = 2052; K3CloudApiClient apiClient = new K3CloudApiClient(url); var isLoginOk = apiClient.Login(dbid, userName, password, lcid); if (!isLoginOk) return; var FBillNo = "A" + DateTime.Now.ToString("yyyyMMddHHmmssfff"); var formId = "UNW_testfwb"; var model = new { FBillNo, F_UNW_RichText_qtr = Convert.ToBase64String(GetRichValue("<h1 style='color:red;'><b>这是一个富文本</b></h1>")) }; var saveResult = apiClient.Save(formId, new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(new { Model = model })); Console.WriteLine(saveResult); } /// <summary> /// 公共函数:字符串转富文本html /// </summary> public static byte[] GetRichValue(string txt) { if (string.IsNullOrWhiteSpace(txt)) { return new byte[0]; } var head = @"<!--RichEdit.HTML5--><meta content=""text/html; charset=utf-8"" http-equiv=""Content-Type"" /><title></title><div>"; var end = @"</div>"; return Encoding.UTF8.GetBytes(head + txt + end); }
3、通过WebApi赋值后的单据
4、发送报文
{"Model":{"FBillNo":"A20240811100510471","F_UNW_RichText_qtr":"PCEtLVJpY2hFZGl0LkhUTUw1LS0+PG1ldGEgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PXV0Zi04IiBodHRwLWVxdWl2PSJDb250ZW50LVR5cGUiIC8+PHRpdGxlPjwvdGl0bGU+PGRpdj48aDEgc3R5bGU9J2NvbG9yOnJlZDsnPjxiPui/meaYr+S4gOS4quWvjOaWh+acrDxiPjwvaDE+PC9kaXY+"}}
赞 91
91人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!
推荐阅读