|
@@ -13,6 +13,7 @@ using Model;
|
|
|
using Services;
|
|
using Services;
|
|
|
using Model.Base;
|
|
using Model.Base;
|
|
|
using System.IO.Compression;
|
|
using System.IO.Compression;
|
|
|
|
|
+using Aliyun.OSS;
|
|
|
|
|
|
|
|
namespace Controllers
|
|
namespace Controllers
|
|
|
{
|
|
{
|
|
@@ -38,89 +39,161 @@ namespace Controllers
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- public string makeAppInitData([FromQuery] MakeAppInitDataDto parm, string EncryptType = "des")
|
|
|
|
|
|
|
+ public string makeAppInitData(OssClient client, AppSourceSet set, MakeAppInitDataDto parm, string EncryptType = "des")
|
|
|
{
|
|
{
|
|
|
string AppInfoList = _AppBottomNavsService.makeAppInitData(parm.kind, parm.appVersion, EncryptType);
|
|
string AppInfoList = _AppBottomNavsService.makeAppInitData(parm.kind, parm.appVersion, EncryptType);
|
|
|
- // Function.WriteLog(AppInfoList);
|
|
|
|
|
string FileInfoList = _FileUpdateInfoService.makeAppInitData(parm.kind, parm.appVersion, EncryptType);
|
|
string FileInfoList = _FileUpdateInfoService.makeAppInitData(parm.kind, parm.appVersion, EncryptType);
|
|
|
- var set = _AppSourceSetService.GetFirst(m => m.projectId == parm.projectId && m.kind == parm.kind);
|
|
|
|
|
- string PageInfoList = _PageUpdateInfoService.makeAppInitData(set, parm.kind, parm.appVersion, EncryptType);
|
|
|
|
|
|
|
+ string PageInfoList = _PageUpdateInfoService.makeAppInitData(client, set, parm.kind, parm.appVersion, EncryptType);
|
|
|
return AppInfoList + "#cut#" + FileInfoList + "#cut#" + PageInfoList;
|
|
return AppInfoList + "#cut#" + FileInfoList + "#cut#" + PageInfoList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
[HttpGet]
|
|
[HttpGet]
|
|
|
[Route("/noauth/pageinfo")]
|
|
[Route("/noauth/pageinfo")]
|
|
|
- public IActionResult page(string v = "4.4.0", string k = "creater", string c = "", int p = 0, string et = "des")
|
|
|
|
|
|
|
+ public string page(string v = "4.2.0", string k = "creater", string c = "", int p = 0, string et = "des")
|
|
|
{
|
|
{
|
|
|
- string appini = makeAppInitData(new MakeAppInitDataDto()
|
|
|
|
|
- {
|
|
|
|
|
- kind = k,
|
|
|
|
|
- appVersion = v,
|
|
|
|
|
- projectId = p,
|
|
|
|
|
- }, et);
|
|
|
|
|
- if (!string.IsNullOrEmpty(appini))
|
|
|
|
|
|
|
+ var set = _AppSourceSetService.GetFirst(m => m.projectId == p && m.kind == k);
|
|
|
|
|
+ if(set != null)
|
|
|
{
|
|
{
|
|
|
- if (appini.Contains("#cut#"))
|
|
|
|
|
|
|
+ var client = new OssClient(set.endPoint, set.accessKeyId, set.accessKeySecret);
|
|
|
|
|
+ string appini = makeAppInitData(client, set, new MakeAppInitDataDto()
|
|
|
{
|
|
{
|
|
|
- string[] appinidata = appini.Split(new string[] { "#cut#" }, StringSplitOptions.None);
|
|
|
|
|
- string AppInfoList = appinidata[0];
|
|
|
|
|
- string SystemSet = appinidata[1];
|
|
|
|
|
- string PageInfoList = appinidata[2];
|
|
|
|
|
- string GotoPages = appinidata[3];
|
|
|
|
|
- string LibFile = appinidata[4];
|
|
|
|
|
- AppInfoList = System.Text.RegularExpressions.Regex.Unescape(AppInfoList);
|
|
|
|
|
- SystemSet = System.Text.RegularExpressions.Regex.Unescape(SystemSet);
|
|
|
|
|
- PageInfoList = System.Text.RegularExpressions.Regex.Unescape(PageInfoList);
|
|
|
|
|
- GotoPages = System.Text.RegularExpressions.Regex.Unescape(GotoPages);
|
|
|
|
|
- LibFile = System.Text.RegularExpressions.Regex.Unescape(LibFile);
|
|
|
|
|
-
|
|
|
|
|
- string startPath = "";
|
|
|
|
|
- string zipPath = "";
|
|
|
|
|
- if(c == "ios")
|
|
|
|
|
- {
|
|
|
|
|
- Function.WritePage("ini", "AppInfoList.ini", AppInfoList);
|
|
|
|
|
- Function.WritePage("ini", "SystemSet.ini", SystemSet);
|
|
|
|
|
- Function.WritePage("ini", "PageInfoList.ini", PageInfoList);
|
|
|
|
|
- Function.WritePage("ini", "GotoPages.ini", GotoPages);
|
|
|
|
|
- Function.WritePage("ini", "LibFile.ini", LibFile);
|
|
|
|
|
- startPath = Function.getPath("ini");
|
|
|
|
|
- zipPath = Function.getPath("ini.zip");
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
|
|
+ kind = k,
|
|
|
|
|
+ appVersion = v,
|
|
|
|
|
+ projectId = p,
|
|
|
|
|
+ }, et);
|
|
|
|
|
+ if (!string.IsNullOrEmpty(appini))
|
|
|
|
|
+ {
|
|
|
|
|
+ if (appini.Contains("#cut#"))
|
|
|
{
|
|
{
|
|
|
- Function.WritePage("txt", "AppInfoList.txt", AppInfoList);
|
|
|
|
|
- Function.WritePage("txt", "SystemSet.txt", SystemSet);
|
|
|
|
|
- Function.WritePage("txt", "PageInfoList.txt", PageInfoList);
|
|
|
|
|
- Function.WritePage("txt", "GotoPages.txt", GotoPages);
|
|
|
|
|
- Function.WritePage("txt", "LibFile.txt", LibFile);
|
|
|
|
|
- startPath = Function.getPath(path_str: "txt");
|
|
|
|
|
- zipPath = Function.getPath("txt.zip");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ string[] appinidata = appini.Split(new string[] { "#cut#" }, StringSplitOptions.None);
|
|
|
|
|
+ string AppInfoList = appinidata[0];
|
|
|
|
|
+ string SystemSet = appinidata[1];
|
|
|
|
|
+ string PageInfoList = appinidata[2];
|
|
|
|
|
+ string GotoPages = appinidata[3];
|
|
|
|
|
+ string LibFile = appinidata[4];
|
|
|
|
|
+ AppInfoList = System.Text.RegularExpressions.Regex.Unescape(AppInfoList);
|
|
|
|
|
+ SystemSet = System.Text.RegularExpressions.Regex.Unescape(SystemSet);
|
|
|
|
|
+ PageInfoList = System.Text.RegularExpressions.Regex.Unescape(PageInfoList);
|
|
|
|
|
+ GotoPages = System.Text.RegularExpressions.Regex.Unescape(GotoPages);
|
|
|
|
|
+ LibFile = System.Text.RegularExpressions.Regex.Unescape(LibFile);
|
|
|
|
|
|
|
|
- if(System.IO.File.Exists(zipPath))
|
|
|
|
|
- {
|
|
|
|
|
- System.IO.File.Delete(zipPath);
|
|
|
|
|
- }
|
|
|
|
|
- ZipFile.CreateFromDirectory(startPath, zipPath);
|
|
|
|
|
|
|
+ string startPath = "";
|
|
|
|
|
+ string zipPath = "";
|
|
|
|
|
+ string zipKey = "";
|
|
|
|
|
+ if(c == "ios")
|
|
|
|
|
+ {
|
|
|
|
|
+ Function.WritePage("ini", "AppInfoList.ini", AppInfoList);
|
|
|
|
|
+ Function.WritePage("ini", "SystemSet.ini", SystemSet);
|
|
|
|
|
+ Function.WritePage("ini", "PageInfoList.ini", PageInfoList);
|
|
|
|
|
+ Function.WritePage("ini", "GotoPages.ini", GotoPages);
|
|
|
|
|
+ Function.WritePage("ini", "LibFile.ini", LibFile);
|
|
|
|
|
+ startPath = Function.getPath("ini");
|
|
|
|
|
+ zipPath = Function.getPath("ini.zip");
|
|
|
|
|
+ zipKey = "ini.zip";
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ Function.WritePage("txt", "AppInfoList.txt", AppInfoList);
|
|
|
|
|
+ Function.WritePage("txt", "SystemSet.txt", SystemSet);
|
|
|
|
|
+ Function.WritePage("txt", "PageInfoList.txt", PageInfoList);
|
|
|
|
|
+ Function.WritePage("txt", "GotoPages.txt", GotoPages);
|
|
|
|
|
+ Function.WritePage("txt", "LibFile.txt", LibFile);
|
|
|
|
|
+ startPath = Function.getPath(path_str: "txt");
|
|
|
|
|
+ zipPath = Function.getPath("txt.zip");
|
|
|
|
|
+ zipKey = "txt.zip";
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- var stream = System.IO.File.OpenRead(zipPath);
|
|
|
|
|
- return File(stream, "text/plain", Path.GetFileName(zipPath));
|
|
|
|
|
|
|
+ if(System.IO.File.Exists(zipPath))
|
|
|
|
|
+ {
|
|
|
|
|
+ System.IO.File.Delete(zipPath);
|
|
|
|
|
+ }
|
|
|
|
|
+ ZipFile.CreateFromDirectory(startPath, zipPath);
|
|
|
|
|
+
|
|
|
|
|
+ // 上传文件
|
|
|
|
|
+ var result = client.PutObject(set.bucketName, zipKey, zipPath, new ObjectMetadata()
|
|
|
|
|
+ {
|
|
|
|
|
+ ExpirationTime = DateTime.Parse("2050-12-31 23:59:59")
|
|
|
|
|
+ });
|
|
|
|
|
+ if (!string.IsNullOrEmpty(result.ETag))
|
|
|
|
|
+ {
|
|
|
|
|
+ if (result.ETag.Length == 32)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (System.IO.File.Exists(zipPath))
|
|
|
|
|
+ {
|
|
|
|
|
+ System.IO.File.Delete(zipPath);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ var url = client.GeneratePresignedUri(set.bucketName, zipKey);
|
|
|
|
|
+ return url.ToString();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- return Content("fail");
|
|
|
|
|
|
|
+ return "fail";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
[HttpGet]
|
|
|
[Route("/noauth/static")]
|
|
[Route("/noauth/static")]
|
|
|
- public IActionResult staticFile(int p, string v = "4.4.0", string k = "creater")
|
|
|
|
|
|
|
+ public string staticFileUpload(int p, string v = "4.2.0", string k = "creater")
|
|
|
{
|
|
{
|
|
|
var set = _AppSourceSetService.GetFirst(m => m.projectId == p && m.kind == k);
|
|
var set = _AppSourceSetService.GetFirst(m => m.projectId == p && m.kind == k);
|
|
|
if(set != null)
|
|
if(set != null)
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
|
|
+ var client = new OssClient(set.endPoint, set.accessKeyId, set.accessKeySecret);
|
|
|
|
|
+ var list = _FileUpdateInfoService.GetList(m => m.kind == k && m.appVersion == v);
|
|
|
|
|
+ foreach(var sub in list)
|
|
|
|
|
+ {
|
|
|
|
|
+ string key = set.path + "/" + v + "/" + sub.path + sub.fileName;
|
|
|
|
|
+ string localPath = "/staticFile/" + key;
|
|
|
|
|
+ var fileObj = client.GetObject(set.bucketName, key);
|
|
|
|
|
+ System.IO.MemoryStream stream = new System.IO.MemoryStream();
|
|
|
|
|
+ fileObj.ResponseStream.CopyTo(stream);
|
|
|
|
|
+ var fileData = stream.ToArray();
|
|
|
|
|
+ if(fileData.Length > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ string fileFullName = Function.getPath(localPath);
|
|
|
|
|
+ string folder = fileFullName.Substring(0, fileFullName.LastIndexOf("/"));
|
|
|
|
|
+ if(!System.IO.Directory.Exists(folder))
|
|
|
|
|
+ {
|
|
|
|
|
+ System.IO.Directory.CreateDirectory(folder);
|
|
|
|
|
+ }
|
|
|
|
|
+ System.IO.File.WriteAllBytes(fileFullName, fileData);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ string startPath = Function.getPath("/staticFile/" + set.path + "/" + v + "/");
|
|
|
|
|
+ string filePath = "/staticOutFile/" + set.path + "/" + v + "/static.zip";
|
|
|
|
|
+ string zipKey = set.path + "/" + v + "/static.zip";
|
|
|
|
|
+ string zipPath = Function.getPath(filePath);
|
|
|
|
|
+ string zipFolder = zipPath.Substring(0, zipPath.LastIndexOf("/"));
|
|
|
|
|
+ if(!System.IO.Directory.Exists(zipFolder))
|
|
|
|
|
+ {
|
|
|
|
|
+ System.IO.Directory.CreateDirectory(zipFolder);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(System.IO.File.Exists(zipPath))
|
|
|
|
|
+ {
|
|
|
|
|
+ System.IO.File.Delete(zipPath);
|
|
|
|
|
+ }
|
|
|
|
|
+ ZipFile.CreateFromDirectory(startPath, zipPath);
|
|
|
|
|
+ // 上传文件
|
|
|
|
|
+ var result = client.PutObject(set.bucketName, zipKey, zipPath, new ObjectMetadata()
|
|
|
|
|
+ {
|
|
|
|
|
+ ExpirationTime = DateTime.Parse("2050-12-31 23:59:59")
|
|
|
|
|
+ });
|
|
|
|
|
+ if (!string.IsNullOrEmpty(result.ETag))
|
|
|
|
|
+ {
|
|
|
|
|
+ if (result.ETag.Length == 32)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (System.IO.File.Exists(zipPath))
|
|
|
|
|
+ {
|
|
|
|
|
+ System.IO.File.Delete(zipPath);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ var url = client.GeneratePresignedUri(set.bucketName, zipKey);
|
|
|
|
|
+ return url.ToString();
|
|
|
}
|
|
}
|
|
|
- return Content("fail");
|
|
|
|
|
|
|
+ return "fail";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|