2099 lines
104 KiB
C#
2099 lines
104 KiB
C#
/******************************
|
||
* 说明:右键菜单、常用菜单通用类
|
||
* 创建人:龚宇超
|
||
* 创建日期:2017-12-19
|
||
* 修改人:
|
||
* 修改日期:
|
||
* 修改备注:
|
||
* 版本:1.0.0.0
|
||
******************************/
|
||
using DevExpress.Utils;
|
||
using DevExpress.Utils.Menu;
|
||
using DevExpress.XtraGrid.Columns;
|
||
using DevExpress.XtraGrid.Views.Base;
|
||
using DevExpress.XtraGrid.Views.Grid;
|
||
using DevExpress.XtraTab;
|
||
using Lskj.Business;
|
||
using Lskj.Business.Impl;
|
||
using Lskj.Control.BrowserSetting;
|
||
using Lskj.Core;
|
||
using Lskj.Data;
|
||
using Lskj.Data.Api.BLL;
|
||
using Lskj.Model;
|
||
using Lskj.Util;
|
||
using Newtonsoft.Json;
|
||
using Newtonsoft.Json.Linq;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.Diagnostics;
|
||
using System.Drawing;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Net;
|
||
using System.Text;
|
||
using System.Text.RegularExpressions;
|
||
using System.Threading;
|
||
using System.Web;
|
||
using System.Windows.Forms;
|
||
|
||
namespace Lskj.Control.Model
|
||
{
|
||
/// <summary>
|
||
/// 右键菜单、常用菜单通用类
|
||
/// </summary>
|
||
public class BaseRightMenu
|
||
{
|
||
/// <summary>
|
||
/// 最初账套版本
|
||
/// </summary>
|
||
public DataRow AccountItem;
|
||
public DataTable MenuTable;
|
||
public DynamicModel Model;
|
||
public MyControl ControlObj;
|
||
/// <summary>
|
||
/// 表格按钮右键
|
||
/// </summary>
|
||
public Dictionary<int, ToolStripMenuItem> RightMenuBtnEdits = new Dictionary<int, ToolStripMenuItem>();
|
||
/// <summary>
|
||
/// mrp按钮右键
|
||
/// </summary>
|
||
public Dictionary<int, ToolStripMenuItem> RightMenuMrpBtnEdits = new Dictionary<int, ToolStripMenuItem>();
|
||
protected GridView BaseGridView;
|
||
protected ContextMenuStrip MenuStrip;
|
||
/// <summary>
|
||
/// 右键菜单执行完成后调用事件
|
||
/// </summary>
|
||
protected event EventHandler OnRightCallback;
|
||
/// <summary>
|
||
/// 替换参数前执行
|
||
/// </summary>
|
||
public event BeforeHandleParamsEventHandler OnBeforeHandleParamsCallback;
|
||
|
||
/// <summary>
|
||
/// 触发替换参数前事件,并返回事件处理后的参数值。
|
||
/// </summary>
|
||
protected string RaiseBeforeHandleParamsCallback(List<string> paramList, DataRow[] rowDatas, string paramItem, DataRow rowData, string fieldValue)
|
||
{
|
||
BeforeHandleParamsEventHandler handler = OnBeforeHandleParamsCallback;
|
||
if (handler == null)
|
||
return fieldValue;
|
||
|
||
HandleParamsArgs handleParamsArgs = new HandleParamsArgs(paramList, rowDatas, paramItem, rowData)
|
||
{
|
||
FieldValue = fieldValue
|
||
};
|
||
handler(this, handleParamsArgs);
|
||
return handleParamsArgs.FieldValue;
|
||
}
|
||
/// <summary>
|
||
/// 缓存右键菜单
|
||
/// </summary>
|
||
protected List<ToolStripMenuItem> RightMenuItems = new List<ToolStripMenuItem>();
|
||
/// <summary>
|
||
/// 是否允许右键回调
|
||
/// </summary>
|
||
public bool AllowRightCallback = false;
|
||
|
||
FrmProgressBar frmProgressBar = null;
|
||
|
||
|
||
/// <summary>
|
||
/// <para>说明:设置右键菜单</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-12-19 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="gridControl">The grid view.</param>
|
||
/// <param name="table">The table.</param>
|
||
public virtual void InitRightMenus(System.Windows.Forms.Control view, DataTable table, DynamicModel model, MyControl control = null, ContextMenuStrip menu = null)
|
||
{
|
||
this.MenuTable = table;
|
||
this.Model = model;
|
||
this.ControlObj = control;
|
||
|
||
//判断是否存在网址框(需要绑定右键打开事件判断是否生成 网址框右键)
|
||
bool existLabWWW = false;
|
||
if (view is GridControlEx)
|
||
{
|
||
GridControlEx grid = view as GridControlEx;
|
||
foreach (GridColumn item in grid.GridView.Columns)
|
||
{
|
||
if (item.Tag is GridColumnModel)
|
||
{
|
||
GridColumnModel gridColumnModel = item.Tag as GridColumnModel;
|
||
if (gridColumnModel.FieldType == ControlType.LabWWW) existLabWWW = true;
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
|
||
if (((table == null || table.Rows.Count == 0) && menu == null) && !existLabWWW) return;
|
||
|
||
ContextMenuStrip cmsMenu = new ContextMenuStrip();
|
||
cmsMenu.Opening += new CancelEventHandler(MenuStripOpening);
|
||
|
||
if (menu != null)
|
||
{
|
||
// 添加固定的右键菜单,例附件管理
|
||
for (int i = menu.Items.Count - 1; i >= 0; i--)
|
||
{
|
||
ToolStripMenuItem item = menu.Items[i] as ToolStripMenuItem;
|
||
cmsMenu.Items.Add(item);
|
||
RightMenuItems.Add(item);
|
||
}
|
||
}
|
||
|
||
foreach (DataRow item in table.Rows)
|
||
{
|
||
GridRightMenuModel menuModel = new GridRightMenuModel(item);
|
||
if (!string.IsNullOrWhiteSpace(menuModel.MenuName))
|
||
{
|
||
ToolStripMenuItem menuItem = new ToolStripMenuItem();
|
||
menuItem.Text = menuModel.MenuName;
|
||
menuItem.Tag = menuModel;
|
||
menuItem.Click += new EventHandler(MenuStripItemClick);
|
||
|
||
if ((item.Table.Columns.Contains("IcoName") && !string.IsNullOrEmpty(item["IcoName"] + "")) || (item.Table.Columns.Contains("showtoolbar") && !string.IsNullOrEmpty(item["showtoolbar"] + "")))
|
||
{
|
||
RightMenuBtnEdits.Add(menuModel.Id, menuItem);
|
||
}
|
||
if (item.Table.Columns.Contains("isMrpClickBtn") && (item["isMrpClickBtn"] + "").Equals("1"))
|
||
{
|
||
RightMenuMrpBtnEdits.Add(menuModel.Id, menuItem);
|
||
}
|
||
else
|
||
{
|
||
cmsMenu.Items.Add(menuItem);
|
||
RightMenuItems.Add(menuItem);
|
||
}
|
||
}
|
||
if (!string.IsNullOrWhiteSpace(menuModel.ExecuteFirstCode))
|
||
{
|
||
DataRow[] rows = table.Select("orderid='" + menuModel.ExecuteFirstCode + "'");
|
||
if (rows != null && rows.Length > 0)
|
||
{
|
||
GridRightMenuModel ExecuteFirstMenuModel = new GridRightMenuModel(rows[0]);
|
||
menuModel.ExecuteFirstRightModel = ExecuteFirstMenuModel;
|
||
}
|
||
|
||
}
|
||
}
|
||
this.MenuStrip = cmsMenu;
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:设置回调函数</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-12-19 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="handler">The handler.</param>
|
||
public virtual void SetRightCallback(EventHandler handler)
|
||
{
|
||
|
||
this.OnRightCallback = handler;
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:右键菜单执行前调用</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-01-29 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="item">The item.</param>
|
||
/// <param name="model">The model.</param>
|
||
protected virtual void MenuStripClickBefore(ToolStripMenuItem item, GridRightMenuModel model)
|
||
{
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:右键菜单执行完</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-01-29 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="item">The item.</param>
|
||
/// <param name="model">The model.</param>
|
||
protected virtual void MenuStripClickAfter(ToolStripMenuItem item, GridRightMenuModel model)
|
||
{
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:右键菜单打开前判断</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-01-29 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The sender.</param>
|
||
/// <param name="e">The <see cref="CancelEventArgs"/> instance containing the event data.</param>
|
||
protected virtual void MenuStripOpening(object sender, CancelEventArgs e)
|
||
{
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:检查可用条件</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-09 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="cond">The cond.</param>
|
||
/// <param name="dataRow">The data row.</param>
|
||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||
public bool ValidateCond(string cond, DataRow dataRow)
|
||
{
|
||
bool result = false;
|
||
cond = ReplaceHelper.ReplaceRowParam(dataRow, cond);
|
||
if (cond.StartsWith("@") || cond.StartsWith("!"))
|
||
{
|
||
result = "1".Equals(BaseImpl.GetDefaultValue(cond));
|
||
}
|
||
else if (dataRow == null)
|
||
{
|
||
result = ReplaceHelper.EvalCond(cond);
|
||
}
|
||
else
|
||
{
|
||
result = ReplaceHelper.ReplaceRowParamCond(dataRow, cond);
|
||
}
|
||
return result;
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:右键菜单点击</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-01-29 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The sender.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
protected virtual void MenuStripItemClick(object sender, EventArgs e)
|
||
{
|
||
|
||
ToolStripMenuItem item = sender as ToolStripMenuItem;
|
||
DXMenuItem items = sender as DXMenuItem;
|
||
|
||
|
||
DataRow[] rowArray = GetSelectedRows();
|
||
GridRightMenuModel model = item == null ? items.Tag as GridRightMenuModel : item.Tag as GridRightMenuModel;
|
||
|
||
if (!model.Mergeexec && !model.MoreClick && rowArray.Length > 1)
|
||
{
|
||
MessageUtil.Show(string.Format(ResourceKeys.ExecRightMenuOnlyOne, model.MenuName));
|
||
return;
|
||
}
|
||
|
||
if (model.VerifyUpdate && BaseGridView!=null)
|
||
{
|
||
for (int i = 0; i < BaseGridView.DataRowCount; i++)
|
||
{
|
||
var row = BaseGridView.GetDataRow(i);
|
||
if (row != null && (row.RowState == DataRowState.Added || row.RowState == DataRowState.Modified))
|
||
{
|
||
MessageUtil.Show("有数据未保存,请先保存后在执行右键");
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
if (rowArray.Length == 0 && model.IsMustSelectRow())
|
||
{
|
||
MessageUtil.Show(ResourceKeys.SelectRowIsNull);
|
||
return;
|
||
}
|
||
if (!string.IsNullOrEmpty(model.UnionZTid))
|
||
{
|
||
string UnionZTid = ReplaceHelper.ReplaceRowParam(rowArray[0], model.UnionZTid);
|
||
string condition = string.Format("where ShowName ='{0}'", ERPInfo.Instance.AccountBook);
|
||
DataTable dt = MainImpl.GetLedgerList(condition);
|
||
DataRow RT = BaseImpl.GetDataRowResult($"select * from p_sydbGroupTab where ID={UnionZTid}");
|
||
AccountItem = dt.Rows[0];
|
||
AccountItem["IP"] = DBConfig.Instance.ServerName;
|
||
ToDBatching(RT, AccountItem);
|
||
}
|
||
try
|
||
{
|
||
this.MenuStripClickBefore(item, model);
|
||
|
||
if (model.ExecuteFirstRightModel != null)
|
||
{
|
||
bool ExecuteFirstExecResult = this.ExecRightMenu(model.ExecuteFirstRightModel, rowArray);
|
||
if (!ExecuteFirstExecResult) return;
|
||
}
|
||
|
||
bool execResult = this.ExecRightMenu(model, rowArray);
|
||
|
||
//if (model.nextrightcode == 0 && execResult)
|
||
//{
|
||
//}
|
||
|
||
if (model.ActionType == 0 && execResult && !model.DisableSuccessfulPrompt)
|
||
{
|
||
MessageUtil.Show(string.IsNullOrEmpty(model.SuccessMsg) ? ResourceKeys.OperSuccess : model.SuccessMsg);
|
||
}
|
||
|
||
if ((execResult || AllowRightCallback) && model.Refresh && this.OnRightCallback != null)
|
||
{
|
||
this.OnRightCallback(sender, e);
|
||
}
|
||
if (!string.IsNullOrWhiteSpace(this.Model.ModuleCode))
|
||
{
|
||
DataRow modelRow = MainImpl.GetSystemdllTab(this.Model.ModuleCode);//获取单个模块信息
|
||
ModuleModel SysModel = new ModuleModel(modelRow);// 系统模块实体对象
|
||
if (SysModel.AccordingNameSelected == 0)
|
||
{
|
||
this.MenuStripClickAfter(item, model);
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||
MessageUtil.Show(Message, ex.Message);
|
||
LogHelper.Instance.WriteError(ex);
|
||
}
|
||
finally
|
||
{
|
||
if (!string.IsNullOrEmpty(model.UnionZTid)) ToDBatching(AccountItem, AccountItem);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 启动账套数据源刷新
|
||
/// </summary>
|
||
protected void ToDBatching(DataRow RT, DataRow firstrow)
|
||
{
|
||
string serverIP = RT["IP"] + "";
|
||
string dbName = RT["DBName"] + "";
|
||
string dataBook = RT["ShowName"] + "";
|
||
bool isInternal = RT.Table.Columns.Contains("IsInternalNetwork") && !string.IsNullOrEmpty(RT["IsInternalNetwork"] + "") ? "1".Equals(RT["IsInternalNetwork"] + "") : false;
|
||
DBConfig.Instance.DataBook = dataBook;
|
||
DBConfig.Instance.ServerName = serverIP;
|
||
DBConfig.Instance.DataBase = dbName;
|
||
DBConfig.Instance.IsInternalNetwork = isInternal;
|
||
if (!DBConfig.Instance.CreateConnection())
|
||
{
|
||
ToDBatching(firstrow, firstrow);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:QQ点击</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-10-30 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
protected void QQItemClick(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
ToolStripMenuItem item = (ToolStripMenuItem)sender;
|
||
Process process = new Process();
|
||
ProcessStartInfo processInfo = new ProcessStartInfo();
|
||
string Url = string.Format(@"tencent://message/?Menu=yes&uin={0}", item.Tag);
|
||
processInfo.FileName = @"iexplore.exe";
|
||
processInfo.Arguments = Url;
|
||
processInfo.UseShellExecute = true;
|
||
processInfo.RedirectStandardInput = false;
|
||
process.StartInfo = processInfo;
|
||
process.Start();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Instance.WriteError(ex);
|
||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||
MessageUtil.Show(ResourceKeys.OpenQQError);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:网站点击</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-10-30 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The source of the event.</param>
|
||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||
protected void BrowerItemClick(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
ToolStripMenuItem item = (ToolStripMenuItem)sender;
|
||
//Process.Start("iexplore.exe", item.Tag + "");
|
||
System.Diagnostics.Process.Start(item.Tag + "");//默认浏览器打开
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Instance.WriteError(ex);
|
||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||
MessageUtil.Show(ResourceKeys.OpenBrowerFault);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:执行右键菜单</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-10-30 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="model">The model.</param>
|
||
/// <param name="rows">The row handles.</param>
|
||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||
public bool ExecRightMenu(GridRightMenuModel model, DataRow[] rows)
|
||
{
|
||
|
||
StaticControl.RightMenuGridView = BaseGridView;
|
||
List<string> paramListEx = model.ParamList;
|
||
List<string> paramList = null;
|
||
|
||
bool resultValue = true;
|
||
bool isFirstSuccess = false;//第一次返回成功
|
||
bool FinallySucceeded = false;//最后一次成功
|
||
|
||
string actionSql = string.Empty;
|
||
bool execOnlyOne = IsExecOnlyOne(model, paramListEx, rows, out actionSql);
|
||
|
||
bool tipOnlyOne = true; // 执行是否提示一次
|
||
bool allowBefore = ApiHelper.IsExecEventApi(Interface.Api.OperateEvent.BeforeModuleContextMenu, Model.ModuleCode, model.Id);
|
||
bool allowAfter = ApiHelper.IsExecEventApi(Interface.Api.OperateEvent.AfterModuleContextMenu, Model.ModuleCode, model.Id);
|
||
if (model.AllowNullExec && rows.Length == 0)
|
||
{
|
||
rows = new DataRow[] { new DataTable().NewRow() };
|
||
}
|
||
for (int i = 0; i < rows.Length; i++)
|
||
{
|
||
// 只执行一次,则后续不再执行.
|
||
if (execOnlyOne && i > 0) continue;
|
||
|
||
LogUtil.WriteDebug(model.MenuTabName, "执行右键", model.MenuName, "右键id:" + model.Id);
|
||
|
||
DataRow rowData = rows[i];
|
||
if (!string.IsNullOrWhiteSpace(model.BeforeMsg) && tipOnlyOne)
|
||
{
|
||
tipOnlyOne = false;
|
||
string prompt = ReplaceHelper.ReplaceRowParam(rowData, model.BeforeMsg);
|
||
if (model.Mergeexec)
|
||
{
|
||
//替换[],替换的是多选行中的数据
|
||
prompt = ReplaceHelper.ReplaceRowParam(rows, prompt.Replace("[", "{").Replace("]", "}"), "", "");
|
||
}
|
||
|
||
if (prompt.StartsWith("@") || prompt.StartsWith("!"))
|
||
{
|
||
prompt = BaseImpl.GetDefaultValue(prompt);
|
||
}
|
||
if (!string.IsNullOrWhiteSpace(prompt))
|
||
{
|
||
DialogResult result = MessageUtil.Show(prompt, MessageBoxButtons.YesNo);
|
||
//DialogResult result = MessageUtil.Show(ReplaceHelper.ReplaceRowParam(rowData, model.BeforeMsg), MessageBoxButtons.YesNo);
|
||
if (result != DialogResult.Yes)
|
||
{
|
||
resultValue = false;
|
||
break;
|
||
}
|
||
}
|
||
|
||
}
|
||
//删除触发的接口所要用到的参数,先把参数存到表中,同步工具去处理
|
||
if (!string.IsNullOrWhiteSpace(model.DelToPostSql) && !string.IsNullOrWhiteSpace(model.SynchronizationToolSQL))
|
||
{
|
||
DataTable dt = BaseModuleImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(rowData, model.DelToPostSql));
|
||
foreach (DataRow dr in dt.Rows)
|
||
{
|
||
SqlHelper.ExecuteNonQuery(ReplaceHelper.ReplaceRowParam(dr, model.SynchronizationToolSQL).Replace("''", "null"));
|
||
}
|
||
}
|
||
|
||
paramList = this.HandleRightMenuParams(paramListEx, rowData, model.Mergeexec ? rows : null, model.ActionType);
|
||
string maintabFocusedRowJson = "";
|
||
if (rowData != null)
|
||
{
|
||
maintabFocusedRowJson = rowData.ToJsonObject();
|
||
}
|
||
paramList.Add(maintabFocusedRowJson);
|
||
string dllName = ReplaceHelper.ReplaceRowParam(rowData, model.DllName).Trim();
|
||
if (this.BaseGridView != null)
|
||
{
|
||
GridCell[] cells = this.BaseGridView.GetSelectedCells();
|
||
if (cells != null && cells.Length > 0 && dllName.Contains("{COLUMN_"))
|
||
{
|
||
GridCell cell = cells[0];
|
||
DataRow focusedRow = this.BaseGridView.GetFocusedDataRow();
|
||
string colValue = focusedRow == null || !focusedRow.Table.Columns.Contains(cell.Column.Name) ? "" : focusedRow[cell.Column.Name] + "";
|
||
dllName = dllName.ReplaceColumnParam(cell.Column.Name, cell.Column.Caption, colValue);
|
||
}
|
||
}
|
||
if ((dllName.Equals("Lskj.PubBrower.dll", StringComparison.CurrentCultureIgnoreCase) || dllName.Equals("Lskj.PubBrower2.dll", StringComparison.CurrentCultureIgnoreCase)) && SystemInfo.Instance.PrimitiveBrowser)
|
||
{
|
||
dllName = "Lskj.PubBrowerXp.dll";
|
||
}
|
||
if (dllName.Equals("MyFormDesinger.exe", StringComparison.OrdinalIgnoreCase))
|
||
{
|
||
string[] args = { paramList[0], "-", "-", paramList[3] };
|
||
|
||
System.Diagnostics.Process.Start(PubUtil.AbsolutelyPath + "Desinger\\" + dllName, string.Join(" ", args));
|
||
}
|
||
else if (dllName.Equals("LsCallLibrary.exe", StringComparison.OrdinalIgnoreCase))
|
||
{
|
||
System.Diagnostics.Process.Start(PubUtil.AbsolutelyPath + dllName, string.Join(" ", paramList.ToArray()));
|
||
}
|
||
// 特殊处理程序
|
||
else if (dllName.Contains(".exe") && !model.WipeExes.Contains(dllName.ToString()) && (dllName.ToLower() != "lstest.exe"))
|
||
{
|
||
//WinHelper.WinExec(File.Exists(dllName) ? dllName : PubUtil.AbsolutelyLibPath + dllName, 1);
|
||
// WinHelper.WinExec(dllName);
|
||
string[] dllNameSplit = Regex.Split(dllName, ":args=");
|
||
string[] pmsSplit = dllNameSplit.Length > 1 ? (dllNameSplit[1] + "").Split(',') : null;
|
||
if (dllNameSplit.Length > 1 && pmsSplit != null && pmsSplit.Length > 0)//嵌入exe模块
|
||
{
|
||
string[] pmsArgs = pmsSplit.Select(pms => ReplaceHelper.ReplaceUserInfo(pms)).ToArray();
|
||
string guid = Guid.NewGuid().ToString();
|
||
Panel mainPanel = new Panel();
|
||
ProcessStartInfo processStartInfo = new ProcessStartInfo()
|
||
{
|
||
FileName = dllNameSplit[0],
|
||
Arguments = HandleHelper.CombineArgs(pmsArgs),
|
||
UseShellExecute = false,
|
||
RedirectStandardOutput = false,
|
||
RedirectStandardError = false,
|
||
CreateNoWindow = false
|
||
};
|
||
Process startedProcess = Process.Start(processStartInfo);
|
||
if (startedProcess == null)
|
||
{
|
||
MessageUtil.Show("进程启动失败");
|
||
return false;
|
||
}
|
||
startedProcess.WaitForInputIdle();
|
||
int retry = 0;
|
||
while (startedProcess.MainWindowHandle == IntPtr.Zero && retry < 500)
|
||
{
|
||
Thread.Sleep(100);
|
||
startedProcess.Refresh();
|
||
retry++;
|
||
}
|
||
IntPtr exeMainHandle = startedProcess.MainWindowHandle;
|
||
if (exeMainHandle == IntPtr.Zero)
|
||
{
|
||
MessageBox.Show("无法获取启动程序的主窗口句柄");
|
||
return false;
|
||
}
|
||
HandleHelper.SetFormNoneStyle(exeMainHandle, mainPanel);
|
||
mainPanel.Dock = DockStyle.Fill;
|
||
using (BaseForm baseForm = new BaseForm())
|
||
{
|
||
baseForm.WindowState = FormWindowState.Maximized;
|
||
baseForm.Controls.Add(mainPanel);
|
||
baseForm.ShowDialog();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//删除选中行的json信息
|
||
if (!string.IsNullOrWhiteSpace(maintabFocusedRowJson)) paramList.Remove(maintabFocusedRowJson);
|
||
// 创建进程启动信息对象
|
||
ProcessStartInfo startInfo = new ProcessStartInfo();
|
||
startInfo.FileName = File.Exists(dllName) ? dllName : PubUtil.AbsolutelyLibPath + dllName; // 指定要启动的 EXE 路径
|
||
// 将参数数组拼接为命令行字符串(注意空格处理)
|
||
// 若参数包含空格,需要用双引号包裹,避免被解析为多个参数
|
||
startInfo.Arguments = string.Join(" ", paramList.Select(arg =>
|
||
arg.Contains(" ") ? $"\"{arg}\"" : arg
|
||
));
|
||
// 可选:设置进程启动选项
|
||
startInfo.UseShellExecute = false; // 不使用系统外壳程序(建议为 false,便于重定向输入输出)
|
||
startInfo.CreateNoWindow = false; // 是否在新窗口中启动(false 为显示窗口)
|
||
// 启动进程
|
||
Process process = Process.Start(startInfo);
|
||
|
||
// 执行exe程序
|
||
//WinHelper.WinExec(File.Exists(dllName) ? dllName : PubUtil.AbsolutelyLibPath + dllName, 1);
|
||
}
|
||
}
|
||
else if (dllName.StartsWith("www.") ||
|
||
dllName.StartsWith("http://") ||
|
||
dllName.StartsWith("https://") ||
|
||
dllName.StartsWith("ftp://") ||
|
||
dllName.StartsWith("file://"))
|
||
{
|
||
// 打开网页程序
|
||
Process.Start(dllName);
|
||
}
|
||
else
|
||
{
|
||
#region 右键执行前调用Api接口
|
||
if (allowBefore)
|
||
{
|
||
ApiHelper apiHelper = new ApiHelper(Model.ModuleCode, model.Id, rowData);
|
||
apiHelper.OnEvent(Interface.Api.OperateEvent.BeforeModuleContextMenu, Interface.Api.ActionType.None);//添
|
||
if (!apiHelper.apiHandler.GetApiSuccess(apiHelper.apiHandlerModels))
|
||
{
|
||
MessageUtil.Show(ResourceKeys.OperFault + "\r\n" + apiHelper.apiResutMsg);
|
||
resultValue = false;
|
||
break;
|
||
}
|
||
}
|
||
#endregion
|
||
if (model.DuringExecutionMinimize) ERPInfo.Instance.MainControl.WindowState = FormWindowState.Minimized;
|
||
|
||
switch (model.ActionType)
|
||
{
|
||
case 1: // 执行存储过程
|
||
if (i == rows.Length - 1 || execOnlyOne)
|
||
{
|
||
//执行最后一条
|
||
FinallySucceeded = true;
|
||
}
|
||
resultValue = ExecProcedure(model, paramList, FinallySucceeded);
|
||
//resultValue = ExecProcedure(model, paramList, isFirstSuccess);
|
||
//isFirstSuccess = resultValue;
|
||
break;
|
||
case 2: // 调用dll程序
|
||
resultValue = ExecDynamicLinkLibary(model, paramList, dllName);
|
||
break;
|
||
case 3: //调用delphi程序
|
||
resultValue = ExecDelphiLibary(model.DllName, paramList);
|
||
//LogUtil.WriteDebug(model.MenuTabName, "打印", "右键打印:"+ model.MenuName, "打印格式:" + paramList[1]);
|
||
break;
|
||
case 4://调用主程序右键直接添加到page上
|
||
resultValue = ExecDynamicLinkLibary(model, paramList, dllName, true, rowData);
|
||
break;
|
||
case 5://执行存储过程获取下载url集合执行批量下载
|
||
resultValue = ExecDownloadFiles(model, paramList, rows);
|
||
break;
|
||
case 6://下载后打开文件
|
||
resultValue = OpenAfterDownloading(model, paramList);
|
||
break;
|
||
case 7://打开导入覆盖控件
|
||
resultValue = OpenFrmcCover(model, paramList);
|
||
break;
|
||
case 0: // 执行sql语句
|
||
resultValue = ExecSqlValue(model, rowData, actionSql);
|
||
break;
|
||
}
|
||
if (resultValue)
|
||
{
|
||
#region 右键执行成功调用Api接口
|
||
if (allowAfter)
|
||
{
|
||
ApiHelper apiHelper = new ApiHelper(Model.ModuleCode, model.Id, rowData);
|
||
apiHelper.OnEvent(Interface.Api.OperateEvent.AfterModuleContextMenu, Interface.Api.ActionType.None);
|
||
if (!apiHelper.apiHandler.GetApiSuccess(apiHelper.apiHandlerModels))
|
||
{
|
||
MessageUtil.Show(ResourceKeys.OperFault + "\r\n" + apiHelper.apiResutMsg);
|
||
resultValue = false;
|
||
break;
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
}
|
||
}
|
||
return resultValue;
|
||
}
|
||
|
||
|
||
//打开导入覆盖控件
|
||
public bool OpenFrmcCover(GridRightMenuModel model, List<string> paramList)
|
||
{
|
||
|
||
bool importIntoDatabase = false;
|
||
if (string.IsNullOrWhiteSpace(paramList[0]) || paramList[0] + "" == "0")
|
||
{
|
||
//模式1,把导入的数据反写到主界面上
|
||
if (string.IsNullOrWhiteSpace(paramList[1]) || string.IsNullOrWhiteSpace(paramList[2]))
|
||
{
|
||
MessageUtil.Show("模块编号或主键名称未配置");
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//模式2,保存到数据库中,在执行保存后sql
|
||
importIntoDatabase = true;
|
||
if (string.IsNullOrWhiteSpace(paramList[1]))
|
||
{
|
||
MessageUtil.Show("模块编号未配置");
|
||
return false;
|
||
}
|
||
}
|
||
|
||
|
||
string primaryKey = paramList[2];
|
||
FrmCover frmCover = new FrmCover(importIntoDatabase, paramList[1], paramList[2], paramList[3]);
|
||
if (frmCover.ShowDialog() == DialogResult.OK && !importIntoDatabase)
|
||
{
|
||
//反写数据源
|
||
DataTable ReverseData = frmCover.ReverseData;
|
||
//外部数据
|
||
DataTable table = GetDataTable();
|
||
|
||
// 2. 筛选出 ReverseData 和 table 中名称和数据类型都相同的列(排除主键列,避免重复赋值)
|
||
var commonColumns = ReverseData.Columns.Cast<DataColumn>()
|
||
.Where(col1 => col1.ColumnName != primaryKey // 跳过 id 列(无需更新)
|
||
&& table.Columns.Contains(col1.ColumnName) // 列名存在于 table2
|
||
)
|
||
.Select(col => col.ColumnName)
|
||
.ToList();
|
||
|
||
if (!commonColumns.Any())
|
||
{
|
||
// 没有可匹配的列,直接返回
|
||
return false;
|
||
}
|
||
|
||
// 3. 遍历 导入数据 的每一行,根据主键匹配 外部数据 的行并更新
|
||
foreach (DataRow row1 in ReverseData.Rows)
|
||
{
|
||
// 获取当前行的主键值
|
||
var idValue = row1[primaryKey];
|
||
if (idValue == DBNull.Value)
|
||
continue; // 跳过 id 为空的行
|
||
|
||
// 在 table2 中查找 id 匹配的行(使用 Select 方法快速定位)
|
||
DataRow[] matchedRows = table.Select($"" + primaryKey + " = '" + idValue + "'");
|
||
|
||
// 只处理找到唯一匹配行的情况
|
||
if (matchedRows.Length == 1)
|
||
{
|
||
DataRow row2 = matchedRows[0];
|
||
// 遍历所有相同列,将 反写数据源 的值赋给 外部数据源
|
||
foreach (string colName in commonColumns)
|
||
{
|
||
// 避免将 DBNull 赋值给不允许为空的列(可选处理)
|
||
if (row2[colName] != DBNull.Value || ReverseData.Columns[colName].AllowDBNull)
|
||
{
|
||
row2[colName] = row1[colName];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
return true;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 下载后打开程序
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public bool OpenAfterDownloading(GridRightMenuModel model, List<string> paramList)
|
||
{
|
||
try
|
||
{
|
||
string url = paramList[0];
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
//获取下载url
|
||
if (!url.StartsWith("http"))
|
||
{
|
||
string OAUrl = !string.IsNullOrEmpty(SystemInfo.Instance.OAUrl) && SystemInfo.Instance.OAUrl.EndsWith("/") ? SystemInfo.Instance.OAUrl : SystemInfo.Instance.OAUrl + "/";
|
||
url = OAUrl + url;
|
||
}
|
||
|
||
//获取下载的文件名
|
||
url = HttpUtility.UrlDecode(url);
|
||
url = url.Replace("%2f", "/");
|
||
url = url.Replace("#", "%23");
|
||
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];
|
||
//设置文件存放路径
|
||
string DownloadFileDirectory = string.Format("{0}\\{1}", Application.StartupPath, "RightDownloadFile");
|
||
if (!Directory.Exists(DownloadFileDirectory))
|
||
{
|
||
Directory.CreateDirectory(DownloadFileDirectory);
|
||
}
|
||
DownloadFileDirectory = string.Format("{0}\\{1}", DownloadFileDirectory, fileTitle);
|
||
|
||
FrmDownload frm = new FrmDownload(url, fileTitle, DownloadFileDirectory, true, false);
|
||
if (frm.ShowDialog() == DialogResult.OK)
|
||
{
|
||
return true;
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// <para>说明:执行存储过程</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-10-31 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="procName">Name of the proc.</param>
|
||
/// <param name="paramList">The parameter list.</param>
|
||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||
private bool ExecProcedure(GridRightMenuModel model, List<string> paramList, bool isFirstFlag = false, string comfirmFlag = "0")
|
||
{
|
||
string procName = model.Action;
|
||
if (string.IsNullOrWhiteSpace(procName))
|
||
{
|
||
MessageUtil.Show(ResourceKeys.NotFoundProcName);
|
||
return false;
|
||
}
|
||
else
|
||
{
|
||
bool reaultValue = true;
|
||
List<string> procParams = ReplaceHelper.GetParamFields(procName);
|
||
if (procParams.Count == 0)
|
||
{
|
||
MessageUtil.Show(ResourceKeys.ProcNameSettingFault);
|
||
return false;
|
||
}
|
||
|
||
string[] paramStr = procParams[0].Replace("{", "").Replace("}", "").Split(',');
|
||
|
||
List<SqlParameter> sqlParamList = new List<SqlParameter>();
|
||
SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
|
||
SqlParameter pComfirmFlag = new SqlParameter("@comfirmFlag", SqlDbType.Int);
|
||
for (int i = 0; i < paramStr.Length; i++)
|
||
{
|
||
string item = paramStr[i];
|
||
if (paramStr[i].Equals("@msg", StringComparison.OrdinalIgnoreCase))
|
||
{
|
||
pMsg.Direction = ParameterDirection.InputOutput;
|
||
pMsg.Value = string.IsNullOrEmpty(paramList[i]) ? "" : paramList[i];
|
||
sqlParamList.Add(pMsg);
|
||
}
|
||
else if (paramStr[i].Equals("@comfirmFlag", StringComparison.OrdinalIgnoreCase))
|
||
{
|
||
pComfirmFlag.Value = comfirmFlag;
|
||
sqlParamList.Add(pComfirmFlag);
|
||
}
|
||
else
|
||
{
|
||
string paramStr1 = paramStr[i];
|
||
SqlParameter param = new SqlParameter(string.Format("{0}", paramStr1), SqlDbType.VarChar);
|
||
param.Value = paramList[i];
|
||
sqlParamList.Add(param);
|
||
}
|
||
}
|
||
|
||
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
|
||
returnValue.Direction = ParameterDirection.ReturnValue;
|
||
int result;
|
||
sqlParamList.Add(returnValue);
|
||
|
||
try
|
||
{
|
||
|
||
if (model.PopupProgressBar)
|
||
{
|
||
frmProgressBar = new FrmProgressBar(procName.Replace(procParams[0], "").Trim(), sqlParamList.ToArray());
|
||
frmProgressBar.ShowDialog();
|
||
result = frmProgressBar.result;
|
||
}
|
||
else
|
||
{
|
||
result = MainImpl.ExecProcedure(procName.Replace(procParams[0], "").Trim(), sqlParamList.ToArray());
|
||
}
|
||
|
||
}
|
||
catch (SqlException sex)
|
||
{
|
||
string Message = ErrorMessage.PromptErrorMessage(sex);
|
||
MessageUtil.Show(Message, sex.Message);
|
||
return false;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
result = 0;
|
||
if (result == 0)
|
||
{
|
||
if (SqlHelper.ConnectionType == ConnectionType.SqlServer)
|
||
{
|
||
SqlStoredProcedurepPrompt.GenerateProcedureExecutionScript(procName, paramList, isFirstFlag, comfirmFlag);
|
||
}
|
||
if (SqlHelper.ConnectionType == ConnectionType.DmServer)
|
||
{
|
||
SqlStoredProcedurepPrompt.GenerateBillSaveScript_DM(SqlHelper.LastFailureSql);
|
||
}
|
||
}
|
||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||
MessageUtil.Show(Message, ex.Message);
|
||
return false;
|
||
}
|
||
finally
|
||
{
|
||
//if (model.PopupProgressBar) frmProgressBar.HideForm();
|
||
|
||
if (frmProgressBar != null)
|
||
{
|
||
frmProgressBar.Dispose();
|
||
}
|
||
|
||
}
|
||
|
||
int.TryParse(returnValue.Value + "", out int rValue);
|
||
|
||
switch (rValue)
|
||
{
|
||
case -1:
|
||
if (rValue == -1)
|
||
{
|
||
if (SqlHelper.ConnectionType == ConnectionType.SqlServer)
|
||
{
|
||
SqlStoredProcedurepPrompt.GenerateProcedureExecutionScript(procName, paramList, isFirstFlag, comfirmFlag);
|
||
}
|
||
if (SqlHelper.ConnectionType == ConnectionType.DmServer)
|
||
{
|
||
SqlStoredProcedurepPrompt.GenerateBillSaveScript_DM(SqlHelper.LastFailureSql);
|
||
}
|
||
}
|
||
MessageUtil.Show(string.IsNullOrEmpty(model.ErrorMsg) ? ResourceKeys.OperFault + "\n" + pMsg.Value : model.ErrorMsg);
|
||
reaultValue = false;
|
||
break;
|
||
case 9:
|
||
if (MessageUtil.Show(string.IsNullOrEmpty(model.ErrorMsg) ? ResourceKeys.OperFault + "\n" + pMsg.Value : model.ErrorMsg, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||
{
|
||
this.ExecProcedure(model, paramList, isFirstFlag, "1");
|
||
}
|
||
break;
|
||
case 99:
|
||
MessageUtil.Show(pMsg.Value + "");
|
||
break;
|
||
case 9999:
|
||
FrmPrompt frmPrompt = new FrmPrompt(pMsg.Value + "");
|
||
DialogResult dialogResult = frmPrompt.ShowDialog();
|
||
if (dialogResult == DialogResult.OK)
|
||
{
|
||
SqlParameter param = sqlParamList.FirstOrDefault(x => "@msg".Equals(x.ParameterName));
|
||
param.Value = frmPrompt.PromptMsg;
|
||
|
||
this.ExecProcedure(model, paramList);
|
||
}
|
||
break;
|
||
default:
|
||
if (isFirstFlag && model.SuccessfulPopup)
|
||
{
|
||
MessageUtil.Show(string.IsNullOrEmpty(model.SuccessMsg) ? ResourceKeys.OperSuccess : model.SuccessMsg);
|
||
}
|
||
break;
|
||
}
|
||
return reaultValue;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// <para>说明:执行sql语句</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-10-31 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sqlValue">The SQL value.</param>
|
||
/// <param name="rowData">The row data.</param>
|
||
private bool ExecSqlValue(GridRightMenuModel model, DataRow rowData, string actionSql)
|
||
{
|
||
|
||
string sqlValue = !string.IsNullOrEmpty(actionSql) ? actionSql : model.Action;
|
||
|
||
if (string.IsNullOrWhiteSpace(sqlValue))
|
||
{
|
||
MessageUtil.Show(ResourceKeys.NotFoundSQLName);
|
||
return false;
|
||
}
|
||
else
|
||
{
|
||
if (model.SqlDirectExecution)
|
||
{
|
||
sqlValue = ReplaceHelper.ReplaceRowParam(rowData, sqlValue);
|
||
if (this.ControlObj != null && sqlValue.Contains(ReplaceHelper.ReplaceParentLeftKey))
|
||
{
|
||
List<string> paramFields = ReplaceHelper.GetParamFields(sqlValue);
|
||
foreach (string item in paramFields)
|
||
{
|
||
string fieldValue = this.ControlObj.GetControlValue(item.Replace(ReplaceHelper.ReplaceParentLeftKey, "").Replace(ReplaceHelper.ReplaceParamEndKey, ""));
|
||
sqlValue = sqlValue.Replace(item, fieldValue);
|
||
}
|
||
}
|
||
int NumberOfImpacts = MainImpl.ExecSqlValue(sqlValue);
|
||
return NumberOfImpacts > 0;
|
||
}
|
||
else
|
||
{
|
||
|
||
// 将sql语句组装成Parameter方式,兼容配置语句.
|
||
List<SqlParameter> paramList = ReplaceHelper.ReplaceRowParamToSqlParameter(rowData, ref sqlValue);
|
||
|
||
if (this.ControlObj != null && sqlValue.Contains(ReplaceHelper.ReplaceParentLeftKey))
|
||
{
|
||
List<string> paramFields = ReplaceHelper.GetParamFields(sqlValue);
|
||
foreach (string item in paramFields)
|
||
{
|
||
string fieldValue = this.ControlObj.GetControlValue(item.Replace(ReplaceHelper.ReplaceParentLeftKey, "").Replace(ReplaceHelper.ReplaceParamEndKey, ""));
|
||
paramList.Add(new SqlParameter(ReplaceHelper.ProcFirstKey + item, fieldValue));
|
||
}
|
||
}
|
||
object text = MainImpl.GetResult(sqlValue, paramList.ToArray());
|
||
if (model.isCopy)
|
||
{
|
||
Clipboard.SetDataObject(text + "");
|
||
}
|
||
}
|
||
}
|
||
return true;
|
||
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:特殊dll模块处理</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-04-20 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="dllName">Name of the DLL.</param>
|
||
/// <returns>System.String.</returns>
|
||
private static string ReplaceDllFileName(string dllName)
|
||
{
|
||
switch (dllName.ToLower().Trim())
|
||
{
|
||
case "pubspec.dll":
|
||
dllName = "Lskj.PubSpec.dll";
|
||
break;
|
||
}
|
||
return dllName;
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:执行动态链接库</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-01 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||
private bool ExecDynamicLinkLibary(GridRightMenuModel model, List<string> paramList, string dllName, bool isAddPage = false, DataRow rowData = null)
|
||
{
|
||
if (string.IsNullOrWhiteSpace(dllName))
|
||
{
|
||
MessageUtil.Show(ResourceKeys.NotFoundLibrary);
|
||
return false;
|
||
}
|
||
else
|
||
{
|
||
switch (dllName.ToLower())
|
||
{
|
||
case "iexplore.exe": // 调用ie浏览器
|
||
string url = (paramList[0] + Uri.EscapeUriString(paramList[1])).Replace("#", "%23");
|
||
Process.Start("iexplore.exe", url);
|
||
break;
|
||
case "lstest.exe": // 调用附件下载
|
||
StringBuilder dfile = new StringBuilder();
|
||
StringBuilder rfile = new StringBuilder();
|
||
|
||
int hwnd = 0;
|
||
|
||
dfile.Append(paramList[0] + paramList[1]);
|
||
|
||
rfile = DelphiHelper.DownloadAttach(dfile, hwnd);
|
||
rfile.Clear();
|
||
string fileName = Path.GetFileName(dfile.ToString());
|
||
string filePath = PubUtil.FileDownLoadTempPath + Path.GetFileName(dfile.ToString());
|
||
rfile.Append(filePath);
|
||
//下载成功验证
|
||
PdfViewerHelper.VerifyDownLoadFinish(filePath, fileName);
|
||
if (File.Exists(rfile.ToString()))
|
||
{
|
||
Process.Start(rfile.ToString(), "");
|
||
}
|
||
break;
|
||
default:
|
||
string[] str = {
|
||
//Model.FormText,
|
||
model.MenuName,
|
||
ERPInfo.Instance.UserId,
|
||
ERPInfo.Instance.UserName,
|
||
"3",
|
||
Model.ModuleCode,
|
||
paramList[0],
|
||
paramList[1],
|
||
paramList[2],
|
||
paramList[3],
|
||
paramList[4],
|
||
paramList[5],
|
||
paramList[6],
|
||
paramList[7],
|
||
paramList[8],
|
||
paramList[9],
|
||
paramList[10],
|
||
paramList[11],
|
||
paramList[12],
|
||
paramList[13]//固定添加行数据json字符串
|
||
};
|
||
XtraTabPage xtraTab = ERPInfo.Instance.PageControl != null ? ERPInfo.Instance.PageControl.SelectedTabPage : null;
|
||
DllModule module = new DllModule
|
||
{
|
||
DllName = ReplaceDllFileName(dllName),
|
||
Id = model.MenuId + "",
|
||
Name = model.MenuName,
|
||
BeforePage = xtraTab
|
||
};
|
||
if (xtraTab != null)
|
||
{
|
||
if (SystemInfo.Instance.SoftOpenMode)
|
||
{
|
||
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
|
||
{
|
||
if (tablepage.Text == model.MenuName)
|
||
{
|
||
MessageUtil.Show("已设置不能打开多个相同模块!");
|
||
ERPInfo.Instance.PageControl.SelectedTabPage = tablepage;
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
bool isPrivateDll = false;
|
||
if (SystemInfo.Instance.IsDogVerify)
|
||
{
|
||
if (!CheckPrivateTable())
|
||
{
|
||
MessageUtil.Show("私密模块权限验证失败,请联系管理员");
|
||
return false;
|
||
}
|
||
DataTable privateDllTab = SqlHelper.ExecuteDataTable("select * from P_PrivateDllTab where privateTag=1");
|
||
string where = string.IsNullOrEmpty(ERPInfo.Instance.SeriesId) ? "" : string.Format("and SeriesId={0}", ERPInfo.Instance.SeriesId);
|
||
string sqlValue = string.Format("select top 1 MenuId from P_FormMenuConfigTab where UrlParams='{0}' and lower(DllFileName) not like '%accraditation%' and subsysid in (select SubSysId from P_SubSystemTab where UseEd=1 {1}) {1}", paramList[1], where);
|
||
string menuId = SqlHelper.ExecuteString("MenuId", sqlValue);
|
||
if (!string.IsNullOrEmpty(menuId) && privateDllTab.Select(string.Format("LMenuid='{0}'", menuId)).Count() > 0)
|
||
{
|
||
isPrivateDll = true;
|
||
int keyHandle = ERPInfo.Instance.keyHandles[0];
|
||
int uPin1 = Convert.ToInt32("0x987F6BCD", 16);
|
||
int uPin2 = Convert.ToInt32("0xE193C5B2", 16);
|
||
int uPin3 = Convert.ToInt32("0xD507CC28", 16);
|
||
int uPin4 = Convert.ToInt32("0x4B125AF6", 16);
|
||
int rtn = SmartX1Api.SmartX1Open(keyHandle, uPin1, uPin2, uPin3, uPin4);
|
||
if (rtn == 0)
|
||
{
|
||
//U盾密码验证
|
||
if (ERPInfo.Instance.isDogVerifyPassword)
|
||
{
|
||
FrmVerify frmVerify = new FrmVerify();
|
||
DialogResult dialogResult = frmVerify.ShowDialog();
|
||
if (dialogResult != DialogResult.OK)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
byte[] buffer = new byte[4096];
|
||
int nrtn = SmartX1Api.SmartX1ReadStorage(keyHandle, 0, 4096, buffer);
|
||
if (nrtn == 0)
|
||
{
|
||
string writeKey = string.Format("{0}_{1}", DBConfig.Instance.ServerName, DBConfig.Instance.DataBase);
|
||
Dictionary<string, string> readKeysValues = new Dictionary<string, string>();
|
||
string verifyStr = Encoding.Default.GetString(buffer);
|
||
string[] readVerifyStrArray = verifyStr.Replace("\0", "").Split(';');
|
||
foreach (string readVerify in readVerifyStrArray)
|
||
{
|
||
string[] readKeyValue = readVerify.Split('^');//获取单个账套
|
||
if (readKeyValue.Length == 2)
|
||
{
|
||
readKeysValues.Add(readKeyValue[0], readKeyValue[1]);
|
||
}
|
||
}
|
||
if (readKeysValues.ContainsKey(writeKey))
|
||
{
|
||
string[] verifyArray = readKeysValues[writeKey].Split(',');
|
||
if (!verifyArray.Contains(menuId))
|
||
{
|
||
MessageUtil.Show("未拥有当前模块查看权限");
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
MessageUtil.Show("未拥有当前模块查看权限");
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
MessageUtil.Show("U盾数据获取失败,请重试或联系管理员");
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
MessageUtil.Show("U盾验证失败,请重试或联系管理员");
|
||
return false;
|
||
}
|
||
SmartX1Api.SmartX1Close(keyHandle);
|
||
}
|
||
}
|
||
IForm form = FormHelper.LoadDllForm(dllName, str);
|
||
if (form == null)
|
||
{
|
||
MessageUtil.Show(ResourceKeys.DyncmicDllNotFount);
|
||
return false;
|
||
}
|
||
if (form.SubForm == null)
|
||
{
|
||
MessageUtil.Show(ResourceKeys.DyncmicDllInitFault);
|
||
return false;
|
||
}
|
||
if (!isAddPage)
|
||
{
|
||
form.SubForm.WindowState = model.MaxWindow ? FormWindowState.Maximized : FormWindowState.Normal;
|
||
form.SubForm.FormBorderStyle = model.NoonWindow ? FormBorderStyle.None : form.SubForm.WindowState == FormWindowState.Maximized ? FormBorderStyle.Sizable : FormBorderStyle.FixedSingle;
|
||
|
||
// 获取屏幕对象,如果宽高超过就设置为屏幕宽高
|
||
Screen primaryScreen = Screen.PrimaryScreen;
|
||
if (form.SubForm.Width > primaryScreen.WorkingArea.Width) form.SubForm.Width = primaryScreen.WorkingArea.Width;
|
||
if (form.SubForm.Height > primaryScreen.WorkingArea.Height) form.SubForm.Height = primaryScreen.WorkingArea.Height;
|
||
|
||
|
||
form.SubForm.StartPosition = FormStartPosition.CenterScreen;
|
||
form.SubForm.Text = model.MenuName;
|
||
if (isPrivateDll)
|
||
{
|
||
StaticControl.DogVerifyNoPageForms.Add(form);
|
||
}
|
||
if (form.SubForm is BaseForm)//dllName.Equals("Lskj.BaseAccraditation.dll", StringComparison.OrdinalIgnoreCase)
|
||
{
|
||
BaseForm baseForm = form.SubForm as BaseForm;
|
||
baseForm.SetFormSize();
|
||
}
|
||
if (form.SubForm is BaseForm)
|
||
{
|
||
(form.SubForm as BaseForm).ParentView = this.BaseGridView;
|
||
}
|
||
//判断是否关闭,如果已经关闭的模块就不ShowDialog了。(浏览器配置右键直接下载,浏览器dll会在打开下载模块前关闭)
|
||
if (!form.SubForm.IsDisposed)
|
||
{
|
||
if (model.IsModal)
|
||
{
|
||
form.SubForm.Show();
|
||
}
|
||
else
|
||
{
|
||
form.SubForm.ShowDialog();
|
||
StaticControl.DogVerifyNoPageForms.Remove(form);
|
||
form.SubForm.Dispose();
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
string guid = Guid.NewGuid().ToString();
|
||
XtraTabPage tp = new XtraTabPage();
|
||
tp.Text = model.MenuName;
|
||
|
||
if (!string.IsNullOrWhiteSpace(model.PageName))
|
||
{
|
||
tp.Text = ReplaceHelper.ReplaceRowParam(rowData, model.PageName).Trim();
|
||
}
|
||
|
||
tp.Tag = guid;
|
||
// 这个必须有不然会提示:"不能向tabControl中添加顶级控件"
|
||
form.SubForm.TopLevel = false;
|
||
form.SubForm.Location = new Point(0, 0);
|
||
form.SubForm.Dock = DockStyle.Fill;
|
||
form.SubForm.FormBorderStyle = FormBorderStyle.None;
|
||
tp.AutoScroll = true;
|
||
tp.Controls.Add(form.SubForm);
|
||
tp.ShowCloseButton = DefaultBoolean.True;
|
||
tp.Dock = DockStyle.Fill;
|
||
//配置了右键刷新的情况下,在当前页签关闭时触发刷新
|
||
if (model.Refresh && this.OnRightCallback != null)
|
||
{
|
||
tp.Disposed += new EventHandler(OnTp_Disposed);
|
||
}
|
||
ERPInfo.Instance.PageControl.TabPages.Add(tp);
|
||
ERPInfo.Instance.PageControl.SelectedTabPage = tp;
|
||
if (isPrivateDll)
|
||
{
|
||
StaticControl.DogVerifyModuleForms.Add(tp);
|
||
}
|
||
if (form.SubForm is BaseForm)
|
||
{
|
||
(form.SubForm as BaseForm).ParentView = this.BaseGridView;
|
||
}
|
||
form.SubForm.Show();
|
||
ERPInfo.Instance.ModuleForms.Add(guid, module);
|
||
//直接页签打开模块会直接向后面运行,默认返回false避免外面执行右键刷新
|
||
return false;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:执行动态链接库</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-01 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||
private bool ExecDownloadFiles(GridRightMenuModel model, List<string> paramList, DataRow[] rows, string comfirmFlag = "0")
|
||
{
|
||
bool reaultValue = true;
|
||
string procName = model.Action;
|
||
if (string.IsNullOrWhiteSpace(procName))
|
||
{
|
||
if (rows.Length > 0 && !string.IsNullOrWhiteSpace(Model.ModuleCode))
|
||
{
|
||
int filequency = 0;
|
||
bool isOpenvisble = rows.Count() > 0;
|
||
string parmaryKey = BaseImpl.GetBasePrimaryKey(this.Model.ModuleCode);//获取主键
|
||
//string detailparmaryKey = parmaryKey;
|
||
List<GridDetailModel> details = GetDetails(Model.ModuleCode);//捕获所有明细 // 2. 筛选出 “关联下载” 的明细
|
||
List<GridDetailModel> downloadRelated = details
|
||
.Where(d => d.IsDownloadRelated) // 只保留 IsDownloadRelated 为 true 的项
|
||
.ToList();
|
||
if (downloadRelated.Count > 0)
|
||
{
|
||
foreach (DataRow dataRow in rows)
|
||
{
|
||
StringBuilder urlsBuilder = new StringBuilder();
|
||
string filenameheader = dataRow[parmaryKey] + "";//头部文件数据
|
||
foreach (GridDetailModel gridDetailModel in downloadRelated)
|
||
{
|
||
//detailparmaryKey = BaseImpl.GetBasePrimaryKey(gridDetailModel.UnionModule);//获取主键
|
||
string searchSql = this.GetSearchSql(gridDetailModel, dataRow, parmaryKey);
|
||
DataTable dataTable = SqlHelper.ExecuteDataTable(searchSql);
|
||
if (dataTable.Rows.Count > 0 && dataTable.Columns.Contains("webpath"))
|
||
{
|
||
foreach (DataRow row in dataTable.Rows)
|
||
{
|
||
|
||
string url = row["webpath"] + "";
|
||
if (!string.IsNullOrEmpty(url))
|
||
{
|
||
urlsBuilder.Append($"{url},");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
try
|
||
{
|
||
string urls = urlsBuilder.ToString().TrimEnd(',');
|
||
string idvalue = parmaryKey;
|
||
//string fileDownTitle = rows[0].Table.Columns.Contains("fileTitle") ? rows[0]["fileTitle"] + "" : "";
|
||
if (!string.IsNullOrWhiteSpace(urls))
|
||
{
|
||
string token = "";
|
||
string loginUrl = $"{SystemInfo.Instance.OAUrl}/Api/SysUserAjaxApi.ashx";
|
||
HttpTools.setting("application/x-www-form-urlencoded", null, null, HttpTools.Encode.UTF8);
|
||
Dictionary<string, string> loginPmsDic = new Dictionary<string, string>();
|
||
loginPmsDic.Add("method", "Login");
|
||
loginPmsDic.Add("username", ERPInfo.Instance.UserName);
|
||
loginPmsDic.Add("password", ERPInfo.Instance.InPassWord);
|
||
HttpWebResponse loginResponse = HttpTools.Post(loginUrl, "", loginPmsDic, HttpTools.Method.POST, out CookieCollection loginCookie, out string loginResult);
|
||
if (loginResponse != null && !string.IsNullOrEmpty(loginResult))
|
||
{
|
||
JObject jObject = JsonConvert.DeserializeObject<JObject>(loginResult);
|
||
if (jObject.ContainsKey("success"))
|
||
{
|
||
if ((jObject["success"] + "").Equals("True"))
|
||
{
|
||
if (jObject.ContainsKey("token"))
|
||
{
|
||
token = jObject["token"] + "";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(token))
|
||
{
|
||
string downUrl = string.Format("{0}Api/FileUploadApi.ashx", SystemInfo.Instance.OAUrl);
|
||
Dictionary<string, string> parmarsDic = new Dictionary<string, string>();
|
||
parmarsDic.Add("userid", HttpUtility.UrlEncode(ERPInfo.Instance.UserId));
|
||
parmarsDic.Add("username", HttpUtility.UrlEncode(ERPInfo.Instance.UserName));
|
||
parmarsDic.Add("password", HttpUtility.UrlEncode(ERPInfo.Instance.InPassWord));
|
||
parmarsDic.Add("method", HttpUtility.UrlEncode("DownLoadFiels"));
|
||
parmarsDic.Add("urls", HttpUtility.UrlEncode(urls));
|
||
parmarsDic.Add("moduleid", HttpUtility.UrlEncode(model.MenuTabName));
|
||
parmarsDic.Add("idvalue", HttpUtility.UrlEncode(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();
|
||
if (filequency > 0) frmSelectDownload.isMultiple = true;
|
||
frmSelectDownload.isprompt = filequency + 1 == rows.Count();
|
||
frmSelectDownload.URL = downLoadUrl;
|
||
frmSelectDownload.isOpenvisble = isOpenvisble;
|
||
frmSelectDownload.ModelId = model.MenuTabName;
|
||
frmSelectDownload.MenuName = model.MenuName;
|
||
frmSelectDownload.MenuId = model.Id + "";
|
||
string[] szName = zipPathUrl.Split('/');
|
||
string fileTitle = !string.IsNullOrWhiteSpace(filenameheader) ? filenameheader + ".zip" : szName[szName.Length - 1];
|
||
frmSelectDownload.FileName = fileTitle;
|
||
//frmSelectDownload.TopMost = true;
|
||
frmSelectDownload.ShowDialog();
|
||
}
|
||
else
|
||
{
|
||
MessageUtil.Show(jsonObject["msg"] + "");
|
||
}
|
||
}
|
||
response.GetResponseStream().Close();
|
||
response.Close();
|
||
}
|
||
else
|
||
{
|
||
MessageUtil.Show($"登录验证失败\r\n{loginResult}");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
MessageUtil.Show("操作失败,未查询到数据");
|
||
}
|
||
}
|
||
catch (SqlException ex)
|
||
{
|
||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||
MessageUtil.Show(Message, ex.Message);
|
||
return false;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageUtil.Show(ex.Message);
|
||
}
|
||
filequency++;
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
MessageUtil.Show("未配置关联明细数据");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
|
||
MessageUtil.Show("没有需要下载的数据");
|
||
}
|
||
return reaultValue;
|
||
}
|
||
else
|
||
{
|
||
int filequency = 0;
|
||
bool isOpenvisble = rows.Count() > 0;
|
||
foreach (DataRow dataRow in rows)
|
||
{
|
||
if (filequency > 0 && model.Mergeexec) continue;
|
||
List<string> procParams = ReplaceHelper.GetParamFields(procName);
|
||
if (procParams.Count == 0)
|
||
{
|
||
MessageUtil.Show(ResourceKeys.ProcNameSettingFault);
|
||
return false;
|
||
}
|
||
string[] paramStr = procParams[0].Replace("{", "").Replace("}", "").Split(',');
|
||
List<SqlParameter> sqlParamList = new List<SqlParameter>();
|
||
SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
|
||
SqlParameter pComfirmFlag = new SqlParameter("@comfirmFlag", SqlDbType.Int);
|
||
paramList = model.Mergeexec ? paramList : this.HandleRightMenuParams(model.ParamList, dataRow, null, model.ActionType);
|
||
for (int i = 0; i < paramStr.Length; i++)
|
||
{
|
||
string item = paramStr[i];
|
||
if (paramStr[i].Equals("@msg", StringComparison.OrdinalIgnoreCase))
|
||
{
|
||
pMsg.Direction = ParameterDirection.InputOutput;
|
||
pMsg.Value = string.IsNullOrEmpty(paramList[i]) ? "" : paramList[i];
|
||
sqlParamList.Add(pMsg);
|
||
}
|
||
else if (paramStr[i].Equals("@comfirmFlag", StringComparison.OrdinalIgnoreCase))
|
||
{
|
||
pComfirmFlag.Value = comfirmFlag;
|
||
sqlParamList.Add(pComfirmFlag);
|
||
}
|
||
else
|
||
{
|
||
string paramStr1 = paramStr[i];
|
||
SqlParameter param = new SqlParameter(string.Format("{0}", paramStr1), SqlDbType.VarChar);
|
||
param.Value = paramList[i];
|
||
sqlParamList.Add(param);
|
||
}
|
||
}
|
||
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
|
||
returnValue.Direction = ParameterDirection.ReturnValue;
|
||
sqlParamList.Add(returnValue);
|
||
try
|
||
{
|
||
DataSet dataSet = SqlHelper.ExecuteDataSet(4, procName.Replace(procParams[0], "").Trim(), "temp", sqlParamList.ToArray());
|
||
DataTable dataTable = dataSet.Tables[0];
|
||
string urls = dataTable != null && dataTable.Rows.Count > 0 && dataTable.Columns.Contains("webpath") ? dataTable.Rows[0]["webpath"] + "" : "";
|
||
string idvalue = dataTable != null && dataTable.Rows.Count > 0 && dataTable.Columns.Contains("keyvalue") ? dataTable.Rows[0]["keyvalue"] + "" : "";
|
||
string fileDownTitle = dataTable != null && dataTable.Rows.Count > 0 && dataTable.Columns.Contains("fileTitle") ? dataTable.Rows[0]["fileTitle"] + "" : "";
|
||
if (!string.IsNullOrWhiteSpace(urls))
|
||
{
|
||
string token = "";
|
||
string loginUrl = $"{SystemInfo.Instance.OAUrl}/Api/SysUserAjaxApi.ashx";
|
||
HttpTools.setting("application/x-www-form-urlencoded", null, null, HttpTools.Encode.UTF8);
|
||
Dictionary<string, string> loginPmsDic = new Dictionary<string, string>();
|
||
loginPmsDic.Add("method", "Login");
|
||
loginPmsDic.Add("username", ERPInfo.Instance.UserName);
|
||
loginPmsDic.Add("password", ERPInfo.Instance.InPassWord);
|
||
HttpWebResponse loginResponse = HttpTools.Post(loginUrl, "", loginPmsDic, HttpTools.Method.POST, out CookieCollection loginCookie, out string loginResult);
|
||
if (loginResponse != null && !string.IsNullOrEmpty(loginResult))
|
||
{
|
||
JObject jObject = JsonConvert.DeserializeObject<JObject>(loginResult);
|
||
if (jObject.ContainsKey("success"))
|
||
{
|
||
if ((jObject["success"] + "").Equals("True"))
|
||
{
|
||
if (jObject.ContainsKey("token"))
|
||
{
|
||
token = jObject["token"] + "";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(token))
|
||
{
|
||
string downUrl = string.Format("{0}Api/FileUploadApi.ashx", SystemInfo.Instance.OAUrl);
|
||
Dictionary<string, string> parmarsDic = new Dictionary<string, string>();
|
||
parmarsDic.Add("userid", HttpUtility.UrlEncode(ERPInfo.Instance.UserId));
|
||
parmarsDic.Add("username", HttpUtility.UrlEncode(ERPInfo.Instance.UserName));
|
||
parmarsDic.Add("password", HttpUtility.UrlEncode(ERPInfo.Instance.InPassWord));
|
||
parmarsDic.Add("method", HttpUtility.UrlEncode("DownLoadFiels"));
|
||
parmarsDic.Add("urls", HttpUtility.UrlEncode(urls));
|
||
parmarsDic.Add("moduleid", HttpUtility.UrlEncode(model.MenuTabName));
|
||
parmarsDic.Add("idvalue", HttpUtility.UrlEncode(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();
|
||
if (filequency > 0) frmSelectDownload.isMultiple = true;
|
||
frmSelectDownload.isprompt = filequency + 1 == rows.Count();
|
||
frmSelectDownload.URL = downLoadUrl;
|
||
frmSelectDownload.isOpenvisble = isOpenvisble;
|
||
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.ShowDialog();
|
||
}
|
||
else
|
||
{
|
||
MessageUtil.Show(jsonObject["msg"] + "");
|
||
}
|
||
}
|
||
response.GetResponseStream().Close();
|
||
response.Close();
|
||
}
|
||
else
|
||
{
|
||
MessageUtil.Show($"登录验证失败\r\n{loginResult}");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
MessageUtil.Show("操作失败,未查询到数据");
|
||
}
|
||
}
|
||
catch (SqlException ex)
|
||
{
|
||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||
MessageUtil.Show(Message, ex.Message);
|
||
return false;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageUtil.Show(ex.Message);
|
||
}
|
||
filequency++;
|
||
}
|
||
return reaultValue;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:获取查询条件</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-22 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="model">The model.</param>
|
||
/// <param name="rowItem">The row item.</param>
|
||
/// <returns>System.String.</returns>
|
||
protected string GetSearchSql(GridDetailModel model, DataRow rowItem, string ParmaryKey)
|
||
{
|
||
string fieldName = !string.IsNullOrEmpty(model.UnionParentField) && rowItem.Table.Columns.Contains(model.UnionParentField) ? model.UnionParentField : ParmaryKey;
|
||
string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql;
|
||
|
||
|
||
sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
|
||
|
||
if (ReplaceHelper.IsSelect(sqlValue) && !string.IsNullOrEmpty(model.UnionValue))
|
||
{
|
||
string Conditions = string.Empty;
|
||
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue) + string.Format(" and {0}='{1}'", model.UnionValue, Conditions);
|
||
}
|
||
if (!string.IsNullOrEmpty(model.UnionCond))
|
||
{
|
||
string UnionCond = ReplaceHelper.ReplaceRowParam(rowItem, model.UnionCond);
|
||
sqlValue += UnionCond;
|
||
}
|
||
return sqlValue;
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:右键捕获明细</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-21 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <returns>List<GridDetailModel>.</returns>
|
||
private List<GridDetailModel> GetDetails(string ModuleCode)
|
||
{
|
||
List<GridDetailModel> details = new List<GridDetailModel>();//表格明细对象的集合
|
||
DataTable table = BaseModuleImpl.GetBaseDetailPages(ModuleCode);// 根据传入的模块编号获得基础档案底部标签的数据
|
||
foreach (DataRow item in table.Rows)
|
||
{
|
||
DataTable gridColumns = ReportImpl.GetReportDetailColumns(ModuleCode, item["id"] + "");//获取报表明细列
|
||
details.Add(new GridDetailModel(item, gridColumns, GridCustomColumnStruct.BaseDetailGridView));
|
||
}
|
||
return details;
|
||
}
|
||
/// <summary>
|
||
/// 调用主程序右键直接添加到page上页面自动关闭后执行刷新
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void OnTp_Disposed(object sender, EventArgs e)
|
||
{
|
||
this.OnRightCallback(sender, e);
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-01 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="libaryName">Name of the libary.</param>
|
||
/// <param name="paramList">The parameter list.</param>
|
||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||
private bool ExecDelphiLibary(string libaryName, List<string> paramList)
|
||
{
|
||
Console.WriteLine(DateTime.Now);
|
||
DelphiHelper.LoadDelphiDll(PubUtil.AbsolutelyPath + libaryName, paramList[0], paramList[1], paramList[2], paramList[3], Convert.ToInt32(paramList[4]), paramList[5]);
|
||
return true;
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:多选右键调用只执行一次处理(例如多选右键调用单据)</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-05-31 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="model">The model.</param>
|
||
/// <returns><c>true</c> if [is execute bill only one] [the specified model]; otherwise, <c>false</c>.</returns>
|
||
protected virtual bool IsExecOnlyOne(GridRightMenuModel model, List<string> paramList, DataRow[] rows, out String actionSql)
|
||
{
|
||
actionSql = string.Empty;
|
||
if (model == null) return false;
|
||
// 右键调用Lskj.PubBill.dll、Lskj.PubBillBrp,并且为多选新增,则汇总明细数据且只执行一次.
|
||
bool isOnlyOne = (model.DllName.Equals("lskj.pubbill.dll", StringComparison.OrdinalIgnoreCase) ||
|
||
model.DllName.Equals("lskj.pubbillbrp.dll", StringComparison.OrdinalIgnoreCase)) &&
|
||
!string.IsNullOrEmpty(model.DllParam8) && !string.IsNullOrEmpty(model.DllParam9) && model.Mergeexec;
|
||
if (isOnlyOne)
|
||
{
|
||
string fieldValue = paramList[8];
|
||
paramList[8] = ReplaceHelper.ReplaceRowParam(rows, fieldValue);
|
||
}
|
||
if (model.Mergeexec)//合并执行
|
||
{
|
||
if (model.ActionType == 0)
|
||
{
|
||
actionSql = ReplaceHelper.ReplaceRowParam(rows, model.Action, "'", "'");
|
||
}
|
||
|
||
if (model.DllName.ToLower().Contains("lskj.pubbrower.dll".ToLower()))
|
||
{
|
||
string url = paramList[2];
|
||
string start = "", end = "";
|
||
|
||
if (rows != null && rows.Length > 0)
|
||
{
|
||
paramList[2] = ReplaceHelper.ReplaceRowParam(rows, url, start, end) + "";
|
||
}
|
||
else
|
||
{
|
||
paramList[2] = ReplaceHelper.ReplaceRowParam(rows, url) + "";
|
||
}
|
||
}
|
||
if (model.DllName.ToLower().Contains("p_PubPrint.lsp".ToLower())&& !model.CancelDefaultReplace)
|
||
{
|
||
string paramsql1 = paramList[2];
|
||
paramList[2] = ReplaceHelper.ReplaceRowParam(rows, paramsql1, "'", "'");
|
||
string paramsql2 = paramList[3];
|
||
paramList[3] = ReplaceHelper.ReplaceRowParam(rows, paramsql2, "'", "'");
|
||
string paramsql3 = paramList[4];
|
||
paramList[4] = ReplaceHelper.ReplaceRowParam(rows, paramsql3, "'", "'");
|
||
}
|
||
else if (model.DllName.ToLower().Contains("Lskj.FastReportDesign.dll".ToLower()))
|
||
{
|
||
string paramsql1 = paramList[1];
|
||
paramList[1] = ReplaceHelper.ReplaceRowParam(rows, paramsql1);
|
||
}
|
||
else if (model.DllName.ToLower().Contains("Lskj.AutoCreatWord.dll".ToLower()))
|
||
{
|
||
if ((paramList[4] + "").Equals("1"))
|
||
{
|
||
string paramsql1 = paramList[3];
|
||
foreach (DataRow row in rows)
|
||
{
|
||
paramsql1 += $"{ReplaceHelper.ReplaceRowParam(row, paramList[3])}^";
|
||
}
|
||
paramList[3] = paramsql1;
|
||
}
|
||
else
|
||
{
|
||
string paramsql1 = paramList[3];
|
||
paramList[3] = ReplaceHelper.ReplaceRowParam(rows, paramsql1, "'", "'");
|
||
}
|
||
}
|
||
else if (model.DllName.ToLower().Contains("Lskj.PubArgoxPrint.dll".ToLower()))
|
||
{
|
||
string mainsql = paramList[2];
|
||
paramList[2] = ReplaceHelper.ReplaceRowParam(rows, mainsql, "'", "'");
|
||
string aftersql = paramList[3];
|
||
paramList[3] = ReplaceHelper.ReplaceRowParam(rows, aftersql, "'", "'");
|
||
}
|
||
else if (model.ActionType == 5)//批量下载
|
||
{
|
||
string modelAction = model.Action;
|
||
if (!string.IsNullOrEmpty(modelAction))
|
||
{
|
||
List<string> procParams = ReplaceHelper.GetParamFields(modelAction);
|
||
string[] paramStr = procParams[0].Replace("{", "").Replace("}", "").Split(',');
|
||
if (paramStr.Contains("@keyvalue"))
|
||
{
|
||
int index = Array.FindIndex(paramStr, new Predicate<string>(str =>
|
||
{
|
||
return str.Equals("@keyvalue");
|
||
}));
|
||
|
||
string fieldValue = paramList[index];
|
||
paramList[index] = ReplaceHelper.ReplaceRowParamSplit(rows, fieldValue, "", "", ';');
|
||
}
|
||
}
|
||
}
|
||
isOnlyOne = true;
|
||
}
|
||
isOnlyOne = model.ActionType == 5 ? true : isOnlyOne;//批量下载默认只循环一次
|
||
return isOnlyOne;
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:获取选中数据行</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-01-29 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <returns>DataRow[].</returns>
|
||
protected virtual DataRow[] GetSelectedRows()
|
||
{
|
||
return null;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取外面的数据源
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
protected virtual DataTable GetDataTable()
|
||
{
|
||
return null;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// <para>说明:处理右键菜单10个扩展参数</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-10-30 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="paramList">The parameter list.</param>
|
||
protected virtual List<string> HandleRightMenuParams(List<string> paramList, DataRow rowData, DataRow[] rowDatas = null, int actiontype = 0)
|
||
{
|
||
List<string> handleParamList = new List<string>();
|
||
foreach (string item in paramList)
|
||
{
|
||
if (!string.IsNullOrWhiteSpace(item))
|
||
{
|
||
string fieldValue = ReplaceHelper.ReplaceUserInfo(item);
|
||
fieldValue = RaiseBeforeHandleParamsCallback(paramList, rowDatas, item, rowData, fieldValue);
|
||
if (!string.IsNullOrWhiteSpace(fieldValue) && fieldValue.TrimStart().StartsWith("MergeExec_", StringComparison.OrdinalIgnoreCase))
|
||
{
|
||
fieldValue = ReplaceHelper.ReplaceRowParam(rowDatas, fieldValue.Replace("MergeExec_", "", true));
|
||
}
|
||
//if (this.ControlObj != null)
|
||
//{
|
||
// fieldValue = this.ControlObj.ReplaceParentControlValue(fieldValue);
|
||
//}
|
||
if (fieldValue.Contains("{COLUMN_"))
|
||
{
|
||
if (this.BaseGridView != null)
|
||
{
|
||
GridCell[] cells = this.BaseGridView.GetSelectedCells();
|
||
if (cells != null && cells.Length > 0)
|
||
{
|
||
GridCell cell = cells[0];
|
||
DataRow focusedRow = this.BaseGridView.GetFocusedDataRow();
|
||
string colValue = focusedRow == null || !focusedRow.Table.Columns.Contains(cell.Column.Name) ? "" : focusedRow[cell.Column.Name] + "";
|
||
fieldValue = fieldValue.ReplaceColumnParam(cell.Column.Name, cell.Column.Caption, colValue);
|
||
}
|
||
}
|
||
}
|
||
|
||
string firstChar = fieldValue.Length > 0 ? fieldValue.Substring(0, 1) : "";
|
||
switch (firstChar)
|
||
{
|
||
case "@": // sql处理
|
||
{
|
||
string value = MainImpl.GetResult(ReplaceHelper.ReplaceRowParam(rowData, fieldValue.Replace("@", ""))) + "";
|
||
handleParamList.Add(value);
|
||
}
|
||
break;
|
||
case "#": // 需要传入的sql语句
|
||
if (rowDatas == null)
|
||
{
|
||
handleParamList.Add(ReplaceHelper.ReplaceRowParam(rowData, fieldValue.Replace("#", "")) + "");
|
||
}
|
||
else
|
||
{
|
||
//多条合并执行时替换参数
|
||
//先替换{},替换的是选中行的数据
|
||
fieldValue = ReplaceHelper.ReplaceRowParam(rowData, fieldValue.Replace("#", ""));
|
||
//替换[],替换的是多选行中的数据
|
||
fieldValue = ReplaceHelper.ReplaceRowParam(rowDatas, fieldValue.Replace("[", "{").Replace("]", "}"), "", "");
|
||
|
||
//如果是sql的情况,可能有 select '[xx]' as xxx 和 where xx in([xxx]) 的情况,start和end不好统一设置,先默认为空
|
||
//ReplaceHelper.ReplaceMultipleLinesParam (rowData, fieldValue); 区分了2种情况
|
||
|
||
handleParamList.Add(fieldValue);
|
||
}
|
||
break;
|
||
case "[": //[FormTitle_格式数据
|
||
if (fieldValue.StartsWith("[FormTitle_"))
|
||
{
|
||
handleParamList.Add(ReplaceHelper.ReplaceRowParam(rowData, fieldValue.Replace("[FormTitle_", "")) + "");
|
||
}
|
||
else if (fieldValue.StartsWith("[Data_"))
|
||
{
|
||
DataTable dataTable = BaseGridView.GetGridViewFilteredAndSortedDataToDataTable();
|
||
string jsonStr = JsonConvert.SerializeObject(dataTable);
|
||
handleParamList.Add(jsonStr);
|
||
}
|
||
else if (fieldValue.StartsWith("[Details|"))
|
||
{
|
||
string TagName = fieldValue.Replace("[Details|", "").Replace("]", "");
|
||
fieldValue = "";
|
||
if (this.ControlObj != null && this.ControlObj.DetailSelection.ContainsKey(TagName))
|
||
{
|
||
Dictionary<DataRow, string> dictionary = this.ControlObj.DetailSelection[TagName];
|
||
if (rowDatas != null)
|
||
{
|
||
foreach (DataRow row in rowDatas)
|
||
{
|
||
if (dictionary.ContainsKey(row) && !string.IsNullOrWhiteSpace(dictionary[row]))
|
||
{
|
||
fieldValue += dictionary[row] + ",";
|
||
}
|
||
}
|
||
fieldValue = fieldValue.Trim(',');
|
||
}
|
||
else
|
||
{
|
||
if (dictionary.ContainsKey(rowData))
|
||
{
|
||
fieldValue = dictionary[rowData];
|
||
}
|
||
|
||
}
|
||
}
|
||
handleParamList.Add(fieldValue);
|
||
}
|
||
else
|
||
{
|
||
fieldValue = fieldValue.Replace("[", "{").Replace("]", "}");
|
||
string start = "'", end = "'";
|
||
if (actiontype == 1)
|
||
{
|
||
start = end = string.Empty;
|
||
}
|
||
if (rowDatas != null)
|
||
{
|
||
handleParamList.Add(ReplaceHelper.ReplaceRowParam(rowDatas, fieldValue, start, end) + "");
|
||
}
|
||
else
|
||
{
|
||
handleParamList.Add(ReplaceHelper.ReplaceRowParam(rowData, fieldValue) + "");
|
||
}
|
||
}
|
||
break;
|
||
case "$": //传入参数不需要任何处理
|
||
handleParamList.Add(fieldValue.Replace("$", "") + "");
|
||
break;
|
||
default:
|
||
fieldValue = ReplaceHelper.ReplaceRowParam(rowData, fieldValue) + "";
|
||
if (this.ControlObj != null)
|
||
{
|
||
fieldValue = this.ControlObj.ReplaceParentControlValue(fieldValue);
|
||
}
|
||
handleParamList.Add(fieldValue);
|
||
break;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
handleParamList.Add(item);
|
||
}
|
||
}
|
||
|
||
return handleParamList;
|
||
}
|
||
/// <summary>
|
||
/// 判断私有模块权限表格是否存在
|
||
/// </summary>
|
||
private static bool CheckPrivateTable()
|
||
{
|
||
try
|
||
{
|
||
//日志表列名
|
||
Dictionary<string, string> colDic = new Dictionary<string, string>();
|
||
colDic.Add("ObjDll", "varchar(1000)");
|
||
colDic.Add("DllShowCaption", "varchar(1000)");
|
||
colDic.Add("LMenuid", "int");
|
||
colDic.Add("Lsubsysid", "int");
|
||
colDic.Add("PrivateTag", "int");
|
||
string isExitApiTab = "select top 1 * from sysObjects where Id=OBJECT_ID(N'P_PrivateDllTab') and xtype='U'";
|
||
DataTable apiTab = SqlHelper.ExecuteDataTable(isExitApiTab);
|
||
if (apiTab.Rows.Count > 0)//存在日志表
|
||
{
|
||
DataTable columnsTab = SqlHelper.ExecuteDataTable(string.Format("select name from syscolumns where id=object_id('P_PrivateDllTab')"));
|
||
foreach (KeyValuePair<string, string> colunmField in colDic)
|
||
{
|
||
DataRow[] dataRows = columnsTab.Select().Where(n => (n["name"] + "").Equals(colunmField.Key)).ToArray();
|
||
if (dataRows.Length == 0)
|
||
{
|
||
string addColSql = string.Format("alter table P_PrivateDllTab add {0} {1}", colunmField.Key, colunmField.Value);
|
||
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;
|
||
}
|
||
}
|
||
}
|
||
}
|