d3587a16f1
Rollback tag: pre-current-browser-sync-20260818
206 lines
9.8 KiB
C#
206 lines
9.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Lskj.Control;
|
|
using Lskj.Util;
|
|
using Lskj.Model;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Business;
|
|
using System.Web;
|
|
using System.Runtime.InteropServices;
|
|
using Lskj.IPersonnelConnection;
|
|
|
|
|
|
namespace Lskj.PubBrower
|
|
{
|
|
public partial class FrmMain : BaseForm
|
|
{
|
|
public DynamicPubBrowerModel PubBrowerModel;
|
|
public static bool isBatchBrower = false;
|
|
public FrmMain()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
/// <summary>
|
|
/// 加载时
|
|
/// </summary>
|
|
public void OnLoad()
|
|
{
|
|
try
|
|
{
|
|
DataRow menuCondRow = BaseImpl.GetPopMenu(this.PubBrowerModel.ModuleCode, this.PubBrowerModel.FormText); //获取菜单其他配置
|
|
isBatchBrower = menuCondRow != null ? menuCondRow["dllname"].Equals("Lskj.PubBatchBrower.dll") ? true : false : false;
|
|
if (PubBrowerModel.isCalSize)
|
|
{
|
|
this.Height = Convert.ToInt32(Lskj.Main.Model.Manager.frmHeight * PubBrowerModel.PerHeight);
|
|
this.Width = Convert.ToInt32(Screen.PrimaryScreen.WorkingArea.Width * PubBrowerModel.PerWidth);
|
|
this.Location = new Point((Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2,
|
|
(Lskj.Main.Model.Manager.frmHeight - this.Height) / 2);
|
|
}
|
|
bool isPostFlag = this.PubBrowerModel.isPostFlag == 1;
|
|
this.PubBrowerModel.Privilege = PubBrowerModel.ModuleId > 0 ? BaseImpl.GetUserPurviewsByMenuId(PubBrowerModel.ModuleId + "") + "" : BaseImpl.GetUserPurviewsByMenuCode(PubBrowerModel.ModuleCode) + "";
|
|
string urlEnd = string.Empty;
|
|
if (isPostFlag)
|
|
{
|
|
urlEnd = string.IsNullOrEmpty(PubBrowerModel.UrlParame) ? "" : HttpUtility.UrlEncode(PubBrowerModel.UrlParame);
|
|
}
|
|
else
|
|
{
|
|
urlEnd = string.IsNullOrEmpty(PubBrowerModel.UrlParame) ? ReplaceHelper.ReplaceUserInfo(PubBrowerModel.ModuleCode) : string.IsNullOrWhiteSpace(PubBrowerModel.UrlParame) ? "" : HttpUtility.UrlEncode(PubBrowerModel.UrlParame);
|
|
}
|
|
this.Tag = urlEnd;
|
|
string OAUrlAndEnd = string.Empty;
|
|
if (!(PubBrowerModel.BetweenDLLCoid != null && PubBrowerModel.BetweenDLLCoid.StartsWith("http")) && !urlEnd.StartsWith("http"))
|
|
{
|
|
string OAUrl = !string.IsNullOrEmpty(SystemInfo.Instance.OAUrl) && SystemInfo.Instance.OAUrl.EndsWith("/") ? SystemInfo.Instance.OAUrl : SystemInfo.Instance.OAUrl + "/";
|
|
string Between = !string.IsNullOrEmpty(PubBrowerModel.BetweenDLLCoid) && PubBrowerModel.BetweenDLLCoid.StartsWith("/") ? PubBrowerModel.BetweenDLLCoid.TrimStart('/') : PubBrowerModel.BetweenDLLCoid;
|
|
OAUrlAndEnd = OAUrl + Between + urlEnd;
|
|
}
|
|
string url = PubBrowerModel.BetweenDLLCoid != null && PubBrowerModel.BetweenDLLCoid.StartsWith("http") ? PubBrowerModel.BetweenDLLCoid + urlEnd : urlEnd.StartsWith("http") ? PubBrowerModel.BetweenDLLCoid + urlEnd : OAUrlAndEnd;
|
|
|
|
if (url.Contains("{iPersonnelAllowInformation}") || url.Contains("{iPersonnelEncryptedMessage}"))
|
|
{
|
|
//url = ReplaceHelper.ReplaceIPersonnel(url, SystemInfo.Instance.iPersonnelAllowInformation, SystemInfo.Instance.iPersonnelCustomerId, SystemInfo.Instance.iPersonnelPrivateKey);
|
|
url = PersonnelReplaceHelper.UrlEncryption(url, SystemInfo.Instance.iPersonnelAllowInformation, SystemInfo.Instance.iPersonnelCustomerId, SystemInfo.Instance.iPersonnelPrivateKey, ERPInfo.Instance.UserLinkPhone);
|
|
}
|
|
if (url.Contains("{CDSBLimsLoginNo}"))
|
|
{
|
|
url = PersonnelReplaceHelper.CDSBLimsUrlEncryption(url, ERPInfo.Instance.LoginAccount, SystemInfo.Instance.CDSBLimsPrivateKey);
|
|
}
|
|
|
|
bool downLoadFlag = this.PubBrowerModel.downLoadFlag == 1;
|
|
int RightKeyFlag = this.PubBrowerModel.RightKeyFlag;
|
|
if (downLoadFlag)
|
|
{
|
|
this.Close();
|
|
|
|
url = HttpUtility.UrlDecode(url);
|
|
url = url.Replace("%2f", "/");
|
|
url = url.Replace("#", "%23");
|
|
//WebBrowser browserNew = new WebBrowser();//点击下载的页面
|
|
//browserNew.Navigate(url);
|
|
string[] newurl = url.Split('?');
|
|
string szFilename = newurl[0].Substring(newurl[0].LastIndexOf('/') + 1);//简单处理文件名,实际中还需要单独处理,这里有BUG
|
|
//string SzFileName = HttpUtility.UrlDecode(szFilename);
|
|
string[] szName = szFilename.Split('/');
|
|
string fileTitle = szName[szName.Length - 1];
|
|
Download(url, fileTitle);
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
this.Opacity = 100D;
|
|
previewFrm previewFrm = new previewFrm();
|
|
previewFrm.moduleWebView.PubBrowerModel = this.PubBrowerModel;
|
|
previewFrm.Dock = DockStyle.Fill;
|
|
previewFrm.OnLoad(url, RightKeyFlag);
|
|
this.Controls.Add(previewFrm);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex, "浏览器dll");
|
|
//MessageUtil.Show(ex.Message + "\r\n" + ex.StackTrace);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
#region 内存回收
|
|
[DllImport("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize")]
|
|
public static extern int SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize);
|
|
/// <summary>
|
|
/// <para>说明:释放内存</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-09-29 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
public static void ClearMemory()
|
|
{
|
|
GC.Collect();
|
|
GC.WaitForPendingFinalizers();
|
|
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
|
{
|
|
//FrmMian为我窗体的类名
|
|
FrmMain.SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// <para>说明:定义服务器文件地址,含文件名。客户端接收地址及文件名由客户端自行定义</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期: </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="URL">The URL.</param>
|
|
/// <param name="FileName">Name of the file.</param>
|
|
public static void Download(string URL, string FileName)
|
|
{
|
|
|
|
FrmSelectDownload frmSelectDownload = new FrmSelectDownload();
|
|
frmSelectDownload.URL = URL;
|
|
frmSelectDownload.FileName = FileName;
|
|
frmSelectDownload.isBatchDownLoad = isBatchBrower;
|
|
// frmSelectDownload.TopMost = true;
|
|
frmSelectDownload.ShowDialog();
|
|
|
|
//if (!string.IsNullOrWhiteSpace(Delimiter))
|
|
//{
|
|
// //批量下载
|
|
// int filequency = 0;
|
|
// string[] urls = URL.Split(new[] { Delimiter }, StringSplitOptions.None);
|
|
// bool isOpenvisble = urls.Count() > 0;
|
|
// foreach (string item in urls)
|
|
// {
|
|
// string url = item;
|
|
// url = HttpUtility.UrlDecode(url);
|
|
// url = item.Replace("%2f", "/");
|
|
// url = item.Replace("#", "%23");
|
|
// string[] newurl = url.Split('?');
|
|
// string szFilename = newurl[0].Substring(newurl[0].LastIndexOf('/') + 1);//简单处理文件名,实际中还需要单独处理,这里有BUG
|
|
// string[] szName = szFilename.Split('/');
|
|
// string fileTitle = szName[szName.Length - 1];
|
|
|
|
// FrmSelectDownload frmSelectDownload = new FrmSelectDownload();
|
|
// if (filequency > 0) frmSelectDownload.isMultiple = true;
|
|
// frmSelectDownload.isprompt = filequency + 1 == urls.Count();
|
|
// frmSelectDownload.URL = item;
|
|
// frmSelectDownload.isOpenvisble = isOpenvisble;
|
|
// frmSelectDownload.FileName = fileTitle;
|
|
// //frmSelectDownload.TopMost = true;
|
|
// DialogResult result = frmSelectDownload.ShowDialog();
|
|
// if (result != DialogResult.OK) return;
|
|
// filequency++;
|
|
// }
|
|
|
|
|
|
//}
|
|
//else
|
|
//{
|
|
// FrmSelectDownload frmSelectDownload = new FrmSelectDownload();
|
|
// frmSelectDownload.URL = URL;
|
|
// frmSelectDownload.FileName = FileName;
|
|
// frmSelectDownload.isBatchDownLoad = isBatchBrower;
|
|
// // frmSelectDownload.TopMost = true;
|
|
// frmSelectDownload.ShowDialog();
|
|
//}
|
|
|
|
}
|
|
}
|
|
}
|