基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,171 @@
|
||||
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.PubBrower2
|
||||
{
|
||||
public partial class FrmMain : BaseForm
|
||||
{
|
||||
public DynamicPubBrowerModel PubBrowerModel;
|
||||
public FrmMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:窗体加载时</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-09-01 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||||
public void OnLoad()
|
||||
{
|
||||
WaitForm.ShowForm();
|
||||
try
|
||||
{
|
||||
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) : HttpUtility.UrlEncode(PubBrowerModel.UrlParame);
|
||||
}
|
||||
string url = PubBrowerModel.BetweenDLLCoid != null && PubBrowerModel.BetweenDLLCoid.StartsWith("http") ? PubBrowerModel.BetweenDLLCoid + urlEnd : urlEnd.StartsWith("http") ? PubBrowerModel.BetweenDLLCoid + urlEnd : SystemInfo.Instance.OAUrl + PubBrowerModel.BetweenDLLCoid + urlEnd;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
|
||||
}
|
||||
WaitForm.HideForm();
|
||||
}
|
||||
#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.TopMost = true;
|
||||
frmSelectDownload.ShowDialog();
|
||||
//SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||
//saveFileDialog.FileName = FileName;
|
||||
//saveFileDialog.Title = "下载模板文件到";
|
||||
//saveFileDialog.RestoreDirectory = true;
|
||||
////点了保存按钮进入
|
||||
//if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
//{
|
||||
// string localFilePath = System.IO.Path.GetFullPath(saveFileDialog.FileName);//获得文件路径,含文件名
|
||||
// string fileNameExt = localFilePath.Substring(localFilePath.LastIndexOf("\\") + 1);//获取文件名,不带路径
|
||||
// string FilePath = localFilePath.Substring(0, localFilePath.LastIndexOf("\\"));//获取文件路径,不带文件名
|
||||
// FrmDownload frm = new FrmDownload(URL, FileName, localFilePath);
|
||||
// frm.Show();
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user