1
This commit is contained in:
25
.dockerignore
Normal file
25
.dockerignore
Normal file
@@ -0,0 +1,25 @@
|
||||
**/.classpath
|
||||
**/.dockerignore
|
||||
**/.env
|
||||
**/.git
|
||||
**/.gitignore
|
||||
**/.project
|
||||
**/.settings
|
||||
**/.toolstarget
|
||||
**/.vs
|
||||
**/.vscode
|
||||
**/*.*proj.user
|
||||
**/*.dbmdl
|
||||
**/*.jfm
|
||||
**/azds.yaml
|
||||
**/bin
|
||||
**/charts
|
||||
**/docker-compose*
|
||||
**/Dockerfile*
|
||||
**/node_modules
|
||||
**/npm-debug.log
|
||||
**/obj
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
LICENSE
|
||||
README.md
|
||||
402
.gitignore
vendored
Normal file
402
.gitignore
vendored
Normal file
@@ -0,0 +1,402 @@
|
||||
# ---> VisualStudio
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
# but not Directory.Build.rsp, as it configures directory-level build defaults
|
||||
!Directory.Build.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.tlog
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||
*.vbp
|
||||
|
||||
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||
*.dsw
|
||||
*.dsp
|
||||
|
||||
# Visual Studio 6 technical files
|
||||
*.ncb
|
||||
*.aps
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# Visual Studio History (VSHistory) files
|
||||
.vshistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
# VS Code files for those working on multiple tools
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Windows Installer files from build outputs
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# JetBrains Rider
|
||||
*.sln.iml
|
||||
|
||||
947
iMES.Bi.API/API/Class1.cs
Normal file
947
iMES.Bi.API/API/Class1.cs
Normal file
@@ -0,0 +1,947 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace QJY.API.API
|
||||
{
|
||||
class Class1
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
#region 添加评论
|
||||
/// <summary>
|
||||
/// 添加评论
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="msg"></param>
|
||||
/// <param name="strParamData"></param>
|
||||
/// <param name="strUserName"></param>
|
||||
public void ADDCOMENT(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
|
||||
{
|
||||
string strMsgType = context.Request["MsgType"] ?? "";
|
||||
string strMsgLYID = context.Request["MsgLYID"] ?? "";
|
||||
string strPoints = context.Request["Points"] ?? "0";
|
||||
string strfjID = context.Request["fjID"] ?? "";
|
||||
string strTLID = context.Request["TLID"] ?? "";
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(P1) && APIHelp.TestWB(P1) != "0")
|
||||
{
|
||||
msg.ErrorMsg = "您得发言涉及违规内容,请完善后再发";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
JH_Auth_TL Model = new JH_Auth_TL();
|
||||
Model.CRDate = DateTime.Now;
|
||||
Model.CRUser = UserInfo.User.UserName;
|
||||
Model.CRUserName = UserInfo.User.UserRealName;
|
||||
Model.MSGContent = P1;
|
||||
Model.ComId = UserInfo.User.ComId;
|
||||
Model.MSGTLYID = strMsgLYID;
|
||||
Model.MSGType = strMsgType;
|
||||
Model.MSGisHasFiles = strfjID;
|
||||
Model.Remark1 = P1;
|
||||
|
||||
if (strTLID != "")
|
||||
{
|
||||
int TLID = Int32.Parse(strTLID);
|
||||
var tl = new JH_Auth_TLB().GetEntity(p => p.ID == TLID);
|
||||
if (tl != null)
|
||||
{
|
||||
Model.TLID = TLID;
|
||||
Model.ReUser = tl.CRUserName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int record = 0;
|
||||
int.TryParse(strPoints, out record);
|
||||
Model.Points = record;
|
||||
new JH_Auth_TLB().Insert(Model);
|
||||
if (Model.MSGType == "GZBG" || Model.MSGType == "RWGL" || Model.MSGType == "TSSQ")
|
||||
{
|
||||
int modelId = int.Parse(Model.MSGTLYID);
|
||||
string CRUser = "";
|
||||
string Content = UserInfo.User.UserRealName + "评论了您的";
|
||||
|
||||
|
||||
if (CRUser != UserInfo.User.UserName)
|
||||
{
|
||||
SZHL_TXSX CSTX = new SZHL_TXSX();
|
||||
CSTX.Date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
CSTX.APIName = "XTGL";
|
||||
CSTX.ComId = UserInfo.User.ComId;
|
||||
CSTX.FunName = "SENDPLMSG";
|
||||
CSTX.CRUserRealName = UserInfo.User.UserRealName;
|
||||
CSTX.MsgID = modelId.ToString();
|
||||
|
||||
CSTX.TXContent = Content;
|
||||
CSTX.ISCS = "N";
|
||||
CSTX.TXUser = CRUser;
|
||||
CSTX.TXMode = Model.MSGType;
|
||||
CSTX.CRUser = UserInfo.User.UserName;
|
||||
|
||||
TXSX.TXSXAPI.AddALERT(CSTX); //时间为发送时间
|
||||
}
|
||||
}
|
||||
|
||||
msg.Result = Model;
|
||||
if (Model.MSGisHasFiles == "")
|
||||
Model.MSGisHasFiles = "0";
|
||||
msg.Result1 = new FT_FileB().GetEntities(" ID in (" + Model.MSGisHasFiles + ")");
|
||||
}
|
||||
public void SENDPLMSG(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
|
||||
{
|
||||
SZHL_TXSX TX = JsonConvert.DeserializeObject<SZHL_TXSX>(P1);
|
||||
Article ar0 = new Article();
|
||||
ar0.Title = TX.TXContent;
|
||||
ar0.Description = "";
|
||||
ar0.Url = TX.MsgID;
|
||||
List<Article> al = new List<Article>();
|
||||
al.Add(ar0);
|
||||
if (!string.IsNullOrEmpty(TX.TXUser))
|
||||
{
|
||||
try
|
||||
{
|
||||
//发送PC消息
|
||||
UserInfo = new JH_Auth_UserB().GetUserInfo(TX.ComId.Value, TX.CRUser);
|
||||
WXHelp wx = new WXHelp(UserInfo.QYinfo);
|
||||
wx.SendTH(al, TX.TXMode, "A", TX.TXUser);
|
||||
new JH_Auth_User_CenterB().SendMsg(UserInfo, TX.TXMode, TX.TXContent, TX.MsgID, TX.TXUser);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
//发送微信消息
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取评论列表
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="msg"></param>
|
||||
/// <param name="P1"></param>
|
||||
/// <param name="P2"></param>
|
||||
/// <param name="UserInfo"></param>
|
||||
public void GETPLLIST(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
|
||||
{
|
||||
string userName = UserInfo.User.UserName;
|
||||
string strWhere = " JH_Auth_TL.ComId=" + UserInfo.User.ComId;
|
||||
if (P1 != "")
|
||||
{
|
||||
strWhere += string.Format(" And JH_Auth_TL.MSGContent like '%{0}%'", P1);
|
||||
}
|
||||
int page = 0;
|
||||
int pagecount = 8;
|
||||
int.TryParse(context["p"] == null ? "0" : context["p"].ToString(), out page);
|
||||
int.TryParse(context["pagecount"] == null ? "8" : context["pagecount"].ToString(), out pagecount);//页数
|
||||
page = page == 0 ? 1 : page;
|
||||
int total = 0;
|
||||
DataTable dt = new JH_Auth_TLB().GetDataPager(" JH_Auth_TL LEFT JOIN SZHL_TSSQ ON JH_Auth_TL.MSGTLYID=SZHL_TSSQ.ID ", " JH_Auth_TL.*,SZHL_TSSQ.HTNR ", pagecount, page, " JH_Auth_TL.CRDate desc", strWhere, ref total);
|
||||
msg.Result = dt;
|
||||
msg.Result1 = total;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
public void UPLOADFILE(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
int fid = 3;
|
||||
if (!string.IsNullOrEmpty(P1))
|
||||
{
|
||||
fid = Int32.Parse(P1);
|
||||
}
|
||||
|
||||
List<FT_File> ls = new List<FT_File>();
|
||||
for (int i = 0; i < context.Request.Files.Count; i++)
|
||||
{
|
||||
HttpPostedFile uploadFile = context.Request.Files[i];
|
||||
|
||||
|
||||
string originalName = uploadFile.FileName;
|
||||
|
||||
|
||||
|
||||
string[] temp = uploadFile.FileName.Split('.');
|
||||
|
||||
//保存图片
|
||||
|
||||
string filename = System.Guid.NewGuid() + "." + temp[temp.Length - 1].ToLower();
|
||||
string md5 = new CommonHelp().SaveFile(UserInfo.QYinfo, filename, uploadFile);
|
||||
|
||||
//MP4上传阿里云
|
||||
if (Path.GetExtension(originalName).ToLower() == ".mp4")
|
||||
{
|
||||
md5 = md5.Replace("\"", "").Split(',')[0];
|
||||
AliyunHelp.UploadToOSS(md5, "mp4", uploadFile.InputStream);
|
||||
}
|
||||
|
||||
FT_File newfile = new FT_File();
|
||||
newfile.ComId = UserInfo.User.ComId;
|
||||
newfile.Name = uploadFile.FileName.Substring(0, uploadFile.FileName.LastIndexOf('.'));
|
||||
newfile.FileMD5 = md5.Replace("\"", "").Split(',')[0];
|
||||
newfile.zyid = md5.Split(',').Length == 2 ? md5.Split(',')[1] : md5.Split(',')[0];
|
||||
newfile.FileSize = uploadFile.InputStream.Length.ToString();
|
||||
newfile.FileVersin = 0;
|
||||
newfile.CRDate = DateTime.Now;
|
||||
newfile.CRUser = UserInfo.User.UserName;
|
||||
newfile.UPDDate = DateTime.Now;
|
||||
newfile.UPUser = UserInfo.User.UserName;
|
||||
newfile.FileExtendName = temp[temp.Length - 1].ToLower();
|
||||
newfile.FolderID = fid;
|
||||
if (new List<string>() { "txt", "html", "doc", "mp4", "flv", "ogg", "jpg", "gif", "png", "bmp", "jpeg" }.Contains(newfile.FileExtendName.ToLower()))
|
||||
{
|
||||
newfile.ISYL = "Y";
|
||||
}
|
||||
if (new List<string>() { "pdf", "doc", "docx", "ppt", "pptx", "xls", "xlsx" }.Contains(newfile.FileExtendName.ToLower()))
|
||||
{
|
||||
newfile.ISYL = "Y";
|
||||
//newfile.YLUrl = UserInfo.QYinfo.FileServerUrl + "/document/YL/" + newfile.zyid;
|
||||
newfile.YLUrl = "https://www.txywpx.com/ViewV5/Base/doc.html?zyid=" + newfile.zyid;
|
||||
}
|
||||
|
||||
if (P2 != "")
|
||||
{
|
||||
newfile.Name = P2.Substring(0, P2.LastIndexOf('.')); //文件名
|
||||
}
|
||||
|
||||
new FT_FileB().Insert(newfile);
|
||||
|
||||
int filesize = 0;
|
||||
int.TryParse(newfile.FileSize, out filesize);
|
||||
new FT_FileB().AddSpace(UserInfo.User.ComId.Value, filesize);
|
||||
//msg.Result = newfile;
|
||||
ls.Add(newfile);
|
||||
}
|
||||
msg.Result = ls;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
msg.ErrorMsg = "上传图片";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 上传文件
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="msg"></param>
|
||||
/// <param name="P1"></param>
|
||||
/// <param name="P2"></param>
|
||||
/// <param name="UserInfo"></param>
|
||||
public void UPLOADFILEV1(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
int fid = 3;
|
||||
if (!string.IsNullOrEmpty(P1))
|
||||
{
|
||||
fid = Int32.Parse(P1);
|
||||
}
|
||||
CommonHelp.WriteLOG("文件数量" + context.Request.Files.Count);
|
||||
|
||||
List<FT_File> ls = new List<FT_File>();
|
||||
for (int i = 0; i < context.Request.Files.Count; i++)
|
||||
{
|
||||
HttpPostedFile uploadFile = context.Request.Files[i];
|
||||
string originalName = uploadFile.FileName;
|
||||
string[] temp = uploadFile.FileName.Split('.');
|
||||
|
||||
//保存图片
|
||||
|
||||
string filename = System.Guid.NewGuid() + "." + temp[temp.Length - 1].ToLower();
|
||||
string md5 = new CommonHelp().SaveFile(UserInfo.QYinfo, filename, uploadFile);
|
||||
|
||||
string json = "[{filename:'" + uploadFile.FileName + "',md5:'" + md5.Split(',')[0] + "',zyid:'" + md5.Split(',')[1] + "',filesize:'" + uploadFile.InputStream.Length.ToString() + "'}]";
|
||||
QYWDManage qywd = new QYWDManage();
|
||||
|
||||
//MP4上传阿里云
|
||||
//if (Path.GetExtension(originalName).ToLower() == ".mp4")
|
||||
//{
|
||||
// md5 = md5.Replace("\"", "").Split(',')[0];
|
||||
// AliyunHelp.UploadToOSS(md5, "mp4", uploadFile.InputStream);
|
||||
//}
|
||||
|
||||
CommonHelp.WriteLOG("调用参数" + fid.ToString());
|
||||
qywd.ADDFILE(context, msg, json, fid.ToString(), UserInfo);
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
msg.ErrorMsg = "上传图片";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上传文件(文档中心)
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="msg"></param>
|
||||
/// <param name="P1"></param>
|
||||
/// <param name="P2"></param>
|
||||
/// <param name="UserInfo"></param>
|
||||
public void UPLOADFILES(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpPostedFile uploadFile = context.Request.Files["upFile"];
|
||||
string originalName = uploadFile.FileName;
|
||||
string[] temp = uploadFile.FileName.Split('.');
|
||||
|
||||
//保存图片
|
||||
string filename = System.Guid.NewGuid() + "." + temp[temp.Length - 1].ToLower();
|
||||
string md5 = new CommonHelp().SaveFile(UserInfo.QYinfo, filename, uploadFile);
|
||||
string json = "[{filename:'" + uploadFile.FileName + "',md5:" + md5 + ",filesize:'" + uploadFile.InputStream.Length.ToString() + "'}]";
|
||||
|
||||
QYWDManage qywd = new QYWDManage();
|
||||
qywd.ADDFILE(context, msg, json, P1, UserInfo);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
msg.ErrorMsg = "上传图片";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region excel转换为table
|
||||
|
||||
/// <summary>
|
||||
/// excel转换为table
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="msg"></param>
|
||||
/// <param name="P1"></param>
|
||||
/// <param name="P2"></param>
|
||||
/// <param name="UserInfo"></param>
|
||||
public void EXCELTOTABLE(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
DataTable dt = new DataTable();
|
||||
HttpPostedFile _upfile = context.Request.Files["upFile"];
|
||||
string headrow = context.Request["headrow"] ?? "0";//头部开始行下标
|
||||
if (_upfile == null)
|
||||
{
|
||||
msg.ErrorMsg = "请选择要上传的文件 ";
|
||||
}
|
||||
else
|
||||
{
|
||||
string fileName = _upfile.FileName;/*获取文件名: C:\Documents and Settings\Administrator\桌面\123.jpg*/
|
||||
string suffix = fileName.Substring(fileName.LastIndexOf(".") + 1).ToLower();/*获取后缀名并转为小写: jpg*/
|
||||
int bytes = _upfile.ContentLength;//获取文件的字节大小
|
||||
if (suffix == "xls" || suffix == "xlsx")
|
||||
{
|
||||
IWorkbook workbook = null;
|
||||
|
||||
Stream stream = _upfile.InputStream;
|
||||
|
||||
if (suffix == "xlsx") // 2007版本
|
||||
{
|
||||
workbook = new XSSFWorkbook(stream);
|
||||
}
|
||||
else if (suffix == "xls") // 2003版本
|
||||
{
|
||||
workbook = new HSSFWorkbook(stream);
|
||||
}
|
||||
|
||||
//获取excel的第一个sheet
|
||||
ISheet sheet = workbook.GetSheetAt(0);
|
||||
|
||||
//获取sheet的第一行
|
||||
IRow headerRow = sheet.GetRow(int.Parse(headrow));
|
||||
|
||||
//一行最后一个方格的编号 即总的列数
|
||||
int cellCount = headerRow.LastCellNum;
|
||||
//最后一列的标号 即总的行数
|
||||
int rowCount = sheet.LastRowNum;
|
||||
if (rowCount <= int.Parse(headrow))
|
||||
{
|
||||
msg.ErrorMsg = "文件中无数据! ";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
List<JH_Auth_ExtendDataB.IMPORTYZ> yz = new List<JH_Auth_ExtendDataB.IMPORTYZ>();
|
||||
yz = new JH_Auth_ExtendDataB().GetTable(P1, UserInfo.QYinfo.ComId);//获取字段
|
||||
string str1 = string.Empty;//验证字段是否包含列名
|
||||
//列名
|
||||
for (int i = 0; i < cellCount; i++)
|
||||
{
|
||||
string strlm = headerRow.GetCell(i).ToString().Trim();
|
||||
if (yz.Count > 0)
|
||||
{
|
||||
#region 字段是否包含列名验证
|
||||
var l = yz.Where(p => p.Name == strlm);//验证字段是否包含列名
|
||||
if (l.Count() == 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str1))
|
||||
{
|
||||
str1 = "文件中的【" + strlm + "】";
|
||||
}
|
||||
else
|
||||
{
|
||||
str1 = str1 + "、【" + strlm + "】";
|
||||
}
|
||||
|
||||
strlm = strlm + "<span style='color:red;'>不会导入</span>";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
dt.Columns.Add(strlm);//添加列名
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(str1))
|
||||
{
|
||||
str1 = str1 + " 不属于当前导入的字段!<br>";
|
||||
}
|
||||
|
||||
dt.Columns.Add("status", Type.GetType("System.String"));
|
||||
|
||||
string str2 = string.Empty;//验证必填字段是否存在
|
||||
|
||||
#region 必填字段在文件中存不存在验证
|
||||
foreach (var v in yz.Where(p => p.IsNull == 1))
|
||||
{
|
||||
if (!dt.Columns.Contains(v.Name))
|
||||
{
|
||||
if (string.IsNullOrEmpty(str2))
|
||||
{
|
||||
str2 = "当前导入的必填字段:【" + v.Name + "】";
|
||||
}
|
||||
else
|
||||
{
|
||||
str2 = str2 + "、【" + v.Name + "】";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(str2))
|
||||
{
|
||||
str2 = str2 + " 在文件中不存在!<br>";
|
||||
}
|
||||
#endregion
|
||||
|
||||
string str3 = string.Empty;//验证必填字段是否有值
|
||||
string str4 = string.Empty;//验证字段是否重复
|
||||
string str5 = string.Empty;//验证字段是否存在
|
||||
|
||||
for (int i = (sheet.FirstRowNum + int.Parse(headrow) + 1); i <= sheet.LastRowNum; i++)
|
||||
{
|
||||
string str31 = string.Empty;
|
||||
string str41 = string.Empty;
|
||||
string str42 = string.Empty;
|
||||
string str51 = string.Empty;
|
||||
|
||||
DataRow dr = dt.NewRow();
|
||||
bool bl = false;
|
||||
IRow row = sheet.GetRow(i);
|
||||
|
||||
dr["status"] = "0";
|
||||
|
||||
for (int j = row.FirstCellNum; j < cellCount; j++)
|
||||
{
|
||||
string strsj = row.GetCell(j) != null ? row.GetCell(j).ToString().Trim() : "";
|
||||
if (strsj != "")
|
||||
{
|
||||
bl = true;
|
||||
}
|
||||
|
||||
foreach (var v in yz.Where(p => p.Name == headerRow.GetCell(j).ToString().Trim()))
|
||||
{
|
||||
if (strsj == "")
|
||||
{
|
||||
#region 必填字段验证
|
||||
if (v.IsNull == 1)
|
||||
{
|
||||
//strsj = "<span style='color:red;'>必填</span>";
|
||||
|
||||
if (string.IsNullOrEmpty(str31))
|
||||
{
|
||||
str31 = "第" + (i + 1) + "行的必填字段:【" + v.Name + "】";
|
||||
}
|
||||
else
|
||||
{
|
||||
str31 = str31 + "、【" + v.Name + "】";
|
||||
}
|
||||
dr["status"] = "2";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
else
|
||||
{
|
||||
#region 长度验证
|
||||
if (v.Length != 0)
|
||||
{
|
||||
if (Encoding.Default.GetBytes(strsj).Length > v.Length)
|
||||
{
|
||||
strsj = strsj + "<span style='color:red;'>长度不能超过" + v.Length + "</span>";
|
||||
dr["status"] = "2";
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region 重复验证
|
||||
if (!string.IsNullOrEmpty(v.IsRepeat))
|
||||
{
|
||||
#region 与现有数据比较是否重复
|
||||
string[] strRS = v.IsRepeat.Split('|');
|
||||
|
||||
var cf = new JH_Auth_UserB().GetDTByCommand("select * from " + strRS[0] + " where " + strRS[1] + "= '" + strsj + "' and ComId='" + UserInfo.QYinfo.ComId + "'");
|
||||
if (cf.Rows.Count > 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str41))
|
||||
{
|
||||
str41 = "第" + (i + 1) + "行的字段:【" + v.Name + "】" + strsj;
|
||||
}
|
||||
else
|
||||
{
|
||||
str41 = str41 + "、【" + v.Name + "】:" + strsj;
|
||||
}
|
||||
dr["status"] = "2";
|
||||
}
|
||||
#endregion
|
||||
#region 与Excel中数据比较是否重复
|
||||
DataRow[] drs = dt.Select(headerRow.GetCell(j).ToString().Trim() + "='" + strsj + "'");
|
||||
if (drs.Length > 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str42))
|
||||
{
|
||||
str42 = "第" + (i + 1) + "行的字段:【" + v.Name + "】" + strsj;
|
||||
}
|
||||
else
|
||||
{
|
||||
str42 = str42 + "、【" + v.Name + "】" + strsj;
|
||||
}
|
||||
dr["status"] = "2";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
#region 存在验证
|
||||
if (!string.IsNullOrEmpty(v.IsExist))
|
||||
{
|
||||
string[] strES = v.IsExist.Split('|');
|
||||
|
||||
var cz = new JH_Auth_UserB().GetDTByCommand("select * from " + strES[0] + " where " + strES[1] + "= '" + strsj + "' and ComId='" + UserInfo.QYinfo.ComId + "'");
|
||||
if (cz.Rows.Count == 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str51))
|
||||
{
|
||||
str51 = "第" + (i + 1) + "行的字段:【" + v.Name + "】" + strsj;
|
||||
}
|
||||
else
|
||||
{
|
||||
str51 = str51 + "、【" + v.Name + "】" + strsj;
|
||||
}
|
||||
dr["status"] = "2";
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
dr[j] = strsj;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(str31))
|
||||
{
|
||||
str31 = str31 + " 不能为空!<br>";
|
||||
str3 = str3 + str31;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(str41))
|
||||
{
|
||||
str41 = str41 + " 已经存在!<br>";
|
||||
str4 = str4 + str41;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(str42))
|
||||
{
|
||||
str42 = str42 + " 在文件中已经存在!<br>";
|
||||
str4 = str4 + str42;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(str51))
|
||||
{
|
||||
str51 = str51 + " 不存在!<br>";
|
||||
str5 = str5 + str51;
|
||||
}
|
||||
|
||||
if (bl)
|
||||
{
|
||||
dt.Rows.Add(dr);
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(str2) && string.IsNullOrEmpty(str3) && string.IsNullOrEmpty(str4) && string.IsNullOrEmpty(str5))
|
||||
{
|
||||
msg.Result = dt;
|
||||
}
|
||||
|
||||
msg.Result1 = str1 + str2 + str3 + str4 + str5;
|
||||
}
|
||||
|
||||
sheet = null;
|
||||
workbook = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.ErrorMsg = "请上传excel文件 ";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//msg.ErrorMsg = ex.ToString();
|
||||
msg.ErrorMsg = "导入失败!";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 导出模板excel
|
||||
|
||||
/// <summary>
|
||||
/// 导出模板excel
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="msg"></param>
|
||||
/// <param name="P1"></param>
|
||||
/// <param name="P2"></param>
|
||||
/// <param name="UserInfo"></param>
|
||||
public void EXPORTTOEXCEL(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<JH_Auth_ExtendDataB.IMPORTYZ> yz = new List<JH_Auth_ExtendDataB.IMPORTYZ>();
|
||||
yz = new JH_Auth_ExtendDataB().GetTable(P1, UserInfo.QYinfo.ComId);//获取字段
|
||||
if (yz.Count > 0)
|
||||
{
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
ISheet sheet = workbook.CreateSheet("Sheet1");
|
||||
|
||||
ICellStyle HeadercellStyle = workbook.CreateCellStyle();
|
||||
HeadercellStyle.BorderBottom = BorderStyle.Thin;
|
||||
HeadercellStyle.BorderLeft = BorderStyle.Thin;
|
||||
HeadercellStyle.BorderRight = BorderStyle.Thin;
|
||||
HeadercellStyle.BorderTop = BorderStyle.Thin;
|
||||
HeadercellStyle.Alignment = HorizontalAlignment.Center;
|
||||
HeadercellStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.SkyBlue.Index;
|
||||
HeadercellStyle.FillPattern = FillPattern.SolidForeground;
|
||||
HeadercellStyle.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.SkyBlue.Index;
|
||||
|
||||
//字体
|
||||
NPOI.SS.UserModel.IFont headerfont = workbook.CreateFont();
|
||||
headerfont.Boldweight = (short)FontBoldWeight.Bold;
|
||||
headerfont.FontHeightInPoints = 12;
|
||||
HeadercellStyle.SetFont(headerfont);
|
||||
|
||||
|
||||
//用column name 作为列名
|
||||
int icolIndex = 0;
|
||||
IRow headerRow = sheet.CreateRow(0);
|
||||
foreach (var l in yz)
|
||||
{
|
||||
ICell cell = headerRow.CreateCell(icolIndex);
|
||||
cell.SetCellValue(l.Name);
|
||||
cell.CellStyle = HeadercellStyle;
|
||||
icolIndex++;
|
||||
}
|
||||
|
||||
ICellStyle cellStyle = workbook.CreateCellStyle();
|
||||
|
||||
//为避免日期格式被Excel自动替换,所以设定 format 为 『@』 表示一率当成text來看
|
||||
cellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("@");
|
||||
cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
|
||||
|
||||
NPOI.SS.UserModel.IFont cellfont = workbook.CreateFont();
|
||||
cellfont.Boldweight = (short)FontBoldWeight.Normal;
|
||||
cellStyle.SetFont(cellfont);
|
||||
|
||||
string strDataJson = new JH_Auth_ExtendDataB().GetExcelData(P1);
|
||||
if (strDataJson != "")
|
||||
{
|
||||
string[] strs = strDataJson.Split(',');
|
||||
|
||||
//建立内容行
|
||||
|
||||
int iCellIndex = 0;
|
||||
|
||||
IRow DataRow = sheet.CreateRow(1);
|
||||
for (int i = 0; i < strs.Length; i++)
|
||||
{
|
||||
|
||||
ICell cell = DataRow.CreateCell(iCellIndex);
|
||||
cell.SetCellValue(strs[i]);
|
||||
cell.CellStyle = cellStyle;
|
||||
iCellIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
//自适应列宽度
|
||||
for (int i = 0; i < icolIndex; i++)
|
||||
{
|
||||
sheet.AutoSizeColumn(i);
|
||||
}
|
||||
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
workbook.Write(ms);
|
||||
|
||||
object curContext = object.Current;
|
||||
|
||||
string strName = string.Empty;
|
||||
|
||||
|
||||
// 设置编码和附件格式
|
||||
curContext.Response.ContentType = "application/vnd.ms-excel";
|
||||
curContext.Response.ContentEncoding = Encoding.UTF8;
|
||||
curContext.Response.Charset = "";
|
||||
curContext.Response.AppendHeader("Content-Disposition",
|
||||
"attachment;filename=" + HttpUtility.UrlEncode("CRM_" + strName + "_模板文件.xls", Encoding.UTF8));
|
||||
|
||||
curContext.Response.BinaryWrite(ms.GetBuffer());
|
||||
curContext.Response.End();
|
||||
|
||||
workbook = null;
|
||||
ms.Close();
|
||||
ms.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
msg.ErrorMsg = "导入失败!";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载模板excel(弃用)
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="msg"></param>
|
||||
/// <param name="P1"></param>
|
||||
/// <param name="P2"></param>
|
||||
/// <param name="UserInfo"></param>
|
||||
public void DOWNLOADEXCEL(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
string strName = string.Empty;
|
||||
if (P1 == "KHGL")
|
||||
{
|
||||
strName = "CRM_客户_导入模板.xls";
|
||||
}
|
||||
else if (P1 == "KHLXR")
|
||||
{
|
||||
strName = "CRM_客户联系人_导入模板.xls";
|
||||
}
|
||||
else if (P1 == "HTGL")
|
||||
{
|
||||
strName = "CRM_合同_导入模板.xls";
|
||||
}
|
||||
object curContext = object.Current;
|
||||
string headrow = context.Request["headrow"] ?? "0";//头部开始行下标
|
||||
string path = curContext.Server.MapPath(@"/ViewV5/base/" + strName);
|
||||
FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read);
|
||||
string suffix = path.Substring(path.LastIndexOf(".") + 1).ToLower();
|
||||
|
||||
IWorkbook workbook = null;
|
||||
|
||||
if (suffix == "xlsx") // 2007版本
|
||||
{
|
||||
workbook = new XSSFWorkbook(file);
|
||||
}
|
||||
else if (suffix == "xls") // 2003版本
|
||||
{
|
||||
workbook = new HSSFWorkbook(file);
|
||||
}
|
||||
ISheet sheet = workbook.GetSheetAt(0);
|
||||
|
||||
IRow headerRow = sheet.GetRow(int.Parse(headrow));
|
||||
IRow oneRow = sheet.GetRow(int.Parse(headrow) + 1);
|
||||
|
||||
int icolIndex = headerRow.Cells.Count;
|
||||
|
||||
DataTable dtExtColumn = new JH_Auth_ExtendModeB().GetExtColumnAll(UserInfo.QYinfo.ComId, P1);
|
||||
foreach (DataRow drExt in dtExtColumn.Rows)
|
||||
{
|
||||
ICell cell = headerRow.CreateCell(icolIndex);
|
||||
cell.SetCellValue(drExt["TableFiledName"].ToString());
|
||||
cell.CellStyle = headerRow.Cells[icolIndex - 1].CellStyle;
|
||||
|
||||
ICell onecell = oneRow.CreateCell(icolIndex);
|
||||
onecell.SetCellValue("");
|
||||
onecell.CellStyle = oneRow.Cells[icolIndex - 1].CellStyle;
|
||||
|
||||
icolIndex++;
|
||||
}
|
||||
|
||||
//自适应列宽度
|
||||
for (int i = 0; i < icolIndex; i++)
|
||||
{
|
||||
sheet.AutoSizeColumn(i);
|
||||
}
|
||||
|
||||
if (P1 == "KHGL")
|
||||
{
|
||||
//表头样式
|
||||
ICellStyle HeadercellStyle = workbook.CreateCellStyle();
|
||||
HeadercellStyle.BorderBottom = BorderStyle.Thin;
|
||||
HeadercellStyle.BorderLeft = BorderStyle.Thin;
|
||||
HeadercellStyle.BorderRight = BorderStyle.Thin;
|
||||
HeadercellStyle.BorderTop = BorderStyle.Thin;
|
||||
HeadercellStyle.Alignment = HorizontalAlignment.Center;
|
||||
|
||||
//字体
|
||||
NPOI.SS.UserModel.IFont headerfont = workbook.CreateFont();
|
||||
headerfont.Boldweight = (short)FontBoldWeight.Bold;
|
||||
headerfont.FontHeightInPoints = 12;
|
||||
HeadercellStyle.SetFont(headerfont);
|
||||
|
||||
//单元格样式
|
||||
ICellStyle cellStyle = workbook.CreateCellStyle();
|
||||
|
||||
//为避免日期格式被Excel自动替换,所以设定 format 为 『@』 表示一率当成text來看
|
||||
cellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("@");
|
||||
cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
|
||||
|
||||
NPOI.SS.UserModel.IFont cellfont = workbook.CreateFont();
|
||||
cellfont.Boldweight = (short)FontBoldWeight.Normal;
|
||||
headerfont.FontHeightInPoints = 10;
|
||||
cellStyle.SetFont(cellfont);
|
||||
|
||||
for (int i = 10; i < 15; i++)
|
||||
{
|
||||
string strZTName = string.Empty;
|
||||
if (i == 10) { strZTName = "客户类型"; }
|
||||
if (i == 11) { strZTName = "跟进状态"; }
|
||||
if (i == 12) { strZTName = "客户来源"; }
|
||||
if (i == 13) { strZTName = "所属行业"; }
|
||||
if (i == 14) { strZTName = "人员规模"; }
|
||||
ISheet sheet1 = workbook.CreateSheet(strZTName);
|
||||
IRow headerRow1 = sheet1.CreateRow(0);
|
||||
ICell cell1 = headerRow1.CreateCell(0);
|
||||
cell1.SetCellValue(strZTName);
|
||||
cell1.CellStyle = HeadercellStyle;
|
||||
|
||||
int rowindex1 = 1;
|
||||
|
||||
foreach (var l in new JH_Auth_ZiDianB().GetEntities(p => p.ComId == UserInfo.QYinfo.ComId && p.Class == i))
|
||||
{
|
||||
IRow DataRow = sheet1.CreateRow(rowindex1);
|
||||
ICell cell = DataRow.CreateCell(0);
|
||||
cell.SetCellValue(l.TypeName);
|
||||
cell.CellStyle = cellStyle;
|
||||
rowindex1++;
|
||||
}
|
||||
|
||||
sheet1.AutoSizeColumn(0);
|
||||
}
|
||||
}
|
||||
if (P1 == "HTGL")
|
||||
{
|
||||
//表头样式
|
||||
ICellStyle HeadercellStyle = workbook.CreateCellStyle();
|
||||
HeadercellStyle.BorderBottom = BorderStyle.Thin;
|
||||
HeadercellStyle.BorderLeft = BorderStyle.Thin;
|
||||
HeadercellStyle.BorderRight = BorderStyle.Thin;
|
||||
HeadercellStyle.BorderTop = BorderStyle.Thin;
|
||||
HeadercellStyle.Alignment = HorizontalAlignment.Center;
|
||||
|
||||
//字体
|
||||
NPOI.SS.UserModel.IFont headerfont = workbook.CreateFont();
|
||||
headerfont.Boldweight = (short)FontBoldWeight.Bold;
|
||||
headerfont.FontHeightInPoints = 12;
|
||||
HeadercellStyle.SetFont(headerfont);
|
||||
|
||||
//单元格样式
|
||||
ICellStyle cellStyle = workbook.CreateCellStyle();
|
||||
|
||||
//为避免日期格式被Excel自动替换,所以设定 format 为 『@』 表示一率当成text來看
|
||||
cellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("@");
|
||||
cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
|
||||
|
||||
NPOI.SS.UserModel.IFont cellfont = workbook.CreateFont();
|
||||
cellfont.Boldweight = (short)FontBoldWeight.Normal;
|
||||
headerfont.FontHeightInPoints = 10;
|
||||
cellStyle.SetFont(cellfont);
|
||||
|
||||
for (int i = 16; i < 18; i++)
|
||||
{
|
||||
string strZTName = string.Empty;
|
||||
if (i == 16) { strZTName = "合同类型"; }
|
||||
if (i == 17) { strZTName = "付款方式"; }
|
||||
ISheet sheet1 = workbook.CreateSheet(strZTName);
|
||||
IRow headerRow1 = sheet1.CreateRow(0);
|
||||
ICell cell1 = headerRow1.CreateCell(0);
|
||||
cell1.SetCellValue(strZTName);
|
||||
cell1.CellStyle = HeadercellStyle;
|
||||
|
||||
int rowindex1 = 1;
|
||||
|
||||
foreach (var l in new JH_Auth_ZiDianB().GetEntities(p => p.ComId == UserInfo.QYinfo.ComId && p.Class == i))
|
||||
{
|
||||
IRow DataRow = sheet1.CreateRow(rowindex1);
|
||||
ICell cell = DataRow.CreateCell(0);
|
||||
cell.SetCellValue(l.TypeName);
|
||||
cell.CellStyle = cellStyle;
|
||||
rowindex1++;
|
||||
}
|
||||
|
||||
sheet1.AutoSizeColumn(0);
|
||||
}
|
||||
}
|
||||
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
workbook.Write(ms);
|
||||
|
||||
//object curContext = object.Current;
|
||||
|
||||
// 设置编码和附件格式
|
||||
curContext.Response.ContentType = "application/vnd.ms-excel";
|
||||
curContext.Response.ContentEncoding = Encoding.UTF8;
|
||||
curContext.Response.Charset = "";
|
||||
curContext.Response.AppendHeader("Content-Disposition",
|
||||
"attachment;filename=" + HttpUtility.UrlEncode(strName, Encoding.UTF8));
|
||||
|
||||
curContext.Response.BinaryWrite(ms.GetBuffer());
|
||||
curContext.Response.End();
|
||||
|
||||
workbook = null;
|
||||
ms.Close();
|
||||
ms.Dispose();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
msg.ErrorMsg = "下载失败!";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
298
iMES.Bi.API/API/DATABI/BIbus.cs
Normal file
298
iMES.Bi.API/API/DATABI/BIbus.cs
Normal file
@@ -0,0 +1,298 @@
|
||||
using iMES.Bi.Data;
|
||||
using SqlSugar;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
namespace iMES.Bi.API
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region 数据BI模块
|
||||
|
||||
public class BI_DB_DimB : BaseEFDao<BI_DB_Dim> { }
|
||||
public class BI_DB_SetB : BaseEFDao<BI_DB_Set>
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取Data得经纬度
|
||||
/// </summary>
|
||||
/// <param name="dt"></param>
|
||||
/// <returns></returns>
|
||||
public List<BI_DB_Dim> getCType(DataTable dt)
|
||||
{
|
||||
|
||||
List<BI_DB_Dim> ListDIM = new List<BI_DB_Dim>();
|
||||
for (int i = 0; i < dt.Columns.Count; i++)
|
||||
{
|
||||
BI_DB_Dim DIM = new BI_DB_Dim();
|
||||
DIM.Name = dt.Columns[i].ColumnName;
|
||||
DIM.ColumnName = dt.Columns[i].ColumnName;
|
||||
DIM.ColumnSource = "0";
|
||||
string strType = dt.Columns[i].DataType.Name.ToLower();
|
||||
if (strType.Contains("int"))
|
||||
{
|
||||
DIM.ColumnType = "Num";
|
||||
DIM.Dimension = "2";
|
||||
}
|
||||
else if (strType.Contains("decimal") || strType.Contains("float") || strType.Contains("Double"))
|
||||
{
|
||||
DIM.ColumnType = "float";
|
||||
DIM.Dimension = "2";
|
||||
|
||||
}
|
||||
else if (strType.Contains("datetime"))
|
||||
{
|
||||
DIM.ColumnType = "Date";
|
||||
DIM.Dimension = "1";
|
||||
}
|
||||
else
|
||||
{
|
||||
DIM.ColumnType = "Str";
|
||||
DIM.Dimension = "1";
|
||||
|
||||
}
|
||||
ListDIM.Add(DIM);
|
||||
}
|
||||
return ListDIM;
|
||||
}
|
||||
}
|
||||
public class BI_DB_SourceB : BaseEFDao<BI_DB_Source>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据源
|
||||
/// </summary>
|
||||
/// <param name="intSID"></param>
|
||||
/// <returns></returns>
|
||||
public DBFactory GetDB(int intSID)
|
||||
{
|
||||
DBFactory db = new DBFactory();
|
||||
if (intSID == 0)//本地数据库
|
||||
{
|
||||
string strCon = new BI_DB_SetB().GetDBString();
|
||||
db = new DBFactory(strCon);
|
||||
}
|
||||
else
|
||||
{
|
||||
var tt = new BI_DB_SourceB().GetEntity(p => p.ID == intSID);
|
||||
if (tt != null)
|
||||
{
|
||||
db = new DBFactory(tt.DBType, tt.DBIP, tt.Port, tt.DBName, tt.DBUser, tt.DBPwd);
|
||||
}
|
||||
}
|
||||
return db;
|
||||
|
||||
}
|
||||
}
|
||||
public class BI_DB_YBPB : BaseEFDao<BI_DB_YBP>
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class BI_DB_TableB : BaseEFDao<BI_DB_Table>
|
||||
{
|
||||
public bool ReTabName(int tabid, string strNewName)
|
||||
{
|
||||
|
||||
BI_DB_Table model = new BI_DB_TableB().GetEntity(D => D.ID == tabid);
|
||||
DBFactory dbccgc = new BI_DB_SourceB().GetDB(model.DSID);
|
||||
dbccgc.GetDBClient().DbMaintenance.RenameTable(model.TableName, strNewName);
|
||||
model.TableName = strNewName;
|
||||
return new BI_DB_TableB().Update(model);
|
||||
}
|
||||
public List<DbColumnInfo> CreateLogicTable(BI_DB_Table model)
|
||||
{
|
||||
string strTableName = model.TableName;
|
||||
DBFactory dbccgc = new BI_DB_SourceB().GetDB(model.DSID);
|
||||
List<DbColumnInfo> ListC = new List<DbColumnInfo>();
|
||||
DbColumnInfo colID = new DbColumnInfo();
|
||||
colID.DataType = "int";
|
||||
colID.DbColumnName = "ID";
|
||||
colID.IsPrimarykey = true;
|
||||
colID.IsIdentity = true;
|
||||
colID.IsNullable = false;
|
||||
ListC.Add(colID);
|
||||
|
||||
DbColumnInfo colCRUser = new DbColumnInfo();
|
||||
colCRUser.DataType = "varchar";
|
||||
colCRUser.DbColumnName = "CRUser";
|
||||
colCRUser.ColumnDescription = "创建人";
|
||||
colCRUser.Length = 255;
|
||||
colCRUser.IsNullable = true;
|
||||
ListC.Add(colCRUser);
|
||||
|
||||
|
||||
DbColumnInfo colDCode = new DbColumnInfo();
|
||||
colDCode.DataType = "varchar";
|
||||
colDCode.DbColumnName = "DCode";
|
||||
colDCode.ColumnDescription = "机构代码";
|
||||
colDCode.Length = 255;
|
||||
colDCode.IsNullable = true;
|
||||
ListC.Add(colDCode);
|
||||
|
||||
DbColumnInfo colDName = new DbColumnInfo();
|
||||
colDName.DataType = "varchar";
|
||||
colDName.DbColumnName = "DName";
|
||||
colDName.ColumnDescription = "机构名称";
|
||||
colDName.Length = 255;
|
||||
colDName.IsNullable = true;
|
||||
ListC.Add(colDName);
|
||||
|
||||
DbColumnInfo colCRUserName = new DbColumnInfo();
|
||||
colCRUserName.DataType = "varchar";
|
||||
colCRUserName.DbColumnName = "CRUserName";
|
||||
colCRUserName.ColumnDescription = "真实姓名";
|
||||
colCRUserName.Length = 255;
|
||||
colCRUserName.IsNullable = true;
|
||||
ListC.Add(colCRUserName);
|
||||
|
||||
DbColumnInfo colCRDate = new DbColumnInfo();
|
||||
colCRDate.DataType = "datetime";
|
||||
colCRDate.DbColumnName = "CRDate";
|
||||
colCRDate.IsNullable = true;
|
||||
|
||||
ListC.Add(colCRDate);
|
||||
|
||||
|
||||
DbColumnInfo colINPID = new DbColumnInfo();
|
||||
colINPID.DataType = "int";
|
||||
colINPID.DbColumnName = "intProcessStanceid";
|
||||
colINPID.ColumnDescription = "流程ID";
|
||||
colINPID.IsNullable = true;
|
||||
colINPID.DefaultValue = "0";
|
||||
|
||||
ListC.Add(colINPID);
|
||||
|
||||
DbColumnInfo colComID = new DbColumnInfo();
|
||||
colComID.DataType = "int";
|
||||
colComID.DbColumnName = "ComID";
|
||||
colComID.IsNullable = true;
|
||||
ListC.Add(colComID);
|
||||
|
||||
dbccgc.GetDBClient().DbMaintenance.CreateTable(strTableName, ListC);
|
||||
return ListC;
|
||||
}
|
||||
|
||||
public void DelLogicTable(int tabid)
|
||||
{
|
||||
|
||||
BI_DB_Table model = this.GetEntity(D => D.ID == tabid);
|
||||
DBFactory dbccgc = new BI_DB_SourceB().GetDB(model.DSID);
|
||||
string strTableName = model.TableName;
|
||||
dbccgc.GetDBClient().DbMaintenance.DropTable(strTableName);
|
||||
|
||||
var result = this.Db.Ado.UseTran(() =>
|
||||
{
|
||||
new BI_DB_TableB().Delete(D => D.ID == tabid);
|
||||
new BI_DB_TablefiledB().Delete(D => D.TableID == tabid);
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class BI_DB_TablefiledB : BaseEFDao<BI_DB_Tablefiled>
|
||||
{
|
||||
public void AddCol(BI_DB_Tablefiled col)
|
||||
{
|
||||
|
||||
BI_DB_Table model = new BI_DB_TableB().GetEntity(D => D.ID == col.TableID);
|
||||
DBFactory dbccgc = new BI_DB_SourceB().GetDB(model.DSID);
|
||||
DbColumnInfo filed = new DbColumnInfo();
|
||||
filed.DataType = col.DataType;
|
||||
filed.DbColumnName = col.DbColumnName;
|
||||
filed.IsPrimarykey = false;
|
||||
filed.IsIdentity = false;
|
||||
filed.ColumnDescription = col.ColumnDescription;
|
||||
filed.IsNullable = col.IsNullable == "0" ? true : false;
|
||||
filed.DefaultValue = col.DefaultValue;
|
||||
if (dbccgc.GetDBType() == "SqlServer" && col.DataType == "int")
|
||||
{
|
||||
filed.Length = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
filed.Length = col.Length == -1 ? int.MaxValue : col.Length;
|
||||
|
||||
}
|
||||
filed.DecimalDigits = int.Parse(col.DecimalDigits);
|
||||
|
||||
dbccgc.GetDBClient().DbMaintenance.AddColumn(model.TableName, filed);
|
||||
}
|
||||
|
||||
public bool upCol(BI_DB_Tablefiled col)
|
||||
{
|
||||
|
||||
BI_DB_Table model = new BI_DB_TableB().GetEntity(D => D.ID == col.TableID);
|
||||
DBFactory dbccgc = new BI_DB_SourceB().GetDB(model.DSID);
|
||||
DbColumnInfo filed = new DbColumnInfo();
|
||||
filed.DataType = col.DataType;
|
||||
filed.DbColumnName = col.DbColumnName;
|
||||
filed.ColumnDescription = col.ColumnDescription;
|
||||
filed.IsNullable = col.IsNullable == "0" ? true : false;
|
||||
filed.DefaultValue = col.DefaultValue;
|
||||
if (dbccgc.GetDBType() == "SqlServer" && col.DataType == "int")
|
||||
{
|
||||
filed.Length = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
filed.Length = col.Length;
|
||||
|
||||
}
|
||||
filed.DecimalDigits = int.Parse(col.DecimalDigits);
|
||||
|
||||
return dbccgc.GetDBClient().DbMaintenance.UpdateColumn(model.TableName, filed);
|
||||
}
|
||||
|
||||
public bool DelCol(BI_DB_Tablefiled col)
|
||||
{
|
||||
|
||||
BI_DB_Table model = new BI_DB_TableB().GetEntity(D => D.ID == col.TableID);
|
||||
DBFactory dbccgc = new BI_DB_SourceB().GetDB(model.DSID);
|
||||
return dbccgc.GetDBClient().DbMaintenance.DropColumn(model.TableName, col.DbColumnName);
|
||||
}
|
||||
|
||||
|
||||
public bool ReColName(BI_DB_Tablefiled col, string strOldName)
|
||||
{
|
||||
|
||||
BI_DB_Table model = new BI_DB_TableB().GetEntity(D => D.ID == col.TableID);
|
||||
DBFactory dbccgc = new BI_DB_SourceB().GetDB(model.DSID);
|
||||
return dbccgc.GetDBClient().DbMaintenance.RenameColumn(model.TableName, strOldName, col.DbColumnName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
1310
iMES.Bi.API/API/DATABI/DATABIManage.cs
Normal file
1310
iMES.Bi.API/API/DATABI/DATABIManage.cs
Normal file
File diff suppressed because it is too large
Load Diff
18
iMES.Bi.API/APIHelp.cs
Normal file
18
iMES.Bi.API/APIHelp.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace iMES.Bi.API
|
||||
{
|
||||
class APIHelp
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public static class APIExtensions
|
||||
{
|
||||
public static string Request(this JObject JData, string strPro, string strDefault = null)
|
||||
{
|
||||
return JData[strPro] != null ? JData[strPro].ToString() : strDefault;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
913
iMES.Bi.API/CommonHelp.cs
Normal file
913
iMES.Bi.API/CommonHelp.cs
Normal file
@@ -0,0 +1,913 @@
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using iMES.Bi.Data;
|
||||
using System;
|
||||
using System.Collections;
|
||||
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 iMES.Bi.API
|
||||
{
|
||||
public class CommonHelp
|
||||
{
|
||||
|
||||
public static T DeepCopyByReflect<T>(T obj)
|
||||
{
|
||||
//如果是字符串或值类型则直接返回
|
||||
if (obj is string || obj.GetType().IsValueType) return obj;
|
||||
|
||||
object retval = Activator.CreateInstance(obj.GetType());
|
||||
FieldInfo[] fields = obj.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
|
||||
foreach (FieldInfo field in fields)
|
||||
{
|
||||
try { field.SetValue(retval, DeepCopyByReflect(field.GetValue(obj))); }
|
||||
catch { }
|
||||
}
|
||||
return (T)retval;
|
||||
}
|
||||
/// <summary>
|
||||
/// 从html中提取纯文本
|
||||
/// </summary>
|
||||
/// <param name="strHtml"></param>
|
||||
/// <returns></returns>
|
||||
public string StripHT(string strHtml) //从html中提取纯文本
|
||||
{
|
||||
Regex regex = new Regex("<.+?>", RegexOptions.IgnoreCase);
|
||||
string strOutput = regex.Replace(strHtml, "");//替换掉"<"和">"之间的内容
|
||||
strOutput = strOutput.Replace("<", "");
|
||||
strOutput = strOutput.Replace(">", "");
|
||||
strOutput = strOutput.Replace(" ", "");
|
||||
return strOutput;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 移除html标签
|
||||
/// </summary>
|
||||
/// <param name="html"></param>
|
||||
/// <returns></returns>
|
||||
public static string RemoveHtml(string html)
|
||||
{
|
||||
if (string.IsNullOrEmpty(html)) return html;
|
||||
|
||||
Regex regex = new Regex("<.+?>");
|
||||
var matches = regex.Matches(html);
|
||||
|
||||
foreach (Match match in matches)
|
||||
{
|
||||
html = html.Replace(match.Value, "");
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static string PostWebRequest(string postUrl, string paramData, Encoding dataEncode)
|
||||
{
|
||||
string ret = string.Empty;
|
||||
try
|
||||
{
|
||||
byte[] byteArray = dataEncode.GetBytes(paramData); //转化
|
||||
HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(new Uri(postUrl));
|
||||
webReq.Method = "POST";
|
||||
webReq.ContentType = "application/json; charset=UTF-8";
|
||||
|
||||
webReq.ContentLength = byteArray.Length;
|
||||
Stream newStream = webReq.GetRequestStream();
|
||||
newStream.Write(byteArray, 0, byteArray.Length);//写入参数
|
||||
newStream.Close();
|
||||
HttpWebResponse response = (HttpWebResponse)webReq.GetResponse();
|
||||
StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.Default);
|
||||
ret = sr.ReadToEnd();
|
||||
sr.Close();
|
||||
response.Close();
|
||||
newStream.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static HttpWebResponse CreateHttpResponse(string url, IDictionary<string, string> parameters, int timeout, string userAgent, CookieCollection cookies, string strType = "POST")
|
||||
{
|
||||
HttpWebRequest request = null;
|
||||
//如果是发送HTTPS请求
|
||||
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
//ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
|
||||
request = WebRequest.Create(url) as HttpWebRequest;
|
||||
//request.ProtocolVersion = HttpVersion.Version10;
|
||||
}
|
||||
else
|
||||
{
|
||||
request = WebRequest.Create(url) as HttpWebRequest;
|
||||
}
|
||||
request.Method = strType;
|
||||
request.ContentType = "application/x-www-form-urlencoded";
|
||||
|
||||
//设置代理UserAgent和超时
|
||||
//request.UserAgent = userAgent;
|
||||
//request.Timeout = timeout;
|
||||
|
||||
if (cookies != null)
|
||||
{
|
||||
request.CookieContainer = new CookieContainer();
|
||||
request.CookieContainer.Add(cookies);
|
||||
}
|
||||
//发送POST数据
|
||||
if (!(parameters == null || parameters.Count == 0))
|
||||
{
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
int i = 0;
|
||||
foreach (string key in parameters.Keys)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
buffer.AppendFormat("&{0}={1}", key, parameters[key]);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.AppendFormat("{0}={1}", key, parameters[key]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
byte[] data = Encoding.UTF8.GetBytes(buffer.ToString());
|
||||
using (Stream stream = request.GetRequestStream())
|
||||
{
|
||||
stream.Write(data, 0, data.Length);
|
||||
}
|
||||
}
|
||||
string[] values = request.Headers.GetValues("Content-Type");
|
||||
return request.GetResponse() as HttpWebResponse;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建POST方式的HTTP请求
|
||||
/// </summary>
|
||||
public static HttpWebResponse CreatePostHttpResponse(string url, IDictionary<string, string> parameters, int timeout, string userAgent, CookieCollection cookies, string strType = "POST")
|
||||
{
|
||||
HttpWebRequest request = null;
|
||||
//如果是发送HTTPS请求
|
||||
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
//ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
|
||||
request = WebRequest.Create(url) as HttpWebRequest;
|
||||
//request.ProtocolVersion = HttpVersion.Version10;
|
||||
}
|
||||
else
|
||||
{
|
||||
request = WebRequest.Create(url) as HttpWebRequest;
|
||||
}
|
||||
request.Method = strType;
|
||||
request.ContentType = "application/x-www-form-urlencoded";
|
||||
|
||||
//设置代理UserAgent和超时
|
||||
//request.UserAgent = userAgent;
|
||||
//request.Timeout = timeout;
|
||||
|
||||
if (cookies != null)
|
||||
{
|
||||
request.CookieContainer = new CookieContainer();
|
||||
request.CookieContainer.Add(cookies);
|
||||
}
|
||||
//发送POST数据
|
||||
if (!(parameters == null || parameters.Count == 0))
|
||||
{
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
int i = 0;
|
||||
foreach (string key in parameters.Keys)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
buffer.AppendFormat("&{0}={1}", key, parameters[key]);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.AppendFormat("{0}={1}", key, parameters[key]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
byte[] data = Encoding.UTF8.GetBytes(buffer.ToString());
|
||||
using (Stream stream = request.GetRequestStream())
|
||||
{
|
||||
stream.Write(data, 0, data.Length);
|
||||
}
|
||||
}
|
||||
string[] values = request.Headers.GetValues("Content-Type");
|
||||
return request.GetResponse() as HttpWebResponse;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取请求的数据
|
||||
/// </summary>
|
||||
public static string GetResponseString(HttpWebResponse webresponse)
|
||||
{
|
||||
using (Stream s = webresponse.GetResponseStream())
|
||||
{
|
||||
StreamReader reader = new StreamReader(s, Encoding.Default);
|
||||
return reader.ReadToEnd();
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 导出Excel
|
||||
/// </summary>
|
||||
/// <param name="table"></param>
|
||||
/// <param name="fileName"></param>
|
||||
public static MemoryStream RenderToExcel(DataTable table)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
|
||||
using (table)
|
||||
{
|
||||
IWorkbook workbook = new HSSFWorkbook();
|
||||
ISheet sheet = workbook.CreateSheet();
|
||||
IRow headerRow = sheet.CreateRow(0);
|
||||
|
||||
// handling header.
|
||||
foreach (DataColumn column in table.Columns)
|
||||
headerRow.CreateCell(column.Ordinal).SetCellValue(column.Caption);//If Caption not set, returns the ColumnName value
|
||||
|
||||
// handling value.
|
||||
int rowIndex = 1;
|
||||
|
||||
foreach (DataRow row in table.Rows)
|
||||
{
|
||||
IRow dataRow = sheet.CreateRow(rowIndex);
|
||||
|
||||
foreach (DataColumn column in table.Columns)
|
||||
{
|
||||
dataRow.CreateCell(column.Ordinal).SetCellValue(row[column].ToString());
|
||||
}
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
workbook.Write(ms);
|
||||
ms.Flush();
|
||||
ms.Position = 0;
|
||||
}
|
||||
|
||||
//using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
|
||||
//{
|
||||
// byte[] data = ms.ToArray();
|
||||
|
||||
// fs.Write(data, 0, data.Length);
|
||||
// fs.Flush();
|
||||
// data = null;
|
||||
//}
|
||||
return ms;
|
||||
}
|
||||
|
||||
//
|
||||
public static bool HasData(Stream excelFileStream)
|
||||
{
|
||||
using (excelFileStream)
|
||||
{
|
||||
IWorkbook workbook = new HSSFWorkbook(excelFileStream);
|
||||
if (workbook.NumberOfSheets > 0)
|
||||
{
|
||||
ISheet sheet = workbook.GetSheetAt(0);
|
||||
return sheet.PhysicalNumberOfRows > 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string SendDX(string Mobile, string Content, string SendTime)
|
||||
{
|
||||
try
|
||||
{
|
||||
string returnData = "";
|
||||
// string url = CommonHelp.GetConfig("DXURL") + "&Mobile=" + Mobile + "&Content=" + Content;
|
||||
if (CommonHelp.GetConfig("DXURL") != "")
|
||||
{
|
||||
string url = CommonHelp.GetConfig("DXURL") + "&phone=" + Mobile + "&msg=" + Content;
|
||||
CommonHelp.WriteLOG(url);
|
||||
WebClient WC = new WebClient();
|
||||
WC.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
|
||||
int p = url.IndexOf("?");
|
||||
string sData = url.Substring(p + 1);
|
||||
url = url.Substring(0, p);
|
||||
byte[] postData = Encoding.GetEncoding("gb2312").GetBytes(sData);
|
||||
byte[] responseData = WC.UploadData(url, "POST", postData);
|
||||
returnData = Encoding.GetEncoding("gb2312").GetString(responseData);
|
||||
}
|
||||
return returnData;
|
||||
|
||||
|
||||
}
|
||||
catch (Exception Ex)
|
||||
{
|
||||
return Ex.Message;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static HSSFWorkbook ExportToExcel(DataTable dt)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
ISheet sheet = workbook.CreateSheet("Sheet1");
|
||||
|
||||
ICellStyle HeadercellStyle = workbook.CreateCellStyle();
|
||||
HeadercellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
HeadercellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
HeadercellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
HeadercellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
HeadercellStyle.Alignment = HorizontalAlignment.Center;
|
||||
HeadercellStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.SkyBlue.Index;
|
||||
HeadercellStyle.FillPattern = FillPattern.SolidForeground;
|
||||
HeadercellStyle.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.SkyBlue.Index;
|
||||
|
||||
//字体
|
||||
NPOI.SS.UserModel.IFont headerfont = workbook.CreateFont();
|
||||
headerfont.Boldweight = (short)FontBoldWeight.Bold;
|
||||
headerfont.FontHeightInPoints = 12;
|
||||
HeadercellStyle.SetFont(headerfont);
|
||||
|
||||
|
||||
//用column name 作为列名
|
||||
int icolIndex = 0;
|
||||
IRow headerRow = sheet.CreateRow(0);
|
||||
foreach (DataColumn dc in dt.Columns)
|
||||
{
|
||||
ICell cell = headerRow.CreateCell(icolIndex);
|
||||
cell.SetCellValue(dc.ColumnName);
|
||||
cell.CellStyle = HeadercellStyle;
|
||||
icolIndex++;
|
||||
}
|
||||
|
||||
ICellStyle cellStyle = workbook.CreateCellStyle();
|
||||
|
||||
//为避免日期格式被Excel自动替换,所以设定 format 为 『@』 表示一率当成text來看
|
||||
cellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("@");
|
||||
cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
|
||||
|
||||
NPOI.SS.UserModel.IFont cellfont = workbook.CreateFont();
|
||||
cellfont.Boldweight = (short)FontBoldWeight.Normal;
|
||||
cellStyle.SetFont(cellfont);
|
||||
|
||||
//建立内容行
|
||||
int iRowIndex = 0;
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
int iCellIndex = 0;
|
||||
IRow irow = sheet.CreateRow(iRowIndex + 1);
|
||||
for (int i = 0; i < dt.Columns.Count; i++)
|
||||
{
|
||||
string strsj = string.Empty;
|
||||
if (dr[i] != null)
|
||||
{
|
||||
strsj = dr[i].ToString();
|
||||
}
|
||||
ICell cell = irow.CreateCell(iCellIndex);
|
||||
cell.SetCellValue(strsj);
|
||||
cell.CellStyle = cellStyle;
|
||||
iCellIndex++;
|
||||
}
|
||||
iRowIndex++;
|
||||
}
|
||||
|
||||
//自适应列宽度
|
||||
for (int i = 0; i < icolIndex; i++)
|
||||
{
|
||||
sheet.AutoSizeColumn(i);
|
||||
}
|
||||
|
||||
//using (MemoryStream ms = new MemoryStream())
|
||||
//{
|
||||
// workbook.Write(ms);
|
||||
|
||||
// HttpContext curContext = HttpContext.Current;
|
||||
|
||||
|
||||
// // 设置编码和附件格式
|
||||
// curContext.Response.ContentType = "application/vnd.ms-excel";
|
||||
// curContext.Response.ContentEncoding = Encoding.UTF8;
|
||||
// curContext.Response.Charset = "";
|
||||
// curContext.Response.AppendHeader("Content-Disposition",
|
||||
// "attachment;filename=" + HttpUtility.UrlEncode(Name + "_导出文件_" + DateTime.Now.Ticks + ".xls", Encoding.UTF8));
|
||||
|
||||
// curContext.Response.BinaryWrite(ms.GetBuffer());
|
||||
|
||||
// workbook = null;
|
||||
// ms.Close();
|
||||
// ms.Dispose();
|
||||
|
||||
// curContext.Response.End();
|
||||
//}
|
||||
}
|
||||
return workbook;
|
||||
|
||||
}
|
||||
public DataTable ExcelToTable(Stream stream, int headrow, string suffix)
|
||||
{
|
||||
DataTable dt = new DataTable();
|
||||
|
||||
IWorkbook workbook = null;
|
||||
if (suffix == "xlsx") // 2007版本
|
||||
{
|
||||
workbook = new XSSFWorkbook(stream);
|
||||
}
|
||||
else if (suffix == "xls") // 2003版本
|
||||
{
|
||||
workbook = new HSSFWorkbook(stream);
|
||||
}
|
||||
|
||||
//获取excel的第一个sheet
|
||||
ISheet sheet = workbook.GetSheetAt(0);
|
||||
|
||||
//获取sheet的第一行
|
||||
IRow headerRow = sheet.GetRow(headrow);
|
||||
|
||||
//一行最后一个方格的编号 即总的列数
|
||||
int cellCount = headerRow.LastCellNum;
|
||||
//最后一列的标号 即总的行数
|
||||
int rowCount = sheet.LastRowNum;
|
||||
//列名
|
||||
for (int i = 0; i < cellCount; i++)
|
||||
{
|
||||
dt.Columns.Add(headerRow.GetCell(i).ToString());
|
||||
}
|
||||
|
||||
for (int i = (sheet.FirstRowNum + headrow + 1); i <= sheet.LastRowNum; i++)
|
||||
{
|
||||
DataRow dr = dt.NewRow();
|
||||
|
||||
IRow row = sheet.GetRow(i);
|
||||
for (int j = row.FirstCellNum; j < cellCount; j++)
|
||||
{
|
||||
if (row.GetCell(j) != null)
|
||||
{
|
||||
dr[j] = row.GetCell(j).ToString();
|
||||
}
|
||||
}
|
||||
|
||||
dt.Rows.Add(dr);
|
||||
}
|
||||
|
||||
sheet = null;
|
||||
workbook = null;
|
||||
|
||||
return dt;
|
||||
}
|
||||
|
||||
public static string HttpGet(string Url)
|
||||
{
|
||||
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
|
||||
request.Method = "GET";
|
||||
request.ContentType = "text/html;charset=UTF-8";
|
||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||
Stream myResponseStream = response.GetResponseStream();
|
||||
StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
|
||||
string retString = myStreamReader.ReadToEnd();
|
||||
myStreamReader.Close();
|
||||
myResponseStream.Close();
|
||||
|
||||
return retString;
|
||||
}
|
||||
public static string GetAPIData(string strUrl)
|
||||
{
|
||||
string strReturn = "";
|
||||
string strHost = GetConfig("APITX");
|
||||
strHost = strHost.Substring(0, strHost.IndexOf("/api"));
|
||||
strReturn = CommonHelp.HttpGet(strUrl.Replace("$API_HOST", strHost));
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
private int rep = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 生成随机不重复的字符串(分享码用)
|
||||
/// </summary>
|
||||
/// <param name="codeCount"></param>
|
||||
/// <returns></returns>
|
||||
public string GenerateCheckCode(int codeCount)
|
||||
{
|
||||
string str = string.Empty;
|
||||
long num2 = DateTime.Now.Ticks + this.rep;
|
||||
this.rep++;
|
||||
Random random = new Random(((int)(((ulong)num2) & 0xffffffffL)) | ((int)(num2 >> this.rep)));
|
||||
for (int i = 0; i < codeCount; i++)
|
||||
{
|
||||
char ch;
|
||||
int num = random.Next();
|
||||
if ((num % 2) == 0)
|
||||
{
|
||||
ch = (char)(0x30 + ((ushort)(num % 10)));
|
||||
}
|
||||
else
|
||||
{
|
||||
ch = (char)(0x41 + ((ushort)(num % 0x1a)));
|
||||
}
|
||||
str = str + ch.ToString();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
/// <summary>
|
||||
/// MD5加密
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetMD5(string content)
|
||||
{
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
var result = md5.ComputeHash(Encoding.ASCII.GetBytes(content));
|
||||
var strResult = BitConverter.ToString(result);
|
||||
return strResult.Replace("-", "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static string GetConfig(string strKey, string strDefault = "")
|
||||
{
|
||||
return Appsettings.app(strKey) ?? strDefault;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数字验证码
|
||||
/// </summary>
|
||||
/// <param name="codenum"></param>
|
||||
/// <returns></returns>
|
||||
public static string numcode(int codenum)
|
||||
{
|
||||
string Vchar = "0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9";
|
||||
string[] VcArray = Vchar.Split(',');
|
||||
string[] stray = new string[codenum];
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < codenum; i++)
|
||||
{
|
||||
int iNum = 0;
|
||||
while ((iNum = Convert.ToInt32(VcArray.Length * random.NextDouble())) == VcArray.Length)
|
||||
{
|
||||
iNum = Convert.ToInt32(VcArray.Length * random.NextDouble());
|
||||
}
|
||||
stray[i] = VcArray[iNum];
|
||||
}
|
||||
|
||||
string identifycode = string.Empty;
|
||||
foreach (string s in stray)
|
||||
{
|
||||
identifycode += s;
|
||||
}
|
||||
return identifycode;
|
||||
}
|
||||
/// <summary>
|
||||
/// 登录验证码
|
||||
/// </summary>
|
||||
/// <param name="codenum"></param>
|
||||
/// <returns></returns>
|
||||
public static string yzmcode(int codenum)
|
||||
{
|
||||
string Vchar = "0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,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";
|
||||
string[] VcArray = Vchar.Split(',');
|
||||
string[] stray = new string[codenum];
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < codenum; i++)
|
||||
{
|
||||
int iNum = 0;
|
||||
while ((iNum = Convert.ToInt32(VcArray.Length * random.NextDouble())) == VcArray.Length)
|
||||
{
|
||||
iNum = Convert.ToInt32(VcArray.Length * random.NextDouble());
|
||||
}
|
||||
stray[i] = VcArray[iNum];
|
||||
}
|
||||
|
||||
string identifycode = string.Empty;
|
||||
foreach (string s in stray)
|
||||
{
|
||||
identifycode += s;
|
||||
}
|
||||
return identifycode;
|
||||
}
|
||||
|
||||
private static bool IsIPAddress(string str1)
|
||||
{
|
||||
if (str1 == null || str1 == string.Empty || str1.Length < 7 || str1.Length > 15) return false;
|
||||
|
||||
string regformat = @"^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$";
|
||||
|
||||
Regex regex = new Regex(regformat, RegexOptions.IgnoreCase);
|
||||
return regex.IsMatch(str1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static void WriteLOG(string err)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
string path = AppContext.BaseDirectory;// .NET CORE
|
||||
//string path = HttpContext.Current.Request.MapPath("/");
|
||||
|
||||
if (!Directory.Exists(path + "/log/"))
|
||||
{
|
||||
Directory.CreateDirectory(path + "/log/");
|
||||
}
|
||||
|
||||
string name = DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
|
||||
if (!File.Exists(path + "/log/" + name))
|
||||
{
|
||||
FileInfo myfile = new FileInfo(path + "/log/" + name);
|
||||
FileStream fs = myfile.Create();
|
||||
fs.Close();
|
||||
}
|
||||
|
||||
StreamWriter sw = File.AppendText(path + "/log/" + name);
|
||||
sw.WriteLine(err + "\r\n" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static bool ProcessSqlStr(string Str, int type)
|
||||
{
|
||||
string SqlStr = "";
|
||||
if (type == 1) //Post方法提交
|
||||
{
|
||||
SqlStr = "script|iframe|xp_loginconfig|xp_fixeddrives|Xp_regremovemultistring|Xp_regread|Xp_regwrite|xp_cmdshell|xp_dirtree|count(|substring(|mid(|master|truncate|char(|declare|replace(|varchar(|cast(";
|
||||
}
|
||||
else if (type == 2) //Get方法提交
|
||||
{
|
||||
SqlStr = "'|script|iframe|xp_loginconfig|xp_fixeddrives|Xp_regremovemultistring|Xp_regread|Xp_regwrite|xp_cmdshell|xp_dirtree|count(|*|asc(|chr(|substring(|mid(|master|truncate|char(|declare|replace(|;|varchar(|cast(";
|
||||
}
|
||||
else if (type == 3) //Cookie提交
|
||||
{
|
||||
SqlStr = "script|iframe|xp_loginconfig|xp_fixeddrives|Xp_regremovemultistring|Xp_regread|Xp_regwrite|xp_cmdshell|xp_dirtree|count(|asc(|chr(|substring(|mid(|master|truncate|char(|declare";
|
||||
}
|
||||
else //默认Post方法提交
|
||||
{
|
||||
SqlStr = "script|iframe|xp_loginconfig|xp_fixeddrives|Xp_regremovemultistring|Xp_regread|Xp_regwrite|xp_cmdshell|xp_dirtree|count(|asc(|chr(|substring(|mid(|master|truncate|char(|declare|replace(";
|
||||
}
|
||||
|
||||
bool ReturnValue = true;
|
||||
try
|
||||
{
|
||||
if (Str != "")
|
||||
{
|
||||
string[] anySqlStr = SqlStr.ToUpper().Split('|'); ;
|
||||
foreach (string ss in anySqlStr)
|
||||
{
|
||||
if (Str.ToUpper().IndexOf(ss) >= 0)
|
||||
{
|
||||
ReturnValue = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
ReturnValue = false;
|
||||
}
|
||||
return ReturnValue;
|
||||
}
|
||||
|
||||
|
||||
public static string Filter(string str)
|
||||
{
|
||||
string[] pattern = { "insert ", "delete", "count\\(", "drop table", "update", "truncate", "xp_cmdshell", "exec master", "netlocalgroup administrators", "net use " };
|
||||
for (int i = 0; i < pattern.Length; i++)
|
||||
{
|
||||
str = str.Replace(pattern[i].ToString(), "");
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static string CreateqQsql(string strQFiled, string strQtype, string strQvalue)
|
||||
{
|
||||
string strSQL = " AND ";
|
||||
strSQL = strSQL + strQFiled;
|
||||
if (strQtype == "0")
|
||||
{
|
||||
strSQL = strSQL + " = ";
|
||||
|
||||
}
|
||||
strSQL = strSQL + "'" + strQvalue + "'";
|
||||
return strSQL.FilterSpecial();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生成流水号格式:8位日期加3位顺序号,如20100302001。
|
||||
/// </summary>
|
||||
public static string GetWFNumber(string serialNumber, string ywcode, string strWFQZ)
|
||||
{
|
||||
if (serialNumber.Length < 13)
|
||||
{
|
||||
strWFQZ = "1";
|
||||
//没法子,只能曲线救国
|
||||
}
|
||||
string strLSTemp = strWFQZ == "0" ? "yyyyMMdd" : "yyyy";
|
||||
if (serialNumber != "0" && serialNumber != "")
|
||||
{
|
||||
string headDate = serialNumber.Substring(ywcode.Length + 1, strLSTemp.Length);
|
||||
int lastNumber = int.Parse(serialNumber.Substring(ywcode.Length + 1 + strLSTemp.Length));
|
||||
//如果数据库最大值流水号中日期和生成日期在同一天,则顺序号加1
|
||||
if (headDate == DateTime.Now.ToString(strLSTemp))
|
||||
{
|
||||
lastNumber++;
|
||||
return ywcode + "-" + headDate + lastNumber.ToString("000");
|
||||
}
|
||||
}
|
||||
return ywcode + "-" + DateTime.Now.ToString(strLSTemp) + "001";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 转化时分秒
|
||||
/// </summary>
|
||||
/// <param name="strSFM"></param>
|
||||
/// <returns></returns>
|
||||
public static int GetSencond(string strSFM)
|
||||
{
|
||||
int[] ListTemp = strSFM.SplitTOInt(':');
|
||||
|
||||
return ListTemp[0] * 3600 + ListTemp[1] * 60 + ListTemp[2];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 在DataTable末尾添加合计行,最后一个参数设置需要合计的列,Tools.dbDataTableSumRowsWithColList(dt,"车号",new string[]{"个人产值","节油(元)","超油(元)"});
|
||||
/// </summary>
|
||||
/// <param name="dt"></param>
|
||||
/// <param name="nColHeJi">需要显示‘合计’字段的列</param>
|
||||
/// <param name="colsHeJi">需要合计的列</param>
|
||||
public static DataRow dbDataTableSumRowsWithColList(DataTable dt, string sColHeJi, string[] colsHeJi)
|
||||
{
|
||||
DataRow dr = dt.NewRow();
|
||||
dr[sColHeJi] = "合计";
|
||||
dt.Rows.Add(dr);
|
||||
//初始化合计数组
|
||||
decimal[] arrDec = new decimal[colsHeJi.Length];
|
||||
for (int i = 0; i < colsHeJi.Length; i++)
|
||||
{
|
||||
arrDec[i] = decimal.Zero;
|
||||
}
|
||||
//合计
|
||||
for (int i = 0; i < dt.Rows.Count - 1; i++)
|
||||
{
|
||||
for (int j = 0; j < colsHeJi.Length; j++)
|
||||
{
|
||||
string cName = colsHeJi[j];
|
||||
if (Convert.IsDBNull(dt.Rows[i][cName])) continue;
|
||||
arrDec[j] += decimal.Parse(dt.Rows[i][cName] + "");
|
||||
}
|
||||
}
|
||||
//赋值
|
||||
for (int i = 0; i < colsHeJi.Length; i++)
|
||||
{
|
||||
string cName = colsHeJi[i];
|
||||
if (arrDec[i] == decimal.Zero) dr[cName] = "0";
|
||||
else dr[cName] = arrDec[i];
|
||||
}
|
||||
return dr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 分类小计,并有合计行,
|
||||
/// </summary>
|
||||
/// <param name="dt"></param>
|
||||
/// <param name="nColHeJi">需要显示‘合计’字段的列</param>
|
||||
/// <param name="colsHeJi">需要合计的列</param>
|
||||
public static DataRow dbDataTableSubSumRowsWithColList(DataTable dt, string sColHeJi, string strGroupName, string[] colsHeJi)
|
||||
{
|
||||
DataRow dr = dt.NewRow();
|
||||
dr[sColHeJi] = "合计";
|
||||
dt.Rows.Add(dr);
|
||||
//初始化合计数组
|
||||
decimal[] arrDec = new decimal[colsHeJi.Length];
|
||||
for (int i = 0; i < colsHeJi.Length; i++)
|
||||
{
|
||||
arrDec[i] = decimal.Zero;
|
||||
}
|
||||
//合计
|
||||
for (int i = 0; i < dt.Rows.Count - 1; i++)
|
||||
{
|
||||
for (int j = 0; j < colsHeJi.Length; j++)
|
||||
{
|
||||
string cName = colsHeJi[j];
|
||||
if (Convert.IsDBNull(dt.Rows[i][cName])) continue;
|
||||
arrDec[j] += decimal.Parse(dt.Rows[i][cName] + "");
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < colsHeJi.Length; i++)
|
||||
{
|
||||
string cName = colsHeJi[i];
|
||||
if (arrDec[i] == decimal.Zero) dr[cName] = 0;
|
||||
else dr[cName] = arrDec[i];
|
||||
}
|
||||
if (dt.Rows.Count <= 1) return dr;
|
||||
//小计
|
||||
string sRate = "";
|
||||
int currSubSumCol = dt.Rows.Count - 2;
|
||||
ArrayList ar = new ArrayList();
|
||||
for (int i = dt.Rows.Count - 2; i >= 0; i--)
|
||||
{
|
||||
string currRate = dt.Rows[i][strGroupName] + "";
|
||||
if (sRate != currRate)
|
||||
{
|
||||
if (i != dt.Rows.Count - 2)
|
||||
{
|
||||
dr = dt.NewRow();
|
||||
dr[sColHeJi] = "小计";
|
||||
for (int j = 0; j < colsHeJi.Length; j++)
|
||||
{
|
||||
string cName = colsHeJi[j];
|
||||
if (arrDec[j] == decimal.Zero) dr[cName] = 0;
|
||||
else dr[cName] = arrDec[j];
|
||||
}
|
||||
dt.Rows.InsertAt(dr, currSubSumCol + 1);
|
||||
}
|
||||
currSubSumCol = i;
|
||||
sRate = currRate;
|
||||
for (int j = 0; j < colsHeJi.Length; j++)
|
||||
{ //归零
|
||||
arrDec[j] = decimal.Zero;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < colsHeJi.Length; j++)
|
||||
{
|
||||
string cName = colsHeJi[j];
|
||||
if (Convert.IsDBNull(dt.Rows[i][cName])) continue;
|
||||
arrDec[j] += decimal.Parse(dt.Rows[i][cName] + "");
|
||||
}
|
||||
if (i == 0)
|
||||
{
|
||||
dr = dt.NewRow();
|
||||
dr[sColHeJi] = "小计";
|
||||
for (int j = 0; j < colsHeJi.Length; j++)
|
||||
{
|
||||
string cName = colsHeJi[j];
|
||||
if (arrDec[j] == decimal.Zero) dr[cName] = 0;
|
||||
else dr[cName] = arrDec[j];
|
||||
}
|
||||
dt.Rows.InsertAt(dr, currSubSumCol + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return dr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
535
iMES.Bi.API/ExtensionMethods.cs
Normal file
535
iMES.Bi.API/ExtensionMethods.cs
Normal file
@@ -0,0 +1,535 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace iMES.Bi.API
|
||||
{
|
||||
public static class MyExtensions
|
||||
{
|
||||
public static int[] SplitTOInt(this string strs, char ch)
|
||||
{
|
||||
string[] arrstr = strs.Split(ch);
|
||||
int[] arrint = new int[arrstr.Length];
|
||||
for (int i = 0; i < arrstr.Length; i++)
|
||||
{
|
||||
arrint[i] = int.Parse(arrstr[i].ToString());
|
||||
}
|
||||
return arrint;
|
||||
}
|
||||
|
||||
public static List<string> SplitTOList(this string strs, char ch)
|
||||
{
|
||||
List<string> Lstr = new List<string>();
|
||||
string[] arrstr = strs.Split(ch);
|
||||
int[] arrint = new int[arrstr.Length];
|
||||
for (int i = 0; i < arrstr.Length; i++)
|
||||
{
|
||||
Lstr.Add(arrstr[i].ToString());
|
||||
}
|
||||
return Lstr;
|
||||
}
|
||||
|
||||
public static Dictionary<string, string> SplitTODictionary(this string strs, char ch, string strKey)
|
||||
{
|
||||
Dictionary<string, string> Lstr = new Dictionary<string, string>();
|
||||
string[] arrstr = strs.Split(ch);
|
||||
int[] arrint = new int[arrstr.Length];
|
||||
for (int i = 0; i < arrstr.Length; i++)
|
||||
{
|
||||
Lstr.Add(arrstr[i].ToString(), strKey);
|
||||
}
|
||||
return Lstr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将List转化为String
|
||||
/// </summary>
|
||||
/// <param name="Lists"></param>
|
||||
/// <param name="ch"></param>
|
||||
/// <returns></returns>
|
||||
public static string ListTOString(this List<string> Lists, char ch)
|
||||
{
|
||||
string strReturn = "";
|
||||
foreach (var item in Lists)
|
||||
{
|
||||
strReturn = strReturn + item.ToString() + ch;
|
||||
}
|
||||
return strReturn.TrimEnd(ch);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将List(int)转化为String
|
||||
/// </summary>
|
||||
/// <param name="Lists"></param>
|
||||
/// <param name="ch"></param>
|
||||
/// <returns></returns>
|
||||
public static string ListTOString(this List<int> Lists, char ch)
|
||||
{
|
||||
string strReturn = "";
|
||||
foreach (var item in Lists)
|
||||
{
|
||||
strReturn = strReturn + item.ToString() + ch;
|
||||
}
|
||||
return strReturn.TrimEnd(ch);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取需要IN的格式
|
||||
/// </summary>
|
||||
/// <param name="strKys"></param>
|
||||
/// <returns></returns>
|
||||
public static string ToFormatLike(this string strKys)
|
||||
{
|
||||
StringBuilder sbKeys = new StringBuilder();
|
||||
foreach (var item in strKys.Split(','))
|
||||
{
|
||||
sbKeys.AppendFormat("'" + item.ToString() + "',");
|
||||
}
|
||||
return sbKeys.Length > 0 ? sbKeys.ToString().TrimEnd(',').Trim('\'') : "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取需要IN的格式
|
||||
/// </summary>
|
||||
/// <param name="strKys"></param>
|
||||
/// <returns></returns>
|
||||
public static string ToFormatLike(this string strKys, char ch)
|
||||
{
|
||||
StringBuilder sbKeys = new StringBuilder();
|
||||
foreach (var item in strKys.Split(ch))
|
||||
{
|
||||
sbKeys.AppendFormat("'" + item.ToString() + "',");
|
||||
}
|
||||
return sbKeys.Length > 0 ? sbKeys.ToString().TrimEnd(',').Trim('\'') : "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 取前N个字符,后面的用省略号代替
|
||||
/// </summary>
|
||||
/// <param name="strKys"></param>
|
||||
/// <returns></returns>
|
||||
public static string ToMangneStr(this string strKys, int intLenght)
|
||||
{
|
||||
|
||||
return strKys.Length > intLenght ? strKys.Substring(0, intLenght) + "…………" : strKys;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static DataTable ToDataTable<T>(this IEnumerable<T> varlist)
|
||||
{
|
||||
DataTable dtReturn = new DataTable();
|
||||
|
||||
// column names
|
||||
PropertyInfo[] oProps = null;
|
||||
|
||||
if (varlist == null) return dtReturn;
|
||||
|
||||
foreach (T rec in varlist)
|
||||
{
|
||||
if (oProps == null)
|
||||
{
|
||||
oProps = ((Type)rec.GetType()).GetProperties();
|
||||
foreach (PropertyInfo pi in oProps)
|
||||
{
|
||||
Type colType = pi.PropertyType;
|
||||
|
||||
if ((colType.IsGenericType) && (colType.GetGenericTypeDefinition()
|
||||
== typeof(Nullable<>)))
|
||||
{
|
||||
colType = colType.GetGenericArguments()[0];
|
||||
}
|
||||
|
||||
dtReturn.Columns.Add(new DataColumn(pi.Name, colType));
|
||||
}
|
||||
}
|
||||
|
||||
DataRow dr = dtReturn.NewRow();
|
||||
|
||||
foreach (PropertyInfo pi in oProps)
|
||||
{
|
||||
dr[pi.Name] = pi.GetValue(rec, null) == null ? DBNull.Value : pi.GetValue
|
||||
(rec, null);
|
||||
}
|
||||
|
||||
dtReturn.Rows.Add(dr);
|
||||
}
|
||||
return dtReturn;
|
||||
}
|
||||
|
||||
public static DataTable OrderBy(this DataTable dt, string orderBy)
|
||||
{
|
||||
dt.DefaultView.Sort = orderBy;
|
||||
return dt.DefaultView.ToTable();
|
||||
}
|
||||
public static DataTable Where(this DataTable dt, string where)
|
||||
{
|
||||
DataTable resultDt = dt.Clone();
|
||||
DataRow[] resultRows = dt.Select(where);
|
||||
foreach (DataRow dr in resultRows) resultDt.Rows.Add(dr.ItemArray);
|
||||
return resultDt;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Datatable转换为Json
|
||||
/// </summary>
|
||||
/// <param name="table">Datatable对象</param>
|
||||
/// <returns>Json字符串</returns>
|
||||
public static string ToJson(this DataTable dt)
|
||||
{
|
||||
StringBuilder jsonString = new StringBuilder();
|
||||
jsonString.Append("[");
|
||||
DataRowCollection drc = dt.Rows;
|
||||
for (int i = 0; i < drc.Count; i++)
|
||||
{
|
||||
jsonString.Append("{");
|
||||
for (int j = 0; j < dt.Columns.Count; j++)
|
||||
{
|
||||
string strKey = dt.Columns[j].ColumnName;
|
||||
string strValue = drc[i][j].ToString();
|
||||
Type type = dt.Columns[j].DataType;
|
||||
jsonString.Append("\"" + strKey + "\":");
|
||||
strValue = StringFormat(strValue, type);
|
||||
if (j < dt.Columns.Count - 1)
|
||||
{
|
||||
jsonString.Append(strValue + ",");
|
||||
}
|
||||
else
|
||||
{
|
||||
jsonString.Append(strValue);
|
||||
}
|
||||
}
|
||||
jsonString.Append("},");
|
||||
}
|
||||
jsonString.Remove(jsonString.Length - 1, 1);
|
||||
if (jsonString.Length != 0)
|
||||
{
|
||||
jsonString.Append("]");
|
||||
}
|
||||
return jsonString.ToString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static int ToInt32(this Object obj)
|
||||
{
|
||||
return Convert.ToInt32(obj);
|
||||
}
|
||||
|
||||
|
||||
public static DateTime ToDateTime(this Object obj)
|
||||
{
|
||||
return Convert.ToDateTime(obj);
|
||||
}
|
||||
|
||||
public static T GetProperty<T>(this object obj, string propertyName)
|
||||
{
|
||||
var property = obj.GetType().GetProperty(propertyName);
|
||||
if (property != null)
|
||||
{
|
||||
return (T)property.GetValue(obj, null);
|
||||
}
|
||||
throw new ArgumentNullException(propertyName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// DataTable转成Json
|
||||
/// </summary>
|
||||
/// <param name="jsonName"></param>
|
||||
/// <param name="dt"></param>
|
||||
/// <returns></returns>
|
||||
public static string ToJson(this DataTable dt, string jsonName)
|
||||
{
|
||||
StringBuilder Json = new StringBuilder();
|
||||
if (string.IsNullOrEmpty(jsonName))
|
||||
jsonName = dt.TableName;
|
||||
Json.Append("{\"" + jsonName + "\":[");
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
Json.Append("{");
|
||||
for (int j = 0; j < dt.Columns.Count; j++)
|
||||
{
|
||||
Type type = dt.Rows[i][j].GetType();
|
||||
Json.Append("\"" + dt.Columns[j].ColumnName.ToString() + "\":" + StringFormat(dt.Rows[i][j].ToString(), type));
|
||||
if (j < dt.Columns.Count - 1)
|
||||
{
|
||||
Json.Append(",");
|
||||
}
|
||||
}
|
||||
Json.Append("}");
|
||||
if (i < dt.Rows.Count - 1)
|
||||
{
|
||||
Json.Append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
Json.Append("]}");
|
||||
return Json.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 过滤特殊字符
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
/// <returns></returns>
|
||||
public static string String2Json(String s)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < s.Length; i++)
|
||||
{
|
||||
char c = s.ToCharArray()[i];
|
||||
switch (c)
|
||||
{
|
||||
case '\"':
|
||||
sb.Append("\\\""); break;
|
||||
case '\\':
|
||||
sb.Append("\\\\"); break;
|
||||
case '/':
|
||||
sb.Append("\\/"); break;
|
||||
case '\b':
|
||||
sb.Append("\\b"); break;
|
||||
case '\f':
|
||||
sb.Append("\\f"); break;
|
||||
case '\n':
|
||||
sb.Append("\\n"); break;
|
||||
case '\r':
|
||||
sb.Append("\\r"); break;
|
||||
case '\t':
|
||||
sb.Append("\\t"); break;
|
||||
default:
|
||||
sb.Append(c); break;
|
||||
}
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 格式化字符型、日期型、布尔型
|
||||
/// </summary>
|
||||
/// <param name="str"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public static string StringFormat(string str, Type type)
|
||||
{
|
||||
if (type == typeof(string))
|
||||
{
|
||||
str = String2Json(str);
|
||||
str = "\"" + str + "\"";
|
||||
}
|
||||
else if (type == typeof(DateTime))
|
||||
{
|
||||
str = "\"" + str + "\"";
|
||||
}
|
||||
else if (type == typeof(Int32))
|
||||
{
|
||||
if (str.Trim() == "")
|
||||
{
|
||||
str = "\"" + str + "\"";
|
||||
}
|
||||
}
|
||||
else if (type == typeof(bool))
|
||||
{
|
||||
str = str.ToLower();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 过滤特殊字符
|
||||
/// 如果字符串为空,直接返回。
|
||||
/// </summary>
|
||||
/// <param name="str">需要过滤的字符串</param>
|
||||
/// <returns>过滤好的字符串</returns>
|
||||
public static string FilterSpecial(this string str)
|
||||
{
|
||||
if (str == "")
|
||||
{
|
||||
return str;
|
||||
}
|
||||
else
|
||||
{
|
||||
str = str.Replace("'", "");
|
||||
str = str.Replace("<", "");
|
||||
str = str.Replace(">", "");
|
||||
str = str.Replace("%", "");
|
||||
str = str.ToLower().Replace("'delete", "");
|
||||
str = str.ToLower().Replace("'truncate", "");
|
||||
str = str.Replace("''", "");
|
||||
str = str.Replace("\"\"", "");
|
||||
str = str.Replace(",", "");
|
||||
str = str.Replace(".", "");
|
||||
str = str.Replace(">=", "");
|
||||
str = str.Replace("=<", "");
|
||||
str = str.Replace(";", "");
|
||||
str = str.Replace("||", "");
|
||||
str = str.Replace("[", "");
|
||||
str = str.Replace("]", "");
|
||||
str = str.Replace("&", "");
|
||||
str = str.Replace("#", "");
|
||||
str = str.Replace("/", "");
|
||||
str = str.Replace("|", "");
|
||||
str = str.Replace("?", "");
|
||||
str = str.Replace(">?", "");
|
||||
str = str.Replace("?<", "");
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除列
|
||||
/// </summary>
|
||||
/// <param name="dt"></param>
|
||||
/// <param name="sCol">保存的列,其他删除</param>
|
||||
/// <returns></returns>
|
||||
public static DataTable DelTableCol(this DataTable dt, string sCol)
|
||||
{
|
||||
|
||||
if (sCol == "")
|
||||
return dt;
|
||||
string[] sp = sCol.Split(',');
|
||||
string sqldd = "";
|
||||
for (int n = 0; n < sp.Length; n++)
|
||||
{
|
||||
sqldd += sp[n].Split('|')[0] + ',';
|
||||
}
|
||||
for (int i = 0; i < dt.Columns.Count; i++)
|
||||
{
|
||||
if (!sqldd.Split(',').Contains(dt.Columns[i].ColumnName))
|
||||
{
|
||||
dt.Columns.RemoveAt(i);
|
||||
i = i - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = 0; j < sp.Length; j++)
|
||||
{
|
||||
string[] sg = sp[j].Split('|');
|
||||
if (sg.Length > 1 && sg[0] == dt.Columns[i].ColumnName)
|
||||
{
|
||||
dt.Columns[i].ColumnName = sg[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return dt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件过滤表
|
||||
/// </summary>
|
||||
/// <param name="dt">未过滤之前的表</param>
|
||||
/// <param name="filter">过滤条件</param>
|
||||
/// <returns>返回过滤后的表</returns>
|
||||
public static DataTable FilterTable(this DataTable dt, string filter, string isSJ = "N")
|
||||
{
|
||||
|
||||
DataTable newTable = dt.Clone();
|
||||
DataRow[] drs = dt.Select(filter);
|
||||
foreach (DataRow dr in drs)
|
||||
{
|
||||
newTable.Rows.Add(dr.ItemArray);
|
||||
}
|
||||
|
||||
return newTable;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 随机排序
|
||||
/// </summary>
|
||||
/// <param name="newTable"></param>
|
||||
/// <returns></returns>
|
||||
public static DataTable SJTable(this DataTable newTable)
|
||||
{
|
||||
|
||||
Random ran = new Random();
|
||||
newTable.Columns.Add("sort", typeof(int));
|
||||
for (int i = 0; i < newTable.Rows.Count; i++)
|
||||
{
|
||||
newTable.Rows[i]["sort"] = ran.Next(0, 100);
|
||||
}
|
||||
DataView dv = newTable.DefaultView;
|
||||
dv.Sort = "sort asc";
|
||||
newTable = dv.ToTable();
|
||||
return newTable;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 处理生成的DataTable
|
||||
/// </summary>
|
||||
/// <param name="newTable"></param>
|
||||
/// <param name="addclName">添加的列</param>
|
||||
/// <param name="clNames">需要合并的列</param>
|
||||
/// <returns></returns>
|
||||
public static DataTable AddColum(this DataTable DTTable,string addclName, char strChar,params string[] clNames)
|
||||
{
|
||||
|
||||
DTTable.Columns.Add(addclName);
|
||||
for (int i = 0; i < DTTable.Rows.Count; i++)
|
||||
{
|
||||
string strTemp = "";
|
||||
for (int m = 0; m < clNames.Length; m++)
|
||||
{
|
||||
strTemp = strTemp + DTTable.Rows[i][clNames[m]].ToString() + strChar;
|
||||
}
|
||||
DTTable.Rows[i][addclName] = strTemp.TrimEnd(strChar);
|
||||
|
||||
}
|
||||
|
||||
return DTTable;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// dataTable分页
|
||||
/// </summary>
|
||||
/// <param name="dt"></param>
|
||||
/// <param name="PageIndex"></param>
|
||||
/// <param name="PageSize"></param>
|
||||
/// <returns></returns>
|
||||
public static DataTable SplitDataTable(this DataTable dt, int PageIndex, int PageSize)
|
||||
{
|
||||
if (PageIndex == 0)
|
||||
return dt;
|
||||
DataTable newdt = dt.Clone();
|
||||
//newdt.Clear();
|
||||
int rowbegin = (PageIndex - 1) * PageSize;
|
||||
int rowend = PageIndex * PageSize;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
51
iMES.Bi.API/Msg_Result.cs
Normal file
51
iMES.Bi.API/Msg_Result.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace iMES.Bi.API
|
||||
{
|
||||
/// <summary>
|
||||
/// 返回消息类
|
||||
/// </summary>
|
||||
public class Msg_Result
|
||||
{
|
||||
[JsonProperty("Action")]
|
||||
public string Action { get; set; }
|
||||
|
||||
[JsonProperty("ErrorMsg")]
|
||||
public string ErrorMsg { get; set; }
|
||||
public int DataLength { get; set; }
|
||||
public string ResultType { get; set; }
|
||||
|
||||
[JsonProperty("Result")]
|
||||
public dynamic Result { get; set; }
|
||||
|
||||
|
||||
[JsonProperty("Result1")]
|
||||
public dynamic Result1 { get; set; }
|
||||
|
||||
|
||||
[JsonProperty("Result2")]
|
||||
public dynamic Result2 { get; set; }
|
||||
|
||||
|
||||
[JsonProperty("Result3")]
|
||||
public dynamic Result3 { get; set; }
|
||||
|
||||
[JsonProperty("Result4")]
|
||||
public dynamic Result4 { get; set; }
|
||||
|
||||
|
||||
[JsonProperty("Result5")]
|
||||
public dynamic Result5 { get; set; }
|
||||
|
||||
|
||||
[JsonProperty("Result6")]
|
||||
public dynamic Result6 { get; set; }
|
||||
|
||||
[JsonProperty("uptoken")]
|
||||
public dynamic uptoken { get; set; }
|
||||
}
|
||||
}
|
||||
25
iMES.Bi.API/iMES.Bi.API.csproj
Normal file
25
iMES.Bi.API/iMES.Bi.API.csproj
Normal file
@@ -0,0 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="API\Class1.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspose.Words" Version="18.7.0" />
|
||||
<PackageReference Include="DotNetCore.NPOI" Version="1.2.1" />
|
||||
<PackageReference Include="Senparc.Weixin" Version="6.7.401" />
|
||||
<PackageReference Include="Senparc.Weixin.MP" Version="16.10.401" />
|
||||
<PackageReference Include="Senparc.Weixin.Work" Version="3.3.5" />
|
||||
<PackageReference Include="Senparc.Weixin.WxOpen" Version="3.8.401" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\iMES.Bi.Data\iMES.Bi.Data.csproj" />
|
||||
<ProjectReference Include="..\iMES.Core\iMES.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
44
iMES.Bi.Data/Appsettings.cs
Normal file
44
iMES.Bi.Data/Appsettings.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Configuration.Json;
|
||||
using System;
|
||||
|
||||
namespace iMES.Bi.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// appsettings.json操作类
|
||||
/// </summary>
|
||||
public class Appsettings
|
||||
{
|
||||
static IConfiguration Configuration { get; set; }
|
||||
static Appsettings()
|
||||
{
|
||||
//ReloadOnChange = true 当appsettings.json被修改时重新加载
|
||||
Configuration = new ConfigurationBuilder()
|
||||
.Add(new JsonConfigurationSource { Path = "appsettings.json", ReloadOnChange = true })//请注意要把当前appsetting.json 文件->右键->属性->复制到输出目录->始终复制
|
||||
.Build();
|
||||
}
|
||||
/// <summary>
|
||||
/// 封装要操作的字符
|
||||
/// </summary>
|
||||
/// <param name="sections"></param>
|
||||
/// <returns></returns>
|
||||
public static string app(params string[] sections)
|
||||
{
|
||||
try
|
||||
{
|
||||
var val = string.Empty;
|
||||
for (int i = 0; i < sections.Length; i++)
|
||||
{
|
||||
val += sections[i] + ":";
|
||||
}
|
||||
|
||||
return Configuration[val.TrimEnd(':')];
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
270
iMES.Bi.Data/BaseEFDao.cs
Normal file
270
iMES.Bi.Data/BaseEFDao.cs
Normal file
@@ -0,0 +1,270 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace iMES.Bi.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// 公共接口
|
||||
/// </summary>
|
||||
public class BaseEFDao<T> : IBaseDao<T> where T : class, new() //限制T为class
|
||||
{
|
||||
public SqlSugarClient Db;//用来处理事务多表查询和复杂的操作
|
||||
public SimpleClient<T> CurrentDb { get { return new SimpleClient<T>(Db); } }//用来处理T表的常用操作
|
||||
|
||||
public static string ConnectionString = Appsettings.app(new string[] { "Connection", "DbConnectionString" });//获取连接字符串
|
||||
public static string DBType = Appsettings.app(new string[] { "Connection", "DBType" });//获取连接字符串
|
||||
|
||||
|
||||
public BaseEFDao()
|
||||
{
|
||||
|
||||
|
||||
Db = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = ConnectionString,
|
||||
DbType = DBType == "MySql" ? SqlSugar.DbType.MySql : SqlSugar.DbType.SqlServer,
|
||||
InitKeyType = InitKeyType.SystemTable,//从特性读取主键和自增列信息
|
||||
IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样我就不多解释了
|
||||
|
||||
});
|
||||
// 调式代码 用来打印SQL
|
||||
Db.Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public void CModel()
|
||||
{
|
||||
Db.DbFirst.CreateClassFile("E:\\Demo", "iMES.Bi.Data");
|
||||
}
|
||||
public virtual IEnumerable<T> GetALLEntities()
|
||||
{
|
||||
|
||||
//AsNoTracking不记录数据变化状况
|
||||
return CurrentDb.GetList();
|
||||
|
||||
}
|
||||
public virtual IEnumerable<T> GetEntities(Expression<Func<T, bool>> exp)
|
||||
{
|
||||
|
||||
//AsNoTracking不记录数据变化状况
|
||||
return CurrentDb.GetList(exp).ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据条件查找
|
||||
/// </summary>
|
||||
/// <param name="exp">lambda查询条件where</param>
|
||||
/// <returns></returns>
|
||||
public virtual T GetEntity(Expression<Func<T, bool>> exp)
|
||||
{
|
||||
return CurrentDb.GetList(exp).SingleOrDefault();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有Entity(立即执行请使用ToList()
|
||||
/// </summary>
|
||||
/// <param name="CommandText">Sql语句</param>
|
||||
/// <param name="objParams">可变参数</param>
|
||||
/// <returns></returns>
|
||||
public virtual IEnumerable<T> GetEntities(string CommandText)
|
||||
{
|
||||
return Db.SqlQueryable<T>("select * from " + typeof(T).Name + " where 1=1 and " + CommandText).ToList();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 插入Entity
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool Insert(T entity)
|
||||
{
|
||||
entity= Db.Insertable<T>(entity).ExecuteReturnEntity();
|
||||
//int dataID = CurrentDb.InsertReturnIdentity(entity);
|
||||
//List<string> List = Db.DbMaintenance.GetIsIdentities(entity.GetType().Name);
|
||||
//if (List.Count > 0)
|
||||
//{
|
||||
// //如果有自增,赋值
|
||||
// entity.GetType().GetProperty(List[0].ToString()).SetValue(entity, dataID, null);
|
||||
//}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同时插入多个实体。
|
||||
/// </summary>
|
||||
/// <param name="entities"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool Insert(IEnumerable<T> entities)
|
||||
{
|
||||
int Return = 0;
|
||||
if (entities.Count() > 0)
|
||||
{
|
||||
Return = Db.Insertable(entities.ToArray()).ExecuteCommand();
|
||||
}
|
||||
return Return > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新Entity(注意这里使用的傻瓜式更新,可能性能略低)
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool Update(T entity)
|
||||
{
|
||||
return CurrentDb.Update(entity);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除Entity
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool Delete(T entity)
|
||||
{
|
||||
return CurrentDb.Delete(entity);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 批量删除Entity
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool Delete(Expression<Func<T, bool>> exp)
|
||||
{
|
||||
return CurrentDb.Delete(exp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件查找
|
||||
/// </summary>
|
||||
/// <param name="CommandText">Sql语句</param>
|
||||
/// <param name="objParams">可变参数</param>
|
||||
/// <returns></returns>
|
||||
public virtual DataTable GetDTByCommand(string CommandText)
|
||||
{
|
||||
return Db.Ado.GetDataTable(CovSQL(CommandText));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取链接字符串
|
||||
/// </summary>
|
||||
/// <param name="CommandText">Sql语句</param>
|
||||
/// <param name="objParams">可变参数</param>
|
||||
/// <returns></returns>
|
||||
public string GetDBString()
|
||||
{
|
||||
return Db.CurrentConnectionConfig.ConnectionString;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//执行SQL语句
|
||||
public void ExsSql(string sql)
|
||||
{
|
||||
List<SugarParameter> parameters = null;
|
||||
Db.Ado.ExecuteCommand(CovSQL(sql), parameters);
|
||||
}
|
||||
|
||||
public object ExsSclarSql(string sql)
|
||||
{
|
||||
List<SugarParameter> parameters = null;
|
||||
return Db.Ado.GetString(CovSQL(sql), parameters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 替换
|
||||
/// </summary>
|
||||
/// <param name="strSQL"></param>
|
||||
/// <returns></returns>
|
||||
private string CovSQL(string strSQL)
|
||||
{
|
||||
if (Db.CurrentConnectionConfig.DbType == SqlSugar.DbType.MySql)//MYSQL数据库
|
||||
{
|
||||
strSQL = strSQL.Replace("isnull", "ifnull").Replace("ISNULL", "IFNULL");
|
||||
}
|
||||
return strSQL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 数据分页
|
||||
/// </summary>
|
||||
/// <param name="viewName">表名</param>
|
||||
/// <param name="fieldName">字段</param>
|
||||
/// <param name="pageSize">默认20</param>
|
||||
/// <param name="pageNo">页数</param>
|
||||
/// <param name="orderString">排序</param>
|
||||
/// <param name="whereString">可选</param>
|
||||
/// <param name="recordTotal">总数</param>
|
||||
/// <returns></returns>
|
||||
public DataTable GetDataPager(string viewName, string fieldName, int pageSize, int pageNo, string orderString, string whereString, ref int recordTotal)
|
||||
{
|
||||
string strSQL = "select " + fieldName + " from " + viewName + " where " + whereString;
|
||||
DataTable dt = Db.SqlQueryable<Object>(CovSQL(strSQL)).OrderBy(orderString).ToDataTablePage(pageNo, pageSize, ref recordTotal);
|
||||
return dt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 数据分页
|
||||
/// </summary>
|
||||
/// <param name="strSQL"></param>
|
||||
/// <param name="strOrder"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="pageNo"></param>
|
||||
/// <param name="recordTotal"></param>
|
||||
/// <returns></returns>
|
||||
public DataTable GetDataPager(string strSQL,string strOrder, int pageSize, int pageNo, ref int recordTotal)
|
||||
{
|
||||
DataTable dt = Db.SqlQueryable<Object>(CovSQL(strSQL)).OrderBy(strOrder).ToDataTablePage(pageNo, pageSize, ref recordTotal);
|
||||
return dt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 行专列
|
||||
/// </summary>
|
||||
/// <param name="CommandText">Sql语句</param>
|
||||
/// <param name="objParams">可变参数</param>
|
||||
/// <returns></returns>
|
||||
public string GetDTHZL(string ExtendModes, string pdid)
|
||||
{
|
||||
string strSQL = "";
|
||||
if (Db.CurrentConnectionConfig.DbType == 0)//MYSQL数据库
|
||||
{
|
||||
string strTemp = "";
|
||||
foreach (string filename in ExtendModes.Split(','))
|
||||
{
|
||||
strTemp = strTemp + " MAX(CASE ExFiledColumn WHEN '" + filename + "' THEN ExtendDataValue ELSE 0 END ) " + filename + ",";
|
||||
}
|
||||
strTemp = strTemp.TrimEnd(',');
|
||||
strSQL = " SELECT * FROM ( SELECT uuid() AS ID, DataID,Yan_WF_PI.ISGD,Yan_WF_PI.BranchNo,Yan_WF_PI.BranchName,Yan_WF_PI.CRUser,Yan_WF_PI.CRUserName, Yan_WF_PI.CRDate, " + strTemp + " FROM JH_Auth_ExtendData INNER JOIN Yan_WF_PI ON JH_Auth_ExtendData.DataID=Yan_WF_PI.ID AND JH_Auth_ExtendData.PDID='" + pdid + "' GROUP BY DataID,Yan_WF_PI.ISGD,Yan_WF_PI.BranchNo,Yan_WF_PI.BranchName,Yan_WF_PI.CRUser,Yan_WF_PI.CRUserName, Yan_WF_PI.CRDate ) T ";
|
||||
|
||||
}
|
||||
else //sqlServer数据库
|
||||
{
|
||||
strSQL = " SELECT NEWID() AS ID, * FROM ( SELECT Yan_WF_PI.ISGD,Yan_WF_PI.BranchNo,Yan_WF_PI.BranchName,JH_Auth_ExtendData.DataID, Yan_WF_PI.CRUser,Yan_WF_PI.CRUserName, Yan_WF_PI.CRDate, JH_Auth_ExtendMode.TableFiledColumn, ExtendDataValue from JH_Auth_ExtendMode INNER JOIN JH_Auth_ExtendData ON JH_Auth_ExtendMode.PDID=JH_Auth_ExtendData.PDID and JH_Auth_ExtendMode.TableFiledColumn=JH_Auth_ExtendData.ExFiledColumn and JH_Auth_ExtendMode.PDID='" + pdid + "' INNER JOIN Yan_WF_PI ON JH_Auth_ExtendData.DataID=Yan_WF_PI.ID ) AS P PIVOT ( MAX(ExtendDataValue) FOR p.TableFiledColumn IN (" + ExtendModes + ") ) AS T ";
|
||||
|
||||
}
|
||||
return strSQL;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
237
iMES.Bi.Data/BaseEFDaoJW.cs
Normal file
237
iMES.Bi.Data/BaseEFDaoJW.cs
Normal file
@@ -0,0 +1,237 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace iMES.Bi.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// 公共接口
|
||||
/// </summary>
|
||||
public class BaseEFDaoJW<T> : IBaseDao<T> where T : class, new() //限制T为class
|
||||
{
|
||||
public SqlSugarClient Db;//用来处理事务多表查询和复杂的操作
|
||||
public SimpleClient<T> CurrentDb { get { return new SimpleClient<T>(Db); } }//用来处理T表的常用操作
|
||||
|
||||
public static string ConnectionString = Appsettings.app(new string[] { "Connection", "DbConnectionString" });//获取连接字符串
|
||||
public static string DBType = Appsettings.app(new string[] { "Connection", "DBType" });//获取连接字符串
|
||||
|
||||
public BaseEFDaoJW()
|
||||
{
|
||||
Db = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = ConnectionString,
|
||||
DbType = DBType == "MySql" ? SqlSugar.DbType.MySql : SqlSugar.DbType.SqlServer,
|
||||
InitKeyType = InitKeyType.SystemTable,//从特性读取主键和自增列信息
|
||||
IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样我就不多解释了
|
||||
|
||||
});
|
||||
// 调式代码 用来打印SQL
|
||||
Db.Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
//WriteLOG(sql + "\r\n" + Db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
|
||||
};
|
||||
}
|
||||
public void CModel()
|
||||
{
|
||||
Db.DbFirst.CreateClassFile("E:\\Demo", "iMES.Bi.Data");
|
||||
}
|
||||
public virtual IEnumerable<T> GetALLEntities()
|
||||
{
|
||||
|
||||
//AsNoTracking不记录数据变化状况
|
||||
return CurrentDb.GetList();
|
||||
}
|
||||
public virtual IEnumerable<T> GetEntities(Expression<Func<T, bool>> exp)
|
||||
{
|
||||
//AsNoTracking不记录数据变化状况
|
||||
return CurrentDb.GetList(exp).ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据条件查找
|
||||
/// </summary>
|
||||
/// <param name="exp">lambda查询条件where</param>
|
||||
/// <returns></returns>
|
||||
public virtual T GetEntity(Expression<Func<T, bool>> exp)
|
||||
{
|
||||
return CurrentDb.GetList(exp).SingleOrDefault();
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取所有Entity(立即执行请使用ToList()
|
||||
/// </summary>
|
||||
/// <param name="CommandText">Sql语句</param>
|
||||
/// <param name="objParams">可变参数</param>
|
||||
/// <returns></returns>
|
||||
public virtual IEnumerable<T> GetEntities(string CommandText)
|
||||
{
|
||||
return Db.SqlQueryable<T>("select * from " + typeof(T).Name + " where 1=1 and " + CommandText).ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 插入Entity
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool Insert(T entity)
|
||||
{
|
||||
entity= Db.Insertable<T>(entity).ExecuteReturnEntity();
|
||||
//int dataID = CurrentDb.InsertReturnIdentity(entity);
|
||||
//List<string> List = Db.DbMaintenance.GetIsIdentities(entity.GetType().Name);
|
||||
//if (List.Count > 0)
|
||||
//{
|
||||
// //如果有自增,赋值
|
||||
// entity.GetType().GetProperty(List[0].ToString()).SetValue(entity, dataID, null);
|
||||
//}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同时插入多个实体。
|
||||
/// </summary>
|
||||
/// <param name="entities"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool Insert(IEnumerable<T> entities)
|
||||
{
|
||||
int Return = 0;
|
||||
if (entities.Count() > 0)
|
||||
{
|
||||
Return = Db.Insertable(entities.ToArray()).ExecuteCommand();
|
||||
}
|
||||
return Return > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新Entity(注意这里使用的傻瓜式更新,可能性能略低)
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool Update(T entity)
|
||||
{
|
||||
return CurrentDb.Update(entity);
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除Entity
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool Delete(T entity)
|
||||
{
|
||||
return CurrentDb.Delete(entity);
|
||||
}
|
||||
/// <summary>
|
||||
/// 批量删除Entity
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool Delete(Expression<Func<T, bool>> exp)
|
||||
{
|
||||
return CurrentDb.Delete(exp);
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据条件查找
|
||||
/// </summary>
|
||||
/// <param name="CommandText">Sql语句</param>
|
||||
/// <param name="objParams">可变参数</param>
|
||||
/// <returns></returns>
|
||||
public virtual DataTable GetDTByCommand(string CommandText)
|
||||
{
|
||||
return Db.Ado.GetDataTable(CovSQL(CommandText));
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取链接字符串
|
||||
/// </summary>
|
||||
/// <param name="CommandText">Sql语句</param>
|
||||
/// <param name="objParams">可变参数</param>
|
||||
/// <returns></returns>
|
||||
public string GetDBString()
|
||||
{
|
||||
return Db.CurrentConnectionConfig.ConnectionString;
|
||||
}
|
||||
//执行SQL语句
|
||||
public void ExsSql(string sql)
|
||||
{
|
||||
List<SugarParameter> parameters = null;
|
||||
Db.Ado.ExecuteCommand(CovSQL(sql), parameters);
|
||||
}
|
||||
public object ExsSclarSql(string sql)
|
||||
{
|
||||
List<SugarParameter> parameters = null;
|
||||
return Db.Ado.GetString(CovSQL(sql), parameters);
|
||||
}
|
||||
/// <summary>
|
||||
/// 替换
|
||||
/// </summary>
|
||||
/// <param name="strSQL"></param>
|
||||
/// <returns></returns>
|
||||
private string CovSQL(string strSQL)
|
||||
{
|
||||
if (Db.CurrentConnectionConfig.DbType == SqlSugar.DbType.MySql)//MYSQL数据库
|
||||
{
|
||||
strSQL = strSQL.Replace("isnull", "ifnull").Replace("ISNULL", "IFNULL");
|
||||
}
|
||||
return strSQL;
|
||||
}
|
||||
/// <summary>
|
||||
/// 数据分页
|
||||
/// </summary>
|
||||
/// <param name="viewName">表名</param>
|
||||
/// <param name="fieldName">字段</param>
|
||||
/// <param name="pageSize">默认20</param>
|
||||
/// <param name="pageNo">页数</param>
|
||||
/// <param name="orderString">排序</param>
|
||||
/// <param name="whereString">可选</param>
|
||||
/// <param name="recordTotal">总数</param>
|
||||
/// <returns></returns>
|
||||
public DataTable GetDataPager(string viewName, string fieldName, int pageSize, int pageNo, string orderString, string whereString, ref int recordTotal)
|
||||
{
|
||||
string strSQL = "select " + fieldName + " from " + viewName + " where " + whereString;
|
||||
DataTable dt = Db.SqlQueryable<Object>(CovSQL(strSQL)).OrderBy(orderString).ToDataTablePage(pageNo, pageSize, ref recordTotal);
|
||||
return dt;
|
||||
}
|
||||
/// <summary>
|
||||
/// 数据分页
|
||||
/// </summary>
|
||||
/// <param name="strSQL"></param>
|
||||
/// <param name="strOrder"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="pageNo"></param>
|
||||
/// <param name="recordTotal"></param>
|
||||
/// <returns></returns>
|
||||
public DataTable GetDataPager(string strSQL,string strOrder, int pageSize, int pageNo, ref int recordTotal)
|
||||
{
|
||||
DataTable dt = Db.SqlQueryable<Object>(CovSQL(strSQL)).OrderBy(strOrder).ToDataTablePage(pageNo, pageSize, ref recordTotal);
|
||||
return dt;
|
||||
}
|
||||
/// <summary>
|
||||
/// 行专列
|
||||
/// </summary>
|
||||
/// <param name="CommandText">Sql语句</param>
|
||||
/// <param name="objParams">可变参数</param>
|
||||
/// <returns></returns>
|
||||
public string GetDTHZL(string ExtendModes, string pdid)
|
||||
{
|
||||
string strSQL = "";
|
||||
if (Db.CurrentConnectionConfig.DbType == 0)//MYSQL数据库
|
||||
{
|
||||
string strTemp = "";
|
||||
foreach (string filename in ExtendModes.Split(','))
|
||||
{
|
||||
strTemp = strTemp + " MAX(CASE ExFiledColumn WHEN '" + filename + "' THEN ExtendDataValue ELSE 0 END ) " + filename + ",";
|
||||
}
|
||||
strTemp = strTemp.TrimEnd(',');
|
||||
strSQL = " SELECT * FROM ( SELECT uuid() AS ID, DataID,Yan_WF_PI.ISGD,Yan_WF_PI.BranchNo,Yan_WF_PI.BranchName,Yan_WF_PI.CRUser,Yan_WF_PI.CRUserName, Yan_WF_PI.CRDate, " + strTemp + " FROM JH_Auth_ExtendData INNER JOIN Yan_WF_PI ON JH_Auth_ExtendData.DataID=Yan_WF_PI.ID AND JH_Auth_ExtendData.PDID='" + pdid + "' GROUP BY DataID,Yan_WF_PI.ISGD,Yan_WF_PI.BranchNo,Yan_WF_PI.BranchName,Yan_WF_PI.CRUser,Yan_WF_PI.CRUserName, Yan_WF_PI.CRDate ) T ";
|
||||
|
||||
}
|
||||
else //sqlServer数据库
|
||||
{
|
||||
strSQL = " SELECT NEWID() AS ID, * FROM ( SELECT Yan_WF_PI.ISGD,Yan_WF_PI.BranchNo,Yan_WF_PI.BranchName,JH_Auth_ExtendData.DataID, Yan_WF_PI.CRUser,Yan_WF_PI.CRUserName, Yan_WF_PI.CRDate, JH_Auth_ExtendMode.TableFiledColumn, ExtendDataValue from JH_Auth_ExtendMode INNER JOIN JH_Auth_ExtendData ON JH_Auth_ExtendMode.PDID=JH_Auth_ExtendData.PDID and JH_Auth_ExtendMode.TableFiledColumn=JH_Auth_ExtendData.ExFiledColumn and JH_Auth_ExtendMode.PDID='" + pdid + "' INNER JOIN Yan_WF_PI ON JH_Auth_ExtendData.DataID=Yan_WF_PI.ID ) AS P PIVOT ( MAX(ExtendDataValue) FOR p.TableFiledColumn IN (" + ExtendModes + ") ) AS T ";
|
||||
|
||||
}
|
||||
return strSQL;
|
||||
}
|
||||
}
|
||||
}
|
||||
173
iMES.Bi.Data/DBFactory.cs
Normal file
173
iMES.Bi.Data/DBFactory.cs
Normal file
@@ -0,0 +1,173 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
namespace iMES.Bi.Data
|
||||
{
|
||||
public class DBFactory
|
||||
{
|
||||
private SqlSugarClient db;
|
||||
public DBFactory()
|
||||
{
|
||||
}
|
||||
public static string DBType = Appsettings.app(new string[] { "Connection", "DBType" });//获取连接字符串
|
||||
public DBFactory(string ConnectionString)
|
||||
{
|
||||
db = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = ConnectionString, //必填, 数据库连接字符串
|
||||
DbType = DBType == "MySql" ? SqlSugar.DbType.MySql : SqlSugar.DbType.SqlServer, //必填, 数据库类型
|
||||
IsAutoCloseConnection = true, //默认false, 时候知道关闭数据库连接, 设置为true无需使用using或者Close操作
|
||||
InitKeyType = InitKeyType.SystemTable //默认SystemTable, 字段信息读取, 如:该属性是不是主键,是不是标识列等等信息
|
||||
});
|
||||
db.Aop.OnLogExecuting = (sql, pars) => //SQL执行前事件
|
||||
{
|
||||
string strSQL = sql;
|
||||
SugarParameter[] pr = pars;
|
||||
};
|
||||
}
|
||||
public DBFactory(string DBType, string DBIP, string Port, string DBName, string DBUser, string DBPwd)
|
||||
{
|
||||
string connectionString = "";
|
||||
var DbType = SqlSugar.DbType.MySql;
|
||||
if (DBType.ToLower() == "sqlserver")
|
||||
{
|
||||
if (string.IsNullOrEmpty(Port))
|
||||
{
|
||||
Port = "1433";
|
||||
}
|
||||
DbType = SqlSugar.DbType.SqlServer;
|
||||
connectionString = string.Format("Data Source ={0},{4};Initial Catalog ={1};User Id ={2};Password={3};", DBIP, DBName, DBUser, DBPwd, Port);
|
||||
}
|
||||
else if (DBType.ToLower() == "mysql")
|
||||
{
|
||||
DbType = SqlSugar.DbType.MySql;
|
||||
if (string.IsNullOrEmpty(Port))
|
||||
{
|
||||
Port = "3306";
|
||||
}
|
||||
connectionString = string.Format("server={0};userid={1};password={2};database={3};PORT={4};", DBIP, DBUser, DBPwd, DBName, Port);
|
||||
}
|
||||
db = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = connectionString, //必填, 数据库连接字符串
|
||||
DbType = DbType, //必填, 数据库类型
|
||||
IsAutoCloseConnection = true, //默认false, 时候知道关闭数据库连接, 设置为true无需使用using或者Close操作
|
||||
InitKeyType = InitKeyType.SystemTable //默认SystemTable, 字段信息读取, 如:该属性是不是主键,是不是标识列等等信息
|
||||
});
|
||||
|
||||
db.Aop.OnLogExecuting = (sql, pars) => //SQL执行前事件
|
||||
{
|
||||
string strSQL = sql;
|
||||
SugarParameter[] pr = pars;
|
||||
};
|
||||
}
|
||||
//测试连接
|
||||
public bool TestConn()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (db.Ado.Connection.State != ConnectionState.Open)
|
||||
{
|
||||
db.Ado.Connection.Open();
|
||||
}
|
||||
if (db.Ado.Connection.State == ConnectionState.Open)
|
||||
{
|
||||
db.Ado.Connection.Close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
return false;
|
||||
}
|
||||
public string GetDBType()
|
||||
{
|
||||
return db.DbMaintenance.Context.CurrentConnectionConfig.DbType.ToString();
|
||||
}
|
||||
public void CModel()
|
||||
{
|
||||
db.DbFirst.CreateClassFile("D:\\Demo\\1");
|
||||
}
|
||||
public DataTable GetTables()
|
||||
{
|
||||
DataTable data = db.Ado.GetDataTable("select name ,type_desc from sys.objects where type_desc in ('USER_TABLE','VIEW') ORDER BY name");
|
||||
return data;
|
||||
}
|
||||
public List<DbTableInfo> GetDBTables()
|
||||
{
|
||||
List<DbTableInfo> data = db.DbMaintenance.GetTableInfoList();
|
||||
return data;
|
||||
}
|
||||
public SqlSugarClient GetDBClient()
|
||||
{
|
||||
return db;
|
||||
}
|
||||
public DataTable GetSQL(string strSQL)
|
||||
{
|
||||
DataTable data = db.Ado.GetDataTable(strSQL);
|
||||
return data;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取SQL模型数据
|
||||
/// </summary>
|
||||
/// <param name="DS"></param>
|
||||
/// <param name="wd"></param>
|
||||
/// <param name="dl"></param>
|
||||
/// <param name="strTableFiled"></param>
|
||||
/// <param name="strDataCount"></param>
|
||||
/// <param name="strWhere"></param>
|
||||
/// <returns></returns>
|
||||
public DataTable GetYBData(string DSSQL, string wd, string dl, string strDataCount, string strWhere, string Order, int pageNo, int pageSize, string wdgroup, string wdhaving, ref int recordTotal, ref string strReturnSQL)
|
||||
{
|
||||
DataTable dt = new DataTable();
|
||||
String strfids = (wd + "," + dl).Trim(',');
|
||||
var Q = db.SqlQueryable<Object>(DSSQL).WhereIF(!string.IsNullOrWhiteSpace(strWhere), strWhere).Select(strfids).OrderByIF(!string.IsNullOrWhiteSpace(Order), Order).Distinct();
|
||||
if (!string.IsNullOrWhiteSpace(wdgroup))
|
||||
{
|
||||
Q = Q.GroupBy(wdgroup);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(wdhaving))
|
||||
{
|
||||
Q = Q.Having(wdhaving);
|
||||
}
|
||||
if (strDataCount != "0")
|
||||
{
|
||||
Q = Q.Take(int.Parse(strDataCount));
|
||||
}
|
||||
if (pageSize == 0)
|
||||
{
|
||||
dt = Q.ToDataTable();
|
||||
}
|
||||
else
|
||||
{
|
||||
dt = Q.ToDataTablePage(pageNo, pageSize, ref recordTotal);
|
||||
}
|
||||
if (dt.Columns.Contains("RowIndex"))
|
||||
{
|
||||
///SQLSERVER多出来得一列
|
||||
dt.Columns.Remove("RowIndex");
|
||||
}
|
||||
strReturnSQL = Q.ToSql().Key;
|
||||
return dt;
|
||||
}
|
||||
/// <summary>
|
||||
/// 插入数据
|
||||
/// </summary>
|
||||
/// <param name="DS"></param>
|
||||
/// <param name="strTable"></param>
|
||||
/// <returns></returns>
|
||||
public int InserData(Dictionary<string, object> DS, string strTable)
|
||||
{
|
||||
var t66 = db.Insertable(DS).AS(strTable).ExecuteReturnIdentity();
|
||||
return int.Parse(t66.ToString());
|
||||
}
|
||||
public int UpdateData(Dictionary<string, object> DS, string strTable)
|
||||
{
|
||||
var returndata = db.Updateable(DS).AS(strTable).ExecuteCommand();
|
||||
return int.Parse(returndata.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
62
iMES.Bi.Data/IBaseDao.cs
Normal file
62
iMES.Bi.Data/IBaseDao.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Web;
|
||||
|
||||
|
||||
namespace iMES.Bi.Data
|
||||
{
|
||||
public interface IBaseDao<T> where T : class //限制class
|
||||
{
|
||||
#region 查询普通实现方案(基于Lambda表达式的Where查询)
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有Entity
|
||||
/// </summary>
|
||||
/// <param name="exp">Lambda条件的where</param>
|
||||
/// <returns></returns>
|
||||
IEnumerable<T> GetEntities(Expression<Func<T, bool>> exp);
|
||||
/// <summary>
|
||||
/// 根据条件查找
|
||||
/// </summary>
|
||||
/// <param name="exp">lambda查询条件where</param>
|
||||
/// <returns></returns>
|
||||
T GetEntity(Expression<Func<T, bool>> exp);
|
||||
|
||||
#endregion 查询普通实现方案(基于Lambda表达式的Where查询)
|
||||
|
||||
#region 查询Sql语句外接接口的查询实现
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有Entity(立即执行请使用ToList()
|
||||
/// </summary>
|
||||
/// <param name="CommandText">Sql语句</param>
|
||||
/// <param name="objParams">可变参数</param>
|
||||
/// <returns></returns>
|
||||
IEnumerable<T> GetEntities(string CommandText);
|
||||
|
||||
#endregion 查询Sql语句外接接口的查询实现
|
||||
|
||||
/// <summary>
|
||||
/// 插入Entity
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
bool Insert(T entity);
|
||||
|
||||
/// <summary>
|
||||
/// 更新Entity
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
bool Update(T entity);
|
||||
|
||||
/// <summary>
|
||||
/// 删除Entity
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
bool Delete(T entity);
|
||||
}
|
||||
}
|
||||
18
iMES.Bi.Data/Models/BI_DB_Dim.cs
Normal file
18
iMES.Bi.Data/Models/BI_DB_Dim.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace iMES.Bi.Data
|
||||
{
|
||||
public partial class BI_DB_Dim
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public int? STID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ColumnName { get; set; }
|
||||
public string ColumnType { get; set; }
|
||||
public string Dimension { get; set; }
|
||||
public string CRUser { get; set; }
|
||||
public DateTime? CRDate { get; set; }
|
||||
public string ColumnSource { get; set; }
|
||||
}
|
||||
}
|
||||
19
iMES.Bi.Data/Models/BI_DB_Set.cs
Normal file
19
iMES.Bi.Data/Models/BI_DB_Set.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace iMES.Bi.Data
|
||||
{
|
||||
public partial class BI_DB_Set
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public int? SID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string SName { get; set; }
|
||||
public string CRUser { get; set; }
|
||||
public DateTime? CRDate { get; set; }
|
||||
public DateTime? UPDate { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Option { get; set; }
|
||||
public string DSQL { get; set; }
|
||||
}
|
||||
}
|
||||
21
iMES.Bi.Data/Models/BI_DB_Source.cs
Normal file
21
iMES.Bi.Data/Models/BI_DB_Source.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace iMES.Bi.Data
|
||||
{
|
||||
public partial class BI_DB_Source
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string DBType { get; set; }
|
||||
public string DBIP { get; set; }
|
||||
public string Port { get; set; }
|
||||
public string DBName { get; set; }
|
||||
public string Schema { get; set; }
|
||||
public string DBUser { get; set; }
|
||||
public string DBPwd { get; set; }
|
||||
public string Attach { get; set; }
|
||||
public string CRUser { get; set; }
|
||||
public DateTime? CRDate { get; set; }
|
||||
}
|
||||
}
|
||||
19
iMES.Bi.Data/Models/BI_DB_Table.cs
Normal file
19
iMES.Bi.Data/Models/BI_DB_Table.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace iMES.Bi.Data
|
||||
{
|
||||
public partial class BI_DB_Table
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string TableName { get; set; }
|
||||
public string TableDesc { get; set; }
|
||||
public string CRUser { get; set; }
|
||||
public DateTime? CRDate { get; set; }
|
||||
public int ModelID { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public int DSID { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
29
iMES.Bi.Data/Models/BI_DB_Tablefiled.cs
Normal file
29
iMES.Bi.Data/Models/BI_DB_Tablefiled.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace iMES.Bi.Data
|
||||
{
|
||||
public partial class BI_DB_Tablefiled
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public int? TableID { get; set; }
|
||||
public string TableName { get; set; }
|
||||
public string PropertyName { get; set; }
|
||||
public string ColumnDescription { get; set; }
|
||||
public string DataType { get; set; }
|
||||
public string IsPrimarykey { get; set; }
|
||||
public string CRUser { get; set; }
|
||||
public DateTime? CRDate { get; set; }
|
||||
public string DbColumnName { get; set; }
|
||||
public string IsIdentity { get; set; }
|
||||
public string IsNullable { get; set; }
|
||||
public string isPkey { get; set; }
|
||||
public string DecimalDigits { get; set; }
|
||||
public int Length { get; set; }
|
||||
public string DefaultValue { get; set; }
|
||||
public string Scale { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
18
iMES.Bi.Data/Models/BI_DB_YBP.cs
Normal file
18
iMES.Bi.Data/Models/BI_DB_YBP.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace iMES.Bi.Data
|
||||
{
|
||||
public partial class BI_DB_YBP
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public int? DimID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string YBContent { get; set; }
|
||||
public string YBType { get; set; }
|
||||
public string YBOption { get; set; }
|
||||
public string CRUser { get; set; }
|
||||
public DateTime? CRDate { get; set; }
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
108
iMES.Bi.Data/SqlHelp.cs
Normal file
108
iMES.Bi.Data/SqlHelp.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
namespace iMES.Bi.Data
|
||||
{
|
||||
public class SqlHelp
|
||||
{
|
||||
/// <summary>
|
||||
/// 将SQLserver的连接字符串语法转为Mysql的语法
|
||||
/// </summary>
|
||||
/// <param name="objs"></param>
|
||||
/// <returns></returns>
|
||||
public static string concat(string strConSQL)
|
||||
{
|
||||
string strReturn = strConSQL;
|
||||
string strDbType = Appsettings.app("DBType");
|
||||
if (strDbType == "0")
|
||||
{
|
||||
strReturn = "CONCAT(" + strReturn.Replace('+', ',') + ")";
|
||||
}
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析日期格式
|
||||
/// </summary>
|
||||
/// <param name="objs"></param>
|
||||
/// <returns></returns>
|
||||
public static string TADate(string strWDColumCode, string strDbType, ref string strGroup)
|
||||
{
|
||||
string strFiledName = strWDColumCode.Split('_')[0];
|
||||
string Format = strWDColumCode.Split('_')[1];
|
||||
|
||||
string strReturn = "";
|
||||
if (strDbType == "MYSQL")
|
||||
{
|
||||
switch (Format)
|
||||
{
|
||||
case "YYYY":
|
||||
strGroup = " DATE_FORMAT(" + strFiledName + ",'%Y') ";
|
||||
strReturn = " DATE_FORMAT(" + strFiledName + ",'%Y') " + strWDColumCode;
|
||||
break;
|
||||
case "YYYYMM":
|
||||
strGroup = " DATE_FORMAT(" + strFiledName + ",'%Y%m') ";
|
||||
strReturn = " DATE_FORMAT(" + strFiledName + ",'%Y%m') " + strWDColumCode;
|
||||
break;
|
||||
case "YYYYMMDD":
|
||||
strGroup = " DATE_FORMAT(" + strFiledName + ",'%Y%m%d') ";
|
||||
strReturn = " DATE_FORMAT(" + strFiledName + ",'%Y%m%d') " + strWDColumCode;
|
||||
break;
|
||||
case "YYYYMMDDHH":
|
||||
strGroup = " DATE_FORMAT(" + strFiledName + ",'%Y%m%d%h') ";
|
||||
strReturn = " DATE_FORMAT(" + strFiledName + ",'%Y%m%d%h') " + strWDColumCode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (strDbType == "SQLSERVER")
|
||||
{
|
||||
switch (Format)
|
||||
{
|
||||
case "YYYY":
|
||||
strGroup = " LEFT(CONVERT(varchar(100)," + strFiledName + ",112),4) ";
|
||||
strReturn = " LEFT(CONVERT(varchar(100)," + strFiledName + ",112),4) AS '" + strWDColumCode + "'";
|
||||
break;
|
||||
case "YYYYMM":
|
||||
strGroup = " LEFT(CONVERT(varchar(100)," + strFiledName + ",112),6) ";
|
||||
strReturn = " LEFT(CONVERT(varchar(100)," + strFiledName + ",112),6) AS '" + strWDColumCode + "'";
|
||||
break;
|
||||
case "YYYYMMDD":
|
||||
strGroup = " LEFT(CONVERT(varchar(100)," + strFiledName + ",112),8) ";
|
||||
strReturn = " LEFT(CONVERT(varchar(100)," + strFiledName + ",112),8) AS '" + strWDColumCode + "'";
|
||||
break;
|
||||
case "YYYYMMDDHH":
|
||||
strGroup = " (LEFT(CONVERT(varchar(100)," + strFiledName + ",112),8)+RIGHT('00'+cast(DATEPART(hh," + strFiledName + ") as VARCHAR),2 ) ) ";
|
||||
strReturn = " (LEFT(CONVERT(varchar(100)," + strFiledName + ",112),8)+RIGHT('00'+cast(DATEPART(hh," + strFiledName + ") as VARCHAR),2 ) ) AS '" + strWDColumCode + "'";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 处理链接字符串废弃
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string concatold(params string[] objs)
|
||||
{
|
||||
string strReturn = "";
|
||||
string strDbType = Appsettings.app("DBType");
|
||||
if (strDbType == "0")
|
||||
{
|
||||
for (int i = 0; i < objs.Length; i++)
|
||||
{
|
||||
strReturn = strReturn + ",";
|
||||
}
|
||||
strReturn = " CONCAT(" + strReturn.TrimEnd(',') + " ) ";
|
||||
}
|
||||
if (strDbType == "1")
|
||||
{
|
||||
for (int i = 0; i < objs.Length; i++)
|
||||
{
|
||||
strReturn = objs[i].ToString() + "+";
|
||||
}
|
||||
strReturn.TrimEnd('+');
|
||||
}
|
||||
|
||||
return strReturn;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
iMES.Bi.Data/iMES.Bi.Data.csproj
Normal file
12
iMES.Bi.Data/iMES.Bi.Data.csproj
Normal file
@@ -0,0 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.211" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
18
iMES.Bi/IRepositories/BiManage/IBi_db_dimRepository.cs
Normal file
18
iMES.Bi/IRepositories/BiManage/IBi_db_dimRepository.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹IBi_db_dimRepository编写接口
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
namespace iMES.Bi.IRepositories
|
||||
{
|
||||
public partial interface IBi_db_dimRepository : IDependency,IRepository<Bi_db_dim>
|
||||
{
|
||||
}
|
||||
}
|
||||
18
iMES.Bi/IRepositories/BiManage/IBi_db_setRepository.cs
Normal file
18
iMES.Bi/IRepositories/BiManage/IBi_db_setRepository.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹IBi_db_setRepository编写接口
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
namespace iMES.Bi.IRepositories
|
||||
{
|
||||
public partial interface IBi_db_setRepository : IDependency,IRepository<Bi_db_set>
|
||||
{
|
||||
}
|
||||
}
|
||||
18
iMES.Bi/IRepositories/BiManage/IBi_db_sourceRepository.cs
Normal file
18
iMES.Bi/IRepositories/BiManage/IBi_db_sourceRepository.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹IBi_db_sourceRepository编写接口
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
namespace iMES.Bi.IRepositories
|
||||
{
|
||||
public partial interface IBi_db_sourceRepository : IDependency,IRepository<Bi_db_source>
|
||||
{
|
||||
}
|
||||
}
|
||||
18
iMES.Bi/IRepositories/BiManage/IBi_db_ybpRepository.cs
Normal file
18
iMES.Bi/IRepositories/BiManage/IBi_db_ybpRepository.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹IBi_db_ybpRepository编写接口
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
namespace iMES.Bi.IRepositories
|
||||
{
|
||||
public partial interface IBi_db_ybpRepository : IDependency,IRepository<Bi_db_ybp>
|
||||
{
|
||||
}
|
||||
}
|
||||
18
iMES.Bi/IRepositories/BiManage/IBi_desktopRepository.cs
Normal file
18
iMES.Bi/IRepositories/BiManage/IBi_desktopRepository.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹IBi_desktopRepository编写接口
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
namespace iMES.Bi.IRepositories
|
||||
{
|
||||
public partial interface IBi_desktopRepository : IDependency,IRepository<Bi_desktop>
|
||||
{
|
||||
}
|
||||
}
|
||||
12
iMES.Bi/IServices/BiManage/IBi_db_dimService.cs
Normal file
12
iMES.Bi/IServices/BiManage/IBi_db_dimService.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Bi.IServices
|
||||
{
|
||||
public partial interface IBi_db_dimService : IService<Bi_db_dim>
|
||||
{
|
||||
}
|
||||
}
|
||||
12
iMES.Bi/IServices/BiManage/IBi_db_setService.cs
Normal file
12
iMES.Bi/IServices/BiManage/IBi_db_setService.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Bi.IServices
|
||||
{
|
||||
public partial interface IBi_db_setService : IService<Bi_db_set>
|
||||
{
|
||||
}
|
||||
}
|
||||
12
iMES.Bi/IServices/BiManage/IBi_db_sourceService.cs
Normal file
12
iMES.Bi/IServices/BiManage/IBi_db_sourceService.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Bi.IServices
|
||||
{
|
||||
public partial interface IBi_db_sourceService : IService<Bi_db_source>
|
||||
{
|
||||
}
|
||||
}
|
||||
12
iMES.Bi/IServices/BiManage/IBi_db_ybpService.cs
Normal file
12
iMES.Bi/IServices/BiManage/IBi_db_ybpService.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Bi.IServices
|
||||
{
|
||||
public partial interface IBi_db_ybpService : IService<Bi_db_ybp>
|
||||
{
|
||||
}
|
||||
}
|
||||
12
iMES.Bi/IServices/BiManage/IBi_desktopService.cs
Normal file
12
iMES.Bi/IServices/BiManage/IBi_desktopService.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Bi.IServices
|
||||
{
|
||||
public partial interface IBi_desktopService : IService<Bi_desktop>
|
||||
{
|
||||
}
|
||||
}
|
||||
13
iMES.Bi/IServices/BiManage/Partial/IBi_db_dimService.cs
Normal file
13
iMES.Bi/IServices/BiManage/Partial/IBi_db_dimService.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
*所有关于Bi_db_dim类的业务代码接口应在此处编写
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Utilities;
|
||||
using System.Linq.Expressions;
|
||||
namespace iMES.Bi.IServices
|
||||
{
|
||||
public partial interface IBi_db_dimService
|
||||
{
|
||||
}
|
||||
}
|
||||
13
iMES.Bi/IServices/BiManage/Partial/IBi_db_setService.cs
Normal file
13
iMES.Bi/IServices/BiManage/Partial/IBi_db_setService.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
*所有关于Bi_db_set类的业务代码接口应在此处编写
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Utilities;
|
||||
using System.Linq.Expressions;
|
||||
namespace iMES.Bi.IServices
|
||||
{
|
||||
public partial interface IBi_db_setService
|
||||
{
|
||||
}
|
||||
}
|
||||
13
iMES.Bi/IServices/BiManage/Partial/IBi_db_sourceService.cs
Normal file
13
iMES.Bi/IServices/BiManage/Partial/IBi_db_sourceService.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
*所有关于Bi_db_source类的业务代码接口应在此处编写
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Utilities;
|
||||
using System.Linq.Expressions;
|
||||
namespace iMES.Bi.IServices
|
||||
{
|
||||
public partial interface IBi_db_sourceService
|
||||
{
|
||||
}
|
||||
}
|
||||
13
iMES.Bi/IServices/BiManage/Partial/IBi_db_ybpService.cs
Normal file
13
iMES.Bi/IServices/BiManage/Partial/IBi_db_ybpService.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
*所有关于Bi_db_ybp类的业务代码接口应在此处编写
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Utilities;
|
||||
using System.Linq.Expressions;
|
||||
namespace iMES.Bi.IServices
|
||||
{
|
||||
public partial interface IBi_db_ybpService
|
||||
{
|
||||
}
|
||||
}
|
||||
13
iMES.Bi/IServices/BiManage/Partial/IBi_desktopService.cs
Normal file
13
iMES.Bi/IServices/BiManage/Partial/IBi_desktopService.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
*所有关于Bi_desktop类的业务代码接口应在此处编写
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Utilities;
|
||||
using System.Linq.Expressions;
|
||||
namespace iMES.Bi.IServices
|
||||
{
|
||||
public partial interface IBi_desktopService
|
||||
{
|
||||
}
|
||||
}
|
||||
24
iMES.Bi/Repositories/BiManage/Bi_db_dimRepository.cs
Normal file
24
iMES.Bi/Repositories/BiManage/Bi_db_dimRepository.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹Bi_db_dimRepository编写代码
|
||||
*/
|
||||
using iMES.Bi.IRepositories;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.EFDbContext;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Bi.Repositories
|
||||
{
|
||||
public partial class Bi_db_dimRepository : RepositoryBase<Bi_db_dim> , IBi_db_dimRepository
|
||||
{
|
||||
public Bi_db_dimRepository(SysDbContext dbContext)
|
||||
: base(dbContext)
|
||||
{
|
||||
|
||||
}
|
||||
public static IBi_db_dimRepository Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<IBi_db_dimRepository>(); } }
|
||||
}
|
||||
}
|
||||
24
iMES.Bi/Repositories/BiManage/Bi_db_setRepository.cs
Normal file
24
iMES.Bi/Repositories/BiManage/Bi_db_setRepository.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹Bi_db_setRepository编写代码
|
||||
*/
|
||||
using iMES.Bi.IRepositories;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.EFDbContext;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Bi.Repositories
|
||||
{
|
||||
public partial class Bi_db_setRepository : RepositoryBase<Bi_db_set> , IBi_db_setRepository
|
||||
{
|
||||
public Bi_db_setRepository(SysDbContext dbContext)
|
||||
: base(dbContext)
|
||||
{
|
||||
|
||||
}
|
||||
public static IBi_db_setRepository Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<IBi_db_setRepository>(); } }
|
||||
}
|
||||
}
|
||||
24
iMES.Bi/Repositories/BiManage/Bi_db_sourceRepository.cs
Normal file
24
iMES.Bi/Repositories/BiManage/Bi_db_sourceRepository.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹Bi_db_sourceRepository编写代码
|
||||
*/
|
||||
using iMES.Bi.IRepositories;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.EFDbContext;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Bi.Repositories
|
||||
{
|
||||
public partial class Bi_db_sourceRepository : RepositoryBase<Bi_db_source> , IBi_db_sourceRepository
|
||||
{
|
||||
public Bi_db_sourceRepository(SysDbContext dbContext)
|
||||
: base(dbContext)
|
||||
{
|
||||
|
||||
}
|
||||
public static IBi_db_sourceRepository Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<IBi_db_sourceRepository>(); } }
|
||||
}
|
||||
}
|
||||
24
iMES.Bi/Repositories/BiManage/Bi_db_ybpRepository.cs
Normal file
24
iMES.Bi/Repositories/BiManage/Bi_db_ybpRepository.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹Bi_db_ybpRepository编写代码
|
||||
*/
|
||||
using iMES.Bi.IRepositories;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.EFDbContext;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Bi.Repositories
|
||||
{
|
||||
public partial class Bi_db_ybpRepository : RepositoryBase<Bi_db_ybp> , IBi_db_ybpRepository
|
||||
{
|
||||
public Bi_db_ybpRepository(SysDbContext dbContext)
|
||||
: base(dbContext)
|
||||
{
|
||||
|
||||
}
|
||||
public static IBi_db_ybpRepository Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<IBi_db_ybpRepository>(); } }
|
||||
}
|
||||
}
|
||||
24
iMES.Bi/Repositories/BiManage/Bi_desktopRepository.cs
Normal file
24
iMES.Bi/Repositories/BiManage/Bi_desktopRepository.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹Bi_desktopRepository编写代码
|
||||
*/
|
||||
using iMES.Bi.IRepositories;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.EFDbContext;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Bi.Repositories
|
||||
{
|
||||
public partial class Bi_desktopRepository : RepositoryBase<Bi_desktop> , IBi_desktopRepository
|
||||
{
|
||||
public Bi_desktopRepository(SysDbContext dbContext)
|
||||
: base(dbContext)
|
||||
{
|
||||
|
||||
}
|
||||
public static IBi_desktopRepository Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<IBi_desktopRepository>(); } }
|
||||
}
|
||||
}
|
||||
26
iMES.Bi/Services/BiManage/Bi_db_dimService.cs
Normal file
26
iMES.Bi/Services/BiManage/Bi_db_dimService.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
*Author:COCO
|
||||
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
|
||||
*所有业务编写全部应在Partial文件夹下Bi_db_dimService与IBi_db_dimService中编写
|
||||
*/
|
||||
using iMES.Bi.IRepositories;
|
||||
using iMES.Bi.IServices;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Bi.Services
|
||||
{
|
||||
public partial class Bi_db_dimService : ServiceBase<Bi_db_dim, IBi_db_dimRepository>
|
||||
, IBi_db_dimService, IDependency
|
||||
{
|
||||
public Bi_db_dimService(IBi_db_dimRepository repository)
|
||||
: base(repository)
|
||||
{
|
||||
Init(repository);
|
||||
}
|
||||
public static IBi_db_dimService Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<IBi_db_dimService>(); } }
|
||||
}
|
||||
}
|
||||
26
iMES.Bi/Services/BiManage/Bi_db_setService.cs
Normal file
26
iMES.Bi/Services/BiManage/Bi_db_setService.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
*Author:COCO
|
||||
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
|
||||
*所有业务编写全部应在Partial文件夹下Bi_db_setService与IBi_db_setService中编写
|
||||
*/
|
||||
using iMES.Bi.IRepositories;
|
||||
using iMES.Bi.IServices;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Bi.Services
|
||||
{
|
||||
public partial class Bi_db_setService : ServiceBase<Bi_db_set, IBi_db_setRepository>
|
||||
, IBi_db_setService, IDependency
|
||||
{
|
||||
public Bi_db_setService(IBi_db_setRepository repository)
|
||||
: base(repository)
|
||||
{
|
||||
Init(repository);
|
||||
}
|
||||
public static IBi_db_setService Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<IBi_db_setService>(); } }
|
||||
}
|
||||
}
|
||||
26
iMES.Bi/Services/BiManage/Bi_db_sourceService.cs
Normal file
26
iMES.Bi/Services/BiManage/Bi_db_sourceService.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
*Author:COCO
|
||||
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
|
||||
*所有业务编写全部应在Partial文件夹下Bi_db_sourceService与IBi_db_sourceService中编写
|
||||
*/
|
||||
using iMES.Bi.IRepositories;
|
||||
using iMES.Bi.IServices;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Bi.Services
|
||||
{
|
||||
public partial class Bi_db_sourceService : ServiceBase<Bi_db_source, IBi_db_sourceRepository>
|
||||
, IBi_db_sourceService, IDependency
|
||||
{
|
||||
public Bi_db_sourceService(IBi_db_sourceRepository repository)
|
||||
: base(repository)
|
||||
{
|
||||
Init(repository);
|
||||
}
|
||||
public static IBi_db_sourceService Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<IBi_db_sourceService>(); } }
|
||||
}
|
||||
}
|
||||
26
iMES.Bi/Services/BiManage/Bi_db_ybpService.cs
Normal file
26
iMES.Bi/Services/BiManage/Bi_db_ybpService.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
*Author:COCO
|
||||
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
|
||||
*所有业务编写全部应在Partial文件夹下Bi_db_ybpService与IBi_db_ybpService中编写
|
||||
*/
|
||||
using iMES.Bi.IRepositories;
|
||||
using iMES.Bi.IServices;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Bi.Services
|
||||
{
|
||||
public partial class Bi_db_ybpService : ServiceBase<Bi_db_ybp, IBi_db_ybpRepository>
|
||||
, IBi_db_ybpService, IDependency
|
||||
{
|
||||
public Bi_db_ybpService(IBi_db_ybpRepository repository)
|
||||
: base(repository)
|
||||
{
|
||||
Init(repository);
|
||||
}
|
||||
public static IBi_db_ybpService Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<IBi_db_ybpService>(); } }
|
||||
}
|
||||
}
|
||||
26
iMES.Bi/Services/BiManage/Bi_desktopService.cs
Normal file
26
iMES.Bi/Services/BiManage/Bi_desktopService.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
*Author:COCO
|
||||
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
|
||||
*所有业务编写全部应在Partial文件夹下Bi_desktopService与IBi_desktopService中编写
|
||||
*/
|
||||
using iMES.Bi.IRepositories;
|
||||
using iMES.Bi.IServices;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Bi.Services
|
||||
{
|
||||
public partial class Bi_desktopService : ServiceBase<Bi_desktop, IBi_desktopRepository>
|
||||
, IBi_desktopService, IDependency
|
||||
{
|
||||
public Bi_desktopService(IBi_desktopRepository repository)
|
||||
: base(repository)
|
||||
{
|
||||
Init(repository);
|
||||
}
|
||||
public static IBi_desktopService Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<IBi_desktopService>(); } }
|
||||
}
|
||||
}
|
||||
41
iMES.Bi/Services/BiManage/Partial/Bi_db_dimService.cs
Normal file
41
iMES.Bi/Services/BiManage/Partial/Bi_db_dimService.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
*所有关于Bi_db_dim类的业务代码应在此处编写
|
||||
*可使用repository.调用常用方法,获取EF/Dapper等信息
|
||||
*如果需要事务请使用repository.DbContextBeginTransaction
|
||||
*也可使用DBServerProvider.手动获取数据库相关信息
|
||||
*用户信息、权限、角色等使用UserContext.Current操作
|
||||
*Bi_db_dimService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
using System.Linq;
|
||||
using iMES.Core.Utilities;
|
||||
using System.Linq.Expressions;
|
||||
using iMES.Core.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using iMES.Bi.IRepositories;
|
||||
|
||||
namespace iMES.Bi.Services
|
||||
{
|
||||
public partial class Bi_db_dimService
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IBi_db_dimRepository _repository;//访问数据库
|
||||
|
||||
[ActivatorUtilitiesConstructor]
|
||||
public Bi_db_dimService(
|
||||
IBi_db_dimRepository dbRepository,
|
||||
IHttpContextAccessor httpContextAccessor
|
||||
)
|
||||
: base(dbRepository)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_repository = dbRepository;
|
||||
//多租户会用到这init代码,其他情况可以不用
|
||||
//base.Init(dbRepository);
|
||||
}
|
||||
}
|
||||
}
|
||||
71
iMES.Bi/Services/BiManage/Partial/Bi_db_setService.cs
Normal file
71
iMES.Bi/Services/BiManage/Partial/Bi_db_setService.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
*所有关于Bi_db_set类的业务代码应在此处编写
|
||||
*可使用repository.调用常用方法,获取EF/Dapper等信息
|
||||
*如果需要事务请使用repository.DbContextBeginTransaction
|
||||
*也可使用DBServerProvider.手动获取数据库相关信息
|
||||
*用户信息、权限、角色等使用UserContext.Current操作
|
||||
*Bi_db_setService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
using System.Linq;
|
||||
using iMES.Core.Utilities;
|
||||
using System.Linq.Expressions;
|
||||
using iMES.Core.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using iMES.Bi.IRepositories;
|
||||
using System;
|
||||
using iMES.Core.ManageUser;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace iMES.Bi.Services
|
||||
{
|
||||
public partial class Bi_db_setService
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IBi_db_setRepository _repository;//访问数据库
|
||||
|
||||
[ActivatorUtilitiesConstructor]
|
||||
public Bi_db_setService(
|
||||
IBi_db_setRepository dbRepository,
|
||||
IHttpContextAccessor httpContextAccessor
|
||||
)
|
||||
: base(dbRepository)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_repository = dbRepository;
|
||||
//多租户会用到这init代码,其他情况可以不用
|
||||
//base.Init(dbRepository);
|
||||
}
|
||||
WebResponseContent webResponse = new WebResponseContent();
|
||||
/// <summary>
|
||||
/// 新建
|
||||
/// </summary>
|
||||
/// <param name="saveDataModel"></param>
|
||||
/// <returns></returns>
|
||||
public override WebResponseContent Add(SaveModel saveDataModel)
|
||||
{
|
||||
//此处saveModel是从前台提交的原生数据,可对数据进修改过滤
|
||||
AddOnExecuting = (Bi_db_set set, object list) =>
|
||||
{
|
||||
set.CRDate = DateTime.Now;
|
||||
set.CRUser = UserContext.Current.UserName;
|
||||
return webResponse.OK();
|
||||
};
|
||||
return base.Add(saveDataModel);
|
||||
}
|
||||
/// <summary>
|
||||
/// 编辑
|
||||
/// </summary>
|
||||
/// <param name="saveDataModel"></param>
|
||||
/// <returns></returns>
|
||||
public override WebResponseContent Update(SaveModel saveDataModel)
|
||||
{
|
||||
saveDataModel.MainData["UPDate"] = DateTime.Now;
|
||||
return base.Update(saveDataModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
41
iMES.Bi/Services/BiManage/Partial/Bi_db_sourceService.cs
Normal file
41
iMES.Bi/Services/BiManage/Partial/Bi_db_sourceService.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
*所有关于Bi_db_source类的业务代码应在此处编写
|
||||
*可使用repository.调用常用方法,获取EF/Dapper等信息
|
||||
*如果需要事务请使用repository.DbContextBeginTransaction
|
||||
*也可使用DBServerProvider.手动获取数据库相关信息
|
||||
*用户信息、权限、角色等使用UserContext.Current操作
|
||||
*Bi_db_sourceService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
using System.Linq;
|
||||
using iMES.Core.Utilities;
|
||||
using System.Linq.Expressions;
|
||||
using iMES.Core.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using iMES.Bi.IRepositories;
|
||||
|
||||
namespace iMES.Bi.Services
|
||||
{
|
||||
public partial class Bi_db_sourceService
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IBi_db_sourceRepository _repository;//访问数据库
|
||||
|
||||
[ActivatorUtilitiesConstructor]
|
||||
public Bi_db_sourceService(
|
||||
IBi_db_sourceRepository dbRepository,
|
||||
IHttpContextAccessor httpContextAccessor
|
||||
)
|
||||
: base(dbRepository)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_repository = dbRepository;
|
||||
//多租户会用到这init代码,其他情况可以不用
|
||||
//base.Init(dbRepository);
|
||||
}
|
||||
}
|
||||
}
|
||||
60
iMES.Bi/Services/BiManage/Partial/Bi_db_ybpService.cs
Normal file
60
iMES.Bi/Services/BiManage/Partial/Bi_db_ybpService.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
*所有关于Bi_db_ybp类的业务代码应在此处编写
|
||||
*可使用repository.调用常用方法,获取EF/Dapper等信息
|
||||
*如果需要事务请使用repository.DbContextBeginTransaction
|
||||
*也可使用DBServerProvider.手动获取数据库相关信息
|
||||
*用户信息、权限、角色等使用UserContext.Current操作
|
||||
*Bi_db_ybpService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
using System.Linq;
|
||||
using iMES.Core.Utilities;
|
||||
using System.Linq.Expressions;
|
||||
using iMES.Core.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using iMES.Bi.IRepositories;
|
||||
using System;
|
||||
using iMES.Core.ManageUser;
|
||||
|
||||
namespace iMES.Bi.Services
|
||||
{
|
||||
public partial class Bi_db_ybpService
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IBi_db_ybpRepository _repository;//访问数据库
|
||||
|
||||
[ActivatorUtilitiesConstructor]
|
||||
public Bi_db_ybpService(
|
||||
IBi_db_ybpRepository dbRepository,
|
||||
IHttpContextAccessor httpContextAccessor
|
||||
)
|
||||
: base(dbRepository)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_repository = dbRepository;
|
||||
//多租户会用到这init代码,其他情况可以不用
|
||||
//base.Init(dbRepository);
|
||||
}
|
||||
WebResponseContent webResponse = new WebResponseContent();
|
||||
/// <summary>
|
||||
/// 新建
|
||||
/// </summary>
|
||||
/// <param name="saveDataModel"></param>
|
||||
/// <returns></returns>
|
||||
public override WebResponseContent Add(SaveModel saveDataModel)
|
||||
{
|
||||
//此处saveModel是从前台提交的原生数据,可对数据进修改过滤
|
||||
AddOnExecuting = (Bi_db_ybp ybp, object list) =>
|
||||
{
|
||||
ybp.CRDate = DateTime.Now;
|
||||
ybp.CRUser = UserContext.Current.UserName;
|
||||
return webResponse.OK();
|
||||
};
|
||||
return base.Add(saveDataModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
41
iMES.Bi/Services/BiManage/Partial/Bi_desktopService.cs
Normal file
41
iMES.Bi/Services/BiManage/Partial/Bi_desktopService.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
*所有关于Bi_desktop类的业务代码应在此处编写
|
||||
*可使用repository.调用常用方法,获取EF/Dapper等信息
|
||||
*如果需要事务请使用repository.DbContextBeginTransaction
|
||||
*也可使用DBServerProvider.手动获取数据库相关信息
|
||||
*用户信息、权限、角色等使用UserContext.Current操作
|
||||
*Bi_desktopService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
using System.Linq;
|
||||
using iMES.Core.Utilities;
|
||||
using System.Linq.Expressions;
|
||||
using iMES.Core.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using iMES.Bi.IRepositories;
|
||||
|
||||
namespace iMES.Bi.Services
|
||||
{
|
||||
public partial class Bi_desktopService
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IBi_desktopRepository _repository;//访问数据库
|
||||
|
||||
[ActivatorUtilitiesConstructor]
|
||||
public Bi_desktopService(
|
||||
IBi_desktopRepository dbRepository,
|
||||
IHttpContextAccessor httpContextAccessor
|
||||
)
|
||||
: base(dbRepository)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_repository = dbRepository;
|
||||
//多租户会用到这init代码,其他情况可以不用
|
||||
//base.Init(dbRepository);
|
||||
}
|
||||
}
|
||||
}
|
||||
13
iMES.Bi/iMES.Bi.csproj
Normal file
13
iMES.Bi/iMES.Bi.csproj
Normal file
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\iMES.Core\iMES.Core.csproj" />
|
||||
<ProjectReference Include="..\iMES.Custom\iMES.Custom.csproj" />
|
||||
<ProjectReference Include="..\iMES.Entity\iMES.Entity.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
15
iMES.Builder/IRepositories/Core/ISys_TableInfoRepository.cs
Normal file
15
iMES.Builder/IRepositories/Core/ISys_TableInfoRepository.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
namespace iMES.Builder.IRepositories
|
||||
{
|
||||
public partial interface ISys_TableInfoRepository : IDependency,IRepository<Sys_TableInfo>
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
10
iMES.Builder/IServices/Core/ISys_TableInfoService.cs
Normal file
10
iMES.Builder/IServices/Core/ISys_TableInfoService.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Builder.IServices
|
||||
{
|
||||
public partial interface ISys_TableInfoService : IService<Sys_TableInfo>
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
26
iMES.Builder/IServices/Core/Partial/ISys_TableInfoService.cs
Normal file
26
iMES.Builder/IServices/Core/Partial/ISys_TableInfoService.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using iMES.Core.Utilities;
|
||||
|
||||
namespace iMES.Builder.IServices
|
||||
{
|
||||
public partial interface ISys_TableInfoService
|
||||
{
|
||||
Task<(string, string)> GetTableTree();
|
||||
|
||||
string CreateEntityModel(Sys_TableInfo tableInfo);
|
||||
|
||||
WebResponseContent SaveEidt(Sys_TableInfo sysTableInfo);
|
||||
|
||||
string CreateServices(string tableName, string nameSpace, string foldername, bool webController, bool apiController);
|
||||
|
||||
|
||||
string CreateVuePage(Sys_TableInfo sysTableInfo, string vuePath);
|
||||
|
||||
object LoadTable(int parentId, string tableName, string columnCNName, string nameSpace, string foldername, int table_Id, bool isTreeLoad,string dbServer);
|
||||
Task<WebResponseContent> SyncTable(string tableName);
|
||||
Task<WebResponseContent> DelTree(int table_Id);
|
||||
}
|
||||
}
|
||||
27
iMES.Builder/Properties/launchSettings.json
Normal file
27
iMES.Builder/Properties/launchSettings.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:34188/",
|
||||
"sslPort": 44309
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"iMES.Builder": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000"
|
||||
}
|
||||
}
|
||||
}
|
||||
22
iMES.Builder/Repositories/Core/Sys_TableInfoRepository.cs
Normal file
22
iMES.Builder/Repositories/Core/Sys_TableInfoRepository.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using iMES.Builder.IRepositories;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.EFDbContext;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Builder.Repositories
|
||||
{
|
||||
public partial class Sys_TableInfoRepository : RepositoryBase<Sys_TableInfo>, ISys_TableInfoRepository
|
||||
{
|
||||
public Sys_TableInfoRepository(SysDbContext dbContext)
|
||||
: base(dbContext)
|
||||
{
|
||||
|
||||
}
|
||||
public static ISys_TableInfoRepository GetService
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<ISys_TableInfoRepository>(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2008
iMES.Builder/Services/Core/Partial/Sys_TableInfoService.cs
Normal file
2008
iMES.Builder/Services/Core/Partial/Sys_TableInfoService.cs
Normal file
File diff suppressed because it is too large
Load Diff
22
iMES.Builder/Services/Core/Sys_TableInfoService.cs
Normal file
22
iMES.Builder/Services/Core/Sys_TableInfoService.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using iMES.Builder.IRepositories;
|
||||
using iMES.Builder.IServices;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Builder.Services
|
||||
{
|
||||
public partial class Sys_TableInfoService : ServiceBase<Sys_TableInfo, ISys_TableInfoRepository>, ISys_TableInfoService, IDependency
|
||||
{
|
||||
public Sys_TableInfoService(ISys_TableInfoRepository repository)
|
||||
: base(repository)
|
||||
{
|
||||
Init(repository);
|
||||
}
|
||||
public static ISys_TableInfoService Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<ISys_TableInfoService>(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
93
iMES.Builder/Utility/ProjectPath.cs
Normal file
93
iMES.Builder/Utility/ProjectPath.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using iMES.Core.Extensions;
|
||||
|
||||
namespace iMES.Builder.Utility
|
||||
{
|
||||
public class ProjectPath
|
||||
{
|
||||
// private int findCount = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 获取web父目录所在位置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static DirectoryInfo GetProjectDirectoryInfo()
|
||||
{
|
||||
return GetProjectDirectoryInfo(new DirectoryInfo("".MapPath()), 1);
|
||||
}
|
||||
public static string GetProjectFileName(string startsWith)
|
||||
{
|
||||
string fileNames = GetProjectDirectoryInfo()?.GetDirectories()
|
||||
.Where(
|
||||
c =>
|
||||
//c.Name.StartsWith(startsWith)&&
|
||||
c.Name != startsWith + ".Core"
|
||||
&& c.Name != startsWith + ".Entity"
|
||||
&& !c.Name.ToLower().EndsWith(".web")
|
||||
&& !c.Name.ToLower().EndsWith(".webapi")
|
||||
&& !c.Name.ToLower().EndsWith(".builder")
|
||||
&& c.Name.ToLower()!=".vs"
|
||||
).Select(x => x.Name).ToList().Serialize();
|
||||
if (string.IsNullOrEmpty(fileNames))
|
||||
{
|
||||
fileNames = new DirectoryInfo("".MapPath()).GetFiles().Where(x => x.Name.EndsWith(".dll")
|
||||
//&& x.Name.StartsWith(startsWith)
|
||||
&& !x.Name.EndsWith(".Core.dll")
|
||||
&& !x.Name.EndsWith(".Entity.dll")
|
||||
&& !x.Name.EndsWith(".Builder.dll")
|
||||
&& !x.Name.ToLower().EndsWith(".web")
|
||||
&& !x.Name.ToLower().EndsWith(".webapi")
|
||||
&& !x.Name.ToLower().EndsWith(".builder")
|
||||
).Select(x => x.Name.Replace(".dll", "")).ToList().Serialize();
|
||||
}
|
||||
return fileNames ?? "''";
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取指定结尾的项目名称
|
||||
/// </summary>
|
||||
/// <param name="lastIndexOfName"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetLastIndexOfDirectoryName(string lastIndexOfName)
|
||||
{
|
||||
string projectName = GetProjectDirectoryInfo()?.GetDirectories()
|
||||
.Where(c => c.Name.LastIndexOf(lastIndexOfName) != -1).Select(x => x.Name).FirstOrDefault();
|
||||
if (string.IsNullOrEmpty(projectName))
|
||||
{
|
||||
projectName = new DirectoryInfo("".MapPath()).GetFiles().Where(x => x.Name.LastIndexOf(lastIndexOfName + ".dll") != -1).FirstOrDefault().Name;
|
||||
if (!string.IsNullOrEmpty(projectName))
|
||||
{
|
||||
projectName = projectName.Replace(".dll", "");
|
||||
}
|
||||
}
|
||||
return projectName;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取项目所在路径
|
||||
/// </summary>
|
||||
/// <param name="directoryInfo"></param>
|
||||
/// <returns></returns>
|
||||
private static DirectoryInfo GetProjectDirectoryInfo(DirectoryInfo directoryInfo, int findCount)
|
||||
{
|
||||
if (directoryInfo == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (directoryInfo.Exists
|
||||
&& directoryInfo.GetDirectories().Where(x => x.Name.LastIndexOf(".Web") != -1).FirstOrDefault() != null)
|
||||
{
|
||||
return directoryInfo;
|
||||
}
|
||||
if (findCount < 7)
|
||||
{
|
||||
findCount++;
|
||||
DirectoryInfo dir = GetProjectDirectoryInfo(directoryInfo.Parent, findCount);
|
||||
if (dir != null)
|
||||
{
|
||||
return dir;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
32
iMES.Builder/iMES.Builder.csproj
Normal file
32
iMES.Builder/iMES.Builder.csproj
Normal file
@@ -0,0 +1,32 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup Label="Globals">
|
||||
<SccProjectName></SccProjectName>
|
||||
<SccProvider></SccProvider>
|
||||
<SccAuxPath></SccAuxPath>
|
||||
<SccLocalPath></SccLocalPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ApplicationIcon />
|
||||
<OutputType>Library</OutputType>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="6.2.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\iMES.Core\iMES.Core.csproj" />
|
||||
<ProjectReference Include="..\iMES.Entity\iMES.Entity.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹ICal_HolidayRepository编写接口
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
namespace iMES.Calendar.IRepositories
|
||||
{
|
||||
public partial interface ICal_HolidayRepository : IDependency,IRepository<Cal_Holiday>
|
||||
{
|
||||
}
|
||||
}
|
||||
18
iMES.Calendar/IRepositories/Calendar/ICal_PlanRepository.cs
Normal file
18
iMES.Calendar/IRepositories/Calendar/ICal_PlanRepository.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹ICal_PlanRepository编写接口
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
namespace iMES.Calendar.IRepositories
|
||||
{
|
||||
public partial interface ICal_PlanRepository : IDependency,IRepository<Cal_Plan>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹ICal_PlanShiftRepository编写接口
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
namespace iMES.Calendar.IRepositories
|
||||
{
|
||||
public partial interface ICal_PlanShiftRepository : IDependency,IRepository<Cal_PlanShift>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹ICal_PlanTeamRepository编写接口
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
namespace iMES.Calendar.IRepositories
|
||||
{
|
||||
public partial interface ICal_PlanTeamRepository : IDependency,IRepository<Cal_PlanTeam>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹ICal_TeamMemberRepository编写接口
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
namespace iMES.Calendar.IRepositories
|
||||
{
|
||||
public partial interface ICal_TeamMemberRepository : IDependency,IRepository<Cal_TeamMember>
|
||||
{
|
||||
}
|
||||
}
|
||||
18
iMES.Calendar/IRepositories/Calendar/ICal_TeamRepository.cs
Normal file
18
iMES.Calendar/IRepositories/Calendar/ICal_TeamRepository.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹ICal_TeamRepository编写接口
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
namespace iMES.Calendar.IRepositories
|
||||
{
|
||||
public partial interface ICal_TeamRepository : IDependency,IRepository<Cal_Team>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹ICal_TeamShiftRepository编写接口
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
namespace iMES.Calendar.IRepositories
|
||||
{
|
||||
public partial interface ICal_TeamShiftRepository : IDependency,IRepository<Cal_TeamShift>
|
||||
{
|
||||
}
|
||||
}
|
||||
12
iMES.Calendar/IServices/Calendar/ICal_HolidayService.cs
Normal file
12
iMES.Calendar/IServices/Calendar/ICal_HolidayService.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.IServices
|
||||
{
|
||||
public partial interface ICal_HolidayService : IService<Cal_Holiday>
|
||||
{
|
||||
}
|
||||
}
|
||||
12
iMES.Calendar/IServices/Calendar/ICal_PlanService.cs
Normal file
12
iMES.Calendar/IServices/Calendar/ICal_PlanService.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.IServices
|
||||
{
|
||||
public partial interface ICal_PlanService : IService<Cal_Plan>
|
||||
{
|
||||
}
|
||||
}
|
||||
12
iMES.Calendar/IServices/Calendar/ICal_PlanShiftService.cs
Normal file
12
iMES.Calendar/IServices/Calendar/ICal_PlanShiftService.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.IServices
|
||||
{
|
||||
public partial interface ICal_PlanShiftService : IService<Cal_PlanShift>
|
||||
{
|
||||
}
|
||||
}
|
||||
12
iMES.Calendar/IServices/Calendar/ICal_PlanTeamService.cs
Normal file
12
iMES.Calendar/IServices/Calendar/ICal_PlanTeamService.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.IServices
|
||||
{
|
||||
public partial interface ICal_PlanTeamService : IService<Cal_PlanTeam>
|
||||
{
|
||||
}
|
||||
}
|
||||
12
iMES.Calendar/IServices/Calendar/ICal_TeamMemberService.cs
Normal file
12
iMES.Calendar/IServices/Calendar/ICal_TeamMemberService.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.IServices
|
||||
{
|
||||
public partial interface ICal_TeamMemberService : IService<Cal_TeamMember>
|
||||
{
|
||||
}
|
||||
}
|
||||
12
iMES.Calendar/IServices/Calendar/ICal_TeamService.cs
Normal file
12
iMES.Calendar/IServices/Calendar/ICal_TeamService.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.IServices
|
||||
{
|
||||
public partial interface ICal_TeamService : IService<Cal_Team>
|
||||
{
|
||||
}
|
||||
}
|
||||
12
iMES.Calendar/IServices/Calendar/ICal_TeamShiftService.cs
Normal file
12
iMES.Calendar/IServices/Calendar/ICal_TeamShiftService.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.IServices
|
||||
{
|
||||
public partial interface ICal_TeamShiftService : IService<Cal_TeamShift>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
*所有关于Cal_Holiday类的业务代码接口应在此处编写
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Utilities;
|
||||
using System.Linq.Expressions;
|
||||
namespace iMES.Calendar.IServices
|
||||
{
|
||||
public partial interface ICal_HolidayService
|
||||
{
|
||||
}
|
||||
}
|
||||
27
iMES.Calendar/IServices/Calendar/Partial/ICal_PlanService.cs
Normal file
27
iMES.Calendar/IServices/Calendar/Partial/ICal_PlanService.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
*所有关于Cal_Plan类的业务代码接口应在此处编写
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Utilities;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace iMES.Calendar.IServices
|
||||
{
|
||||
public partial interface ICal_PlanService
|
||||
{
|
||||
/// 获取table1的数据
|
||||
/// </summary>
|
||||
/// <param name="loadData"></param>
|
||||
/// <returns></returns>
|
||||
Task<object> GetTable1Data(PageDataOptions loadData);
|
||||
|
||||
/// <summary>
|
||||
/// 获取table2的数据
|
||||
/// </summary>
|
||||
/// <param name="loadData"></param>
|
||||
/// <returns></returns>
|
||||
Task<object> GetTable2Data(PageDataOptions loadData);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
*所有关于Cal_PlanShift类的业务代码接口应在此处编写
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Utilities;
|
||||
using System.Linq.Expressions;
|
||||
namespace iMES.Calendar.IServices
|
||||
{
|
||||
public partial interface ICal_PlanShiftService
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
*所有关于Cal_PlanTeam类的业务代码接口应在此处编写
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Utilities;
|
||||
using System.Linq.Expressions;
|
||||
namespace iMES.Calendar.IServices
|
||||
{
|
||||
public partial interface ICal_PlanTeamService
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
*所有关于Cal_TeamMember类的业务代码接口应在此处编写
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Utilities;
|
||||
using System.Linq.Expressions;
|
||||
namespace iMES.Calendar.IServices
|
||||
{
|
||||
public partial interface ICal_TeamMemberService
|
||||
{
|
||||
}
|
||||
}
|
||||
13
iMES.Calendar/IServices/Calendar/Partial/ICal_TeamService.cs
Normal file
13
iMES.Calendar/IServices/Calendar/Partial/ICal_TeamService.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
*所有关于Cal_Team类的业务代码接口应在此处编写
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Utilities;
|
||||
using System.Linq.Expressions;
|
||||
namespace iMES.Calendar.IServices
|
||||
{
|
||||
public partial interface ICal_TeamService
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
*所有关于Cal_TeamShift类的业务代码接口应在此处编写
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Entity.DomainModels;
|
||||
using iMES.Core.Utilities;
|
||||
using System.Linq.Expressions;
|
||||
namespace iMES.Calendar.IServices
|
||||
{
|
||||
public partial interface ICal_TeamShiftService
|
||||
{
|
||||
}
|
||||
}
|
||||
24
iMES.Calendar/Repositories/Calendar/Cal_HolidayRepository.cs
Normal file
24
iMES.Calendar/Repositories/Calendar/Cal_HolidayRepository.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹Cal_HolidayRepository编写代码
|
||||
*/
|
||||
using iMES.Calendar.IRepositories;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.EFDbContext;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.Repositories
|
||||
{
|
||||
public partial class Cal_HolidayRepository : RepositoryBase<Cal_Holiday> , ICal_HolidayRepository
|
||||
{
|
||||
public Cal_HolidayRepository(SysDbContext dbContext)
|
||||
: base(dbContext)
|
||||
{
|
||||
|
||||
}
|
||||
public static ICal_HolidayRepository Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<ICal_HolidayRepository>(); } }
|
||||
}
|
||||
}
|
||||
24
iMES.Calendar/Repositories/Calendar/Cal_PlanRepository.cs
Normal file
24
iMES.Calendar/Repositories/Calendar/Cal_PlanRepository.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹Cal_PlanRepository编写代码
|
||||
*/
|
||||
using iMES.Calendar.IRepositories;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.EFDbContext;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.Repositories
|
||||
{
|
||||
public partial class Cal_PlanRepository : RepositoryBase<Cal_Plan> , ICal_PlanRepository
|
||||
{
|
||||
public Cal_PlanRepository(SysDbContext dbContext)
|
||||
: base(dbContext)
|
||||
{
|
||||
|
||||
}
|
||||
public static ICal_PlanRepository Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<ICal_PlanRepository>(); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹Cal_PlanShiftRepository编写代码
|
||||
*/
|
||||
using iMES.Calendar.IRepositories;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.EFDbContext;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.Repositories
|
||||
{
|
||||
public partial class Cal_PlanShiftRepository : RepositoryBase<Cal_PlanShift> , ICal_PlanShiftRepository
|
||||
{
|
||||
public Cal_PlanShiftRepository(SysDbContext dbContext)
|
||||
: base(dbContext)
|
||||
{
|
||||
|
||||
}
|
||||
public static ICal_PlanShiftRepository Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<ICal_PlanShiftRepository>(); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹Cal_PlanTeamRepository编写代码
|
||||
*/
|
||||
using iMES.Calendar.IRepositories;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.EFDbContext;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.Repositories
|
||||
{
|
||||
public partial class Cal_PlanTeamRepository : RepositoryBase<Cal_PlanTeam> , ICal_PlanTeamRepository
|
||||
{
|
||||
public Cal_PlanTeamRepository(SysDbContext dbContext)
|
||||
: base(dbContext)
|
||||
{
|
||||
|
||||
}
|
||||
public static ICal_PlanTeamRepository Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<ICal_PlanTeamRepository>(); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹Cal_TeamMemberRepository编写代码
|
||||
*/
|
||||
using iMES.Calendar.IRepositories;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.EFDbContext;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.Repositories
|
||||
{
|
||||
public partial class Cal_TeamMemberRepository : RepositoryBase<Cal_TeamMember> , ICal_TeamMemberRepository
|
||||
{
|
||||
public Cal_TeamMemberRepository(SysDbContext dbContext)
|
||||
: base(dbContext)
|
||||
{
|
||||
|
||||
}
|
||||
public static ICal_TeamMemberRepository Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<ICal_TeamMemberRepository>(); } }
|
||||
}
|
||||
}
|
||||
24
iMES.Calendar/Repositories/Calendar/Cal_TeamRepository.cs
Normal file
24
iMES.Calendar/Repositories/Calendar/Cal_TeamRepository.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹Cal_TeamRepository编写代码
|
||||
*/
|
||||
using iMES.Calendar.IRepositories;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.EFDbContext;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.Repositories
|
||||
{
|
||||
public partial class Cal_TeamRepository : RepositoryBase<Cal_Team> , ICal_TeamRepository
|
||||
{
|
||||
public Cal_TeamRepository(SysDbContext dbContext)
|
||||
: base(dbContext)
|
||||
{
|
||||
|
||||
}
|
||||
public static ICal_TeamRepository Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<ICal_TeamRepository>(); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
|
||||
*Repository提供数据库操作,如果要增加数据库操作请在当前目录下Partial文件夹Cal_TeamShiftRepository编写代码
|
||||
*/
|
||||
using iMES.Calendar.IRepositories;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.EFDbContext;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.Repositories
|
||||
{
|
||||
public partial class Cal_TeamShiftRepository : RepositoryBase<Cal_TeamShift> , ICal_TeamShiftRepository
|
||||
{
|
||||
public Cal_TeamShiftRepository(SysDbContext dbContext)
|
||||
: base(dbContext)
|
||||
{
|
||||
|
||||
}
|
||||
public static ICal_TeamShiftRepository Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<ICal_TeamShiftRepository>(); } }
|
||||
}
|
||||
}
|
||||
26
iMES.Calendar/Services/Calendar/Cal_HolidayService.cs
Normal file
26
iMES.Calendar/Services/Calendar/Cal_HolidayService.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
*Author:COCO
|
||||
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
|
||||
*所有业务编写全部应在Partial文件夹下Cal_HolidayService与ICal_HolidayService中编写
|
||||
*/
|
||||
using iMES.Calendar.IRepositories;
|
||||
using iMES.Calendar.IServices;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.Services
|
||||
{
|
||||
public partial class Cal_HolidayService : ServiceBase<Cal_Holiday, ICal_HolidayRepository>
|
||||
, ICal_HolidayService, IDependency
|
||||
{
|
||||
public Cal_HolidayService(ICal_HolidayRepository repository)
|
||||
: base(repository)
|
||||
{
|
||||
Init(repository);
|
||||
}
|
||||
public static ICal_HolidayService Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<ICal_HolidayService>(); } }
|
||||
}
|
||||
}
|
||||
26
iMES.Calendar/Services/Calendar/Cal_PlanService.cs
Normal file
26
iMES.Calendar/Services/Calendar/Cal_PlanService.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
*Author:COCO
|
||||
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
|
||||
*所有业务编写全部应在Partial文件夹下Cal_PlanService与ICal_PlanService中编写
|
||||
*/
|
||||
using iMES.Calendar.IRepositories;
|
||||
using iMES.Calendar.IServices;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.Services
|
||||
{
|
||||
public partial class Cal_PlanService : ServiceBase<Cal_Plan, ICal_PlanRepository>
|
||||
, ICal_PlanService, IDependency
|
||||
{
|
||||
public Cal_PlanService(ICal_PlanRepository repository)
|
||||
: base(repository)
|
||||
{
|
||||
Init(repository);
|
||||
}
|
||||
public static ICal_PlanService Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<ICal_PlanService>(); } }
|
||||
}
|
||||
}
|
||||
26
iMES.Calendar/Services/Calendar/Cal_PlanShiftService.cs
Normal file
26
iMES.Calendar/Services/Calendar/Cal_PlanShiftService.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
*Author:COCO
|
||||
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
|
||||
*所有业务编写全部应在Partial文件夹下Cal_PlanShiftService与ICal_PlanShiftService中编写
|
||||
*/
|
||||
using iMES.Calendar.IRepositories;
|
||||
using iMES.Calendar.IServices;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.Services
|
||||
{
|
||||
public partial class Cal_PlanShiftService : ServiceBase<Cal_PlanShift, ICal_PlanShiftRepository>
|
||||
, ICal_PlanShiftService, IDependency
|
||||
{
|
||||
public Cal_PlanShiftService(ICal_PlanShiftRepository repository)
|
||||
: base(repository)
|
||||
{
|
||||
Init(repository);
|
||||
}
|
||||
public static ICal_PlanShiftService Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<ICal_PlanShiftService>(); } }
|
||||
}
|
||||
}
|
||||
26
iMES.Calendar/Services/Calendar/Cal_PlanTeamService.cs
Normal file
26
iMES.Calendar/Services/Calendar/Cal_PlanTeamService.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
*Author:COCO
|
||||
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
|
||||
*所有业务编写全部应在Partial文件夹下Cal_PlanTeamService与ICal_PlanTeamService中编写
|
||||
*/
|
||||
using iMES.Calendar.IRepositories;
|
||||
using iMES.Calendar.IServices;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.Services
|
||||
{
|
||||
public partial class Cal_PlanTeamService : ServiceBase<Cal_PlanTeam, ICal_PlanTeamRepository>
|
||||
, ICal_PlanTeamService, IDependency
|
||||
{
|
||||
public Cal_PlanTeamService(ICal_PlanTeamRepository repository)
|
||||
: base(repository)
|
||||
{
|
||||
Init(repository);
|
||||
}
|
||||
public static ICal_PlanTeamService Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<ICal_PlanTeamService>(); } }
|
||||
}
|
||||
}
|
||||
26
iMES.Calendar/Services/Calendar/Cal_TeamMemberService.cs
Normal file
26
iMES.Calendar/Services/Calendar/Cal_TeamMemberService.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
*Author:COCO
|
||||
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
|
||||
*所有业务编写全部应在Partial文件夹下Cal_TeamMemberService与ICal_TeamMemberService中编写
|
||||
*/
|
||||
using iMES.Calendar.IRepositories;
|
||||
using iMES.Calendar.IServices;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.Services
|
||||
{
|
||||
public partial class Cal_TeamMemberService : ServiceBase<Cal_TeamMember, ICal_TeamMemberRepository>
|
||||
, ICal_TeamMemberService, IDependency
|
||||
{
|
||||
public Cal_TeamMemberService(ICal_TeamMemberRepository repository)
|
||||
: base(repository)
|
||||
{
|
||||
Init(repository);
|
||||
}
|
||||
public static ICal_TeamMemberService Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<ICal_TeamMemberService>(); } }
|
||||
}
|
||||
}
|
||||
26
iMES.Calendar/Services/Calendar/Cal_TeamService.cs
Normal file
26
iMES.Calendar/Services/Calendar/Cal_TeamService.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
*Author:COCO
|
||||
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
|
||||
*所有业务编写全部应在Partial文件夹下Cal_TeamService与ICal_TeamService中编写
|
||||
*/
|
||||
using iMES.Calendar.IRepositories;
|
||||
using iMES.Calendar.IServices;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.Services
|
||||
{
|
||||
public partial class Cal_TeamService : ServiceBase<Cal_Team, ICal_TeamRepository>
|
||||
, ICal_TeamService, IDependency
|
||||
{
|
||||
public Cal_TeamService(ICal_TeamRepository repository)
|
||||
: base(repository)
|
||||
{
|
||||
Init(repository);
|
||||
}
|
||||
public static ICal_TeamService Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<ICal_TeamService>(); } }
|
||||
}
|
||||
}
|
||||
26
iMES.Calendar/Services/Calendar/Cal_TeamShiftService.cs
Normal file
26
iMES.Calendar/Services/Calendar/Cal_TeamShiftService.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
*Author:COCO
|
||||
*代码由框架生成,此处任何更改都可能导致被代码生成器覆盖
|
||||
*所有业务编写全部应在Partial文件夹下Cal_TeamShiftService与ICal_TeamShiftService中编写
|
||||
*/
|
||||
using iMES.Calendar.IRepositories;
|
||||
using iMES.Calendar.IServices;
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
|
||||
namespace iMES.Calendar.Services
|
||||
{
|
||||
public partial class Cal_TeamShiftService : ServiceBase<Cal_TeamShift, ICal_TeamShiftRepository>
|
||||
, ICal_TeamShiftService, IDependency
|
||||
{
|
||||
public Cal_TeamShiftService(ICal_TeamShiftRepository repository)
|
||||
: base(repository)
|
||||
{
|
||||
Init(repository);
|
||||
}
|
||||
public static ICal_TeamShiftService Instance
|
||||
{
|
||||
get { return AutofacContainerModule.GetService<ICal_TeamShiftService>(); } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
*所有关于Cal_Holiday类的业务代码应在此处编写
|
||||
*可使用repository.调用常用方法,获取EF/Dapper等信息
|
||||
*如果需要事务请使用repository.DbContextBeginTransaction
|
||||
*也可使用DBServerProvider.手动获取数据库相关信息
|
||||
*用户信息、权限、角色等使用UserContext.Current操作
|
||||
*Cal_HolidayService对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
|
||||
*/
|
||||
using iMES.Core.BaseProvider;
|
||||
using iMES.Core.Extensions.AutofacManager;
|
||||
using iMES.Entity.DomainModels;
|
||||
using System.Linq;
|
||||
using iMES.Core.Utilities;
|
||||
using System.Linq.Expressions;
|
||||
using iMES.Core.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using iMES.Calendar.IRepositories;
|
||||
|
||||
namespace iMES.Calendar.Services
|
||||
{
|
||||
public partial class Cal_HolidayService
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly ICal_HolidayRepository _repository;//访问数据库
|
||||
|
||||
[ActivatorUtilitiesConstructor]
|
||||
public Cal_HolidayService(
|
||||
ICal_HolidayRepository dbRepository,
|
||||
IHttpContextAccessor httpContextAccessor
|
||||
)
|
||||
: base(dbRepository)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_repository = dbRepository;
|
||||
//多租户会用到这init代码,其他情况可以不用
|
||||
//base.Init(dbRepository);
|
||||
}
|
||||
WebResponseContent _webResponse = new WebResponseContent();
|
||||
/// <summary>
|
||||
/// 新建
|
||||
/// </summary>
|
||||
/// <param name="saveDataModel"></param>
|
||||
/// <returns></returns>
|
||||
public override WebResponseContent Add(SaveModel saveDataModel)
|
||||
{
|
||||
//此处saveModel是从前台提交的原生数据,可对数据进修改过滤
|
||||
AddOnExecuting = (Cal_Holiday ho, object list) =>
|
||||
{
|
||||
//如果返回false,后面代码不会再执行
|
||||
if (repository.Exists(x => x.TheDay == ho.TheDay))
|
||||
{
|
||||
Cal_Holiday calho = repository.FindAsIQueryable(x => x.TheDay == ho.TheDay)
|
||||
.OrderByDescending(x => x.CreateDate)
|
||||
.FirstOrDefault();
|
||||
calho.HolidayType = ho.HolidayType;
|
||||
repository.Update(calho, x => new { x.HolidayType }, true);
|
||||
}
|
||||
return _webResponse.OK();
|
||||
};
|
||||
return base.Add(saveDataModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user