INIT
This commit is contained in:
commit
db13743ae9
|
|
@ -0,0 +1,32 @@
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
|
||||||
|
# Visual Studio 2022 cache/options directory
|
||||||
|
.vs/
|
||||||
|
packages/
|
||||||
|
/.svn
|
||||||
|
/Core.Web/Export
|
||||||
|
/Core.Web/LogError
|
||||||
|
LogError/
|
||||||
|
logs/
|
||||||
|
/Core.AuditService/Core.AuditService_TemporaryKey.pfx
|
||||||
|
UploadFile/
|
||||||
|
/Core.Web/logs
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Configuration.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Common
|
||||||
|
{
|
||||||
|
public class AppConfigurtaionServices
|
||||||
|
{
|
||||||
|
public static IConfiguration Configuration { get; set; }
|
||||||
|
static AppConfigurtaionServices()
|
||||||
|
{
|
||||||
|
//ReloadOnChange = true 当appsettings.json被修改时重新加载
|
||||||
|
Configuration = new ConfigurationBuilder()
|
||||||
|
.Add(new JsonConfigurationSource { Path = "appsettings.json", ReloadOnChange = true })
|
||||||
|
.Build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,298 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace Mini.Common
|
||||||
|
{
|
||||||
|
public class AppDomainTypeFinder : ITypeFinder
|
||||||
|
{
|
||||||
|
#region Fields
|
||||||
|
|
||||||
|
private bool ignoreReflectionErrors = true;
|
||||||
|
private bool loadAppDomainAssemblies = true;
|
||||||
|
private string assemblySkipLoadingPattern = "^System|^mscorlib|^Microsoft|^AjaxControlToolkit|^Antlr3|^Autofac|^AutoMapper|^Castle|^ComponentArt|^CppCodeProvider|^DotNetOpenAuth|^EntityFramework|^EPPlus|^FluentValidation|^ImageResizer|^itextsharp|^log4net|^MaxMind|^MbUnit|^MiniProfiler|^Mono.Math|^MvcContrib|^Newtonsoft|^NHibernate|^nunit|^Org.Mentalis|^PerlRegex|^QuickGraph|^Recaptcha|^Remotion|^RestSharp|^Rhino|^Telerik|^Iesi|^TestDriven|^TestFu|^UserAgentStringLibrary|^VJSharpCodeProvider|^WebActivator|^WebDev|^WebGrease";
|
||||||
|
private string assemblyRestrictToLoadingPattern = ".*";
|
||||||
|
private IList<string> assemblyNames = new List<string>();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
/// <summary>The app domain to look for types in.</summary>
|
||||||
|
public virtual AppDomain App
|
||||||
|
{
|
||||||
|
get { return AppDomain.CurrentDomain; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Gets or sets whether Nop should iterate assemblies in the app domain when loading Nop types. Loading patterns are applied when loading these assemblies.</summary>
|
||||||
|
public bool LoadAppDomainAssemblies
|
||||||
|
{
|
||||||
|
get { return loadAppDomainAssemblies; }
|
||||||
|
set { loadAppDomainAssemblies = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Gets or sets assemblies loaded a startup in addition to those loaded in the AppDomain.</summary>
|
||||||
|
public IList<string> AssemblyNames
|
||||||
|
{
|
||||||
|
get { return assemblyNames; }
|
||||||
|
set { assemblyNames = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Gets the pattern for dlls that we know don't need to be investigated.</summary>
|
||||||
|
public string AssemblySkipLoadingPattern
|
||||||
|
{
|
||||||
|
get { return assemblySkipLoadingPattern; }
|
||||||
|
set { assemblySkipLoadingPattern = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Gets or sets the pattern for dll that will be investigated. For ease of use this defaults to match all but to increase performance you might want to configure a pattern that includes assemblies and your own.</summary>
|
||||||
|
/// <remarks>If you change this so that Nop assemblies arn't investigated (e.g. by not including something like "^Nop|..." you may break core functionality.</remarks>
|
||||||
|
public string AssemblyRestrictToLoadingPattern
|
||||||
|
{
|
||||||
|
get { return assemblyRestrictToLoadingPattern; }
|
||||||
|
set { assemblyRestrictToLoadingPattern = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
public IEnumerable<Type> FindClassesOfType<T>(bool onlyConcreteClasses = true)
|
||||||
|
{
|
||||||
|
return FindClassesOfType(typeof(T), onlyConcreteClasses);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Type> FindClassesOfType(Type assignTypeFrom, bool onlyConcreteClasses = true)
|
||||||
|
{
|
||||||
|
return FindClassesOfType(assignTypeFrom, GetAssemblies(), onlyConcreteClasses);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Type> FindClassesOfType<T>(IEnumerable<Assembly> assemblies, bool onlyConcreteClasses = true)
|
||||||
|
{
|
||||||
|
return FindClassesOfType(typeof(T), assemblies, onlyConcreteClasses);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Type> FindClassesOfType(Type assignTypeFrom, IEnumerable<Assembly> assemblies, bool onlyConcreteClasses = true)
|
||||||
|
{
|
||||||
|
var result = new List<Type>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (var a in assemblies)
|
||||||
|
{
|
||||||
|
Type[] types = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
types = a.GetTypes();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//Entity Framework 6 doesn't allow getting types (throws an exception)
|
||||||
|
if (!ignoreReflectionErrors)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (types != null)
|
||||||
|
{
|
||||||
|
foreach (var t in types)
|
||||||
|
{
|
||||||
|
if (assignTypeFrom.IsAssignableFrom(t) || (assignTypeFrom.IsGenericTypeDefinition && DoesTypeImplementOpenGeneric(t, assignTypeFrom)))
|
||||||
|
{
|
||||||
|
if (!t.IsInterface)
|
||||||
|
{
|
||||||
|
if (onlyConcreteClasses)
|
||||||
|
{
|
||||||
|
if (t.IsClass && !t.IsAbstract)
|
||||||
|
{
|
||||||
|
result.Add(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.Add(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ReflectionTypeLoadException ex)
|
||||||
|
{
|
||||||
|
var msg = string.Empty;
|
||||||
|
foreach (var e in ex.LoaderExceptions)
|
||||||
|
msg += e.Message + Environment.NewLine;
|
||||||
|
|
||||||
|
var fail = new Exception(msg, ex);
|
||||||
|
Debug.WriteLine(fail.Message, fail);
|
||||||
|
|
||||||
|
throw fail;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Gets the assemblies related to the current implementation.</summary>
|
||||||
|
/// <returns>A list of assemblies that should be loaded by the Nop factory.</returns>
|
||||||
|
public virtual IList<Assembly> GetAssemblies()
|
||||||
|
{
|
||||||
|
var addedAssemblyNames = new List<string>();
|
||||||
|
var assemblies = new List<Assembly>();
|
||||||
|
|
||||||
|
if (LoadAppDomainAssemblies)
|
||||||
|
AddAssembliesInAppDomain(addedAssemblyNames, assemblies);
|
||||||
|
AddConfiguredAssemblies(addedAssemblyNames, assemblies);
|
||||||
|
|
||||||
|
return assemblies;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Utilities
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Iterates all assemblies in the AppDomain and if it's name matches the configured patterns add it to our list.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="addedAssemblyNames"></param>
|
||||||
|
/// <param name="assemblies"></param>
|
||||||
|
private void AddAssembliesInAppDomain(List<string> addedAssemblyNames, List<Assembly> assemblies)
|
||||||
|
{
|
||||||
|
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
|
{
|
||||||
|
if (Matches(assembly.FullName))
|
||||||
|
{
|
||||||
|
if (!addedAssemblyNames.Contains(assembly.FullName))
|
||||||
|
{
|
||||||
|
assemblies.Add(assembly);
|
||||||
|
addedAssemblyNames.Add(assembly.FullName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds specifically configured assemblies.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="addedAssemblyNames"></param>
|
||||||
|
/// <param name="assemblies"></param>
|
||||||
|
protected virtual void AddConfiguredAssemblies(List<string> addedAssemblyNames, List<Assembly> assemblies)
|
||||||
|
{
|
||||||
|
foreach (string assemblyName in AssemblyNames)
|
||||||
|
{
|
||||||
|
Assembly assembly = Assembly.Load(assemblyName);
|
||||||
|
if (!addedAssemblyNames.Contains(assembly.FullName))
|
||||||
|
{
|
||||||
|
assemblies.Add(assembly);
|
||||||
|
addedAssemblyNames.Add(assembly.FullName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if a dll is one of the shipped dlls that we know don't need to be investigated.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assemblyFullName">
|
||||||
|
/// The name of the assembly to check.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// True if the assembly should be loaded into Nop.
|
||||||
|
/// </returns>
|
||||||
|
public virtual bool Matches(string assemblyFullName)
|
||||||
|
{
|
||||||
|
return !Matches(assemblyFullName, AssemblySkipLoadingPattern)
|
||||||
|
&& Matches(assemblyFullName, AssemblyRestrictToLoadingPattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if a dll is one of the shipped dlls that we know don't need to be investigated.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assemblyFullName">
|
||||||
|
/// The assembly name to match.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="pattern">
|
||||||
|
/// The regular expression pattern to match against the assembly name.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// True if the pattern matches the assembly name.
|
||||||
|
/// </returns>
|
||||||
|
protected virtual bool Matches(string assemblyFullName, string pattern)
|
||||||
|
{
|
||||||
|
return Regex.IsMatch(assemblyFullName, pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Makes sure matching assemblies in the supplied folder are loaded in the app domain.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryPath">
|
||||||
|
/// The physical path to a directory containing dlls to load in the app domain.
|
||||||
|
/// </param>
|
||||||
|
protected virtual void LoadMatchingAssemblies(string directoryPath)
|
||||||
|
{
|
||||||
|
var loadedAssemblyNames = new List<string>();
|
||||||
|
foreach (Assembly a in GetAssemblies())
|
||||||
|
{
|
||||||
|
loadedAssemblyNames.Add(a.FullName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Directory.Exists(directoryPath))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string dllPath in Directory.GetFiles(directoryPath, "*.dll"))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var an = AssemblyName.GetAssemblyName(dllPath);
|
||||||
|
if (Matches(an.FullName) && !loadedAssemblyNames.Contains(an.FullName))
|
||||||
|
{
|
||||||
|
App.Load(an);
|
||||||
|
}
|
||||||
|
|
||||||
|
//old loading stuff
|
||||||
|
//Assembly a = Assembly.ReflectionOnlyLoadFrom(dllPath);
|
||||||
|
//if (Matches(a.FullName) && !loadedAssemblyNames.Contains(a.FullName))
|
||||||
|
//{
|
||||||
|
// App.Load(a.FullName);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
catch (BadImageFormatException ex)
|
||||||
|
{
|
||||||
|
Trace.TraceError(ex.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Does type implement generic?
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
/// <param name="openGeneric"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
protected virtual bool DoesTypeImplementOpenGeneric(Type type, Type openGeneric)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var genericTypeDefinition = openGeneric.GetGenericTypeDefinition();
|
||||||
|
foreach (var implementedInterface in type.FindInterfaces((objType, objCriteria) => true, null))
|
||||||
|
{
|
||||||
|
if (!implementedInterface.IsGenericType)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var isMatch = genericTypeDefinition.IsAssignableFrom(implementedInterface.GetGenericTypeDefinition());
|
||||||
|
return isMatch;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Common
|
||||||
|
{
|
||||||
|
public class CacheHelper
|
||||||
|
{
|
||||||
|
public static IMemoryCache _memoryCache = new MemoryCache(new MemoryCacheOptions());
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存绝对过期时间
|
||||||
|
/// </summary>
|
||||||
|
///<param name="key">Cache键值</param>
|
||||||
|
///<param name="value">给Cache[key]赋的值</param>
|
||||||
|
///<param name="minute">minute分钟后绝对过期</param>
|
||||||
|
public static void CacheInsertAddMinutes(string key, object value, int minute)
|
||||||
|
{
|
||||||
|
if (value == null) return;
|
||||||
|
_memoryCache.Set(key, value, new MemoryCacheEntryOptions()
|
||||||
|
.SetAbsoluteExpiration(TimeSpan.FromMinutes(minute)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存相对过期,最后一次访问后minute分钟后过期
|
||||||
|
/// </summary>
|
||||||
|
///<param name="key">Cache键值</param>
|
||||||
|
///<param name="value">给Cache[key]赋的值</param>
|
||||||
|
///<param name="minute">滑动过期分钟</param>
|
||||||
|
public static void CacheInsertFromMinutes(string key, object value, int minute)
|
||||||
|
{
|
||||||
|
if (value == null) return;
|
||||||
|
_memoryCache.Set(key, value, new MemoryCacheEntryOptions()
|
||||||
|
.SetSlidingExpiration(TimeSpan.FromMinutes(minute)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///以key键值,把value赋给Cache[key].如果不主动清空,会一直保存在内存中.
|
||||||
|
/// </summary>
|
||||||
|
///<param name="key">Cache键值</param>
|
||||||
|
///<param name="value">给Cache[key]赋的值</param>
|
||||||
|
public static void Set(string key, object value)
|
||||||
|
{
|
||||||
|
_memoryCache.Set(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///清除Cache[key]的值
|
||||||
|
/// </summary>
|
||||||
|
///<param name="key"></param>
|
||||||
|
public static void Remove(string key)
|
||||||
|
{
|
||||||
|
_memoryCache.Remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///根据key值,返回Cache[key]的值
|
||||||
|
/// </summary>
|
||||||
|
///<param name="key"></param>
|
||||||
|
public static object CacheValue(string key)
|
||||||
|
{
|
||||||
|
return _memoryCache.Get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">类型</typeparam>
|
||||||
|
/// <param name="key">Key</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T Get<T>(string key)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
T t = (T)_memoryCache.Get<T>(key);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace Mini.Common
|
||||||
|
{
|
||||||
|
public static class CommpnHelpEx
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// unicode编码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string ToUnicodeString(this string str)
|
||||||
|
{
|
||||||
|
StringBuilder strResult = new StringBuilder();
|
||||||
|
if (!string.IsNullOrEmpty(str))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < str.Length; i++)
|
||||||
|
{
|
||||||
|
strResult.Append("\\u");
|
||||||
|
strResult.Append(((int)str[i]).ToString("x"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return strResult.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// unicode解码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string FromUnicodeString(this string str)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(str))
|
||||||
|
return str;
|
||||||
|
return System.Text.RegularExpressions.Regex.Unescape(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Common
|
||||||
|
{
|
||||||
|
|
||||||
|
public static class ConfigHelper
|
||||||
|
{
|
||||||
|
private static IConfiguration _configuration;
|
||||||
|
|
||||||
|
static ConfigHelper()
|
||||||
|
{
|
||||||
|
//在当前目录或者根目录中寻找appsettings.json文件
|
||||||
|
var fileName = "appsettings.json";
|
||||||
|
|
||||||
|
var directory = AppContext.BaseDirectory;
|
||||||
|
directory = directory.Replace("\\", "/");
|
||||||
|
|
||||||
|
var filePath = $"{directory}/{fileName}";
|
||||||
|
if (!File.Exists(filePath))
|
||||||
|
{
|
||||||
|
var length = directory.IndexOf("/bin");
|
||||||
|
filePath = $"{directory.Substring(0, length)}/{fileName}";
|
||||||
|
}
|
||||||
|
|
||||||
|
var builder = new ConfigurationBuilder().AddJsonFile(filePath, false, true);
|
||||||
|
|
||||||
|
_configuration = builder.Build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetSectionValue(string key)
|
||||||
|
{
|
||||||
|
return _configuration.GetSection(key).Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
using Autofac;
|
||||||
|
using Autofac.Integration.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Text;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using System.Linq;
|
||||||
|
namespace Mini.Common
|
||||||
|
{
|
||||||
|
public class ContainerManager
|
||||||
|
{
|
||||||
|
public static Autofac.IContainer container = null;
|
||||||
|
|
||||||
|
public static T Resolve<T>()
|
||||||
|
{
|
||||||
|
return container.Resolve<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T ResolveNamed<T>(string name)
|
||||||
|
{
|
||||||
|
return container.ResolveNamed<T>(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void InitContainer()
|
||||||
|
{
|
||||||
|
var typeFinder = new WebAppTypeFinder();
|
||||||
|
|
||||||
|
var containerBuilder = new ContainerBuilder();
|
||||||
|
|
||||||
|
var types = typeFinder.FindClassesOfType(typeof(IDependencyRegistrar));
|
||||||
|
var drInstances = new List<IDependencyRegistrar>();
|
||||||
|
foreach (var drType in types)
|
||||||
|
{
|
||||||
|
drInstances.Add((IDependencyRegistrar)Activator.CreateInstance(drType));
|
||||||
|
//LogHelper.Info(drType.ToString());
|
||||||
|
}
|
||||||
|
drInstances = drInstances.AsQueryable().OrderBy(t => t.Order).ToList();
|
||||||
|
//register all provided dependencies
|
||||||
|
foreach (var dependencyRegistrar in drInstances)
|
||||||
|
{
|
||||||
|
dependencyRegistrar.Register(containerBuilder, typeFinder);
|
||||||
|
}
|
||||||
|
container = containerBuilder.Build();
|
||||||
|
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,162 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Common
|
||||||
|
{
|
||||||
|
public static class DateTimeTool
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取指定日期所在周的第一天,星期天为第一天
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dateTime"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DateTime GetDateTimeWeekFirstDaySun(DateTime dateTime)
|
||||||
|
{
|
||||||
|
DateTime firstWeekDay = DateTime.Now;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//得到是星期几,然后从当前日期减去相应天数
|
||||||
|
int weeknow = Convert.ToInt32(dateTime.DayOfWeek);
|
||||||
|
|
||||||
|
int daydiff = (-1) * weeknow;
|
||||||
|
|
||||||
|
firstWeekDay = dateTime.AddDays(daydiff);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
return firstWeekDay;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取指定日期所在周的第一天,星期一为第一天
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dateTime"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DateTime GetDateTimeWeekFirstDayMon(DateTime dateTime)
|
||||||
|
{
|
||||||
|
DateTime firstWeekDay = DateTime.Now;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int weeknow = Convert.ToInt32(dateTime.DayOfWeek);
|
||||||
|
|
||||||
|
//星期一为第一天,weeknow等于0时,要向前推6天。
|
||||||
|
weeknow = (weeknow == 0 ? (7 - 1) : (weeknow - 1));
|
||||||
|
|
||||||
|
int daydiff = (-1) * weeknow;
|
||||||
|
|
||||||
|
firstWeekDay = dateTime.AddDays(daydiff);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
return firstWeekDay;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取指定日期所在周的最后一天,星期六为最后一天
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dateTime"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DateTime GetDateTimeWeekLastDaySat(DateTime dateTime)
|
||||||
|
{
|
||||||
|
DateTime lastWeekDay = DateTime.Now;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int weeknow = Convert.ToInt32(dateTime.DayOfWeek);
|
||||||
|
|
||||||
|
int daydiff = (7 - weeknow) - 1;
|
||||||
|
|
||||||
|
lastWeekDay = dateTime.AddDays(daydiff);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
return lastWeekDay;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取指定日期所在周的最后一天,星期天为最后一天
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dateTime"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
|
||||||
|
public static DateTime GetDateTimeWeekLastDaySun(DateTime dateTime)
|
||||||
|
{
|
||||||
|
DateTime lastWeekDay = DateTime.Now;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int weeknow = Convert.ToInt32(dateTime.DayOfWeek);
|
||||||
|
|
||||||
|
weeknow = (weeknow == 0 ? 7 : weeknow);
|
||||||
|
|
||||||
|
int daydiff = (7 - weeknow);
|
||||||
|
|
||||||
|
lastWeekDay = dateTime.AddDays(daydiff);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
return lastWeekDay;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取指定日期的月份第一天
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dateTime"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DateTime GetDateTimeMonthFirstDay(DateTime dateTime)
|
||||||
|
{
|
||||||
|
if (dateTime == null)
|
||||||
|
{
|
||||||
|
dateTime = DateTime.Now;
|
||||||
|
}
|
||||||
|
return new DateTime(dateTime.Year, dateTime.Month, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取指定月份最后一天
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dateTime"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DateTime GetDateTimeMonthLastDay(DateTime dateTime)
|
||||||
|
{
|
||||||
|
int day = DateTime.DaysInMonth(dateTime.Year, dateTime.Month);
|
||||||
|
|
||||||
|
return new DateTime(dateTime.Year, dateTime.Month, day);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 时间戳转为C#格式时间
|
||||||
|
/// </summary>
|
||||||
|
/// <param name=”timeStamp”></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DateTime GetTimeFromLinuxTime(long timeStamp)
|
||||||
|
{
|
||||||
|
System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||||
|
dtDateTime = dtDateTime.AddMilliseconds(timeStamp).ToLocalTime();
|
||||||
|
return dtDateTime;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 时间戳转为C#格式时间
|
||||||
|
/// </summary>
|
||||||
|
/// <param name=”timeStamp”></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DateTime GetTimeFromLinuxShortTime(long timeStamp)
|
||||||
|
{
|
||||||
|
DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
|
||||||
|
long lTime = long.Parse(timeStamp.ToString() + "0000000");
|
||||||
|
TimeSpan toNow = new TimeSpan(lTime); return dtStart.Add(toNow);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// DateTime时间格式转换为Unix时间戳格式
|
||||||
|
/// </summary>
|
||||||
|
/// <param name=”time”></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int ConvertDateTimeInt(System.DateTime time)
|
||||||
|
{
|
||||||
|
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
|
||||||
|
return (int)(time - startTime).TotalSeconds;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,283 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using System.Linq;
|
||||||
|
namespace Mini.Common
|
||||||
|
{
|
||||||
|
public class FileUnit
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 连接基路径和子路径,比如把 c: 与 test.doc 连接成 c:\test.doc
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="basePath">基路径,范例:c:</param>
|
||||||
|
/// <param name="subPath">子路径,可以是文件名, 范例:test.doc</param>
|
||||||
|
public static string JoinPath(string basePath, string subPath)
|
||||||
|
{
|
||||||
|
basePath = basePath.TrimEnd('/').TrimEnd('\\');
|
||||||
|
subPath = subPath.TrimStart('/').TrimStart('\\');
|
||||||
|
string path = basePath + "\\" + subPath;
|
||||||
|
return path.Replace("/", "\\").ToLower();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取系统物理路径
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetBaseDirectory()
|
||||||
|
{
|
||||||
|
string path = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新建文件夹并写入文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folderPath">文件夹相对路径(/文件夹/)</param>
|
||||||
|
/// <param name="fileName">文件名(abc.txt)</param>
|
||||||
|
/// <param name="content">内容</param>
|
||||||
|
public static void WriteWithDirectory(string folderPath, string fileName, string content)
|
||||||
|
{
|
||||||
|
// string absoluteFlolder = GetBaseDirectory() + folderPath;
|
||||||
|
if (!Directory.Exists(folderPath))//判断文件夹是否存在
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(folderPath);//不存在则创建文件夹
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(fileName))
|
||||||
|
{
|
||||||
|
fileName = string.Format("{0:yyMMddHHmmss}.txt", DateTime.Now);
|
||||||
|
}
|
||||||
|
string absolutefile = Path.Combine(folderPath, fileName);
|
||||||
|
Write(absolutefile, content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AppendFile(string folderPath, string fileName, string content)
|
||||||
|
{
|
||||||
|
// string absoluteFlolder = GetBaseDirectory() + folderPath;
|
||||||
|
if (!Directory.Exists(folderPath))//判断文件夹是否存在
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(folderPath);//不存在则创建文件夹
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(fileName))
|
||||||
|
{
|
||||||
|
fileName = string.Format("{0:yyMMddHHmmss}.txt", DateTime.Now);
|
||||||
|
}
|
||||||
|
string absolutefile = Path.Combine(folderPath, fileName);
|
||||||
|
WriteLine(absolutefile, content);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新建文件夹并写入文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folderPath">文件夹相对路径(/文件夹/)</param>
|
||||||
|
/// <param name="fileName">文件名</param>
|
||||||
|
/// <param name="stream"></param>
|
||||||
|
public static void WriteWithDirectory(string folderPath, string fileName, Stream stream)
|
||||||
|
{
|
||||||
|
// string absoluteFlolder = GetBaseDirectory() + folderPath;
|
||||||
|
if (!Directory.Exists(folderPath))//判断文件夹是否存在
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(folderPath);//不存在则创建文件夹
|
||||||
|
}
|
||||||
|
string absolutefile = folderPath + fileName;
|
||||||
|
byte[] buffer = new byte[stream.Length];
|
||||||
|
stream.Read(buffer, 0, buffer.Length); //将流的内容读到缓冲区
|
||||||
|
FileStream fs = new FileStream(absolutefile, FileMode.OpenOrCreate, FileAccess.Write);
|
||||||
|
fs.Write(buffer, 0, buffer.Length);
|
||||||
|
fs.Flush();
|
||||||
|
fs.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将字符串写入文件,文件不存在则创建
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">文件的绝对路径</param>
|
||||||
|
/// <param name="content">数据</param>
|
||||||
|
public static void Write(string filePath, string content)
|
||||||
|
{
|
||||||
|
Write(filePath, StringToBytes(content));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将字符串写入文件,文件不存在则创建
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">文件的绝对路径</param>
|
||||||
|
/// <param name="content">数据</param>
|
||||||
|
public static void Write(string filePath, byte[] bytes)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(filePath))
|
||||||
|
return;
|
||||||
|
if (bytes == null)
|
||||||
|
return;
|
||||||
|
System.IO.File.WriteAllBytes(filePath, bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteLine(string filePath, string contents)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(filePath))
|
||||||
|
return;
|
||||||
|
if (contents == null)
|
||||||
|
return;
|
||||||
|
System.IO.File.AppendAllText(filePath, contents);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 字符串转换成字节数组
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">数据,默认字符编码utf-8</param>
|
||||||
|
public static byte[] StringToBytes(string data)
|
||||||
|
{
|
||||||
|
return StringToBytes(data, Encoding.GetEncoding("utf-8"));
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 字符串转换成字节数组
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">数据</param>
|
||||||
|
/// <param name="encoding">字符编码</param>
|
||||||
|
public static byte[] StringToBytes(string data, Encoding encoding)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(data))
|
||||||
|
return new byte[] { };
|
||||||
|
return encoding.GetBytes(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePaths">文件集合的绝对路径</param>
|
||||||
|
public static void Delete(IEnumerable<string> filePaths)
|
||||||
|
{
|
||||||
|
foreach (var filePath in filePaths)
|
||||||
|
Delete(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">文件的绝对路径</param>
|
||||||
|
public static void Delete(string filePath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(filePath))
|
||||||
|
return;
|
||||||
|
System.IO.File.Delete(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除文件和文件夹
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath"></param>
|
||||||
|
public static void DeleteDirectory(IEnumerable<string> filePaths)
|
||||||
|
{
|
||||||
|
foreach (var filePath in filePaths)
|
||||||
|
{
|
||||||
|
DeleteDirectory(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除文件夹和文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath"></param>
|
||||||
|
private static void DeleteDirectory(string filePath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(filePath))
|
||||||
|
return;
|
||||||
|
var listpath = GetAllFiles(filePath);
|
||||||
|
Delete(listpath);
|
||||||
|
Directory.Delete(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取目录中全部文件列表,包括子目录
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryPath">目录绝对路径</param>
|
||||||
|
public static List<string> GetAllFiles(string directoryPath)
|
||||||
|
{
|
||||||
|
return Directory.GetFiles(directoryPath, "*.*", SearchOption.AllDirectories).ToList();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取文件目录
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryPath"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<string> GetAllDirectory(string directoryPath)
|
||||||
|
{
|
||||||
|
return Directory.GetDirectories(directoryPath, "*", SearchOption.TopDirectoryOnly).ToList();
|
||||||
|
}
|
||||||
|
#region Read(读取文件到字符串)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取文件到字符串
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">文件的绝对路径</param>
|
||||||
|
public static string Read(string filePath)
|
||||||
|
{
|
||||||
|
return Read(filePath, Encoding.GetEncoding("utf-8"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取文件到字符串
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">文件的绝对路径</param>
|
||||||
|
/// <param name="encoding">字符编码</param>
|
||||||
|
public static string Read(string filePath, Encoding encoding)
|
||||||
|
{
|
||||||
|
if (!System.IO.File.Exists(filePath))
|
||||||
|
return string.Empty;
|
||||||
|
using (var reader = new StreamReader(filePath, encoding))
|
||||||
|
{
|
||||||
|
return reader.ReadToEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ReadToBytes(将文件读取到字节流中)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将文件读取到字节流中
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">文件的绝对路径</param>
|
||||||
|
public static byte[] ReadToBytes(string filePath)
|
||||||
|
{
|
||||||
|
if (!System.IO.File.Exists(filePath))
|
||||||
|
return null;
|
||||||
|
FileInfo fileInfo = new FileInfo(filePath);
|
||||||
|
int fileSize = (int)fileInfo.Length;
|
||||||
|
using (BinaryReader reader = new BinaryReader(fileInfo.Open(FileMode.Open)))
|
||||||
|
{
|
||||||
|
return reader.ReadBytes(fileSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取文件MD5值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName">文件绝对路径</param>
|
||||||
|
/// <returns>MD5值</returns>
|
||||||
|
public static string GetMD5HashFromFile(string fileName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileStream file = new FileStream(fileName, FileMode.Open);
|
||||||
|
System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
|
||||||
|
byte[] retVal = md5.ComputeHash(file);
|
||||||
|
file.Close();
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i = 0; i < retVal.Length; i++)
|
||||||
|
{
|
||||||
|
sb.Append(retVal[i].ToString("x2"));
|
||||||
|
}
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception("GetMD5HashFromFile() fail,error:" + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace Mini.Common
|
||||||
|
{
|
||||||
|
public class HtmlHelper
|
||||||
|
{
|
||||||
|
public static string NoHTML(string Htmlstring)
|
||||||
|
{
|
||||||
|
if (Htmlstring.Length > 0)
|
||||||
|
{
|
||||||
|
//删除脚本
|
||||||
|
Htmlstring = Regex.Replace(Htmlstring, @"<script[^>]*?>.*?</script>", "", RegexOptions.IgnoreCase);
|
||||||
|
//删除HTML
|
||||||
|
Htmlstring = Regex.Replace(Htmlstring, @"<(.[^>]*)>", "", RegexOptions.IgnoreCase);
|
||||||
|
Htmlstring = Regex.Replace(Htmlstring, @"([\r\n])[\s]+", "", RegexOptions.IgnoreCase);
|
||||||
|
Htmlstring = Regex.Replace(Htmlstring, @"-->", "", RegexOptions.IgnoreCase);
|
||||||
|
Htmlstring = Regex.Replace(Htmlstring, @"<!--.*", "", RegexOptions.IgnoreCase);
|
||||||
|
Htmlstring = Regex.Replace(Htmlstring, @"&(quot|#34);", "\"", RegexOptions.IgnoreCase);
|
||||||
|
Htmlstring = Regex.Replace(Htmlstring, @"&(amp|#38);", "&", RegexOptions.IgnoreCase);
|
||||||
|
Htmlstring = Regex.Replace(Htmlstring, @"&(lt|#60);", "<", RegexOptions.IgnoreCase);
|
||||||
|
Htmlstring = Regex.Replace(Htmlstring, @"&(gt|#62);", ">", RegexOptions.IgnoreCase);
|
||||||
|
Htmlstring = Regex.Replace(Htmlstring, @"&(nbsp|#160);", " ", RegexOptions.IgnoreCase);
|
||||||
|
Htmlstring = Regex.Replace(Htmlstring, @"&(iexcl|#161);", "\xa1", RegexOptions.IgnoreCase);
|
||||||
|
Htmlstring = Regex.Replace(Htmlstring, @"&(cent|#162);", "\xa2", RegexOptions.IgnoreCase);
|
||||||
|
Htmlstring = Regex.Replace(Htmlstring, @"&(pound|#163);", "\xa3", RegexOptions.IgnoreCase);
|
||||||
|
Htmlstring = Regex.Replace(Htmlstring, @"&(copy|#169);", "\xa9", RegexOptions.IgnoreCase);
|
||||||
|
Htmlstring = Regex.Replace(Htmlstring, @"&#(\d+);", "", RegexOptions.IgnoreCase);
|
||||||
|
Htmlstring = Regex.Replace(Htmlstring, @"“", "\"", RegexOptions.IgnoreCase);//保留【 “ 】的标点符合
|
||||||
|
Htmlstring = Regex.Replace(Htmlstring, @"”", "\"", RegexOptions.IgnoreCase);//保留【 ” 】的标点符合
|
||||||
|
Htmlstring.Replace("<", "");
|
||||||
|
Htmlstring.Replace(">", "");
|
||||||
|
Htmlstring.Replace("\r\n", "");
|
||||||
|
Htmlstring = WebUtility.UrlEncode(Htmlstring).Trim();
|
||||||
|
}
|
||||||
|
return Htmlstring;
|
||||||
|
}
|
||||||
|
public static string ClearHtml(string Content)
|
||||||
|
{
|
||||||
|
Content = Zxj_ReplaceHtml("&#[^>]*;", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?marquee[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?object[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?param[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?embed[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?table[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml(" ", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?tr[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?th[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?p[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?a[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?img[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?tbody[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?li[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?span[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?div[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?th[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?td[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?script[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("(javascript|jscript|vbscript|vbs):", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("on(mouse|exit|error|click|key)", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("<\\?xml[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("<\\/?[a-z]+:[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?font[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?b[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?u[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?i[^>]*>", "", Content);
|
||||||
|
Content = Zxj_ReplaceHtml("</?strong[^>]*>", "", Content);
|
||||||
|
string clearHtml = Content;
|
||||||
|
return clearHtml;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 清除文本中的Html标签
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="patrn">要替换的标签正则表达式</param>
|
||||||
|
/// <param name="strRep">替换为的内容</param>
|
||||||
|
/// <param name="content">要替换的内容</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static string Zxj_ReplaceHtml(string patrn, string strRep, string content)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(content))
|
||||||
|
{
|
||||||
|
content = "";
|
||||||
|
}
|
||||||
|
Regex rgEx = new Regex(patrn, RegexOptions.IgnoreCase);
|
||||||
|
string strTxt = rgEx.Replace(content, strRep);
|
||||||
|
return strTxt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
using Autofac;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Common
|
||||||
|
{
|
||||||
|
public interface IDependencyRegistrar
|
||||||
|
{
|
||||||
|
void Register(ContainerBuilder builder, ITypeFinder typeFinder);
|
||||||
|
int Order { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Common
|
||||||
|
{
|
||||||
|
public interface ITypeFinder
|
||||||
|
{
|
||||||
|
IList<Assembly> GetAssemblies();
|
||||||
|
|
||||||
|
IEnumerable<Type> FindClassesOfType(Type assignTypeFrom, bool onlyConcreteClasses = true);
|
||||||
|
|
||||||
|
IEnumerable<Type> FindClassesOfType(Type assignTypeFrom, IEnumerable<Assembly> assemblies, bool onlyConcreteClasses = true);
|
||||||
|
|
||||||
|
IEnumerable<Type> FindClassesOfType<T>(bool onlyConcreteClasses = true);
|
||||||
|
|
||||||
|
IEnumerable<Type> FindClassesOfType<T>(IEnumerable<Assembly> assemblies, bool onlyConcreteClasses = true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Common
|
||||||
|
{
|
||||||
|
public class JsonHelper
|
||||||
|
{
|
||||||
|
public static T JsonDivertToObj<T>(string json)
|
||||||
|
{
|
||||||
|
return JsonConvert.DeserializeObject<T>(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ObjDivertToJson(object obj)
|
||||||
|
{
|
||||||
|
return JsonConvert.SerializeObject(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
using log4net;
|
||||||
|
using log4net.Config;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Common
|
||||||
|
{
|
||||||
|
public class LogHelper
|
||||||
|
{
|
||||||
|
|
||||||
|
private static ILog logger;
|
||||||
|
static LogHelper()
|
||||||
|
{
|
||||||
|
if (logger == null)
|
||||||
|
{
|
||||||
|
var repository = LogManager.CreateRepository("NETCoreRepository");
|
||||||
|
//log4net从log4net.config文件中读取配置信息
|
||||||
|
XmlConfigurator.Configure(repository, new FileInfo("log4net.config"));
|
||||||
|
logger = LogManager.GetLogger(repository.Name, "InfoLogger");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 普通日志
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
/// <param name="exception"></param>
|
||||||
|
public static void Info(string message, Exception exception = null)
|
||||||
|
{
|
||||||
|
if (exception == null)
|
||||||
|
logger.Info(message);
|
||||||
|
else
|
||||||
|
logger.Info(message, exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 告警日志
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
/// <param name="exception"></param>
|
||||||
|
public static void Warn(string message, Exception exception = null)
|
||||||
|
{
|
||||||
|
if (exception == null)
|
||||||
|
logger.Warn(message);
|
||||||
|
else
|
||||||
|
logger.Warn(message, exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 错误日志
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
/// <param name="exception"></param>
|
||||||
|
public static void Error(string message, Exception exception = null)
|
||||||
|
{
|
||||||
|
if (exception == null)
|
||||||
|
logger.Error(message);
|
||||||
|
else
|
||||||
|
logger.Error(message, exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
//public static ILog log = LogManager.GetLogger(typeof(LogHelper));
|
||||||
|
|
||||||
|
//public static void Error(Exception ex)
|
||||||
|
//{
|
||||||
|
// log.Error(ex);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public static void Error(string msg)
|
||||||
|
//{
|
||||||
|
// log.Error(msg);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public static void Error(string msg, Exception ex)
|
||||||
|
//{
|
||||||
|
// log.Error(msg, ex);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public static void Info(string msg)
|
||||||
|
//{
|
||||||
|
// log.Info(msg);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public static void Debug(string msg)
|
||||||
|
//{
|
||||||
|
// log.Debug(msg);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Remove="ContainerManager.cs" />
|
||||||
|
<Compile Remove="IDependencyRegistrar.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="log4net" Version="2.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.7" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.1.1" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
||||||
|
<PackageReference Include="System.Linq" Version="4.3.0" />
|
||||||
|
<PackageReference Include="System.Net.Security" Version="4.3.2" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Mini.Common
|
||||||
|
{
|
||||||
|
public class Pager
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每页行数
|
||||||
|
/// </summary>
|
||||||
|
public int rows { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 当前页是第几页
|
||||||
|
/// </summary>
|
||||||
|
public int page { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 排序方式
|
||||||
|
/// </summary>
|
||||||
|
public string order { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 排序列
|
||||||
|
/// </summary>
|
||||||
|
public string sort { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 总行数
|
||||||
|
/// </summary>
|
||||||
|
public int totalRows { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 总页数
|
||||||
|
/// </summary>
|
||||||
|
public int totalPages
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (totalRows == 0)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return (int)Math.Ceiling((float)totalRows / (float)rows);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Common
|
||||||
|
{
|
||||||
|
public class PagerUtil
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 设置分页信息
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="queryData"></param>
|
||||||
|
/// <param name="pager"></param>
|
||||||
|
public static void SetPager<T>(ref IQueryable<T> queryData, ref Pager pager)
|
||||||
|
{
|
||||||
|
//分页
|
||||||
|
pager.totalRows = queryData.Count();
|
||||||
|
if (pager.totalRows > 0)
|
||||||
|
{
|
||||||
|
if (pager.page <= 1)
|
||||||
|
{
|
||||||
|
queryData = queryData.Take(pager.rows);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
queryData = queryData.Skip((pager.page - 1) * pager.rows).Take(pager.rows);//分页
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DataTable SetPager(DataTable dt, ref Pager pager)
|
||||||
|
{
|
||||||
|
pager.totalRows = dt.Rows.Count;
|
||||||
|
if (pager.page == 0) { return dt; }
|
||||||
|
DataTable newdt = dt.Copy();
|
||||||
|
newdt.Clear();
|
||||||
|
int rowbegin = (pager.page - 1) * pager.rows;
|
||||||
|
int rowend = pager.page * pager.rows;
|
||||||
|
|
||||||
|
if (rowbegin >= dt.Rows.Count)
|
||||||
|
{ return newdt; }
|
||||||
|
|
||||||
|
if (rowend > dt.Rows.Count)
|
||||||
|
{ rowend = dt.Rows.Count; }
|
||||||
|
for (int i = rowbegin; i <= rowend - 1; i++)
|
||||||
|
{
|
||||||
|
DataRow newdr = newdt.NewRow();
|
||||||
|
DataRow dr = dt.Rows[i];
|
||||||
|
foreach (DataColumn column in dt.Columns)
|
||||||
|
{
|
||||||
|
newdr[column.ColumnName] = dr[column.ColumnName];
|
||||||
|
}
|
||||||
|
newdt.Rows.Add(newdr);
|
||||||
|
}
|
||||||
|
return newdt;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,330 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace Mini.Common
|
||||||
|
{
|
||||||
|
public class PhoneHelper
|
||||||
|
{
|
||||||
|
#region 超过8个数字的数据替换成*
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 超过8个数字的数据替换成*
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="txt"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string Replace8Number(object txt)
|
||||||
|
{
|
||||||
|
if (txt == null)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(txt.ToString()))
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
var content = txt.ToString();
|
||||||
|
//普通数字
|
||||||
|
string numReg = @"\d+";
|
||||||
|
var result = Regex.Matches(content, numReg).Cast<Match>().Select(t => t.Value).ToList();
|
||||||
|
if (result != null && result.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var s in result)
|
||||||
|
{
|
||||||
|
if (s.Length > 7)
|
||||||
|
{
|
||||||
|
content = content.Replace(s, GetHideNumber(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//下标数字
|
||||||
|
numReg = @"[₁,₂,₃,₄,₅,₆,₇,₈,₉,₀]{8,}";
|
||||||
|
result = Regex.Matches(content, numReg).Cast<Match>().Select(t => t.Value).ToList();
|
||||||
|
if (result != null && result.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var s in result)
|
||||||
|
{
|
||||||
|
if (s.Length > 7)
|
||||||
|
{
|
||||||
|
content = content.Replace(s, GetHideDownNumber(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//上标数字
|
||||||
|
numReg = @"[¹,²,³,⁴,⁵,⁶,⁷,⁸,⁹,⁰]{8,}";
|
||||||
|
result = Regex.Matches(content, numReg).Cast<Match>().Select(t => t.Value).ToList();
|
||||||
|
if (result != null && result.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var s in result)
|
||||||
|
{
|
||||||
|
if (s.Length > 7)
|
||||||
|
{
|
||||||
|
content = content.Replace(s, GetHideUpNumber(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//全角数字
|
||||||
|
numReg = @"[1,2,3,4,5,6,7,8,9,0]{8,}";
|
||||||
|
result = Regex.Matches(content, numReg).Cast<Match>().Select(t => t.Value).ToList();
|
||||||
|
if (result != null && result.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var s in result)
|
||||||
|
{
|
||||||
|
if (s.Length > 7)
|
||||||
|
{
|
||||||
|
content = content.Replace(s, GetHideRoundNumber(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
//全角数字屏蔽
|
||||||
|
public static string GetHideRoundNumber(string phoneNo)
|
||||||
|
{
|
||||||
|
string rexstr = "";
|
||||||
|
string xinghao = "";
|
||||||
|
if (phoneNo.Length == 8)
|
||||||
|
{
|
||||||
|
rexstr = @"([1,2,3,4,5,6,7,8,9,0]{2})([1,2,3,4,5,6,7,8,9,0]{4})([1,2,3,4,5,6,7,8,9,0]{2})";
|
||||||
|
xinghao = "****";
|
||||||
|
}
|
||||||
|
else if (phoneNo.Length == 9)
|
||||||
|
{
|
||||||
|
rexstr = @"([1,2,3,4,5,6,7,8,9,0]{2})([1,2,3,4,5,6,7,8,9,0]{5})([1,2,3,4,5,6,7,8,9,0]{2})";
|
||||||
|
xinghao = "*****";
|
||||||
|
}
|
||||||
|
else if (phoneNo.Length == 10)
|
||||||
|
{
|
||||||
|
rexstr = @"([1,2,3,4,5,6,7,8,9,0]{2})([1,2,3,4,5,6,7,8,9,0]{5})([1,2,3,4,5,6,7,8,9,0]{3})";
|
||||||
|
xinghao = "*****";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rexstr = @"([1,2,3,4,5,6,7,8,9,0]{3})([1,2,3,4,5,6,7,8,9,0]{" + (phoneNo.Length - 6) + @"})([1,2,3,4,5,6,7,8,9,0]{3})";
|
||||||
|
for (int i = 0; i < (phoneNo.Length - 6); i++)
|
||||||
|
{
|
||||||
|
xinghao += "*";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Regex re = new Regex(rexstr, RegexOptions.None);
|
||||||
|
phoneNo = re.Replace(phoneNo, "$1" + xinghao + "$3");
|
||||||
|
return phoneNo;
|
||||||
|
}
|
||||||
|
//上标数字屏蔽
|
||||||
|
public static string GetHideUpNumber(string phoneNo)
|
||||||
|
{
|
||||||
|
string rexstr = "";
|
||||||
|
string xinghao = "";
|
||||||
|
if (phoneNo.Length == 8)
|
||||||
|
{
|
||||||
|
rexstr = @"([¹,²,³,⁴,⁵,⁶,⁷,⁸,⁹,⁰,]{2})([¹,²,³,⁴,⁵,⁶,⁷,⁸,⁹,⁰,]{4})([¹,²,³,⁴,⁵,⁶,⁷,⁸,⁹,⁰,]{2})";
|
||||||
|
xinghao = "****";
|
||||||
|
}
|
||||||
|
else if (phoneNo.Length == 9)
|
||||||
|
{
|
||||||
|
rexstr = @"([¹,²,³,⁴,⁵,⁶,⁷,⁸,⁹,⁰,]{2})([¹,²,³,⁴,⁵,⁶,⁷,⁸,⁹,⁰,]{5})([¹,²,³,⁴,⁵,⁶,⁷,⁸,⁹,⁰,]{2})";
|
||||||
|
xinghao = "*****";
|
||||||
|
}
|
||||||
|
else if (phoneNo.Length == 10)
|
||||||
|
{
|
||||||
|
rexstr = @"([¹,²,³,⁴,⁵,⁶,⁷,⁸,⁹,⁰,]{2})([¹,²,³,⁴,⁵,⁶,⁷,⁸,⁹,⁰,]{5})([¹,²,³,⁴,⁵,⁶,⁷,⁸,⁹,⁰,]{3})";
|
||||||
|
xinghao = "*****";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rexstr = @"([¹,²,³,⁴,⁵,⁶,⁷,⁸,⁹,⁰,]{3})([¹,²,³,⁴,⁵,⁶,⁷,⁸,⁹,⁰,]{" + (phoneNo.Length - 6) + @"})([¹,²,³,⁴,⁵,⁶,⁷,⁸,⁹,⁰,]{3})";
|
||||||
|
for (int i = 0; i < (phoneNo.Length - 6); i++)
|
||||||
|
{
|
||||||
|
xinghao += "*";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Regex re = new Regex(rexstr, RegexOptions.None);
|
||||||
|
phoneNo = re.Replace(phoneNo, "$1" + xinghao + "$3");
|
||||||
|
return phoneNo;
|
||||||
|
}
|
||||||
|
//下标数字屏蔽
|
||||||
|
public static string GetHideDownNumber(string phoneNo)
|
||||||
|
{
|
||||||
|
string rexstr = "";
|
||||||
|
string xinghao = "";
|
||||||
|
if (phoneNo.Length == 8)
|
||||||
|
{
|
||||||
|
rexstr = @"([₁,₂,₃,₄,₅,₆,₇,₈,₉,₀]{2})([₁,₂,₃,₄,₅,₆,₇,₈,₉,₀]{4})([₁,₂,₃,₄,₅,₆,₇,₈,₉,₀]{2})";
|
||||||
|
xinghao = "****";
|
||||||
|
}
|
||||||
|
else if (phoneNo.Length == 9)
|
||||||
|
{
|
||||||
|
rexstr = @"([₁,₂,₃,₄,₅,₆,₇,₈,₉,₀]{2})([₁,₂,₃,₄,₅,₆,₇,₈,₉,₀]{5})([₁,₂,₃,₄,₅,₆,₇,₈,₉,₀]{2})";
|
||||||
|
xinghao = "*****";
|
||||||
|
}
|
||||||
|
else if (phoneNo.Length == 10)
|
||||||
|
{
|
||||||
|
rexstr = @"([₁,₂,₃,₄,₅,₆,₇,₈,₉,₀]{2})([₁,₂,₃,₄,₅,₆,₇,₈,₉,₀]{5})([₁,₂,₃,₄,₅,₆,₇,₈,₉,₀]{3})";
|
||||||
|
xinghao = "*****";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rexstr = @"([₁,₂,₃,₄,₅,₆,₇,₈,₉,₀]{3})([₁,₂,₃,₄,₅,₆,₇,₈,₉,₀]{" + (phoneNo.Length - 6) + @"})([₁,₂,₃,₄,₅,₆,₇,₈,₉,₀]{3})";
|
||||||
|
for (int i = 0; i < (phoneNo.Length - 6); i++)
|
||||||
|
{
|
||||||
|
xinghao += "*";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Regex re = new Regex(rexstr, RegexOptions.None);
|
||||||
|
phoneNo = re.Replace(phoneNo, "$1" + xinghao + "$3");
|
||||||
|
return phoneNo;
|
||||||
|
}
|
||||||
|
//数字屏蔽
|
||||||
|
public static string GetHideNumber(string phoneNo)
|
||||||
|
{
|
||||||
|
string rexstr = "";
|
||||||
|
string xinghao = "";
|
||||||
|
if (phoneNo.Length == 8)
|
||||||
|
{
|
||||||
|
rexstr = @"(\d{2})(\d{4})(\d{2})";
|
||||||
|
xinghao = "****";
|
||||||
|
}
|
||||||
|
else if (phoneNo.Length == 9)
|
||||||
|
{
|
||||||
|
rexstr = @"(\d{2})(\d{5})(\d{2})";
|
||||||
|
xinghao = "*****";
|
||||||
|
}
|
||||||
|
else if (phoneNo.Length == 10)
|
||||||
|
{
|
||||||
|
rexstr = @"(\d{2})(\d{5})(\d{3})";
|
||||||
|
xinghao = "*****";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rexstr = @"(\d{3})(\d{" + (phoneNo.Length - 6) + @"})(\d{3})";
|
||||||
|
for (int i = 0; i < (phoneNo.Length - 6); i++)
|
||||||
|
{
|
||||||
|
xinghao += "*";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Regex re = new Regex(rexstr, RegexOptions.None);
|
||||||
|
phoneNo = re.Replace(phoneNo, "$1" + xinghao + "$3");
|
||||||
|
return phoneNo;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 格式化以手机号码作为用户名的username
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="username"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string FormatPhoneUserName(string username)
|
||||||
|
{
|
||||||
|
string newUsername = GetFormatPhoneUserName(username);//手机号码格式化
|
||||||
|
return newUsername;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 格式化以手机号码作为用户名的username(存在多个用户名)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="username"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string FormatPhoneMoreUserName(string username)
|
||||||
|
{
|
||||||
|
string newUsername = GetFormatPhoneUserName(username);//手机号码格式化
|
||||||
|
if (string.IsNullOrEmpty(newUsername))
|
||||||
|
return newUsername;
|
||||||
|
string userNames = string.Empty;
|
||||||
|
foreach (var item in newUsername.Split(','))
|
||||||
|
{
|
||||||
|
userNames += FormatUserName(item) + ",";//用户名格式化
|
||||||
|
}
|
||||||
|
userNames = userNames.Substring(0, userNames.Length - 1);
|
||||||
|
return userNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 格式化以手机号码作为用户名的username
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="username">需要改动的用户名</param>
|
||||||
|
/// <param name="ntype"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string FormatPhoneUserNameContent(string username)
|
||||||
|
{
|
||||||
|
string newUsername = GetFormatPhoneUserName(username);//手机号码格式化
|
||||||
|
return newUsername;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 用户名
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string FormatUserName(string userName)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
用户名屏蔽规则:
|
||||||
|
1、手机号形式的按原处理规则中间几位屏蔽;
|
||||||
|
2、否则看用户名长度,小于等于5位的,第一位不屏蔽,后面的屏蔽,比如“test1”,处理后为“t****”;
|
||||||
|
3、5位以上的,用户名长度除2向下取整,再减1做为起始值,从起始值开始后面4位用*号;比如“test123”,处理后为“te****3”
|
||||||
|
*/
|
||||||
|
if (string.IsNullOrEmpty(userName))
|
||||||
|
return "";
|
||||||
|
if (userName == "未设置")
|
||||||
|
return userName;
|
||||||
|
string newUserName = userName;
|
||||||
|
//判断 是否已经在手机号屏蔽的时候屏蔽过一次
|
||||||
|
if (userName.IndexOf("*****") > -1)
|
||||||
|
{
|
||||||
|
return newUserName;
|
||||||
|
}
|
||||||
|
int nameLth = newUserName.Length;
|
||||||
|
if (nameLth <= 5)
|
||||||
|
{
|
||||||
|
newUserName = newUserName.Substring(0, 1) + GetAsterisk(nameLth - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int startIndex = nameLth / 2;
|
||||||
|
startIndex = startIndex - 1;
|
||||||
|
newUserName = newUserName.Substring(0, startIndex) + "****" + newUserName.Substring(startIndex + 4, nameLth - startIndex - 4);
|
||||||
|
}
|
||||||
|
return newUserName;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 格式化以手机号码作为用户名的username
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="username"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static string GetFormatPhoneUserName(string username)
|
||||||
|
{
|
||||||
|
string newUsername = username;
|
||||||
|
if (string.IsNullOrWhiteSpace(newUsername))
|
||||||
|
return newUsername;
|
||||||
|
while (Utility.ContainMobile(newUsername))
|
||||||
|
{
|
||||||
|
string phone = Utility.GetMobile(newUsername);
|
||||||
|
if (string.IsNullOrWhiteSpace(phone))
|
||||||
|
break;
|
||||||
|
newUsername = newUsername.Replace(phone, (phone.Substring(0, 3) + "*****" + phone.Substring(8, 3)));
|
||||||
|
}
|
||||||
|
return newUsername;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取星号
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="number">需要返回的星号数量</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static string GetAsterisk(int number)
|
||||||
|
{
|
||||||
|
string xingHao = string.Empty;
|
||||||
|
if (number == 0)
|
||||||
|
return xingHao;
|
||||||
|
for (int i = 0; i < number; i++)
|
||||||
|
{
|
||||||
|
xingHao += "*";
|
||||||
|
}
|
||||||
|
return xingHao;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,974 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace Mini.Common
|
||||||
|
{
|
||||||
|
public static class Utility
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取配置文件中的设置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetSettingByKey(string key)
|
||||||
|
{
|
||||||
|
return ConfigHelper.GetSectionValue(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DataTable 转list
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TResult"></typeparam>
|
||||||
|
/// <param name="dt"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<TResult> ToList<TResult>(this DataTable dt) where TResult : class, new()
|
||||||
|
{
|
||||||
|
|
||||||
|
//创建一个属性的列表
|
||||||
|
List<PropertyInfo> prlist = new List<PropertyInfo>();
|
||||||
|
//获取TResult的类型实例 反射的入口
|
||||||
|
Type t = typeof(TResult);
|
||||||
|
//获得TResult 的所有的Public 属性 并找出TResult属性和DataTable的列名称相同的属性(PropertyInfo) 并加入到属性列表
|
||||||
|
Array.ForEach<PropertyInfo>(t.GetProperties(), p => { if (dt.Columns.IndexOf(p.Name) != -1) prlist.Add(p); });
|
||||||
|
//创建返回的集合
|
||||||
|
List<TResult> oblist = new List<TResult>();
|
||||||
|
foreach (DataRow row in dt.Rows)
|
||||||
|
{
|
||||||
|
//创建TResult的实例
|
||||||
|
TResult ob = new TResult();
|
||||||
|
//找到对应的数据,并赋值
|
||||||
|
prlist.ForEach(p => { if (row[p.Name] != DBNull.Value) p.SetValue(ob, row[p.Name], null); });
|
||||||
|
//放入到返回的集合中.
|
||||||
|
oblist.Add(ob);
|
||||||
|
}
|
||||||
|
return oblist;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List 转为DataTable
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="entitys"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DataTable ToDataTable<T>(List<T> entitys)
|
||||||
|
{
|
||||||
|
|
||||||
|
//检查实体集合不能为空
|
||||||
|
if (entitys == null || entitys.Count < 1)
|
||||||
|
{
|
||||||
|
throw new Exception("需转换的集合为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
//取出第一个实体的所有Propertie
|
||||||
|
Type entityType = entitys[0].GetType();
|
||||||
|
PropertyInfo[] entityProperties = entityType.GetProperties();
|
||||||
|
|
||||||
|
//生成DataTable的structure
|
||||||
|
//生产代码中,应将生成的DataTable结构Cache起来,此处略
|
||||||
|
DataTable dt = new DataTable();
|
||||||
|
for (int i = 0; i < entityProperties.Length; i++)
|
||||||
|
{
|
||||||
|
//dt.Columns.Add(entityProperties[i].Name, entityProperties[i].PropertyType);
|
||||||
|
dt.Columns.Add(entityProperties[i].Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
//将所有entity添加到DataTable中
|
||||||
|
foreach (object entity in entitys)
|
||||||
|
{
|
||||||
|
//检查所有的的实体都为同一类型
|
||||||
|
if (entity.GetType() != entityType)
|
||||||
|
{
|
||||||
|
throw new Exception("要转换的集合元素类型不一致");
|
||||||
|
}
|
||||||
|
object[] entityValues = new object[entityProperties.Length];
|
||||||
|
for (int i = 0; i < entityProperties.Length; i++)
|
||||||
|
{
|
||||||
|
entityValues[i] = entityProperties[i].GetValue(entity, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
dt.Rows.Add(entityValues);
|
||||||
|
}
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List 转为DataTable需要指定类型
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="entitys"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DataTable ToOracleDataTable<T>(List<T> entitys)
|
||||||
|
{
|
||||||
|
|
||||||
|
//检查实体集合不能为空
|
||||||
|
if (entitys == null || entitys.Count < 1)
|
||||||
|
{
|
||||||
|
throw new Exception("需转换的集合为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
//取出第一个实体的所有Propertie
|
||||||
|
Type entityType = entitys[0].GetType();
|
||||||
|
PropertyInfo[] entityProperties = entityType.GetProperties();
|
||||||
|
|
||||||
|
//生成DataTable的structure
|
||||||
|
//生产代码中,应将生成的DataTable结构Cache起来,此处略
|
||||||
|
DataTable dt = new DataTable();
|
||||||
|
for (int i = 0; i < entityProperties.Length; i++)
|
||||||
|
{
|
||||||
|
Type colType = entityProperties[i].PropertyType;
|
||||||
|
if ((colType.IsGenericType) && (colType.GetGenericTypeDefinition() == typeof(Nullable<>)))
|
||||||
|
{
|
||||||
|
|
||||||
|
colType = colType.GetGenericArguments()[0];
|
||||||
|
|
||||||
|
}
|
||||||
|
dt.Columns.Add(entityProperties[i].Name, colType);
|
||||||
|
// dt.Columns.Add(entityProperties[i].Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
//将所有entity添加到DataTable中
|
||||||
|
foreach (object entity in entitys)
|
||||||
|
{
|
||||||
|
//检查所有的的实体都为同一类型
|
||||||
|
if (entity.GetType() != entityType)
|
||||||
|
{
|
||||||
|
throw new Exception("要转换的集合元素类型不一致");
|
||||||
|
}
|
||||||
|
object[] entityValues = new object[entityProperties.Length];
|
||||||
|
for (int i = 0; i < entityProperties.Length; i++)
|
||||||
|
{
|
||||||
|
entityValues[i] = entityProperties[i].GetValue(entity, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
dt.Rows.Add(entityValues);
|
||||||
|
}
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// List 转为DataTable需要指定类型
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="entitys"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DataTable ToOracleDataTableToUpper<T>(List<T> entitys)
|
||||||
|
{
|
||||||
|
//检查实体集合不能为空
|
||||||
|
if (entitys == null || entitys.Count < 1)
|
||||||
|
{
|
||||||
|
throw new Exception("需转换的集合为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
//取出第一个实体的所有Propertie
|
||||||
|
Type entityType = entitys[0].GetType();
|
||||||
|
PropertyInfo[] entityProperties = entityType.GetProperties();
|
||||||
|
|
||||||
|
//生成DataTable的structure
|
||||||
|
//生产代码中,应将生成的DataTable结构Cache起来,此处略
|
||||||
|
DataTable dt = new DataTable();
|
||||||
|
for (int i = 0; i < entityProperties.Length; i++)
|
||||||
|
{
|
||||||
|
Type colType = entityProperties[i].PropertyType;
|
||||||
|
if ((colType.IsGenericType) && (colType.GetGenericTypeDefinition() == typeof(Nullable<>)))
|
||||||
|
{
|
||||||
|
|
||||||
|
colType = colType.GetGenericArguments()[0];
|
||||||
|
|
||||||
|
}
|
||||||
|
dt.Columns.Add(entityProperties[i].Name.ToUpper(), colType);
|
||||||
|
// dt.Columns.Add(entityProperties[i].Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
//将所有entity添加到DataTable中
|
||||||
|
foreach (object entity in entitys)
|
||||||
|
{
|
||||||
|
//检查所有的的实体都为同一类型
|
||||||
|
if (entity.GetType() != entityType)
|
||||||
|
{
|
||||||
|
throw new Exception("要转换的集合元素类型不一致");
|
||||||
|
}
|
||||||
|
object[] entityValues = new object[entityProperties.Length];
|
||||||
|
for (int i = 0; i < entityProperties.Length; i++)
|
||||||
|
{
|
||||||
|
entityValues[i] = entityProperties[i].GetValue(entity, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
dt.Rows.Add(entityValues);
|
||||||
|
}
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 把DataTable转成 List集合, 存每一行,集合中放的是键值对字典,存每一列
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dt">数据表</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<Dictionary<string, object>> DataTableToList(DataTable dt)
|
||||||
|
{
|
||||||
|
List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
|
||||||
|
|
||||||
|
foreach (DataRow dr in dt.Rows)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> dic = new Dictionary<string, object>();
|
||||||
|
foreach (DataColumn dc in dt.Columns)
|
||||||
|
{
|
||||||
|
dic.Add(dc.ColumnName, dr[dc.ColumnName].ToString());
|
||||||
|
}
|
||||||
|
list.Add(dic);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region 加密 解密
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// DES加密偏移量,必须是>=8位长的字符串
|
||||||
|
private static string iv = "1234567890";
|
||||||
|
|
||||||
|
// DES加密的私钥,必须是8位长的字符串DES
|
||||||
|
private static string key = "12345678";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 对字符串加密后进行编码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sourceString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string EncryptUrlEncode(string sourceString)
|
||||||
|
{
|
||||||
|
sourceString = Encrypt(sourceString);
|
||||||
|
|
||||||
|
return HttpUtility.UrlEncode(sourceString, Encoding.UTF8);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 对字符串解码后解密
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sourceString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string DecryptUrlDecode(string sourceString)
|
||||||
|
{
|
||||||
|
if (sourceString.IndexOf("%") > -1)
|
||||||
|
sourceString = HttpUtility.UrlDecode(sourceString, Encoding.UTF8);
|
||||||
|
|
||||||
|
return Decrypt(sourceString);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 对字符串进行DES加密
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sourceString">待加密的字符串</param>
|
||||||
|
/// <returns>加密后的BASE64编码的字符串</returns>
|
||||||
|
public static string Encrypt(string sourceString)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(sourceString))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
byte[] btKey = Encoding.Default.GetBytes(key);
|
||||||
|
byte[] btIV = Encoding.Default.GetBytes(iv);
|
||||||
|
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
|
||||||
|
using (MemoryStream ms = new MemoryStream())
|
||||||
|
{
|
||||||
|
byte[] inData = Encoding.Default.GetBytes(sourceString);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(btKey, btIV), CryptoStreamMode.Write))
|
||||||
|
{
|
||||||
|
cs.Write(inData, 0, inData.Length);
|
||||||
|
cs.FlushFinalBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Convert.ToBase64String(ms.ToArray());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 对DES加密后的字符串进行解密
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="encryptedString">待解密的字符串</param>
|
||||||
|
/// <returns>解密后的字符串</returns>
|
||||||
|
public static string Decrypt(string encryptedString)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(encryptedString))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
byte[] btKey = Encoding.Default.GetBytes(key);
|
||||||
|
byte[] btIV = Encoding.Default.GetBytes(iv);
|
||||||
|
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
|
||||||
|
|
||||||
|
using (MemoryStream ms = new MemoryStream())
|
||||||
|
{
|
||||||
|
byte[] inData = Convert.FromBase64String(encryptedString);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(btKey, btIV), CryptoStreamMode.Write))
|
||||||
|
{
|
||||||
|
cs.Write(inData, 0, inData.Length);
|
||||||
|
cs.FlushFinalBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Encoding.Default.GetString(ms.ToArray());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static string Left(string sSource, int iLength)
|
||||||
|
{
|
||||||
|
return sSource.Substring(0, iLength > sSource.Length ? sSource.Length : iLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Right(string sSource, int iLength)
|
||||||
|
{
|
||||||
|
return sSource.Substring(iLength > sSource.Length ? 0 : sSource.Length - iLength);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// md5加密
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string EncryptMD5(string input)
|
||||||
|
{
|
||||||
|
string output = null;
|
||||||
|
if (string.IsNullOrEmpty(input))
|
||||||
|
{
|
||||||
|
output = input;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
|
||||||
|
byte[] bytes = Encoding.UTF8.GetBytes(input);
|
||||||
|
string result = BitConverter.ToString(md5.ComputeHash(bytes));
|
||||||
|
return result.Replace("-", "");
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 进行DES解密。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pToDecrypt">要解密的串</param>
|
||||||
|
/// <param name="sKey">密钥,且必须为8位。</param>
|
||||||
|
/// <returns>已解密的字符串。</returns>
|
||||||
|
public static string DecryptDES(string source, string sKey)
|
||||||
|
{
|
||||||
|
byte[] inputByteArray = System.Convert.FromBase64String(source);//Encoding.UTF8.GetBytes(source);
|
||||||
|
using (DESCryptoServiceProvider des = new DESCryptoServiceProvider())
|
||||||
|
{
|
||||||
|
des.Mode = CipherMode.ECB;
|
||||||
|
des.Key = ASCIIEncoding.ASCII.GetBytes(sKey.Substring(0, 8));
|
||||||
|
des.IV = ASCIIEncoding.ASCII.GetBytes(sKey.Substring(0, 8));
|
||||||
|
System.IO.MemoryStream ms = new System.IO.MemoryStream();
|
||||||
|
using (CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write))
|
||||||
|
{
|
||||||
|
cs.Write(inputByteArray, 0, inputByteArray.Length);
|
||||||
|
cs.FlushFinalBlock();
|
||||||
|
cs.Close();
|
||||||
|
}
|
||||||
|
string str = Encoding.UTF8.GetString(ms.ToArray());
|
||||||
|
ms.Close();
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///时间格式化
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dt">返回字符串的类型(默认4)
|
||||||
|
///例子: 2014/05/08 19:14:17
|
||||||
|
///type=1 2014/05/08 没有时分秒
|
||||||
|
///type=2 2014/05/08 19:14 没有秒
|
||||||
|
///type=3 14/05/08 19:14 没有年前两位和秒
|
||||||
|
///type=4 05/08 19:14 没有年和秒
|
||||||
|
/// </param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string ToUnityString(this DateTime dt, int type = 4)
|
||||||
|
{
|
||||||
|
if (dt == DateTime.MinValue)
|
||||||
|
return "";
|
||||||
|
string formartStr = string.Empty;
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case 1: formartStr = "yyyy/MM/dd"; break;
|
||||||
|
case 2: formartStr = "yyyy/MM/dd HH:mm"; break;
|
||||||
|
case 3: formartStr = "yy/MM/dd HH:mm"; break;
|
||||||
|
case 4: formartStr = "MM/dd HH:mm"; break;
|
||||||
|
case 5: formartStr = "yyyyMM"; break;
|
||||||
|
case 6: formartStr = "yyyy-MM-dd"; break;
|
||||||
|
case 7: formartStr = "yyyy-MM-dd HH:mm:ss"; break;
|
||||||
|
}
|
||||||
|
return dt.ToString(formartStr);
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///时间格式化
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dt">返回字符串的类型(默认4)
|
||||||
|
///例子: 2014/05/08 19:14:17
|
||||||
|
///type=1 2014/05/08 没有时分秒
|
||||||
|
///type=2 2014/05/08 19:14 没有秒
|
||||||
|
///type=3 14/05/08 19:14 没有年前两位和秒
|
||||||
|
///type=4 05/08 19:14 没有年和秒
|
||||||
|
/// </param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string ToUnityString(this DateTime? dt, int type = 4)
|
||||||
|
{
|
||||||
|
if (dt == null || dt.Value == DateTime.MinValue)
|
||||||
|
return "";
|
||||||
|
string formartStr = string.Empty;
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case 1: formartStr = "yyyy/MM/dd"; break;
|
||||||
|
case 2: formartStr = "yyyy/MM/dd HH:mm"; break;
|
||||||
|
case 3: formartStr = "yy/MM/dd HH:mm"; break;
|
||||||
|
case 4: formartStr = "MM/dd HH:mm"; break;
|
||||||
|
case 5: formartStr = "yyyyMM"; break;
|
||||||
|
case 6: formartStr = "yyyy-MM-dd"; break;
|
||||||
|
}
|
||||||
|
return dt.Value.ToString(formartStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 枚举
|
||||||
|
|
||||||
|
public static string GetEnumName<T>(int i)
|
||||||
|
{
|
||||||
|
string name = null;
|
||||||
|
string[] names = Enum.GetNames(typeof(T));
|
||||||
|
if (i < names.Length)
|
||||||
|
{
|
||||||
|
name = names[i];
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static string GetEnumNameByValue<T>(int i)
|
||||||
|
{
|
||||||
|
string name = Enum.GetName(typeof(T), i);
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetCheckEnumNameByValue<T>(int i)
|
||||||
|
{
|
||||||
|
string name = i.ToString();
|
||||||
|
if (Enum.IsDefined(typeof(T), i))
|
||||||
|
name = Enum.GetName(typeof(T), i);
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region JSON
|
||||||
|
public static T JSONToObject<T>(string json)
|
||||||
|
{
|
||||||
|
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(json);
|
||||||
|
|
||||||
|
}
|
||||||
|
public static string ConvertToJSON<T>(IList<T> list)
|
||||||
|
{
|
||||||
|
return Newtonsoft.Json.JsonConvert.SerializeObject(list);
|
||||||
|
}
|
||||||
|
public static string ConvertToJSON<T>(T obj)
|
||||||
|
{
|
||||||
|
return Newtonsoft.Json.JsonConvert.SerializeObject(obj);
|
||||||
|
}
|
||||||
|
public static string ObjectToJson<T>(T t)
|
||||||
|
{
|
||||||
|
return Newtonsoft.Json.JsonConvert.SerializeObject(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region 十进制转六十四进制
|
||||||
|
static string[] SubstrSplit(string str, int lenStep)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(str))
|
||||||
|
return null;
|
||||||
|
int L = str.Length % lenStep;
|
||||||
|
if (L > 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < lenStep - L; i++)
|
||||||
|
{
|
||||||
|
str = "0" + str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
string tem = "";
|
||||||
|
while (str.Length >= lenStep)
|
||||||
|
{
|
||||||
|
if (str.Length > lenStep)
|
||||||
|
tem += string.Format(",{0}", str.Substring(0, lenStep));
|
||||||
|
else
|
||||||
|
tem += string.Format(",{0}", str);
|
||||||
|
str = str.Substring(lenStep);
|
||||||
|
}
|
||||||
|
tem = tem.Trim(',');
|
||||||
|
return tem.Split(',');
|
||||||
|
}
|
||||||
|
public static string Conver10To64Ext(long d10)
|
||||||
|
{
|
||||||
|
string str64 = "";
|
||||||
|
string[] fhs = "0,1,2,3,4,5,6,7,8,9,@,-,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z".Split(',');
|
||||||
|
string binStr = Convert.ToString(d10, 2);
|
||||||
|
string[] bstrForLenStep = SubstrSplit(binStr, 6);
|
||||||
|
if (bstrForLenStep == null)
|
||||||
|
return "";
|
||||||
|
for (int j = 0; j < bstrForLenStep.Length; j++)
|
||||||
|
{
|
||||||
|
int index = Convert.ToInt32(bstrForLenStep[j], 2);
|
||||||
|
str64 += string.Format("{0}", fhs[index]);
|
||||||
|
}
|
||||||
|
return str64;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region unix 时间转换
|
||||||
|
/// <summary>
|
||||||
|
/// 将Unix时间戳转换为DateTime类型时间
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="d">double 型数字</param>
|
||||||
|
/// <returns>DateTime</returns>
|
||||||
|
public static System.DateTime ConvertIntDateTime(double d)
|
||||||
|
{
|
||||||
|
System.DateTime time = System.DateTime.MinValue;
|
||||||
|
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
|
||||||
|
time = startTime.AddSeconds(d);
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将c# DateTime时间格式转换为Unix时间戳格式
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="time">时间</param>
|
||||||
|
/// <returns>double</returns>
|
||||||
|
public static double ConvertDateTimeInt(System.DateTime time)
|
||||||
|
{
|
||||||
|
double intResult = 0;
|
||||||
|
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
|
||||||
|
intResult = (time - startTime).TotalSeconds;
|
||||||
|
return intResult;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="timeJavaLong">java长整型日期,毫秒为单位</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DateTime JavaLongToDateTime(long timeJavaLong)
|
||||||
|
{
|
||||||
|
var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0);
|
||||||
|
var tricks1970 = dt1970.Ticks;//1970年1月1日刻度
|
||||||
|
var timeTricks = tricks1970 + timeJavaLong * 10000;//日志日期刻度
|
||||||
|
return new DateTime(timeTricks).AddHours(8);//转化为DateTime
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 检查是否手机号
|
||||||
|
/// <summary>
|
||||||
|
/// 00852+8位是香港的电话
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="number"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool ChekMobile(string number)
|
||||||
|
{
|
||||||
|
string rgs = @"^(13|14|15|17|18|0085)\d{9}$";
|
||||||
|
Regex reg = new Regex(rgs);
|
||||||
|
return reg.IsMatch(number);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 检查是否包含手机号码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="number"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool ContainMobile(string number)
|
||||||
|
{
|
||||||
|
string rgs = @".*(11|12|13|14|15|16|17|18|19)\d{9}.*";
|
||||||
|
Regex reg = new Regex(rgs);
|
||||||
|
return reg.IsMatch(number);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 从文本中返回号码字符串
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="txt"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetMobile(string txt)
|
||||||
|
{
|
||||||
|
string rgs = @"(11|12|13|14|15|16|17|18|19)\d{9}";
|
||||||
|
string result = Regex.Match(txt, rgs).Value;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public static bool CheckIsNum(string txt)
|
||||||
|
{
|
||||||
|
string rgs = "^\\d{6,16}$";
|
||||||
|
Regex reg = new Regex(rgs);
|
||||||
|
return reg.IsMatch(txt);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsNum(string txt)
|
||||||
|
{
|
||||||
|
string rgs = "^\\d+$";
|
||||||
|
Regex reg = new Regex(rgs);
|
||||||
|
return reg.IsMatch(txt);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
public static string NumberSub(string number)
|
||||||
|
{
|
||||||
|
string Sub_0 = @"^(013|015|016|018|014|017|019)\d*$";
|
||||||
|
Regex reg = new Regex(Sub_0);
|
||||||
|
if (number.Length > 11 && reg.IsMatch(number))
|
||||||
|
return number.Substring(1);
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 验证固定电话号码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="telcode"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool ValidateTelCode(string telcode)
|
||||||
|
{
|
||||||
|
string express = @"^(0[0-9]{2,3}\-?)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$";
|
||||||
|
return ValidateInput(telcode, express);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string NumberFormat(string number)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(number) || number.Length <= 6)
|
||||||
|
{
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
return number.Substring(0, 3) +
|
||||||
|
new string('*', number.Length - 6) +
|
||||||
|
number.Substring(number.Length - 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 验证固定电话号码无下滑斜杠
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="telcode"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool ValidateTelCode2(string telcode)
|
||||||
|
{
|
||||||
|
string express = @"^\d{6,20}$";
|
||||||
|
return ValidateInput(telcode, express);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 验证数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">需验证数据</param>
|
||||||
|
/// <param name="express">正则表达式</param>
|
||||||
|
/// <returns>符合返回为true,否则返回false</returns>
|
||||||
|
public static bool ValidateInput(string data, string express)
|
||||||
|
{
|
||||||
|
Regex reg = new Regex(express);
|
||||||
|
return reg.IsMatch(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取随机数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="codeCount"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string CreateRandomSatl(int codeCount)
|
||||||
|
{
|
||||||
|
string allChar = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,w,x,y,z";
|
||||||
|
string[] allCharArray = allChar.Split(',');
|
||||||
|
string randomCode = "";
|
||||||
|
int temp = -1;
|
||||||
|
Random rand = new Random();
|
||||||
|
for (int i = 0; i < codeCount; i++)
|
||||||
|
{
|
||||||
|
if (temp != -1)
|
||||||
|
{
|
||||||
|
rand = new Random(i * temp * ((int)DateTime.Now.Ticks));
|
||||||
|
}
|
||||||
|
int t = rand.Next(50);
|
||||||
|
if (temp == t)
|
||||||
|
{
|
||||||
|
return CreateRandomSatl(codeCount);
|
||||||
|
}
|
||||||
|
temp = t;
|
||||||
|
randomCode += allCharArray[t];
|
||||||
|
}
|
||||||
|
return randomCode;
|
||||||
|
}
|
||||||
|
public static string Sha512(string value)
|
||||||
|
{
|
||||||
|
SHA512 s512 = new SHA512Managed();
|
||||||
|
byte[] bit_pwd = Encoding.Default.GetBytes(value);
|
||||||
|
byte[] bit_shapsw = s512.ComputeHash(bit_pwd);
|
||||||
|
string shapsw = Convert.ToBase64String(bit_shapsw);
|
||||||
|
return shapsw;
|
||||||
|
}
|
||||||
|
public static int PasswordStrength(string password)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(password)) return -1;
|
||||||
|
//字符统计
|
||||||
|
int iNum = 0, iLtt = 0, iSym = 0;
|
||||||
|
foreach (char c in password)
|
||||||
|
{
|
||||||
|
if (c >= '0' && c <= '9') iNum++;
|
||||||
|
else if (c >= 'a' && c <= 'z') iLtt++;
|
||||||
|
else if (c >= 'A' && c <= 'Z') iLtt++;
|
||||||
|
else iSym++;
|
||||||
|
}
|
||||||
|
if (password.Length < 6) return 3; //长度小于6的密码
|
||||||
|
if (iLtt == 0 && iSym == 0) return 1; //纯数字密码
|
||||||
|
if (iNum == 0 && iSym == 0) return 2; //纯字母密码
|
||||||
|
return 0; //正确
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static string GetSendMsgModel(string strJson, string modelParam)
|
||||||
|
{
|
||||||
|
string key = string.Empty;
|
||||||
|
string values = string.Empty;
|
||||||
|
strJson = strJson.Replace(",\"", "*\"").Replace("\":", "\"#").ToString();
|
||||||
|
|
||||||
|
Regex regex = new Regex(@"(?<={)[^}]+(?=})");
|
||||||
|
MatchCollection mc = regex.Matches(strJson);
|
||||||
|
Dictionary<string, string> list = new Dictionary<string, string>();
|
||||||
|
for (int i = 0; i < mc.Count; i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
string strRow = mc[i].Value;
|
||||||
|
string[] strRows = strRow.Split('*');
|
||||||
|
foreach (string str in strRows)
|
||||||
|
{
|
||||||
|
string[] strCell = str.Split('#');
|
||||||
|
|
||||||
|
key = strCell[0].Replace("\"", "");
|
||||||
|
values = strCell[1].Replace("\"", "");
|
||||||
|
list.Add(key, values);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
modelParam = modelParam.Replace("${" + item.Key + "}", item.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return modelParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string DateEnToCn(string date)
|
||||||
|
{
|
||||||
|
string datename = "";
|
||||||
|
date = date.ToLower();
|
||||||
|
switch (date)
|
||||||
|
{//--Monday 周一 Tuesday 周二 Wednesday 周三 Thursday 周四 Friday 周五 Saturday 周六 Sunday 周日
|
||||||
|
case "monday": datename = "星期一"; break;
|
||||||
|
case "tuesday": datename = "星期二"; break;
|
||||||
|
case "wednesday": datename = "星期三"; break;
|
||||||
|
case "thursday": datename = "星期四"; break;
|
||||||
|
case "friday": datename = "星期五"; break;
|
||||||
|
case "saturday": datename = "星期六"; break;
|
||||||
|
case "sunday": datename = "星期日"; break;
|
||||||
|
}
|
||||||
|
return datename;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将c# DateTime时间格式转换为Unix时间戳格式
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="time">时间</param>
|
||||||
|
/// <returns>long</returns>
|
||||||
|
public static long ConvertDateTimeToInt(System.DateTime time)
|
||||||
|
{
|
||||||
|
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0, 0));
|
||||||
|
long t = (time.Ticks - startTime.Ticks) / 10000; //除10000调整为13位
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 时间戳转为C#格式时间
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="timeStamp"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DateTime ConvertStringToDateTime(string timeStamp)
|
||||||
|
{
|
||||||
|
DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
|
||||||
|
long lTime = long.Parse(timeStamp + "0000");
|
||||||
|
TimeSpan toNow = new TimeSpan(lTime);
|
||||||
|
return dtStart.Add(toNow);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取文件的MD5码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName">传入的文件名(含路径及后缀名)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetMD5HashFromFile(string fileName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileStream file = new FileStream(fileName, System.IO.FileMode.Open);
|
||||||
|
MD5 md5 = new MD5CryptoServiceProvider();
|
||||||
|
byte[] retVal = md5.ComputeHash(file);
|
||||||
|
file.Close();
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i = 0; i < retVal.Length; i++)
|
||||||
|
{
|
||||||
|
sb.Append(retVal[i].ToString("x2"));
|
||||||
|
}
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception("GetMD5HashFromFile() fail,error:" + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找指定目录下的所有末级子目录
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dir">要查找的目录</param>
|
||||||
|
/// <param name="list">查找结果列表</param>
|
||||||
|
/// <param name="system">是否包含系统目录</param>
|
||||||
|
/// <param name="hidden">是否包含隐藏目录</param>
|
||||||
|
public static void GetEndDirectories(DirectoryInfo dir, List<DirectoryInfo> list, bool system = false, bool hidden = false)
|
||||||
|
{
|
||||||
|
DirectoryInfo[] sub = dir.GetDirectories();
|
||||||
|
|
||||||
|
if (sub.Length == 0)
|
||||||
|
{// 没有子目录了
|
||||||
|
list.Add(dir);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (DirectoryInfo subDir in sub)
|
||||||
|
{
|
||||||
|
// 跳过系统目录
|
||||||
|
if (!system && (subDir.Attributes & FileAttributes.System) == FileAttributes.System)
|
||||||
|
continue;
|
||||||
|
// 跳过隐藏目录
|
||||||
|
if (!hidden && (subDir.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
GetEndDirectories(subDir, list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="url"></param>
|
||||||
|
/// <param name="encoding"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetData(string Url, string RequestPara, Encoding encoding)
|
||||||
|
{
|
||||||
|
if (!String.IsNullOrEmpty(RequestPara))
|
||||||
|
RequestPara = RequestPara.IndexOf('?') > -1 ? (RequestPara) : ("?" + RequestPara);
|
||||||
|
|
||||||
|
WebRequest hr = HttpWebRequest.Create(Url + RequestPara);
|
||||||
|
|
||||||
|
byte[] buf = encoding.GetBytes(RequestPara);
|
||||||
|
hr.Method = "GET";
|
||||||
|
|
||||||
|
System.Net.WebResponse response = hr.GetResponse();
|
||||||
|
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8"));
|
||||||
|
string ReturnVal = reader.ReadToEnd();
|
||||||
|
reader.Close();
|
||||||
|
response.Close();
|
||||||
|
|
||||||
|
return ReturnVal;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="url"></param>
|
||||||
|
/// <param name="encoding"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<string> GetArryData(string Url, string RequestPara, Encoding encoding)
|
||||||
|
{
|
||||||
|
if (!String.IsNullOrEmpty(RequestPara))
|
||||||
|
RequestPara = RequestPara.IndexOf('?') > -1 ? (RequestPara) : ("?" + RequestPara);
|
||||||
|
|
||||||
|
WebRequest hr = HttpWebRequest.Create(Url + RequestPara);
|
||||||
|
|
||||||
|
byte[] buf = encoding.GetBytes(RequestPara);
|
||||||
|
hr.Method = "GET";
|
||||||
|
List<string> htmllist = new List<string>();
|
||||||
|
System.Net.WebResponse response = hr.GetResponse();
|
||||||
|
using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8")))
|
||||||
|
{
|
||||||
|
while (!reader.EndOfStream)
|
||||||
|
{
|
||||||
|
htmllist.Add(reader.ReadLine());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response.Close();
|
||||||
|
return htmllist;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="url"></param>
|
||||||
|
/// <param name="encoding"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetNewUrlData(string Url, string RequestPara, Encoding encoding)
|
||||||
|
{
|
||||||
|
if (!String.IsNullOrEmpty(RequestPara))
|
||||||
|
RequestPara = RequestPara.IndexOf('?') > -1 ? (RequestPara) : ("?" + RequestPara);
|
||||||
|
|
||||||
|
WebRequest hr = HttpWebRequest.Create(Url + RequestPara);
|
||||||
|
|
||||||
|
hr.Method = "GET";
|
||||||
|
System.Net.WebResponse response = hr.GetResponse();
|
||||||
|
string r= response.ResponseUri.AbsoluteUri;
|
||||||
|
|
||||||
|
response.Close();
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// MD5 16位加密 加密后密码为小写
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ConvertString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetMd5Str16(string ConvertString)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider())
|
||||||
|
{
|
||||||
|
string t2 = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.Default.GetBytes(ConvertString)), 4, 8);
|
||||||
|
return t2.Replace("-", "").ToLower();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { return null; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Common
|
||||||
|
{
|
||||||
|
public class ValidationError
|
||||||
|
{
|
||||||
|
public ValidationError() { }
|
||||||
|
public string ErrorMessage { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
public class ValidationErrors : List<ValidationError>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 添加错误
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="errorMessage">信息描述</param>
|
||||||
|
public void Add(string errorMessage)
|
||||||
|
{
|
||||||
|
base.Add(new ValidationError { ErrorMessage = errorMessage });
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取错误集合
|
||||||
|
/// </summary>
|
||||||
|
public string Error
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
string error = "";
|
||||||
|
this.All(a => {
|
||||||
|
error += a.ErrorMessage;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Common
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides information about types in the current web application.
|
||||||
|
/// Optionally this class can look at all assemblies in the bin folder.
|
||||||
|
/// </summary>
|
||||||
|
public class WebAppTypeFinder : AppDomainTypeFinder
|
||||||
|
{
|
||||||
|
#region Fields
|
||||||
|
|
||||||
|
private bool _ensureBinFolderAssembliesLoaded = true;
|
||||||
|
private bool _binFolderAssembliesLoaded;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets whether assemblies in the bin folder of the web application should be specifically checked for being loaded on application load. This is need in situations where plugins need to be loaded in the AppDomain after the application been reloaded.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnsureBinFolderAssembliesLoaded
|
||||||
|
{
|
||||||
|
get { return _ensureBinFolderAssembliesLoaded; }
|
||||||
|
set { _ensureBinFolderAssembliesLoaded = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a physical disk path of \Bin directory
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The physical path. E.g. "c:\inetpub\wwwroot\bin"</returns>
|
||||||
|
public virtual string GetBinDirectory()
|
||||||
|
{
|
||||||
|
//if (HostingEnvironment.IsHosted)
|
||||||
|
//{
|
||||||
|
// //hosted
|
||||||
|
// return HttpRuntime.BinDirectory;
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
//not hosted. For example, run either in unit tests
|
||||||
|
return AppDomain.CurrentDomain.BaseDirectory;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IList<Assembly> GetAssemblies()
|
||||||
|
{
|
||||||
|
if (this.EnsureBinFolderAssembliesLoaded && !_binFolderAssembliesLoaded)
|
||||||
|
{
|
||||||
|
_binFolderAssembliesLoaded = true;
|
||||||
|
string binPath = GetBinDirectory();
|
||||||
|
//binPath = _webHelper.MapPath("~/bin");
|
||||||
|
LoadMatchingAssemblies(binPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.GetAssemblies();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.1.32228.430
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mini.Web", "Mini.Web\Mini.Web.csproj", "{7E4EED86-463B-4AE8-8572-74080CA60D61}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mini.Model", "Mini.Model\Mini.Model.csproj", "{1D1B0475-6095-4AA9-B17A-53061F0E1E6B}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mini.Services", "Mini.Services\Mini.Services.csproj", "{2C926BCA-1647-4C89-B244-459201865601}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mini.Common", "Mini.Common\Mini.Common.csproj", "{34C1F847-C0C2-452E-BC08-01AC9DF814F8}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test1", "Test1\Test1.csproj", "{2179F183-C2E6-45EB-BDEE-9535FA91494A}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsFormsApp1", "WindowsFormsApp1\WindowsFormsApp1.csproj", "{FFB66D6A-27D7-4B65-B3EB-BF059FC8B5FC}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Winform2", "Winform2\Winform2.csproj", "{3CD263D6-D43C-41CA-9CF1-DBD7E65924B1}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{7E4EED86-463B-4AE8-8572-74080CA60D61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{7E4EED86-463B-4AE8-8572-74080CA60D61}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{7E4EED86-463B-4AE8-8572-74080CA60D61}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{7E4EED86-463B-4AE8-8572-74080CA60D61}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{1D1B0475-6095-4AA9-B17A-53061F0E1E6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1D1B0475-6095-4AA9-B17A-53061F0E1E6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1D1B0475-6095-4AA9-B17A-53061F0E1E6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1D1B0475-6095-4AA9-B17A-53061F0E1E6B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{2C926BCA-1647-4C89-B244-459201865601}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{2C926BCA-1647-4C89-B244-459201865601}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{2C926BCA-1647-4C89-B244-459201865601}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{2C926BCA-1647-4C89-B244-459201865601}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{34C1F847-C0C2-452E-BC08-01AC9DF814F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{34C1F847-C0C2-452E-BC08-01AC9DF814F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{34C1F847-C0C2-452E-BC08-01AC9DF814F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{34C1F847-C0C2-452E-BC08-01AC9DF814F8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{2179F183-C2E6-45EB-BDEE-9535FA91494A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{2179F183-C2E6-45EB-BDEE-9535FA91494A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{2179F183-C2E6-45EB-BDEE-9535FA91494A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{2179F183-C2E6-45EB-BDEE-9535FA91494A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{FFB66D6A-27D7-4B65-B3EB-BF059FC8B5FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{FFB66D6A-27D7-4B65-B3EB-BF059FC8B5FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{FFB66D6A-27D7-4B65-B3EB-BF059FC8B5FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{FFB66D6A-27D7-4B65-B3EB-BF059FC8B5FC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3CD263D6-D43C-41CA-9CF1-DBD7E65924B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3CD263D6-D43C-41CA-9CF1-DBD7E65924B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3CD263D6-D43C-41CA-9CF1-DBD7E65924B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3CD263D6-D43C-41CA-9CF1-DBD7E65924B1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {0787597B-C0FA-4630-83FD-281448B0B175}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model
|
||||||
|
{
|
||||||
|
public abstract class BaseEntity
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.CrmModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 结果类
|
||||||
|
/// </summary>
|
||||||
|
public class ApiResult
|
||||||
|
{
|
||||||
|
public ApiResult() { }
|
||||||
|
public ApiResult(bool _success, int _code, string _msg, dynamic _data)
|
||||||
|
{
|
||||||
|
this.success = _success;
|
||||||
|
this.code = _code;
|
||||||
|
this.msg = _msg;
|
||||||
|
this.data = _data;
|
||||||
|
}
|
||||||
|
public ApiResult(bool _success, int _code, string _msg, dynamic _data, Laypage _page)
|
||||||
|
{
|
||||||
|
this.success = _success;
|
||||||
|
this.code = _code;
|
||||||
|
this.msg = _msg;
|
||||||
|
this.data = _data;
|
||||||
|
this.page = _page;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 是否成功
|
||||||
|
/// </summary>
|
||||||
|
public bool success { get; set; } = true;
|
||||||
|
/// <summary>
|
||||||
|
/// 状态码
|
||||||
|
/// </summary>
|
||||||
|
public int code { set; get; } = 0;
|
||||||
|
/// <summary>
|
||||||
|
/// 描述
|
||||||
|
/// </summary>
|
||||||
|
public string msg { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据[返回list,或者Model]
|
||||||
|
/// </summary>
|
||||||
|
public dynamic data { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 如果是有分页的列表讲传入 page信息
|
||||||
|
/// </summary>
|
||||||
|
public Laypage page { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.CrmModel
|
||||||
|
{
|
||||||
|
public class Laypage
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每页行数
|
||||||
|
/// </summary>
|
||||||
|
public int limit { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 当前页是第几页
|
||||||
|
/// </summary>
|
||||||
|
public int page { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 排序方式
|
||||||
|
/// </summary>
|
||||||
|
public string order { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 排序字段
|
||||||
|
/// </summary>
|
||||||
|
public string sort { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 总数据量
|
||||||
|
/// </summary>
|
||||||
|
public int count { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.CrmModel
|
||||||
|
{
|
||||||
|
public class LayuiData<T>
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// code :0正常 1不正常
|
||||||
|
/// </summary>
|
||||||
|
public int code { get; set; }
|
||||||
|
public string msg { get; set; }
|
||||||
|
public int count { get; set; }
|
||||||
|
public List<T> data { get; set; }
|
||||||
|
|
||||||
|
public void SetFail(int code, string msg)
|
||||||
|
{
|
||||||
|
this.code = code;
|
||||||
|
this.msg = msg;
|
||||||
|
this.count = 0;
|
||||||
|
this.data = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.CrmModel
|
||||||
|
{
|
||||||
|
public class retMsg
|
||||||
|
{
|
||||||
|
public bool result { get; set; }
|
||||||
|
public int retcode { get; set; }
|
||||||
|
public string retmsg { get; set; }
|
||||||
|
public void SetFail(string msg, int code)
|
||||||
|
{
|
||||||
|
this.result = false;
|
||||||
|
this.retcode = code;
|
||||||
|
this.retmsg = msg;
|
||||||
|
}
|
||||||
|
public void SetResult(ApiResult result)
|
||||||
|
{
|
||||||
|
this.result = result.success;
|
||||||
|
this.retcode = result.code;
|
||||||
|
this.retmsg = result.msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetResult(bool success, int code, string msg)
|
||||||
|
{
|
||||||
|
this.result = success;
|
||||||
|
this.retcode = code;
|
||||||
|
this.retmsg = msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class retMsg<T>
|
||||||
|
{
|
||||||
|
public bool result { get; set; }
|
||||||
|
public int retcode { get; set; }
|
||||||
|
public string retmsg { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 数据
|
||||||
|
/// </summary>
|
||||||
|
public T retData { get; set; }
|
||||||
|
public Laypage retpage { get; set; }
|
||||||
|
|
||||||
|
public void SetFail(string msg, int code)
|
||||||
|
{
|
||||||
|
this.result = false;
|
||||||
|
this.retcode = code;
|
||||||
|
this.retmsg = msg;
|
||||||
|
}
|
||||||
|
public void SetResult(ApiResult result)
|
||||||
|
{
|
||||||
|
this.result = result.success;
|
||||||
|
this.retcode = result.code;
|
||||||
|
if (result.success)
|
||||||
|
{
|
||||||
|
Type t = typeof(T);
|
||||||
|
if (t == typeof(string))
|
||||||
|
{
|
||||||
|
this.retData = result.data;
|
||||||
|
}
|
||||||
|
else if (t == typeof(int))
|
||||||
|
{
|
||||||
|
this.retData = result.data;
|
||||||
|
}
|
||||||
|
else if (t == typeof(long))
|
||||||
|
{
|
||||||
|
this.retData = result.data;
|
||||||
|
}
|
||||||
|
else if (result.data != null)
|
||||||
|
{
|
||||||
|
this.retData = result.data.ToObject<T>();
|
||||||
|
}
|
||||||
|
if (result.page != null)
|
||||||
|
{
|
||||||
|
this.retpage = result.page;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.retmsg = result.msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.DTO
|
||||||
|
{
|
||||||
|
public class RoomParam
|
||||||
|
{
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public string extuserid { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model
|
||||||
|
{
|
||||||
|
public class EfAdminRepository<T> : EfRepository<T>, IAdminRepository<T> where T : BaseEntity
|
||||||
|
{
|
||||||
|
public EfAdminRepository(crmContext context) : base(context)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,218 @@
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Mini.Common;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model
|
||||||
|
{
|
||||||
|
public class EfRepository<T> : EfRepositoryBase<T> where T : BaseEntity
|
||||||
|
{
|
||||||
|
private readonly DbContext _context;
|
||||||
|
private DbSet<T> _entities;
|
||||||
|
protected EfRepository(DbContext context)
|
||||||
|
{
|
||||||
|
this._context = new crmContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual DbSet<T> Entities
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_entities == null)
|
||||||
|
_entities = _context.Set<T>();
|
||||||
|
return _entities;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override T Get(Expression<Func<T, bool>> @where)
|
||||||
|
{
|
||||||
|
return this.Entities.FirstOrDefault(where);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IQueryable<T> GetList()
|
||||||
|
{
|
||||||
|
return GetList(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IQueryable<T> GetList(Expression<Func<T, bool>> @where)
|
||||||
|
{
|
||||||
|
if (where != null)
|
||||||
|
{
|
||||||
|
return this.Entities.Where(where).AsNoTracking();
|
||||||
|
}
|
||||||
|
return this.Entities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IQueryable<T> GetList<TOrderBy>(Expression<Func<T, bool>> @where, Expression<Func<T, TOrderBy>> orderBy = null, SortOrder sortOrder = SortOrder.Descending)
|
||||||
|
{
|
||||||
|
if (orderBy == null)
|
||||||
|
{
|
||||||
|
return this.Entities.Where(where);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (sortOrder == SortOrder.Descending)
|
||||||
|
return this.Entities.Where(where).OrderByDescending(orderBy);
|
||||||
|
else
|
||||||
|
return this.Entities.Where(where).OrderBy(orderBy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IQueryable<T> GetList<TOrderBy>(Expression<Func<T, TOrderBy>> orderBy, int pageindex, int pagesize, out int totalRecords, SortOrder sortOrder = SortOrder.Descending)
|
||||||
|
{
|
||||||
|
return GetList(null, orderBy, pageindex, pagesize, out totalRecords, sortOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IQueryable<T> GetList<TOrderBy>(Expression<Func<T, bool>> @where, Expression<Func<T, TOrderBy>> orderBy, int pageindex, int pagesize, out int totalRecords, SortOrder sortOrder = SortOrder.Descending)
|
||||||
|
{
|
||||||
|
if (pageindex < 1)
|
||||||
|
throw new ArgumentException("pageindex");
|
||||||
|
if (pagesize < 1)
|
||||||
|
throw new ArgumentException("pagesize");
|
||||||
|
|
||||||
|
int skip = (pageindex - 1) * pagesize;
|
||||||
|
var _query = this.Entities.AsQueryable().AsNoTracking();
|
||||||
|
if (null != where)
|
||||||
|
_query = _query.Where(where);
|
||||||
|
|
||||||
|
totalRecords = _query.Count();
|
||||||
|
if (sortOrder == SortOrder.Descending)
|
||||||
|
{
|
||||||
|
_query = _query.OrderByDescending(orderBy);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_query = _query.OrderBy(orderBy);
|
||||||
|
return _query.Skip(skip).Take(pagesize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IQueryable<T> GetList<TOrderBy>(Expression<Func<T, bool>> @where, Expression<Func<T, TOrderBy>> orderBy, Pager pg, SortOrder sortOrder = SortOrder.Descending)
|
||||||
|
{
|
||||||
|
int totalRecords;
|
||||||
|
var list = GetList(where, orderBy, pg.page, pg.rows, out totalRecords, sortOrder);
|
||||||
|
pg.totalRows = totalRecords;
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int Add(T entity)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (entity == null)
|
||||||
|
throw new ArgumentNullException();
|
||||||
|
|
||||||
|
this.Entities.Add(entity);
|
||||||
|
|
||||||
|
return this._context.SaveChanges();
|
||||||
|
}
|
||||||
|
catch (Exception dbEx)
|
||||||
|
{
|
||||||
|
throw dbEx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void AddList(IEnumerable<T> entities)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (entities == null)
|
||||||
|
throw new ArgumentNullException();
|
||||||
|
|
||||||
|
foreach (var entity in entities)
|
||||||
|
this.Entities.Add(entity);
|
||||||
|
|
||||||
|
this._context.SaveChanges();
|
||||||
|
}
|
||||||
|
catch (Exception dbEx)
|
||||||
|
{
|
||||||
|
throw dbEx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Update(T entity)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (entity == null)
|
||||||
|
throw new ArgumentNullException();
|
||||||
|
|
||||||
|
return this._context.SaveChanges() > 0;
|
||||||
|
}
|
||||||
|
catch (Exception dbEx)
|
||||||
|
{
|
||||||
|
throw dbEx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update(IEnumerable<T> entities)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (entities == null)
|
||||||
|
throw new ArgumentNullException();
|
||||||
|
|
||||||
|
this._context.SaveChanges();
|
||||||
|
}
|
||||||
|
catch (Exception dbEx)
|
||||||
|
{
|
||||||
|
throw dbEx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Delete(T entity)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (entity == null)
|
||||||
|
throw new ArgumentNullException();
|
||||||
|
|
||||||
|
this.Entities.Remove(entity);
|
||||||
|
|
||||||
|
this._context.SaveChanges();
|
||||||
|
}
|
||||||
|
catch (Exception dbEx)
|
||||||
|
{
|
||||||
|
throw dbEx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Delete(IEnumerable<T> entities)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (entities == null)
|
||||||
|
throw new ArgumentNullException();
|
||||||
|
|
||||||
|
foreach (var entity in entities)
|
||||||
|
this.Entities.Remove(entity);
|
||||||
|
|
||||||
|
this._context.SaveChanges();
|
||||||
|
}
|
||||||
|
catch (Exception dbEx)
|
||||||
|
{
|
||||||
|
throw dbEx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IQueryable<T> Table
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.Entities;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//protected string GetFullErrorText(Exception exc)
|
||||||
|
//{
|
||||||
|
// var msg = string.Empty;
|
||||||
|
// foreach (var validationErrors in exc.EntityValidationErrors)
|
||||||
|
// foreach (var error in validationErrors.ValidationErrors)
|
||||||
|
// msg += string.Format("Property: {0} Error: {1}", error.PropertyName, error.ErrorMessage) + Environment.NewLine;
|
||||||
|
// return msg;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
using Mini.Common;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model
|
||||||
|
{
|
||||||
|
public abstract class EfRepositoryBase<T> : IRepository<T> where T : BaseEntity
|
||||||
|
{
|
||||||
|
public abstract T Get(Expression<Func<T, bool>> @where);
|
||||||
|
|
||||||
|
public abstract IQueryable<T> GetList();
|
||||||
|
|
||||||
|
public abstract IQueryable<T> GetList(Expression<Func<T, bool>> @where);
|
||||||
|
|
||||||
|
public abstract IQueryable<T> GetList<TOrderBy>(Expression<Func<T, bool>> @where, Expression<Func<T, TOrderBy>> orderBy = null, SortOrder sortOrder = SortOrder.Descending);
|
||||||
|
|
||||||
|
public abstract IQueryable<T> GetList<TOrderBy>(Expression<Func<T, TOrderBy>> orderBy, int pageindex, int pagesize, out int totalRecords, SortOrder sortOrder = SortOrder.Descending);
|
||||||
|
|
||||||
|
public abstract IQueryable<T> GetList<TOrderBy>(Expression<Func<T, bool>> @where, Expression<Func<T, TOrderBy>> orderBy, int pageindex, int pagesize, out int totalRecords, SortOrder sortOrder = SortOrder.Descending);
|
||||||
|
|
||||||
|
public abstract IQueryable<T> GetList<TOrderBy>(Expression<Func<T, bool>> @where, Expression<Func<T, TOrderBy>> orderBy, Pager pg, SortOrder sortOrder = SortOrder.Descending);
|
||||||
|
|
||||||
|
public abstract int Add(T entity);
|
||||||
|
|
||||||
|
public abstract void AddList(IEnumerable<T> entities);
|
||||||
|
|
||||||
|
public abstract bool Update(T entity);
|
||||||
|
|
||||||
|
public abstract void Update(IEnumerable<T> entities);
|
||||||
|
|
||||||
|
public abstract void Delete(T entity);
|
||||||
|
|
||||||
|
public abstract void Delete(IEnumerable<T> entities);
|
||||||
|
|
||||||
|
public abstract IQueryable<T> Table { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Bas_Config : BaseEntity
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public string code { get; set; }
|
||||||
|
public string value { get; set; }
|
||||||
|
public DateTime? time { get; set; }
|
||||||
|
public string content { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Bas_InnerUser : BaseEntity
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int uid { get; set; }
|
||||||
|
public string uname { get; set; }
|
||||||
|
public int eid { get; set; }
|
||||||
|
public string gender { get; set; }
|
||||||
|
public DateTime? birthday { get; set; }
|
||||||
|
public string passwd { get; set; }
|
||||||
|
public int isdismiss { get; set; }
|
||||||
|
public DateTime ctime { get; set; }
|
||||||
|
public int createUser { get; set; }
|
||||||
|
public DateTime? utime { get; set; }
|
||||||
|
public int? updateuser { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
using Mini.Model.Entity;
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Bas_InnerUserRole : BaseEntity
|
||||||
|
{
|
||||||
|
[Key, Column(Order = 0)]
|
||||||
|
public int InnerUserId { get; set; }
|
||||||
|
[Key, Column(Order = 1)]
|
||||||
|
public int RoleId { get; set; }
|
||||||
|
public DateTime CTime { get; set; }
|
||||||
|
public int CreateUser { get; set; }
|
||||||
|
public DateTime? UTime { get; set; }
|
||||||
|
public int? UpdateUser { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Bas_InnerUserSalt : BaseEntity
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int InnerUserId { get; set; }
|
||||||
|
public int Eid { get; set; }
|
||||||
|
public string PwdSalt { get; set; }
|
||||||
|
public DateTime? CTime { get; set; }
|
||||||
|
public int? CreateUser { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Bas_LeftMemu : BaseEntity
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int MenuId { get; set; }
|
||||||
|
public int ModuleMenuId { get; set; }
|
||||||
|
public string MName { get; set; }
|
||||||
|
public string Url { get; set; }
|
||||||
|
public int IsGroup { get; set; }
|
||||||
|
public int IsShow { get; set; }
|
||||||
|
public string RightId { get; set; }
|
||||||
|
public int? ParentId { get; set; }
|
||||||
|
public int SortId { get; set; }
|
||||||
|
public DateTime CTime { get; set; }
|
||||||
|
public int CreateUser { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Bas_LoginLog : BaseEntity
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int pkid { get; set; }
|
||||||
|
public int uid { get; set; }
|
||||||
|
public int eid { get; set; }
|
||||||
|
public DateTime logintime { get; set; }
|
||||||
|
public string ip { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Bas_ModuleMenu : BaseEntity
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int ModuleMenuId { get; set; }
|
||||||
|
public string MName { get; set; }
|
||||||
|
public string RightId { get; set; }
|
||||||
|
public string ImageUrl { get; set; }
|
||||||
|
public int SortId { get; set; }
|
||||||
|
public DateTime CTime { get; set; }
|
||||||
|
public int CreateUser { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Bas_Parameter : BaseEntity
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public string parakey { get; set; }
|
||||||
|
public string paravalue { get; set; }
|
||||||
|
public string remark { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Bas_Right : BaseEntity
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public string RightId { get; set; }
|
||||||
|
public string RName { get; set; }
|
||||||
|
public int SortId { get; set; }
|
||||||
|
public DateTime CTime { get; set; }
|
||||||
|
public int ?CreateUser { get; set; }
|
||||||
|
public int? GroupId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Bas_RightGroup : BaseEntity
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int PkId { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public int ParentId { get; set; }
|
||||||
|
public DateTime CTime { get; set; }
|
||||||
|
public int CreateUser { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Bas_Right_ToolButton : BaseEntity
|
||||||
|
{
|
||||||
|
[Key, Column(Order = 0)]
|
||||||
|
public string RightId { get; set; }
|
||||||
|
[Key, Column(Order = 1)]
|
||||||
|
public int ButtonId { get; set; }
|
||||||
|
public string ButtonName { get; set; }
|
||||||
|
public string ButtonCode { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Bas_Role : BaseEntity
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int RoleId { get; set; }
|
||||||
|
public string RName { get; set; }
|
||||||
|
public int SortId { get; set; }
|
||||||
|
public DateTime CTime { get; set; }
|
||||||
|
public int CreateUser { get; set; }
|
||||||
|
public DateTime? UTime { get; set; }
|
||||||
|
public int? UpdateUser { get; set; }
|
||||||
|
public string Code { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Bas_RoleRightResource : BaseEntity
|
||||||
|
{
|
||||||
|
[Key, Column(Order = 0)]
|
||||||
|
public int RoleId { get; set; }
|
||||||
|
[Key, Column(Order = 1)]
|
||||||
|
public string RightId { get; set; }
|
||||||
|
public DateTime CTime { get; set; }
|
||||||
|
public int CreateUser { get; set; }
|
||||||
|
public int? ToolBarvalue { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Bas_Supplier : BaseEntity
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int SupplierId { get; set; }
|
||||||
|
public string SupplierName { get; set; }
|
||||||
|
public string FullName { get; set; }
|
||||||
|
public string Licence { get; set; }
|
||||||
|
public string Address { get; set; }
|
||||||
|
public string LinkMan { get; set; }
|
||||||
|
public string LinkPhone { get; set; }
|
||||||
|
public DateTime CTime { get; set; }
|
||||||
|
public int CreateUser { get; set; }
|
||||||
|
public DateTime? UTime { get; set; }
|
||||||
|
public int? UpdateUser { get; set; }
|
||||||
|
public string bankname { get; set; }
|
||||||
|
public string accountnumber { get; set; }
|
||||||
|
public string accountname { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Ww_Corp
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public string corpname { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 所属公司ID
|
||||||
|
/// </summary>
|
||||||
|
public string companycode { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 部门ID
|
||||||
|
/// </summary>
|
||||||
|
public string deptid { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Ww_Dept
|
||||||
|
{
|
||||||
|
[Key, Column(Order = 0)]
|
||||||
|
public int deptid { get; set; }
|
||||||
|
[Key, Column(Order = 1)]
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public string deptname { get; set; }
|
||||||
|
public long parentid { get; set; }
|
||||||
|
public long orderseq { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Ww_DeptUser
|
||||||
|
{
|
||||||
|
[Key, Column(Order = 0)]
|
||||||
|
public string userid { get; set; }
|
||||||
|
[Key, Column(Order = 1)]
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public string department { get; set; }
|
||||||
|
public DateTime? ctime { get; set; }
|
||||||
|
public string open_userid { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Ww_Extuser
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public string userid { get; set; }
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public DateTime? ctime { get; set; }
|
||||||
|
public DateTime? lastupdate { get; set; }
|
||||||
|
public string exinfo { get; set; }
|
||||||
|
public string avatar { get; set; }
|
||||||
|
public string unionid { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Ww_GroupChat
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public string chat_id { get; set; }
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public string owner { get; set; }
|
||||||
|
public string notice { get; set; }
|
||||||
|
public long create_time { get; set; }
|
||||||
|
public string member_list { get; set; }
|
||||||
|
public int membernum { get; set; }
|
||||||
|
public int status { get; set; }
|
||||||
|
public DateTime? ctime { get; set; }
|
||||||
|
public DateTime ?ltimeupdate { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Ww_Record
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public string voiceid { get; set; }
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public string fromer { get; set; }
|
||||||
|
public string tolist { get; set; }
|
||||||
|
public string roomid { get; set; }
|
||||||
|
public string msgid { get; set; }
|
||||||
|
public DateTime starttime { get; set; }
|
||||||
|
public DateTime endtime { get; set; }
|
||||||
|
public string filename { get; set; }
|
||||||
|
public int length { get; set; }
|
||||||
|
public string ctime { get; set; }
|
||||||
|
public int calltype { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Ww_Role_Dept
|
||||||
|
{
|
||||||
|
[Key, Column(Order = 0)]
|
||||||
|
public string corpid { get; set; }
|
||||||
|
[Key, Column(Order = 1)]
|
||||||
|
public int roleid { get; set; }
|
||||||
|
[Key, Column(Order = 3)]
|
||||||
|
public int deptid { get; set; }
|
||||||
|
public string deptcode { get; set; }
|
||||||
|
public DateTime ctime { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Ww_RoomChat
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public string roomid { get; set; }
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public string roomname { get; set; }
|
||||||
|
public string creator { get; set; }
|
||||||
|
public string notice { get; set; }
|
||||||
|
public long room_create_time { get; set; }
|
||||||
|
public string members { get; set; }
|
||||||
|
public int membernum { get; set; }
|
||||||
|
public DateTime? ctime { get; set; }
|
||||||
|
public DateTime? ltimeupdate { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Ww_UserChat
|
||||||
|
{
|
||||||
|
[Key, Column(Order = 0)]
|
||||||
|
public string userid { get; set; }
|
||||||
|
[Key, Column(Order = 1)]
|
||||||
|
public string corpid { get; set; }
|
||||||
|
[Key, Column(Order = 2)]
|
||||||
|
public string deptuserid { get; set; }
|
||||||
|
public DateTime? ctime { get; set; }
|
||||||
|
public DateTime? lmsgtime { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Ww_User_Extuser
|
||||||
|
{
|
||||||
|
[Key, Column(Order = 0)]
|
||||||
|
public string userid { get; set; }
|
||||||
|
[Key, Column(Order = 1)]
|
||||||
|
public string extuserid { get; set; }
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public DateTime? ctime { get; set; }
|
||||||
|
|
||||||
|
public DateTime? lmsgtime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Ww_hhuser
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[Column(Order = 0)]
|
||||||
|
public string userid { get; set; }
|
||||||
|
[Key]
|
||||||
|
[Column(Order = 1)]
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public string uname { get; set; }
|
||||||
|
public string exinfo { get; set; }
|
||||||
|
public int? deptid { get; set; }
|
||||||
|
public DateTime? lastupdate { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 最后聊天时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? lmsgtime { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 首次聊天时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? fmsgtime { get; set; }
|
||||||
|
|
||||||
|
public string alias { get; set; }
|
||||||
|
public string mobile { get; set; }
|
||||||
|
public string email { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Ww_hhuser_Eid
|
||||||
|
{
|
||||||
|
[Key, Column(Order = 0)]
|
||||||
|
public string corpid { get; set; }
|
||||||
|
[Key, Column(Order = 1)]
|
||||||
|
public string userid { get; set; }
|
||||||
|
public DateTime ctime { get; set; }
|
||||||
|
public int eid { get; set; }
|
||||||
|
public DateTime? utime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.Entity
|
||||||
|
{
|
||||||
|
public class Ww_hhuser_Name : BaseEntity
|
||||||
|
{
|
||||||
|
[Key, Column(Order = 0)]
|
||||||
|
public string userid { get; set; }
|
||||||
|
[Key, Column(Order = 1)]
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public string remarkname { get; set; }
|
||||||
|
//public DateTime? ctime { get; set; }
|
||||||
|
//public DateTime? utime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.Enum
|
||||||
|
{
|
||||||
|
public enum BasConfigEnums
|
||||||
|
{
|
||||||
|
IsShowPhone,//是否显示手机号码
|
||||||
|
IsOutAndInnerGroupLevel,//是区分了内外部的版本满,1是,0老版本
|
||||||
|
HiddenEWM,//隐藏聊天记录图片二维码 1:隐藏,0和默认不隐藏
|
||||||
|
SelfUrl,//本身的地址
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.Enum
|
||||||
|
{
|
||||||
|
public enum ParameterEnums
|
||||||
|
{
|
||||||
|
WeiXin_IllegalKewords,//关键词配置
|
||||||
|
ShowSaleLine,//显示销售线索
|
||||||
|
SaleLineHttp,//销售线索地址
|
||||||
|
NotShowGroupCorp,//不显示的群
|
||||||
|
ShowOtherSaleLT//企业微信聊天详细里面是否显示该客户与其他客服的聊天记录
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model
|
||||||
|
{
|
||||||
|
public interface IAdminRepository<T> : IRepository<T> where T : class
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Mini.Model.Entity;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model
|
||||||
|
{
|
||||||
|
public interface IDbContext
|
||||||
|
{
|
||||||
|
DbSet<TEntity> Set<TEntity>() where TEntity : BaseEntity;
|
||||||
|
int SaveChanges();
|
||||||
|
IList<TEntity> ExecuteStoredProcedureList<TEntity>(string commandText, params object[] parameters) where TEntity : BaseEntity, new();
|
||||||
|
IEnumerable<TElement> SqlQuery<TElement>(string sql, params object[] parameters);
|
||||||
|
int ExecuteSqlCommand(string sql, bool doNotEnsureTransaction = false, int? timeout = null, params object[] parameters);
|
||||||
|
DataSet SqlQueryDataSet(string sql, CommandType commandType = CommandType.Text, params MySqlParameter[] parameters);
|
||||||
|
void Detach(object entity);
|
||||||
|
bool ProxyCreationEnabled { get; set; }
|
||||||
|
bool AutoDetectChangesEnabled { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Mini.Model
|
||||||
|
{
|
||||||
|
public interface IDependency
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
using Mini.Common;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model
|
||||||
|
{
|
||||||
|
public interface IRepository<T> where T : class
|
||||||
|
{
|
||||||
|
T Get(Expression<Func<T, bool>> where);
|
||||||
|
|
||||||
|
IQueryable<T> GetList();
|
||||||
|
|
||||||
|
IQueryable<T> GetList(Expression<Func<T, bool>> where);
|
||||||
|
|
||||||
|
IQueryable<T> GetList<TOrderBy>(Expression<Func<T, bool>> where, Expression<Func<T, TOrderBy>> orderBy = null, SortOrder sortOrder = SortOrder.Descending);
|
||||||
|
|
||||||
|
IQueryable<T> GetList<TOrderBy>(Expression<Func<T, TOrderBy>> orderBy, int pageindex, int pagesize, out int totalRecords, SortOrder sortOrder = SortOrder.Descending);
|
||||||
|
|
||||||
|
IQueryable<T> GetList<TOrderBy>(Expression<Func<T, bool>> where, Expression<Func<T, TOrderBy>> orderBy, int pageindex, int pagesize, out int totalRecords, SortOrder sortOrder = SortOrder.Descending);
|
||||||
|
|
||||||
|
IQueryable<T> GetList<TOrderBy>(Expression<Func<T, bool>> where, Expression<Func<T, TOrderBy>> orderBy, Pager pg, SortOrder sortOrder = SortOrder.Descending);
|
||||||
|
|
||||||
|
int Add(T entity);
|
||||||
|
|
||||||
|
void AddList(IEnumerable<T> entities);
|
||||||
|
|
||||||
|
bool Update(T entity);
|
||||||
|
|
||||||
|
void Update(IEnumerable<T> entities);
|
||||||
|
|
||||||
|
void Delete(T entity);
|
||||||
|
|
||||||
|
void Delete(IEnumerable<T> entities);
|
||||||
|
|
||||||
|
IQueryable<T> Table { get; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.Map
|
||||||
|
{
|
||||||
|
public class ww_exinfo
|
||||||
|
{
|
||||||
|
public external external_contact { get; set; }
|
||||||
|
public List<follow> follow_user { get; set; }
|
||||||
|
public follow self { get; set; }
|
||||||
|
}
|
||||||
|
public class external
|
||||||
|
{
|
||||||
|
public string external_userid { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public string type { get; set; }
|
||||||
|
}
|
||||||
|
public class follow
|
||||||
|
{
|
||||||
|
public string userid { get; set; }
|
||||||
|
public string remark { get; set; }
|
||||||
|
public string description { get; set; }
|
||||||
|
public long ? createtime { get; set; }
|
||||||
|
public object remark_mobiles { get; set; }
|
||||||
|
public object tags { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.18" />
|
||||||
|
<PackageReference Include="System.Data.SqlClient" Version="4.7.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Mini.Common\Mini.Common.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model
|
||||||
|
{
|
||||||
|
|
||||||
|
public static class PredicateBuilder
|
||||||
|
{
|
||||||
|
public static Expression<Func<T, bool>> True<T>() { return f => true; }
|
||||||
|
public static Expression<Func<T, bool>> False<T>() { return f => false; }
|
||||||
|
//false
|
||||||
|
public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> expr1,
|
||||||
|
Expression<Func<T, bool>> expr2)
|
||||||
|
{
|
||||||
|
var invokedExpr = Expression.Invoke(expr2, expr1.Parameters.Cast<Expression>());
|
||||||
|
return Expression.Lambda<Func<T, bool>>
|
||||||
|
(Expression.Or(expr1.Body, invokedExpr), expr1.Parameters);
|
||||||
|
}
|
||||||
|
//true
|
||||||
|
public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> expr1,
|
||||||
|
Expression<Func<T, bool>> expr2)
|
||||||
|
{
|
||||||
|
var invokedExpr = Expression.Invoke(expr2, expr1.Parameters.Cast<Expression>());
|
||||||
|
return Expression.Lambda<Func<T, bool>>
|
||||||
|
(Expression.And(expr1.Body, invokedExpr), expr1.Parameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Air.Model.AirAdminViewModel
|
||||||
|
{
|
||||||
|
public class Bas_InnerUserModel
|
||||||
|
{
|
||||||
|
public int uid { get; set; }
|
||||||
|
public string uname { get; set; }
|
||||||
|
public int eid { get; set; }
|
||||||
|
public string gender { get; set; }
|
||||||
|
public DateTime? birthday { get; set; }
|
||||||
|
public string passwd { get; set; }
|
||||||
|
public int isdismiss { get; set; }
|
||||||
|
public DateTime ctime { get; set; }
|
||||||
|
public int createUser { get; set; }
|
||||||
|
public DateTime? utime { get; set; }
|
||||||
|
public int? updateuser { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Bas_InnerUserEidtModel
|
||||||
|
{
|
||||||
|
public int uid { get; set; }
|
||||||
|
public string uname { get; set; }
|
||||||
|
public int eid { get; set; }
|
||||||
|
public string gender { get; set; }
|
||||||
|
public DateTime? birthday { get; set; }
|
||||||
|
public string passwd { get; set; }
|
||||||
|
public string passwd2 { get; set; }
|
||||||
|
public int isdismiss { get; set; }
|
||||||
|
public DateTime ctime { get; set; }
|
||||||
|
public int createUser { get; set; }
|
||||||
|
public DateTime? utime { get; set; }
|
||||||
|
public int? updateuser { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改密码
|
||||||
|
/// </summary>
|
||||||
|
public class BasUpdatePwd
|
||||||
|
{
|
||||||
|
public int uid { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("密码")]
|
||||||
|
[Required(ErrorMessage = "密码不能为空")]
|
||||||
|
public string password { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("确认密码")]
|
||||||
|
[Compare("password", ErrorMessage = "密码不一致")]
|
||||||
|
public string rpassword { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Air.Model.AirAdminViewModel
|
||||||
|
{
|
||||||
|
public class Bas_InnerUserRoleModel
|
||||||
|
{
|
||||||
|
public int Uid { get; set; }
|
||||||
|
public int Eid { get; set; }
|
||||||
|
public string UName { get; set; }
|
||||||
|
public string RolesNames { get; set; }
|
||||||
|
public string RoleIds { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Air.Model.AirAdminViewModel
|
||||||
|
{
|
||||||
|
public class Bas_LeftMemuModel
|
||||||
|
{
|
||||||
|
public int MenuId { get; set; }
|
||||||
|
public int ModuleMenuId { get; set; }
|
||||||
|
public string MName { get; set; }
|
||||||
|
public string Url { get; set; }
|
||||||
|
public int IsGroup { get; set; }
|
||||||
|
public int IsShow { get; set; }
|
||||||
|
public string RightId { get; set; }
|
||||||
|
public int? ParentId { get; set; }
|
||||||
|
public int SortId { get; set; }
|
||||||
|
public DateTime CTime { get; set; }
|
||||||
|
public int CreateUser { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Bas_LeftMenuTreeViewModel
|
||||||
|
{
|
||||||
|
public int id { get; set; }
|
||||||
|
public string text { get; set; }
|
||||||
|
public string value { get; set; }
|
||||||
|
public bool showcheck { get; set; }
|
||||||
|
public bool complete { get; set; }
|
||||||
|
public bool isexpand { get; set; }
|
||||||
|
public int checkstate { get; set; }
|
||||||
|
public int? parentid { get; set; }
|
||||||
|
public bool hasChildren { get; set; }
|
||||||
|
public IList<Bas_LeftMenuTreeViewModel> ChildNodes { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Air.Model.AirAdminViewModel
|
||||||
|
{
|
||||||
|
public class Bas_ModuleMenuModel
|
||||||
|
{
|
||||||
|
public int ModuleMenuId { get; set; }
|
||||||
|
public string MName { get; set; }
|
||||||
|
public string RightId { get; set; }
|
||||||
|
public string ImageUrl { get; set; }
|
||||||
|
public int SortId { get; set; }
|
||||||
|
public DateTime CTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Air.Model.AirAdminViewModel
|
||||||
|
{
|
||||||
|
public class Bas_RightGroupModel
|
||||||
|
{
|
||||||
|
public int PkId { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public int ParentId { get; set; }
|
||||||
|
public DateTime CTime { get; set; }
|
||||||
|
public int CreateUser { get; set; }
|
||||||
|
public string GroupPath { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Air.Model.AirAdminViewModel
|
||||||
|
{
|
||||||
|
public class Bas_RightModel
|
||||||
|
{
|
||||||
|
public string RightId { get; set; }
|
||||||
|
public string RName { get; set; }
|
||||||
|
public int SortId { get; set; }
|
||||||
|
public DateTime CTime { get; set; }
|
||||||
|
public int? CreateUser { get; set; }
|
||||||
|
public int? GroupId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Air.Model.AirAdminViewModel
|
||||||
|
{
|
||||||
|
public class Bas_RightToolButtonModel
|
||||||
|
{
|
||||||
|
public string RightId { get; set; }
|
||||||
|
public int ButtonId { get; set; }
|
||||||
|
public string ButtonName { get; set; }
|
||||||
|
public string ButtonCode { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Air.Model.AirAdminViewModel
|
||||||
|
{
|
||||||
|
public class Bas_SupplierModel
|
||||||
|
{
|
||||||
|
public int SupplierId { get; set; }
|
||||||
|
[DisplayName("名称")]
|
||||||
|
[Required(ErrorMessage = "名称不能为空!")]
|
||||||
|
public string SupplierName { get; set; }
|
||||||
|
[DisplayName("全称")]
|
||||||
|
[Required(ErrorMessage = "全称不能为空!")]
|
||||||
|
public string FullName { get; set; }
|
||||||
|
[DisplayName("营业执照号")]
|
||||||
|
public string Licence { get; set; }
|
||||||
|
[DisplayName("地址")]
|
||||||
|
public string Address { get; set; }
|
||||||
|
[DisplayName("联系人")]
|
||||||
|
[Required(ErrorMessage = "联系人不能为空!")]
|
||||||
|
public string LinkMan { get; set; }
|
||||||
|
[DisplayName("联系电话")]
|
||||||
|
[Required(ErrorMessage = "联系电话不能为空!")]
|
||||||
|
public string LinkPhone { get; set; }
|
||||||
|
public int? CreateUser { get; set; }
|
||||||
|
public int? UpdateUser { get; set; }
|
||||||
|
[DisplayName("银行名称")]
|
||||||
|
[Required(ErrorMessage = "银行名称不能为空!")]
|
||||||
|
public string bankname { get; set; }
|
||||||
|
[DisplayName("银行账号")]
|
||||||
|
[Required(ErrorMessage = "银行账号不能为空!")]
|
||||||
|
public string accountnumber { get; set; }
|
||||||
|
[DisplayName("账户姓名")]
|
||||||
|
[Required(ErrorMessage = "账户姓名不能为空!")]
|
||||||
|
public string accountname { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 群成员
|
||||||
|
/// </summary>
|
||||||
|
public class GroupUser
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 群ID
|
||||||
|
/// </summary>
|
||||||
|
public string roomid { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 用户ID
|
||||||
|
/// </summary>
|
||||||
|
public string userid { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 企业号ID
|
||||||
|
/// </summary>
|
||||||
|
public string corpid { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 名称
|
||||||
|
/// </summary>
|
||||||
|
public string name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 头像
|
||||||
|
/// </summary>
|
||||||
|
public string avatar { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
public class HHuserInfo
|
||||||
|
{
|
||||||
|
public string userid { get; set; }
|
||||||
|
public string avatar { get; set; }
|
||||||
|
public string thumb_avatar { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Air.Model.AirAdminViewModel
|
||||||
|
{
|
||||||
|
public class RightAndButton
|
||||||
|
{
|
||||||
|
public string rightId { get; set; }
|
||||||
|
public int buttons { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
public class Sys_CanLookMsgGroup
|
||||||
|
{
|
||||||
|
public string Group { get; set; }
|
||||||
|
public string Contains { get; set; }
|
||||||
|
public string Target { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
public class Ww_Dept_Corp
|
||||||
|
{
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public string id { get; set; }
|
||||||
|
}
|
||||||
|
public class Ww_Dept_CorpInt
|
||||||
|
{
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public int id { get; set; }
|
||||||
|
}
|
||||||
|
public class Ww_Dept_CorpIntNull
|
||||||
|
{
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public int? id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
public class Ww_ExtuserModel
|
||||||
|
{
|
||||||
|
public string userid { get; set; }
|
||||||
|
public DateTime? ctime { get; set; }
|
||||||
|
public DateTime? lastupdate { get; set; }
|
||||||
|
public string exinfo { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
public class Ww_FindUserShow
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 公司名称
|
||||||
|
/// </summary>
|
||||||
|
public string corpname { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 客服ID
|
||||||
|
/// </summary>
|
||||||
|
public string userid { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 客服姓名
|
||||||
|
/// </summary>
|
||||||
|
public string uname { get; set; }
|
||||||
|
//好友ID
|
||||||
|
public string extuserid { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 好友名称
|
||||||
|
/// </summary>
|
||||||
|
public string name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 好友备注
|
||||||
|
/// </summary>
|
||||||
|
public string remark { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 时间
|
||||||
|
/// </summary>
|
||||||
|
public string createtime { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 备注号码
|
||||||
|
/// </summary>
|
||||||
|
public string remark_mobiles { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 头像
|
||||||
|
/// </summary>
|
||||||
|
public string avatar { get; set; }
|
||||||
|
|
||||||
|
public string corpid { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
public class Ww_FindUser_Model
|
||||||
|
{
|
||||||
|
//客服企业号
|
||||||
|
public string corpname { get; set; }
|
||||||
|
//客服名称
|
||||||
|
public string uname { get; set; }
|
||||||
|
//客服ID
|
||||||
|
public string userid { get; set; }
|
||||||
|
public int? deptid { get; set; }
|
||||||
|
public string corpid { get; set; }
|
||||||
|
//好友ID
|
||||||
|
public string extuserid { get; set; }
|
||||||
|
//好友名称
|
||||||
|
public string name { get; set; }
|
||||||
|
//好友json信息
|
||||||
|
public string exinfo { get; set; }
|
||||||
|
public DateTime? ctime { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 头像
|
||||||
|
/// </summary>
|
||||||
|
public string avatar { get; set; }
|
||||||
|
public string myphone { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
public class Ww_Groupchat_Member
|
||||||
|
{
|
||||||
|
public string userid { get; set; }
|
||||||
|
|
||||||
|
public int type { get; set; }
|
||||||
|
public long join_time { get; set; }
|
||||||
|
public int join_scene { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 内部群
|
||||||
|
/// </summary>
|
||||||
|
public class Ww_InnerGroupModel
|
||||||
|
{
|
||||||
|
public string roomid { get; set; }
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public string roomname { get; set; }
|
||||||
|
public string creator { get; set; }
|
||||||
|
public string creatorname { get; set; }
|
||||||
|
public string notice { get; set; }
|
||||||
|
public long room_create_time { get; set; }
|
||||||
|
public string members { get; set; }
|
||||||
|
public int membernum { get; set; }
|
||||||
|
public DateTime? ctime { get; set; }
|
||||||
|
public DateTime? ltimeupdate { get; set; }
|
||||||
|
|
||||||
|
public string ltimeupdatestr { get; set; }
|
||||||
|
|
||||||
|
public string createtime { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
public class Ww_InnerUserModel
|
||||||
|
{
|
||||||
|
public string userid { get; set; }
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public string deptuserid { get; set; }
|
||||||
|
public DateTime? ctime { get; set; }
|
||||||
|
public DateTime? lmsgtime { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public string department { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 头像
|
||||||
|
/// </summary>
|
||||||
|
public string avatar { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// json信息
|
||||||
|
/// </summary>
|
||||||
|
public string exinfo { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
public class Ww_MomentModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public string moment_id { get; set; }
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public string creator { get; set; }
|
||||||
|
public string create_time { get; set; }
|
||||||
|
public int create_type { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 见范围类型。0:部分可见 1:公开
|
||||||
|
/// </summary>
|
||||||
|
public int visible_type { get; set; }
|
||||||
|
public string text { get; set; }
|
||||||
|
public string image { get; set; }
|
||||||
|
public string video { get; set; }
|
||||||
|
public string link { get; set; }
|
||||||
|
public string location { get; set; }
|
||||||
|
public DateTime ctime { get; set; }
|
||||||
|
public string ctimestr { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 客服的uname信息
|
||||||
|
/// </summary>
|
||||||
|
public string uname { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 客服的扩展信息,比如头像
|
||||||
|
/// </summary>
|
||||||
|
public string exinfo { get; set; }
|
||||||
|
public string corpname { get; set; }
|
||||||
|
}
|
||||||
|
public class MomentContent
|
||||||
|
{
|
||||||
|
public string content { get; set; }
|
||||||
|
}
|
||||||
|
public class MomentImage
|
||||||
|
{
|
||||||
|
public string media_id { get; set; }
|
||||||
|
}
|
||||||
|
public class MomentVideo
|
||||||
|
{
|
||||||
|
public string media_id { get; set; }
|
||||||
|
public string thumb_media_id { get; set; }
|
||||||
|
}
|
||||||
|
public class MomentAvator
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 头像
|
||||||
|
/// </summary>
|
||||||
|
public string avatar { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 缩略图
|
||||||
|
/// </summary>
|
||||||
|
public string thumb_avatar { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MomentLocation
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
public class Ww_MsgRoom
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 企业号ID
|
||||||
|
/// </summary>
|
||||||
|
public string corp { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 房间ID
|
||||||
|
/// </summary>
|
||||||
|
public string roomid { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 成员列表
|
||||||
|
/// </summary>
|
||||||
|
public string userlist { get; set; }
|
||||||
|
public DateTime? ctime { get; set; }
|
||||||
|
public string ctimestr { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 群名称
|
||||||
|
/// </summary>
|
||||||
|
public string roomname { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 群成员数量
|
||||||
|
/// </summary>
|
||||||
|
public int membernum { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 内部群
|
||||||
|
/// </summary>
|
||||||
|
public class Ww_OuterGroupModel
|
||||||
|
{
|
||||||
|
public string chat_id { get; set; }
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public string owner { get; set; }
|
||||||
|
public string creatorname { get; set; }
|
||||||
|
public string notice { get; set; }
|
||||||
|
public long create_time { get; set; }
|
||||||
|
public string member_list { get; set; }
|
||||||
|
public int membernum { get; set; }
|
||||||
|
public DateTime? ctime { get; set; }
|
||||||
|
public DateTime? ltimeupdate { get; set; }
|
||||||
|
|
||||||
|
public string ltimeupdatestr { get; set; }
|
||||||
|
|
||||||
|
public string createtime { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
public class Ww_RecordModel
|
||||||
|
{
|
||||||
|
public int ? deptid { get; set; }
|
||||||
|
public string voiceid { get; set; }
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public string fromer { get; set; }
|
||||||
|
public string tolist { get; set; }
|
||||||
|
public string roomid { get; set; }
|
||||||
|
public string msgid { get; set; }
|
||||||
|
public DateTime starttime { get; set; }
|
||||||
|
public string starttimestr { get; set; }
|
||||||
|
public DateTime endtime { get; set; }
|
||||||
|
public string endtimestr { get; set; }
|
||||||
|
public string filename { get; set; }
|
||||||
|
public int length { get; set; }
|
||||||
|
public string ctime { get; set; }
|
||||||
|
public int calltype { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 企业号名称
|
||||||
|
/// </summary>
|
||||||
|
public string corpname { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 客服名称
|
||||||
|
/// </summary>
|
||||||
|
public string kefuname { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 客户名称
|
||||||
|
/// </summary>
|
||||||
|
public string customername { get; set; }
|
||||||
|
|
||||||
|
public string remarkname { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 内部群成员
|
||||||
|
/// </summary>
|
||||||
|
public class Ww_Roomchat_Member
|
||||||
|
{
|
||||||
|
public string memberid { get; set; }
|
||||||
|
public long jointime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
public partial class Ww_User_ExtuserModel
|
||||||
|
{
|
||||||
|
public string userid { get; set; }
|
||||||
|
public DateTime? ctime { get; set; }
|
||||||
|
public string cname { get; set; }
|
||||||
|
public DateTime? lmsgtime { get; set; }
|
||||||
|
public string avatar { get; set; }
|
||||||
|
}
|
||||||
|
public partial class Ww_User_ExtuserModel
|
||||||
|
{
|
||||||
|
public string exinfo { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 公司ID
|
||||||
|
/// </summary>
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public string corpname { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
public class Ww_exinfoShow
|
||||||
|
{
|
||||||
|
public string external_userid { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public string remark { get; set; }
|
||||||
|
public string createtime { get; set; }
|
||||||
|
public string remark_mobiles { get; set; }
|
||||||
|
}
|
||||||
|
public class Ww_User_ExtuserShow
|
||||||
|
{
|
||||||
|
public string external_userid { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public string remark { get; set; }
|
||||||
|
public string createtime { get; set; }
|
||||||
|
public string remark_mobiles { get; set; }
|
||||||
|
public DateTime? lmsgtime { get; set; }
|
||||||
|
public string avatar { get; set; }
|
||||||
|
public string corpid { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
public class Ww_hhuserModel
|
||||||
|
{
|
||||||
|
public string userid { get; set; }
|
||||||
|
public string uname { get; set; }
|
||||||
|
public string exinfo { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 公司ID
|
||||||
|
/// </summary>
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public int? deptid { get; set; }
|
||||||
|
public string deptname { get; set; }
|
||||||
|
public string corpname { get; set; }
|
||||||
|
public DateTime? lmsgtime { get; set; }
|
||||||
|
public string remarkname { get; set; }
|
||||||
|
|
||||||
|
public int? eid { get; set; }
|
||||||
|
public string eidandname { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 首次聊天时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? fmsgtime { get; set; }
|
||||||
|
|
||||||
|
public string alias { get; set; }
|
||||||
|
public string mobile { get; set; }
|
||||||
|
public string email { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
public class Ww_room
|
||||||
|
{
|
||||||
|
public string roomlist { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
public class Wx_ExuserModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 客服ID
|
||||||
|
/// </summary>
|
||||||
|
public string userid { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 客服名称
|
||||||
|
/// </summary>
|
||||||
|
public string uname { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 客服公司ID
|
||||||
|
/// </summary>
|
||||||
|
public string corpid { get; set; }
|
||||||
|
public string corpname { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 关联客户ID
|
||||||
|
/// </summary>
|
||||||
|
public string extuserid { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 关联客户名称
|
||||||
|
/// </summary>
|
||||||
|
public string name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 客户扩展信息
|
||||||
|
/// </summary>
|
||||||
|
public string exinfo { get; set; }
|
||||||
|
public int isOutDept { get; set; }
|
||||||
|
public string deptname { get; set; }
|
||||||
|
public int? deptid { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
public class Wx_HongBaoModel
|
||||||
|
{
|
||||||
|
public string sendid { get; set; }
|
||||||
|
public string sendusername { get; set; }
|
||||||
|
public string sendNickName { get; set; }
|
||||||
|
public string sendconremark { get; set; }
|
||||||
|
public string mntype { get; set; }
|
||||||
|
public string title { get; set; }
|
||||||
|
public string username { get; set; }
|
||||||
|
public string getNickName { get; set; }
|
||||||
|
public string getconremark { get; set; }
|
||||||
|
public DateTime? createtime { get; set; }
|
||||||
|
public DateTime? sendTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
public class Wx_Rcontact_List
|
||||||
|
{
|
||||||
|
public int pkid { get; set; }
|
||||||
|
public string jobwxusername { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 工作微信昵称
|
||||||
|
/// </summary>
|
||||||
|
public string jobnickname { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 工作微信号
|
||||||
|
/// </summary>
|
||||||
|
public string jobalias { get; set; }
|
||||||
|
public string username { get; set; }
|
||||||
|
public string alias { get; set; }
|
||||||
|
public string conremark { get; set; }
|
||||||
|
public string nickname { get; set; }
|
||||||
|
public int? type { get; set; }
|
||||||
|
|
||||||
|
public DateTime? ctime { get; set; }
|
||||||
|
public string ctimestr { get; set; }
|
||||||
|
public int? lastchattime { get; set; }
|
||||||
|
public DateTime? rctime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
public class Wx_WorkAccountModel
|
||||||
|
{
|
||||||
|
public int pkid { get; set; }
|
||||||
|
public string username { get; set; }
|
||||||
|
public string alias { get; set; }
|
||||||
|
public string conremark { get; set; }
|
||||||
|
public string nickname { get; set; }
|
||||||
|
public string pyinitial { get; set; }
|
||||||
|
public int type { get; set; }
|
||||||
|
public DateTime ctime { get; set; }
|
||||||
|
public int? isfenghao { get; set; }
|
||||||
|
public DateTime? fenghaotime { get; set; }
|
||||||
|
public string status { get; set; }
|
||||||
|
public string version { get; set; }
|
||||||
|
public DateTime? lasttime { get; set; }
|
||||||
|
public DateTime? lastfriendtime { get; set; }
|
||||||
|
public string lastfriendtimestr { get; set; }
|
||||||
|
public DateTime? lastmsgtime { get; set; }
|
||||||
|
public string lastmsgtimestr { get; set; }
|
||||||
|
public string lasttimestr { get; set; }
|
||||||
|
public int isOnlie { get; set; }
|
||||||
|
public string uin { get; set; }
|
||||||
|
public string forever_uin { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,102 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
public class Wx_WorkRcontactModel
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WX_WorkRCONTACT
|
||||||
|
{
|
||||||
|
public decimal PKID { get; set; }
|
||||||
|
|
||||||
|
public string JOBWXUSERNAME { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public string USERNAME { get; set; }
|
||||||
|
|
||||||
|
public string ALIAS { get; set; }
|
||||||
|
|
||||||
|
public string CONREMARK { get; set; }
|
||||||
|
public string NICKNAME { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 最后聊天时间
|
||||||
|
/// </summary>
|
||||||
|
public decimal LASTCHARTIME { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///关联wx_friendsrelation 的username
|
||||||
|
/// </summary>
|
||||||
|
public string FUSERNAME { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 关联wx_workaccount 的username
|
||||||
|
/// </summary>
|
||||||
|
public string WUSERNAME { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 关联wx_workaccount_note 的username
|
||||||
|
/// </summary>
|
||||||
|
public string NUSERNAME { get; set; }
|
||||||
|
public decimal isblacklist { get; set; }
|
||||||
|
public decimal isunservedlist { get; set; }
|
||||||
|
public DateTime ctime { get; set; }
|
||||||
|
public int rtype { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class Wx_WorkGroupRcontact
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 群名称
|
||||||
|
/// </summary>
|
||||||
|
public string groupName { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 群名称
|
||||||
|
/// </summary>
|
||||||
|
public string shortName { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 群号
|
||||||
|
/// </summary>
|
||||||
|
public string chatRoomName { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 群所属人
|
||||||
|
/// </summary>
|
||||||
|
public string roomowner { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? createTime { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 最近聊天时间
|
||||||
|
/// </summary>
|
||||||
|
public decimal LASTCHARTIME { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WX_GroupDetial
|
||||||
|
{
|
||||||
|
//public decimal PKID { get; set; }
|
||||||
|
|
||||||
|
public string JOBWXUSERNAME { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public string USERNAME { get; set; }
|
||||||
|
|
||||||
|
public string ALIAS { get; set; }
|
||||||
|
|
||||||
|
public string CONREMARK { get; set; }
|
||||||
|
public string NICKNAME { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 最后聊天时间
|
||||||
|
/// </summary>
|
||||||
|
public decimal LASTCHARTIME { get; set; }
|
||||||
|
|
||||||
|
public decimal blacknumber { get; set; }
|
||||||
|
public decimal repeatnumber { get; set; }
|
||||||
|
public DateTime ctime { get; set; }
|
||||||
|
public int status { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Mini.Model.ViewModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取工作微信的头像类
|
||||||
|
/// </summary>
|
||||||
|
public class thumb_avatar_Model
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 头像高清图
|
||||||
|
/// </summary>
|
||||||
|
public string avatar { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 头像缩略图
|
||||||
|
/// </summary>
|
||||||
|
public string thumb_avatar { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue