init commit
This commit is contained in:
77
20220330_Vote/Ewide.RoadFlow/Data/AppLibary/AppLibrary.cs
Normal file
77
20220330_Vote/Ewide.RoadFlow/Data/AppLibary/AppLibrary.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using Furion.DependencyInjection;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class Applibrary:RoadFlowRepository<RoadFlow.Model.rf_applibrary>,IApplibrary, ITransient
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 根据Code得到实体
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
public Model.rf_applibrary GetByCode(string code)
|
||||
{
|
||||
List<Model.rf_applibrary> appLibraries = GetAll();
|
||||
return appLibraries.Find(p => p.Code.EqualsIgnoreCase(code));
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除应用
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public int Delete(string id)
|
||||
{
|
||||
var app = GetOneById(id);
|
||||
return null == app ? 0 : Delete(app);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到对应语言的标题
|
||||
/// </summary>
|
||||
/// <param name="appLibrary"></param>
|
||||
/// <param name="language">语言</param>
|
||||
/// <returns></returns>
|
||||
public string GetLanguageTitle(Model.rf_applibrary appLibrary, string language = "")
|
||||
{
|
||||
if (null == appLibrary)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
string lang = language.IsNullOrWhiteSpace() ? Tools.GetCurrentLanguage() : language;
|
||||
switch (lang)
|
||||
{
|
||||
case "en-US":
|
||||
return appLibrary.Title_en;
|
||||
case "zh":
|
||||
return appLibrary.Title_zh;
|
||||
default:
|
||||
return appLibrary.Title;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个类别的应用
|
||||
/// </summary>
|
||||
/// <param name="typeId">类别ID</param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_applibrary> GetListByType(string typeId)
|
||||
{
|
||||
List<Model.rf_applibrary> appLibraries = new List<Model.rf_applibrary>();
|
||||
var all = GetAll();
|
||||
var typeIds = new Dictionary().GetAllChildsId(typeId);
|
||||
foreach (var id in typeIds)
|
||||
{
|
||||
appLibraries.AddRange(all.FindAll(p => p.Type == id));
|
||||
}
|
||||
return appLibraries.OrderBy(p => p.Title).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
41
20220330_Vote/Ewide.RoadFlow/Data/AppLibary/IApplibrary.cs
Normal file
41
20220330_Vote/Ewide.RoadFlow/Data/AppLibary/IApplibrary.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IApplibrary : IRoadFlowRepository<RoadFlow.Model.rf_applibrary>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 根据Code得到实体
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
public Model.rf_applibrary GetByCode(string code);
|
||||
/// <summary>
|
||||
/// 删除应用
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public int Delete(string id);
|
||||
|
||||
/// <summary>
|
||||
/// 得到对应语言的标题
|
||||
/// </summary>
|
||||
/// <param name="appLibrary"></param>
|
||||
/// <param name="language">语言</param>
|
||||
/// <returns></returns>
|
||||
public string GetLanguageTitle(Model.rf_applibrary appLibrary, string language = "");
|
||||
/// <summary>
|
||||
/// 得到一个类别的应用
|
||||
/// </summary>
|
||||
/// <param name="typeId">类别ID</param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_applibrary> GetListByType(string typeId);
|
||||
}
|
||||
|
||||
}
|
||||
702
20220330_Vote/Ewide.RoadFlow/Data/DbConnection/DbConnection.cs
Normal file
702
20220330_Vote/Ewide.RoadFlow/Data/DbConnection/DbConnection.cs
Normal file
@@ -0,0 +1,702 @@
|
||||
using Furion.DependencyInjection;
|
||||
using Furion.FriendlyException;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using MySql.Data.MySqlClient;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class DbConnection:RoadFlowRepository<RoadFlow.Model.rf_dbconnection>,IDbConnection, ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 添加一个连接
|
||||
/// </summary>
|
||||
/// <param name="dbConnection">连接实体</param>
|
||||
/// <returns></returns>
|
||||
public override int Add(Model.rf_dbconnection dbConnection)
|
||||
{
|
||||
ClearCache();
|
||||
dbConnection.ConnString = dbConnection.ConnString.DESEncrypt();
|
||||
return db.Insertable(dbConnection).ExecuteCommand();
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新连接
|
||||
/// </summary>
|
||||
/// <param name="dictionary">连接实体</param>
|
||||
public override int Update(Model.rf_dbconnection dbConnection, bool clearCache = true)
|
||||
{
|
||||
if(clearCache)
|
||||
ClearCache();
|
||||
dbConnection.ConnString = dbConnection.ConnString.DESEncrypt();
|
||||
return db.Updateable(dbConnection).ExecuteCommand();
|
||||
}
|
||||
/// <summary>
|
||||
/// 得到所有连接
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override List<Model.rf_dbconnection> GetAll()
|
||||
{
|
||||
return _memoryCache.GetOrCreate(CACHEKEY, v =>
|
||||
{
|
||||
var dbConnections = db.Queryable<Model.rf_dbconnection>().OrderBy(p => p.Sort).ToList();
|
||||
foreach (var dbConn in dbConnections)
|
||||
{
|
||||
dbConn.ConnString = dbConn.ConnString.DESDecrypt();
|
||||
}
|
||||
return dbConnections;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个表所有字段
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="tableName"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.TableField> GetTableFields(string id, string tableName)
|
||||
{
|
||||
var conn = GetOneById(id);
|
||||
if (null == conn)
|
||||
{
|
||||
return new List<Model.TableField>();
|
||||
}
|
||||
return GetTableFields(conn, tableName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个表所有字段
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="tableName"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.TableField> GetTableFields(Model.rf_dbconnection conn, string tableName)
|
||||
{
|
||||
List<Model.TableField> tableFields = new List<Model.TableField>();
|
||||
string dbName = string.Empty;
|
||||
if (conn.ConnType.EqualsIgnoreCase("mysql"))
|
||||
{
|
||||
string[] connStringArray = conn.ConnString.Split(';');
|
||||
foreach (string connString in connStringArray)
|
||||
{
|
||||
string[] connArray = connString.Split('=');
|
||||
if (connArray.Length > 1 && (connArray[0].Trim().Equals("database") || connArray[0].Trim().Equals("db") || connArray[0].Trim().Equals("Initial Catalog")))
|
||||
{
|
||||
dbName = connArray[1].Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
var dt = this.GetTableFields(conn, tableName, dbName);
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
Model.TableField tableField = new Model.TableField()
|
||||
{
|
||||
FieldName = dr["f_name"].ToString().Trim(),
|
||||
Type = dr["t_name"].ToString(),
|
||||
Size = dr["length"].ToString().ToInt(),
|
||||
IsNull = "1".Equals(dr["is_null"].ToString()),
|
||||
IsDefault = dr["cdefault"].ToString().ToInt(0) != 0,
|
||||
IsIdentity = dr["isidentity"].ToString().ToInt() == 1,
|
||||
DefaultValue = dr["defaultvalue"].ToString(),
|
||||
Comment = dr["comments"].ToString()
|
||||
};
|
||||
tableFields.Add(tableField);
|
||||
}
|
||||
return tableFields;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个表所有字段
|
||||
/// </summary>
|
||||
/// <param name="dbConnection"></param>
|
||||
/// <param name="table">表名</param>
|
||||
/// <param name="dbName">数据库名(MYSQL时需要,防止同一个连接中不同的数据库中有相同的表名的情况。其它数据库为空)</param>
|
||||
/// <returns>返回datatable 列:f_name,t_name,length,is_null,cdefault,isidentity,defaultvalue,comments</returns>
|
||||
public DataTable GetTableFields(Model.rf_dbconnection dbConnection, string table, string dbName)
|
||||
{
|
||||
using var conn = dbConnection.GetConn(db);
|
||||
string sql = GetTableFieldsSql(dbConnection, table, dbName);
|
||||
return conn.Ado.GetDataTable(sql);
|
||||
}
|
||||
|
||||
|
||||
private string GetTableFieldsSql(Model.rf_dbconnection dbConnection, string tableName, string dbName)
|
||||
{
|
||||
using (var conn = db.GetConnection(dbConnection.Id))
|
||||
{
|
||||
switch (dbConnection.DbType)
|
||||
{
|
||||
case SqlSugar.DbType.MySql:
|
||||
return "SELECT COLUMN_NAME f_name,DATA_TYPE t_name, CHARACTER_MAXIMUM_LENGTH length " +
|
||||
",CASE IS_NULLABLE WHEN 'NO' THEN 0 WHEN 'YES' THEN 1 END is_null,COLUMN_DEFAULT cdefault,0 isidentity,COLUMN_DEFAULT defaultvalue,COLUMN_COMMENT comments FROM " +
|
||||
"information_schema.TABLES a " +
|
||||
"LEFT JOIN information_schema.COLUMNS b ON a.table_name = b.TABLE_NAME " +
|
||||
"WHERE a.TABLE_NAME='" + tableName + "'"
|
||||
+ (dbName.IsNullOrWhiteSpace() ? "" : " AND a.TABLE_SCHEMA='" + dbName + "' AND b.TABLE_SCHEMA='" + dbName + "'")
|
||||
+ " ORDER BY b.ordinal_position";
|
||||
case SqlSugar.DbType.SqlServer:
|
||||
return string.Format("select a.name as f_name,b.name as t_name,a.prec as [length],a.isnullable as is_null,a.cdefault as cdefault," +
|
||||
"COLUMNPROPERTY(OBJECT_ID('{0}'),a.name,'IsIdentity') as isidentity," +
|
||||
"(select top 1 text from sysobjects d inner join syscolumns e on e.id=d.id inner join syscomments f on f.id=e.cdefault " +
|
||||
"where d.name='{0}' and e.name=a.name) as defaultvalue,cast([value] as varchar(500)) as comments " +
|
||||
"from sys.syscolumns a left join sys.types b on b.user_type_id=a.xtype left join sys.extended_properties x " +
|
||||
"on x.major_id=OBJECT_ID('{0}') and x.minor_id=a.colid " +
|
||||
"where OBJECT_ID('{0}')=id order by a.colid", tableName);
|
||||
case SqlSugar.DbType.Oracle:
|
||||
return string.Format("SELECT user_tab_columns.COLUMN_NAME as f_name," +
|
||||
"user_tab_columns.DATA_TYPE as t_name," +
|
||||
"user_tab_columns.CHAR_LENGTH AS length," +
|
||||
"CASE user_tab_columns.NULLABLE WHEN 'Y' THEN 1 WHEN 'N' THEN 0 END AS is_null," +
|
||||
"user_tab_columns.DATA_DEFAULT AS cdefault," +
|
||||
"0 as isidentity,user_tab_columns.DATA_DEFAULT AS defaultvalue,user_col_comments.comments FROM user_tab_columns,user_col_comments " +
|
||||
"WHERE user_tab_columns.COLUMN_NAME=user_col_comments.COLUMN_NAME " +
|
||||
"and user_tab_columns.TABLE_NAME=user_col_comments.TABLE_NAME " +
|
||||
"and UPPER(user_tab_columns.TABLE_NAME)=UPPER('{0}') " +
|
||||
"and UPPER(user_col_comments.TABLE_NAME)=UPPER('{0}') " +
|
||||
"ORDER BY user_tab_columns.COLUMN_ID", tableName);
|
||||
case SqlSugar.DbType.PostgreSQL:
|
||||
return "select column_name as f_name,udt_name as t_name,character_maximum_length as length,case is_nullable when 'NO' then 0 when 'YES' then 1 end as is_null,column_default as cdefault,case is_identity when 'NO' then 0 when 'YES' then 1 end as isidentity,column_default as defaultvalue,'' as comments from information_schema.columns where table_name='" + tableName.ToLower() + "' order by ordinal_position";
|
||||
case SqlSugar.DbType.Dm:
|
||||
case SqlSugar.DbType.Kdbndp:
|
||||
case SqlSugar.DbType.Sqlite:
|
||||
return "不支持的连接类型";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到数据库所有表SQL
|
||||
/// </summary>
|
||||
private string GetDbTablesSql(SqlSugar.DbType type,string database)
|
||||
{
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case SqlSugar.DbType.MySql:
|
||||
return "select TABLE_NAME, TABLE_COMMENT COMMENTS from information_schema.TABLES where TABLE_SCHEMA='" + database + "' and (table_type='BASE TABLE' or table_type='VIEW')";
|
||||
case SqlSugar.DbType.SqlServer:
|
||||
return "SELECT name TABLE_NAME,(select top 1 cast([value] as varchar) [value] from sys.extended_properties where major_id=sysobjects.id and minor_id=0) COMMENTS from sysobjects WHERE name<>'sysdiagrams' AND (xtype='U' or xtype='V') ORDER BY xtype,name";
|
||||
case SqlSugar.DbType.Oracle:
|
||||
return "select a.TABLE_NAME,b.COMMENTS from user_tables a,user_tab_comments b WHERE a.TABLE_NAME=b.TABLE_NAME and a.TABLE_NAME not like '%$%' and a.TABLE_NAME not like 'LOGMNR%' and a.TABLE_NAME not like 'HELP%' and a.TABLE_NAME not like 'SPRING%' and a.TABLE_NAME not like 'SQLPLUS%' order by TABLE_NAME";
|
||||
case SqlSugar.DbType.PostgreSQL:
|
||||
return "select table_name, '' as comments from information_schema.tables where table_catalog='" + database + "' and table_schema='public' and (table_type='BASE TABLE' or table_type='VIEW')";
|
||||
case SqlSugar.DbType.Dm:
|
||||
case SqlSugar.DbType.Kdbndp:
|
||||
case SqlSugar.DbType.Sqlite:
|
||||
return "不支持的连接类型";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个连接所有表
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>Dictionary(表名, 表说明)</returns>
|
||||
public Dictionary<string, string> GetTables(string id)
|
||||
{
|
||||
Dictionary<string, string> dict = new Dictionary<string, string>();
|
||||
var conn = GetOneById(id);
|
||||
if (null == conn)
|
||||
{
|
||||
return dict;
|
||||
}
|
||||
DataTable dt = this.GetTables(conn);
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
dict.Add(dr[0].ToString().Trim(), dr[1].ToString());
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询一个连接所有表
|
||||
/// </summary>
|
||||
/// <param name="dbConnection"></param>
|
||||
/// <returns>表名,表说明</returns>
|
||||
public DataTable GetTables(Model.rf_dbconnection dbConnection)
|
||||
{
|
||||
using (SqlSugar.SqlSugarClient c = new SqlSugar.SqlSugarClient(new SqlSugar.ConnectionConfig()
|
||||
{
|
||||
ConfigId = dbConnection.Id,
|
||||
ConnectionString = dbConnection.ConnString,
|
||||
DbType = dbConnection.DbType,
|
||||
IsAutoCloseConnection = true,
|
||||
InitKeyType = SqlSugar.InitKeyType.SystemTable
|
||||
}))
|
||||
{
|
||||
var prd = c.GetConnection(dbConnection.Id);
|
||||
return prd.Ado.GetDataTable(
|
||||
GetDbTablesSql(dbConnection.DbType, prd.Ado.Connection.Database));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个字段的值(默认系统连接)
|
||||
/// </summary>
|
||||
/// <param name="sql">SQL</param>
|
||||
/// <param name="objs">参数</param>
|
||||
/// <returns></returns>
|
||||
public string GetFieldValue(string sql, params object[] objs)
|
||||
{
|
||||
return JObject.FromObject(db.Ado.SqlQuery<dynamic>(sql, objs)).ToString();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 得到DATATABLE
|
||||
/// </summary>
|
||||
/// <param name="dbConnectionModel"></param>
|
||||
/// <param name="tableName"></param>
|
||||
/// <param name="primaryKey"></param>
|
||||
/// <param name="primaryKeyValue"></param>
|
||||
/// <param name="order">排序 f1 desc</param>
|
||||
/// <returns></returns>
|
||||
public DataTable GetDataTable(Model.rf_dbconnection dbConnectionModel, string tableName, string primaryKey, string primaryKeyValue, string order = "")
|
||||
{
|
||||
if (null == dbConnectionModel || primaryKeyValue.IsNullOrWhiteSpace()
|
||||
|| tableName.IsNullOrWhiteSpace() || primaryKey.IsNullOrWhiteSpace())
|
||||
{
|
||||
return new DataTable();
|
||||
}
|
||||
var (sql, param) = GetFieldValueSql(tableName, "*", primaryKey, primaryKeyValue);
|
||||
|
||||
DataTable dt = GetDataTable(dbConnectionModel, sql, param);
|
||||
if (!order.IsNullOrWhiteSpace())
|
||||
{
|
||||
dt.DefaultView.Sort = order;
|
||||
return dt.DefaultView.ToTable();
|
||||
}
|
||||
else
|
||||
{
|
||||
return dt;
|
||||
}
|
||||
}
|
||||
|
||||
public DataTable GetDataTable(Model.rf_dbconnection conn, string sql, params object[] objs)
|
||||
{
|
||||
using (SqlSugar.SqlSugarClient c = new SqlSugar.SqlSugarClient(new SqlSugar.ConnectionConfig()
|
||||
{
|
||||
ConfigId = conn.Id,
|
||||
ConnectionString = conn.ConnString,
|
||||
DbType = conn.DbType,
|
||||
IsAutoCloseConnection = true,
|
||||
InitKeyType = SqlSugar.InitKeyType.SystemTable
|
||||
}))
|
||||
{
|
||||
var prd = c.GetConnection(conn.Id);
|
||||
List<SqlSugar.SugarParameter> list = new List<SqlSugar.SugarParameter>();
|
||||
foreach (object o in objs)
|
||||
list.Add((SqlSugar.SugarParameter)o);
|
||||
return prd.Ado.GetDataTable(sql, list);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到查询一个字段值SQL
|
||||
/// </summary>
|
||||
/// <param name="tableName"></param>
|
||||
/// <param name="fieldName"></param>
|
||||
/// <param name="primaryKey"></param>
|
||||
/// <param name="primaryKeyValue"></param>
|
||||
/// <returns></returns>
|
||||
public (string sql, object[] parameter) GetFieldValueSql(string tableName, string fieldName, string primaryKey, string primaryKeyValue)
|
||||
{
|
||||
string sql = "SELECT " + fieldName + " FROM " + tableName + " WHERE " + primaryKey + " = @primarykeyvalue";
|
||||
return (sql, new object[] { new SqlSugar.SugarParameter("primarykeyvalue",primaryKeyValue) } );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个字段的值
|
||||
/// </summary>
|
||||
/// <param name="id">连接ID</param>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="fieldName">要查询的字段</param>
|
||||
/// <param name="primaryKey">主键</param>
|
||||
/// <param name="primaryKeyValue">主键值</param>
|
||||
/// <returns></returns>
|
||||
public string GetFieldValue(string id, string tableName, string fieldName, string primaryKey, string primaryKeyValue)
|
||||
{
|
||||
var conn = GetOneById(id);
|
||||
if (null == conn)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
return GetFieldValue(conn, tableName, fieldName, primaryKey, primaryKeyValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个字段的值
|
||||
/// </summary>
|
||||
/// <param name="dbConnection">连接实体</param>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="fieldName">要查询的字段</param>
|
||||
/// <param name="primaryKey">主键</param>
|
||||
/// <param name="primaryKeyValue">主键值</param>
|
||||
/// <returns></returns>
|
||||
public string GetFieldValue(Model.rf_dbconnection dbConnection, string tableName, string fieldName, string primaryKey, string primaryKeyValue)
|
||||
{
|
||||
var sql = GetFieldValueSql(tableName, fieldName, primaryKey, primaryKeyValue);
|
||||
DataTable dataTable = GetDataTable(dbConnection, sql.sql, sql.parameter );
|
||||
return dataTable.Rows.Count > 0 ? dataTable.Rows[0][0].ToString() : string.Empty;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 保存数据
|
||||
/// </summary>
|
||||
/// <param name="dbConnection"></param>
|
||||
/// <param name="tuples"></param>
|
||||
/// <param name="isIdentity"></param>
|
||||
/// <param name="seqName"></param>
|
||||
/// <param name="sqlList">要额外执行的SQL列表</param>
|
||||
/// <returns>返回数字表示成功(数字是受影响的行数或者自增主键值),其它为错误信息</returns>
|
||||
public string SaveData(Model.rf_dbconnection dbConnection, List<(Dictionary<string, object> dicts, string tableName, string primaryKey, int flag)> tuples,
|
||||
bool isIdentity = false, string seqName = "", List<(string, SqlSugar.SugarParameter[])> sqlList = null)
|
||||
{
|
||||
return tuples.Count == 0 && (sqlList == null || sqlList.Count == 0) ? "0" : SaveData2(dbConnection, tuples, isIdentity, seqName, sqlList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存数据
|
||||
/// </summary>
|
||||
/// <param name="tuples"></param>
|
||||
/// <param name="sqlList1">要额外执行的SQL列表</param>
|
||||
/// <returns>返回数字表示成功(数字是受影响的行数或者自增主键值),其它为错误信息</returns>
|
||||
public string SaveData2(Model.rf_dbconnection dbConnection, List<(Dictionary<string, object> dicts, string tableName, string primaryKey, int flag)> tuples,
|
||||
bool isIdentity = false, string seqName = "", List<(string, SqlSugar.SugarParameter[])> sqlList1 = null)
|
||||
{
|
||||
|
||||
List<(string sql, SqlSugar.SugarParameter[] parameters)> sqlList = new List<(string sql, SqlSugar.SugarParameter[] parameters)>();
|
||||
foreach (var (dicts, tableName, primaryKey, flag) in tuples)
|
||||
{
|
||||
var (sql, paramArray) = GetSaveDataSql(dicts, tableName, primaryKey, flag);
|
||||
sqlList.Add((sql, paramArray));
|
||||
}
|
||||
if (sqlList1 != null && sqlList1.Count > 0)
|
||||
{
|
||||
sqlList.AddRange(sqlList1);
|
||||
}
|
||||
|
||||
using (SqlSugar.SqlSugarClient c = new SqlSugar.SqlSugarClient(new SqlSugar.ConnectionConfig()
|
||||
{
|
||||
ConfigId = dbConnection.Id,
|
||||
ConnectionString = dbConnection.ConnString,
|
||||
DbType = dbConnection.DbType,
|
||||
IsAutoCloseConnection = true,
|
||||
InitKeyType = SqlSugar.InitKeyType.SystemTable
|
||||
}))
|
||||
{
|
||||
var prd = c.GetConnection(dbConnection.Id);
|
||||
prd.Ado.BeginTran();
|
||||
try
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var (sql, parameter) in sqlList)
|
||||
{
|
||||
i += prd.Ado.ExecuteCommand(sql, parameter);
|
||||
}
|
||||
if (isIdentity && !seqName.IsNullOrWhiteSpace())
|
||||
{
|
||||
i = prd.Ado.SqlQuery<int>("SELECT @@IDENTITY")[0];
|
||||
}
|
||||
prd.Ado.CommitTran();
|
||||
return i.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
prd.Ado.RollbackTran();
|
||||
}
|
||||
|
||||
}
|
||||
return "-1";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到保存数据SQL
|
||||
/// </summary>
|
||||
/// <param name="dicts"></param>
|
||||
/// <param name="flag">0删除 1新增 2修改</param>
|
||||
/// <returns></returns>
|
||||
public (string sql, SqlSugar.SugarParameter[] parameter) GetSaveDataSql(Dictionary<string, object> dicts, string tableName, string primaryKey, int flag)
|
||||
{
|
||||
StringBuilder sqlBuilder = new StringBuilder();
|
||||
List<SqlSugar.SugarParameter> parameters = new List<SqlSugar.SugarParameter>();
|
||||
if (0 == flag)
|
||||
{
|
||||
sqlBuilder.Append("DELETE FROM " + tableName);
|
||||
}
|
||||
else if (1 == flag)
|
||||
{
|
||||
sqlBuilder.Append("INSERT INTO " + tableName + "(");
|
||||
foreach (var dict in dicts)
|
||||
{
|
||||
sqlBuilder.Append(dict.Key);
|
||||
if (!dict.Key.Equals(dicts.Last().Key))
|
||||
{
|
||||
sqlBuilder.Append(",");
|
||||
}
|
||||
}
|
||||
sqlBuilder.Append(") VALUES(");
|
||||
}
|
||||
else if (2 == flag)
|
||||
{
|
||||
sqlBuilder.Append("UPDATE " + tableName + " SET ");
|
||||
}
|
||||
foreach (var dict in dicts)
|
||||
{
|
||||
if (0 == flag)
|
||||
{
|
||||
sqlBuilder.Append(" WHERE " + primaryKey + "=@" + primaryKey);
|
||||
parameters.Add(new SqlSugar.SugarParameter("@" + primaryKey, dicts[primaryKey]));
|
||||
}
|
||||
else if (1 == flag)
|
||||
{
|
||||
parameters.Add(new SqlSugar.SugarParameter("@" + dict.Key, dict.Value));
|
||||
sqlBuilder.Append("@" + dict.Key);
|
||||
if (!dict.Key.Equals(dicts.Last().Key))
|
||||
{
|
||||
sqlBuilder.Append(",");
|
||||
}
|
||||
}
|
||||
else if (2 == flag)
|
||||
{
|
||||
parameters.Add(new SqlSugar.SugarParameter("@" + dict.Key, dict.Value));
|
||||
if (dict.Key.EqualsIgnoreCase(primaryKey))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
sqlBuilder.Append(dict.Key + "=@" + dict.Key);
|
||||
if (!dict.Key.Equals(dicts.Last().Key))
|
||||
{
|
||||
sqlBuilder.Append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (1 == flag)
|
||||
{
|
||||
sqlBuilder.Append(")");
|
||||
}
|
||||
else if (2 == flag)
|
||||
{
|
||||
sqlBuilder.Append(" WHERE " + primaryKey + "=@" + primaryKey);
|
||||
}
|
||||
return (sqlBuilder.ToString(), parameters.ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断一个连接是否和系统是一个连接
|
||||
/// </summary>
|
||||
/// <param name="connId"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsSystemConn(Model.rf_dbconnection connModel)
|
||||
{
|
||||
var con =db.CurrentConnectionConfig;
|
||||
return true;
|
||||
}
|
||||
|
||||
public int executeSqlByConnection(Model.rf_dbconnection conn, IEnumerable<(string, object[], int)> list, bool trans = true)
|
||||
{
|
||||
using (SqlSugar.SqlSugarClient c = new SqlSugar.SqlSugarClient(new SqlSugar.ConnectionConfig()
|
||||
{
|
||||
ConfigId = conn.Id,
|
||||
ConnectionString = conn.ConnString,
|
||||
DbType = conn.DbType,
|
||||
IsAutoCloseConnection = true,
|
||||
InitKeyType = SqlSugar.InitKeyType.SystemTable
|
||||
}))
|
||||
{
|
||||
if(trans)
|
||||
c.BeginTran();
|
||||
try
|
||||
{
|
||||
int count = 0;
|
||||
foreach (var (sql, pars, _) in list)
|
||||
count = c.Ado.ExecuteCommand(sql, pars);
|
||||
if (trans)
|
||||
c.CommitTran();
|
||||
return count;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (trans)
|
||||
c.RollbackTran();
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int executeSqlByConnection(Model.rf_dbconnection conn, string sql,params object[] pars)
|
||||
{
|
||||
using (SqlSugar.SqlSugarClient c = new SqlSugar.SqlSugarClient(new SqlSugar.ConnectionConfig()
|
||||
{
|
||||
ConfigId = conn.Id,
|
||||
ConnectionString = conn.ConnString,
|
||||
DbType = conn.DbType,
|
||||
IsAutoCloseConnection = true,
|
||||
InitKeyType = SqlSugar.InitKeyType.SystemTable
|
||||
}))
|
||||
{
|
||||
return c.Ado.ExecuteCommand(sql, pars);
|
||||
}
|
||||
|
||||
}
|
||||
public int executeSqlByConnection(string connId, List<(string, IEnumerable<object>)> sqls)
|
||||
{
|
||||
var conn = GetOneById(connId);
|
||||
using (SqlSugar.SqlSugarClient c = new SqlSugar.SqlSugarClient(new SqlSugar.ConnectionConfig()
|
||||
{
|
||||
ConfigId = conn.Id,
|
||||
ConnectionString = conn.ConnString,
|
||||
DbType = conn.DbType,
|
||||
IsAutoCloseConnection = true,
|
||||
InitKeyType = SqlSugar.InitKeyType.SystemTable
|
||||
}))
|
||||
{
|
||||
c.Ado.BeginTran();
|
||||
try
|
||||
{
|
||||
int count = 0;
|
||||
foreach ((string sql, IEnumerable<object> pars) in sqls)
|
||||
{
|
||||
count +=c.Ado.ExecuteCommand(sql, pars);
|
||||
}
|
||||
c.Ado.CommitTran();
|
||||
return count;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
c.Ado.RollbackTran();
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int executeSqlByCurrent(IEnumerable<(string, object[], int)> list,bool trans=true)
|
||||
{
|
||||
if (trans)
|
||||
db.BeginTran();
|
||||
try
|
||||
{
|
||||
int count = 0;
|
||||
foreach (var (sql, pars, _) in list)
|
||||
count = db.Ado.ExecuteCommand(sql, pars);
|
||||
if (trans)
|
||||
db.CommitTran();
|
||||
return count;
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (trans)
|
||||
db.RollbackTran();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 测试一个SQL语句是否正确
|
||||
/// </summary>
|
||||
/// <param name="id">连接ID</param>
|
||||
/// <param name="sql">sql语句</param>
|
||||
/// <param name="parameters">sql参数</param>
|
||||
/// <returns></returns>
|
||||
public string TestSQL(string id, string sql, object[] parameters = null)
|
||||
{
|
||||
var conn = GetOneById(id);
|
||||
if (conn == null)
|
||||
return "未找到连接实体";
|
||||
using (SqlSugar.SqlSugarClient c = new SqlSugar.SqlSugarClient(new SqlSugar.ConnectionConfig()
|
||||
{
|
||||
ConfigId = conn.Id,
|
||||
ConnectionString = conn.ConnString,
|
||||
DbType = conn.DbType,
|
||||
IsAutoCloseConnection = true,
|
||||
InitKeyType = SqlSugar.InitKeyType.SystemTable
|
||||
}))
|
||||
{
|
||||
c.Ado.BeginTran();
|
||||
try {
|
||||
int rtn = c.Ado.ExecuteCommand(sql, parameters);
|
||||
return rtn.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return "SQL:" + sql + " " + ex.Message;
|
||||
}
|
||||
finally {
|
||||
c.Ado.RollbackTran();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 得到连接类别下拉项(VUE)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public JArray GetConnTypeOptionsVue()
|
||||
{
|
||||
JArray jArray = new JArray();
|
||||
var array = Enum.GetValues(typeof(ConnType));
|
||||
foreach (var arr in array)
|
||||
{
|
||||
jArray.Add(new JObject() { { "value", arr.ToString() }, { "title", arr.ToString() } });
|
||||
}
|
||||
return jArray;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 测试一个连接
|
||||
/// </summary>
|
||||
/// <param name="id">连接ID</param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns>返回"1"表示正常,其它为错误信息</returns>
|
||||
public string TestConnection(string id, IStringLocalizer localizer = null)
|
||||
{
|
||||
var conn = this.GetOneById(id);
|
||||
if (conn == null)
|
||||
return localizer == null ? "未找到连接" : localizer["NotFoundConnection"].Value;
|
||||
using (SqlSugar.SqlSugarClient c = new SqlSugar.SqlSugarClient(new SqlSugar.ConnectionConfig()
|
||||
{
|
||||
ConfigId = conn.Id,
|
||||
ConnectionString = conn.ConnString,
|
||||
DbType = conn.DbType,
|
||||
IsAutoCloseConnection = true,
|
||||
InitKeyType = SqlSugar.InitKeyType.SystemTable
|
||||
}))
|
||||
{
|
||||
return "1";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据连接类型枚举
|
||||
/// </summary>
|
||||
public enum ConnType
|
||||
{
|
||||
SqlServer,
|
||||
MySql,
|
||||
Oracle,
|
||||
PostgreSql
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IDbConnection : IRoadFlowRepository<RoadFlow.Model.rf_dbconnection>
|
||||
{
|
||||
List<Model.TableField> GetTableFields(string id, string tableName);
|
||||
List<Model.TableField> GetTableFields(Model.rf_dbconnection conn, string tableName);
|
||||
DataTable GetTableFields(Model.rf_dbconnection dbConnection, string table, string dbName);
|
||||
Dictionary<string, string> GetTables(string id);
|
||||
DataTable GetTables(Model.rf_dbconnection dbConnection);
|
||||
|
||||
/// <summary>
|
||||
/// 测试一个SQL语句是否正确
|
||||
/// </summary>
|
||||
/// <param name="id">连接ID</param>
|
||||
/// <param name="sql">sql语句</param>
|
||||
/// <param name="parameters">sql参数</param>
|
||||
/// <returns></returns>
|
||||
public string TestSQL(string id, string sql, object[] parameters = null);
|
||||
/// <summary>
|
||||
/// 得到连接类别下拉项(VUE)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public JArray GetConnTypeOptionsVue();
|
||||
/// <summary>
|
||||
/// 测试一个连接
|
||||
/// </summary>
|
||||
/// <param name="id">连接ID</param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns>返回"1"表示正常,其它为错误信息</returns>
|
||||
public string TestConnection(string id, IStringLocalizer localizer = null);
|
||||
}
|
||||
|
||||
}
|
||||
574
20220330_Vote/Ewide.RoadFlow/Data/Dictionary/Dictionary.cs
Normal file
574
20220330_Vote/Ewide.RoadFlow/Data/Dictionary/Dictionary.cs
Normal file
@@ -0,0 +1,574 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Furion.DependencyInjection;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RoadFlow.Data;
|
||||
using RoadFlow.Utility;
|
||||
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class Dictionary : RoadFlowRepository<RoadFlow.Model.rf_dictionary>, IDictionary, ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 值字段
|
||||
/// </summary>
|
||||
public enum ValueField
|
||||
{
|
||||
Id,
|
||||
Title,
|
||||
Code,
|
||||
Value,
|
||||
Other,
|
||||
Note
|
||||
}
|
||||
/// <summary>
|
||||
/// 得到所有下级ID
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="isMe">是包含自己</param>
|
||||
/// <returns></returns>
|
||||
public List<string> GetAllChildsId(string id, bool isMe = true)
|
||||
{
|
||||
List<string> guids = new();
|
||||
if (isMe)
|
||||
{
|
||||
guids.Add(id);
|
||||
}
|
||||
var allChilds = GetAllChilds(id);
|
||||
foreach (var child in allChilds)
|
||||
{
|
||||
guids.Add(child.Id);
|
||||
}
|
||||
return guids;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据ID得到所有下级
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="isMe">是否包含自己</param>
|
||||
/// <returns></returns>
|
||||
public List<RoadFlow.Model.rf_dictionary> GetAllChilds(string id, bool isMe = false)
|
||||
{
|
||||
List<RoadFlow.Model.rf_dictionary> dictionaries = new();
|
||||
var dict =id.IsGuid()? this.GetOneById(id):this.GetOneBy(x=>x.Code==id);
|
||||
if (null == dict)
|
||||
{
|
||||
return dictionaries;
|
||||
}
|
||||
if (isMe)
|
||||
{
|
||||
dictionaries.Add(dict);
|
||||
}
|
||||
AddChilds(dict, dictionaries);
|
||||
return dictionaries;
|
||||
}
|
||||
/// <summary>
|
||||
/// 递归添加下级
|
||||
/// </summary>
|
||||
/// <param name="dictionary"></param>
|
||||
/// <param name="dictionaries"></param>
|
||||
private void AddChilds(RoadFlow.Model.rf_dictionary dictionary, List<RoadFlow.Model.rf_dictionary> dictionaries)
|
||||
{
|
||||
var childs = GetChilds(dictionary.Id);
|
||||
if (childs.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (RoadFlow.Model.rf_dictionary child in childs)
|
||||
{
|
||||
dictionaries.Add(child);
|
||||
AddChilds(child, dictionaries);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID得到下级
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public List<RoadFlow.Model.rf_dictionary> GetChilds(string id)
|
||||
{
|
||||
return this.GetAll().FindAll(p => p.ParentId == id.ToString()).OrderBy(p => p.Sort).ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据唯一代码得到ID
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
public string GetIdByCode(string code)
|
||||
{
|
||||
var dict = this.GetOneBy(a => a.Code.EqualsIgnoreCase(code));
|
||||
return null == dict ? string.Empty : dict.Id;
|
||||
}
|
||||
/// <summary>
|
||||
/// 得到字典根
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public RoadFlow.Model.rf_dictionary GetRoot()
|
||||
{
|
||||
return this.GetAll().Find(p => p.ParentId == string.Empty);
|
||||
}
|
||||
/// <summary>
|
||||
/// 判断一个字典是否有下级字典
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public bool HasChilds(string id)
|
||||
{
|
||||
return this.GetAll().Exists(p => p.ParentId == id.ToString());
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 得到多语言标题
|
||||
/// </summary>
|
||||
/// <param name="dictionary">字典实体</param>
|
||||
/// <param name="language">语言</param>
|
||||
/// <returns></returns>
|
||||
public string GetLanguageTitle(RoadFlow.Model.rf_dictionary dictionary, string language = "")
|
||||
{
|
||||
string title = string.Empty;
|
||||
if (null == dictionary)
|
||||
{
|
||||
return title;
|
||||
}
|
||||
if (language.IsNullOrWhiteSpace())
|
||||
{
|
||||
language = Tools.GetCurrentLanguage();
|
||||
}
|
||||
switch (language)
|
||||
{
|
||||
case "en-US":
|
||||
title = dictionary.Title_en;
|
||||
break;
|
||||
case "zh":
|
||||
title = dictionary.Title_zh;
|
||||
break;
|
||||
default:
|
||||
title = dictionary.Title;
|
||||
break;
|
||||
}
|
||||
if (title.IsNullOrWhiteSpace())
|
||||
{
|
||||
title = dictionary.Title;
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID查询字典标题
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="language">语言</param>
|
||||
/// <returns></returns>
|
||||
public string GetTitle(string id, string language = "")
|
||||
{
|
||||
var dict = this.GetOneById(id);
|
||||
return null == dict ? "" : GetLanguageTitle(dict, language);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按code获取字典项
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
public RoadFlow.Model.rf_dictionary GetOneByCode(string code)
|
||||
{
|
||||
return code.IsNullOrWhiteSpace() ? null : this.GetAll().Find(x => x.Code.EqualsIgnoreCase(code));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID得到选项
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="valueField">值字段,默认id</param>
|
||||
/// <param name="value">默认值</param>
|
||||
/// <param name="isAllChild">是否显示所有下级</param>
|
||||
/// <param name="existsFlowType">是否包含流程分类(流程设计时选表单不能选择流程分类)</param>
|
||||
/// <returns></returns>
|
||||
public string GetOptionsByID(string id, ValueField valueField = ValueField.Id, string value = "", bool isAllChild = true, bool existsFlowType = true)
|
||||
{
|
||||
if (id.IsNullOrWhiteSpace())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
var childs = isAllChild ? GetAllChilds(id) : GetChilds(id);
|
||||
StringBuilder options = new StringBuilder(childs.Count * 60);
|
||||
StringBuilder space = new StringBuilder();
|
||||
var flowChilds = existsFlowType ? new List<Model.rf_dictionary>() : GetAllChilds("system_applibrarytype_flow", true);//取出流程分类的下级,为了如果不包含流程分类时要排除
|
||||
foreach (var child in childs)
|
||||
{
|
||||
if (child.Status == 1)//标记为已删除的不作为选项
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!existsFlowType && flowChilds.Exists(p => p.Id == child.Id))//如果不包含流程分类要排除
|
||||
{
|
||||
continue;
|
||||
}
|
||||
space.Clear();
|
||||
int parentCount = GetParentCount(childs, child);
|
||||
for (int i = 0; i < parentCount; i++)
|
||||
{
|
||||
space.Append(" ");
|
||||
}
|
||||
if (parentCount > 0)
|
||||
{
|
||||
space.Append("├");
|
||||
}
|
||||
string value1 = GetOptionValue(valueField, child);
|
||||
options.AppendFormat("<option value=\"{0}\"{1}>{2}{3}</option>", value1, value1.Equals(value) ? " selected=\"selected\"" : "", space.ToString(), GetLanguageTitle(child));
|
||||
}
|
||||
return options.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// 得到一个字典项的上级节点数
|
||||
/// </summary>
|
||||
/// <param name="dictList"></param>
|
||||
/// <param name="dict"></param>
|
||||
/// <returns></returns>
|
||||
private int GetParentCount(List<Model.rf_dictionary> dictList, Model.rf_dictionary dict)
|
||||
{
|
||||
int parent = 0;
|
||||
Model.rf_dictionary parentDict = dictList.Find(p => p.Id == dict.ParentId);
|
||||
while (parentDict != null)
|
||||
{
|
||||
parentDict = dictList.Find(p => p.Id == parentDict.ParentId);
|
||||
parent++;
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
/// <summary>
|
||||
/// 得到选项值
|
||||
/// </summary>
|
||||
/// <param name="valueField"></param>
|
||||
/// <param name="dictionary"></param>
|
||||
/// <returns></returns>
|
||||
private string GetOptionValue(ValueField valueField, Model.rf_dictionary dictionary)
|
||||
{
|
||||
string value = string.Empty;
|
||||
switch (valueField)
|
||||
{
|
||||
case ValueField.Id:
|
||||
value = dictionary.Id.ToString();
|
||||
break;
|
||||
case ValueField.Code:
|
||||
value = dictionary.Code;
|
||||
break;
|
||||
case ValueField.Note:
|
||||
value = dictionary.Note;
|
||||
break;
|
||||
case ValueField.Other:
|
||||
value = dictionary.Other;
|
||||
break;
|
||||
case ValueField.Title:
|
||||
value = GetLanguageTitle(dictionary, Tools.GetCurrentLanguage());
|
||||
break;
|
||||
case ValueField.Value:
|
||||
value = dictionary.Value;
|
||||
break;
|
||||
}
|
||||
return value ?? string.Empty;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据字符串得到ValueField
|
||||
/// </summary>
|
||||
/// <param name="valueField"></param>
|
||||
/// <returns></returns>
|
||||
public ValueField GetValueField(string valueField)
|
||||
{
|
||||
return valueField.IsNullOrEmpty() ? ValueField.Id : valueField switch
|
||||
{
|
||||
"code" => ValueField.Code,
|
||||
"value" => ValueField.Value,
|
||||
"title" => ValueField.Title,
|
||||
"note" => ValueField.Note,
|
||||
"other" => ValueField.Other,
|
||||
_ => ValueField.Id,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID得到选项(返回jarray,vue项目用)
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="valueField">值字段,默认id</param>
|
||||
/// <param name="value">默认值</param>
|
||||
/// <param name="isAllChild">是否显示所有下级</param>
|
||||
/// <param name="isSelectParent">是否可以选择上级</param>
|
||||
/// <returns></returns>
|
||||
public JArray GetArrayOptionsByID(string id, ValueField valueField = ValueField.Id, string value = "", bool isAllChild = true, bool isSelectParent = true)
|
||||
{
|
||||
JArray jArray = new JArray();
|
||||
if (id.IsNullOrWhiteSpace())
|
||||
{
|
||||
return jArray;
|
||||
}
|
||||
string lang = Tools.GetCurrentLanguage();
|
||||
var childs = isAllChild ? GetAllChilds(id) : GetChilds(id);
|
||||
StringBuilder space = new StringBuilder();
|
||||
foreach (var child in childs)
|
||||
{
|
||||
if (child.Status == 1)//标记为已删除的不作为选项
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
space.Clear();
|
||||
int parentCount = GetParentCount(childs, child);
|
||||
for (int i = 0; i < parentCount; i++)
|
||||
{
|
||||
space.Append(" ");
|
||||
}
|
||||
if (parentCount > 0)
|
||||
{
|
||||
space.Append("├");
|
||||
}
|
||||
string value1 = GetOptionValue(valueField, child);
|
||||
jArray.Add(new JObject() {
|
||||
{ "value", value1 },
|
||||
{ "title", space.ToString() + GetLanguageTitle(child, lang) },
|
||||
{ "selected", value1.EqualsIgnoreCase(value) },
|
||||
|
||||
});
|
||||
}
|
||||
return jArray;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID得到所有下级(控件选项)
|
||||
/// </summary>
|
||||
/// <param name="id">根节点字典id</param>
|
||||
/// <param name="valueField">值字段</param>
|
||||
/// <param name="isRoot">是否显示根节点</param>
|
||||
/// <param name="lang">标题语言</param>
|
||||
/// <returns></returns>
|
||||
public JArray GetAllChildsArray(string id, ValueField valueField, bool isRoot = false, string lang = "")
|
||||
{
|
||||
var childs = GetChilds(id);
|
||||
JArray jArray = new JArray();
|
||||
foreach (Model.rf_dictionary child in childs)
|
||||
{
|
||||
JObject jObject = child.ToJObject();
|
||||
jObject.Add("Value1", child.Value);
|
||||
jObject.Remove("Value");
|
||||
jObject.Add("value", GetOptionValue(valueField, child));
|
||||
jObject.Add("label", GetLanguageTitle(child, lang));
|
||||
jArray.Add(jObject);
|
||||
AddChildsArray(child, jObject, valueField, lang);
|
||||
}
|
||||
JArray jArray1;
|
||||
if (isRoot)
|
||||
{
|
||||
var rootDict = GetOneById(id);
|
||||
if (null == rootDict)
|
||||
{
|
||||
return new JArray();
|
||||
}
|
||||
JObject rootObj = rootDict.ToJObject();
|
||||
rootObj.Add("Value1", rootDict.Value);
|
||||
rootObj.Add("value", GetOptionValue(valueField, rootDict));
|
||||
rootObj.Add("label", GetLanguageTitle(rootDict, lang));
|
||||
rootObj.Add("children", jArray);
|
||||
rootObj.Add("isLeaf", jArray.Count == 0);
|
||||
rootObj.Add("slots", new JObject() { { "icon", "custom" } });
|
||||
jArray1 = new JArray() { rootObj };
|
||||
}
|
||||
else
|
||||
{
|
||||
jArray1 = jArray;
|
||||
}
|
||||
return jArray1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 递归添加下级(控件选项)
|
||||
/// </summary>
|
||||
/// <param name="dictionary"></param>
|
||||
/// <param name="dictionaries"></param>
|
||||
private void AddChildsArray(Model.rf_dictionary dictionary, JObject jObject, ValueField valueField, string lang = "")
|
||||
{
|
||||
var childs = GetChilds(dictionary.Id);
|
||||
if (childs.Count == 0)
|
||||
{
|
||||
jObject.Add("isLeaf", true);
|
||||
jObject.Add("slots", new JObject() { { "icon", "custom" } });
|
||||
return;
|
||||
}
|
||||
JArray jArray = new JArray();
|
||||
jObject.Add("children", jArray);
|
||||
jObject.Add("isLeaf", false);
|
||||
jObject.Add("slots", new JObject() { { "icon", "custom" } });
|
||||
foreach (Model.rf_dictionary child in childs)
|
||||
{
|
||||
JObject jObject1 = child.ToJObject();
|
||||
jObject1.Add("Value1", child.Value);
|
||||
jObject1.Remove("Value");
|
||||
jObject1.Add("value", GetOptionValue(valueField, child));
|
||||
jObject1.Add("label", GetLanguageTitle(child, lang));
|
||||
jArray.Add(jObject1);
|
||||
AddChildsArray(child, jObject1, valueField, lang);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID得到选项(返回jarray,vue项目用)
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="valueField">值字段,默认id</param>
|
||||
/// <param name="value">默认值</param>
|
||||
/// <param name="isAllChild">是否显示所有下级</param>
|
||||
/// <param name="isSelectParent">是否可以选择上级</param>
|
||||
/// <returns></returns>
|
||||
public JArray GetArrayComboxsByID(string id, ValueField valueField = ValueField.Id, string value = "", bool isAllChild = true, bool isSelectParent = true)
|
||||
{
|
||||
JArray jArray = new JArray();
|
||||
if (id.IsNullOrWhiteSpace())
|
||||
{
|
||||
return jArray;
|
||||
}
|
||||
var childs = isAllChild ? GetAllChilds(id) : GetChilds(id);
|
||||
string lang = Tools.GetCurrentLanguage();
|
||||
foreach (var child in childs)
|
||||
{
|
||||
if (child.Status == 1)//标记为已删除的不作为选项
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int parentCount = GetParentCount(childs, child);
|
||||
string value1 = GetOptionValue(valueField, child);
|
||||
jArray.Add(new JObject() {
|
||||
{ "value", value1 },
|
||||
{ "title", GetLanguageTitle(child, lang)},
|
||||
{ "selected", value1.EqualsIgnoreCase(value) },
|
||||
{ "parentCount", parentCount },
|
||||
{ "group", !isSelectParent && childs.Exists(p=>p.ParentId == child.Id) },
|
||||
});
|
||||
}
|
||||
return jArray;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到单选或复选按钮组选项
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="valueField">值字段</param>
|
||||
/// <returns></returns>
|
||||
public JArray GetRadioOrCheckboxItems(string id, ValueField valueField = ValueField.Id)
|
||||
{
|
||||
JArray jArray = new JArray();
|
||||
if (id.IsNullOrWhiteSpace())
|
||||
{
|
||||
return jArray;
|
||||
}
|
||||
var childs = GetChilds(id);
|
||||
string lang = Tools.GetCurrentLanguage();
|
||||
foreach (var child in childs)
|
||||
{
|
||||
if (child.Status == 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string value1 = GetOptionValue(valueField, child);
|
||||
jArray.Add(new JObject() {
|
||||
{ "value", value1 },
|
||||
{ "title", GetLanguageTitle(child, lang) },
|
||||
});
|
||||
}
|
||||
return jArray;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个字典下级的最大排序号
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public int GetMaxSort(string id)
|
||||
{
|
||||
var childs = GetChilds(id);
|
||||
return childs.Count == 0 ? 5 : childs.Max(p => p.Sort) + 5;
|
||||
}
|
||||
/// <summary>
|
||||
/// 检查唯一代码是否重复
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="code"></param>
|
||||
/// <returns>true 没有重复 false 重复</returns>
|
||||
public bool CheckCode(string id, string code)
|
||||
{
|
||||
var dict = GetOneById(code);
|
||||
return null == dict ? true : dict.Id == id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到字典根ID
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetRootId()
|
||||
{
|
||||
var root = GetRoot();
|
||||
return null == root ? string.Empty : root.Id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入数据字典
|
||||
/// </summary>
|
||||
/// <param name="json"></param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
public string Import(string json, IStringLocalizer localizer = null)
|
||||
{
|
||||
if (json.IsNullOrWhiteSpace())
|
||||
{
|
||||
return localizer == null ? "要导入的json为空!" : localizer["ImportJsonEmpty"].Value;
|
||||
}
|
||||
Newtonsoft.Json.Linq.JArray jArray = null;
|
||||
try
|
||||
{
|
||||
jArray = Newtonsoft.Json.Linq.JArray.Parse(json);
|
||||
}
|
||||
catch
|
||||
{
|
||||
jArray = null;
|
||||
}
|
||||
if (null == jArray)
|
||||
{
|
||||
return localizer == null ? "json解析错误!" : localizer["JsonParseError"].Value;
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
foreach (Newtonsoft.Json.Linq.JObject jObject in jArray)
|
||||
{
|
||||
try
|
||||
{
|
||||
Model.rf_dictionary dictionaryModel = jObject.ToObject<Model.rf_dictionary>();
|
||||
if (null == dictionaryModel)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (GetOneById(dictionaryModel.Id) != null)
|
||||
{
|
||||
Update(dictionaryModel);
|
||||
}
|
||||
else
|
||||
{
|
||||
Add(dictionaryModel);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
stringBuilder.Append(err.Message + ";");
|
||||
new Log().Add(err);
|
||||
}
|
||||
}
|
||||
return stringBuilder.Length == 0 ? "1" : stringBuilder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
158
20220330_Vote/Ewide.RoadFlow/Data/Dictionary/IDictionary.cs
Normal file
158
20220330_Vote/Ewide.RoadFlow/Data/Dictionary/IDictionary.cs
Normal file
@@ -0,0 +1,158 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static RoadFlow.Data.Dictionary;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IDictionary:IRoadFlowRepository<RoadFlow.Model.rf_dictionary>
|
||||
{
|
||||
/// <summary>
|
||||
/// 得到所有下级ID
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="isMe">是包含自己</param>
|
||||
/// <returns></returns>
|
||||
List<string> GetAllChildsId(string id, bool isMe = true);
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID得到所有下级
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="isMe">是否包含自己</param>
|
||||
/// <returns></returns>
|
||||
List<RoadFlow.Model.rf_dictionary> GetAllChilds(string id, bool isMe = false);
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID得到下级
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
List<RoadFlow.Model.rf_dictionary> GetChilds(string id);
|
||||
|
||||
/// <summary>
|
||||
/// 根据唯一代码得到ID
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
string GetIdByCode(string code);
|
||||
|
||||
/// <summary>
|
||||
/// 得到字典根
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
RoadFlow.Model.rf_dictionary GetRoot();
|
||||
|
||||
/// <summary>
|
||||
/// 判断一个字典是否有下级字典
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
bool HasChilds(string id);
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 得到多语言标题
|
||||
/// </summary>
|
||||
/// <param name="dictionary">字典实体</param>
|
||||
/// <param name="language">语言</param>
|
||||
/// <returns></returns>
|
||||
string GetLanguageTitle(RoadFlow.Model.rf_dictionary dictionary, string language = "");
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID查询字典标题
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="language">语言</param>
|
||||
/// <returns></returns>
|
||||
string GetTitle(string id, string language = "");
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 按code获取字典项
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
RoadFlow.Model.rf_dictionary GetOneByCode(string code);
|
||||
/// <summary>
|
||||
/// 根据字符串得到ValueField
|
||||
/// </summary>
|
||||
/// <param name="valueField"></param>
|
||||
/// <returns></returns>
|
||||
public ValueField GetValueField(string valueField);
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID得到选项(返回jarray,vue项目用)
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="valueField">值字段,默认id</param>
|
||||
/// <param name="value">默认值</param>
|
||||
/// <param name="isAllChild">是否显示所有下级</param>
|
||||
/// <param name="isSelectParent">是否可以选择上级</param>
|
||||
/// <returns></returns>
|
||||
public JArray GetArrayOptionsByID(string id, ValueField valueField = ValueField.Id, string value = "", bool isAllChild = true, bool isSelectParent = true);
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID得到所有下级(控件选项)
|
||||
/// </summary>
|
||||
/// <param name="id">根节点字典id</param>
|
||||
/// <param name="valueField">值字段</param>
|
||||
/// <param name="isRoot">是否显示根节点</param>
|
||||
/// <param name="lang">标题语言</param>
|
||||
/// <returns></returns>
|
||||
public JArray GetAllChildsArray(string id, ValueField valueField, bool isRoot = false, string lang = "");
|
||||
/// <summary>
|
||||
/// 根据ID得到选项(返回jarray,vue项目用)
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="valueField">值字段,默认id</param>
|
||||
/// <param name="value">默认值</param>
|
||||
/// <param name="isAllChild">是否显示所有下级</param>
|
||||
/// <param name="isSelectParent">是否可以选择上级</param>
|
||||
/// <returns></returns>
|
||||
public JArray GetArrayComboxsByID(string id, ValueField valueField = ValueField.Id, string value = "", bool isAllChild = true, bool isSelectParent = true);
|
||||
|
||||
/// <summary>
|
||||
/// 得到单选或复选按钮组选项
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="valueField">值字段</param>
|
||||
/// <returns></returns>
|
||||
public JArray GetRadioOrCheckboxItems(string id, ValueField valueField = ValueField.Id);
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个字典下级的最大排序号
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public int GetMaxSort(string id);
|
||||
|
||||
/// <summary>
|
||||
/// 检查唯一代码是否重复
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="code"></param>
|
||||
/// <returns>true 没有重复 false 重复</returns>
|
||||
public bool CheckCode(string id, string code);
|
||||
/// <summary>
|
||||
/// 得到字典根ID
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetRootId();
|
||||
|
||||
/// <summary>
|
||||
/// 导入数据字典
|
||||
/// </summary>
|
||||
/// <param name="json"></param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
public string Import(string json, IStringLocalizer localizer = null);
|
||||
}
|
||||
}
|
||||
1218
20220330_Vote/Ewide.RoadFlow/Data/Flow/Flow.cs
Normal file
1218
20220330_Vote/Ewide.RoadFlow/Data/Flow/Flow.cs
Normal file
File diff suppressed because it is too large
Load Diff
154
20220330_Vote/Ewide.RoadFlow/Data/Flow/IFlow.cs
Normal file
154
20220330_Vote/Ewide.RoadFlow/Data/Flow/IFlow.cs
Normal file
@@ -0,0 +1,154 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IFlow:IRoadFlowRepository<Model.rf_flow>
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询一页数据
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="flowId">可管理的流程ID</param>
|
||||
/// <param name="whereLambda"></param>
|
||||
/// <param name="orderbyLambda"></param>
|
||||
/// <param name="isAsc"></param>
|
||||
/// <returns></returns>
|
||||
List<Model.rf_flow> GetPagerList(out int count, int size, int number, List<string> flowIdList, string name, List<string> types, string order, int status = -1);
|
||||
/// <summary>
|
||||
/// 得到一个用户可管理的流程
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public List<string> GetManageFlowIds(string userId);
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个用户可管理的流程
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_flow> GetManageFlow(string userId);
|
||||
|
||||
/// <summary>
|
||||
/// 得到状态显示
|
||||
/// </summary>
|
||||
/// <param name="status"></param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns></returns>
|
||||
public string GetStatusTitle(int status, IStringLocalizer localizer = null);
|
||||
|
||||
/// <summary>
|
||||
/// 保存流程
|
||||
/// </summary>
|
||||
/// <param name="json"></param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns></returns>
|
||||
public string Save(string json, IStringLocalizer localizer = null);
|
||||
/// <summary>
|
||||
/// 流程另存为
|
||||
/// </summary>
|
||||
/// <param name="flowId">流程ID</param>
|
||||
/// <param name="newFlowName">新的流程名称</param>
|
||||
/// <returns>返回guid字符串表示成功(新流程的ID),其它为错误信息</returns>
|
||||
/// <param name="localizer">语言包</param>
|
||||
public string SaveAs(string flowId, string newFlowName, IStringLocalizer localizer = null);
|
||||
|
||||
/// <summary>
|
||||
/// 安装流程
|
||||
/// </summary>
|
||||
/// <param name="json"></param>
|
||||
/// <param name="logTitle">日志标题</param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns></returns>
|
||||
public string Install(string json, IStringLocalizer localizer = null);
|
||||
/// <summary>
|
||||
/// 安装流程
|
||||
/// </summary>
|
||||
/// <param name="flow">流程实体</param>
|
||||
/// <param name="appLibrary">应用程序库实体</param>
|
||||
public int Install(Model.rf_flow flow);
|
||||
/// <summary>
|
||||
/// 卸载或作删除标记流程
|
||||
/// </summary>
|
||||
/// <param name="json"></param>
|
||||
/// <param name="logTitle">日志标题</param>
|
||||
/// <param name="status">状态,2卸载 3删除</param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns></returns>
|
||||
public string UnInstall(string json, int status, IStringLocalizer localizer = null);
|
||||
|
||||
/// <summary>
|
||||
/// 得到流程运行时实体
|
||||
/// </summary>
|
||||
/// <param name="json">流程设置JSON</param>
|
||||
/// <param name="errMsg">加载错误时的错误信息</param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns></returns>
|
||||
|
||||
public Model.FlowRun GetFlowRunModel(string json, out string errMsg, IStringLocalizer localizer = null);
|
||||
|
||||
/// <summary>
|
||||
/// 查询一个流程
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public Model.rf_flow Get(string id);
|
||||
|
||||
/// <summary>
|
||||
/// 导入流程
|
||||
/// </summary>
|
||||
/// <param name="json"></param>
|
||||
/// <param name="createFormFile">是否要创建表单文件,VUE导入时不需要创建</param>
|
||||
/// <returns>返回1表示成功,其它为错误信息</returns>
|
||||
public string ImportFlow(string json, bool createFormFile = true);
|
||||
/// <summary>
|
||||
/// 查询一页数据
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="flowIdList"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="status">状态-1表示查询未删除的流程</param>
|
||||
/// <returns></returns>
|
||||
List<Model.rf_flow> GetPagerList(out int count, int size, int number, List<string> flowIdList, string name, string type, string order, int status = -1);
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个用户可以发起的流程运行时实体列表
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.FlowRun> GetStartFlows(string userId);
|
||||
|
||||
/// <summary>
|
||||
/// 得到流程运行时实体
|
||||
/// </summary>
|
||||
/// <param name="id">流程ID</param>
|
||||
/// <param name="isCache">是否从缓存中取</param>
|
||||
/// <param name="currentTask">当前任务实体(动态步骤时要取动态的步骤流程运行时实体)</param>
|
||||
/// <returns></returns>
|
||||
public Model.FlowRun GetFlowRunModel(string id, bool isCache = true, RoadFlow.Model.rf_flowtask currentTask = null);
|
||||
/// <summary>
|
||||
/// 得到一个步骤的所有后续步骤集合
|
||||
/// </summary>
|
||||
/// <param name="flowRunModel"></param>
|
||||
/// <param name="stepId"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.FlowRunModel.Step> GetAllNextSteps(Model.FlowRun flowRunModel, Guid stepId);
|
||||
/// <summary>
|
||||
/// 得到一个用户可管理实例的流程
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public List<string> GetManageInstanceFlowIds(string userId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Furion.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class FlowApiSystem:RoadFlowRepository<RoadFlow.Model.rf_flowapisystem>,IFlowApiSystem, ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 删除一批系统
|
||||
/// </summary>
|
||||
/// <param name="flowApiSystems">系统实体</param>
|
||||
/// <returns></returns>
|
||||
public int Delete(Model.rf_flowapisystem[] flowApiSystems)
|
||||
{
|
||||
ClearCache();
|
||||
List<string> ids = new List<string>();
|
||||
foreach (var obj in flowApiSystems)
|
||||
ids.Add(obj.Id);
|
||||
return this.DeleteBy(x => ids.Contains(x.Id));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IFlowApiSystem: IRoadFlowRepository<RoadFlow.Model.rf_flowapisystem>
|
||||
{
|
||||
/// <summary>
|
||||
/// 删除一批系统
|
||||
/// </summary>
|
||||
/// <param name="flowApiSystems">系统实体</param>
|
||||
/// <returns></returns>
|
||||
int Delete(Model.rf_flowapisystem[] flowApiSystems);
|
||||
}
|
||||
}
|
||||
31
20220330_Vote/Ewide.RoadFlow/Data/FlowArchive/FlowArchive.cs
Normal file
31
20220330_Vote/Ewide.RoadFlow/Data/FlowArchive/FlowArchive.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Furion.DependencyInjection;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class FlowArchive: RoadFlowRepository<RoadFlow.Model.rf_flowarchive>, IFlowArchive, ITransient
|
||||
{
|
||||
public List<Model.rf_flowarchive> GetPagerData(out int count, int size, int number, string flowId, string stepName, string title, string date1, string date2, string order)
|
||||
{
|
||||
|
||||
int total=0;
|
||||
var rtn = db.Queryable<Model.rf_flowarchive>()
|
||||
.WhereIF(flowId.IsGuid(), x => x.FlowId == flowId)
|
||||
.WhereIF(!stepName.IsNullOrWhiteSpace(), x => x.StepName.Contains(stepName))
|
||||
.WhereIF(!title.IsNullOrWhiteSpace(), x => x.Title.Contains(title))
|
||||
.WhereIF(date1.IsDateTime(out DateTime dt1), x => x.WriteTime >= dt1)
|
||||
.WhereIF(date2.IsDateTime(out DateTime dt2), x => x.WriteTime >= dt2)
|
||||
.OrderByIF(!order.IsNullOrWhiteSpace(), order.FilterSelectSql())
|
||||
.ToPageList(number, size, ref total).ToList();
|
||||
count = total;
|
||||
return rtn;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IFlowArchive: IRoadFlowRepository<RoadFlow.Model.rf_flowarchive>
|
||||
{
|
||||
public List<Model.rf_flowarchive> GetPagerData(out int count, int size, int number, string flowId, string stepName, string title, string date1, string date2, string order);
|
||||
|
||||
}
|
||||
}
|
||||
55
20220330_Vote/Ewide.RoadFlow/Data/FlowButton/FlowButton.cs
Normal file
55
20220330_Vote/Ewide.RoadFlow/Data/FlowButton/FlowButton.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Furion.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class FlowButton:RoadFlowRepository<RoadFlow.Model.rf_flowbutton>,IFlowButton, ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 得到一个按钮
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public Model.rf_flowbutton Get(string id)
|
||||
{
|
||||
return GetOneById(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到按钮显示标题(多语言时)
|
||||
/// </summary>
|
||||
/// <param name="language">语言</param>
|
||||
/// <param name="flowButton">按钮实体</param>
|
||||
/// <param name="note">输出备注</param>
|
||||
/// <returns></returns>
|
||||
public string GetLanguageTitle(Model.rf_flowbutton flowButton, out string note, string language = "zh-CN")
|
||||
{
|
||||
note = string.Empty;
|
||||
if (null == flowButton)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
string title;
|
||||
switch (language)
|
||||
{
|
||||
case "en-US":
|
||||
title = flowButton.Title_en;
|
||||
note = flowButton.Note_en;
|
||||
break;
|
||||
case "zh":
|
||||
title = flowButton.Title_zh;
|
||||
note = flowButton.Note_zh;
|
||||
break;
|
||||
default:
|
||||
title = flowButton.Title;
|
||||
note = flowButton.Note;
|
||||
break;
|
||||
}
|
||||
return title;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
20220330_Vote/Ewide.RoadFlow/Data/FlowButton/IFlowButton.cs
Normal file
26
20220330_Vote/Ewide.RoadFlow/Data/FlowButton/IFlowButton.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IFlowButton:IRoadFlowRepository<RoadFlow.Model.rf_flowbutton>
|
||||
{
|
||||
/// <summary>
|
||||
/// 得到一个按钮
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public Model.rf_flowbutton Get(string id);
|
||||
/// <summary>
|
||||
/// 得到按钮显示标题(多语言时)
|
||||
/// </summary>
|
||||
/// <param name="language">语言</param>
|
||||
/// <param name="flowButton">按钮实体</param>
|
||||
/// <param name="note">输出备注</param>
|
||||
/// <returns></returns>
|
||||
public string GetLanguageTitle(Model.rf_flowbutton flowButton, out string note, string language = "zh-CN");
|
||||
}
|
||||
}
|
||||
47
20220330_Vote/Ewide.RoadFlow/Data/FlowComment/FlowComment.cs
Normal file
47
20220330_Vote/Ewide.RoadFlow/Data/FlowComment/FlowComment.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using Furion.DependencyInjection;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class FlowComment:RoadFlowRepository<RoadFlow.Model.rf_flowcomment>,IFlowComment, ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 得到一个用户可以使用的意见
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_flowcomment> GetListByUserId(string userId)
|
||||
{
|
||||
var all = GetAll();
|
||||
return all.FindAll(p => p.UserId == string.Empty || p.UserId == userId).Distinct(new Model.rf_flowcomment()).OrderBy(p => p.AddType).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询一页数据
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="comment"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_flowcomment> GetPagerList(out int count, int size, int number, string comment, string userId, string order)
|
||||
{
|
||||
int total = 0;
|
||||
var rtn =db.Queryable<Model.rf_flowcomment>()
|
||||
.WhereIF(!comment.IsNullOrWhiteSpace(), x => x.Comments.Contains(comment))
|
||||
.WhereIF(userId.IsGuid(), x => x.UserId == userId)
|
||||
.OrderByIF(!order.IsNullOrWhiteSpace(), order)
|
||||
.ToPageList(number, size, ref total);
|
||||
count = total;
|
||||
return rtn;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IFlowComment : IRoadFlowRepository<RoadFlow.Model.rf_flowcomment>
|
||||
{
|
||||
/// <summary>
|
||||
/// 得到一个用户可以使用的意见
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_flowcomment> GetListByUserId(string userId);
|
||||
|
||||
/// <summary>
|
||||
/// 查询一页数据
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="comment"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_flowcomment> GetPagerList(out int count, int size, int number, string comment, string userId, string order);
|
||||
}
|
||||
}
|
||||
211
20220330_Vote/Ewide.RoadFlow/Data/FlowDynamic/FlowDynamic.cs
Normal file
211
20220330_Vote/Ewide.RoadFlow/Data/FlowDynamic/FlowDynamic.cs
Normal file
@@ -0,0 +1,211 @@
|
||||
using Ewide.Core;
|
||||
using Furion.DependencyInjection;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class FlowDynamic:RoadFlowRepository<RoadFlow.Model.rf_flowdynamic>,IFlowDynamic, ITransient
|
||||
{
|
||||
private readonly IUserManager _userManager = Furion.App.GetService<IUserManager>();
|
||||
/// <summary>
|
||||
/// 查询一个动态流程
|
||||
/// </summary>
|
||||
/// <param name="StepId">动态步骤ID</param>
|
||||
/// <param name="groupId">组ID</param>
|
||||
/// <returns></returns>
|
||||
public Model.rf_flowdynamic Get(string StepId, string groupId)
|
||||
{
|
||||
return GetOneBy(p => p.StepId == StepId && p.GroupId == groupId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加动态流程
|
||||
/// </summary>
|
||||
/// <param name="executeModel">流程执行参数实体</param>
|
||||
/// <param name="groupTasks">当前组任务List</param>
|
||||
/// <returns></returns>
|
||||
public Model.FlowRun Add(Model.FlowRunModel.Execute executeModel, List<Model.rf_flowtask> groupTasks)
|
||||
{
|
||||
if (null == executeModel || executeModel.GroupId.IsEmptyGuid())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string oldFlowJSON = string.Empty;
|
||||
if (groupTasks != null && groupTasks.Count > 0 && groupTasks.Exists(p => p.BeforeStepId.IsNotEmptyGuid()))
|
||||
{
|
||||
var flowDynamicModel = new FlowDynamic().Get(groupTasks.OrderByDescending(p => p.Sort).Where(p => p.BeforeStepId.IsNotEmptyGuid()).First().BeforeStepId, executeModel.GroupId.ToString());
|
||||
if (null != flowDynamicModel)
|
||||
{
|
||||
oldFlowJSON = flowDynamicModel.FlowJSON;
|
||||
}
|
||||
}
|
||||
if (oldFlowJSON.IsNullOrWhiteSpace())
|
||||
{
|
||||
var flowModel = new Flow().Get(executeModel.FlowId.ToString());
|
||||
if (null != flowModel)
|
||||
{
|
||||
oldFlowJSON = flowModel.RunJSON.IsNullOrWhiteSpace() ? flowModel.DesignerJSON : flowModel.RunJSON;
|
||||
}
|
||||
}
|
||||
if (oldFlowJSON.IsNullOrWhiteSpace())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
JObject jObject = null;
|
||||
try
|
||||
{
|
||||
jObject = JObject.Parse(oldFlowJSON);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (!jObject.ContainsKey("steps"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var stepArray = jObject.Value<JArray>("steps");
|
||||
var lineArray = jObject.Value<JArray>("lines");
|
||||
var steps = executeModel.Steps.FindAll(p => p.beforeStepId.IsNotEmptyGuid()).GroupBy(p => p.beforeStepId).ToList();
|
||||
string flowJSON = string.Empty;
|
||||
UserDummy buser = new UserDummy();
|
||||
foreach (var step in steps)
|
||||
{
|
||||
int stepIndex = 0;
|
||||
foreach (var (stepId, stepName, beforeStepId, parallelorserial, receiveUsers, completedTime) in step)
|
||||
{
|
||||
var oldStepJsons = stepArray.Where(p => p["id"].ToString().EqualsIgnoreCase(beforeStepId.Value.ToString()));
|
||||
if (oldStepJsons.Count() == 0)
|
||||
{
|
||||
stepIndex++;
|
||||
continue;
|
||||
}
|
||||
var oldStepJson = oldStepJsons.First();
|
||||
if (stepId != beforeStepId)
|
||||
{
|
||||
var stepJson = oldStepJson.DeepClone();
|
||||
stepJson["id"] = stepId;
|
||||
stepJson["name"] = stepName;
|
||||
stepJson["dynamic"] = 0;
|
||||
stepJson["behavior"]["runSelect"] = 0;
|
||||
stepJson["behavior"]["defaultHandler"] = buser.GetUserIds(receiveUsers);
|
||||
stepJson["position"]["y"] = stepJson["position"]["y"].ToString().ToInt() + (70 * stepIndex);
|
||||
stepArray.Add(stepJson);
|
||||
}
|
||||
else
|
||||
{
|
||||
oldStepJson["dynamic"] = 0;
|
||||
oldStepJson["behavior"]["runSelect"] = 0;
|
||||
oldStepJson["behavior"]["defaultHandler"] = buser.GetUserIds(receiveUsers);
|
||||
}
|
||||
//如果是串行
|
||||
if (parallelorserial.HasValue && parallelorserial.Value == 1)
|
||||
{
|
||||
if (stepIndex == step.Count() - 1)
|
||||
{
|
||||
var oldLines = lineArray.Where(p => p["from"].ToString().EqualsIgnoreCase(beforeStepId.Value.ToString()));
|
||||
if (oldLines.Any())
|
||||
{
|
||||
var lineJson = oldLines.First().DeepClone();
|
||||
lineJson["id"] = GuidExtensions.NewGuid().ToString();
|
||||
lineJson["to"] = step.ElementAt(stepIndex).stepId.ToString();
|
||||
lineJson["from"] = stepIndex == 0 ? beforeStepId.Value.ToString() : step.ElementAt(stepIndex - 1).stepId.ToString();
|
||||
if (stepId != beforeStepId)
|
||||
{
|
||||
lineArray.Add(lineJson);
|
||||
}
|
||||
if (!step.Where(p => p.stepId == oldLines.First()["to"].ToString().ToGuid()).Any())
|
||||
{
|
||||
oldLines.First()["from"] = step.Last().stepId.ToString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var oldLines1 = lineArray.Where(p => p["to"].ToString().EqualsIgnoreCase(beforeStepId.Value.ToString()));
|
||||
if (oldLines1.Any())
|
||||
{
|
||||
var lineJson = oldLines1.First().DeepClone();
|
||||
lineJson["id"] = GuidExtensions.NewGuid().ToString();
|
||||
lineJson["to"] = step.ElementAt(stepIndex).stepId.ToString();
|
||||
lineJson["from"] = stepIndex == 0 ? beforeStepId.Value.ToString() : step.ElementAt(stepIndex - 1).stepId.ToString();
|
||||
if (stepId != beforeStepId)
|
||||
{
|
||||
lineArray.Add(lineJson);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var oldLines = lineArray.Where(p => p["to"].ToString().EqualsIgnoreCase(beforeStepId.Value.ToString()));
|
||||
if (oldLines.Any())
|
||||
{
|
||||
var lineJson = oldLines.First().DeepClone();
|
||||
lineJson["id"] = GuidExtensions.NewGuid().ToString();
|
||||
lineJson["from"] = stepIndex == 0 ? beforeStepId.Value.ToString() : step.ElementAt(stepIndex - 1).stepId.ToString();
|
||||
lineJson["to"] = step.ElementAt(stepIndex).stepId.ToString();
|
||||
if (stepId != beforeStepId)
|
||||
{
|
||||
lineArray.Add(lineJson);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//并行
|
||||
else
|
||||
{
|
||||
var oldLines = lineArray.Where(p => p["to"].ToString().EqualsIgnoreCase(beforeStepId.Value.ToString()) && p["from"].ToString().EqualsIgnoreCase(executeModel.StepId.ToString()));
|
||||
if (oldLines.Any())
|
||||
{
|
||||
var lineJson = oldLines.First().DeepClone();
|
||||
lineJson["id"] = GuidExtensions.NewGuid().ToString();
|
||||
lineJson["to"] = stepId;
|
||||
if (stepId != beforeStepId)
|
||||
{
|
||||
lineArray.Add(lineJson);
|
||||
}
|
||||
}
|
||||
var oldLines1 = lineArray.Where(p => p["from"].ToString().EqualsIgnoreCase(beforeStepId.Value.ToString()));
|
||||
int j = oldLines1.Count();
|
||||
for (int i = 0; i < j; i++)
|
||||
{
|
||||
var lineJson = oldLines1.ElementAt(i).DeepClone();
|
||||
lineJson["id"] = GuidExtensions.NewGuid().ToString();
|
||||
lineJson["from"] = stepId;
|
||||
if (stepId != beforeStepId)
|
||||
{
|
||||
lineArray.Add(lineJson);
|
||||
}
|
||||
}
|
||||
}
|
||||
stepIndex++;
|
||||
}
|
||||
var dynamicModel = Get(step.Key.Value.ToString(), executeModel.GroupId.ToString());
|
||||
string json = jObject.ToString(Newtonsoft.Json.Formatting.None);
|
||||
if (null == dynamicModel)
|
||||
{
|
||||
dynamicModel = new Model.rf_flowdynamic() { StepId = step.Key.Value.ToString(), GroupId = executeModel.GroupId.ToString(), FlowJSON = json };
|
||||
Add(dynamicModel);
|
||||
}
|
||||
else
|
||||
{
|
||||
dynamicModel.FlowJSON = json;
|
||||
Update(dynamicModel);
|
||||
}
|
||||
_memoryCache.Remove("roadflow_cache_" + typeof(RoadFlow.Model.rf_flow).FullName + "_" + dynamicModel.StepId + "_" + dynamicModel.GroupId);
|
||||
if (step.Key == steps.Last().Key)
|
||||
{
|
||||
flowJSON = json;
|
||||
}
|
||||
}
|
||||
return new Flow().GetFlowRunModel(flowJSON, out string msg);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IFlowDynamic:IRoadFlowRepository<RoadFlow.Model.rf_flowdynamic>
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询一个动态流程
|
||||
/// </summary>
|
||||
/// <param name="StepId">动态步骤ID</param>
|
||||
/// <param name="groupId">组ID</param>
|
||||
/// <returns></returns>
|
||||
public Model.rf_flowdynamic Get(string StepId, string groupId);
|
||||
|
||||
/// <summary>
|
||||
/// 添加动态流程
|
||||
/// </summary>
|
||||
/// <param name="executeModel">流程执行参数实体</param>
|
||||
/// <param name="groupTasks">当前组任务List</param>
|
||||
/// <returns></returns>
|
||||
public Model.FlowRun Add(Model.FlowRunModel.Execute executeModel, List<Model.rf_flowtask> groupTasks);
|
||||
}
|
||||
}
|
||||
52
20220330_Vote/Ewide.RoadFlow/Data/FlowEntrust/FlowEntrust.cs
Normal file
52
20220330_Vote/Ewide.RoadFlow/Data/FlowEntrust/FlowEntrust.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Ewide.Core;
|
||||
using Furion.DependencyInjection;
|
||||
using RoadFlow.Model.FlowRunModel;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class FlowEntrust : RoadFlowRepository<RoadFlow.Model.rf_flowentrust>, IFlowEntrust, ITransient
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询一页数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<RoadFlow.Model.rf_flowentrust> GetPagerList(out int count, int size, int number, string userId, string date1, string date2, string order)
|
||||
{
|
||||
int total = 0;
|
||||
var list = this.db.Queryable<RoadFlow.Model.rf_flowentrust>()
|
||||
.WhereIF(userId.IsGuid(), x => x.UserId == userId)
|
||||
.WhereIF(date1.IsDateTime(), x => x.StartTime >= DateTime.Parse(date1))
|
||||
.WhereIF(date2.IsDateTime(), x => x.EndTime <= DateTime.Parse(date2))
|
||||
.OrderByIF(!order.IsNullOrEmpty(), order)
|
||||
.ToPageList(number, size,ref total);
|
||||
count = total;
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个人员一个流程的委托人员(如果没有则返回string.Empty)
|
||||
/// </summary>
|
||||
/// <param name="flowId">流程ID</param>
|
||||
/// <param name="user">人员实体</param>
|
||||
/// <returns>如果没有委托则返回string.Empty</returns>
|
||||
public string GetEntrustUserId(string flowId, SysUser user)
|
||||
{
|
||||
var all = GetAll();
|
||||
DateTime now = Utility.DateExtensions.Now;
|
||||
var entrust = all.Find(p => p.UserId == user.Id && (!p.FlowId.IsNullOrWhiteSpace() || p.FlowId == flowId) &&
|
||||
p.StartTime <= now && p.EndTime >= now);
|
||||
return null == entrust ? string.Empty : entrust.ToUserId;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IFlowEntrust : IRoadFlowRepository<RoadFlow.Model.rf_flowentrust>
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询一页数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<RoadFlow.Model.rf_flowentrust> GetPagerList(out int count, int size, int number, string userId, string date1, string date2, string order);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
43
20220330_Vote/Ewide.RoadFlow/Data/FlowReceive/FlowReceive.cs
Normal file
43
20220330_Vote/Ewide.RoadFlow/Data/FlowReceive/FlowReceive.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Furion.DependencyInjection;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class FlowReceive: RoadFlowRepository<RoadFlow.Model.rf_flowreceive>, IFlowReceive, ITransient
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 查询一个流程一个步骤的上一次处理人
|
||||
/// </summary>
|
||||
/// <param name="flowId">流程id</param>
|
||||
/// <param name="stepId">步骤id</param>
|
||||
/// <param name="SenderId">发送人</param>
|
||||
/// <returns></returns>
|
||||
public string GetPrevMembers(string flowId, string stepId, string SenderId)
|
||||
{
|
||||
//SELECT Members FROM RF_FlowReceive WHERE FlowId = @FlowId AND StepId = @StepId AND SenderId = @SenderId ORDER BY SendTime DESC LIMIT 1
|
||||
return GetListBy(x => x.FlowId == flowId && x.StepId == stepId && x.SenderId == SenderId)
|
||||
.OrderByDescending(x => x.SendTime).Take(1).ToList()[0].Members;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 批量添加
|
||||
/// </summary>
|
||||
/// <param name="flowReceive">实体类</param>
|
||||
/// <returns></returns>
|
||||
public int AddRange(List<Model.rf_flowreceive> flowReceives)
|
||||
{
|
||||
return AddRangeList(flowReceives);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IFlowReceive : IRoadFlowRepository<RoadFlow.Model.rf_flowreceive>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
5449
20220330_Vote/Ewide.RoadFlow/Data/FlowTask/FlowTask.cs
Normal file
5449
20220330_Vote/Ewide.RoadFlow/Data/FlowTask/FlowTask.cs
Normal file
File diff suppressed because it is too large
Load Diff
254
20220330_Vote/Ewide.RoadFlow/Data/FlowTask/IFlowTask.cs
Normal file
254
20220330_Vote/Ewide.RoadFlow/Data/FlowTask/IFlowTask.cs
Normal file
@@ -0,0 +1,254 @@
|
||||
using Ewide.Core;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IFlowTask : IRoadFlowRepository<RoadFlow.Model.rf_flowtask>
|
||||
{
|
||||
// <summary>
|
||||
/// 根据组ID查询列表
|
||||
/// </summary>
|
||||
/// <param name="groupId"></param>
|
||||
/// <returns></returns>
|
||||
List<Model.rf_flowtask> GetListByGroupId(string groupId);
|
||||
/// <summary>
|
||||
/// 得到获取动态步骤的任务实体
|
||||
/// </summary>
|
||||
/// <param name="groupId">组ID</param>
|
||||
/// <param name="taskId">当前任务ID,如果为空,则返回的Model.FlowTask当前任务实体也为空</param>
|
||||
/// <returns>(动态任务, 当前任务, 任务组List)</returns>
|
||||
public (Model.rf_flowtask, Model.rf_flowtask, List<Model.rf_flowtask>) GetDynamicTask(string groupId, string? taskId = null);
|
||||
/// <summary>
|
||||
/// 判断人员是否可以打开任务
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns>返回 -1表示不能打开 0任务为空 1任务处理人 2实例管理人</returns>
|
||||
public int IsOpenTask(string userId, Model.rf_flowtask flowTaskModel, Model.FlowRun flowRunModel = null);
|
||||
/// <summary>
|
||||
/// 更新状态
|
||||
/// </summary>
|
||||
/// <param name="taskId">任务id</param>
|
||||
/// <param name="status">状态</param>
|
||||
/// <param name="executeType">处理类型 int.MinValue表示不更新</param>
|
||||
/// <param name="openTime">打开时间 null表示不更新</param>
|
||||
/// <returns></returns>
|
||||
public int UpdateStatus(string taskId, int status, int executeType = int.MinValue, DateTime? openTime = null);
|
||||
|
||||
/// <summary>
|
||||
/// 判断一个任务是否可以催办
|
||||
/// </summary>
|
||||
/// <param name="flowTask"></param>
|
||||
/// <param name="isWithdraw">是否可以收回</param>
|
||||
/// <returns>isWithdraw 是否可以收回</returns>
|
||||
public bool IsHasten(string taskId, out bool isWithdraw);
|
||||
|
||||
/// <summary>
|
||||
/// 得到当前任务的后续接收步骤选择HTML
|
||||
/// </summary>
|
||||
/// <param name="flowRunModel">流程运行时实体</param>
|
||||
/// <param name="stepId">步骤ID</param>
|
||||
/// <param name="groupId">组ID</param>
|
||||
/// <param name="taskId">任务ID</param>
|
||||
/// <param name="instanceId">实例ID</param>
|
||||
/// <param name="userId">当前人员ID</param>
|
||||
/// <param name="sendSteps">可以发送的步骤</param>
|
||||
/// <param name="isFreeSend">是否是自由发送</param>
|
||||
/// <param name="isMobile">是否是移动端</param>
|
||||
/// <param name="groupTasks">组任务集合,为空则在方法中查询</param>
|
||||
/// <param name="localizer">多语言包</param>
|
||||
/// <returns>步骤选择html, 提醒信息, 可以发送的步骤集合</returns>
|
||||
public (string html, string message, List<Model.FlowRunModel.Step> sendSteps) GetNextSteps(Model.FlowRun flowRunModel, Guid stepId, string groupId, string taskId, string instanceId, string userId, bool isFreeSend, bool isMobile = false, List<Model.rf_flowtask> groupTasks = null, IStringLocalizer localizer = null);
|
||||
|
||||
/// <summary>
|
||||
/// 从字段值得到动态步骤
|
||||
/// <para>字段值格式:{flowtype:0 流转类型0并且 1串行,runedit:0 是否运行时编辑,steps:[{name:'test1',members:'u_EB03262C-AB60-4BC6-A4C0-96E66A4229FE'},{name:'test2',members:'u_954DC69A-30FF-4484-9234-3C9272B6893F'}]}</para>
|
||||
/// </summary>
|
||||
/// <param name="flowRunModel"></param>
|
||||
/// <param name="step"></param>
|
||||
/// <param name="instanceId"></param>
|
||||
/// <returns></returns>
|
||||
public JObject GetDynamicStepFromFieldValue(Model.FlowRun flowRunModel, Model.FlowRunModel.Step step, string instanceId);
|
||||
|
||||
/// <summary>
|
||||
/// 抄送任务
|
||||
/// </summary>
|
||||
/// <param name="currentTask">当前任务</param>
|
||||
/// <param name="users">接收人</param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns>返回1表示成功,其它为错误信息</returns>
|
||||
public string CopyFor(Model.rf_flowtask currentTask, List<SysUser> users, IStringLocalizer localizer = null);
|
||||
/// <summary>
|
||||
/// 征求意见
|
||||
/// </summary>
|
||||
/// <param name="currentTask"></param>
|
||||
/// <param name="users"></param>
|
||||
/// <param name="visibility">意见可见性 20自己可见 21流程参与人可见</param>
|
||||
/// <param name="note">备注</param>
|
||||
/// <returns></returns>
|
||||
public string SolicitOpinion(Model.rf_flowtask currentTask, List<SysUser> users, int visibility, string note = "", IStringLocalizer localizer = null);
|
||||
|
||||
/// <summary>
|
||||
/// 查询待办事项
|
||||
/// </summary>
|
||||
/// <param name="flowId"></param>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="startDate"></param>
|
||||
/// <param name="endDate"></param>
|
||||
/// <param name="isBatch">是否批量 0不是,1是</param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_flowtask> GetWaitTask(int size, int number, string userId, string flowId, string title, string startDate, string endDate, string order, out int count, int isBatch = 0);
|
||||
|
||||
/// <summary>
|
||||
/// 判断一个任务是否可以作废
|
||||
/// </summary>
|
||||
/// <param name="taskId"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsDelete(string taskId, Model.FlowRun flowRunModel = null);
|
||||
|
||||
/// <summary>
|
||||
/// 得到任务类型标题
|
||||
/// </summary>
|
||||
/// <param name="taskType">任务类型</param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns></returns>
|
||||
public string GetTaskTypeTitle(int taskType, IStringLocalizer localizer = null);
|
||||
/// <summary>
|
||||
/// 查询已办事项
|
||||
/// </summary>
|
||||
/// <param name="flowId"></param>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="startDate"></param>
|
||||
/// <param name="endDate"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_flowtask> GetCompletedTask(int size, int number, string userId, string flowId, string title, string startDate, string endDate, string order, out int count);
|
||||
|
||||
/// <summary>
|
||||
/// 查询我发起的流程
|
||||
/// </summary>
|
||||
/// <param name="flowId"></param>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="startDate"></param>
|
||||
/// <param name="endDate"></param>
|
||||
/// <param name="status">""全部 "0"未完成 "1" 已完成</param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_flowtask> GetMyStartList(int size, int number, string userId, string flowId, string title, string startDate, string endDate, string status, string order, out int count);
|
||||
|
||||
/// <summary>
|
||||
/// 查询已委托事项
|
||||
/// </summary>
|
||||
/// <param name="flowId"></param>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="startDate"></param>
|
||||
/// <param name="endDate"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_flowtask> GetEntrustTask(int size, int number, string userId, string flowId, string title, string startDate, string endDate, string order, out int count);
|
||||
|
||||
/// <summary>
|
||||
/// 得到处理类别显示标题
|
||||
/// </summary>
|
||||
/// <param name="executeType"></param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns></returns>
|
||||
public string GetExecuteTypeTitle(int executeType, IStringLocalizer localizer = null);
|
||||
|
||||
/// <summary>
|
||||
/// 自动执行一个任务
|
||||
/// </summary>
|
||||
/// <param name="taskId"></param>
|
||||
/// <param name="type">执行类型</param>
|
||||
/// <param name="comment">处理意见</param>
|
||||
/// <returns></returns>
|
||||
public Model.FlowRunModel.ExecuteResult AutoSubmit(Guid taskId, string type = "submit", string comment = "");
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="flowTaskModels">任务实体</param>
|
||||
/// <returns></returns>
|
||||
public int DeleteByGroupId(string groupid);
|
||||
/// <summary>
|
||||
/// 更新任务
|
||||
/// </summary>
|
||||
/// <param name="removeTasks">要删除的列表</param>
|
||||
/// <param name="updateTasks">要更新的列表</param>
|
||||
/// <param name="addTasks">要添加的列表</param>
|
||||
/// <param name="executeSqls">要执行的sql列表(sql,参数,0提交退回前 1提交退回后)</param>
|
||||
/// <returns></returns>
|
||||
public int Update(List<Model.rf_flowtask> removeTasks, List<Model.rf_flowtask> updateTasks, List<Model.rf_flowtask> addTasks, List<(string, object[], int)> executeSqls);
|
||||
|
||||
/// <summary>
|
||||
/// 发送待办消息
|
||||
/// </summary>
|
||||
/// <param name="nextTasks"></param>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="sendModel">发送方式 0站内短信 1手机短信 2微信 3公众号 4邮件</param>
|
||||
/// <param name="contents">消息内容</param>
|
||||
public void SendMessage(List<Model.rf_flowtask> nextTasks, SysUser sender, string sendModel = "", string contents = "", IStringLocalizer localizer = null);
|
||||
|
||||
/// <summary>
|
||||
/// 判断人员是否可以查看处理过程
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="groupTasks">组任务列表</param>
|
||||
/// <returns>返回 -1表示不能打开 1任务参与人 2实例管理人</returns>
|
||||
public int IsOpenProcess(string userId, List<Model.rf_flowtask> groupTasks, Model.FlowRun flowRunModel = null);
|
||||
/// <summary>
|
||||
/// 得到步骤由流程处理人设置的后续步骤处理人员
|
||||
/// </summary>
|
||||
/// <param name="groupTasks">实例组列表</param>
|
||||
/// <returns></returns>
|
||||
public Dictionary<Guid, string> GetNextStepsHandle(List<Model.rf_flowtask> groupTasks);
|
||||
/// <summary>
|
||||
/// 根据子流程组ID查询主流程任务
|
||||
/// </summary>
|
||||
/// <param name="groupId"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_flowtask> GetListBySubFlowGroupId(string groupId);
|
||||
/// <summary>
|
||||
/// 查询实例列表
|
||||
/// </summary>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="flowId"></param>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="receiveId"></param>
|
||||
/// <param name="receiveDate1"></param>
|
||||
/// <param name="receiveDate2"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_flowtask> GetInstanceList(int size, int number, string flowId, string title, string receiveId, string receiveDate1, string receiveDate2, string order, out int count);
|
||||
|
||||
/// <summary>
|
||||
/// 指派任务
|
||||
/// </summary>
|
||||
/// <param name="currentTask">当前任务</param>
|
||||
/// <param name="users">要指派的人员</param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns>返回1表示成功,其它为错误信息</returns>
|
||||
public string Designate(Model.rf_flowtask currentTask, List<SysUser> users, IStringLocalizer localizer = null);
|
||||
/// <summary>
|
||||
/// 跳转任务
|
||||
/// </summary>
|
||||
/// <param name="currentTask">当前任务</param>
|
||||
/// <param name="steps">要跳转到的步骤</param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns>返回1表示成功,其它为错误信息</returns>
|
||||
public string GoTo(Model.rf_flowtask currentTask, Dictionary<Guid, List<SysUser>> steps, IStringLocalizer localizer = null);
|
||||
/// <summary>
|
||||
/// 根据JSON字符串参数执行流程
|
||||
/// </summary>
|
||||
/// <param name="json">
|
||||
/// <para>{id:'任务id',flowId:'流程ID',instanceId:'实例id',title:'任务标题',comment:'处理意见',type:'处理类型',note:'备注',</para>
|
||||
/// <para> senderId:'发送人id',sign:'是否签章 0|1',steps:[{id:'接收步骤id',name:'接收步骤名称',member:'接收人',completedtime:'要求完成时间'}]}</para>
|
||||
/// </param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns></returns>
|
||||
public Model.FlowRunModel.ExecuteResult ExecuteFromJSON(string json, IStringLocalizer localizer = null);
|
||||
}
|
||||
}
|
||||
1324
20220330_Vote/Ewide.RoadFlow/Data/Form/Form.cs
Normal file
1324
20220330_Vote/Ewide.RoadFlow/Data/Form/Form.cs
Normal file
File diff suppressed because it is too large
Load Diff
146
20220330_Vote/Ewide.RoadFlow/Data/Form/IForm.cs
Normal file
146
20220330_Vote/Ewide.RoadFlow/Data/Form/IForm.cs
Normal file
@@ -0,0 +1,146 @@
|
||||
using Ewide.Core;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IForm : IRoadFlowRepository<RoadFlow.Model.rf_form>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取表单运行时HTML
|
||||
/// </summary>
|
||||
/// <param name="formId">表单ID</param>
|
||||
/// <param name="attrJson">预览表单时传</param>
|
||||
/// <param name="eventJson">预览表单时传</param>
|
||||
/// <returns>表单相关属性json</returns>
|
||||
public JObject GetRunJObject(string formId, string attrJson = "", string eventJson = "");
|
||||
/// <summary>
|
||||
/// 根据字符串表达式得到选项
|
||||
/// </summary>
|
||||
/// <param name="expression">选项文本1,选项值1;选项文本2,选项值2</param>
|
||||
/// <returns></returns>
|
||||
public string GetOptionsByStringExpression(string expression, string defaultValue = "");
|
||||
/// <summary>
|
||||
/// 查询表单数据
|
||||
/// </summary>
|
||||
/// <param name="connId"></param>
|
||||
/// <param name="tableName"></param>
|
||||
/// <param name="primaryKey"></param>
|
||||
/// <param name="taskId"></param>
|
||||
/// <param name="flowId"></param>
|
||||
/// <param name="formatJSON"></param>
|
||||
/// <param name="fieldStatusJSON"></param>
|
||||
/// <param name="groupId">动态步骤模式时用于获取步骤字段状态</param>
|
||||
/// <returns></returns>
|
||||
public string GetFormData(string connId, string tableName, string primaryKey, string instanceId, string stepId, string flowId, string formatJSON, out string fieldStatusJSON, string groupId = "");
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个连接SQL的数据表JArray
|
||||
/// </summary>
|
||||
/// <param name="connId"></param>
|
||||
/// <param name="sql"></param>
|
||||
/// <returns>(rows, cols)</returns>
|
||||
public (JArray, JArray) GetDataTablJArray(string connId, string sql);
|
||||
|
||||
/// <summary>
|
||||
/// 得到子表行数据
|
||||
/// </summary>
|
||||
/// <param name="jObject"></param>
|
||||
/// <param name="connId">连接id</param>
|
||||
/// <param name="instanceId">实例id</param>
|
||||
/// <returns></returns>
|
||||
public JArray GetSubTableJarray(JObject jObject, string connId, string instanceId);
|
||||
|
||||
/// <summary>
|
||||
/// 得到子表默认值json
|
||||
/// </summary>
|
||||
/// <param name="jObject"></param>
|
||||
/// <returns></returns>
|
||||
public JArray GetSubTableDefaultValueJArray(JArray jArray, SysUser userModel = null);
|
||||
|
||||
/// <summary>
|
||||
/// 替换标题表达式
|
||||
/// </summary>
|
||||
/// <param name="titleExpression"></param>
|
||||
/// <param name="tableName"></param>
|
||||
/// <param name="instanceId"></param>
|
||||
/// <returns></returns>
|
||||
public string ReplaceTitleExpression(string titleExpression, string tableName, string instanceId, JObject formBody);
|
||||
|
||||
/// <summary>
|
||||
/// 删除一个表单对应的数据
|
||||
/// </summary>
|
||||
/// <param name="formId">表单Id(RF_Form表Id)</param>
|
||||
/// <param name="instanceId">实例Id</param>
|
||||
/// <param name="programRunModel">设计的应用程序实体(用于判断数据删除后事件)</param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <param name="isVue">是否是VUE版本</param>
|
||||
/// <returns>返回1表单成功,其它为错误信息</returns>
|
||||
public string DeleteFormData(string formId, string instanceId, Model.ProgramRun programRunModel = null, IStringLocalizer localizer = null, bool isVue = false);
|
||||
|
||||
/// <summary>
|
||||
/// 保存表单数据(vue前后分离方式)
|
||||
/// </summary>
|
||||
/// <returns>业务表主键值, 错误信息</returns>
|
||||
/// <param name="request">当前请求</param>
|
||||
public (string, string) SaveDataVue(JObject args, IStringLocalizer localizer = null);
|
||||
|
||||
/// <summary>
|
||||
/// 查询一页数据
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="userId">当前人员ID</param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="status">状态,默认为查询没有删除的表单</param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_form> GetPagerList(out int count, int size, int number, string userId, string name, string type, string order, int status = -1);
|
||||
|
||||
/// <summary>
|
||||
/// 删除表单同时删除应用程序库中记录
|
||||
/// </summary>
|
||||
/// <param name="form">表单实体</param>
|
||||
/// <param name="delete">是否彻底删除 0不 1彻底删除</param>
|
||||
/// <returns></returns>
|
||||
public int DeleteAndApplibrary(Model.rf_form form, int delete = 0);
|
||||
/// <summary>
|
||||
/// 清除表单运行时HTML缓存
|
||||
/// </summary>
|
||||
/// <param name="formId">表单ID</param>
|
||||
public void ClearRunJObjectCache(string formId);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据SQL得到下拉选项(vue项目用)
|
||||
/// </summary>
|
||||
/// <param name="connId"></param>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public JArray GetJArrayOptionsBySQL(string connId, string sql, string value);
|
||||
/// <summary>
|
||||
/// 根据URL得到下拉选项
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <returns></returns>
|
||||
public string GetOptionsByUrl(string url);
|
||||
/// <summary>
|
||||
/// 导入表单
|
||||
/// </summary>
|
||||
/// <param name="json"></param>
|
||||
/// <param name="createFile">是否需要创建文件,VUE不需要创建文件</param>
|
||||
/// <returns>返回1表示成功,其它为错误信息</returns>
|
||||
public string ImportForm(string json, bool createFile = true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
105
20220330_Vote/Ewide.RoadFlow/Data/IRoadFlowRepository.cs
Normal file
105
20220330_Vote/Ewide.RoadFlow/Data/IRoadFlowRepository.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IRoadFlowRepository<T>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有的数据对象并缓存
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<T> GetAll();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 按Id获取一个对象
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
T GetOneById(string id);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 按条件获取一个对象
|
||||
/// </summary>
|
||||
/// <param name="predicate"></param>
|
||||
/// <returns></returns>
|
||||
T GetOneBy(Predicate<T> predicate);
|
||||
|
||||
/// <summary>
|
||||
/// 按条件获取列表
|
||||
/// </summary>
|
||||
/// <param name="predicate"></param>
|
||||
/// <returns></returns>
|
||||
List<T> GetListBy(Predicate<T> predicate);
|
||||
|
||||
/// <summary>
|
||||
/// 增加对象
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
int Add(T t);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 增加多个对象
|
||||
/// </summary>
|
||||
/// <param name="ts"></param>
|
||||
/// <returns></returns>
|
||||
int AddRangeList(List<T> ts);
|
||||
|
||||
/// <summary>
|
||||
/// 更新对象
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
int Update(T t,bool clearCache=true);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新多个对象
|
||||
/// </summary>
|
||||
/// <param name="ts"></param>
|
||||
/// <returns></returns>
|
||||
int Update(List<T> ts, bool trans = true);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除对象(物理)
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
int Delete(T t);
|
||||
|
||||
/// <summary>
|
||||
/// 删除一批对象(物理)
|
||||
/// </summary>
|
||||
/// <param name="ts"></param>
|
||||
/// <returns></returns>
|
||||
int Delete(List<T> ts);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 按条件删除对象
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
int DeleteBy(System.Linq.Expressions.Expression<Func<T, bool>> expression);
|
||||
|
||||
/// <summary>
|
||||
/// 清空缓存
|
||||
/// </summary>
|
||||
void ClearCache();
|
||||
/// <summary>
|
||||
/// 清空缓存
|
||||
/// </summary>
|
||||
void ClearCache(string id);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
46
20220330_Vote/Ewide.RoadFlow/Data/Log/ILog.cs
Normal file
46
20220330_Vote/Ewide.RoadFlow/Data/Log/ILog.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface ILog:IRoadFlowRepository<RoadFlow.Model.rf_log>
|
||||
{
|
||||
/// <summary>
|
||||
/// 添加日志
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="contents"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="oldContents"></param>
|
||||
/// <param name="newContents"></param>
|
||||
/// <param name="others"></param>
|
||||
/// <param name="browseAgent"></param>
|
||||
/// <param name="ipAddress"></param>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="userName"></param>
|
||||
public void Add(string title, string CurrentUserId = "", string contents = "",
|
||||
LogType type = LogType.其他, string oldContents = "", string newContents = "", string others = "",
|
||||
string browseAgent = "", string ipAddress = "", string url = "", string userId = "", string userName = "");
|
||||
|
||||
/// <summary>
|
||||
/// 得到日志类型
|
||||
/// </summary>
|
||||
/// <param name="type">日志类型</param>
|
||||
/// <param name="language">语言</param>
|
||||
/// <returns></returns>
|
||||
public string GetLogType(string type, string language);
|
||||
|
||||
/// <summary>
|
||||
/// 添加异常日志
|
||||
/// </summary>
|
||||
/// <param name="err">异常类</param>
|
||||
/// <param name="title">标题 如果为空用err.Message</param>
|
||||
public void Add(Exception err, string title = "");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
208
20220330_Vote/Ewide.RoadFlow/Data/Log/Log.cs
Normal file
208
20220330_Vote/Ewide.RoadFlow/Data/Log/Log.cs
Normal file
@@ -0,0 +1,208 @@
|
||||
using Ewide.Core;
|
||||
using Furion.DatabaseAccessor;
|
||||
using Furion.DependencyInjection;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class Log :RoadFlowRepository<RoadFlow.Model.rf_log>,ILog, ITransient
|
||||
{
|
||||
private readonly IRepository<SysUser> _sysUserRep =Furion.App.GetService<IRepository<SysUser>>();
|
||||
private readonly IUserManager _userManager=Furion.App.GetService<IUserManager>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加日志
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="contents"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="oldContents"></param>
|
||||
/// <param name="newContents"></param>
|
||||
/// <param name="others"></param>
|
||||
/// <param name="browseAgent"></param>
|
||||
/// <param name="ipAddress"></param>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="userName"></param>
|
||||
public void Add(string title, string CurrentUserId = "", string contents = "", LogType type = LogType.其他, string oldContents = "", string newContents = "", string others = "", string browseAgent = "", string ipAddress = "", string url = "", string userId = "", string userName = "")
|
||||
{
|
||||
var logModel = new Model.rf_log
|
||||
{
|
||||
Id = GuidExtensions.NewGuid().ToString(),
|
||||
Title = title,
|
||||
Type = type.ToString(),
|
||||
IPAddress = ipAddress.IsNullOrWhiteSpace() ? Tools.GetIP() : ipAddress,
|
||||
URL = url.IsNullOrWhiteSpace() ? Tools.GetAbsoluteURL() : url,
|
||||
WriteTime = DateExtensions.Now,
|
||||
Referer = Tools.GetReferer()
|
||||
};
|
||||
if (userId.IsGuid(out Guid userGuid))
|
||||
{
|
||||
logModel.UserId = userGuid.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
logModel.UserId = CurrentUserId;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
if (!userName.IsNullOrWhiteSpace())
|
||||
{
|
||||
logModel.UserName = userName;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
var userModel = logModel.UserId.IsNullOrWhiteSpace() ?_sysUserRep.DetachedEntities.FirstOrDefault(x=>x.Id==logModel.UserId) : null;
|
||||
|
||||
if (null != userModel)
|
||||
{
|
||||
logModel.UserName = userModel.Name;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
if (!contents.IsNullOrWhiteSpace())
|
||||
{
|
||||
logModel.Contents = contents;
|
||||
}
|
||||
if (!others.IsNullOrWhiteSpace())
|
||||
{
|
||||
logModel.Others = others;
|
||||
}
|
||||
if (!oldContents.IsNullOrWhiteSpace())
|
||||
{
|
||||
logModel.OldContents = oldContents;
|
||||
}
|
||||
if (!newContents.IsNullOrWhiteSpace())
|
||||
{
|
||||
logModel.NewContents = newContents;
|
||||
}
|
||||
logModel.BrowseAgent = browseAgent.IsNullOrWhiteSpace() ? Tools.GetBrowseAgent() : browseAgent;
|
||||
AddLog(logModel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加日志
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="contents"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="oldContents"></param>
|
||||
/// <param name="newContents"></param>
|
||||
/// <param name="others"></param>
|
||||
/// <param name="browseAgent"></param>
|
||||
/// <param name="ipAddress"></param>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="userName"></param>
|
||||
public void Add(string title, string contents = "", LogType type = LogType.其他, string oldContents = "", string newContents = "", string others = "", string browseAgent = "", string ipAddress = "", string url = "", string userId = "", string userName = "")
|
||||
{
|
||||
this.Add(title, _userManager.UserId, contents, type, oldContents, newContents, others, browseAgent, ipAddress, url, userId, userName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加日志
|
||||
/// </summary>
|
||||
/// <param name="log"></param>
|
||||
private void AddLog(Model.rf_log log)
|
||||
{
|
||||
log.Type = GetLogType(log.Type, Config.Language_Default);
|
||||
this.Add(log);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到日志类型
|
||||
/// </summary>
|
||||
/// <param name="type">日志类型</param>
|
||||
/// <param name="language">语言</param>
|
||||
/// <returns></returns>
|
||||
public string GetLogType(string type, string language)
|
||||
{
|
||||
switch (language)
|
||||
{
|
||||
case "zh-CN":
|
||||
return type;
|
||||
case "zh":
|
||||
return ZH_Type.TryGetValue(type, out string t) ? t : type;
|
||||
case "en-US":
|
||||
return EN_US_Type.TryGetValue(type, out string t2) ? t2 : type;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
private static readonly Dictionary<string, string> ZH_Type = new Dictionary<string, string>
|
||||
{
|
||||
{"用户登录" ,"用戶登錄"},
|
||||
{"系统管理" ,"系統管理"},
|
||||
{"流程管理" ,"流程管理"},
|
||||
{"表单管理" ,"表單管理"},
|
||||
{"流程运行" ,"流程運行"},
|
||||
{"系统异常" ,"系統異常"},
|
||||
{"其他" ,"其他"},
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, string> EN_US_Type = new Dictionary<string, string>
|
||||
{
|
||||
{"用户登录" ,"User login"},
|
||||
{"系统管理" ,"System management"},
|
||||
{"流程管理" ,"Workflow management"},
|
||||
{"表单管理" ,"Form management"},
|
||||
{"流程运行" ,"Workflow run"},
|
||||
{"系统异常" ,"Exception"},
|
||||
{"其他" ,"Other"},
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 添加异常日志
|
||||
/// </summary>
|
||||
/// <param name="err">异常类</param>
|
||||
/// <param name="title">标题 如果为空用err.Message</param>
|
||||
public void Add(Exception err, string title = "")
|
||||
{
|
||||
Model.rf_log logModel = new Model.rf_log
|
||||
{
|
||||
Id = GuidExtensions.NewGuid().ToString(),
|
||||
Title = title.IsNullOrWhiteSpace() ? err.Message : title,
|
||||
Type = GetLogType("系统异常", Tools.GetCurrentLanguage()),
|
||||
IPAddress = Tools.GetIP(),
|
||||
URL = Tools.GetAbsoluteURL(),
|
||||
WriteTime = DateExtensions.Now,
|
||||
Referer = Tools.GetReferer()
|
||||
};
|
||||
string uid = _userManager.UserId;
|
||||
/*if (uid.IsNullOrWhiteSpace())
|
||||
{
|
||||
uid = EnterpriseWeiXin.Common.GetUserId();
|
||||
}*/
|
||||
if (uid.IsNotEmptyGuid())
|
||||
{
|
||||
logModel.UserId = uid;
|
||||
}
|
||||
var userModel = _userManager.User;//logModel.UserId.HasValue ? new RoadFlow.Business.User().Get(logModel.UserId.Value) : null;
|
||||
/*if (null == userModel)
|
||||
{
|
||||
userModel = EnterpriseWeiXin.Common.GetUser();
|
||||
}*/
|
||||
if (null != userModel)
|
||||
{
|
||||
logModel.UserName = userModel.Name;
|
||||
}
|
||||
logModel.Contents = err.StackTrace;
|
||||
logModel.Others = err.Source + "(" + err.Message + ")";
|
||||
logModel.BrowseAgent = Tools.GetBrowseAgent();
|
||||
AddLog(logModel);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
19
20220330_Vote/Ewide.RoadFlow/Data/Log/LogType.cs
Normal file
19
20220330_Vote/Ewide.RoadFlow/Data/Log/LogType.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public enum LogType
|
||||
{
|
||||
用户登录,
|
||||
系统管理,
|
||||
流程管理,
|
||||
表单管理,
|
||||
流程运行,
|
||||
系统异常,
|
||||
其他
|
||||
}
|
||||
}
|
||||
13
20220330_Vote/Ewide.RoadFlow/Data/Menu/IMenu.cs
Normal file
13
20220330_Vote/Ewide.RoadFlow/Data/Menu/IMenu.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IMenu: IRoadFlowRepository<RoadFlow.Model.rf_menu>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
31
20220330_Vote/Ewide.RoadFlow/Data/Menu/Menu.cs
Normal file
31
20220330_Vote/Ewide.RoadFlow/Data/Menu/Menu.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Furion.DependencyInjection;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class Menu: RoadFlowRepository<RoadFlow.Model.rf_menu>, IMenu, ITransient
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 判断一个人员是否可以使用一个菜单下的某个按钮
|
||||
/// </summary>
|
||||
/// <param name="menuId"></param>
|
||||
/// <param name="buttonId"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="menuusers"></param>
|
||||
/// <returns></returns>
|
||||
public bool HasUseButton(string menuId, string buttonId, string userId, List<Model.rf_menuuser> menuusers)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
13
20220330_Vote/Ewide.RoadFlow/Data/MenuUser/IMenuUser.cs
Normal file
13
20220330_Vote/Ewide.RoadFlow/Data/MenuUser/IMenuUser.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IMenuUser: IRoadFlowRepository<RoadFlow.Model.rf_menuuser>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
20
20220330_Vote/Ewide.RoadFlow/Data/MenuUser/MenuUser.cs
Normal file
20
20220330_Vote/Ewide.RoadFlow/Data/MenuUser/MenuUser.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Furion.DependencyInjection;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class MenuUser: RoadFlowRepository<RoadFlow.Model.rf_menuuser>, IMenuUser, ITransient
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
49
20220330_Vote/Ewide.RoadFlow/Data/Message/IMessage.cs
Normal file
49
20220330_Vote/Ewide.RoadFlow/Data/Message/IMessage.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using Ewide.Core;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IMessage: IRoadFlowRepository<RoadFlow.Model.rf_message>
|
||||
{
|
||||
/// <summary>
|
||||
/// 发送一条消息(VUE版本)
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="receiveUsers">接收人员,如果为空则从message.ReceiverIdString中取</param>
|
||||
/// <param name="url">要连接的地址</param>
|
||||
/// <param name="language">语言包</param>
|
||||
/// <returns>返回1表示成功,其它为错误信息</returns>
|
||||
public string VueSend(Model.rf_message message, IEnumerable<SysUser> receiveUsers = null, string url = "", IConfigurationSection language = null);
|
||||
|
||||
/// <summary>
|
||||
/// 查询一页已发送消息
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="contents"></param>
|
||||
/// <param name="date1"></param>
|
||||
/// <param name="date2"></param>
|
||||
/// <param name="status">0自己发送的消息 1未读消息 2已读消息</param>
|
||||
/// <param name="order"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_message> GetSendList(out int count, int size, int number, string userId, string contents, string date1, string date2, string status, string order);
|
||||
|
||||
/// <summary>
|
||||
/// 得到发送方式字符串
|
||||
/// </summary>
|
||||
/// <param name="receiveType">发送方式 0站内消息 1手机短信 2微信 </param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns></returns>
|
||||
public string GetSendTypeString(string sendType, IStringLocalizer localizer = null);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
243
20220330_Vote/Ewide.RoadFlow/Data/Message/Message.cs
Normal file
243
20220330_Vote/Ewide.RoadFlow/Data/Message/Message.cs
Normal file
@@ -0,0 +1,243 @@
|
||||
using Ewide.Core;
|
||||
using Furion.DependencyInjection;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RoadFlow.Utility;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class Message: RoadFlowRepository<RoadFlow.Model.rf_message>, IMessage, ITransient
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 发送一条消息(VUE版本)
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="receiveUsers">接收人员,如果为空则从message.ReceiverIdString中取</param>
|
||||
/// <param name="url">要连接的地址</param>
|
||||
/// <param name="language">语言包</param>
|
||||
/// <returns>返回1表示成功,其它为错误信息</returns>
|
||||
public string VueSend(Model.rf_message message, IEnumerable<SysUser> receiveUsers = null, string url = "", IConfigurationSection language = null)
|
||||
{
|
||||
if (null == message)
|
||||
{
|
||||
return language != null && language.GetSection("sendmsg_empty") != null ? language.GetSection("sendmsg_empty").Value : "消息为空!";
|
||||
}
|
||||
if (receiveUsers == null)
|
||||
{
|
||||
receiveUsers = new Organize().GetAllUsers(message.ReceiverIdString);
|
||||
}
|
||||
if (!receiveUsers.Any())
|
||||
{
|
||||
return language != null && language.GetSection("sendmsg_notreceiver") != null ? language.GetSection("sendmsg_notreceiver").Value : "消息没有接收人!";
|
||||
}
|
||||
if (message.ReceiverIdString.IsNullOrEmpty())
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
foreach (var u in receiveUsers)
|
||||
{
|
||||
stringBuilder.Append(IOrganize.PREFIX_USER);
|
||||
stringBuilder.Append(u.Id);
|
||||
stringBuilder.Append(",");
|
||||
}
|
||||
message.ReceiverIdString = stringBuilder.ToString().TrimEnd(',');
|
||||
}
|
||||
List<Model.rf_messageuser> messageUsers = new List<Model.rf_messageuser>();
|
||||
List<string> userIDList = new List<string>();//记录用户ID,用于发送singalr消息
|
||||
string[] sendTypes = message.SendType.Split(',');
|
||||
foreach (string sendType in sendTypes)
|
||||
{
|
||||
if (!sendType.IsInt(out int t))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
switch (t)
|
||||
{
|
||||
case 0://站内短信
|
||||
foreach (var user in receiveUsers)
|
||||
{
|
||||
messageUsers.Add(new Model.rf_messageuser()
|
||||
{
|
||||
MessageId = message.Id,
|
||||
UserId = user.Id,
|
||||
IsRead = 0
|
||||
});
|
||||
userIDList.Add(user.Id.ToString().ToLower());
|
||||
}
|
||||
break;
|
||||
case 1://手机短信
|
||||
StringBuilder mobiles = new StringBuilder();
|
||||
foreach (var user in receiveUsers)
|
||||
{
|
||||
if (!user.Phone.IsNullOrWhiteSpace())
|
||||
{
|
||||
mobiles.Append(user.Phone);
|
||||
mobiles.Append(",");
|
||||
}
|
||||
}
|
||||
SMS.SendSMS(message.Contents.RemoveHTML(), mobiles.ToString().TrimEnd(','));
|
||||
|
||||
break;
|
||||
case 2://企业微信
|
||||
/* if (Config.EnterpriseWeChatIsUse)
|
||||
{
|
||||
if (message.Type == 20)
|
||||
{
|
||||
if (!url.ContainsIgnoreCase("&ismobile="))
|
||||
{
|
||||
url += "&ismobile=1";
|
||||
}
|
||||
if (!url.ContainsIgnoreCase("&ismessage="))
|
||||
{
|
||||
url += "&ismessage=1";
|
||||
}
|
||||
}
|
||||
string linkUrl = url.IsNullOrWhiteSpace() && message.Type == 1
|
||||
? Config.EnterpriseWeChatWebUrl + "/?loadurl=" + ("/mobile/message-show?messageid=" + message.Id.ToString()).UrlEncode()
|
||||
: Config.EnterpriseWeChatWebUrl + "/?loadurl=" + url.UrlEncode();
|
||||
string msgTitle = message.Type == 20 ? (language != null && language.GetSection("sendmsg_todo") != null ? language.GetSection("sendmsg_todo").Value : "待办事项")
|
||||
: (language != null && language.GetSection("sendmsg_msg") != null ? language.GetSection("sendmsg_msg").Value : "消息");
|
||||
string msgDescription = "<div class=\"normal\">" + message.Contents + "</div><div class=\"gray\">"
|
||||
+ (message.SenderName.IsNullOrWhiteSpace() ? "" : (language != null && language.GetSection("sendmsg_sender") != null ? language.GetSection("sendmsg_sender").Value : "发送人") + ":" + message.SenderName)
|
||||
+ " " + (language != null && language.GetSection("sendmsg_time") != null ? language.GetSection("sendmsg_time").Value : "时间") + ":" + message.SendTime.ToShortDateTimeString() + "</div>";
|
||||
string msgBtnText = message.Type == 20 ? (language != null && language.GetSection("sendmsg_handle") != null ? language.GetSection("sendmsg_handle").Value : "点击处理")
|
||||
: (language != null && language.GetSection("sendmsg_info") != null ? language.GetSection("sendmsg_info").Value : "详情");
|
||||
|
||||
//每次最大只能发1000人,所以这里要分段
|
||||
List<List<Model.User>> toUsers = new List<List<Model.User>>();
|
||||
int skip = 1000;
|
||||
int number = 1;
|
||||
while (skip == 1000)
|
||||
{
|
||||
var userList = receiveUsers.Skip(number++ * 1000 - 1000).Take(1000).ToList();
|
||||
toUsers.Add(userList);
|
||||
skip = userList.Count;
|
||||
}
|
||||
|
||||
EnterpriseWeChat.Message weChatMessage = new EnterpriseWeChat.Message();
|
||||
foreach (var toUserList in toUsers)
|
||||
{
|
||||
StringBuilder msgReceiveUsers = new StringBuilder();
|
||||
foreach (var receiveUser in toUserList)
|
||||
{
|
||||
msgReceiveUsers.Append(receiveUser.Account + "|");
|
||||
}
|
||||
weChatMessage.SendTextCard(msgTitle, msgDescription, msgBtnText, linkUrl, msgReceiveUsers.ToString().TrimEnd('|'));
|
||||
}
|
||||
}*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
//发送singalr消息
|
||||
if (userIDList.Count > 0)
|
||||
{
|
||||
JObject jObject = new JObject
|
||||
{
|
||||
{ "id", message.Id.ToString() },
|
||||
{ "title", message.Type == 20 ? language != null && language.GetSection("sendmsg_todomsg") != null ? language.GetSection("sendmsg_todomsg").Value : "待办任务消息"
|
||||
: language != null && language.GetSection("sendmsg_msg") != null ? language.GetSection("sendmsg_msg").Value : "消息" },
|
||||
{ "contents", message.Contents },
|
||||
{ "linkUrl", message.Files.IsNullOrWhiteSpace() ? "" : message.Files },
|
||||
{ "count", 1 }
|
||||
};
|
||||
new Business.SignalR.SignalRHub().SendMessage(jObject.ToString(Newtonsoft.Json.Formatting.None), userIDList);
|
||||
}
|
||||
return Add(message, messageUsers.ToArray()) > 0 ? "1" : language != null && language.GetSection("sendmsg_fail") != null ? language.GetSection("sendmsg_fail").Value : "发送失败!";
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加一批消息
|
||||
/// </summary>
|
||||
/// <param name="message">消息实体</param>
|
||||
/// <param name="messageUsers">阅读人员</param>
|
||||
/// <returns></returns>
|
||||
public int Add(Model.rf_message message, Model.rf_messageuser[] messageUsers)
|
||||
{
|
||||
return 1;
|
||||
//this.Add(message);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询一页已发送消息
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="contents"></param>
|
||||
/// <param name="date1"></param>
|
||||
/// <param name="date2"></param>
|
||||
/// <param name="status">0自己发送的消息 1未读消息 2已读消息</param>
|
||||
/// <param name="order"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_message> GetSendList(out int count, int size, int number, string userId, string contents, string date1, string date2, string status, string order)
|
||||
{
|
||||
int total = 0;
|
||||
var rtn = db.Queryable<Model.rf_message>()
|
||||
.WhereIF(status == "1",
|
||||
x => SqlFunc.Subqueryable<Model.rf_messageuser>().Where(y => y.MessageId == x.Id && y.IsRead == 0 && y.UserId == userId).Count() > 0)
|
||||
.WhereIF(status == "2",
|
||||
x => SqlFunc.Subqueryable<Model.rf_messageuser>().Where(y => y.MessageId == x.Id && y.IsRead == 1 && y.UserId == userId).Count() > 0)
|
||||
.WhereIF(status == "0",
|
||||
x => x.SenderId == userId)
|
||||
.WhereIF(!contents.IsNullOrWhiteSpace(),
|
||||
x => x.Contents.Contains(contents.Trim()))
|
||||
.WhereIF(date1.IsDateTime(out DateTime dt),
|
||||
x => x.SendTime >= dt.GetDate())
|
||||
.WhereIF(date2.IsDateTime(out DateTime dt1),
|
||||
x => x.SendTime < dt1.GetDate()
|
||||
)
|
||||
.OrderByIF(!order.IsNullOrWhiteSpace(), order.FilterSelectSql())
|
||||
.ToPageList(number, size, ref total).ToList();
|
||||
count = total;
|
||||
return rtn;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 得到发送方式字符串
|
||||
/// </summary>
|
||||
/// <param name="receiveType">发送方式 0站内消息 1手机短信 2微信 </param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns></returns>
|
||||
public string GetSendTypeString(string sendType, IStringLocalizer localizer = null)
|
||||
{
|
||||
if (sendType.IsNullOrWhiteSpace())
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
string[] types = sendType.Split(',');
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
foreach (string type in types)
|
||||
{
|
||||
if (!type.IsInt(out int t))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
switch (t)
|
||||
{
|
||||
case 0:
|
||||
stringBuilder.Append(localizer == null ? "站内消息、" : localizer["MessageType0"] + "、");
|
||||
break;
|
||||
case 1:
|
||||
stringBuilder.Append(localizer == null ? "手机短信、" : localizer["MessageType1"] + "、");
|
||||
break;
|
||||
case 2:
|
||||
stringBuilder.Append(localizer == null ? "微信、" : localizer["MessageType2"] + "、");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return stringBuilder.ToString().TrimEnd('、');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using Ewide.Core;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IMessageUser : IRoadFlowRepository<RoadFlow.Model.rf_messageuser>
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询一页已发送消息阅读人员
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="messageId"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_messageuser> GetReadUserList(out int count, int size, int number, string messageId, string order);
|
||||
/// <summary>
|
||||
/// 更新一个消息为已读
|
||||
/// </summary>
|
||||
/// <param name="messageId"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateIsRead(string messageId, string userId);
|
||||
|
||||
/// <summary>
|
||||
/// 更新一个人员的所有未读消息为已读
|
||||
/// </summary>
|
||||
/// <param name="messageUsers"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateAllIsRead();
|
||||
/// <summary>
|
||||
/// 删除一批消息
|
||||
/// </summary>
|
||||
/// <param name="guids">要删除的id</param>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <returns></returns>
|
||||
public int Delete(IEnumerable<string> guids, string userId);
|
||||
}
|
||||
}
|
||||
79
20220330_Vote/Ewide.RoadFlow/Data/MessageUser/MessageUser.cs
Normal file
79
20220330_Vote/Ewide.RoadFlow/Data/MessageUser/MessageUser.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using Ewide.Core;
|
||||
using Furion.DependencyInjection;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RoadFlow.Utility;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class MessageUser: RoadFlowRepository<RoadFlow.Model.rf_messageuser>, IMessageUser, ITransient
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 查询一页已发送消息阅读人员
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="messageId"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_messageuser> GetReadUserList(out int count, int size, int number, string messageId, string order)
|
||||
{
|
||||
int total = 0;
|
||||
var rtn = db.Queryable<Model.rf_messageuser>().Where(x => x.MessageId == messageId)
|
||||
.OrderByIF(!order.IsNullOrEmpty(), order).ToPageList(number, size, ref total).ToList();
|
||||
count = total;
|
||||
return rtn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新一个消息为已读
|
||||
/// </summary>
|
||||
/// <param name="messageId"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateIsRead(string messageId, string userId)
|
||||
{
|
||||
Model.rf_messageuser tmp = GetOneBy(x => x.MessageId == messageId && x.UserId == userId);
|
||||
if (tmp == null)
|
||||
return 0;
|
||||
tmp.IsRead = 1;
|
||||
tmp.ReadTime = DateExtensions.Now;
|
||||
return Update(tmp);
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新一个人员的所有未读消息为已读
|
||||
/// </summary>
|
||||
/// <param name="messageUsers"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateAllIsRead()
|
||||
{
|
||||
IUserManager m = Furion.App.GetService<IUserManager>();
|
||||
return db.Ado.ExecuteCommand("UPDATE RF_MessageUser SET IsRead=1,ReadTime="
|
||||
+ DateExtensions.Now.ToString() + " WHERE IsRead=0 AND UserId="+m.UserId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除一批消息
|
||||
/// </summary>
|
||||
/// <param name="guids">要删除的id</param>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <returns></returns>
|
||||
public int Delete(IEnumerable<string> guids, string userId)
|
||||
{
|
||||
|
||||
var msgs = GetListBy(x => x.UserId == userId && guids.Contains(x.Id));
|
||||
return Delete(msgs);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
71
20220330_Vote/Ewide.RoadFlow/Data/Organize/IOrganize.cs
Normal file
71
20220330_Vote/Ewide.RoadFlow/Data/Organize/IOrganize.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using Ewide.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IOrganize
|
||||
{
|
||||
/// <summary>
|
||||
/// 人员前缀
|
||||
/// </summary>
|
||||
const string PREFIX_USER = "u_";
|
||||
/// <summary>
|
||||
/// 工作组前缀
|
||||
/// </summary>
|
||||
const string PREFIX_WORKGROUP = "w_";
|
||||
/// <summary>
|
||||
/// 人员兼职前缀
|
||||
/// </summary>
|
||||
const string PREFIX_RELATION = "r_";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID字符串得到所有人员ID
|
||||
/// </summary>
|
||||
/// <param name="idString">u_人员,id,w_工作且,r_兼职</param>
|
||||
/// <returns>逗号分开的ID</returns>
|
||||
public string GetAllUsersId(string idString);
|
||||
/// <summary>
|
||||
/// 得到一个机构下所有人员
|
||||
/// </summary>
|
||||
/// <param name="id">机构ID</param>
|
||||
/// <param name="hasPartTime">是否包含兼任人员</param>
|
||||
/// <returns></returns>
|
||||
public List<SysUser> GetAllUsers(string id, bool hasPartTime = true);
|
||||
|
||||
/// <summary>
|
||||
/// 得到所有下级组织机构
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="isMe">是否包含自己</param>
|
||||
/// <returns></returns>
|
||||
public List<SysOrg> GetAllChilds(string id, bool isMe = false);
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID查询一个组织机构
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public SysOrg Get(string id);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个人员的主要组织显示
|
||||
/// </summary>
|
||||
/// <param name="id">人员ID</param>
|
||||
/// <param name="isShowRoot">是否显示根</param>
|
||||
/// <returns></returns>
|
||||
public string GetOrganizeMainShowHtml(string id, bool isShowRoot = true);
|
||||
/// <summary>
|
||||
/// 得到一个人员的主要组织显示
|
||||
/// </summary>
|
||||
/// <param name="id">人员ID</param>
|
||||
/// <param name="isShowRoot">是否显示根</param>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, string> GetOrganizeMainShowHtml(IEnumerable<string> ids, bool isShowRoot = true);
|
||||
}
|
||||
}
|
||||
269
20220330_Vote/Ewide.RoadFlow/Data/Organize/Organize.cs
Normal file
269
20220330_Vote/Ewide.RoadFlow/Data/Organize/Organize.cs
Normal file
@@ -0,0 +1,269 @@
|
||||
using Ewide.Core;
|
||||
using Furion;
|
||||
using Furion.DatabaseAccessor;
|
||||
using Furion.DependencyInjection;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class Organize:IOrganize, ITransient
|
||||
{
|
||||
private readonly IRepository<SysUser> _sysUserRep = App.GetService<IRepository<SysUser>>(); // 用户表仓储
|
||||
private readonly IRepository<SysOrg> _sysOrgRep = App.GetService<IRepository<SysOrg>>();
|
||||
private readonly IRepository<SysEmp> _sysEmpRep = App.GetService<IRepository<SysEmp>>();
|
||||
private readonly IRepository<SysEmpExtOrgPos> _sysEmpExtOrgPosRep = App.GetService<IRepository<SysEmpExtOrgPos>>();
|
||||
private readonly IUserManager _userManager = App.GetService<IUserManager>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID字符串得到所有人员ID
|
||||
/// </summary>
|
||||
/// <param name="idString">u_人员,id,w_工作且,r_兼职</param>
|
||||
/// <returns>逗号分开的ID</returns>
|
||||
public string GetAllUsersId(string idString)
|
||||
{
|
||||
var users = GetAllUsers(idString);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
foreach (var user in users)
|
||||
{
|
||||
stringBuilder.Append(user.Id);
|
||||
stringBuilder.Append(",");
|
||||
}
|
||||
return stringBuilder.ToString().TrimEnd(',');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个机构下所有人员
|
||||
/// </summary>
|
||||
/// <param name="id">机构ID</param>
|
||||
/// <param name="hasPartTime">是否包含兼任人员</param>
|
||||
/// <returns></returns>
|
||||
public List<SysUser> GetAllUsers(string id, bool hasPartTime = true)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(id)&&id.StartsWith(IOrganize.PREFIX_USER))
|
||||
return _sysUserRep.DetachedEntities.Where(x => x.Id == id.RemoveUserPrefix()).ToList();
|
||||
|
||||
var allChilds = GetAllChilds(id, true);
|
||||
List<string> orgids = new List<string>();
|
||||
foreach (var child in allChilds)
|
||||
{
|
||||
orgids.Add(child.Id);
|
||||
}
|
||||
List<string> userIds = new List<string>();
|
||||
var empList =_sysEmpRep.DetachedEntities.Where(x => orgids.Contains(x.OrgId)).ToList();
|
||||
foreach (var emp in empList)
|
||||
userIds.Add(emp.Id);
|
||||
if (hasPartTime)
|
||||
{
|
||||
var empExtList = _sysEmpExtOrgPosRep.DetachedEntities.Where(x => orgids.Contains(x.SysOrgId)).ToList();
|
||||
foreach (var emp in empExtList)
|
||||
userIds.Add(emp.SysEmpId);
|
||||
}
|
||||
|
||||
return _sysUserRep.DetachedEntities.Where(x => userIds.Contains(x.Id)).ToList();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 得到所有下级组织机构
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="isMe">是否包含自己</param>
|
||||
/// <returns></returns>
|
||||
public List<SysOrg> GetAllChilds(string id, bool isMe = false)
|
||||
{
|
||||
List<SysOrg> organizes = new List<SysOrg>();
|
||||
var org = Get(id);
|
||||
if (null == org)
|
||||
{
|
||||
return organizes;
|
||||
}
|
||||
if (isMe)
|
||||
{
|
||||
organizes.Add(org);
|
||||
}
|
||||
var all = _sysOrgRep.DetachedEntities.ToList();//GetAll();
|
||||
AddChilds(org, organizes, all);
|
||||
return organizes;
|
||||
}
|
||||
private void AddChilds(SysOrg organize, List<SysOrg> organizes, List<SysOrg> all)
|
||||
{
|
||||
if (null == organize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var childs = all.FindAll(p => p.Pid == organize.Id).OrderBy(p => p.Sort).ToList();
|
||||
foreach (var child in childs)
|
||||
{
|
||||
organizes.Add(child);
|
||||
AddChilds(child, organizes, all);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据ID查询一个组织机构
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public SysOrg Get(string id)
|
||||
{
|
||||
return _sysOrgRep.DetachedEntities.FirstOrDefault(x=>x.Id ==id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据JSON字符串得到组织机构选择属性
|
||||
/// </summary>
|
||||
/// <param name="json">例:{"dept":"1","station":"0"}</param>
|
||||
/// <returns>dept="1" station="0"</returns>
|
||||
public string GetOrganizeAttrString(string json)
|
||||
{
|
||||
Newtonsoft.Json.Linq.JObject jObject = null;
|
||||
try
|
||||
{
|
||||
jObject = Newtonsoft.Json.Linq.JObject.Parse(json);
|
||||
}
|
||||
catch { }
|
||||
if (null == jObject)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
string unit = jObject.Value<string>("unit");
|
||||
string dept = jObject.Value<string>("dept");
|
||||
string station = jObject.Value<string>("station");
|
||||
string user = jObject.Value<string>("user");
|
||||
string more = jObject.Value<string>("more");
|
||||
string group = jObject.Value<string>("group");
|
||||
string role = jObject.Value<string>("role");
|
||||
string rootid = jObject.Value<string>("rootid");
|
||||
stringBuilder.Append(" unit=\"" + (unit.IsNullOrWhiteSpace() ? "0" : unit) + "\"");
|
||||
stringBuilder.Append(" dept=\"" + (dept.IsNullOrWhiteSpace() ? "0" : dept) + "\"");
|
||||
stringBuilder.Append(" station=\"" + (station.IsNullOrWhiteSpace() ? "0" : station) + "\"");
|
||||
stringBuilder.Append(" user=\"" + (user.IsNullOrWhiteSpace() ? "0" : user) + "\"");
|
||||
stringBuilder.Append(" more=\"" + (more.IsNullOrWhiteSpace() ? "0" : more) + "\"");
|
||||
stringBuilder.Append(" group=\"" + (group.IsNullOrWhiteSpace() ? "0" : group) + "\"");
|
||||
stringBuilder.Append(" role=\"" + (role.IsNullOrWhiteSpace() ? "0" : role) + "\"");
|
||||
stringBuilder.Append(" rootid=\"" + (rootid.IsNullOrWhiteSpace() ? "" : rootid) + "\"");
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID字符串得到名称
|
||||
/// </summary>
|
||||
/// <param name="idString">逗号分开的人员ID,机构ID,工作组ID等</param>
|
||||
/// <param name="splitChar">多个名称之前的分隔字符</param>
|
||||
/// <returns></returns>
|
||||
public string GetNames(string idString, string splitChar = "、")
|
||||
{
|
||||
if (idString.IsNullOrWhiteSpace())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
foreach (string id in idString.Split(','))
|
||||
{
|
||||
if (id.IsGuid(out Guid orgId))
|
||||
{
|
||||
stringBuilder.Append(_sysOrgRep.DetachedEntities.FirstOrDefault(x => x.Id == id)?.Name);
|
||||
stringBuilder.Append(splitChar);
|
||||
}
|
||||
else if (id.StartsWith(IOrganize.PREFIX_USER))
|
||||
{
|
||||
stringBuilder.Append(_sysUserRep.DetachedEntities.FirstOrDefault(x=>x.Id==id.RemoveUserPrefix())?.Name);
|
||||
stringBuilder.Append(splitChar);
|
||||
}
|
||||
else if (id.StartsWith(IOrganize.PREFIX_RELATION))
|
||||
{
|
||||
|
||||
stringBuilder.Append(_sysUserRep.DetachedEntities.FirstOrDefault(x => x.Id == id.RemoveUserRelationPrefix())?.Name);
|
||||
stringBuilder.Append(splitChar);
|
||||
|
||||
}
|
||||
else if (id.StartsWith(IOrganize.PREFIX_WORKGROUP))
|
||||
{
|
||||
/* 无workgroup
|
||||
stringBuilder.Append(workGroup.GetName(id.RemoveWorkGroupPrefix().ToGuid()));
|
||||
stringBuilder.Append(splitChar);
|
||||
*/
|
||||
}
|
||||
}
|
||||
return stringBuilder.ToString().TrimEnd(splitChar.ToCharArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个人员的主要组织显示
|
||||
/// </summary>
|
||||
/// <param name="id">人员ID</param>
|
||||
/// <param name="isShowRoot">是否显示根</param>
|
||||
/// <returns></returns>
|
||||
public string GetOrganizeMainShowHtml(string id, bool isShowRoot = true)
|
||||
{
|
||||
var emp =_sysEmpRep.DetachedEntities.FirstOrDefault(x => x.Id == id);
|
||||
if (emp == null)
|
||||
return "";
|
||||
var org = _sysOrgRep.DetachedEntities.FirstOrDefault(x=>x.Id==emp.OrgId);
|
||||
string[] pararr = org.Pids.TrimStart('[').TrimEnd(',',']').Split("],[");
|
||||
var parents = _sysOrgRep.DetachedEntities.Where(x => pararr.Contains(x.Id));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
var tmp = org;
|
||||
while (tmp.Pid != "00000000 - 0000 - 0000 - 0000 - 000000000000")
|
||||
{
|
||||
sb.Insert(0, "\\" + tmp.Name);
|
||||
tmp = parents.FirstOrDefault(x => x.Id == tmp.Pid);
|
||||
}
|
||||
if(isShowRoot)
|
||||
sb.Insert(0, tmp.Name);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个人员的主要组织显示
|
||||
/// </summary>
|
||||
/// <param name="id">人员ID</param>
|
||||
/// <param name="isShowRoot">是否显示根</param>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string,string> GetOrganizeMainShowHtml(IEnumerable<string> ids, bool isShowRoot = true)
|
||||
{
|
||||
var emps =_sysEmpRep.DetachedEntities.ToList();
|
||||
var orgs = _sysOrgRep.DetachedEntities.ToList();
|
||||
Dictionary<string, string> rtn = new Dictionary<string, string>();
|
||||
foreach (string id in ids)
|
||||
{
|
||||
var emp =emps.FirstOrDefault(x => x.Id == id);
|
||||
if (emp == null)
|
||||
rtn.Add(id, "");
|
||||
else
|
||||
{
|
||||
string orgId = emp.OrgId;
|
||||
var org =orgs.FirstOrDefault(x => x.Id == orgId);
|
||||
if (org == null)
|
||||
{
|
||||
rtn.Add(id, "");
|
||||
continue;
|
||||
}
|
||||
string[] pararr = org.Pids.TrimStart('[').TrimEnd(',', ']').Split("],[");
|
||||
var parents = orgs.Where(x => pararr.Contains(x.Id));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
var tmp = org;
|
||||
while (tmp.Pid != "00000000 - 0000 - 0000 - 0000 - 000000000000")
|
||||
{
|
||||
sb.Insert(0, "\\" + tmp.Name);
|
||||
tmp = parents.FirstOrDefault(x => x.Id == tmp.Pid);
|
||||
}
|
||||
if(isShowRoot)
|
||||
sb.Insert(0, tmp.Name);
|
||||
rtn.Add(id, sb.ToString());
|
||||
}
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
}
|
||||
}
|
||||
31
20220330_Vote/Ewide.RoadFlow/Data/Program/IProgram.cs
Normal file
31
20220330_Vote/Ewide.RoadFlow/Data/Program/IProgram.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Ewide.Core;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IProgram : IRoadFlowRepository<RoadFlow.Model.rf_program>
|
||||
{
|
||||
/// <summary>
|
||||
/// 得到运行时实体
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns></returns>
|
||||
public Model.ProgramRun GetRunModel(string id, IStringLocalizer localizer = null);
|
||||
|
||||
/// <summary>
|
||||
/// 得到运行时实体
|
||||
/// </summary>
|
||||
/// <param name="id">应用程序ID,RF_Program表ID</param>
|
||||
/// <param name="userModel">用户实体,用于判断按钮权限</param>
|
||||
/// <param name="menuId">菜单id</param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns></returns>
|
||||
public Model.ProgramRun VueGetRunModel(string id, SysUser userModel, string menuId, IStringLocalizer localizer = null);
|
||||
}
|
||||
}
|
||||
757
20220330_Vote/Ewide.RoadFlow/Data/Program/Program.cs
Normal file
757
20220330_Vote/Ewide.RoadFlow/Data/Program/Program.cs
Normal file
@@ -0,0 +1,757 @@
|
||||
using Ewide.Core;
|
||||
using Furion.DependencyInjection;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class Program: RoadFlowRepository<RoadFlow.Model.rf_program>,IProgram, ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 得到运行时实体
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns></returns>
|
||||
public Model.ProgramRun GetRunModel(string id, IStringLocalizer localizer = null)
|
||||
{
|
||||
string key = "ProgramRun_" + id;
|
||||
var obj = _memoryCache.Get(key);
|
||||
if (obj != null)
|
||||
{
|
||||
return (Model.ProgramRun)obj;
|
||||
}
|
||||
else
|
||||
{
|
||||
var programModel = GetOneById(id);
|
||||
if (null == programModel)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Model.ProgramRun programRunModel = new Model.ProgramRun
|
||||
{
|
||||
ButtonLocation = programModel.ButtonLocation,
|
||||
ClientScript = programModel.ClientScript,
|
||||
ConnId = programModel.ConnId.ToGuid(),
|
||||
CreateTime = programModel.CreateTime,
|
||||
CreateUserId = programModel.CreateUserId.ToGuid(),
|
||||
EditModel = programModel.EditModel,
|
||||
ExportFileName = programModel.ExportFileName,
|
||||
ExportHeaderText = programModel.ExportHeaderText,
|
||||
ExportTemplate = programModel.ExportTemplate,
|
||||
FormId = programModel.FormId,
|
||||
Height = programModel.Height,
|
||||
Id = programModel.Id.ToGuid(),
|
||||
InDataNumberFiledName = programModel.InDataNumberFiledName,
|
||||
IsAdd = programModel.IsAdd,
|
||||
IsPager = programModel.IsPager,
|
||||
RowNumber = programModel.RowNumber,
|
||||
Name = programModel.Name,
|
||||
ProgramButtons = new ProgramButton().GetAllByProgramId(programModel.Id),
|
||||
ProgramExports = new ProgramExport().GetAllByProgramId(programModel.Id),
|
||||
ProgramFields = new ProgramField().GetAllByProgramId(programModel.Id),
|
||||
ProgramQueries = new ProgramQuery().GetAllByProgramId(programModel.Id),
|
||||
ProgramValidates = new ProgramValidate().GetAllByProgramId(programModel.Id),
|
||||
PublishTime = programModel.PublishTime,
|
||||
SelectColumn = programModel.SelectColumn,
|
||||
SqlString = programModel.SqlString,
|
||||
Status = programModel.Status,
|
||||
TableHead = programModel.TableHead,
|
||||
TableStyle = programModel.TableStyle,
|
||||
Type = programModel.Type.ToGuid(),
|
||||
Width = programModel.Width,
|
||||
GroupHeaders = programModel.GroupHeaders,
|
||||
DefaultSort = programModel.DefaultSort,
|
||||
EditEvents = programModel.EditEvents
|
||||
};
|
||||
programRunModel.QueryHtml = GetQueryHtml(programRunModel.ProgramQueries, localizer);
|
||||
programRunModel.QueryData = GetQueryData(programRunModel.ProgramQueries);
|
||||
programRunModel.GridColNames = GetColNames(programRunModel.ProgramFields);
|
||||
programRunModel.GridColModels = GetColModels(programRunModel.ProgramFields);
|
||||
programRunModel.DefaultSort =
|
||||
programModel.DefaultSort.IsNullOrWhiteSpace() ? GetDefaultSort(programRunModel.ProgramFields) : programModel.DefaultSort;
|
||||
|
||||
_memoryCache.Set(key, programRunModel);
|
||||
return programRunModel;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 得到查询HTML
|
||||
/// </summary>
|
||||
/// <param name="programQueries"></param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns></returns>
|
||||
private string GetQueryHtml(List<Model.rf_programquery> programQueries, IStringLocalizer localizer = null)
|
||||
{
|
||||
StringBuilder query_controls = new StringBuilder();
|
||||
if (null == programQueries)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
foreach (var query in programQueries)
|
||||
{
|
||||
string title = query.ShowTitle.IsNullOrWhiteSpace() ? query.Field : query.ShowTitle;
|
||||
string controlName = query.ControlName.IsNullOrWhiteSpace() ? "ctl_" + query.Id : query.ControlName;
|
||||
query_controls.Append("<span style=\"margin-right:8px;display:inline-block;word-wrap:break-word;white-space:normal;\">");
|
||||
query_controls.Append("<label>" + title + ":</label>");
|
||||
switch (query.InputType)
|
||||
{
|
||||
case 0: //文本框
|
||||
query_controls.Append("<input type='text' class='mytext'");
|
||||
query_controls.Append(" id='" + controlName + "'");
|
||||
query_controls.Append(" name='" + controlName + "'");
|
||||
if (!query.ShowStyle.IsNullOrWhiteSpace())
|
||||
{
|
||||
query_controls.Append(" style=\"" + query.ShowStyle + "\"");
|
||||
}
|
||||
query_controls.Append("/>");
|
||||
break;
|
||||
case 1://日期
|
||||
query_controls.Append("<input type='text' class='mycalendar'");
|
||||
query_controls.Append(" id='" + controlName + "'");
|
||||
query_controls.Append(" name='" + controlName + "'");
|
||||
if (!query.ShowStyle.IsNullOrWhiteSpace())
|
||||
{
|
||||
query_controls.Append(" style=\"" + query.ShowStyle + "\"");
|
||||
}
|
||||
query_controls.Append("/>");
|
||||
break;
|
||||
case 2://日期范围
|
||||
query_controls.Append("<input type='text' class='mycalendar'");
|
||||
query_controls.Append(" id='" + controlName + "'");
|
||||
query_controls.Append(" name='" + controlName + "'");
|
||||
if (!query.ShowStyle.IsNullOrWhiteSpace())
|
||||
{
|
||||
query_controls.Append(" style=\"" + query.ShowStyle + "\"");
|
||||
}
|
||||
query_controls.Append("/>");
|
||||
query_controls.Append(localizer == null ? (localizer == null ? " 至 " : localizer["To"]) : localizer["To"]);
|
||||
query_controls.Append("<input type='text' class='mycalendar'");
|
||||
query_controls.Append(" id='" + controlName + "1'");
|
||||
query_controls.Append(" name='" + controlName + "1'");
|
||||
if (!query.ShowStyle.IsNullOrWhiteSpace())
|
||||
{
|
||||
query_controls.Append(" style=\"" + query.ShowStyle + "\"");
|
||||
}
|
||||
query_controls.Append("/>");
|
||||
break;
|
||||
case 3://日期时间
|
||||
query_controls.Append("<input type='text' class='mycalendar' istime='1'");
|
||||
query_controls.Append(" id='" + controlName + "'");
|
||||
query_controls.Append(" name='" + controlName + "'");
|
||||
if (!query.ShowStyle.IsNullOrWhiteSpace())
|
||||
{
|
||||
query_controls.Append(" style=\"" + query.ShowStyle + "\"");
|
||||
}
|
||||
query_controls.Append("/>");
|
||||
break;
|
||||
case 4://日期时间范围
|
||||
query_controls.Append("<input type='text' class='mycalendar' istime='1'");
|
||||
query_controls.Append(" id='" + controlName + "'");
|
||||
query_controls.Append(" name='" + controlName + "'");
|
||||
if (!query.ShowStyle.IsNullOrWhiteSpace())
|
||||
{
|
||||
query_controls.Append(" style=\"" + query.ShowStyle + "\"");
|
||||
}
|
||||
query_controls.Append("/>");
|
||||
query_controls.Append(localizer == null ? (localizer == null ? " 至 " : localizer["To"]) : localizer["To"]);
|
||||
query_controls.Append("<input type='text' class='mycalendar' istime='1'");
|
||||
query_controls.Append(" id='" + controlName + "1'");
|
||||
query_controls.Append(" name='" + controlName + "1'");
|
||||
if (!query.ShowStyle.IsNullOrWhiteSpace())
|
||||
{
|
||||
query_controls.Append(" style=\"" + query.ShowStyle + "\"");
|
||||
}
|
||||
query_controls.Append("/>");
|
||||
break;
|
||||
case 5://下拉选项
|
||||
query_controls.Append("<select class='myselect'");
|
||||
query_controls.Append(" id='" + controlName + "'");
|
||||
query_controls.Append(" name='" + controlName + "'");
|
||||
if (!query.ShowStyle.IsNullOrWhiteSpace())
|
||||
{
|
||||
query_controls.Append(" style=\"" + query.ShowStyle + "\"");
|
||||
}
|
||||
query_controls.Append(">");
|
||||
query_controls.Append("<option value=\"\"></option>");
|
||||
switch (query.DataSource.Value)
|
||||
{
|
||||
case 0://字符串表达式
|
||||
query_controls.Append(new Form().GetOptionsByStringExpression(query.DataSourceString, ""));
|
||||
break;
|
||||
case 1://数据字典
|
||||
Dictionary.ValueField valueField = Dictionary.ValueField.Id;
|
||||
switch (query.OrgAttribute.ToInt(0))
|
||||
{
|
||||
case 1:
|
||||
valueField = Dictionary.ValueField.Title;
|
||||
break;
|
||||
case 2:
|
||||
valueField = Dictionary.ValueField.Code;
|
||||
break;
|
||||
case 3:
|
||||
valueField = Dictionary.ValueField.Value;
|
||||
break;
|
||||
case 4:
|
||||
valueField = Dictionary.ValueField.Note;
|
||||
break;
|
||||
case 5:
|
||||
valueField = Dictionary.ValueField.Other;
|
||||
break;
|
||||
default:
|
||||
valueField = Dictionary.ValueField.Id;
|
||||
break;
|
||||
}
|
||||
query_controls.Append(new Dictionary().GetOptionsByID(query.DictValue, valueField));
|
||||
break;
|
||||
case 2://SQL
|
||||
query_controls.Append(new Form().GetOptionsBySQL(query.ConnId, query.DataSourceString, ""));
|
||||
break;
|
||||
}
|
||||
query_controls.Append("</select>");
|
||||
break;
|
||||
case 6://组织机构选择
|
||||
query_controls.Append("<input type='text' class='mymember'");
|
||||
query_controls.Append(" id='" + controlName + "'");
|
||||
query_controls.Append(" name='" + controlName + "'");
|
||||
if (!query.ShowStyle.IsNullOrWhiteSpace())
|
||||
{
|
||||
query_controls.Append(" style=\"" + query.ShowStyle + "\"");
|
||||
}
|
||||
string orgOptions = new Organize().GetOrganizeAttrString(query.OrgAttribute);
|
||||
query_controls.Append(orgOptions);
|
||||
query_controls.Append("/>");
|
||||
break;
|
||||
case 7://数据字典选择
|
||||
query_controls.Append("<input type='text' class='mydict'");
|
||||
query_controls.Append(" id='" + controlName + "'");
|
||||
query_controls.Append(" name='" + controlName + "'");
|
||||
query_controls.Append(" rootid='" + query.DictValue + "'");
|
||||
if (!query.ShowStyle.IsNullOrWhiteSpace())
|
||||
{
|
||||
query_controls.Append(" style=\"" + query.ShowStyle + "\"");
|
||||
}
|
||||
query_controls.Append("/>");
|
||||
break;
|
||||
}
|
||||
query_controls.Append("</span>");
|
||||
}
|
||||
return query_controls.ToString();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 得到查询的JSON data
|
||||
/// </summary>
|
||||
/// <param name="programQueries"></param>
|
||||
/// <returns></returns>
|
||||
private string GetQueryData(List<Model.rf_programquery> programQueries)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.Append("\"pagesize\": size || curPageSize, \"pagenumber\": number || curPageNumber,");
|
||||
foreach (var query in programQueries)
|
||||
{
|
||||
string controlName = query.ControlName.IsNullOrWhiteSpace() ? "ctl_" + query.Id : query.ControlName;
|
||||
stringBuilder.Append("\"" + controlName + "\":$(\"#" + controlName + "\").val(),");
|
||||
if (query.InputType.In(2, 4))//如果是日期时间范围要加上截止时间
|
||||
{
|
||||
stringBuilder.Append("\"" + controlName + "1\":$(\"#" + controlName + "1\").val(),");
|
||||
}
|
||||
}
|
||||
return "{" + stringBuilder.ToString().TrimEnd(',') + "}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到Grid列头
|
||||
/// </summary>
|
||||
/// <param name="programFields"></param>
|
||||
/// <returns></returns>
|
||||
private string GetColNames(List<Model.rf_programfield> programFields)
|
||||
{
|
||||
if (null == programFields)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.Append("[");
|
||||
foreach (var field in programFields)
|
||||
{
|
||||
stringBuilder.Append("\"" + (field.ShowTitle.IsNullOrWhiteSpace() ? field.Field : field.ShowTitle) + "\",");
|
||||
}
|
||||
return stringBuilder.ToString().TrimEnd(',') + "]";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到GRID列JSON
|
||||
/// </summary>
|
||||
/// <param name="programFields"></param>
|
||||
/// <returns></returns>
|
||||
private string GetColModels(List<Model.rf_programfield> programFields)
|
||||
{
|
||||
if (null == programFields)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
Newtonsoft.Json.Linq.JArray jArray = new Newtonsoft.Json.Linq.JArray();
|
||||
foreach (var field in programFields)
|
||||
{
|
||||
Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject();
|
||||
string name = field.Field;
|
||||
if (name.IsNullOrWhiteSpace())
|
||||
{
|
||||
if (100 == field.ShowType)
|
||||
{
|
||||
name = "opation";
|
||||
}
|
||||
else if (1 == field.ShowType)
|
||||
{
|
||||
name = "rowserialnumber";
|
||||
}
|
||||
}
|
||||
jObject.Add("name", name);
|
||||
if (!field.IsSort.IsNullOrWhiteSpace())
|
||||
{
|
||||
jObject.Add("index", field.IsSort.Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
jObject.Add("sortable", false);
|
||||
}
|
||||
if (field.ShowType == 100)
|
||||
{
|
||||
jObject.Add("title", false);
|
||||
}
|
||||
if (field.IsShow == 0)
|
||||
{
|
||||
jObject.Add("hidedlg", true);
|
||||
jObject.Add("hidden", true);
|
||||
}
|
||||
if (!field.Width.IsNullOrWhiteSpace())
|
||||
{
|
||||
jObject.Add("width", field.Width.GetNumber());
|
||||
}
|
||||
jObject.Add("align", field.Align);
|
||||
|
||||
jArray.Add(jObject);
|
||||
}
|
||||
return jArray.ToString(Newtonsoft.Json.Formatting.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到默认排序列
|
||||
/// </summary>
|
||||
/// <param name="programFields"></param>
|
||||
/// <returns></returns>
|
||||
private string GetDefaultSort(List<Model.rf_programfield> programFields)
|
||||
{
|
||||
if (null == programFields || programFields.Count == 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
var filed = programFields.Find(p => !p.IsSort.IsNullOrWhiteSpace());
|
||||
if (null != filed)
|
||||
{
|
||||
return filed.IsSort;
|
||||
}
|
||||
else
|
||||
{
|
||||
return programFields.First().Field + " ASC";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到运行时实体
|
||||
/// </summary>
|
||||
/// <param name="id">应用程序ID,RF_Program表ID</param>
|
||||
/// <param name="userModel">用户实体,用于判断按钮权限</param>
|
||||
/// <param name="menuId">菜单id</param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns></returns>
|
||||
public Model.ProgramRun VueGetRunModel(string id, SysUser userModel, string menuId, IStringLocalizer localizer = null)
|
||||
{
|
||||
string key = "ProgramRun_VUE_" + id;
|
||||
var obj = _memoryCache.Get(key);
|
||||
Model.ProgramRun programRunModel;
|
||||
if (obj != null)
|
||||
{
|
||||
programRunModel = (Model.ProgramRun)obj;
|
||||
}
|
||||
else
|
||||
{
|
||||
var programModel = GetOneById(id);
|
||||
if (null == programModel)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
programRunModel = new Model.ProgramRun
|
||||
{
|
||||
ButtonLocation = programModel.ButtonLocation,
|
||||
ClientScript = programModel.ClientScript,
|
||||
ConnId = programModel.ConnId.ToGuid(),
|
||||
CreateTime = programModel.CreateTime,
|
||||
CreateUserId = programModel.CreateUserId.ToGuid(),
|
||||
EditModel = programModel.EditModel,
|
||||
ExportFileName = programModel.ExportFileName,
|
||||
ExportHeaderText = programModel.ExportHeaderText,
|
||||
ExportTemplate = programModel.ExportTemplate,
|
||||
FormId = programModel.FormId,
|
||||
Height = programModel.Height,
|
||||
Id = programModel.Id.ToGuid(),
|
||||
InDataNumberFiledName = programModel.InDataNumberFiledName,
|
||||
IsAdd = programModel.IsAdd,
|
||||
IsPager = programModel.IsPager,
|
||||
RowNumber = programModel.RowNumber,
|
||||
Name = programModel.Name,
|
||||
ProgramButtons = new ProgramButton().GetAllByProgramId(programModel.Id),
|
||||
ProgramExports = new ProgramExport().GetAllByProgramId(programModel.Id),
|
||||
ProgramFields = new ProgramField().GetAllByProgramId(programModel.Id),
|
||||
ProgramQueries = new ProgramQuery().GetAllByProgramId(programModel.Id),
|
||||
ProgramValidates = new ProgramValidate().GetAllByProgramId(programModel.Id),
|
||||
PublishTime = programModel.PublishTime,
|
||||
SelectColumn = programModel.SelectColumn,
|
||||
SqlString = programModel.SqlString,
|
||||
Status = programModel.Status,
|
||||
TableHead = programModel.TableHead,
|
||||
TableStyle = programModel.TableStyle,
|
||||
Type = programModel.Type.ToGuid(),
|
||||
Width = programModel.Width,
|
||||
GroupHeaders = programModel.GroupHeaders,
|
||||
DefaultSort = programModel.DefaultSort,
|
||||
EditEvents = programModel.EditEvents
|
||||
};
|
||||
programRunModel.QueryHtml = VueGetRunHtml(programRunModel, localizer);
|
||||
_memoryCache.Set(key, programRunModel);
|
||||
}
|
||||
|
||||
//替换按钮
|
||||
if (userModel != null)
|
||||
{
|
||||
var (normalButton, listButton) = VueGetButtons(programRunModel.ProgramButtons, userModel, menuId);
|
||||
programRunModel.QueryHtml = programRunModel.QueryHtml.Replace("{<button-normal>}", normalButton);
|
||||
foreach (JObject jObject in programRunModel.Cols)
|
||||
{
|
||||
if (jObject.ContainsKey("buttons"))
|
||||
{
|
||||
jObject["buttons"] = listButton;
|
||||
}
|
||||
}
|
||||
}
|
||||
return programRunModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到运行时VUE组件HTML
|
||||
/// </summary>
|
||||
/// <param name="programRun"></param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns></returns>
|
||||
public string VueGetRunHtml(Model.ProgramRun programRunModel, IStringLocalizer localizer = null)
|
||||
{
|
||||
if (programRunModel == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
StringBuilder html = new StringBuilder();
|
||||
#region 查询字段
|
||||
string queryHtml = VueGetQueryHtml(programRunModel.ProgramQueries, localizer);
|
||||
html.Append("<div style='padding:0 10px;'>");
|
||||
html.Append(queryHtml);
|
||||
//查询按钮(查询后面)
|
||||
if (programRunModel.ButtonLocation == 1)
|
||||
{
|
||||
if (!queryHtml.IsNullOrWhiteSpace())
|
||||
{
|
||||
html.Append("<roadui-button @click.native=\"query()\">" + (localizer == null ? "查询" : localizer["Query"].Value) + "</roadui-button>");
|
||||
}
|
||||
//{<button-normal>}作为占位符,实际运行时根据当前用户获取有权限的按钮填充。
|
||||
html.Append("{<button-normal>}");
|
||||
}
|
||||
html.Append("</div>");
|
||||
//查询按钮(新行)
|
||||
if (programRunModel.ButtonLocation == 0)
|
||||
{
|
||||
html.Append("<div style='text-align:center;margin:15px 0 10px 0;'>" + (queryHtml.IsNullOrWhiteSpace() ? string.Empty : "<roadui-button @click.native=\"query()\">" + (localizer == null ? "查询" : localizer["Query"].Value) + "</roadui-button>") + "{<button-normal>}</div>");
|
||||
}
|
||||
#endregion
|
||||
#region 列表
|
||||
html.Append("<roadui-table style=\"margin-top:15px;\" :cols=\"cols\" :rows=\"table.rows\" :loading=\"loading\" :total=\"table.total\""
|
||||
+ " :pagenumber.sync=\"number\" :pagesize.sync=\"size\" :ordertype=\"0\" :height=\"tableHeight\""
|
||||
+ (programRunModel.RowNumber == 1 ? " number" : "")
|
||||
+ (programRunModel.SelectColumn == 2 ? " checkbox" : programRunModel.SelectColumn == 1 ? " radio" : "") + " v-model=\"selectRows\""
|
||||
+ (programRunModel.TableHead.IsNullOrWhiteSpace() ? "" : " :mythead=\"myThead\"")
|
||||
+ " :pager=\"" + (programRunModel.IsPager == 1 ? "true" : "false") + "\" :order.sync=\"order\" @load=\"query\"></roadui-table>");
|
||||
programRunModel.Cols = VueGetCols(programRunModel.ProgramFields);
|
||||
#endregion
|
||||
return html.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取按钮
|
||||
/// </summary>
|
||||
/// <param name="programButtons"></param>
|
||||
/// <param name="userModel"></param>
|
||||
/// <param name="menuId">菜单id</param>
|
||||
/// <returns>(常规按钮,列表按钮)</returns>
|
||||
public (string, JArray) VueGetButtons(List<Model.rf_programbutton> programButtons, SysUser userModel, string menuId)
|
||||
{
|
||||
StringBuilder button_normal = new StringBuilder();
|
||||
JArray button_list = new JArray();
|
||||
|
||||
List<Model.rf_menuuser> menuusers = new MenuUser().GetAll();
|
||||
Menu menu = new Menu();
|
||||
SystemButton systemButton = new SystemButton();
|
||||
string language = Tools.GetCurrentLanguage();
|
||||
foreach (var button in programButtons.OrderBy(p => p.Sort))
|
||||
{
|
||||
//检查权限
|
||||
if (1 == button.IsValidateShow)
|
||||
{
|
||||
if (!menu.HasUseButton(menuId, button.Id, userModel.Id, menuusers))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
string butName = button.ButtonName;
|
||||
string ico = button.Ico;
|
||||
string note = button.Note;
|
||||
if (button.ShowType == 1)//常规按钮
|
||||
{
|
||||
button_normal.Append("<roadui-button");
|
||||
button_normal.Append(" @click.native=\"execScript('" + RoadFlow.Business.Wildcard.Filter(button.ClientScript, userModel).UrlEncode() + "')\"");
|
||||
if (!ico.IsNullOrWhiteSpace())
|
||||
{
|
||||
button_normal.Append(" ico=\"" + ico + "\"");
|
||||
}
|
||||
if (!note.IsNullOrWhiteSpace())
|
||||
{
|
||||
button_normal.Append(" title=\"" + note + "\"");
|
||||
}
|
||||
button_normal.Append(">");
|
||||
if (!butName.IsNullOrWhiteSpace())
|
||||
{
|
||||
button_normal.Append(butName);
|
||||
}
|
||||
button_normal.Append("</roadui-button>");
|
||||
}
|
||||
else if (button.ShowType == 2)//列表按钮 不替换通配符,列表按钮涉及运行时数据,在运行时替换。
|
||||
{
|
||||
button_list.Add(new JObject()
|
||||
{
|
||||
{ "title", butName },
|
||||
{ "ico", ico },
|
||||
{ "fun", RoadFlow.Business.Wildcard.Filter(button.ClientScript, userModel).UrlEncode()},
|
||||
{ "note", note },
|
||||
});
|
||||
}
|
||||
}
|
||||
return (button_normal.ToString(), button_list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到VUE查询HTML
|
||||
/// </summary>
|
||||
/// <param name="programQueries"></param>
|
||||
/// <param name="localizer">语言包</param>
|
||||
/// <returns></returns>
|
||||
public string VueGetQueryHtml(List<Model.rf_programquery> programQueries, IStringLocalizer localizer = null)
|
||||
{
|
||||
if (null == programQueries)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
StringBuilder query_controls = new StringBuilder();
|
||||
foreach (var query in programQueries)
|
||||
{
|
||||
string title = query.ShowTitle.IsNullOrWhiteSpace() ? query.Field : query.ShowTitle;
|
||||
string controlName = query.ControlName.IsNullOrWhiteSpace() ? "ctl_" + query.Id : query.ControlName;
|
||||
query_controls.Append("<span style=\"margin-right:8px;display:inline-block;word-wrap:break-word;white-space:normal;\">");
|
||||
query_controls.Append(title + ":");
|
||||
switch (query.InputType)
|
||||
{
|
||||
case 0: //文本框
|
||||
query_controls.Append("<roadui-text");
|
||||
query_controls.Append(" v-model='find." + controlName + "'");
|
||||
if (!query.ShowStyle.IsNullOrWhiteSpace())
|
||||
{
|
||||
query_controls.Append(" style=\"" + query.ShowStyle + "\"");
|
||||
}
|
||||
query_controls.Append("></roadui-text>");
|
||||
break;
|
||||
case 1://日期
|
||||
query_controls.Append("<roadui-calendar");
|
||||
query_controls.Append(" v-model='find." + controlName + "'");
|
||||
if (!query.ShowStyle.IsNullOrWhiteSpace())
|
||||
{
|
||||
query_controls.Append(" style=\"" + query.ShowStyle + "\"");
|
||||
}
|
||||
query_controls.Append("></roadui-calendar>");
|
||||
break;
|
||||
case 2://日期范围
|
||||
query_controls.Append("<roadui-calendar");
|
||||
query_controls.Append(" v-model='find." + controlName + "'");
|
||||
if (!query.ShowStyle.IsNullOrWhiteSpace())
|
||||
{
|
||||
query_controls.Append(" style=\"" + query.ShowStyle + "\"");
|
||||
}
|
||||
query_controls.Append("></roadui-calendar>");
|
||||
query_controls.Append(localizer == null ? " 至 " : localizer["To"].Value);
|
||||
query_controls.Append("<roadui-calendar");
|
||||
query_controls.Append(" v-model='find." + controlName + "1'");
|
||||
if (!query.ShowStyle.IsNullOrWhiteSpace())
|
||||
{
|
||||
query_controls.Append(" style=\"" + query.ShowStyle + "\"");
|
||||
}
|
||||
query_controls.Append("></roadui-calendar>");
|
||||
break;
|
||||
case 3://日期时间
|
||||
query_controls.Append("<roadui-calendar time='HH:mm'");
|
||||
query_controls.Append(" v-model='find." + controlName + "'");
|
||||
if (!query.ShowStyle.IsNullOrWhiteSpace())
|
||||
{
|
||||
query_controls.Append(" style=\"" + query.ShowStyle + "\"");
|
||||
}
|
||||
query_controls.Append("></roadui-calendar>");
|
||||
break;
|
||||
case 4://日期时间范围
|
||||
query_controls.Append("<roadui-calendar time='HH:mm'");
|
||||
query_controls.Append(" v-model='find." + controlName + "'");
|
||||
if (!query.ShowStyle.IsNullOrWhiteSpace())
|
||||
{
|
||||
query_controls.Append(" style=\"" + query.ShowStyle + "\"");
|
||||
}
|
||||
query_controls.Append("></roadui-calendar>");
|
||||
query_controls.Append(localizer == null ? " 至 " : localizer["To"].Value);
|
||||
query_controls.Append("<roadui-calendar time='HH:mm'");
|
||||
query_controls.Append(" v-model='find." + controlName + "1'");
|
||||
if (!query.ShowStyle.IsNullOrWhiteSpace())
|
||||
{
|
||||
query_controls.Append(" style=\"" + query.ShowStyle + "\"");
|
||||
}
|
||||
query_controls.Append("></roadui-calendar>");
|
||||
break;
|
||||
case 5://下拉选项
|
||||
query_controls.Append("<roadui-combox");
|
||||
query_controls.Append(" v-model='find." + controlName + "'");
|
||||
if (!query.ShowStyle.IsNullOrWhiteSpace())
|
||||
{
|
||||
query_controls.Append(" style=\"" + query.ShowStyle + "\"");
|
||||
}
|
||||
switch (query.DataSource.Value)
|
||||
{
|
||||
case 0://字符串表达式
|
||||
query_controls.Append(" :source=\"{type:1,str:'" + query.DataSourceString.UrlEncode().Replace("'", "\\'") + "'}\"");
|
||||
break;
|
||||
case 1://数据字典
|
||||
query_controls.Append(" :source=\"{type:0,dictId:'" + query.DataSourceString + "',childs:1,valueField:'" + query.DictValue + "'}\"");
|
||||
break;
|
||||
case 2://SQL
|
||||
query_controls.Append(" :source=\"{type:2,connId:'" + query.ConnId + "',sql:'" + query.DataSourceString.UrlEncode().Replace("'", "\\'") + "'}\"");
|
||||
break;
|
||||
}
|
||||
query_controls.Append("></roadui-combox>");
|
||||
break;
|
||||
case 6://组织机构选择
|
||||
query_controls.Append("<roadui-org");
|
||||
query_controls.Append(" v-model='find." + controlName + "'");
|
||||
if (!query.ShowStyle.IsNullOrWhiteSpace())
|
||||
{
|
||||
query_controls.Append(" style=\"" + query.ShowStyle + "\"");
|
||||
}
|
||||
JObject orgJObject = query.OrgAttribute.ToJObject();
|
||||
if (!orgJObject.IsEmptyJObject())
|
||||
{
|
||||
string selectrange = orgJObject.Value<string>("selectrange");//选择范围
|
||||
string multiple = orgJObject.Value<string>("multiple");//多选
|
||||
JArray selecttype = orgJObject.Value<JArray>("selecttype");//选择类型
|
||||
JArray selecttype1 = new JArray();
|
||||
foreach (JValue j in selecttype)
|
||||
{
|
||||
if (!j.ToString().IsNullOrWhiteSpace())
|
||||
{
|
||||
selecttype1.Add(j);
|
||||
}
|
||||
}
|
||||
if (selecttype1.Count == 0)//没有设置时为全部可选
|
||||
{
|
||||
selecttype1.Add("unit");
|
||||
selecttype1.Add("dept");
|
||||
selecttype1.Add("station");
|
||||
selecttype1.Add("user");
|
||||
selecttype1.Add("workgroup");
|
||||
}
|
||||
query_controls.Append("1".Equals(multiple) ? " multiple" : "");
|
||||
query_controls.Append(selectrange.IsNullOrWhiteSpace() ? "" : " root='" + selectrange + "'");
|
||||
query_controls.Append(" :selecttype='" + selecttype1.ToString(Newtonsoft.Json.Formatting.None) + "'");
|
||||
}
|
||||
query_controls.Append("></roadui-org>");
|
||||
break;
|
||||
}
|
||||
query_controls.Append("</span>");
|
||||
}
|
||||
return query_controls.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// 得到列设置
|
||||
/// </summary>
|
||||
/// <param name="programFields"></param>
|
||||
/// <returns></returns>
|
||||
public JArray VueGetCols(List<Model.rf_programfield> programFields)
|
||||
{
|
||||
JArray jArray = new JArray
|
||||
{
|
||||
//添加id列
|
||||
new JObject()
|
||||
{
|
||||
{ "name", "Id" },
|
||||
{ "title", "" },
|
||||
{ "order", "none" },
|
||||
{ "width", "" },
|
||||
{ "key", true },
|
||||
{ "show", 0 },
|
||||
}
|
||||
};
|
||||
foreach (var field in programFields)
|
||||
{
|
||||
JObject jObject = new JObject() {
|
||||
{ "name", field.Field },
|
||||
{ "title", field.ShowTitle.IsNullOrEmpty() ? field.Field :field.ShowTitle },
|
||||
{ "width", field.Width },
|
||||
{ "align", field.Align },
|
||||
};
|
||||
if (field.IsSort.IsNullOrWhiteSpace())
|
||||
{
|
||||
jObject.Add("order", "none");
|
||||
}
|
||||
if (field.IsShow == 0)
|
||||
{
|
||||
jObject.Add("show", 0);
|
||||
}
|
||||
if (field.ShowType == 100)//操作列
|
||||
{
|
||||
jObject["name"] = "Opation";
|
||||
jObject["order"] = "none";
|
||||
jObject.Add("type", "buttons");
|
||||
jObject.Add("buttons", new JArray());
|
||||
}
|
||||
else if (field.ShowType == 1)//序号列
|
||||
{
|
||||
jObject["name"] = "RowSerialNumber";
|
||||
}
|
||||
else if (field.ShowType.In(8, 9, 10))//显示附件,全部显示,不省略内容, 列加属性noellipsis:true
|
||||
{
|
||||
jObject.Add("noellipsis", true);
|
||||
}
|
||||
jArray.Add(jObject);
|
||||
}
|
||||
return jArray;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IProgramButton : IRoadFlowRepository<RoadFlow.Model.rf_programbutton>
|
||||
{
|
||||
/// <summary>
|
||||
/// 按programId获取
|
||||
/// </summary>
|
||||
/// <param name="programId"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_programbutton> GetAllByProgramId(string programId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Furion.DependencyInjection;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class ProgramButton: RoadFlowRepository<RoadFlow.Model.rf_programbutton>,IProgramButton, ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 按programId获取
|
||||
/// </summary>
|
||||
/// <param name="programId"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_programbutton> GetAllByProgramId(string programId)
|
||||
{
|
||||
return this.GetListBy(x => x.ProgramId == programId).ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IProgramExport : IRoadFlowRepository<RoadFlow.Model.rf_programexport>
|
||||
{
|
||||
/// <summary>
|
||||
/// 按programId获取
|
||||
/// </summary>
|
||||
/// <param name="programId"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_programexport> GetAllByProgramId(string programId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Furion.DependencyInjection;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class ProgramExport: RoadFlowRepository<RoadFlow.Model.rf_programexport>, IProgramExport, ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 按programId获取
|
||||
/// </summary>
|
||||
/// <param name="programId"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_programexport> GetAllByProgramId(string programId)
|
||||
{
|
||||
return this.GetListBy(x => x.ProgramId == programId).ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IProgramField : IRoadFlowRepository<RoadFlow.Model.rf_programfield>
|
||||
{
|
||||
/// <summary>
|
||||
/// 按programId获取
|
||||
/// </summary>
|
||||
/// <param name="programId"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_programfield> GetAllByProgramId(string programId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Furion.DependencyInjection;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class ProgramField: RoadFlowRepository<RoadFlow.Model.rf_programfield>, IProgramField, ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 按programId获取
|
||||
/// </summary>
|
||||
/// <param name="programId"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_programfield> GetAllByProgramId(string programId)
|
||||
{
|
||||
return this.GetListBy(x => x.ProgramId == programId).ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IProgramQuery : IRoadFlowRepository<RoadFlow.Model.rf_programquery>
|
||||
{
|
||||
/// <summary>
|
||||
/// 按programId获取
|
||||
/// </summary>
|
||||
/// <param name="programId"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_programquery> GetAllByProgramId(string programId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Furion.DependencyInjection;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class ProgramQuery: RoadFlowRepository<RoadFlow.Model.rf_programquery>, IProgramQuery, ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 按programId获取
|
||||
/// </summary>
|
||||
/// <param name="programId"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_programquery> GetAllByProgramId(string programId)
|
||||
{
|
||||
return this.GetListBy(x => x.ProgramId == programId).ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IProgramValidate: IRoadFlowRepository<RoadFlow.Model.rf_programvalidate>
|
||||
{
|
||||
/// <summary>
|
||||
/// 按programId获取
|
||||
/// </summary>
|
||||
/// <param name="programId"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_programvalidate> GetAllByProgramId(string programId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Furion.DependencyInjection;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class ProgramValidate: RoadFlowRepository<RoadFlow.Model.rf_programvalidate>, IProgramValidate, ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 按programId获取
|
||||
/// </summary>
|
||||
/// <param name="programId"></param>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_programvalidate> GetAllByProgramId(string programId)
|
||||
{
|
||||
return this.GetListBy(x => x.ProgramId == programId).ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
210
20220330_Vote/Ewide.RoadFlow/Data/RoadFlowRepository.cs
Normal file
210
20220330_Vote/Ewide.RoadFlow/Data/RoadFlowRepository.cs
Normal file
@@ -0,0 +1,210 @@
|
||||
using Furion;
|
||||
using Furion.DependencyInjection;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class RoadFlowRepository<T> : IRoadFlowRepository<T>, ITransient where T:RoadFlow.Model.BaseEntity,new()
|
||||
{
|
||||
protected readonly IMemoryCache _memoryCache;
|
||||
protected readonly ISqlSugarRepository repository;
|
||||
protected readonly SqlSugarClient db;
|
||||
protected readonly string CACHEKEY = "roadflow_cache_" + typeof(T).FullName;
|
||||
public RoadFlowRepository()
|
||||
{
|
||||
_memoryCache = App.GetService< IMemoryCache > ();
|
||||
repository = App.GetService<ISqlSugarRepository>();
|
||||
db = repository.Context;
|
||||
//db选择
|
||||
db.ChangeDatabase("118_3310_ewide");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有的数据对象并缓存
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual List<T> GetAll()
|
||||
{
|
||||
return _memoryCache.GetOrCreate(CACHEKEY, v =>
|
||||
{
|
||||
return db.Queryable<T>().ToList();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 按Id获取一个对象
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public virtual T GetOneById(string id)
|
||||
{
|
||||
List<T> list = GetAll();
|
||||
return list.Find(p => p.Id == id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按条件获取一个对象
|
||||
/// </summary>
|
||||
/// <param name="predicate"></param>
|
||||
/// <returns></returns>
|
||||
public virtual T GetOneBy(Predicate<T> predicate)
|
||||
{
|
||||
return GetAll().Find(predicate);
|
||||
}
|
||||
/// <summary>
|
||||
/// 按条件获取列表
|
||||
/// </summary>
|
||||
/// <param name="predicate"></param>
|
||||
/// <returns></returns>
|
||||
public virtual List<T> GetListBy(Predicate<T> predicate)
|
||||
{
|
||||
return GetAll().FindAll(predicate);
|
||||
}
|
||||
/// <summary>
|
||||
/// 增加对象
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
public virtual int Add(T t)
|
||||
{
|
||||
int rtn =db.Insertable<T>(t).ExecuteCommand();
|
||||
ClearCache();
|
||||
return rtn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加多个对象
|
||||
/// </summary>
|
||||
/// <param name="ts"></param>
|
||||
/// <returns></returns>
|
||||
public virtual int AddRangeList(List<T> ts)
|
||||
{
|
||||
int rtn =db.Insertable<T>(ts).ExecuteCommand();
|
||||
ClearCache();
|
||||
return rtn;
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新对象
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
public virtual int Update(T t,bool clearCache=true)
|
||||
{
|
||||
int rtn =db.Updateable<T>(t).ExecuteCommand();
|
||||
if(clearCache)
|
||||
ClearCache();
|
||||
return rtn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新多个对象
|
||||
/// </summary>
|
||||
/// <param name="ts"></param>
|
||||
/// <returns></returns>
|
||||
public virtual int Update(List<T> ts,bool trans=true)
|
||||
{
|
||||
int rslt = 0;
|
||||
|
||||
try
|
||||
{
|
||||
if(trans)
|
||||
db.BeginTran();
|
||||
foreach (var t in ts)
|
||||
{
|
||||
rslt += this.Update(t,false);
|
||||
}
|
||||
if(trans)
|
||||
db.CommitTran();
|
||||
ClearCache();
|
||||
}
|
||||
catch
|
||||
{
|
||||
db.RollbackTran();
|
||||
}
|
||||
return rslt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除对象(物理)
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
public virtual int Delete(T t)
|
||||
{
|
||||
int rtn =db.Deleteable<T>(t).ExecuteCommand();
|
||||
ClearCache();
|
||||
return rtn;
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除一批对象(物理)
|
||||
/// </summary>
|
||||
/// <param name="ts"></param>
|
||||
/// <returns></returns>
|
||||
public virtual int Delete(List<T> ts)
|
||||
{
|
||||
int rtn = db.Deleteable<T>(ts).ExecuteCommand();
|
||||
ClearCache();
|
||||
return rtn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按条件删除对象
|
||||
/// </summary>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
public virtual int DeleteBy(System.Linq.Expressions.Expression<Func<T, bool>> expression)
|
||||
{
|
||||
int rtn =db.Deleteable<T>(expression).ExecuteCommand();
|
||||
ClearCache();
|
||||
return rtn;
|
||||
}
|
||||
/// <summary>
|
||||
/// 清空缓存
|
||||
/// </summary>
|
||||
public virtual void ClearCache()
|
||||
{
|
||||
_memoryCache.Remove(CACHEKEY);
|
||||
}
|
||||
/// <summary>
|
||||
/// 清空缓存
|
||||
/// </summary>
|
||||
public virtual void ClearCache(string id)
|
||||
{
|
||||
_memoryCache.Remove(CACHEKEY + id);
|
||||
}
|
||||
|
||||
public virtual SqlSugarClient getClient()
|
||||
{
|
||||
// string str =this.db.Ado.Connection.ConnectionString;
|
||||
return this.db;
|
||||
|
||||
}
|
||||
|
||||
public virtual void BeginTrans()
|
||||
{
|
||||
this.db.Ado.BeginTran();
|
||||
}
|
||||
|
||||
public virtual void CommitTran()
|
||||
{
|
||||
this.db.Ado.CommitTran();
|
||||
}
|
||||
|
||||
public virtual void RollbackTran()
|
||||
{
|
||||
this.db.Ado.RollbackTran();
|
||||
}
|
||||
|
||||
public virtual string getCacheKey()
|
||||
{
|
||||
return this.CACHEKEY;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface ISystemButton: IRoadFlowRepository<RoadFlow.Model.rf_systembutton>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Furion.DependencyInjection;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class SystemButton: RoadFlowRepository<RoadFlow.Model.rf_systembutton>, ISystemButton, ITransient
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
50
20220330_Vote/Ewide.RoadFlow/Data/User/IUserDummy.cs
Normal file
50
20220330_Vote/Ewide.RoadFlow/Data/User/IUserDummy.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Ewide.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IUserDummy
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据一组ID字符串得到人员的姓名
|
||||
/// </summary>
|
||||
/// <param name="id">逗号分开的ID</param>
|
||||
/// <returns></returns>
|
||||
public string GetNames(string ids);
|
||||
|
||||
/// <summary>
|
||||
/// 判断一个人员ID是否在一个组织机构字符串中
|
||||
/// </summary>
|
||||
/// <param name="organizeIds"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public bool Contains(string organizeIds, string userId);
|
||||
/// <summary>
|
||||
/// 判断一个人员是否在一个组织架构字符串里
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="memberIds"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsIn(string userId, string memberIds);
|
||||
|
||||
/// <summary>
|
||||
/// 得到人员的签章图片路径(VUE版本)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetSignSrcVue(string userId = "", string userName = "");
|
||||
|
||||
/// <summary>
|
||||
/// 得到用户加密后的密码
|
||||
/// </summary>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <param name="password">密码</param>
|
||||
/// <returns></returns>
|
||||
public string GetMD5Password(string userId, string password);
|
||||
|
||||
public SysUser Get(string id);
|
||||
}
|
||||
}
|
||||
550
20220330_Vote/Ewide.RoadFlow/Data/User/UserDummy.cs
Normal file
550
20220330_Vote/Ewide.RoadFlow/Data/User/UserDummy.cs
Normal file
@@ -0,0 +1,550 @@
|
||||
using Ewide.Core;
|
||||
using Furion;
|
||||
using Furion.DatabaseAccessor;
|
||||
using Furion.DependencyInjection;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RoadFlow.Data;
|
||||
using RoadFlow.Model.FlowRunModel;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class UserDummy: IUserDummy, ITransient
|
||||
{
|
||||
private readonly IRepository<SysUser> _sysUserRep =App.GetService<IRepository<SysUser>>(); // 用户表仓储
|
||||
private readonly IRepository<SysOrg> _sysOrgRep =App.GetService< IRepository<SysOrg>>();
|
||||
private readonly IRepository<SysEmp> _sysEmpRep=App.GetService<IRepository<SysEmp>>();
|
||||
private readonly IRepository<SysEmpExtOrgPos> _sysEmpExtOrgPosRep= App.GetService<IRepository<SysEmpExtOrgPos>>();
|
||||
private readonly IRepository<SysRole> _sysRoleRep= App.GetService<IRepository<SysRole>>();
|
||||
private readonly IOrganize _organize = new Organize();
|
||||
private readonly IUserManager _userManager = App.GetService<IUserManager>();
|
||||
private readonly IRepository<SysRoleDataScope> _sysRoleDataScopeRep= App.GetService<IRepository<SysRoleDataScope>>();
|
||||
|
||||
/// <summary>
|
||||
/// 根据一组ID字符串得到人员的姓名
|
||||
/// </summary>
|
||||
/// <param name="id">逗号分开的ID</param>
|
||||
/// <returns></returns>
|
||||
public string GetNames(string ids)
|
||||
{
|
||||
if (ids.IsNullOrEmpty())
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
List<string> userids = new List<string>();
|
||||
foreach (string id in ids.Split(','))
|
||||
{
|
||||
string userId = id;
|
||||
if (id.StartsWith(IOrganize.PREFIX_USER))
|
||||
{
|
||||
userId = id.RemoveUserPrefix();
|
||||
}
|
||||
if (!userId.IsGuid())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
userids.Add(userId);
|
||||
}
|
||||
List<SysUser> users = _sysUserRep.DetachedEntities.Where(x => userids.Contains(x.Id)).ToList();
|
||||
foreach (SysUser u in users)
|
||||
{
|
||||
stringBuilder.Append(u.Name);
|
||||
stringBuilder.Append("、");
|
||||
}
|
||||
return stringBuilder.ToString().TrimEnd('、');
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 判断一个人员ID是否在一个组织机构字符串中
|
||||
/// </summary>
|
||||
/// <param name="organizeIds"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public bool Contains(string organizeIds, string userId)
|
||||
{
|
||||
string[] orgids = organizeIds.Split(',');
|
||||
for (int a = 0; a < orgids.Length; a++)
|
||||
{
|
||||
string curent = orgids[a];
|
||||
if (curent.StartsWith(IOrganize.PREFIX_USER) && curent.RemoveUserPrefix() == userId)
|
||||
return true;
|
||||
if (curent.StartsWith(IOrganize.PREFIX_RELATION) && curent.RemoveUserRelationPrefix() == userId)
|
||||
return true;
|
||||
if (curent.StartsWith(IOrganize.PREFIX_WORKGROUP))
|
||||
orgids[a] = curent.RemoveWorkGroupPrefix();
|
||||
}
|
||||
bool emp =_sysEmpRep.Count(x => x.Id == userId && orgids.Contains(x.OrgId))>0;
|
||||
bool extEmp=_sysEmpExtOrgPosRep.Count(x => x.SysEmpId == userId && orgids.Contains(x.SysOrgId)) > 0;
|
||||
return emp | extEmp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断一个人员是否在一个组织架构字符串里
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="memberIds"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsIn(string userId, string memberIds)
|
||||
{
|
||||
if (!userId.IsGuid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (userId.StartsWith(IOrganize.PREFIX_USER))
|
||||
{
|
||||
userId = userId.RemoveUserPrefix();
|
||||
}
|
||||
else if (userId.StartsWith(IOrganize.PREFIX_RELATION))
|
||||
{
|
||||
userId = userId.RemoveUserRelationPrefix ();
|
||||
}
|
||||
|
||||
var users = _organize.GetAllUsers(memberIds);
|
||||
return users.Exists(p => p.Id == userId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到人员的签章图片路径(VUE版本)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetSignSrcVue(string userId = "", string userName = "")
|
||||
{
|
||||
string rootPath = Tools.GetContentRootPath() + "/wwwroot";
|
||||
string signPath = "/roadflow-files/user-signs/" + (userId.IsNullOrWhiteSpace() ? _userManager.UserId.ToLower() : userId.ToLower()) + "/default.png";
|
||||
if (File.Exists(rootPath + signPath))
|
||||
{
|
||||
return signPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
string dirName = Path.GetDirectoryName(rootPath + signPath);
|
||||
if (!Directory.Exists(dirName))
|
||||
{
|
||||
Directory.CreateDirectory(dirName);
|
||||
}
|
||||
var img = CreateSignImage(userName.IsNullOrWhiteSpace() ? _userManager.Name : userName);
|
||||
img.Save(rootPath + signPath, System.Drawing.Imaging.ImageFormat.Png);
|
||||
return signPath;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置签章图片
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <returns></returns>
|
||||
public string ResetSignSrcVue(string userId = "", string userName = "")
|
||||
{
|
||||
string rootPath = Tools.GetContentRootPath() + "/wwwroot";
|
||||
string signPath = "/roadflow-files/user-signs/" + (userId.IsNullOrWhiteSpace() ? _userManager.UserId.ToLower(): userId.ToLower()) + "/default.png";
|
||||
string dirName = Path.GetDirectoryName(rootPath + signPath);
|
||||
if (!Directory.Exists(dirName))
|
||||
{
|
||||
Directory.CreateDirectory(dirName);
|
||||
}
|
||||
var img = CreateSignImage(userName.IsNullOrWhiteSpace() ? _userManager.Name : userName);
|
||||
img.Save(rootPath + signPath, System.Drawing.Imaging.ImageFormat.Png);
|
||||
return signPath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成签章图片
|
||||
/// </summary>
|
||||
/// <param name="UserName"></param>
|
||||
/// <returns></returns>
|
||||
public Bitmap CreateSignImage(string UserName)
|
||||
{
|
||||
if (UserName.IsNullOrEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Random rand = new Random(UserName.GetHashCode());
|
||||
Size ImageSize = Size.Empty;
|
||||
Font myFont;
|
||||
try
|
||||
{
|
||||
myFont = new Font("LiSu", 16);
|
||||
}
|
||||
catch
|
||||
{
|
||||
myFont = new Font(new FontFamily(System.Drawing.Text.GenericFontFamilies.Monospace), 16);
|
||||
}
|
||||
// 计算图片大小
|
||||
using (Bitmap bmp1 = new Bitmap(5, 5))
|
||||
{
|
||||
using (Graphics g = Graphics.FromImage(bmp1))
|
||||
{
|
||||
SizeF size = g.MeasureString(UserName, myFont, 10000);
|
||||
ImageSize.Width = (int)size.Width + 4;
|
||||
ImageSize.Height = (int)size.Height;
|
||||
}
|
||||
}
|
||||
// 创建图片
|
||||
Bitmap bmp = new Bitmap(ImageSize.Width, ImageSize.Height);
|
||||
// 绘制文本
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
{
|
||||
g.Clear(Color.White);
|
||||
using (StringFormat f = new StringFormat())
|
||||
{
|
||||
f.Alignment = StringAlignment.Center;
|
||||
f.LineAlignment = StringAlignment.Center;
|
||||
f.FormatFlags = StringFormatFlags.NoWrap;
|
||||
g.DrawString(
|
||||
UserName,
|
||||
myFont,
|
||||
Brushes.Red,
|
||||
new RectangleF(
|
||||
0,
|
||||
2,
|
||||
ImageSize.Width,
|
||||
ImageSize.Height),
|
||||
f);
|
||||
}
|
||||
}
|
||||
|
||||
// 随机制造噪点 (用户名绑定)
|
||||
Color c = Color.Red;
|
||||
int x, y;
|
||||
int num = ImageSize.Width * ImageSize.Height * 8 / 100;
|
||||
for (int iCount = 0; iCount < num; iCount++)
|
||||
{
|
||||
x = rand.Next(0, 4);
|
||||
y = rand.Next(ImageSize.Height);
|
||||
bmp.SetPixel(x, y, c);
|
||||
|
||||
x = rand.Next(ImageSize.Width - 4, ImageSize.Width);
|
||||
y = rand.Next(ImageSize.Height);
|
||||
bmp.SetPixel(x, y, c);
|
||||
|
||||
}
|
||||
|
||||
int num1 = ImageSize.Width * ImageSize.Height * 20 / 100;
|
||||
for (int iCount = 0; iCount < num1; iCount++)
|
||||
{
|
||||
x = rand.Next(ImageSize.Width);
|
||||
y = rand.Next(0, 4);
|
||||
bmp.SetPixel(x, y, c);
|
||||
|
||||
x = rand.Next(ImageSize.Width);
|
||||
y = rand.Next(ImageSize.Height - 4, ImageSize.Height);
|
||||
bmp.SetPixel(x, y, c);
|
||||
}
|
||||
|
||||
int num2 = ImageSize.Width * ImageSize.Height / 150;
|
||||
for (int iCount = 0; iCount < num2; iCount++)
|
||||
{
|
||||
x = rand.Next(ImageSize.Width);
|
||||
y = rand.Next(ImageSize.Height);
|
||||
bmp.SetPixel(x, y, c);
|
||||
}
|
||||
myFont.Dispose();
|
||||
return bmp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户部门
|
||||
/// </summary>
|
||||
/// <param name="uid"></param>
|
||||
/// <returns></returns>
|
||||
public SysOrg GetDept(string uid)
|
||||
{
|
||||
string oid = _sysEmpRep.DetachedEntities.FirstOrDefault(x => x.Id == uid).OrgId;
|
||||
return _sysOrgRep.DetachedEntities.FirstOrDefault(x => x.Id == oid);
|
||||
|
||||
}
|
||||
|
||||
public SysPos GetStation(string uid)
|
||||
{
|
||||
return _sysEmpRep.DetachedEntities.FirstOrDefault(x => x.Id == uid).SysEmpPos[0].SysPos;
|
||||
}
|
||||
|
||||
public string GetWorkGroupsId(string userId)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
public string GetWorkGroupsName(string userId)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
public static string LEADER_CODE="";
|
||||
|
||||
public string GetLeader(string userId)
|
||||
{
|
||||
string orgid =_sysEmpRep.DetachedEntities.FirstOrDefault(x => x.Id == userId).OrgId;
|
||||
var emps =_sysEmpRep.DetachedEntities.Where(x => x.OrgId == orgid).ToList();
|
||||
HashSet<string> userIds = new HashSet<string>();
|
||||
foreach (var e in emps)
|
||||
userIds.Add(e.Id);
|
||||
var leaders =_sysRoleRep.DetachedEntities.Where(x => x.Code == LEADER_CODE).ToList();
|
||||
foreach (var l in leaders)
|
||||
{
|
||||
foreach (var u in l.SysUsers)
|
||||
{
|
||||
if (userIds.Contains(u.Id))
|
||||
return u.Id;
|
||||
}
|
||||
|
||||
}
|
||||
return string.Empty;
|
||||
|
||||
}
|
||||
public SysOrg GetUnit(string userId)
|
||||
{
|
||||
string orgid =_sysEmpRep.DetachedEntities.FirstOrDefault(x => x.Id == userId).OrgId;
|
||||
return _sysOrgRep.DetachedEntities.FirstOrDefault(x => x.Id == orgid);
|
||||
}
|
||||
|
||||
public string GetName(string userId)
|
||||
{
|
||||
return _sysUserRep.DetachedEntities.FirstOrDefault(x => x.Id == userId)?.Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个人员所在部门的工作角色
|
||||
/// </summary>
|
||||
/// <param name="id">人员id</param>
|
||||
/// <returns></returns>
|
||||
public JArray GetWorkRole(string userId)
|
||||
{
|
||||
SysUser usr =_sysUserRep.DetachedEntities.FirstOrDefault(x => x.Id == userId);
|
||||
return JArray.FromObject(usr.SysRoles);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到一批人员的部门领导和分管领导
|
||||
/// </summary>
|
||||
/// <param name="userIds"></param>
|
||||
/// <returns></returns>
|
||||
public (string leader, string chargeLeader) GetLeader(List<string> userIds)
|
||||
{
|
||||
StringBuilder leaderBuilder = new StringBuilder();
|
||||
StringBuilder chargeLeaderBuilder = new StringBuilder();
|
||||
foreach (string userId in userIds)
|
||||
{
|
||||
string leader = GetLeader(userId);
|
||||
string chargeLeader = leader;
|
||||
leaderBuilder.Append(leader);
|
||||
leaderBuilder.Append(",");
|
||||
chargeLeaderBuilder.Append(chargeLeader);
|
||||
chargeLeaderBuilder.Append(",");
|
||||
}
|
||||
return (leaderBuilder.ToString().TrimEnd(','), chargeLeaderBuilder.ToString().TrimEnd(','));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个人员的上级部门领导
|
||||
/// </summary>
|
||||
/// <param name="userId">guid(人ID),u_guid(人ID),r_guid(关系表ID)</param>
|
||||
/// <returns></returns>
|
||||
public (string leader, string chargeLeader) GetParentLeader(string userId)
|
||||
{
|
||||
var emp = _sysEmpRep.DetachedEntities.FirstOrDefault(x => x.Id == userId);
|
||||
var org = _sysOrgRep.DetachedEntities.FirstOrDefault(x => x.Id == emp.OrgId);
|
||||
var parent = _sysOrgRep.DetachedEntities.FirstOrDefault(x => x.Id == org.Pid);
|
||||
|
||||
var emps = _sysEmpRep.DetachedEntities.Where(x => x.OrgId == parent.Id).ToList();
|
||||
HashSet<string> userIds = new HashSet<string>();
|
||||
foreach (var e in emps)
|
||||
userIds.Add(e.Id);
|
||||
var leaders = _sysRoleRep.DetachedEntities.Where(x => x.Code == LEADER_CODE).ToList();
|
||||
foreach (var l in leaders)
|
||||
{
|
||||
foreach (var u in l.SysUsers)
|
||||
{
|
||||
if (userIds.Contains(u.Id))
|
||||
return (u.Id,u.Id);
|
||||
}
|
||||
|
||||
}
|
||||
return (string.Empty, string.Empty);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 得到一批人员的上级部门领导
|
||||
/// </summary>
|
||||
/// <param name="userId">guid(人ID),u_guid(人ID),r_guid(关系表ID)</param>
|
||||
/// <returns></returns>
|
||||
public (string leader, string chargeLeader) GetParentLeader(List<string> userIds)
|
||||
{
|
||||
StringBuilder leaderBuilder = new StringBuilder();
|
||||
StringBuilder chargeLeaderBuilder = new StringBuilder();
|
||||
foreach (string userId in userIds)
|
||||
{
|
||||
(string leader, string chargeLeader) = GetParentLeader(userId);
|
||||
leaderBuilder.Append(leader);
|
||||
leaderBuilder.Append(",");
|
||||
chargeLeaderBuilder.Append(chargeLeader);
|
||||
chargeLeaderBuilder.Append(",");
|
||||
}
|
||||
return (leaderBuilder.ToString().TrimEnd(','), chargeLeaderBuilder.ToString().TrimEnd(','));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个人员的所有上级部门领导
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public (string leader, string chargeLeader) GetAllParentLeader(string userId)
|
||||
{
|
||||
|
||||
var emp = _sysEmpRep.DetachedEntities.FirstOrDefault(x => x.Id == userId);
|
||||
var org = _sysOrgRep.DetachedEntities.FirstOrDefault(x => x.Id == emp.OrgId);
|
||||
List<string> orgIds = new List<string>();
|
||||
foreach (string str in org.Pids.Split("],",StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
orgIds.Add(str.TrimStart('['));
|
||||
}
|
||||
List<SysEmp> emps =_sysEmpRep.DetachedEntities.Where(x => orgIds.Contains(x.OrgId)).ToList();
|
||||
HashSet<string> uids = new HashSet<string>();
|
||||
foreach (SysEmp em in emps)
|
||||
uids.Add(em.Id);
|
||||
|
||||
var leaders = _sysRoleRep.DetachedEntities.Where(x => x.Code == LEADER_CODE).ToList();
|
||||
|
||||
StringBuilder leader = new StringBuilder();
|
||||
foreach (var l in leaders)
|
||||
{
|
||||
foreach (var u in l.SysUsers)
|
||||
{
|
||||
if (uids.Contains(u.Id))
|
||||
leader.Append(u.Id).Append(",");
|
||||
}
|
||||
}
|
||||
string rtn = leader.ToString().TrimEnd(',');
|
||||
return (rtn,rtn);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 得到一批人员的所有上级部门领导
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public (string leader, string chargeLeader) GetAllParentLeader(List<string> userIds)
|
||||
{
|
||||
var empss = _sysEmpRep.DetachedEntities.Where(x => userIds.Contains(x.Id) ).ToList();
|
||||
HashSet<string> orgset = new HashSet<string>();
|
||||
foreach (var em in empss)
|
||||
{
|
||||
orgset.Add(em.OrgId);
|
||||
}
|
||||
var orgs =_sysOrgRep.DetachedEntities.Where(x => orgset.Contains(x.Id));
|
||||
HashSet<string> orgIds = new HashSet<string>();
|
||||
foreach (var org in orgs)
|
||||
{
|
||||
foreach (string str in org.Pids.Split("],", StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
orgIds.Add(str.TrimStart('['));
|
||||
}
|
||||
}
|
||||
List<SysEmp> emps = _sysEmpRep.DetachedEntities.Where(x => orgIds.Contains(x.OrgId)).ToList();
|
||||
HashSet<string> uids = new HashSet<string>();
|
||||
foreach (SysEmp em in emps)
|
||||
uids.Add(em.Id);
|
||||
|
||||
var leaders = _sysRoleRep.DetachedEntities.Where(x => x.Code == LEADER_CODE).ToList();
|
||||
|
||||
StringBuilder leader = new StringBuilder();
|
||||
foreach (var l in leaders)
|
||||
{
|
||||
foreach (var u in l.SysUsers)
|
||||
{
|
||||
if (uids.Contains(u.Id))
|
||||
leader.Append(u.Id).Append(",");
|
||||
}
|
||||
}
|
||||
string rtn = leader.ToString().TrimEnd(',');
|
||||
return (rtn, rtn);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到人员ID字符串
|
||||
/// </summary>
|
||||
/// <param name="users"></param>
|
||||
/// <returns>u_人员ID1,u_人员ID2</returns>
|
||||
public string GetUserIds(List<User> users)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
foreach (var user in users)
|
||||
{
|
||||
stringBuilder.Append(IOrganize.PREFIX_USER);
|
||||
stringBuilder.Append(user.Id);
|
||||
stringBuilder.Append(",");
|
||||
}
|
||||
return stringBuilder.ToString().TrimEnd(',');
|
||||
}
|
||||
public string GetUserIds(List<SysUser> users)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
foreach (var user in users)
|
||||
{
|
||||
stringBuilder.Append(IOrganize.PREFIX_USER);
|
||||
stringBuilder.Append(user.Id);
|
||||
stringBuilder.Append(",");
|
||||
}
|
||||
return stringBuilder.ToString().TrimEnd(',');
|
||||
}
|
||||
|
||||
public string GetUserIds(List<SysEmp> users)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
foreach (var user in users)
|
||||
{
|
||||
stringBuilder.Append(IOrganize.PREFIX_USER);
|
||||
stringBuilder.Append(user.Id);
|
||||
stringBuilder.Append(",");
|
||||
}
|
||||
return stringBuilder.ToString().TrimEnd(',');
|
||||
}
|
||||
/// <summary>
|
||||
/// 得到一个人员所在部门所有人员
|
||||
/// </summary>
|
||||
/// <param name="userId">guid(人ID),u_guid(人ID),r_guid(关系表ID)</param>
|
||||
/// <returns></returns>
|
||||
public List<SysEmp> GetOrganizeUsers(string userId)
|
||||
{
|
||||
string id = userId.StartsWith(IOrganize.PREFIX_RELATION) ? userId.RemoveUserRelationPrefix() : userId.StartsWith(IOrganize.PREFIX_USER) ? userId.RemoveUserPrefix() : userId;
|
||||
string oid =_sysEmpRep.DetachedEntities.FirstOrDefault(x => x.Id == id).OrgId;
|
||||
return _sysEmpRep.DetachedEntities.Where(x => x.OrgId == oid).ToList();
|
||||
/*Guid organzieId = GetOrganizeId(userId);
|
||||
return new Organize(systemCode).GetAllUsers(organzieId);*/
|
||||
}
|
||||
private HashSet<SysUser> tmpUserCache;
|
||||
public SysUser GetFromTempCache(string userId)
|
||||
{
|
||||
if (tmpUserCache == null)
|
||||
tmpUserCache = _sysUserRep.DetachedEntities.ToHashSet();
|
||||
return tmpUserCache.FirstOrDefault(x => x.Id == userId);
|
||||
}
|
||||
|
||||
public SysUser Get(string id)
|
||||
{
|
||||
return _sysUserRep.DetachedEntities.FirstOrDefault(x=>x.Id ==id);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 得到用户加密后的密码
|
||||
/// </summary>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <param name="password">密码</param>
|
||||
/// <returns></returns>
|
||||
public string GetMD5Password(string userId, string password)
|
||||
{
|
||||
return (userId.ToString().ToUpper() + password).MD5();
|
||||
}
|
||||
}
|
||||
}
|
||||
541
20220330_Vote/Ewide.RoadFlow/Data/Wildcard.cs
Normal file
541
20220330_Vote/Ewide.RoadFlow/Data/Wildcard.cs
Normal file
@@ -0,0 +1,541 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Ewide.Core;
|
||||
using RoadFlow.Data;
|
||||
using RoadFlow.Utility;
|
||||
|
||||
namespace RoadFlow.Business
|
||||
{
|
||||
/// <summary>
|
||||
/// 通配符类
|
||||
/// </summary>
|
||||
public class Wildcard
|
||||
{
|
||||
|
||||
|
||||
private static readonly string[] wildcardList = new string[] {
|
||||
"{<UserId>}",
|
||||
"{<UserName>}",
|
||||
"{<UserAccount>}",
|
||||
"{<UserDeptId>}",
|
||||
"{<UserDeptName>}",
|
||||
"{<UserStationId>}",
|
||||
"{<UserStationName>}",
|
||||
"{<UserWorkGroupId>}",
|
||||
"{<UserWorkGroupName>}",
|
||||
"{<UserDeptLeaderId>}",
|
||||
"{<UserDeptLeaderName>}",
|
||||
"{<UserCharegLeaderId>}",
|
||||
"{<UserCharegLeaderName>}",
|
||||
"{<UserUnitId>}",
|
||||
"{<UserUnitName>}",
|
||||
"{<InitiatorId>}",
|
||||
"{<InitiatorName>}",
|
||||
"{<InitiatorDeptId>}",
|
||||
"{<InitiatorDeptName>}",
|
||||
"{<InitiatorStationId>}",
|
||||
"{<InitiatorStationName>}",
|
||||
"{<InitiatorRoleId>}",
|
||||
"{<InitiatorRoleName>}",
|
||||
"{<InitiatorUnitId>}",
|
||||
"{<InitiatorUnitName>}",
|
||||
"{<InitiatorLeaderId>}",
|
||||
"{<InitiatorLeaderName>}",
|
||||
"{<InitiatorCharegId>}",
|
||||
"{<InitiatorCharegName>}",
|
||||
"{<ShortDate>}",
|
||||
"{<LongDate>}",
|
||||
"{<ShortDateTime>}",
|
||||
"{<LongDateTime>}",
|
||||
"{<ShortDateTimeSecond>}",
|
||||
"{<LongDateTimeSecond>}",
|
||||
"{<FlowId>}",
|
||||
"{<FlowName>}",
|
||||
"{<StepId>}",
|
||||
"{<StepName>}",
|
||||
"{<TaskId>}",
|
||||
"{<InstanceId>}",
|
||||
"{<GroupId>}",
|
||||
"{<PrevInstanceId>}",
|
||||
"{<PrevFlowTitle>}",
|
||||
"{<Guid>}",
|
||||
"{<EmptyGuid>}",
|
||||
|
||||
"{Query<",
|
||||
"{Form<",
|
||||
"{DataRow<",
|
||||
"{Date<",
|
||||
"{Method<",
|
||||
"{SQL<",
|
||||
"{JArray<",
|
||||
"{JObject<"
|
||||
};
|
||||
|
||||
public static string GetWildcardValue(string wildcard, SysUser userModel, object obj)
|
||||
{
|
||||
IUserManager userManager = Furion.App.GetService<IUserManager>();
|
||||
UserDummy user = new UserDummy();
|
||||
|
||||
var httpContext = Tools.HttpContext;
|
||||
Microsoft.AspNetCore.Http.HttpRequest request = httpContext?.Request;
|
||||
switch (wildcard.ToLower())
|
||||
{
|
||||
case "{<userid>}"://当前用户ID
|
||||
userModel = userModel ?? userManager.User;
|
||||
return userModel == null ? "" : userModel.Id.ToUpper();
|
||||
case "{<username>}"://当前用户姓名
|
||||
userModel = userModel ?? userManager.User;
|
||||
return userModel == null ? "" : userModel.Name;
|
||||
case "{<useraccount>}"://当前帐号
|
||||
userModel = userModel ?? userManager.User;
|
||||
return userModel == null ? "" : userModel.Account;
|
||||
case "{<userdeptid>}"://当前用户部门ID
|
||||
userModel = userModel ?? userManager.User;
|
||||
if (userModel == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
var dept = user.GetDept(userModel.Id);
|
||||
return dept == null ? "" : dept.Id.ToUpper();
|
||||
case "{<userdeptname>}"://当前用户部门名称
|
||||
userModel = userModel ?? userManager.User;
|
||||
if (userModel == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
var dept1 = user.GetDept(userModel.Id);
|
||||
return dept1 == null ? "" : dept1.Name;
|
||||
case "{<userstationid>}"://当前用户岗位ID
|
||||
userModel = userModel ?? userManager.User;
|
||||
if (userModel == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
var station = user.GetStation(userModel.Id);
|
||||
return station == null ? "" : station.Id.ToUpper();
|
||||
case "{<userstationname>}"://当前用户岗位名称
|
||||
userModel = userModel ?? userManager.User;
|
||||
if (userModel == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
var station1 = user.GetStation(userModel.Id);
|
||||
return station1 == null ? "" : station1.Name;
|
||||
case "{<userworkgroupid>}"://当前用户工作组ID
|
||||
userModel = userModel ?? userManager.User;
|
||||
return userModel == null ? "" : user.GetWorkGroupsId(userModel.Id);
|
||||
case "{<userworkgroupname>}"://当前用户工作组名称
|
||||
userModel = userModel ?? userManager.User;
|
||||
return userModel == null ? "" : user.GetWorkGroupsName(userModel.Id);
|
||||
case "{<userdeptleaderid>}"://当前用户部门领导ID
|
||||
userModel = userModel ?? userManager.User;
|
||||
return userModel == null ? "" : user.GetLeader(userModel.Id.ToString());
|
||||
case "{<userdeptleadername>}"://当前用户部门领导姓名
|
||||
userModel = userModel ?? userManager.User;
|
||||
return userModel == null ? "" : user.GetNames(user.GetLeader(userModel.Id));
|
||||
case "{<usercharegleaderid>}"://当前用户分管领导ID
|
||||
userModel = userModel ?? userManager.User;
|
||||
return userModel == null ? "" : user.GetLeader(userModel.Id);
|
||||
case "{<usercharegleadername>}"://当前用户分管领导姓名
|
||||
userModel = userModel ?? userManager.User;
|
||||
return userModel == null ? "" : user.GetNames(user.GetLeader(userModel.Id));
|
||||
case "{<userunitid>}"://当前用户单位ID
|
||||
userModel = userModel ?? userManager.User;
|
||||
if (userModel == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
var unit = user.GetUnit(userModel.Id);
|
||||
return unit == null ? "" : unit.Id.ToUpper();
|
||||
case "{<userunitname>}"://当前用户单位名称
|
||||
userModel = userModel ?? userManager.User;
|
||||
if (userModel == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
var unit1 = user.GetUnit(userModel.Id.ToString());
|
||||
return unit1 == null ? "" : unit1.Name;
|
||||
case "{<initiatorid>}"://发起者ID
|
||||
userModel = userModel ?? userManager.User;
|
||||
var firstId = new FlowTask().GetFirstSenderId(request.Querys("groupid"));
|
||||
return firstId.IsNullOrWhiteSpace() && userModel != null ? userModel.Id.ToString() : firstId.ToString();
|
||||
case "{<initiatorname>}"://发起者姓名
|
||||
userModel = userModel ?? userManager.User;
|
||||
var firstId1 = new FlowTask().GetFirstSenderId(request.Querys("groupid"));
|
||||
return firstId1.IsNullOrWhiteSpace() && userModel != null ? userModel.Name : user.GetName(firstId1);
|
||||
case "{<initiatordeptid>}"://发起者部门ID
|
||||
userModel = userModel ?? userManager.User;
|
||||
var firstId2 = new FlowTask().GetFirstSenderId(request.Querys("groupid"));
|
||||
if (firstId2.IsNullOrWhiteSpace() && null != userModel)
|
||||
{
|
||||
firstId2 = userModel.Id;
|
||||
}
|
||||
var dept2 = user.GetDept(firstId2.ToString());
|
||||
return null == dept2 ? "" : dept2.Id.ToString();
|
||||
case "{<initiatordeptname>}"://发起者部门名称
|
||||
userModel = userModel ?? userManager.User;
|
||||
var firstId3 = new FlowTask().GetFirstSenderId(request.Querys("groupid"));
|
||||
if (firstId3.IsNullOrWhiteSpace() && null != userModel)
|
||||
{
|
||||
firstId3 = userModel.Id;
|
||||
}
|
||||
var dept3 = user.GetDept(firstId3.ToString());
|
||||
return dept3 == null ? "" : dept3.Name;
|
||||
case "{<initiatorstationid>}"://发起者岗位ID
|
||||
userModel = userModel ?? userManager.User;
|
||||
var firstId4 = new FlowTask().GetFirstSenderId(request.Querys("groupid"));
|
||||
if (firstId4.IsNullOrWhiteSpace() && null != userModel)
|
||||
{
|
||||
firstId4 = userModel.Id;
|
||||
}
|
||||
var station4 = user.GetStation(firstId4.ToString());
|
||||
return station4 == null ? "" : station4.Id.ToString();
|
||||
case "{<initiatorstationname>}"://发起者岗位名称
|
||||
var firstId5 = new FlowTask().GetFirstSenderId(request.Querys("groupid"));
|
||||
userModel = userModel ?? userManager.User;
|
||||
if (firstId5.IsNullOrWhiteSpace() && null != userModel)
|
||||
{
|
||||
firstId5 = userModel.Id;
|
||||
}
|
||||
var station5 = user.GetStation(firstId5.ToString());
|
||||
return station5 == null ? "" : station5.Name;
|
||||
case "{<initiatorworkgroupid>}"://发起者角色组ID
|
||||
var firstId6 = new FlowTask().GetFirstSenderId(request.Querys("groupid"));
|
||||
userModel = userModel ?? userManager.User;
|
||||
if (firstId6.IsNullOrWhiteSpace() && null != userModel)
|
||||
{
|
||||
firstId6 = userModel.Id;
|
||||
}
|
||||
return user.GetWorkGroupsId(firstId6);
|
||||
case "{<initiatorworkgroupname>}"://发起者角色组名称
|
||||
var firstId7 = new FlowTask().GetFirstSenderId(request.Querys("groupid"));
|
||||
userModel = userModel ?? userManager.User;
|
||||
if (firstId7.IsNullOrWhiteSpace() && null != userModel)
|
||||
{
|
||||
firstId7 = userModel.Id;
|
||||
}
|
||||
return user.GetWorkGroupsName(firstId7);
|
||||
case "{<initiatorunitid>}"://发起者单位ID
|
||||
var firstId8 = new FlowTask().GetFirstSenderId(request.Querys("groupid"));
|
||||
userModel = userModel ?? userManager.User;
|
||||
if (firstId8.IsNullOrWhiteSpace() && null != userModel)
|
||||
{
|
||||
firstId8 = userModel.Id;
|
||||
}
|
||||
var unit8 = user.GetUnit(firstId8.ToString());
|
||||
return unit8 == null ? "" : unit8.Id.ToString();
|
||||
case "{<initiatorunitname>}"://发起者单位名称
|
||||
var firstId9 = new FlowTask().GetFirstSenderId(request.Querys("groupid"));
|
||||
userModel = userModel ?? userManager.User;
|
||||
if (firstId9.IsNullOrWhiteSpace() && null != userModel)
|
||||
{
|
||||
firstId9 = userModel.Id;
|
||||
}
|
||||
var unit9 = user.GetUnit(firstId9.ToString());
|
||||
return unit9 == null ? "" : unit9.Name;
|
||||
case "{<initiatorleaderid>}"://发起者部门领导ID
|
||||
var firstId10 = new FlowTask().GetFirstSenderId(request.Querys("groupid"));
|
||||
userModel = userModel ?? userManager.User;
|
||||
if (firstId10.IsNullOrWhiteSpace() && null != userModel)
|
||||
{
|
||||
firstId10 = userModel.Id;
|
||||
}
|
||||
return user.GetLeader(firstId10.ToString());
|
||||
case "{<initiatorleadername>}"://发起者部门领导姓名
|
||||
var firstId11 = new FlowTask().GetFirstSenderId(request.Querys("groupid"));
|
||||
userModel = userModel ?? userManager.User;
|
||||
if (firstId11.IsNullOrWhiteSpace() && null != userModel)
|
||||
{
|
||||
firstId11 = userModel.Id;
|
||||
}
|
||||
return user.GetNames(user.GetLeader(firstId11));
|
||||
case "{<initiatorcharegid>}"://发起者分管领导ID
|
||||
var firstId12 = new FlowTask().GetFirstSenderId(request.Querys("groupid"));
|
||||
userModel = userModel ?? userManager.User;
|
||||
if (firstId12.IsNullOrWhiteSpace() && null != userModel)
|
||||
{
|
||||
firstId12 = userModel.Id;
|
||||
}
|
||||
return user.GetLeader(firstId12.ToString());
|
||||
case "{<initiatorcharegname>}"://发起者分管领导姓名
|
||||
var firstId13 = new FlowTask().GetFirstSenderId(request.Querys("groupid"));
|
||||
userModel = userModel ?? userManager.User;
|
||||
if (firstId13.IsNullOrWhiteSpace() && null != userModel)
|
||||
{
|
||||
firstId13 = userModel.Id;
|
||||
}
|
||||
return user.GetNames(user.GetLeader(firstId13.ToString()));
|
||||
case "{<shortdate>}"://短日期格式(yyyy-MM-dd)
|
||||
return DateExtensions.Now.ToString("yyyy-MM-dd");
|
||||
case "{<longdate>}"://长日期格式(yyyy年MM月dd日)
|
||||
return DateExtensions.Now.ToString("yyyy年MM月dd日");
|
||||
case "{<shortdatetime>}"://短日期时间(yyyy-MM-dd HH:mm)
|
||||
return DateExtensions.Now.ToString("yyyy-MM-dd HH:mm");
|
||||
case "{<longdatetime>}"://长日期格式(yyyy年MM月dd日 HH时mm分)
|
||||
return DateExtensions.Now.ToString("yyyy年MM月dd日 HH时mm分");
|
||||
case "{<shortdatetimesecond>}"://短日期时间(yyyy-MM-dd HH:mm:ss)
|
||||
return DateExtensions.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
case "{<longdatetimesecond>}"://长日期格式(yyyy年MM月dd日 HH时mm分ss秒)
|
||||
return DateExtensions.Now.ToString("yyyy年MM月dd日 HH时mm分ss秒");
|
||||
case "{<flowid>}"://流程ID
|
||||
return request.Querys("flowid").IsNullOrWhiteSpace() ? GetValueFromObj(obj, "flowid") : request.Querys("flowid");
|
||||
case "{<flowname>}"://流程名称
|
||||
string flowId = request.Querys("flowid").IsNullOrWhiteSpace() ? GetValueFromObj(obj, "flowid") : request.Querys("flowid");
|
||||
return !flowId.IsGuid() ? "" : new Flow().GetOneById(flowId).Name;
|
||||
case "{<stepid>}"://流程步骤ID
|
||||
return request.Querys("stepid").IsNullOrWhiteSpace() ? GetValueFromObj(obj, "stepid") : request.Querys("stepid");
|
||||
case "{<stepname>}"://流程步骤名称
|
||||
string flowId1 = request.Querys("flowid").IsNullOrWhiteSpace() ? GetValueFromObj(obj, "flowid") : request.Querys("flowid");
|
||||
string stepId = request.Querys("stepid").IsNullOrWhiteSpace() ? GetValueFromObj(obj, "stepid") : request.Querys("stepid");
|
||||
return flowId1.IsGuid() ? new Flow().GetStepName(flowId1, stepId.ToGuid()) : string.Empty;
|
||||
case "{<taskid>}"://任务ID
|
||||
return request.Querys("taskid").IsNullOrWhiteSpace() ? GetValueFromObj(obj, "taskid") : request.Querys("taskid");
|
||||
case "{<instanceid>}"://实例ID
|
||||
string instanceId = request.Querys("instanceid");
|
||||
if (instanceId.IsNullOrWhiteSpace())
|
||||
{
|
||||
instanceId = GetValueFromObj(obj, "instanceid");
|
||||
}
|
||||
if (instanceId.IsNullOrWhiteSpace())
|
||||
{
|
||||
instanceId = request.Forms("form_instanceid");
|
||||
}
|
||||
if (instanceId.IsNullOrWhiteSpace())
|
||||
{
|
||||
instanceId = request.Querys("instanceid1");
|
||||
}
|
||||
return instanceId;
|
||||
case "{<groupid>}"://组ID
|
||||
return request.Querys("groupid").IsNullOrWhiteSpace() ? GetValueFromObj(obj, "groupid") : request.Querys("groupid");
|
||||
case "{<previnstanceid>}"://前一步实例ID
|
||||
return new FlowTask().GetPrevInstanceID(request.Querys("taskid").IsNullOrWhiteSpace() ? GetValueFromObj(obj, "taskid") : request.Querys("taskid"));
|
||||
case "{<prevflowtitle>}"://前一步流程任务标题
|
||||
return new FlowTask().GetPrevTitle(request.Querys("taskid").IsNullOrWhiteSpace() ? GetValueFromObj(obj, "taskid") : request.Querys("taskid"));
|
||||
case "{<guid>}"://随机生成UUID
|
||||
return GuidExtensions.NewGuid().ToString();
|
||||
case "{<emptyguid>}"://空UUID
|
||||
return Guid.Empty.ToString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从对象中获取值
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="idName"></param>
|
||||
/// <returns></returns>
|
||||
private static string GetValueFromObj(object obj, string idName)
|
||||
{
|
||||
if (obj == null || idName.IsNullOrWhiteSpace())
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
if (obj is Model.FlowRunModel.Execute executeModel)
|
||||
{
|
||||
switch (idName.ToLower())
|
||||
{
|
||||
case "flowid":
|
||||
return executeModel.FlowId.ToString();
|
||||
case "stepid":
|
||||
return executeModel.StepId.ToString();
|
||||
case "taskid":
|
||||
return executeModel.TaskId.ToString();
|
||||
case "instanceid":
|
||||
return executeModel.InstanceId.ToString();
|
||||
case "groupid":
|
||||
return executeModel.GroupId.ToString();
|
||||
}
|
||||
}
|
||||
else if (obj is Model.rf_flowtask taskModel)
|
||||
{
|
||||
switch (idName.ToLower())
|
||||
{
|
||||
case "flowid":
|
||||
return taskModel.FlowId.ToString();
|
||||
case "stepid":
|
||||
return taskModel.StepId.ToString();
|
||||
case "taskid":
|
||||
return taskModel.Id.ToString();
|
||||
case "instanceid":
|
||||
return taskModel.InstanceId.ToString();
|
||||
case "groupid":
|
||||
return taskModel.GroupId.ToString();
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 过滤通配符
|
||||
/// </summary>
|
||||
/// <param name="str"></param>
|
||||
/// <param name="currentUser">当前登录用户实体</param>
|
||||
/// <param name="obj">对象</param>
|
||||
/// <returns></returns>
|
||||
public static string Filter(string str, SysUser user = null, object obj = null)
|
||||
{
|
||||
if (str.IsNullOrWhiteSpace())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
var httpContent = Tools.HttpContext;
|
||||
Microsoft.AspNetCore.Http.HttpRequest request = httpContent?.Request;
|
||||
foreach (string wildcard in wildcardList)
|
||||
{
|
||||
while (str.ContainsIgnoreCase(wildcard))
|
||||
{
|
||||
string value = string.Empty;
|
||||
string wildcard1 = wildcard;
|
||||
if ("{Query<".EqualsIgnoreCase(wildcard))
|
||||
{
|
||||
string key = str.Substring(str.IndexOf("{Query<") + 7);
|
||||
string key1 = key.Substring(0, key.IndexOf(">}"));
|
||||
if (!key1.IsNullOrWhiteSpace())
|
||||
{
|
||||
wildcard1 = wildcard + key1 + ">}";
|
||||
value = request.Querys(key1).FilterSelectSql();//2021-3-8增加了.FilterSelectSql(),过滤危险SQL。
|
||||
}
|
||||
}
|
||||
else if ("{Form<".EqualsIgnoreCase(wildcard))
|
||||
{
|
||||
string key = str.Substring(str.IndexOf("{Form<") + 6);
|
||||
string key1 = key.Substring(0, key.IndexOf(">}"));
|
||||
if (!key1.IsNullOrWhiteSpace())
|
||||
{
|
||||
wildcard1 = wildcard + key1 + ">}";
|
||||
value = request.Forms(key1).FilterSelectSql();//2021-3-8增加了.FilterSelectSql(),过滤危险SQL。
|
||||
}
|
||||
}
|
||||
else if ("{DataRow<".EqualsIgnoreCase(wildcard))
|
||||
{
|
||||
string key = str.Substring(str.IndexOf("{DataRow<") + 9);
|
||||
string key1 = key.Substring(0, key.IndexOf(">}"));
|
||||
if (!key1.IsNullOrWhiteSpace())
|
||||
{
|
||||
wildcard1 = wildcard + key1 + ">}";
|
||||
var dr = (System.Data.DataRow)obj;
|
||||
try
|
||||
{
|
||||
value = dr[key1].ToString().FilterSelectSql();//2021-3-8增加了.FilterSelectSql(),过滤危险SQL。
|
||||
}
|
||||
catch
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("{Method<".EqualsIgnoreCase(wildcard))
|
||||
{
|
||||
//执行一个方法替换通配符 object为方法参数
|
||||
string key = str.Substring(str.IndexOf("{Method<") + 8);
|
||||
string key1 = key.Substring(0, key.IndexOf(">}"));
|
||||
if (!key1.IsNullOrWhiteSpace())
|
||||
{
|
||||
wildcard1 = wildcard + key1 + ">}";
|
||||
var (o, err) = obj == null ? Tools.ExecuteMethod(key1) : Tools.ExecuteMethod(key1, obj);
|
||||
value = null == o ? "" : o.ToString().FilterSelectSql();//2021-3-8增加了.FilterSelectSql(),过滤危险SQL。
|
||||
}
|
||||
}
|
||||
else if ("{SQL<".EqualsIgnoreCase(wildcard))
|
||||
{
|
||||
//执行一个SQL替换通配符
|
||||
string key = str.Substring(str.IndexOf("{SQL<") + 5);
|
||||
string key1 = key.Substring(0, key.IndexOf(">}"));
|
||||
if (!key1.IsNullOrWhiteSpace())
|
||||
{
|
||||
wildcard1 = wildcard + key1 + ">}";
|
||||
value = new DbConnection().GetFieldValue(key1).FilterSelectSql();//2021-3-8增加了.FilterSelectSql(),过滤危险SQL。
|
||||
}
|
||||
}
|
||||
else if ("{Date<".EqualsIgnoreCase(wildcard))
|
||||
{
|
||||
//取当前日期替换指定格式
|
||||
string key = str.Substring(str.IndexOf("{Date<") + 6);
|
||||
string key1 = key.Substring(0, key.IndexOf(">}"));
|
||||
if (!key1.IsNullOrWhiteSpace())
|
||||
{
|
||||
wildcard1 = wildcard + key1 + ">}";
|
||||
value = DateExtensions.Now.ToString(key1);
|
||||
}
|
||||
}
|
||||
else if ("{Object<".EqualsIgnoreCase(wildcard))
|
||||
{
|
||||
//将对象转换为字符串替换
|
||||
string key = str.Substring(str.IndexOf("{Object<") + 8);
|
||||
string key1 = key.Substring(0, key.IndexOf(">}"));
|
||||
if (!key1.IsNullOrWhiteSpace())
|
||||
{
|
||||
wildcard1 = wildcard + key1 + ">}";
|
||||
value = obj == null ? "" : obj.ToString();
|
||||
}
|
||||
}
|
||||
else if ("{JArray<".EqualsIgnoreCase(wildcard))
|
||||
{
|
||||
//取json数组值
|
||||
string key = str.Substring(str.IndexOf("{JArray<") + 8);
|
||||
string key1 = key.Substring(0, key.IndexOf(">}"));
|
||||
if (!key1.IsNullOrWhiteSpace())
|
||||
{
|
||||
wildcard1 = wildcard + key1 + ">}";
|
||||
Newtonsoft.Json.Linq.JArray jArray = (Newtonsoft.Json.Linq.JArray)obj;
|
||||
if (null != jArray)
|
||||
{
|
||||
foreach (Newtonsoft.Json.Linq.JObject jObject in jArray)
|
||||
{
|
||||
if (jObject.ContainsKey(key1))
|
||||
{
|
||||
value = jObject.Value<string>(key1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (value.IsNullOrEmpty())
|
||||
{
|
||||
//这里循环找是取表单数据形式的JSON [{"name":"","value":""}] 这里取表单字段对应的值
|
||||
foreach (Newtonsoft.Json.Linq.JObject jObject in jArray)
|
||||
{
|
||||
if (jObject.ContainsKey("name") && jObject.Value<string>("name").Equals(key1))
|
||||
{
|
||||
value = jObject.Value<string>("value");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("{JObject<".EqualsIgnoreCase(wildcard))
|
||||
{
|
||||
//取json对象值
|
||||
string key = str.Substring(str.IndexOf("{JObject<") + 9);
|
||||
string key1 = key.Substring(0, key.IndexOf(">}"));
|
||||
if (!key1.IsNullOrWhiteSpace())
|
||||
{
|
||||
wildcard1 = wildcard + key1 + ">}";
|
||||
Newtonsoft.Json.Linq.JObject jObject = (Newtonsoft.Json.Linq.JObject)obj;
|
||||
if (null != jObject && jObject.ContainsKey(key1))
|
||||
{
|
||||
value = jObject.Value<string>(key1);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = GetWildcardValue(wildcard, user, obj);
|
||||
}
|
||||
str = str.ReplaceIgnoreCase(wildcard1, value);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
20220330_Vote/Ewide.RoadFlow/Data/WorkDate/IWorkDate.cs
Normal file
13
20220330_Vote/Ewide.RoadFlow/Data/WorkDate/IWorkDate.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public interface IWorkDate : IRoadFlowRepository<RoadFlow.Model.rf_workdate>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
71
20220330_Vote/Ewide.RoadFlow/Data/WorkDate/WorkDate.cs
Normal file
71
20220330_Vote/Ewide.RoadFlow/Data/WorkDate/WorkDate.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using Furion.DependencyInjection;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using RoadFlow.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RoadFlow.Data
|
||||
{
|
||||
public class WorkDate: RoadFlowRepository<RoadFlow.Model.rf_workdate>, IWorkDate, ITransient
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 得到一个时间加上几天之后的工作时间
|
||||
/// </summary>
|
||||
/// <param name="days">天数</param>
|
||||
/// <param name="dt">时间</param>
|
||||
/// <returns></returns>
|
||||
public DateTime GetWorkDateTime(double days, DateTime? dt = null)
|
||||
{
|
||||
DateTime dateTime = dt != null && dt.HasValue ? dt.Value : Utility.DateExtensions.Now;
|
||||
var yearList = GetYearList(dateTime.Year);
|
||||
int max = (int)Math.Floor(days);
|
||||
for (int i = 0; i < max; i++)
|
||||
{
|
||||
if (yearList.Exists(p => p.WorkDay == dateTime.AddDays(i).Date && p.IsWork == 0))
|
||||
{
|
||||
max++;
|
||||
}
|
||||
}
|
||||
return dateTime.AddDays(max + (days - Math.Floor(days)));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 得到一年所有工作日
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<Model.rf_workdate> GetYearList(int year)
|
||||
{
|
||||
string cacheKey = CACHEKEY + "_" + year.ToString();
|
||||
object obj = _memoryCache.Get(cacheKey);
|
||||
if (null == obj)
|
||||
{
|
||||
List<Model.rf_workdate> workDates = db.Queryable<Model.rf_workdate>()
|
||||
.Where("YEAR(WorkDay)="+ year)
|
||||
.ToList();
|
||||
_memoryCache.Set(CACHEKEY, workDates);
|
||||
return workDates;
|
||||
/*
|
||||
using (var db = new DataContext())
|
||||
{
|
||||
string sql = db.IsOracle ? "SELECT * FROM RF_WorkDate WHERE TO_CHAR(WorkDay,'yyyy')=" + year :
|
||||
db.IsPostgreSql ? "select * from rf_workdate where extract(year from WorkDay)=" + year :
|
||||
"SELECT * FROM RF_WorkDate WHERE YEAR(WorkDay)=" + year;
|
||||
var workDates = db.Query<Model.WorkDate>(sql);
|
||||
_memoryCache.set(CACHEKEY, workDates);
|
||||
return workDates;
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
return (List<Model.rf_workdate>)obj;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user