提交当前本机整理版本
This commit is contained in:
@@ -110,6 +110,7 @@ namespace Lskj.Util
|
||||
{
|
||||
JSCaller caller = new JSCaller();
|
||||
obj = caller.Eval(statement);
|
||||
|
||||
//obj = "0";
|
||||
//obj = _evaluatorType.InvokeMember(
|
||||
// "Eval",
|
||||
|
||||
@@ -5,4 +5,42 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Lskj.U
|
||||
namespace Lskj.Util
|
||||
{
|
||||
/// <summary>
|
||||
/// 外部字体类
|
||||
/// </summary>
|
||||
public static class FontUtil
|
||||
{
|
||||
static FontUtil()
|
||||
{
|
||||
if (Directory.Exists(PubUtil.Fonts))
|
||||
{
|
||||
string[] fontFiles = Directory.GetFiles(PubUtil.Fonts);
|
||||
foreach (string fontFile in fontFiles)
|
||||
{
|
||||
AddFont(fontFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 字体集合
|
||||
/// </summary>
|
||||
public static PrivateFontCollection Fonts = new PrivateFontCollection();
|
||||
/// <summary>
|
||||
/// 添加字体
|
||||
/// </summary>
|
||||
/// <param name="fontFilePath"></param>
|
||||
public static void AddFont(string fontFilePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
Fonts.AddFontFile(fontFilePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ namespace Lskj.Util
|
||||
{
|
||||
DllFileName = "Lskj.PubBrowerXp.dll";
|
||||
}
|
||||
//DllFileName = "Lskj.PubTabDll.dll";
|
||||
string libPath = DllFileName.Trim().ToLower().Equals("lskj.pubbrowser.dll") ? PubUtil.AbsolutelyBrowserPath + DllFileName : PubUtil.AbsolutelyLibPath + DllFileName;
|
||||
|
||||
Assembly _Assembly = Assembly.UnsafeLoadFrom(libPath);
|
||||
Type[] _types = _Assembly.GetTypes();
|
||||
foreach (Type _type in _types)
|
||||
|
||||
@@ -365,4 +365,25 @@ namespace Lskj.Util
|
||||
JOBOBJECT_BASIC_LIMIT_INFORMATION info = new JOBOBJECT_BASIC_LIMIT_INFORMATION();
|
||||
info.LimitFlags = 0x2000;
|
||||
JOBOBJECT_EXTENDED_LIMIT_INFORMATION extendedInfo = new JOBOBJECT_EXTENDED_LIMIT_INFORMATION();
|
||||
extendedI
|
||||
extendedInfo.BasicLimitInformation = info;
|
||||
//Design by LeventureQys
|
||||
int length = Marshal.SizeOf(typeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION));
|
||||
IntPtr extendedInfoPtr = Marshal.AllocHGlobal(length);
|
||||
Marshal.StructureToPtr(extendedInfo, extendedInfoPtr, false);
|
||||
|
||||
if (!SetInformationJobObject(job_handle, JobObjectInfoType.ExtendedLimitInformation, extendedInfoPtr, (uint)length))
|
||||
throw new Exception(string.Format("Unable to set information. Error: {0}", Marshal.GetLastWin32Error()));
|
||||
}
|
||||
/// <summary>
|
||||
/// 为该dll注册子进程,当主程序崩溃的时候,子进程一样退出
|
||||
/// </summary>
|
||||
/// <param name="added_process"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddProcess(IntPtr intPtr)
|
||||
{
|
||||
System.IntPtr handle = System.IntPtr.Zero;
|
||||
handle = intPtr;
|
||||
return AssignProcessToJobObject(job_handle, handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+30
-104
@@ -12,9 +12,6 @@ namespace Lskj.Util
|
||||
{
|
||||
public static class HttpHelper
|
||||
{
|
||||
private const int RequestTimeout = 120000;
|
||||
private const int Tls12 = 3072;
|
||||
|
||||
public enum Encode
|
||||
{
|
||||
Default = 0,
|
||||
@@ -31,76 +28,6 @@ namespace Lskj.Util
|
||||
UserAgent = userAgent;
|
||||
EncodeMode = encode;
|
||||
}
|
||||
|
||||
private static void ConfigureTransport()
|
||||
{
|
||||
try
|
||||
{
|
||||
ServicePointManager.SecurityProtocol |= (SecurityProtocolType)Tls12;
|
||||
ServicePointManager.Expect100Continue = false;
|
||||
if (ServicePointManager.DefaultConnectionLimit < 20)
|
||||
{
|
||||
ServicePointManager.DefaultConnectionLimit = 20;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private static void ConfigureRequest(HttpWebRequest request)
|
||||
{
|
||||
request.Timeout = RequestTimeout;
|
||||
request.ReadWriteTimeout = RequestTimeout;
|
||||
request.KeepAlive = false;
|
||||
request.ServicePoint.Expect100Continue = false;
|
||||
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
|
||||
}
|
||||
|
||||
private static string BuildExceptionMessage(Exception ex)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.Append(ex.Message);
|
||||
if (ex.InnerException != null)
|
||||
{
|
||||
builder.AppendFormat("; Inner={0}", ex.InnerException.Message);
|
||||
}
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
private static string BuildWebExceptionMessage(WebException ex)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.Append(BuildExceptionMessage(ex));
|
||||
builder.AppendFormat("; Status={0}", ex.Status);
|
||||
|
||||
HttpWebResponse response = ex.Response as HttpWebResponse;
|
||||
if (response != null)
|
||||
{
|
||||
builder.AppendFormat("; HttpStatus={0} {1}", (int)response.StatusCode, response.StatusDescription);
|
||||
try
|
||||
{
|
||||
Stream responseStream = response.GetResponseStream();
|
||||
if (responseStream != null)
|
||||
{
|
||||
using (StreamReader streamReader = new StreamReader(responseStream, Encoding.UTF8))
|
||||
{
|
||||
string responseText = streamReader.ReadToEnd();
|
||||
if (!string.IsNullOrEmpty(responseText))
|
||||
{
|
||||
builder.AppendFormat("; Response={0}", responseText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// post数据到指定的网址,获取cookie数据,和返回页
|
||||
/// </summary>
|
||||
@@ -110,9 +37,7 @@ namespace Lskj.Util
|
||||
try
|
||||
{
|
||||
HttpWebRequest httpWebRequest;
|
||||
ConfigureTransport();
|
||||
httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
|
||||
ConfigureRequest(httpWebRequest);
|
||||
|
||||
httpWebRequest.ContentType = ContentType;
|
||||
httpWebRequest.Accept = Accept;
|
||||
@@ -180,16 +105,10 @@ namespace Lskj.Util
|
||||
|
||||
return httpWebResponse;
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
result = BuildWebExceptionMessage(ex);
|
||||
return httpWebResponse;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
result = BuildExceptionMessage(ex);
|
||||
Console.WriteLine(ex.Message);
|
||||
result = ex.Message;
|
||||
return httpWebResponse;
|
||||
}
|
||||
}
|
||||
@@ -215,9 +134,7 @@ namespace Lskj.Util
|
||||
}
|
||||
}
|
||||
HttpWebRequest httpWebRequest;
|
||||
ConfigureTransport();
|
||||
httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(builder.ToString());
|
||||
ConfigureRequest(httpWebRequest);
|
||||
httpWebRequest.ContentType = ContentType;
|
||||
//httpWebRequest.Referer = url;
|
||||
httpWebRequest.Accept = Accept;
|
||||
@@ -246,16 +163,10 @@ namespace Lskj.Util
|
||||
|
||||
return httpWebResponse;
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
result = BuildWebExceptionMessage(ex);
|
||||
return httpWebResponse;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
result = BuildExceptionMessage(ex);
|
||||
Console.WriteLine(ex.Message);
|
||||
result = ex.Message;
|
||||
return httpWebResponse;
|
||||
}
|
||||
}
|
||||
@@ -275,9 +186,7 @@ namespace Lskj.Util
|
||||
{
|
||||
string boundary = "----WebKitFormBoundary" + DateTime.Now.Ticks.ToString("x");
|
||||
|
||||
ConfigureTransport();
|
||||
HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
|
||||
ConfigureRequest(httpWebRequest);
|
||||
httpWebRequest.Method = "POST";
|
||||
httpWebRequest.Accept = Accept;
|
||||
httpWebRequest.UserAgent = UserAgent;
|
||||
@@ -322,16 +231,10 @@ namespace Lskj.Util
|
||||
|
||||
return httpWebResponse;
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
result = BuildWebExceptionMessage(ex);
|
||||
return httpWebResponse;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
result = BuildExceptionMessage(ex);
|
||||
Console.WriteLine(ex.Message);
|
||||
result = ex.Message;
|
||||
return httpWebResponse;
|
||||
}
|
||||
}
|
||||
@@ -364,4 +267,27 @@ namespace Lskj.Util
|
||||
}
|
||||
if (hasEn || eqParams[0].ToLower() == "username" || eqParams[0].ToLower() == "password")
|
||||
{
|
||||
pms.Add(eqParams[0],
|
||||
pms.Add(eqParams[0], eqParams[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
qpLS.Add(string.Format("{0}={1}", eqParams[0], HttpUtility.UrlEncode(eqParams[1])));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
if (pms.Count > 0)
|
||||
{
|
||||
DateTime dateTime = DateTime.Now.AddDays(1);
|
||||
DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
long timestamp = (dateTime.Ticks - epoch.Ticks) / TimeSpan.TicksPerSecond;
|
||||
pms.Add("exp", timestamp);
|
||||
}
|
||||
return $"{urlParams[0]}?pms={HttpUtility.UrlEncode(hasEn ? Lskj.Web.Core.Util.safety.AESUtil.Encrypt(JSON.Encode(pms), enVal) : Lskj.Web.Core.Util.safety.AESUtil.MobileEncrypt(JSON.Encode(pms)))}&{qpLS.SJoin("&")}";
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,4 +140,49 @@ namespace Lskj.Util
|
||||
Error(message, e);
|
||||
}
|
||||
}
|
||||
private st
|
||||
private static object lockObj = new object();
|
||||
private static DateTime LastCheckDate = DateTime.Now;
|
||||
}
|
||||
public class LogInfo
|
||||
{
|
||||
public LogInfo(object happenobj)
|
||||
: base()
|
||||
{
|
||||
this.happenobj = happenobj;
|
||||
}
|
||||
|
||||
private object happenobj { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 信息
|
||||
/// </summary>
|
||||
public object msg { get; set; }
|
||||
|
||||
public string classname
|
||||
{
|
||||
get
|
||||
{
|
||||
return $"{happenobj.GetType().FullName}=>";
|
||||
}
|
||||
set { }
|
||||
}
|
||||
public string operatorId
|
||||
{
|
||||
get
|
||||
{
|
||||
return $"{ERPInfo.Instance.UserName}=>";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 异常
|
||||
/// </summary>
|
||||
public Exception exception { get; set; }
|
||||
|
||||
//more property;
|
||||
public override string ToString()
|
||||
{
|
||||
|
||||
return msg + "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,4 +37,35 @@ namespace Lskj.Util
|
||||
{
|
||||
// 写入所有关键值对
|
||||
|
||||
WriteDictionary(writer, loggingEvent.
|
||||
WriteDictionary(writer, loggingEvent.Repository, loggingEvent.GetProperties());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 通过反射获取传入的日志对象的某个属性的值
|
||||
/// </summary>
|
||||
/// <param name="property"></param>
|
||||
/// <param name="loggingEvent"></param>
|
||||
/// <returns></returns>
|
||||
private object LookupProperty(string property, log4net.Core.LoggingEvent loggingEvent)
|
||||
{
|
||||
object propertyValue = default(object);
|
||||
PropertyInfo propertyInfo = null;
|
||||
Type objtype = loggingEvent.MessageObject.GetType();
|
||||
propertyInfo = objtype.GetProperty(property);
|
||||
|
||||
propertyValue = propertyInfo != null ? propertyInfo.GetValue(loggingEvent.MessageObject, null) : loggingEvent.LookupProperty(property);
|
||||
if (property == "msg" && objtype == typeof(String))
|
||||
{
|
||||
return loggingEvent.MessageObject;
|
||||
}
|
||||
|
||||
return propertyValue ?? "";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+454
-417
@@ -1,417 +1,454 @@
|
||||
/******************************
|
||||
* 说明:程序通用方法管理类
|
||||
* 创建人:龚宇超
|
||||
* 创建日期:2017-08-16
|
||||
* 修改人:
|
||||
* 修改日期:
|
||||
* 修改备注:
|
||||
* 版本:1.0.0.0
|
||||
******************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
|
||||
namespace Lskj.Util
|
||||
{
|
||||
/// <summary>
|
||||
/// 程序通用方法管理类
|
||||
/// </summary>
|
||||
public sealed class PubUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// productDynamic图标
|
||||
/// </summary>
|
||||
/// <value>The system update log path.</value>
|
||||
public static string ProductDynamic
|
||||
{
|
||||
get { return AbsolutelyPath + "\\Images\\" + "ProductDynamic\\"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:获取应用程序启动目录</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-21 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string AbsolutelyPath
|
||||
{
|
||||
get { return Application.StartupPath + "\\"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取应用程序启动目录下的Lib目录
|
||||
/// </summary>
|
||||
/// <value>The absolutely library path.</value>
|
||||
public static string AbsolutelyLibPath
|
||||
{
|
||||
get { return AbsolutelyPath + "Lib/"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取应用程序启动目录下的Browser目录
|
||||
/// </summary>
|
||||
/// <value>The absolutely browser path.</value>
|
||||
public static string AbsolutelyBrowserPath
|
||||
{
|
||||
get { return AbsolutelyPath + "Browser/"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取应用程序启动目录下的小平台目录
|
||||
/// </summary>
|
||||
/// <value>The absolutely small client path.</value>
|
||||
public static string AbsolutelySmallClientPath
|
||||
{
|
||||
get { return AbsolutelyPath + "Client.exe"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:获取附件下载存放临时目录</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-11-01 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string FileDownLoadTempPath
|
||||
{
|
||||
get
|
||||
{
|
||||
string path = AbsolutelyPath + "TempFiles/";
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 图片扩展框图片下载路径(LabelImageEdit,每次进入程序会清空)
|
||||
/// </summary>
|
||||
public static string ImageDownloadPath
|
||||
{
|
||||
get
|
||||
{
|
||||
string path = AbsolutelyPath + "TempFiles\\ImageFile/";
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出文件的文件路径
|
||||
/// </summary>
|
||||
public static string ExportFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
string path = AbsolutelyPath + "TempFiles\\ExportFile/";
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 签章打印临时文件
|
||||
/// </summary>
|
||||
public static string SignatureFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
string path = AbsolutelyPath + "TempFiles\\SignatureFile/";
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void ClearFilesInDirectory(string targetDir)
|
||||
{
|
||||
// 校验目录是否存在
|
||||
if (!Directory.Exists(targetDir))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
// 删除所有文件
|
||||
foreach (string filePath in Directory.GetFiles(targetDir))
|
||||
{
|
||||
File.SetAttributes(filePath, FileAttributes.Normal);
|
||||
File.Delete(filePath);
|
||||
}
|
||||
|
||||
// 删除所有子文件夹(及其内容)
|
||||
foreach (string subDir in Directory.GetDirectories(targetDir))
|
||||
{
|
||||
Directory.Delete(subDir, recursive: true); // 递归删除子文件夹
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取打印文件路径
|
||||
/// </summary>
|
||||
/// <value>The print file absolutely path.</value>
|
||||
public static string PrintFileAbsolutelyPath
|
||||
{
|
||||
get { return AbsolutelyPath + "Lib/P_PubPrint.lsp"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取新版打印文件路径
|
||||
/// </summary>
|
||||
/// <value>The print file absolutely path.</value>
|
||||
public static string PrintFileAbsolutelyPath70
|
||||
{
|
||||
get { return AbsolutelyPath + "Lib/p_pubprint70.lsp"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 附件exe文件路径
|
||||
/// </summary>
|
||||
/// <value>The name of the file executable.</value>
|
||||
public static string AbsolutelyFileUploadPath
|
||||
{
|
||||
get { return AbsolutelyPath + "Attach/LSTest.exe"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 主界面模块图片加载路径
|
||||
/// </summary>
|
||||
/// <value>The main menu default image.</value>
|
||||
public static string MainMenuDefaultImage
|
||||
{
|
||||
get { return BitMapPath + "Main/Module/"; }
|
||||
}
|
||||
public static string MesItemImage
|
||||
{
|
||||
get { return BitMapPath + "MesItem/"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 主界面、登录界面、子系统图片存放位置
|
||||
/// </summary>
|
||||
/// <value>The bit map path.</value>
|
||||
public static string BitMapPath
|
||||
{
|
||||
get { return AbsolutelyPath + "Images/"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 身份证阅读器图片存放位置
|
||||
/// </summary>
|
||||
/// <value>The identifier card bit map path.</value>
|
||||
public static string IDCardBitMapPath
|
||||
{
|
||||
get
|
||||
{
|
||||
string filePath = AbsolutelyPath + "Card\\";
|
||||
if (!Directory.Exists(filePath))
|
||||
Directory.CreateDirectory(filePath);
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 串口通过ini本地设置
|
||||
/// </summary>
|
||||
/// <value>The main menu configuration path.</value>
|
||||
public static string TextPath
|
||||
{
|
||||
get { return AbsolutelyPath + "text.ini"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 模块配置文件存放路径
|
||||
/// </summary>
|
||||
/// <value>The main menu configuration path.</value>
|
||||
public static string MainMenuConfigPath
|
||||
{
|
||||
get { return AbsolutelyPath + "MenuConfig.ini"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 控件缓存数据源
|
||||
/// </summary>
|
||||
/// <value>The identifier card bit map path.</value>
|
||||
public static string ControlCacheData
|
||||
{
|
||||
get
|
||||
{
|
||||
string filePath = AbsolutelyPath + "ControlData\\";
|
||||
if (!Directory.Exists(filePath))
|
||||
Directory.CreateDirectory(filePath);
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Excel模板路径
|
||||
/// </summary>
|
||||
/// <value>The menu excel path.</value>
|
||||
public static string MenuExcelPath
|
||||
{
|
||||
get
|
||||
{
|
||||
string filePath = AbsolutelyPath + "Templete/";
|
||||
if (!Directory.Exists(filePath))
|
||||
{
|
||||
Directory.CreateDirectory(filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 打印模板 repx文件存放地址
|
||||
/// </summary>
|
||||
public static string PrintModePath
|
||||
{
|
||||
get
|
||||
{
|
||||
string filePath = AbsolutelyPath + "Reports\\";
|
||||
if (!Directory.Exists(filePath))
|
||||
{
|
||||
Directory.CreateDirectory(filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// ppt模板 pptx文件存放地址
|
||||
/// </summary>
|
||||
public static string CreatePptPath
|
||||
{
|
||||
get
|
||||
{
|
||||
string filePath = AbsolutelyPath + "Pptxs\\";
|
||||
if (!Directory.Exists(filePath))
|
||||
{
|
||||
Directory.CreateDirectory(filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 发票扫描图片文件存放地址
|
||||
/// </summary>
|
||||
public static string CreateInvoicePic
|
||||
{
|
||||
get
|
||||
{
|
||||
string filePath = AbsolutelyPath + "InvoicePic\\";
|
||||
if (!Directory.Exists(filePath))
|
||||
{
|
||||
Directory.CreateDirectory(filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 打印所有模块xml生成地址
|
||||
/// </summary>
|
||||
public static string AllMethodXml
|
||||
{
|
||||
get
|
||||
{
|
||||
string filePath = AbsolutelyPath + "AllMethodXml\\";
|
||||
if (!Directory.Exists(filePath))
|
||||
{
|
||||
Directory.CreateDirectory(filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 打印模板语言包存放位置
|
||||
/// </summary>
|
||||
public static string PrintModeResourcePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return AbsolutelyPath + "Localization\\Chinese (Simplified).frl";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 软件升级日志
|
||||
/// </summary>
|
||||
/// <value>The system update log path.</value>
|
||||
public static string SystemUpdateLogPath
|
||||
{
|
||||
get { return AbsolutelyPath + "\\Log.txt"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// WebView2
|
||||
/// </summary>
|
||||
/// <value>The system update log path.</value>
|
||||
public static string WebViewPath
|
||||
{
|
||||
get { return AbsolutelyPath + "\\Browser3\\"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// GridControl操作列图标
|
||||
/// </summary>
|
||||
/// <value>The system update log path.</value>
|
||||
public static string GridColumnIco
|
||||
{
|
||||
get { return AbsolutelyPath + "\\Images\\" + "ColumnIco\\"; }
|
||||
}
|
||||
public static string TreeViewImagePath
|
||||
{
|
||||
get { return AbsolutelyPath + "\\Images\\" + "TreeViewImage\\"; }
|
||||
}
|
||||
public static string PdfSignImagePath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!Directory.Exists(AbsolutelyPath + "\\PdfSign\\" + "PdfSignImage\\"))
|
||||
{
|
||||
Directory.CreateDirectory(AbsolutelyPath + "\\PdfSign\\" + "PdfSignImage\\");
|
||||
}
|
||||
return AbsolutelyPath + "\\PdfSign\\" + "PdfSignImage\\";
|
||||
}
|
||||
}
|
||||
public static string PdfSignTempPath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!Directory.Exists(AbsolutelyPath + "\\PdfSign\\" + "PdfSignTemp\\"))
|
||||
{
|
||||
Directory.CreateDirectory(AbsolutelyPath + "\\PdfSign\\" + "PdfSignTemp\\");
|
||||
}
|
||||
return AbsolutelyPath + "\\PdfSign\\" + "PdfSignTemp\\";
|
||||
}
|
||||
}
|
||||
public static string PdfSignTempSavePath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!Directory.Exists(AbsolutelyPath + "\\PdfSign\\" + "PdfSignTempSave\\"))
|
||||
{
|
||||
Directory.CreateDirectory(AbsolutelyPath + "\\PdfSign\\" + "PdfSignTempSave\\");
|
||||
}
|
||||
return AbsolutelyPath + "\\PdfSign\\" + "PdfSignTempSave\\";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 菜单默认图标
|
||||
/// </summary>
|
||||
public static string ModuleDefaultPath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!Directory.Exists(AbsolutelyPath + "Images\\Main\\Module\\Default"))
|
||||
{
|
||||
/******************************
|
||||
* 说明:程序通用方法管理类
|
||||
* 创建人:龚宇超
|
||||
* 创建日期:2017-08-16
|
||||
* 修改人:
|
||||
* 修改日期:
|
||||
* 修改备注:
|
||||
* 版本:1.0.0.0
|
||||
******************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
|
||||
namespace Lskj.Util
|
||||
{
|
||||
/// <summary>
|
||||
/// 程序通用方法管理类
|
||||
/// </summary>
|
||||
public sealed class PubUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// productDynamic图标
|
||||
/// </summary>
|
||||
/// <value>The system update log path.</value>
|
||||
public static string ProductDynamic
|
||||
{
|
||||
get { return AbsolutelyPath + "\\Images\\" + "ProductDynamic\\"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:获取应用程序启动目录</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-21 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string AbsolutelyPath
|
||||
{
|
||||
get { return Application.StartupPath + "\\"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取应用程序启动目录下的Lib目录
|
||||
/// </summary>
|
||||
/// <value>The absolutely library path.</value>
|
||||
public static string AbsolutelyLibPath
|
||||
{
|
||||
get { return AbsolutelyPath + "Lib/"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取应用程序启动目录下的Browser目录
|
||||
/// </summary>
|
||||
/// <value>The absolutely browser path.</value>
|
||||
public static string AbsolutelyBrowserPath
|
||||
{
|
||||
get { return AbsolutelyPath + "Browser/"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取应用程序启动目录下的小平台目录
|
||||
/// </summary>
|
||||
/// <value>The absolutely small client path.</value>
|
||||
public static string AbsolutelySmallClientPath
|
||||
{
|
||||
get { return AbsolutelyPath + "Client.exe"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:获取附件下载存放临时目录</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-11-01 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string FileDownLoadTempPath
|
||||
{
|
||||
get
|
||||
{
|
||||
string path = AbsolutelyPath + "TempFiles/";
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 图片扩展框图片下载路径(LabelImageEdit,每次进入程序会清空)
|
||||
/// </summary>
|
||||
public static string ImageDownloadPath
|
||||
{
|
||||
get
|
||||
{
|
||||
string path = AbsolutelyPath + "TempFiles\\ImageFile/";
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出文件的文件路径
|
||||
/// </summary>
|
||||
public static string ExportFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
string path = AbsolutelyPath + "TempFiles\\ExportFile/";
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 签章打印临时文件
|
||||
/// </summary>
|
||||
public static string SignatureFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
string path = AbsolutelyPath + "TempFiles\\SignatureFile/";
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void ClearFilesInDirectory(string targetDir)
|
||||
{
|
||||
// 校验目录是否存在
|
||||
if (!Directory.Exists(targetDir))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
// 删除所有文件
|
||||
foreach (string filePath in Directory.GetFiles(targetDir))
|
||||
{
|
||||
File.SetAttributes(filePath, FileAttributes.Normal);
|
||||
File.Delete(filePath);
|
||||
}
|
||||
|
||||
// 删除所有子文件夹(及其内容)
|
||||
foreach (string subDir in Directory.GetDirectories(targetDir))
|
||||
{
|
||||
Directory.Delete(subDir, recursive: true); // 递归删除子文件夹
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取打印文件路径
|
||||
/// </summary>
|
||||
/// <value>The print file absolutely path.</value>
|
||||
public static string PrintFileAbsolutelyPath
|
||||
{
|
||||
get { return AbsolutelyPath + "Lib/P_PubPrint.lsp"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取新版打印文件路径
|
||||
/// </summary>
|
||||
/// <value>The print file absolutely path.</value>
|
||||
public static string PrintFileAbsolutelyPath70
|
||||
{
|
||||
get { return AbsolutelyPath + "Lib/p_pubprint70.lsp"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 附件exe文件路径
|
||||
/// </summary>
|
||||
/// <value>The name of the file executable.</value>
|
||||
public static string AbsolutelyFileUploadPath
|
||||
{
|
||||
get { return AbsolutelyPath + "Attach/LSTest.exe"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 主界面模块图片加载路径
|
||||
/// </summary>
|
||||
/// <value>The main menu default image.</value>
|
||||
public static string MainMenuDefaultImage
|
||||
{
|
||||
get { return BitMapPath + "Main/Module/"; }
|
||||
}
|
||||
public static string MesItemImage
|
||||
{
|
||||
get { return BitMapPath + "MesItem/"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 主界面、登录界面、子系统图片存放位置
|
||||
/// </summary>
|
||||
/// <value>The bit map path.</value>
|
||||
public static string BitMapPath
|
||||
{
|
||||
get { return AbsolutelyPath + "Images/"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 身份证阅读器图片存放位置
|
||||
/// </summary>
|
||||
/// <value>The identifier card bit map path.</value>
|
||||
public static string IDCardBitMapPath
|
||||
{
|
||||
get
|
||||
{
|
||||
string filePath = AbsolutelyPath + "Card\\";
|
||||
if (!Directory.Exists(filePath))
|
||||
Directory.CreateDirectory(filePath);
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 串口通过ini本地设置
|
||||
/// </summary>
|
||||
/// <value>The main menu configuration path.</value>
|
||||
public static string TextPath
|
||||
{
|
||||
get { return AbsolutelyPath + "text.ini"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 模块配置文件存放路径
|
||||
/// </summary>
|
||||
/// <value>The main menu configuration path.</value>
|
||||
public static string MainMenuConfigPath
|
||||
{
|
||||
get { return AbsolutelyPath + "MenuConfig.ini"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 控件缓存数据源
|
||||
/// </summary>
|
||||
/// <value>The identifier card bit map path.</value>
|
||||
public static string ControlCacheData
|
||||
{
|
||||
get
|
||||
{
|
||||
string filePath = AbsolutelyPath + "ControlData\\";
|
||||
if (!Directory.Exists(filePath))
|
||||
Directory.CreateDirectory(filePath);
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Excel模板路径
|
||||
/// </summary>
|
||||
/// <value>The menu excel path.</value>
|
||||
public static string MenuExcelPath
|
||||
{
|
||||
get
|
||||
{
|
||||
string filePath = AbsolutelyPath + "Templete/";
|
||||
if (!Directory.Exists(filePath))
|
||||
{
|
||||
Directory.CreateDirectory(filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 打印模板 repx文件存放地址
|
||||
/// </summary>
|
||||
public static string PrintModePath
|
||||
{
|
||||
get
|
||||
{
|
||||
string filePath = AbsolutelyPath + "Reports\\";
|
||||
if (!Directory.Exists(filePath))
|
||||
{
|
||||
Directory.CreateDirectory(filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// ppt模板 pptx文件存放地址
|
||||
/// </summary>
|
||||
public static string CreatePptPath
|
||||
{
|
||||
get
|
||||
{
|
||||
string filePath = AbsolutelyPath + "Pptxs\\";
|
||||
if (!Directory.Exists(filePath))
|
||||
{
|
||||
Directory.CreateDirectory(filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 发票扫描图片文件存放地址
|
||||
/// </summary>
|
||||
public static string CreateInvoicePic
|
||||
{
|
||||
get
|
||||
{
|
||||
string filePath = AbsolutelyPath + "InvoicePic\\";
|
||||
if (!Directory.Exists(filePath))
|
||||
{
|
||||
Directory.CreateDirectory(filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 打印所有模块xml生成地址
|
||||
/// </summary>
|
||||
public static string AllMethodXml
|
||||
{
|
||||
get
|
||||
{
|
||||
string filePath = AbsolutelyPath + "AllMethodXml\\";
|
||||
if (!Directory.Exists(filePath))
|
||||
{
|
||||
Directory.CreateDirectory(filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 打印模板语言包存放位置
|
||||
/// </summary>
|
||||
public static string PrintModeResourcePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return AbsolutelyPath + "Localization\\Chinese (Simplified).frl";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 软件升级日志
|
||||
/// </summary>
|
||||
/// <value>The system update log path.</value>
|
||||
public static string SystemUpdateLogPath
|
||||
{
|
||||
get { return AbsolutelyPath + "\\Log.txt"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// WebView2
|
||||
/// </summary>
|
||||
/// <value>The system update log path.</value>
|
||||
public static string WebViewPath
|
||||
{
|
||||
get { return AbsolutelyPath + "\\Browser3\\"; }
|
||||
}
|
||||
/// <summary>
|
||||
/// GridControl操作列图标
|
||||
/// </summary>
|
||||
/// <value>The system update log path.</value>
|
||||
public static string GridColumnIco
|
||||
{
|
||||
get { return AbsolutelyPath + "\\Images\\" + "ColumnIco\\"; }
|
||||
}
|
||||
public static string TreeViewImagePath
|
||||
{
|
||||
get { return AbsolutelyPath + "\\Images\\" + "TreeViewImage\\"; }
|
||||
}
|
||||
public static string PdfSignImagePath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!Directory.Exists(AbsolutelyPath + "\\PdfSign\\" + "PdfSignImage\\"))
|
||||
{
|
||||
Directory.CreateDirectory(AbsolutelyPath + "\\PdfSign\\" + "PdfSignImage\\");
|
||||
}
|
||||
return AbsolutelyPath + "\\PdfSign\\" + "PdfSignImage\\";
|
||||
}
|
||||
}
|
||||
public static string PdfSignTempPath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!Directory.Exists(AbsolutelyPath + "\\PdfSign\\" + "PdfSignTemp\\"))
|
||||
{
|
||||
Directory.CreateDirectory(AbsolutelyPath + "\\PdfSign\\" + "PdfSignTemp\\");
|
||||
}
|
||||
return AbsolutelyPath + "\\PdfSign\\" + "PdfSignTemp\\";
|
||||
}
|
||||
}
|
||||
public static string PdfSignTempSavePath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!Directory.Exists(AbsolutelyPath + "\\PdfSign\\" + "PdfSignTempSave\\"))
|
||||
{
|
||||
Directory.CreateDirectory(AbsolutelyPath + "\\PdfSign\\" + "PdfSignTempSave\\");
|
||||
}
|
||||
return AbsolutelyPath + "\\PdfSign\\" + "PdfSignTempSave\\";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 菜单默认图标
|
||||
/// </summary>
|
||||
public static string ModuleDefaultPath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!Directory.Exists(AbsolutelyPath + "Images\\Main\\Module\\Default"))
|
||||
{
|
||||
Directory.CreateDirectory(AbsolutelyPath + "Images\\Main\\Module\\Default");
|
||||
}
|
||||
return AbsolutelyPath + "Images\\Main\\Module\\Default";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 选中边框图
|
||||
/// </summary>
|
||||
public static string ModuleChooesImg
|
||||
{
|
||||
get
|
||||
{
|
||||
return AbsolutelyPath + "Images\\Main\\Module\\Default\\Chooes\\chooes.png";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 选中图标
|
||||
/// </summary>
|
||||
public static string ModuleHoverImg
|
||||
{
|
||||
get
|
||||
{
|
||||
return AbsolutelyPath + "Images\\Main\\Module\\Default\\Chooes\\hover.png";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 字体文件夹
|
||||
/// </summary>
|
||||
public static string Fonts
|
||||
{
|
||||
get
|
||||
{
|
||||
return AbsolutelyPath + "Fonts";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -879,4 +879,38 @@ namespace Lskj.Util
|
||||
|
||||
foreach (string field in fields)
|
||||
{
|
||||
|
||||
fieldValues = string.Empty;
|
||||
start = string.Empty;
|
||||
end = string.Empty;
|
||||
|
||||
string key = field.Replace("[", "").Replace("]", "");
|
||||
if (key.StartsWith("!"))
|
||||
{
|
||||
key = key.Replace("!", "");
|
||||
start = end = "'";
|
||||
}
|
||||
else if (key.StartsWith("@"))
|
||||
{
|
||||
key = key.Replace("@", "");
|
||||
start = end = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (DataRow item in rows)
|
||||
{
|
||||
if (item.Table.Columns.Contains(key) && !string.IsNullOrWhiteSpace(item[key] + ""))
|
||||
fieldValues += start + item[key] + end + ",";
|
||||
}
|
||||
param = param.Replace(field, fieldValues.TrimEnd(','));
|
||||
}
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,4 +301,39 @@ namespace Lskj.Util
|
||||
}
|
||||
else
|
||||
{
|
||||
returnMsg
|
||||
returnMsg = "登录失败";
|
||||
isDelete = false;
|
||||
}
|
||||
return isDelete;
|
||||
}
|
||||
/// <summary>
|
||||
/// 文件转换为byte[]
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
/// <returns></returns>
|
||||
public static byte[] ConvertFileToBytes(string filePath)
|
||||
{
|
||||
byte[] bytContent = null;
|
||||
FileStream fs = null;
|
||||
BinaryReader br = null;
|
||||
try
|
||||
{
|
||||
fs = new FileStream(filePath, System.IO.FileMode.Open);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (fs != null)
|
||||
br = new BinaryReader((Stream)fs);
|
||||
if (br != null)
|
||||
bytContent = br.ReadBytes((Int32)fs.Length);
|
||||
if (fs != null)
|
||||
fs.Dispose();
|
||||
}
|
||||
return bytContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,4 +248,36 @@ namespace Lskj.Util
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Console.WriteLine(ex.Message);
|
||||
return default;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加任务
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="cachesDic"></param>
|
||||
/// <param name="control"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="task"></param>
|
||||
public static Task<T> AddTask<T>(this Dictionary<object, Hashtable> cachesDic, object control, string key, Task<T> task)
|
||||
{
|
||||
Hashtable cachesHash = new Hashtable();
|
||||
if (!cachesDic.ContainsKey(control))
|
||||
{
|
||||
cachesDic.Add(control, cachesHash);
|
||||
}
|
||||
else
|
||||
{
|
||||
cachesHash = cachesDic[control];
|
||||
}
|
||||
cachesHash.Add(key, task);
|
||||
if (task.Status == TaskStatus.Created)
|
||||
{
|
||||
task.Start(SchedulerUtil);
|
||||
}
|
||||
return task;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,4 +102,38 @@ namespace Lskj.Util
|
||||
}
|
||||
|
||||
var comparison = ignoreCase
|
||||
? StringComparison.Ordinal
|
||||
? StringComparison.OrdinalIgnoreCase
|
||||
: StringComparison.Ordinal;
|
||||
|
||||
if (str.IndexOf(key, comparison) < 0)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
return Regex.Replace(
|
||||
str,
|
||||
key,
|
||||
value ?? "",
|
||||
ignoreCase ? RegexOptions.IgnoreCase : RegexOptions.None);
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期: </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="text">The text.</param>
|
||||
public static bool IsChinese(this string text)
|
||||
{
|
||||
for (int i = 0; i < text.Length; i++)
|
||||
{
|
||||
if ((int)text[i] > 127)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user