标题# 系列文章目录
条码管理操作手册
本文链接:https://blog.csdn.net/youcheng_ge/article/details/126589496
C#WebAPI项目发布和IIS部署
本文链接:https://blog.csdn.net/youcheng_ge/article/details/126539836
前言
后期补充
一、WebAPI服务端
采用C# WebAPI创建项目,功能与前端安卓(手持机)进行交互,负责接发前端传来的数据。
1.1 文件下载代码
/// <summary>
/// apk自动更新机制
/// </summary>
/// <returns>文件字节流</returns>
[HttpGet]
public HttpResponseMessage DownloadFile(string a_fileName)
{
try
{
//文件的服务器地址
string filePath = HttpContext.Current.Server.MapPath("~/") + "filepath\\" + a_fileName;
if (!File.Exists(filePath))
{
return new HttpResponseMessage(HttpStatusCode.NotFound);
}
FileStream stream = new FileStream(filePath, FileMode.Open);
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
response.Content = new StreamContent(stream);
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
FileName = HttpUtility.UrlEncode(a_fileName)
};
response.Headers.Add("Access-Control-Expose-Headers", "FileName");
response.Headers.Add("FileName", HttpUtility.UrlEncode(a_fileName));
return response;
}
catch (Exception)
{
return new HttpResponseMessage(HttpStatusCode.NoContent);
}
}
1.2 接口测试
Postman测试
二、安卓自动更新机制
2.1. 手持项目代码更改
增加config.xml文件
开启自动更新配置:
全部参数设置如下:
<widget id="A6103689395438" version="0.0.1">
<name>条码管理</name>
<description>条码管理</description>
<author email="ge.youcheng@yuanshi-advanced.com" href="http://www.apicloud.com">geyc</author>
<content src="html/index.html"/>
<access origin="*"/>
<preference name="pageBounce" value="false"/>
<preference name="appBackground" value="rgba(0,0,0,0.0)"/>
<preference name="windowBackground" value="rgba(0,0,0,0.0)"/>
<preference name="frameBackgroundColor" value="rgba(0,0,0,0.0)"/>
<preference name="hScrollBarEnabled" value="false"/>
<preference name="vScrollBarEnabled" value="true"/>
<preference name="autoLaunch" value="true"/>
<preference name="fullScreen" value="false"/>
<preference name="autoUpdate" value="true"/>
<preference name="smartUpdate" value="false"/>
<preference name="debug" value="true"/>
<preference name="statusBarAppearance" value="false"/>
<permission name="readPhoneState"/>
<permission name="camera"/>
<permission name="location"/>
<permission name="fileSystem"/>
<permission name="internet"/>
<permission name="bootCompleted"/>
<permission name="hardware"/>
<feature name="scanner"/>
</widget>
2.1. 安卓版本发布
编译包,20220908.apk
平台:android
版本:V0.0.5
更新地址:http://192.168.6.93:8090/API/QR/DownloadFile?a_fileName=20220908.apk
更新备注:1、母线质量登记,增加 设备类型、工字轮通用选择
2、改进员工档案界面
3、其它功能性优化
软件工程师--葛游成发布
2.2. 安卓手机测试
总结
提示:这里对文章进行总结: