SVN-Revision: r424
This commit is contained in:
wyf
2025-04-01 03:49:00 +00:00
parent 09efc2371b
commit b985ab9954
@@ -1131,48 +1131,79 @@ namespace Lskj.Control.Model
string fileDownTitle = dataTable != null && dataTable.Rows.Count > 0 && dataTable.Columns.Contains("fileTitle") ? dataTable.Rows[0]["fileTitle"] + "" : ""; string fileDownTitle = dataTable != null && dataTable.Rows.Count > 0 && dataTable.Columns.Contains("fileTitle") ? dataTable.Rows[0]["fileTitle"] + "" : "";
if (!string.IsNullOrWhiteSpace(urls)) if (!string.IsNullOrWhiteSpace(urls))
{ {
string downUrl = string.Format("{0}Api/FileUploadApi.ashx", SystemInfo.Instance.OAUrl); string token = "";
Dictionary<string, string> parmarsDic = new Dictionary<string, string>(); string loginUrl = $"{SystemInfo.Instance.OAUrl}/Api/SysUserAjaxApi.ashx";
parmarsDic.Add("userid", ERPInfo.Instance.UserId); HttpTools.setting("application/x-www-form-urlencoded", null, null, HttpTools.Encode.UTF8);
parmarsDic.Add("username", ERPInfo.Instance.UserName); Dictionary<string, string> loginPmsDic = new Dictionary<string, string>();
parmarsDic.Add("password", ERPInfo.Instance.InPassWord); loginPmsDic.Add("method", "Login");
parmarsDic.Add("method", "DownLoadFiels"); loginPmsDic.Add("username", ERPInfo.Instance.UserName);
parmarsDic.Add("urls", urls); loginPmsDic.Add("password", ERPInfo.Instance.InPassWord);
parmarsDic.Add("moduleid", model.MenuTabName); HttpWebResponse loginResponse = HttpTools.Post(loginUrl, "", loginPmsDic, HttpTools.Method.POST, out CookieCollection loginCookie, out string loginResult);
parmarsDic.Add("idvalue", idvalue); if (loginResponse != null && !string.IsNullOrEmpty(loginResult))
HttpTools.setting("application/x-www-form-urlencoded", null, null);
//HttpWebResponse response = HttpTools.Post(downUrl, "", parmarsDic, HttpTools.Method.POST);
HttpWebResponse response = HttpTools.Post(downUrl, "", parmarsDic, null, HttpTools.Method.POST);
string result = new StreamReader(response.GetResponseStream(), Encoding.UTF8).ReadToEnd();
if (response != null && !string.IsNullOrEmpty(result))
{ {
JObject jsonObject = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(result); JObject jObject = JsonConvert.DeserializeObject<JObject>(loginResult);
string isSuccess = jsonObject["success"] + ""; if (jObject.ContainsKey("success"))
if (isSuccess.Equals("True", StringComparison.CurrentCultureIgnoreCase))
{ {
string zipPathUrl = jsonObject["data"] + ""; if ((jObject["success"] + "").Equals("True"))
string downLoadUrl = string.Format("{0}{1}", SystemInfo.Instance.OAUrl, zipPathUrl.TrimStart('/')); {
FrmSelectDownload frmSelectDownload = new FrmSelectDownload(); if (jObject.ContainsKey("token"))
frmSelectDownload.URL = downLoadUrl; {
token = jObject["token"] + "";
frmSelectDownload.ModelId = model.MenuTabName; }
frmSelectDownload.MenuName = model.MenuName; }
frmSelectDownload.MenuId = model.Id + "";
string[] szName = zipPathUrl.Split('/');
string fileTitle = !string.IsNullOrWhiteSpace(fileDownTitle) ? fileDownTitle : szName[szName.Length - 1];
frmSelectDownload.FileName = fileTitle;
//frmSelectDownload.TopMost = true;
frmSelectDownload.Show();
}
else
{
MessageUtil.Show(jsonObject["msg"] + "");
} }
} }
response.GetResponseStream().Close(); if (!string.IsNullOrEmpty(token))
response.Close(); {
string downUrl = string.Format("{0}Api/FileUploadApi.ashx", SystemInfo.Instance.OAUrl);
Dictionary<string, string> parmarsDic = new Dictionary<string, string>();
parmarsDic.Add("userid", ERPInfo.Instance.UserId);
parmarsDic.Add("username", ERPInfo.Instance.UserName);
parmarsDic.Add("password", ERPInfo.Instance.InPassWord);
parmarsDic.Add("method", "DownLoadFiels");
parmarsDic.Add("urls", urls);
parmarsDic.Add("moduleid", model.MenuTabName);
parmarsDic.Add("idvalue", idvalue);
Dictionary<string, string> headerDic = new Dictionary<string, string>();
headerDic.Add("Authorization", $"Bearer {token}");
HttpTools.setting("application/x-www-form-urlencoded", null, null);
//HttpWebResponse response = HttpTools.Post(downUrl, "", parmarsDic, HttpTools.Method.POST);
HttpWebResponse response = HttpTools.Post(downUrl, "", parmarsDic, headerDic, HttpTools.Method.POST);
string result = new StreamReader(response.GetResponseStream(), Encoding.UTF8).ReadToEnd();
if (response != null && !string.IsNullOrEmpty(result))
{
JObject jsonObject = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(result);
string isSuccess = jsonObject["success"] + "";
if (isSuccess.Equals("True", StringComparison.CurrentCultureIgnoreCase))
{
string zipPathUrl = jsonObject["data"] + "";
string downLoadUrl = string.Format("{0}{1}", SystemInfo.Instance.OAUrl, zipPathUrl.TrimStart('/'));
FrmSelectDownload frmSelectDownload = new FrmSelectDownload();
frmSelectDownload.URL = downLoadUrl;
frmSelectDownload.ModelId = model.MenuTabName;
frmSelectDownload.MenuName = model.MenuName;
frmSelectDownload.MenuId = model.Id + "";
string[] szName = zipPathUrl.Split('/');
string fileTitle = !string.IsNullOrWhiteSpace(fileDownTitle) ? fileDownTitle : szName[szName.Length - 1];
frmSelectDownload.FileName = fileTitle;
//frmSelectDownload.TopMost = true;
frmSelectDownload.Show();
}
else
{
MessageUtil.Show(jsonObject["msg"] + "");
}
}
response.GetResponseStream().Close();
response.Close();
}
else
{
MessageUtil.Show($"登录验证失败\r\n{loginResult}");
}
} }
else else
{ {
@@ -1470,28 +1501,4 @@ namespace Lskj.Control.Model
DataRow[] dataRows = columnsTab.Select().Where(n => (n["name"] + "").Equals(colunmField.Key)).ToArray(); DataRow[] dataRows = columnsTab.Select().Where(n => (n["name"] + "").Equals(colunmField.Key)).ToArray();
if (dataRows.Length == 0) if (dataRows.Length == 0)
{ {
string addColSql = string.Format("alter table P_PrivateDllTab add {0} {1}", colunmField.Key, colunmField.Value); string a
SqlHelper.ExecuteNonQuery(addColSql);//添加列
}
}
}
else
{
string createTabSql = "create table P_PrivateDllTab(id int IDENTITY(1,1) NOT NULL,{0})";
string createCol = string.Empty;
foreach (KeyValuePair<string, string> colunmField in colDic)
{
createCol += string.Format("{0} {1},", colunmField.Key, colunmField.Value);
}
createTabSql = string.Format(createTabSql, createCol.TrimEnd(','));
SqlHelper.ExecuteNonQuery(createTabSql);//创建表
}
return true;
}
catch (Exception)
{
return false;
}
}
}
}