initProject
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public static class AttachFileService
|
||||
{
|
||||
/// <summary>
|
||||
/// 添加附件存储信息
|
||||
/// </summary>
|
||||
/// <param name="workArea"></param>
|
||||
public static void AddAttachFile(Model.AttachFile attachFile)
|
||||
{
|
||||
string newKeyID = SQLHelper.GetNewID(typeof(Model.AttachFile));
|
||||
Model.AttachFile newAttachFile = new Model.AttachFile();
|
||||
newAttachFile.AttachFileId = newKeyID;
|
||||
newAttachFile.ToKeyId = attachFile.ToKeyId;
|
||||
newAttachFile.AttachSource = attachFile.AttachSource;
|
||||
newAttachFile.AttachUrl = attachFile.AttachUrl;
|
||||
newAttachFile.MenuId = attachFile.MenuId;
|
||||
|
||||
Funs.DB.AttachFile.InsertOnSubmit(newAttachFile);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改附件存储信息
|
||||
/// </summary>
|
||||
/// <param name="workArea"></param>
|
||||
public static void updateAttachFile(Model.AttachFile attachFile)
|
||||
{
|
||||
Model.AttachFile newAttachFile = Funs.DB.AttachFile.FirstOrDefault(x => x.AttachFileId == attachFile.AttachFileId);
|
||||
newAttachFile.ToKeyId = attachFile.ToKeyId;
|
||||
newAttachFile.AttachSource = attachFile.AttachSource;
|
||||
newAttachFile.AttachUrl = attachFile.AttachUrl;
|
||||
newAttachFile.MenuId = attachFile.MenuId;
|
||||
Funs.DB.SubmitChanges();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据对应Id删除附件信息及文件存放的物理位置
|
||||
/// </summary>
|
||||
/// <param name="workAreaId"></param>
|
||||
public static void DeleteAttachFile(string rootPath, string toKeyId, string menuId)
|
||||
{
|
||||
Model.AttachFile att = Funs.DB.AttachFile.FirstOrDefault(e => e.ToKeyId == toKeyId && e.MenuId == menuId);
|
||||
if (att != null)
|
||||
{
|
||||
BLL.UploadFileService.DeleteFile(rootPath, att.AttachUrl);
|
||||
Funs.DB.AttachFile.DeleteOnSubmit(att);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据对应主键和菜单获取文件信息
|
||||
/// </summary>
|
||||
/// <param name="toKey">对应主键</param>
|
||||
/// <param name="menuId">对应菜单</param>
|
||||
/// <returns>文件信息</returns>
|
||||
public static Model.AttachFile GetAttachFile(string toKey,string menuId)
|
||||
{
|
||||
return Funs.DB.AttachFile.FirstOrDefault(e => e.ToKeyId == toKey && e.MenuId == menuId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
namespace BLL
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Web.UI.DataVisualization.Charting;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义图形通用类
|
||||
/// </summary>
|
||||
public static class ChartControlService
|
||||
{
|
||||
#region 给chart类赋值
|
||||
/// <summary>
|
||||
/// 给chart类赋值
|
||||
/// </summary>
|
||||
/// <param name="dt">数据源表值</param>
|
||||
/// <param name="title">图标题</param>
|
||||
/// <param name="type">图类型</param>
|
||||
/// <param name="width">图显示宽度</param>
|
||||
/// <param name="height">图显示高度</param>
|
||||
/// <param name="isNotEnable3D">是否显示3D效果</param>
|
||||
/// <returns>返回图</returns>
|
||||
public static Model.DataSourceChart GetDataSourceChart(DataTable dt, string title, string type, int width, int height, bool isNotEnable3D)
|
||||
{
|
||||
Model.DataSourceChart dataSourceChart = new Model.DataSourceChart();
|
||||
dataSourceChart.Width = width;
|
||||
dataSourceChart.Height = height;
|
||||
dataSourceChart.Title = title;
|
||||
dataSourceChart.IsNotEnable3D = isNotEnable3D;
|
||||
dataSourceChart.ChartType = GetChartType(type);
|
||||
List<Model.DataSourceTeam> dataSourceTeams = new List<Model.DataSourceTeam>();
|
||||
for (int i = 1; i < dt.Columns.Count; i++)
|
||||
{
|
||||
Model.DataSourceTeam dataSourceTeam = new Model.DataSourceTeam();
|
||||
dataSourceTeam.DataPointName = dt.Columns[i].ToString();
|
||||
List<Model.DataSourcePoint> dataSourcePoints = new List<Model.DataSourcePoint>();
|
||||
for (int j = 0; j < dt.Rows.Count; j++)
|
||||
{
|
||||
Model.DataSourcePoint dataSourcePoint = new Model.DataSourcePoint();
|
||||
dataSourcePoint.PointText = dt.Rows[j][0].ToString();
|
||||
dataSourcePoint.PointValue = dt.Rows[j][i].ToString();
|
||||
dataSourcePoints.Add(dataSourcePoint);
|
||||
}
|
||||
dataSourceTeam.DataSourcePoints = dataSourcePoints;
|
||||
dataSourceTeams.Add(dataSourceTeam);
|
||||
}
|
||||
dataSourceChart.DataSourceTeams = dataSourceTeams;
|
||||
return dataSourceChart;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示类型
|
||||
/// </summary>
|
||||
/// <param name="chartType"></param>
|
||||
/// <returns></returns>
|
||||
public static SeriesChartType GetChartType(string chartType)
|
||||
{
|
||||
SeriesChartType chart = SeriesChartType.Column;
|
||||
if (chartType == "Column")
|
||||
{
|
||||
chart = SeriesChartType.Column;
|
||||
}
|
||||
else if (chartType == "Line")
|
||||
{
|
||||
chart = SeriesChartType.Line;
|
||||
}
|
||||
else if (chartType == "StackedArea")
|
||||
{
|
||||
chart = SeriesChartType.StackedArea;
|
||||
}
|
||||
else if (chartType == "Spline")
|
||||
{
|
||||
chart = SeriesChartType.Spline;
|
||||
}
|
||||
else if (chartType == "SplineArea")
|
||||
{
|
||||
chart = SeriesChartType.SplineArea;
|
||||
}
|
||||
else if (chartType == "StepLine")
|
||||
{
|
||||
chart = SeriesChartType.StepLine;
|
||||
}
|
||||
else if (chartType == "Stock")
|
||||
{
|
||||
chart = SeriesChartType.Stock;
|
||||
}
|
||||
else if (chartType == "Radar")
|
||||
{
|
||||
chart = SeriesChartType.Radar;
|
||||
}
|
||||
else if (chartType == "Pie")
|
||||
{
|
||||
chart = SeriesChartType.Pie;
|
||||
}
|
||||
return chart;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,398 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public class CommonService
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取多项目系统
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//public static ListItem[] GetIsMoreProjectSystemList()
|
||||
//{
|
||||
// var q = (from x in Funs.DB.Sys_System
|
||||
// where x.IsMoreProject == true && x.IsEnable == true
|
||||
// orderby x.SorIndex
|
||||
// select x).ToList();
|
||||
// ListItem[] lis = new ListItem[q.Count()];
|
||||
// for (int i = 0; i < q.Count(); i++)
|
||||
// {
|
||||
// lis[i] = new ListItem(q[i].SystemName ?? "", q[i].SystemId);
|
||||
// }
|
||||
|
||||
// return lis;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 获取本部和现场系统
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//public static ListItem[] GetHeadAndProjectSystemList(string systemId)
|
||||
//{
|
||||
// var system = (from x in Funs.DB.Sys_System
|
||||
// where x.IsEnable == true
|
||||
// orderby x.SorIndex
|
||||
// select x).ToList();
|
||||
// if (systemId != Const.System_1)
|
||||
// {
|
||||
// string projectSystemId = (Funs.GetNewInt(systemId) + 1).ToString();
|
||||
// system = system = system.Where(x => (x.SystemId == systemId || x.SystemId == projectSystemId)).OrderBy(x => x.SorIndex).ToList();
|
||||
// }
|
||||
|
||||
// ListItem[] lis = new ListItem[system.Count()];
|
||||
// for (int i = 0; i < system.Count(); i++)
|
||||
// {
|
||||
// lis[i] = new ListItem(system[i].SystemName ?? "", system[i].SystemId);
|
||||
// }
|
||||
// return lis;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 判断菜单是否存在
|
||||
/// </summary>
|
||||
/// <param name="postId"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsExistMenu(string menuId)
|
||||
{
|
||||
Model.Sys_Menu m = Funs.DB.Sys_Menu.FirstOrDefault(e => e.MenuId == menuId);
|
||||
if (m != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断按键对应菜单是否存在
|
||||
/// </summary>
|
||||
/// <param name="postId"></param>
|
||||
/// <returns></returns>
|
||||
public static bool isExistButtonToMenu(string buttonToMenuId)
|
||||
{
|
||||
Model.Sys_ButtonToMenu b = Funs.DB.Sys_ButtonToMenu.FirstOrDefault(e => e.ButtonToMenuId == buttonToMenuId);
|
||||
if (b != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#region 获取当前人是否具有按钮操作权限
|
||||
/// <summary>
|
||||
/// 本项目用这个方法来获取按钮操作权限(不按项目角色和项目用户来获取按钮操作权限)
|
||||
/// </summary>
|
||||
/// <param name="userId">用户id</param>
|
||||
/// <param name="menuId">按钮id</param>
|
||||
/// <param name="buttonName">按钮名称</param>
|
||||
/// <returns>是否具有权限</returns>
|
||||
public static bool GetAllButtonPowerList(string userId, string menuId, string buttonName)
|
||||
{
|
||||
Model.EProjectDB db = Funs.DB;
|
||||
bool isPower = false; ////定义是否具备按钮权限
|
||||
|
||||
var user = BLL.Sys_UserService.GetUsersByUserId(userId); ////用户
|
||||
if (user != null)
|
||||
{
|
||||
if (user.UserId == Const.GlyId)
|
||||
{
|
||||
isPower = true;
|
||||
}
|
||||
// 根据角色判断是否有按钮权限
|
||||
if (!string.IsNullOrEmpty(user.RoleId) && !isPower)
|
||||
{
|
||||
var buttonToMenu = from x in db.Sys_ButtonToMenu
|
||||
join y in db.Sys_ButtonPower on x.ButtonToMenuId equals y.ButtonToMenuId
|
||||
where y.RoleId == user.RoleId && y.MenuId == menuId
|
||||
&& x.ButtonName == buttonName && x.MenuId == menuId
|
||||
select x;
|
||||
if (buttonToMenu.Count() > 0)
|
||||
{
|
||||
isPower = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isPower;
|
||||
}
|
||||
|
||||
// 分项目时使用
|
||||
//public static bool GetAllButtonPowerList1(string projectId, string userId, string menuId, string buttonName)
|
||||
//{
|
||||
// Model.EProjectDB db = Funs.DB;
|
||||
// bool isPower = false; ////定义是否具备按钮权限
|
||||
// if (buttonName == Const.BtnSelect)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// var pro = BLL.Base_ProjectService.GetProjectByProjectId(projectId);
|
||||
// if (pro != null && pro.IsClosed == true)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// var user = BLL.Sys_UserService.GetUsersByUserId(userId); ////用户
|
||||
// if (user != null)
|
||||
// {
|
||||
// if (user.UserId == Const.GlyId)
|
||||
// {
|
||||
// isPower = true;
|
||||
// }
|
||||
// ////根据角色判断是否有按钮权限
|
||||
// if (string.IsNullOrEmpty(projectId)
|
||||
// && !string.IsNullOrEmpty(user.RoleId) && !isPower)
|
||||
// {
|
||||
|
||||
// var buttonToMenu = from x in db.ButtonToMenu
|
||||
// join y in db.Sys_ButtonPower on x.ButtonToMenuId equals y.ButtonToMenuId
|
||||
// where y.RoleId == user.RoleId && y.MenuId == menuId
|
||||
// && x.ButtonName == buttonName && x.MenuId == menuId
|
||||
// select x;
|
||||
// if (buttonToMenu.Count() > 0)
|
||||
// {
|
||||
// isPower = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
// ////项目不为空的时候
|
||||
// if (!string.IsNullOrEmpty(projectId) && !isPower)
|
||||
// {
|
||||
// ////判断项目用户是否具有按钮权限
|
||||
// var userButtonToMenu = from x in db.ButtonToMenu
|
||||
// join y in db.Project_UserButtonPower on x.ButtonToMenuId equals y.ButtonToMenuId
|
||||
// where y.UserId == userId && y.MenuId == menuId && y.ProjectId == projectId
|
||||
// && x.ButtonName == buttonName && x.MenuId == menuId
|
||||
// select x;
|
||||
// if (userButtonToMenu.Count() > 0)
|
||||
// {
|
||||
// isPower = true;
|
||||
// }
|
||||
|
||||
// if (!isPower)
|
||||
// {
|
||||
// ////判断项目角色是否具有按钮权限
|
||||
// var projectRoleId = BLL.Project_UserService.GetProjectRoleIdByUserId(projectId, userId); ////项目用户角色
|
||||
// if (!string.IsNullOrEmpty(projectRoleId)) ////根据角色判断是否有按钮权限
|
||||
// {
|
||||
// var pbuttonToMenu = from x in db.ButtonToMenu
|
||||
// join y in db.Project_RoleButtonPower on x.ButtonToMenuId equals y.ButtonToMenuId
|
||||
// where y.RoleId == projectRoleId && y.MenuId == menuId && y.ProjectId == projectId
|
||||
// && x.ButtonName == buttonName && x.MenuId == menuId
|
||||
// select x;
|
||||
// if (pbuttonToMenu.Count() > 0)
|
||||
// {
|
||||
// isPower = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// return isPower;
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 根据登陆id和系统id得到菜单列表
|
||||
/// <summary>
|
||||
/// 根据登陆id和系统id得到菜单列表
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="menuModule"></param>
|
||||
/// <returns></returns>
|
||||
//public static List<Model.Sys_Menu> GetMenu(string projectId, string userId, string menuModule)
|
||||
//{
|
||||
// List<Model.Sys_Menu> reMenuList = new List<Model.Sys_Menu>(); ////要返回的菜单列表
|
||||
// var user = BLL.Sys_UserService.GetUsersByUserId(userId); ////用户
|
||||
// if (user != null)
|
||||
// {
|
||||
// if (user.UserId == Const.GlyId) //// 如果是管理员或者本部人员返回所有菜单
|
||||
// {
|
||||
// var sysMenu = from x in Funs.DB.Sys_Menu where x.MenuModule == menuModule orderby x.SortIndex select x;
|
||||
// reMenuList = sysMenu.ToList();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (string.IsNullOrEmpty(projectId))
|
||||
// {
|
||||
// ////得到非项目菜单
|
||||
// var sysMenuRole = from x in Funs.DB.Sys_Menu
|
||||
// join y in Funs.DB.Sys_RolePower on x.MenuId equals y.MenuId
|
||||
// where x.MenuModule == menuModule && y.RoleId == user.RoleId
|
||||
// orderby x.SortIndex
|
||||
// select x;
|
||||
// reMenuList = sysMenuRole.ToList();
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // 项目角色 权限菜单
|
||||
// var projectUser = BLL.Project_UserService.GetProject_UserByProjectIdUserId(projectId, userId);
|
||||
// if (projectUser != null)
|
||||
// {
|
||||
// var sysMenuProjectRole = from x in Funs.DB.Sys_Menu
|
||||
// join y in Funs.DB.Project_RolePower on x.MenuId equals y.MenuId
|
||||
// where x.MenuModule == menuModule && y.RoleId == projectUser.RoleId
|
||||
// && y.ProjectId == projectId
|
||||
// orderby x.SortIndex
|
||||
// select x;
|
||||
|
||||
|
||||
// if (sysMenuProjectRole.Count() > 0)
|
||||
// {
|
||||
// reMenuList.AddRange(sysMenuProjectRole);
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 项目人员 权限菜单
|
||||
// var sysMenuProjectUser = from x in Funs.DB.Sys_Menu
|
||||
// join y in Funs.DB.Project_UserPower on x.MenuId equals y.MenuId
|
||||
// where x.MenuModule == menuModule && y.UserId == user.UserId && y.ProjectId == projectId
|
||||
// orderby x.SortIndex
|
||||
// select x;
|
||||
// if (sysMenuProjectUser.Count() > 0)
|
||||
// {
|
||||
// reMenuList.AddRange(sysMenuProjectUser);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
////var deskMenu = GetDeskDesktopMenuId(menuModule);
|
||||
////if (deskMenu != null)
|
||||
////{
|
||||
//// // 得到首页导航菜单列表 用于空权限登陆加载
|
||||
//// var sysMenuDesk = from x in Funs.DB.Sys_Menu where deskMenu.Contains(x.MenuId) select x;
|
||||
//// reMenuList.AddRange(sysMenuDesk);
|
||||
////}
|
||||
|
||||
// reMenuList = reMenuList.Distinct().OrderBy(x => x.SortIndex).ToList();
|
||||
// ////对于菜单集合 去重复返回
|
||||
// return reMenuList;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 本项目用这个方法来获取权限(不按项目角色和项目用户来获取权限)
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="menuModule"></param>
|
||||
/// <returns></returns>
|
||||
public static List<Model.Sys_Menu> GetMenuByRoleRower(string userId)
|
||||
{
|
||||
List<Model.Sys_Menu> reMenuList = new List<Model.Sys_Menu>(); ////要返回的菜单列表
|
||||
var user = BLL.Sys_UserService.GetUsersByUserId(userId); ////用户
|
||||
if (user != null)
|
||||
{
|
||||
if (user.UserId == Const.GlyId) //// 如果是管理员或者本部人员返回所有菜单
|
||||
{
|
||||
var sysMenu = from x in Funs.DB.Sys_Menu orderby x.SortIndex select x;
|
||||
reMenuList = sysMenu.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
var sysMenuRole = from x in Funs.DB.Sys_Menu
|
||||
join y in Funs.DB.Sys_ButtonPower on x.MenuId equals y.MenuId
|
||||
where y.RoleId == user.RoleId
|
||||
orderby x.SortIndex
|
||||
select x;
|
||||
reMenuList = sysMenuRole.ToList();
|
||||
|
||||
// PM,EM,CM权限特殊处理
|
||||
List<string> pm = (from x in Funs.DB.Editor_EProject select x.ProjectControl_ProjectManagerId).ToList();
|
||||
List<string> cm = (from x in Funs.DB.Editor_EProject select x.ProjectControl_ConstManagerId).ToList();
|
||||
List<string> em = (from x in Funs.DB.Editor_EProject select x.ProjectControl_EMManagerId).ToList();
|
||||
if (pm.Contains(user.UserId) || em.Contains(user.UserId))
|
||||
{
|
||||
Model.Sys_Menu addSupMenu = (from x in Funs.DB.Sys_Menu where x.MenuId == "1FA19FE4-D8B9-4D1B-8EB0-CAC05B71AFBB" select x).First();
|
||||
Model.Sys_Menu addMenu = (from x in Funs.DB.Sys_Menu where x.MenuId == Const.PMEditorMenuId select x).First();
|
||||
reMenuList.Add(addMenu);
|
||||
}
|
||||
if (cm.Contains(user.UserId))
|
||||
{
|
||||
Model.Sys_Menu addSupMenu = (from x in Funs.DB.Sys_Menu where x.MenuId == "1FA19FE4-D8B9-4D1B-8EB0-CAC05B71AFBB" select x).First();
|
||||
Model.Sys_Menu addMenu = (from x in Funs.DB.Sys_Menu where x.MenuId == Const.CMEditorMenuId select x).First();
|
||||
reMenuList.Add(addMenu);
|
||||
}
|
||||
|
||||
// 对资源模块的特殊处理:CTE/M具有RP权限
|
||||
if (user.DepartId == Const.CTEM_DepartId)
|
||||
{
|
||||
Model.Sys_Menu addSupMenu = (from x in Funs.DB.Sys_Menu where x.MenuId == "72CDB9E2-F44B-4F96-A578-3271211FDC15" select x).First();
|
||||
Model.Sys_Menu addMenu = (from x in Funs.DB.Sys_Menu where x.MenuId == Const.ResourcePlanMenuId select x).First();
|
||||
reMenuList.Add(addSupMenu);
|
||||
reMenuList.Add(addMenu);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
reMenuList = reMenuList.Distinct().OrderBy(x => x.SortIndex).ToList();
|
||||
return reMenuList;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Base64加密
|
||||
/// </summary>
|
||||
/// <param name="Message"></param>
|
||||
/// <returns></returns>
|
||||
public static string Base64Code(string Message)
|
||||
{
|
||||
byte[] bytes = Encoding.Default.GetBytes(Message);
|
||||
return Convert.ToBase64String(bytes);
|
||||
}
|
||||
/// <summary>
|
||||
/// Base64解密
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
public static string Base64Decode(string message)
|
||||
{
|
||||
byte[] bytes = Convert.FromBase64String(message);
|
||||
return Encoding.Default.GetString(bytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户菜单按钮权限
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="menuId"></param>
|
||||
/// <returns></returns>
|
||||
public static List<string> GetAllButtonList(string userId, string menuId)
|
||||
{
|
||||
Model.EProjectDB db = Funs.DB;
|
||||
List<string> buttonList = new List<string>();
|
||||
List<Model.Sys_ButtonToMenu> buttons = new List<Model.Sys_ButtonToMenu>();
|
||||
if (userId == Const.GlyId)
|
||||
{
|
||||
buttons = (from x in db.Sys_ButtonToMenu
|
||||
where x.MenuId == menuId
|
||||
select x).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
var user = BLL.Sys_UserService.GetUsersByUserId(userId); ////用户
|
||||
if (user != null)
|
||||
{
|
||||
buttons = (from x in db.Sys_ButtonToMenu
|
||||
join y in db.Sys_ButtonPower on x.ButtonToMenuId equals y.ButtonToMenuId
|
||||
where y.RoleId == user.RoleId && y.MenuId == menuId && x.MenuId == menuId
|
||||
select x).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
if (buttons.Count() > 0)
|
||||
{
|
||||
buttonList = buttons.Select(x => x.ButtonEnName).ToList();
|
||||
}
|
||||
return buttonList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,786 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public static class Const
|
||||
{
|
||||
/// <summary>
|
||||
/// 本部系统管理员帐号
|
||||
/// </summary>
|
||||
public const string Gly = "gly";
|
||||
|
||||
/// <summary>
|
||||
/// 本部系统管理员ID
|
||||
/// </summary>
|
||||
public const string GlyId = "AF17168B-87BD-466E-1111-F0A0A1158F9B";
|
||||
|
||||
/// <summary>
|
||||
/// 普通用户
|
||||
/// </summary>
|
||||
public const string Role_CommonUsers = "1d5e10a3-8a5c-4c6c-be43-8e439e785781";
|
||||
|
||||
/// <summary>
|
||||
/// CTE部门ID
|
||||
/// </summary>
|
||||
public const string CTE_DepartId = "770DF268-7955-4E8E-9A47-95595B3E614C";
|
||||
|
||||
/// <summary>
|
||||
/// CTE/M部门ID
|
||||
/// </summary>
|
||||
public const string CTEM_DepartId = "01ED3DA9-589A-494C-9188-94BFD6DC761E";
|
||||
|
||||
/// <summary>
|
||||
/// 项目计划工程师角色
|
||||
/// </summary>
|
||||
public const string Role_PPE = "39be6729-aecc-46cb-bfe2-08e6974c557f";
|
||||
|
||||
/// <summary>
|
||||
/// 文档管理工程师
|
||||
/// </summary>
|
||||
public const string Role_TDC = "56f738a9-afeb-4639-8c51-6981d17e6cb3";
|
||||
|
||||
/// <summary>
|
||||
/// 初始化密码
|
||||
/// </summary>
|
||||
public const string glyPassWord = "gly.1234";
|
||||
|
||||
#region 常量是否字符串
|
||||
/// <summary>
|
||||
/// 是 字符串
|
||||
/// </summary>
|
||||
public const string _True = "True";
|
||||
|
||||
/// <summary>
|
||||
/// 否 字符串
|
||||
/// </summary>
|
||||
public const string _False = "False";
|
||||
|
||||
/// <summary>
|
||||
/// null字符串
|
||||
/// </summary>
|
||||
public const string _Null = "null";
|
||||
#endregion
|
||||
|
||||
#region 按钮描述
|
||||
/// <summary>
|
||||
/// 增加
|
||||
/// </summary>
|
||||
public const string BtnAdd = "Add";
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
public const string BtnModify = "Modify";
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
public const string BtnDelete = "Delete";
|
||||
|
||||
/// <summary>
|
||||
/// 保存
|
||||
/// </summary>
|
||||
public const string BtnSave = "Save";
|
||||
|
||||
/// <summary>
|
||||
/// 打印
|
||||
/// </summary>
|
||||
public const string BtnPrint = "Print";
|
||||
|
||||
/// <summary>
|
||||
/// 查看
|
||||
/// </summary>
|
||||
public const string BtnView = "View";
|
||||
|
||||
/// <summary>
|
||||
/// 导入
|
||||
/// </summary>
|
||||
public const string BtnIn = "Import";
|
||||
|
||||
/// <summary>
|
||||
/// 导出
|
||||
/// </summary>
|
||||
public const string BtnOut = "Export";
|
||||
|
||||
/// <summary>
|
||||
/// 计划人工时
|
||||
/// </summary>
|
||||
public const string BtnStaffingPlan = "StaffingPlan";
|
||||
|
||||
/// <summary>
|
||||
/// 实际人工时
|
||||
/// </summary>
|
||||
public const string BtnTimeSheet = "TimeSheet";
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public const string BtnAccountDisabled = "Account Disabled";
|
||||
|
||||
/// <summary>
|
||||
/// 发送
|
||||
/// </summary>
|
||||
public const string BtnSend = "Send";
|
||||
|
||||
/// <summary>
|
||||
/// 数据库备份
|
||||
/// </summary>
|
||||
public const string BtnDataBak = "DataBak";
|
||||
|
||||
/// <summary>
|
||||
/// 增加其他
|
||||
/// </summary>
|
||||
public const string BtnOtherPlanEdit = "OtherPlanEdit";
|
||||
#endregion
|
||||
|
||||
#region 初始化上传路径
|
||||
/// <summary>
|
||||
/// Excel附件路径
|
||||
/// </summary>
|
||||
public const string ExcelUrl = "File\\Excel\\";
|
||||
|
||||
/// <summary>
|
||||
/// 默认照片的初始化虚拟路径
|
||||
/// </summary>
|
||||
public const string initDefaultPath = "FileUpload\\photo.jpg";
|
||||
|
||||
/// <summary>
|
||||
/// 成本报告导入模板
|
||||
/// </summary>
|
||||
public const string CostReportTemplateUrl = "File\\Excel\\CostReport.xlsx";
|
||||
|
||||
/// <summary>
|
||||
/// 经验教训导入模板
|
||||
/// </summary>
|
||||
public const string LessonsLearnedTemplateUrl = "File\\Excel\\LessonsLearned.xlsx";
|
||||
|
||||
|
||||
public const string PunchTemplateUrl = "File\\Excel\\PunchIn.xlsx";
|
||||
|
||||
/// <summary>
|
||||
/// 用户导入模板
|
||||
/// </summary>
|
||||
public const string UserTemplateUrl = "File\\Excel\\UserList.xlsx";
|
||||
|
||||
/// <summary>
|
||||
/// 附件模板
|
||||
/// </summary>
|
||||
public const string FilesLinkTemplateUrl = "File\\Excel\\FilesLink.xlsx";
|
||||
|
||||
public const string FileUrl = "File\\";
|
||||
|
||||
public const string PublicFilePath = "D:\\Projects_Transmittals";
|
||||
|
||||
#endregion
|
||||
|
||||
#region 系统菜单ID
|
||||
#region 系统设置
|
||||
/// <summary>
|
||||
/// 角色
|
||||
/// </summary>
|
||||
public const string RoleMenuId = "B93AAD69-009D-405B-9569-92E1675B8213";
|
||||
|
||||
/// <summary>
|
||||
/// 用户
|
||||
/// </summary>
|
||||
public const string UserMenuId = "07E9AAA4-8577-4821-B0C1-0756935A004E";
|
||||
|
||||
/// <summary>
|
||||
/// 修改密码
|
||||
/// </summary>
|
||||
public const string UpdatePasswordMenuId = "2156BDB2-3D48-4B95-BC45-9E5B2619B8F5";
|
||||
|
||||
/// <summary>
|
||||
/// 系统功能授权
|
||||
/// </summary>
|
||||
public const string RolePowerMenuId = "D2C1FC96-CF5C-4D12-9DF2-101F9478EBCE";
|
||||
|
||||
/// <summary>
|
||||
/// 数据库备份
|
||||
/// </summary>
|
||||
public const string DataBakMenuId = "D4EC02EB-89C6-43AB-8EE0-FCAE1728697A";
|
||||
|
||||
/// <summary>
|
||||
/// 系统环境设置
|
||||
/// </summary>
|
||||
public const string SysSetMenuId = "A5114D5B-868E-4F73-966C-B2085894BE3C";
|
||||
|
||||
/// <summary>
|
||||
/// 每月人工时设置
|
||||
/// </summary>
|
||||
public const string ActualManHourMonthSetMenuId = "E0BF987D-69B3-48F2-8F55-42F5FEB0E61A";
|
||||
|
||||
/// <summary>
|
||||
/// 日志管理
|
||||
/// </summary>
|
||||
public const string LogMenuId = "E317A98D-85B8-4AF0-8C1A-0D39D119401E";
|
||||
|
||||
#endregion
|
||||
|
||||
#region 基础设置
|
||||
/// <summary>
|
||||
/// 部门
|
||||
/// </summary>
|
||||
public const string DepartMenuId = "13B6A924-A887-49CF-8F9E-46A2BE1BD098";
|
||||
|
||||
/// <summary>
|
||||
/// 项目经理编辑器-CDI
|
||||
/// </summary>
|
||||
public const string PMCDIMenuId = "5EF97269-79D3-4A55-8E9F-534BF29D6D39";
|
||||
|
||||
/// <summary>
|
||||
/// 项目经理编辑器-优先级
|
||||
/// </summary>
|
||||
public const string PMPriorityMenuId = "ECEEA211-758C-4149-849C-39D10D251105";
|
||||
|
||||
/// <summary>
|
||||
/// 项目经理编辑器-项目种类
|
||||
/// </summary>
|
||||
public const string PMCategoryMenuId = "BEE548C7-2BC7-4C85-9243-2913CBBE0007";
|
||||
|
||||
/// <summary>
|
||||
/// 计划工程师编辑器_项目类型
|
||||
/// </summary>
|
||||
public const string ProjectPlannerJobTypeMenuId = "012F6BA1-9BA9-4254-98F1-9D33DD838606";
|
||||
|
||||
/// <summary>
|
||||
/// 计划工程师编辑器-项目状态
|
||||
/// </summary>
|
||||
public const string ProjectPlannerJobStatusMenuId = "EDB7B708-0845-4A53-9B50-DA4906C6B1B4";
|
||||
|
||||
/// <summary>
|
||||
/// 文档编辑器_文档类型
|
||||
/// </summary>
|
||||
public const string TDCTypeMenuId = "AB9D0EAB-5A48-4C11-B4BC-B7D6572367E7";
|
||||
|
||||
/// <summary>
|
||||
/// 文档编辑器-文档专业
|
||||
/// </summary>
|
||||
public const string TDCDiscMenuId = "78B5F781-10FF-4F6C-820D-0AA918E51AC5";
|
||||
|
||||
public const string ResoursesDisciplineMenuId = "A93D18F3-2FCA-463D-AA43-EE00FD451171";
|
||||
|
||||
public const string AreaCencernsCategoryMenuId = "9119179E-36B2-40D9-BD9D-C619E98D8B4D";
|
||||
|
||||
public const string PunchDetailsDisciplineMenuId = "6C2A8755-A80E-4AEE-B9ED-4B8A521273F3";
|
||||
|
||||
public const string ResoursesClassMenuId = "75683F31-D019-4178-9D04-7BA87B021066";
|
||||
|
||||
public const string AppliedDiscipMenuId = "3BD10C20-9960-4D1D-8558-2CB0AA9187C8";
|
||||
|
||||
public const string StageMenuId = "6285281D-D643-45FC-B3A5-0F1F7EBBF2CB";
|
||||
|
||||
public const string KeywordMenuId = "1DB5C990-F363-4FEC-BC1C-EA22E1FD9E27";
|
||||
|
||||
public const string FCRLogDisciplineMenuId = "D16E2ECC-0EAB-4CFA-92EE-71F1CB231A7D";
|
||||
|
||||
public const string FCRLogCategoryMenuId = "5C9B4284-CB28-411A-B777-37DFD043575A";
|
||||
|
||||
public const string FCRLogCDIMenuId = "40BE5F9F-464E-4879-A8C9-1C350D308309";
|
||||
|
||||
public const string MyTimeSheetTypeMenuId = "76EB522D-6CB6-4FDA-BA3F-A5C8481AEA96";
|
||||
|
||||
public const string ActTypeMenuId = "6DDB7072-E6FE-4786-AAA8-6F2230350363";
|
||||
|
||||
/// <summary>
|
||||
/// 承包商
|
||||
/// </summary>
|
||||
public const string ContractorMenuId = "968BDDE3-D358-45C9-8BE3-48F9E4A6A45B";
|
||||
|
||||
/// <summary>
|
||||
/// 设计专业
|
||||
/// </summary>
|
||||
public const string DisciplinesWBSMenuId = "BD8BD9DD-FF73-4477-B5DF-F7F27DFF395D";
|
||||
|
||||
/// <summary>
|
||||
/// 超链接设置
|
||||
/// </summary>
|
||||
public const string HyperLinkSetMenuId = "CE289C0B-7E32-4DD3-B02E-60368EE47CCB";
|
||||
#endregion
|
||||
|
||||
#region 编辑器
|
||||
/// <summary>
|
||||
/// 项目经理编辑器
|
||||
/// </summary>
|
||||
public const string PMEditorMenuId = "E65DBEA9-C4D1-4B80-A7A0-B69D7DF65095";
|
||||
|
||||
/// <summary>
|
||||
/// 施工经理编辑器
|
||||
/// </summary>
|
||||
public const string CMEditorMenuId = "CBE8B464-8E1B-446B-8BC0-FE4E4B0FB43E";
|
||||
|
||||
/// <summary>
|
||||
/// SQIB
|
||||
/// </summary>
|
||||
public const string SQIBEditorMenuId = "F1CBF2DD-D977-4C82-966B-643570773C5D";
|
||||
|
||||
/// <summary>
|
||||
/// Permit
|
||||
/// </summary>
|
||||
public const string PermitEditorMenuId = "F75EFC0E-3DBB-4807-9FCB-DE2F2D6D7E4D";
|
||||
|
||||
/// <summary>
|
||||
/// 文档编辑器
|
||||
/// </summary>
|
||||
public const string TDCEditorMenuId = "38F7019D-E3A6-4621-A004-12B39FD14621";
|
||||
|
||||
/// <summary>
|
||||
/// 计划工程师编辑器
|
||||
/// </summary>
|
||||
public const string ProjectControlEditorMenuId = "DF08D995-70C6-4FFB-9619-08D9B7AE4EA0";
|
||||
|
||||
/// <summary>
|
||||
/// 经验教训编辑器
|
||||
/// </summary>
|
||||
public const string LessonsLearnedEditorMenuId = "94400031-F93E-48FC-8838-BB4951D55847";
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public const string AreaConcernMenuId = "A9FC3DF6-A176-4FED-AA8F-F3BB4144D147";
|
||||
|
||||
/// <summary>
|
||||
/// 尾项编辑器
|
||||
/// </summary>
|
||||
public const string PunchMenuId = "B9B9ECE0-01B4-488C-BBE2-A4F9BCAEA8EA";
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public const string FCRLogMenuId = "BAFC1DBF-CA33-43A8-8338-AB3510B77BCB";
|
||||
|
||||
/// <summary>
|
||||
/// 成本报告
|
||||
/// </summary>
|
||||
public const string CostReportMenuId = "02069175-4901-4325-8019-3442D409233E";
|
||||
#endregion
|
||||
|
||||
#region 资源计划
|
||||
/// <summary>
|
||||
/// 资源计划
|
||||
/// </summary>
|
||||
public const string ResourcePlanMenuId = "BC216B1B-4DD4-49E9-8B6D-A207E674455A";
|
||||
|
||||
#endregion
|
||||
|
||||
#region 人工时
|
||||
/// <summary>
|
||||
/// 人工时
|
||||
/// </summary>
|
||||
public const string ManHoursMenuId = "A6779FAA-36CE-4134-B7A1-8FA00D1493BF";
|
||||
|
||||
/// <summary>
|
||||
/// 人工时统计
|
||||
/// </summary>
|
||||
public const string ManHoursStatisticsMenuId = "96FE678A-BCC0-4F48-B076-2FB3185E6FCE";
|
||||
#endregion
|
||||
|
||||
#region 邮箱发送
|
||||
/// <summary>
|
||||
/// 发送邮件
|
||||
/// </summary>
|
||||
public const string SendEmailMenuId = "D05CSBCA-2854-4822-A7E9-24AD3EAF0A6E";
|
||||
|
||||
/// <summary>
|
||||
/// 邮件配置
|
||||
/// </summary>
|
||||
public const string SendEmailPopMenuId = "D05CSBCA-4554-4822-A7E9-24AD3EAF0A6E";
|
||||
|
||||
/// <summary>
|
||||
/// 邮件记录
|
||||
/// </summary>
|
||||
public const string SendEmailLogMenuId = "D05CSBCA-4554-4836-A7E9-24AD3EAF0A6E";
|
||||
|
||||
/// <summary>
|
||||
/// 邮箱模板设置
|
||||
/// </summary>
|
||||
public const string SendEmailTemplateListMenuId = "D05CSBCA-4554-4836-A7E9-24AD3EAF0A78";
|
||||
|
||||
/// <summary>
|
||||
/// 邮箱参数设置
|
||||
/// </summary>
|
||||
public const string MailParametersMenuId = "C189A0D1-8676-449E-9F60-94993ACE403A";
|
||||
|
||||
#endregion
|
||||
|
||||
#region 报表
|
||||
/// <summary>
|
||||
/// 月报
|
||||
/// </summary>
|
||||
public const string MonthReportMenuId = "5CC52FC7-4DBB-4E41-8C9E-0D2AD2794785";
|
||||
|
||||
/// <summary>
|
||||
/// 项目列表
|
||||
/// </summary>
|
||||
public const string ProjectListMenuId = "0D4D99FB-7990-4A54-99AF-3620097E7905";
|
||||
|
||||
/// <summary>
|
||||
/// Concern Report
|
||||
/// </summary>
|
||||
public const string ConcernReportMenuId = "2C53179D-A460-439F-AFBB-DA3FDD823902";
|
||||
|
||||
/// <summary>
|
||||
/// Project Cost Report
|
||||
/// </summary>
|
||||
public const string ProjectCostReportMenuId = "B66D0C42-05F2-49AF-AF9C-7378AE4A4F3A";
|
||||
|
||||
/// <summary>
|
||||
/// Project Closure Report
|
||||
/// </summary>
|
||||
public const string ProjectClosureReportMenuId = "10B14154-1325-43C5-A815-68294054906E";
|
||||
|
||||
/// <summary>
|
||||
/// Project Manhour Report
|
||||
/// </summary>
|
||||
public const string ProjectManhourReportMenuId = "EBA376F1-48D6-410A-A873-43E2114E6817";
|
||||
|
||||
/// <summary>
|
||||
/// Time Sheet Report
|
||||
/// </summary>
|
||||
public const string TimeSheetReportMenuId = "53057208-5EDE-4972-8570-25183AB9DB63";
|
||||
|
||||
/// <summary>
|
||||
/// Time Sheet Summary
|
||||
/// </summary>
|
||||
public const string TimeSheetSummaryMenuId = "E578FF6F-5E1F-487B-90B9-8CFE05FFC2B1";
|
||||
|
||||
/// <summary>
|
||||
/// Documentation Takeover Report
|
||||
/// </summary>
|
||||
public const string DocumentationTakeoverReportMenuId = "022EB0EA-C04E-4F6B-AFDB-A8FD69B73DBF";
|
||||
|
||||
/// <summary>
|
||||
/// Documentation Status MC
|
||||
/// </summary>
|
||||
public const string DocumentationStatusMCMenuId = "CA706A80-B290-4CA1-8770-9AEDFB5C85BC";
|
||||
|
||||
/// <summary>
|
||||
/// FCR Report
|
||||
/// </summary>
|
||||
public const string FCRReportMenuId = "F321476F-2B38-47D4-953F-44ABF7BB719E";
|
||||
|
||||
/// <summary>
|
||||
/// Overview
|
||||
/// </summary>
|
||||
public const string OverviewMenuId = "99BA7A7E-2E49-467F-9062-D02D4AF64410";
|
||||
|
||||
/// <summary>
|
||||
/// Roles Report
|
||||
/// </summary>
|
||||
public const string RolesReportMenuId = "A1E4E1E3-938C-431F-980A-5BFFF5BF0573";
|
||||
|
||||
/// <summary>
|
||||
/// TaskList Report
|
||||
/// </summary>
|
||||
public const string TaskListReportMenuId = "739DE271-D915-49AB-A226-B9DAB3167924";
|
||||
|
||||
/// <summary>
|
||||
/// SiteJob Report
|
||||
/// </summary>
|
||||
public const string SiteJobReportMenuId = "8B7335BA-2473-4F87-8E70-4D4A897EC4DD";
|
||||
|
||||
/// <summary>
|
||||
/// FTE Report
|
||||
/// </summary>
|
||||
public const string FTEReportAprilMenuId = "CEE8F836-F79E-42FA-9CB0-9640569492D7";
|
||||
|
||||
/// <summary>
|
||||
/// MC Report
|
||||
/// </summary>
|
||||
public const string MCReportMenuId = "CF3A3E66-C0C4-4A7E-A175-C980499B1778";
|
||||
|
||||
/// <summary>
|
||||
/// 杂项人工时
|
||||
/// </summary>
|
||||
public const string OthersManhoursMenuId = "86C924AC-F3E2-4E5E-B835-096B0C561F12";
|
||||
|
||||
/// <summary>
|
||||
/// 交工技术文档
|
||||
/// </summary>
|
||||
public const string CMHTDMenuId = "F574B823-DA9C-4220-AC2B-5F5DC81E94BF";
|
||||
|
||||
/// <summary>
|
||||
/// Job List
|
||||
/// </summary>
|
||||
public const string JobListReportMenuId = "92EED539-03DD-49D9-9F63-88759E41F91E";
|
||||
|
||||
/// <summary>
|
||||
/// 计划人工时报表菜单
|
||||
/// </summary>
|
||||
public const string StaffingPlanReportMenuId = "D2EF741B-6B3D-4BC9-8A90-72EE0DAA1A46";
|
||||
|
||||
#endregion
|
||||
|
||||
public const string UserGuideAndQAMenuId = "8F21C1FC-B979-4063-A716-F724F771A1A0";
|
||||
|
||||
public const string TemplatesMenuId = "E6DF9926-A29D-4360-B25F-EDD996A613F9";
|
||||
|
||||
#endregion
|
||||
|
||||
#region 定义变量
|
||||
/// <summary>
|
||||
/// PM-CDI
|
||||
/// </summary>
|
||||
public const string PM_CDI = "PM-CDI";
|
||||
|
||||
/// <summary>
|
||||
/// 项目经理编辑器-优先级
|
||||
/// </summary>
|
||||
public const string PM_Priority = "PM-Priority";
|
||||
|
||||
/// <summary>
|
||||
/// 项目经理编辑器-项目种类
|
||||
/// </summary>
|
||||
public const string PM_Category = "PM-Category";
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public const string ReasonForCritical = "ReasonForCritical";
|
||||
|
||||
/// <summary>
|
||||
/// 计划工程师编辑器_项目类型
|
||||
/// </summary>
|
||||
public const string ProjectPlanner_JobType = "ProjectPlanner-JobType";
|
||||
|
||||
/// <summary>
|
||||
/// 计划工程师编辑器-项目状态
|
||||
/// </summary>
|
||||
public const string ProjectPlanner_JobStatus = "ProjectPlanner-JobStatus";
|
||||
|
||||
/// <summary>
|
||||
/// 文档编辑器_文档类型
|
||||
/// </summary>
|
||||
public const string TDC_Type = "TDC-Type";
|
||||
|
||||
/// <summary>
|
||||
/// 文档编辑器-文档专业
|
||||
/// </summary>
|
||||
public const string TDC_Disc = "TDC-Disc";
|
||||
|
||||
public const string Punch_ActionType = "Punch-ActionType";
|
||||
|
||||
/// <summary>
|
||||
/// 资源专业
|
||||
/// </summary>
|
||||
public const string Resourses_Discipline = "Resourses-Discipline";
|
||||
|
||||
public const string AreaCencerns_Category = "AreaCencerns-Category";
|
||||
|
||||
public const string PunchDetails_Discipline = "PunchDetails-Discipline";
|
||||
|
||||
/// <summary>
|
||||
/// 资源类型
|
||||
/// </summary>
|
||||
public const string Resourses_Class = "Resourses-Class";
|
||||
|
||||
/// <summary>
|
||||
/// 经验教训编辑器-专业
|
||||
/// </summary>
|
||||
public const string LessonsLearned_AppliedDiscip = "LessonsLearned-AppliedDiscip";
|
||||
|
||||
/// <summary>
|
||||
/// 经验教训编辑器-阶段
|
||||
/// </summary>
|
||||
public const string LessonsLearned_Stage = "LessonsLearned-Stage";
|
||||
|
||||
/// <summary>
|
||||
/// 经验教训编辑器-关键词
|
||||
/// </summary>
|
||||
public const string LessonsLearned_Keyword = "LessonsLearned-Keyword";
|
||||
|
||||
public const string FCRLog_Discipline = "FCRLog-Discipline";
|
||||
|
||||
public const string FCRLog_Category = "FCRLog-Category";
|
||||
|
||||
public const string FCRLog_CDI = "FCRLog-CDI";
|
||||
|
||||
public const string MyTimeSheet_Type = "MyTimeSheet-Type";
|
||||
|
||||
#endregion
|
||||
|
||||
#region 首页筛选条件
|
||||
public const string JobNo = "JobNo";
|
||||
|
||||
public const string JobTitle = "JobTitle";
|
||||
|
||||
public const string ProjectManager = "ProjectManager";
|
||||
|
||||
public const string ConstManager = "ConstManager";
|
||||
|
||||
public const string OperationRep = "OperationRep";
|
||||
|
||||
public const string Account = "Account";
|
||||
|
||||
public const string MOCFormNo = "MOCFormNo";
|
||||
|
||||
public const string LeadBy = "LeadBy";
|
||||
|
||||
public const string Engineer = "Engineer";
|
||||
#endregion
|
||||
|
||||
#region 邮件配置参数
|
||||
/// <summary>
|
||||
/// 邮件配置ID
|
||||
/// </summary>
|
||||
public const string EmailPopId = "7EC5E991-B7A0-495A-90ED-2BE15370C959";
|
||||
|
||||
public const string SenderType = "0";//发送人
|
||||
public const string CCType = "1";//抄送人
|
||||
|
||||
/// <summary>
|
||||
/// 计划:邮件26号自动发送提醒,下月10号冻结
|
||||
/// </summary>
|
||||
public const string SASString = "SAS";
|
||||
|
||||
/// <summary>
|
||||
/// //压力容器报备提醒
|
||||
/// </summary>
|
||||
public const string WPRString = "WPR";
|
||||
|
||||
/// <summary>
|
||||
/// 压力管道报备提醒
|
||||
/// </summary>
|
||||
public const string WPPString = "WPP";
|
||||
|
||||
/// <summary>
|
||||
/// 实际:邮件21号自动发送提醒,当月25号冻结。
|
||||
/// </summary>
|
||||
public const string AASString = "AAS";
|
||||
|
||||
/// <summary>
|
||||
/// Lesson learn邮件通知1
|
||||
/// </summary>
|
||||
public const string LL1String = "LL1";
|
||||
|
||||
/// <summary>
|
||||
/// QIB提醒
|
||||
/// </summary>
|
||||
public const string QIBString = "QIB";
|
||||
|
||||
/// <summary>
|
||||
/// Lesson learn Review邮件通知2
|
||||
/// </summary>
|
||||
public const string LLR2String = "LLR2";
|
||||
|
||||
/// <summary>
|
||||
/// 压力管道注册提醒
|
||||
/// </summary>
|
||||
public const string PPRRString = "PPRR";
|
||||
|
||||
/// <summary>
|
||||
/// MC auto Mail邮件通知1
|
||||
/// </summary>
|
||||
public const string MAM1String = "MAM1";
|
||||
|
||||
/// <summary>
|
||||
/// MC auto Mail邮件通知2
|
||||
/// </summary>
|
||||
public const string MAM2String = "MAM2";
|
||||
|
||||
/// <summary>
|
||||
/// hold或cancelled auto Mail邮件通知
|
||||
/// </summary>
|
||||
public const string HCString = "HC";
|
||||
|
||||
/// <summary>
|
||||
/// 施工信息维护提醒
|
||||
/// </summary>
|
||||
public const string CIMRString = "CIMR";
|
||||
|
||||
/// <summary>
|
||||
/// 压力容器注册提醒
|
||||
/// </summary>
|
||||
public const string PVRRString = "PVRR";
|
||||
|
||||
/// <summary>
|
||||
/// Lesson learn published邮件通知
|
||||
/// </summary>
|
||||
public const string LLPString = "LLP";
|
||||
|
||||
/// <summary>
|
||||
/// 项目关闭,文件整理提醒
|
||||
/// </summary>
|
||||
public const string PCFSRString = "PCFSR";
|
||||
|
||||
/// <summary>
|
||||
/// QIB监检提醒
|
||||
/// </summary>
|
||||
public const string QIBIRString = "QIBIR";
|
||||
|
||||
/// <summary>
|
||||
/// 人工时提醒
|
||||
/// </summary>
|
||||
public const string FIRILHString = "FIRILH";
|
||||
|
||||
/// <summary>
|
||||
/// CTEChecker和OwnerChecker
|
||||
/// </summary>
|
||||
public const string CCOCString = "CCOC";
|
||||
|
||||
/// <summary>
|
||||
/// MC证书提醒
|
||||
/// </summary>
|
||||
public const string MCSigned = "MCSIGNED";
|
||||
|
||||
/// <summary>
|
||||
/// FC证书提醒
|
||||
/// </summary>
|
||||
public const string FCSigned = "FCSIGNED";
|
||||
|
||||
/// <summary>
|
||||
/// CMTDC项目交工技术文件归档信息
|
||||
/// </summary>
|
||||
public const string CMTDCString = "CMTDC";
|
||||
|
||||
/// <summary>
|
||||
/// 设计输入提醒
|
||||
/// </summary>
|
||||
public const string DesignInputString = "DesignInput";
|
||||
|
||||
/// <summary>
|
||||
/// PreApproval提醒
|
||||
/// </summary>
|
||||
public const string PreApprovalString = "PreApproval";
|
||||
|
||||
/// <summary>
|
||||
/// Approval提醒
|
||||
/// </summary>
|
||||
public const string ApprovalString = "Approval";
|
||||
|
||||
/// <summary>
|
||||
/// 邮件标题有参数
|
||||
/// </summary>
|
||||
public const string CustomString = "1";
|
||||
|
||||
/// <summary>
|
||||
/// 邮件标题无参数
|
||||
/// </summary>
|
||||
public const string NoCustomString = "0";
|
||||
|
||||
/// <summary>
|
||||
/// 取当前项目EP里面对应的人信息
|
||||
/// </summary>
|
||||
public const string NoprojectString = "0";
|
||||
|
||||
/// <summary>
|
||||
/// 取当前User表中的信息
|
||||
/// </summary>
|
||||
public const string projectString = "1";
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件查询相关人员信息
|
||||
/// </summary>
|
||||
public const string projectString2 = "2";
|
||||
|
||||
/// <summary>
|
||||
/// MC证书提醒
|
||||
/// </summary>
|
||||
public const string projectString4 = "4";
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public static class ConstValue
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 获取常量下拉框 根据常量组id
|
||||
/// </summary>
|
||||
/// <param name="groupId">常量组id</param>
|
||||
/// <returns>常量集合</returns>
|
||||
public static List<Model.Sys_Const> drpConstItemList(string groupId)
|
||||
{
|
||||
var list = (from x in Funs.DB.Sys_Const
|
||||
where x.GroupId == groupId
|
||||
orderby x.SortIndex
|
||||
select x).ToList();
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void InitSysConstDropDownList(FineUIPro.DropDownList dropName, string groupId, bool isShowPlease)
|
||||
{
|
||||
dropName.DataValueField = "ConstValue";
|
||||
dropName.DataTextField = "ConstText";
|
||||
dropName.DataSource = drpConstItemList(groupId);
|
||||
dropName.DataBind();
|
||||
if (isShowPlease)
|
||||
{
|
||||
Funs.FineUIPleaseSelect(dropName);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ConstValue获取常量信息
|
||||
/// </summary>
|
||||
/// <param name="constValue"></param>
|
||||
/// <param name="groupId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.Sys_Const GetSysConstListByGroupId(string constValue, string groupId)
|
||||
{
|
||||
return Funs.DB.Sys_Const.FirstOrDefault(e => e.ConstValue == constValue && e.GroupId == groupId);
|
||||
}
|
||||
|
||||
|
||||
#region 常量组
|
||||
public const string Group_PlanType = "Resource_PlanType";
|
||||
|
||||
/// <summary>
|
||||
/// 是否
|
||||
/// </summary>
|
||||
public const string Group_YesOrNo = "YesOrNo";
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 首页筛选条件
|
||||
/// </summary>
|
||||
public const string Group_Search = "Search";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public static class ExtractFilePath
|
||||
{
|
||||
private static int GetCharCount(String str)
|
||||
{
|
||||
string[] strNum = str.Split('\\');
|
||||
|
||||
return strNum.Length;
|
||||
}
|
||||
private static string FileList(String listPath, String listName)
|
||||
{
|
||||
string path = string.Empty;
|
||||
//In order to improve the search speed, check the depth;
|
||||
if (GetCharCount(listPath) > 6)
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
DirectoryInfo dir = new DirectoryInfo(listPath);
|
||||
foreach (DirectoryInfo subdir in dir.GetDirectories())
|
||||
{
|
||||
if (subdir.ToString().ToLower().Contains(listName.ToLower()))
|
||||
{
|
||||
path = listPath + "\\" + subdir;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
FileList(listPath + "\\" + subdir, listName);
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace BLL.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Hashtable帮助类
|
||||
/// </summary>
|
||||
public class HashtableHelper
|
||||
{
|
||||
public static string HashtableToXml(Hashtable ht)
|
||||
{
|
||||
StringBuilder xml = new StringBuilder("<root>");
|
||||
xml.Append(HashtableToNode(ht));
|
||||
xml.Append("</root>");
|
||||
return xml.ToString();
|
||||
}
|
||||
|
||||
private static string HashtableToNode(Hashtable ht)
|
||||
{
|
||||
StringBuilder xml = new StringBuilder("");
|
||||
foreach (string key in ht.Keys)
|
||||
{
|
||||
object value = ht[key];
|
||||
xml.Append("<").Append(key).Append(">").Append(value).Append("</").Append(key).Append(">");
|
||||
}
|
||||
xml.Append("");
|
||||
return xml.ToString();
|
||||
}
|
||||
|
||||
public static string IListToXML(IList<Hashtable> datas)
|
||||
{
|
||||
StringBuilder xml = new StringBuilder("<root>");
|
||||
foreach (Hashtable ht in datas)
|
||||
{
|
||||
xml.Append(HashtableToNode(ht));
|
||||
}
|
||||
xml.Append("</root>");
|
||||
return xml.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体类Model转Hashtable(反射)
|
||||
/// </summary>
|
||||
public static Hashtable GetModelToHashtable<T>(T model)
|
||||
{
|
||||
Hashtable ht = new Hashtable();
|
||||
PropertyInfo[] properties = model.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
|
||||
foreach (PropertyInfo item in properties)
|
||||
{
|
||||
string key = item.Name;
|
||||
ht[key] = item.GetValue(model, null);
|
||||
}
|
||||
return ht;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字符串 分割转换 Hashtable ≌; ☻
|
||||
/// </summary>
|
||||
public static Hashtable String_Key_ValueToHashtable(string str)
|
||||
{
|
||||
Hashtable ht = new Hashtable();
|
||||
if (!string.IsNullOrEmpty(str))
|
||||
{
|
||||
string[] arrayParm_Key_Value = str.Split('≌');
|
||||
foreach (string item in arrayParm_Key_Value)
|
||||
{
|
||||
if (item.Length > 0)
|
||||
{
|
||||
string[] Key_Value = item.Split('☻');
|
||||
ht[Key_Value[0]] = Key_Value[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return ht;
|
||||
}
|
||||
/// <summary>
|
||||
/// 自定义格式字符串转换 Hashtable
|
||||
/// </summary>
|
||||
/// <param name="array_Key_Value"></param>
|
||||
/// <returns></returns>
|
||||
public static Hashtable Master_Key_ValueToHashtable(object[] array_Key_Value)
|
||||
{
|
||||
Hashtable ht = new Hashtable();
|
||||
foreach (string item in array_Key_Value)
|
||||
{
|
||||
if (item.Length > 0)
|
||||
{
|
||||
string[] Key_Value = item.Split('☻');
|
||||
ht[Key_Value[0]] = Key_Value[1];
|
||||
}
|
||||
}
|
||||
return ht;
|
||||
}
|
||||
/// <summary>
|
||||
/// 自定义格式字符串转换 Hashtable
|
||||
/// </summary>
|
||||
/// <param name="item">自定义字符串</param>
|
||||
/// <returns></returns>
|
||||
public static Hashtable List_Key_ValueToHashtable(string item)
|
||||
{
|
||||
Hashtable ht = new Hashtable();
|
||||
foreach (string itemwithin in item.Split('☺'))
|
||||
{
|
||||
if (itemwithin.Length > 0)
|
||||
{
|
||||
string[] str_item = itemwithin.Split('☻');
|
||||
ht[str_item[0]] = str_item[1];
|
||||
}
|
||||
}
|
||||
return ht;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BLL.Common
|
||||
{
|
||||
public class HttpHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Http Get Request
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <returns></returns>
|
||||
public static string HttpGetRequest(string url)
|
||||
{
|
||||
string strGetResponse = string.Empty;
|
||||
try
|
||||
{
|
||||
var getRequest = CreateHttpRequest(url,"", "GET");
|
||||
var getResponse = getRequest.GetResponse() as HttpWebResponse;
|
||||
strGetResponse = GetHttpResponse(getResponse, "GET");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
strGetResponse = ex.Message;
|
||||
}
|
||||
return strGetResponse;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Http Post Request
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="postJsonData"></param>
|
||||
/// <returns></returns>
|
||||
public static string HttpPostRequest(string url, string postJsonData,string token)
|
||||
{
|
||||
BLL.ErrLogInfo.WriteLog("token=" + token);
|
||||
string strPostReponse = string.Empty;
|
||||
try
|
||||
{
|
||||
var postRequest = CreateHttpRequest(url, "POST",token, postJsonData);
|
||||
var postResponse = postRequest.GetResponse() as HttpWebResponse;
|
||||
strPostReponse = GetHttpResponse(postResponse, "POST");
|
||||
BLL.ErrLogInfo.WriteLog("result=" + strPostReponse);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
strPostReponse = ex.Message;
|
||||
BLL.ErrLogInfo.WriteLog("error=" + ex.Message);
|
||||
}
|
||||
return strPostReponse;
|
||||
}
|
||||
|
||||
private static HttpWebRequest CreateHttpRequest(string url, string requestType, string token, params object[] strJson)
|
||||
{
|
||||
HttpWebRequest request = null;
|
||||
const string get = "GET";
|
||||
const string post = "POST";
|
||||
if (string.Equals(requestType, get, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
request = CreateGetHttpWebRequest(url);
|
||||
}
|
||||
if (string.Equals(requestType, post, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
request = CreatePostHttpWebRequest(url, strJson[0].ToString(),token);
|
||||
}
|
||||
return request;
|
||||
}
|
||||
|
||||
private static HttpWebRequest CreateGetHttpWebRequest(string url)
|
||||
{
|
||||
var getRequest = HttpWebRequest.Create(url) as HttpWebRequest;
|
||||
getRequest.Method = "GET";
|
||||
getRequest.Timeout = 5000;
|
||||
getRequest.ContentType = "text/html;charset=UTF-8";
|
||||
getRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
|
||||
return getRequest;
|
||||
}
|
||||
private static HttpWebRequest CreatePostHttpWebRequest(string url, string postData,string token)
|
||||
{
|
||||
var postRequest = HttpWebRequest.Create(url) as HttpWebRequest;
|
||||
postRequest.KeepAlive = false;
|
||||
postRequest.Method = "POST";
|
||||
postRequest.ContentType = "application/x-www-form-urlencoded";
|
||||
if (!string.IsNullOrEmpty(token))
|
||||
{
|
||||
postRequest.ContentType = "application/json";
|
||||
postRequest.Headers.Add("token_app", token);
|
||||
}
|
||||
postRequest.ContentLength = postData.Length;
|
||||
postRequest.AllowWriteStreamBuffering = false;
|
||||
StreamWriter writer = new StreamWriter(postRequest.GetRequestStream(), Encoding.ASCII);
|
||||
writer.Write(postData);
|
||||
writer.Flush();
|
||||
return postRequest;
|
||||
}
|
||||
|
||||
private static string GetHttpResponse(HttpWebResponse response, string requestType)
|
||||
{
|
||||
var responseResult = "";
|
||||
const string post = "POST";
|
||||
string encoding = "UTF-8";
|
||||
if (string.Equals(requestType, post, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
encoding = response.ContentEncoding;
|
||||
if (encoding == null || encoding.Length < 1)
|
||||
{
|
||||
encoding = "UTF-8";
|
||||
}
|
||||
}
|
||||
using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding)))
|
||||
{
|
||||
responseResult = reader.ReadToEnd();
|
||||
}
|
||||
return responseResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Web.Script.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using System.IO;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public static class JsonHelper
|
||||
{
|
||||
|
||||
public static string ListToJson<T>(IList<T> list)
|
||||
{
|
||||
return Newtonsoft.Json.JsonConvert.SerializeObject(list);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 对象转JSON
|
||||
/// </summary>
|
||||
/// <param name="obj">对象</param>
|
||||
/// <returns>JSON格式的字符串</returns>
|
||||
public static string ObjectToJSON(object obj)
|
||||
{
|
||||
JavaScriptSerializer jss = new JavaScriptSerializer();
|
||||
try
|
||||
{
|
||||
byte[] b = Encoding.UTF8.GetBytes(jss.Serialize(obj));
|
||||
return Encoding.UTF8.GetString(b);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
throw new Exception("JSONHelper.ObjectToJSON(): " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据表转键值对集合
|
||||
/// 把DataTable转成 List集合, 存每一行
|
||||
/// 集合中放的是键值对字典,存每一列
|
||||
/// </summary>
|
||||
/// <param name="dt">数据表</param>
|
||||
/// <returns>哈希表数组</returns>
|
||||
public static List<Dictionary<string, object>> DataTableToList(DataTable dt)
|
||||
{
|
||||
List<Dictionary<string, object>> list
|
||||
= new List<Dictionary<string, object>>();
|
||||
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
Dictionary<string, object> dic = new Dictionary<string, object>();
|
||||
foreach (DataColumn dc in dt.Columns)
|
||||
{
|
||||
dic.Add(dc.ColumnName, dr[dc.ColumnName]);
|
||||
}
|
||||
list.Add(dic);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据表转JSON
|
||||
/// </summary>
|
||||
/// <param name="dataTable">数据表</param>
|
||||
/// <returns>JSON字符串</returns>
|
||||
public static string DataTableToJSON(DataTable dt)
|
||||
{
|
||||
return ObjectToJSON(DataTableToList(dt));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 将对象序列化为JSON格式
|
||||
/// </summary>
|
||||
/// <param name="o">对象</param>
|
||||
/// <returns>json字符串</returns>
|
||||
public static string SerializeObject(object o)
|
||||
{
|
||||
string json = JsonConvert.SerializeObject(o);
|
||||
return json;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析JSON字符串生成对象实体
|
||||
/// </summary>
|
||||
/// <typeparam name="T">对象类型</typeparam>
|
||||
/// <param name="json">json字符串(eg.{"ID":"112","Name":"石子儿"})</param>
|
||||
/// <returns>对象实体</returns>
|
||||
public static T DeserializeJsonToObject<T>(string json) where T : class
|
||||
{
|
||||
JsonSerializer serializer = new JsonSerializer();
|
||||
StringReader sr = new StringReader(json);
|
||||
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(T));
|
||||
T t = o as T;
|
||||
return t;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析JSON数组生成对象实体集合
|
||||
/// </summary>
|
||||
/// <typeparam name="T">对象类型</typeparam>
|
||||
/// <param name="json">json数组字符串(eg.[{"ID":"112","Name":"石子儿"}])</param>
|
||||
/// <returns>对象实体集合</returns>
|
||||
public static List<T> DeserializeJsonToList<T>(string json) where T : class
|
||||
{
|
||||
JsonSerializer serializer = new JsonSerializer();
|
||||
StringReader sr = new StringReader(json);
|
||||
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(List<T>));
|
||||
List<T> list = o as List<T>;
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 反序列化JSON到给定的匿名对象.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">匿名对象类型</typeparam>
|
||||
/// <param name="json">json字符串</param>
|
||||
/// <param name="anonymousTypeObject">匿名对象</param>
|
||||
/// <returns>匿名对象</returns>
|
||||
public static T DeserializeAnonymousType<T>(string json, T anonymousTypeObject)
|
||||
{
|
||||
T t = JsonConvert.DeserializeAnonymousType(json, anonymousTypeObject);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,509 @@
|
||||
using NPOI.HSSF.UserModel;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BLL.Common
|
||||
{
|
||||
public class NPOIHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Excel转换成DataTable(.xls)
|
||||
/// </summary>
|
||||
/// <param name="filePath">Excel文件路径</param>
|
||||
/// <returns></returns>
|
||||
public static DataTable ExcelToDataTable(string filePath)
|
||||
{
|
||||
var dt = new DataTable();
|
||||
using (var file = new FileStream(filePath, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
var hssfworkbook = new HSSFWorkbook(file);
|
||||
var sheet = hssfworkbook.GetSheetAt(0);
|
||||
for (var j = 0; j < 5; j++)
|
||||
{
|
||||
dt.Columns.Add(Convert.ToChar(((int)'A') + j).ToString());
|
||||
}
|
||||
var rows = sheet.GetRowEnumerator();
|
||||
while (rows.MoveNext())
|
||||
{
|
||||
var row = (HSSFRow)rows.Current;
|
||||
var dr = dt.NewRow();
|
||||
for (var i = 0; i < row.LastCellNum; i++)
|
||||
{
|
||||
var cell = row.GetCell(i);
|
||||
if (cell == null)
|
||||
{
|
||||
dr[i] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (cell.CellType)
|
||||
{
|
||||
case CellType.Blank:
|
||||
dr[i] = "[null]";
|
||||
break;
|
||||
case CellType.Boolean:
|
||||
dr[i] = cell.BooleanCellValue;
|
||||
break;
|
||||
case CellType.Numeric:
|
||||
dr[i] = cell.ToString();
|
||||
break;
|
||||
case CellType.String:
|
||||
dr[i] = cell.StringCellValue;
|
||||
break;
|
||||
case CellType.Error:
|
||||
dr[i] = cell.ErrorCellValue;
|
||||
break;
|
||||
case CellType.Formula:
|
||||
try
|
||||
{
|
||||
dr[i] = cell.NumericCellValue;
|
||||
}
|
||||
catch
|
||||
{
|
||||
dr[i] = cell.StringCellValue;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
dr[i] = "=" + cell.CellFormula;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
dt.Rows.Add(dr);
|
||||
}
|
||||
}
|
||||
return dt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Excel转换成DataSet(.xlsx/.xls)
|
||||
/// </summary>
|
||||
/// <param name="filePath">Excel文件路径</param>
|
||||
/// <param name="strMsg"></param>
|
||||
/// <param firstTitle="strMsg">第一行是否为表头</param>
|
||||
/// <returns></returns>
|
||||
public static DataSet ExcelToDataSet(string filePath, out string strMsg, bool firstTitle = false)
|
||||
{
|
||||
strMsg = "";
|
||||
DataSet ds = new DataSet();
|
||||
DataTable dt = new DataTable();
|
||||
string fileType = Path.GetExtension(filePath).ToLower();
|
||||
string fileName = Path.GetFileName(filePath).ToLower();
|
||||
try
|
||||
{
|
||||
ISheet sheet = null;
|
||||
int sheetNumber = 0;
|
||||
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
|
||||
if (fileType == ".xlsx")
|
||||
{
|
||||
// 2007版本
|
||||
XSSFWorkbook workbook = new XSSFWorkbook(fs);
|
||||
sheetNumber = workbook.NumberOfSheets;
|
||||
for (int i = 0; i < sheetNumber; i++)
|
||||
{
|
||||
string sheetName = workbook.GetSheetName(i);
|
||||
sheet = workbook.GetSheet(sheetName);
|
||||
if (sheet != null)
|
||||
{
|
||||
dt = firstTitle ? GetFirstSheetDataTable(sheet, out strMsg) : GetSheetDataTable(sheet, out strMsg);
|
||||
if (dt != null)
|
||||
{
|
||||
dt.TableName = sheetName.Trim();
|
||||
ds.Tables.Add(dt);
|
||||
}
|
||||
else
|
||||
{
|
||||
strMsg = "Sheet数据获取失败,原因:" + strMsg;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (fileType == ".xls")
|
||||
{
|
||||
// 2003版本
|
||||
HSSFWorkbook workbook = new HSSFWorkbook(fs);
|
||||
sheetNumber = workbook.NumberOfSheets;
|
||||
for (int i = 0; i < sheetNumber; i++)
|
||||
{
|
||||
string sheetName = workbook.GetSheetName(i);
|
||||
sheet = workbook.GetSheet(sheetName);
|
||||
if (sheet != null)
|
||||
{
|
||||
//dt = GetSheetDataTable(sheet, out strMsg);
|
||||
dt = firstTitle ? GetFirstSheetDataTable(sheet, out strMsg) : GetSheetDataTable(sheet, out strMsg);
|
||||
if (dt != null)
|
||||
{
|
||||
dt.TableName = sheetName.Trim();
|
||||
ds.Tables.Add(dt);
|
||||
}
|
||||
else
|
||||
{
|
||||
strMsg = "Sheet数据获取失败,原因:" + strMsg;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ds;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
strMsg = ex.Message;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取sheet表对应的DataTable
|
||||
/// </summary>
|
||||
/// <param name="sheet">Excel工作表</param>
|
||||
/// <param name="strMsg"></param>
|
||||
/// <returns></returns>
|
||||
private static DataTable GetSheetDataTable(ISheet sheet, out string strMsg)
|
||||
{
|
||||
strMsg = "";
|
||||
DataTable dt = new DataTable();
|
||||
string sheetName = sheet.SheetName;
|
||||
int startIndex = 0;// sheet.FirstRowNum;
|
||||
int lastIndex = sheet.LastRowNum;
|
||||
//最大列数
|
||||
int cellCount = 0;
|
||||
IRow maxRow = sheet.GetRow(0);
|
||||
for (int i = startIndex; i <= lastIndex; i++)
|
||||
{
|
||||
IRow row = sheet.GetRow(i);
|
||||
if (row != null && cellCount < row.LastCellNum)
|
||||
{
|
||||
cellCount = row.LastCellNum;
|
||||
maxRow = row;
|
||||
}
|
||||
}
|
||||
//列名设置
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < maxRow.LastCellNum; i++)//maxRow.FirstCellNum
|
||||
{
|
||||
dt.Columns.Add(Convert.ToChar(((int)'A') + i).ToString());
|
||||
//DataColumn column = new DataColumn("Column" + (i + 1).ToString());
|
||||
//dt.Columns.Add(column);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
strMsg = "工作表" + sheetName + "中无数据";
|
||||
return null;
|
||||
}
|
||||
//数据填充
|
||||
for (int i = startIndex; i <= lastIndex; i++)
|
||||
{
|
||||
IRow row = sheet.GetRow(i);
|
||||
DataRow drNew = dt.NewRow();
|
||||
if (row != null)
|
||||
{
|
||||
for (int j = row.FirstCellNum; j < row.LastCellNum; ++j)
|
||||
{
|
||||
if (row.GetCell(j) != null)
|
||||
{
|
||||
ICell cell = row.GetCell(j);
|
||||
switch (cell.CellType)
|
||||
{
|
||||
case CellType.Blank:
|
||||
drNew[j] = "";
|
||||
break;
|
||||
case CellType.Numeric:
|
||||
short format = cell.CellStyle.DataFormat;
|
||||
//对时间格式(2015.12.5、2015/12/5、2015-12-5等)的处理
|
||||
if (format == 14 || format == 31 || format == 57 || format == 58)
|
||||
drNew[j] = cell.DateCellValue;
|
||||
else
|
||||
drNew[j] = cell.NumericCellValue;
|
||||
if (cell.CellStyle.DataFormat == 177 || cell.CellStyle.DataFormat == 178 || cell.CellStyle.DataFormat == 188)
|
||||
drNew[j] = cell.NumericCellValue.ToString("#0.00");
|
||||
break;
|
||||
case CellType.String:
|
||||
drNew[j] = cell.StringCellValue;
|
||||
break;
|
||||
case CellType.Formula:
|
||||
try
|
||||
{
|
||||
drNew[j] = cell.NumericCellValue;
|
||||
if (cell.CellStyle.DataFormat == 177 || cell.CellStyle.DataFormat == 178 || cell.CellStyle.DataFormat == 188)
|
||||
drNew[j] = cell.NumericCellValue.ToString("#0.00");
|
||||
}
|
||||
catch
|
||||
{
|
||||
try
|
||||
{
|
||||
drNew[j] = cell.StringCellValue;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
break;
|
||||
default:
|
||||
drNew[j] = cell.StringCellValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dt.Rows.Add(drNew);
|
||||
}
|
||||
return dt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 默认第一行为表头,获取sheet表对应的DataTable
|
||||
/// </summary>
|
||||
/// <param name="sheet">Excel工作表</param>
|
||||
/// <param name="strMsg"></param>
|
||||
/// <returns></returns>
|
||||
private static DataTable GetFirstSheetDataTable(ISheet sheet, out string strMsg)
|
||||
{
|
||||
strMsg = string.Empty;
|
||||
DataTable dt = new DataTable();
|
||||
FileStream file = null;
|
||||
try
|
||||
{
|
||||
|
||||
//ISheet sheet = Workbook.GetSheetAt(0);//读取第一个sheet
|
||||
System.Collections.IEnumerator rows = sheet.GetRowEnumerator();
|
||||
//得到Excel工作表的行
|
||||
IRow headerRow = sheet.GetRow(0);
|
||||
//得到Excel工作表的总列数
|
||||
int cellCount = headerRow.LastCellNum;
|
||||
|
||||
for (int j = 0; j < cellCount; j++)
|
||||
{
|
||||
//得到Excel工作表指定行的单元格
|
||||
ICell cell = headerRow.GetCell(j);
|
||||
if (cell != null)
|
||||
{
|
||||
dt.Columns.Add(cell.ToString().Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
dt.Columns.Add(j.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = (sheet.FirstRowNum + 1); i <= sheet.LastRowNum; i++)
|
||||
{
|
||||
IRow row = sheet.GetRow(i);
|
||||
DataRow dataRow = dt.NewRow();
|
||||
|
||||
for (int j = row.FirstCellNum; j < cellCount; j++)
|
||||
{
|
||||
if (row.PhysicalNumberOfCells != 0 && row.GetCell(j) != null)
|
||||
{
|
||||
if (row.GetCell(j).CellType == CellType.Numeric && DateUtil.IsCellDateFormatted(row.GetCell(j)))
|
||||
{
|
||||
dataRow[j] = row.GetCell(j).DateCellValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
dataRow[j] = row.GetCell(j).ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
dt.Rows.Add(dataRow);
|
||||
}
|
||||
return dt;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
strMsg = ex.Message;
|
||||
if (file != null)
|
||||
{
|
||||
file.Close();//关闭当前流并释放资源
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>读取excel 到datatable
|
||||
/// 默认第一行为表头,导入第一个工作表
|
||||
/// </summary>
|
||||
/// <param name="strFileName">excel文档路径</param>
|
||||
/// <returns></returns>
|
||||
public static DataTable FirstTitleExcelToDataTable(string strFileName)
|
||||
{
|
||||
DataTable dt = new DataTable();
|
||||
FileStream file = null;
|
||||
IWorkbook Workbook = null;
|
||||
try
|
||||
{
|
||||
|
||||
using (file = new FileStream(strFileName, FileMode.Open, FileAccess.Read))//C#文件流读取文件
|
||||
{
|
||||
if (strFileName.IndexOf(".xlsx") > 0)
|
||||
//把xlsx文件中的数据写入Workbook中
|
||||
Workbook = new XSSFWorkbook(file);
|
||||
|
||||
else if (strFileName.IndexOf(".xls") > 0)
|
||||
//把xls文件中的数据写入Workbook中
|
||||
Workbook = new HSSFWorkbook(file);
|
||||
|
||||
if (Workbook != null)
|
||||
{
|
||||
ISheet sheet = Workbook.GetSheetAt(0);//读取第一个sheet
|
||||
System.Collections.IEnumerator rows = sheet.GetRowEnumerator();
|
||||
//得到Excel工作表的行
|
||||
IRow headerRow = sheet.GetRow(0);
|
||||
//得到Excel工作表的总列数
|
||||
int cellCount = headerRow.LastCellNum;
|
||||
|
||||
for (int j = 0; j < cellCount; j++)
|
||||
{
|
||||
//得到Excel工作表指定行的单元格
|
||||
ICell cell = headerRow.GetCell(j);
|
||||
dt.Columns.Add(cell.ToString());
|
||||
}
|
||||
|
||||
for (int i = (sheet.FirstRowNum + 1); i <= sheet.LastRowNum; i++)
|
||||
{
|
||||
IRow row = sheet.GetRow(i);
|
||||
DataRow dataRow = dt.NewRow();
|
||||
|
||||
for (int j = row.FirstCellNum; j < cellCount; j++)
|
||||
{
|
||||
if (row.GetCell(j) != null)
|
||||
dataRow[j] = row.GetCell(j).ToString();
|
||||
}
|
||||
dt.Rows.Add(dataRow);
|
||||
}
|
||||
}
|
||||
return dt;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (file != null)
|
||||
{
|
||||
file.Close();//关闭当前流并释放资源
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region 导出
|
||||
/// <summary>
|
||||
/// DataSet导出excel,多个sheet
|
||||
/// </summary>
|
||||
/// <param name="ds"></param>
|
||||
/// <param name="Path"></param>
|
||||
/// <returns></returns>
|
||||
public static string DataSetToExcel(DataSet ds, string Path)
|
||||
{
|
||||
var result = string.Empty;
|
||||
FileStream fs = null;
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
for (int i = 0; i < ds.Tables.Count; i++)
|
||||
{
|
||||
XSSFSheet sheet = (XSSFSheet)workbook.CreateSheet(ds.Tables[i].TableName);
|
||||
|
||||
XSSFCellStyle dateStyle = (XSSFCellStyle)workbook.CreateCellStyle();
|
||||
XSSFDataFormat format = (XSSFDataFormat)workbook.CreateDataFormat();
|
||||
dateStyle.DataFormat = format.GetFormat("yyyy-mm-dd");
|
||||
|
||||
int rowIndex = 0;
|
||||
|
||||
#region 新建表,填充表头,填充列头,样式
|
||||
if (rowIndex == 0)
|
||||
{
|
||||
//#region 列头及样式
|
||||
//{
|
||||
// XSSFRow headerRow = (XSSFRow)sheet.CreateRow(0);
|
||||
// XSSFCellStyle headStyle = (XSSFCellStyle)workbook.CreateCellStyle();
|
||||
// //headStyle.Alignment = CellHorizontalAlignment.CENTER;
|
||||
// XSSFFont font = (XSSFFont)workbook.CreateFont();
|
||||
// font.FontHeightInPoints = 10;
|
||||
// font.Boldweight = 700;
|
||||
// headStyle.SetFont(font);
|
||||
//}
|
||||
//#endregion
|
||||
//填充表头
|
||||
XSSFRow dataRow = (XSSFRow)sheet.CreateRow(rowIndex);
|
||||
foreach (DataColumn column in ds.Tables[i].Columns)
|
||||
{
|
||||
dataRow.CreateCell(column.Ordinal).SetCellValue(column.ColumnName);
|
||||
}
|
||||
|
||||
rowIndex = 1;
|
||||
}
|
||||
#endregion
|
||||
|
||||
foreach (DataRow row in ds.Tables[i].Rows)
|
||||
{
|
||||
XSSFRow dataRow = (XSSFRow)sheet.CreateRow(rowIndex);
|
||||
|
||||
#region 填充内容
|
||||
foreach (DataColumn column in ds.Tables[i].Columns)
|
||||
{
|
||||
XSSFCell newCell = (XSSFCell)dataRow.CreateCell(column.Ordinal);
|
||||
string type = row[column].GetType().FullName.ToString();
|
||||
newCell.SetCellValue(GetValue(row[column].ToString(), type));
|
||||
}
|
||||
#endregion
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
using (fs = File.OpenWrite(Path))
|
||||
{
|
||||
workbook.Write(fs);//向打开的这个xls文件中写入数据
|
||||
result = Path;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string GetValue(string cellValue, string type)
|
||||
{
|
||||
object value = string.Empty;
|
||||
switch (type)
|
||||
{
|
||||
case "System.String"://字符串类型
|
||||
value = cellValue;
|
||||
break;
|
||||
case "System.DateTime"://日期类型
|
||||
System.DateTime dateV;
|
||||
System.DateTime.TryParse(cellValue, out dateV);
|
||||
value = dateV;
|
||||
break;
|
||||
case "System.Boolean"://布尔型
|
||||
bool boolV = false;
|
||||
bool.TryParse(cellValue, out boolV);
|
||||
value = boolV;
|
||||
break;
|
||||
case "System.Int16"://整型
|
||||
case "System.Int32":
|
||||
case "System.Int64":
|
||||
case "System.Byte":
|
||||
int intV = 0;
|
||||
int.TryParse(cellValue, out intV);
|
||||
value = intV;
|
||||
break;
|
||||
case "System.Decimal"://浮点型
|
||||
case "System.Double":
|
||||
double doubV = 0;
|
||||
double.TryParse(cellValue, out doubV);
|
||||
value = doubV;
|
||||
break;
|
||||
case "System.DBNull"://空值处理
|
||||
value = string.Empty;
|
||||
break;
|
||||
default:
|
||||
value = string.Empty;
|
||||
break;
|
||||
}
|
||||
return value.ToString();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Data.Linq;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI.WebControls;
|
||||
using Model;
|
||||
using BLL;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public static class Common_ReportPrintService
|
||||
{
|
||||
/// <summary>
|
||||
/// 菜单项
|
||||
/// </summary>
|
||||
public class ReportList
|
||||
{
|
||||
/// <summary>
|
||||
/// 报表ID
|
||||
/// </summary>
|
||||
public string ReportId
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 报表名称
|
||||
/// </summary>
|
||||
public string ReportName
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 焊接报表下拉框
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<ReportList> PrintReport()
|
||||
{
|
||||
List<ReportList> lis = new List<ReportList>();
|
||||
|
||||
ReportList list1=new ReportList();
|
||||
return lis;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Collections.Specialized;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
namespace FineUIPro.Web.common
|
||||
{
|
||||
public class TemplateHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 私有构造方法,不允许创建实例
|
||||
/// </summary>
|
||||
private TemplateHelper()
|
||||
{
|
||||
// TODO: Add constructor logic here
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Template File Helper
|
||||
/// </summary>
|
||||
/// <param name="templatePath">Templet Path</param>
|
||||
/// <param name="values">NameValueCollection</param>
|
||||
/// <returns>string</returns>
|
||||
public static string BulidByFile(string templatePath, NameValueCollection values)
|
||||
{
|
||||
return BulidByFile(templatePath, values, "[$", "]");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Template File Helper
|
||||
/// </summary>
|
||||
/// <param name="templatePath">Templet Path</param>
|
||||
/// <param name="values">NameValueCollection</param>
|
||||
/// <returns>string</returns>
|
||||
public static string BulidByFile2(string templatePath, NameValueCollection values)
|
||||
{
|
||||
return BulidByFile2(templatePath, values, "[$", "]");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="template"></param>
|
||||
/// <param name="values">NameValueCollection obj</param>
|
||||
/// <param name="prefix"></param>
|
||||
/// <param name="postfix"></param>
|
||||
/// <returns></returns>
|
||||
public static string Build(string template, NameValueCollection values, string prefix, string postfix)
|
||||
{
|
||||
if (values != null)
|
||||
{
|
||||
foreach (DictionaryEntry entry in values)
|
||||
{
|
||||
template = template.Replace(string.Format("{0}{1}{2}", prefix, entry.Key, postfix), entry.Value.ToString());
|
||||
}
|
||||
}
|
||||
return template;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="templatePath"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="prefix"></param>
|
||||
/// <param name="postfix"></param>
|
||||
/// <returns></returns>
|
||||
public static string BulidByFile(string templatePath, NameValueCollection values, string prefix, string postfix)
|
||||
{
|
||||
StreamReader reader = null;
|
||||
string template = string.Empty;
|
||||
try
|
||||
{
|
||||
reader = new StreamReader(templatePath);
|
||||
template = reader.ReadToEnd();
|
||||
reader.Close();
|
||||
if (values != null)
|
||||
{
|
||||
foreach (string key in values.AllKeys)
|
||||
{
|
||||
template = template.Replace(string.Format("{0}{1}{2}", prefix, key, postfix), values[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (reader != null)
|
||||
reader.Close();
|
||||
}
|
||||
return template;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="templatePath"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="prefix"></param>
|
||||
/// <param name="postfix"></param>
|
||||
/// <returns></returns>
|
||||
public static string BulidByFile2(string templatePath, NameValueCollection values, string prefix, string postfix)
|
||||
{
|
||||
string template = templatePath;
|
||||
|
||||
if (values != null)
|
||||
{
|
||||
foreach (string key in values.AllKeys)
|
||||
{
|
||||
template = template.Replace(string.Format("{0}{1}{2}", prefix, key, postfix), values[key]);
|
||||
}
|
||||
}
|
||||
|
||||
return template;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Linq;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using BLL;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 上传附件相关
|
||||
/// </summary>
|
||||
public class UploadAttachmentService
|
||||
{
|
||||
#region 附件显示
|
||||
/// <summary>
|
||||
/// 附件显示
|
||||
/// </summary>
|
||||
/// <param name="rootValue">文件夹路径</param>
|
||||
/// <param name="path">附件路径</param>
|
||||
/// <returns>附件显示HTML</returns>
|
||||
public static string ShowAttachment(string rootValue, string path)
|
||||
{
|
||||
string htmlStr = string.Empty;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
htmlStr = "<table runat='server' cellpadding='5' cellspacing='5' style=\"width: 100%\">";
|
||||
string[] arrStr = path.Split(new string[] { "," }, System.StringSplitOptions.RemoveEmptyEntries);
|
||||
for (int i = 0; i < arrStr.Length; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(arrStr[i]))
|
||||
{
|
||||
string[] urlArray = arrStr[i].Split('\\');
|
||||
string scanUrl = string.Empty;
|
||||
for (int j = 0; j < urlArray.Length; j++)
|
||||
{
|
||||
scanUrl += urlArray[j] + "|";
|
||||
}
|
||||
|
||||
string url = rootValue + arrStr[i].Replace('\\', '/');
|
||||
string[] subUrl = url.Split('/');
|
||||
string fileName = subUrl[subUrl.Count() - 1];
|
||||
string newFileName = fileName.Substring(fileName.IndexOf("~") + 1);
|
||||
if (newFileName.Contains("_"))
|
||||
{
|
||||
newFileName = newFileName.Replace(newFileName.Split('_')[0], "");
|
||||
newFileName = newFileName.Substring(1);
|
||||
}
|
||||
htmlStr += "<tr><td style=\"width: 60%\" align=\"left\"><span style='cursor:pointer;cursor:pointer;cursor:pointer;TEXT-DECORATION: underline;color:blue' onclick=\"window.open('" + url + "')\">" + newFileName + "</span></td>";
|
||||
}
|
||||
}
|
||||
|
||||
htmlStr += "</table>";
|
||||
}
|
||||
|
||||
return htmlStr;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 附件显示 带删除
|
||||
/// <summary>
|
||||
/// 附件显示
|
||||
/// </summary>
|
||||
/// <param name="rootValue">文件夹路径</param>
|
||||
/// <param name="path">附件路径</param>
|
||||
/// <returns>附件显示HTML</returns>
|
||||
public static string ShowAndDeleteAttachment(string rootValue, string path)
|
||||
{
|
||||
string htmlStr = string.Empty;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
htmlStr = "<table runat='server' cellpadding='5' cellspacing='5' style=\"width: 100%\">";
|
||||
string[] arrStr = path.Split(new string[] { "," }, System.StringSplitOptions.RemoveEmptyEntries);
|
||||
for (int i = 0; i < arrStr.Length; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(arrStr[i]))
|
||||
{
|
||||
string[] urlArray = arrStr[i].Split('\\');
|
||||
string scanUrl = string.Empty;
|
||||
for (int j = 0; j < urlArray.Length; j++)
|
||||
{
|
||||
scanUrl += urlArray[j] + "|";
|
||||
}
|
||||
string url = rootValue + arrStr[i].Replace('\\', '/');
|
||||
string[] subUrl = url.Split('/');
|
||||
string fileName = subUrl[subUrl.Count() - 1];
|
||||
string newFileName = fileName.Substring(fileName.IndexOf("~") + 1);
|
||||
|
||||
htmlStr += "<tr><td style=\"width: 60%\" align=\"left\"><span style='cursor:pointer;cursor:pointer;cursor:pointer;TEXT-DECORATION: underline;color:blue' onclick=\"window.open('" + url + "')\">" + newFileName + "</span></td>";
|
||||
htmlStr += "<td style=\"width: 40%\" align=\"left\"><a style='cursor:pointer;cursor:pointer;cursor:pointer;TEXT-DECORATION: underline;color:blue' onclick='DelAttachment(" + "\"" + scanUrl + "\"" + ")' >删除</a></td></tr>";
|
||||
}
|
||||
}
|
||||
|
||||
htmlStr += "</table>";
|
||||
}
|
||||
|
||||
return htmlStr;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 附件上传
|
||||
/// <summary>
|
||||
/// 附件上传
|
||||
/// </summary>
|
||||
/// <param name="fileUpload">上传控件</param>
|
||||
/// <param name="fileUrl">上传路径</param>
|
||||
/// <param name="constUrl">定义路径</param>
|
||||
/// <returns></returns>
|
||||
public static string UploadAttachment(string rootPath, FileUpload fileUpload, string fileUrl, string constUrl)
|
||||
{
|
||||
string initFullPath = rootPath + constUrl;
|
||||
if (!Directory.Exists(initFullPath))
|
||||
{
|
||||
Directory.CreateDirectory(initFullPath);
|
||||
}
|
||||
|
||||
string filePath = fileUpload.PostedFile.FileName;
|
||||
string fileName = Funs.GetNewFileName() + "~" + Path.GetFileName(filePath);
|
||||
int count = fileUpload.PostedFile.ContentLength;
|
||||
string savePath = constUrl + fileName;
|
||||
string fullPath = initFullPath + fileName;
|
||||
|
||||
if (!File.Exists(fullPath))
|
||||
{
|
||||
byte[] buffer = new byte[count];
|
||||
Stream stream = fileUpload.PostedFile.InputStream;
|
||||
|
||||
stream.Read(buffer, 0, count);
|
||||
MemoryStream memoryStream = new MemoryStream(buffer);
|
||||
FileStream fs = new FileStream(fullPath, FileMode.Create, FileAccess.Write);
|
||||
memoryStream.WriteTo(fs);
|
||||
memoryStream.Flush();
|
||||
memoryStream.Close();
|
||||
fs.Flush();
|
||||
fs.Close();
|
||||
memoryStream = null;
|
||||
fs = null;
|
||||
if (!string.IsNullOrEmpty(fileUrl))
|
||||
{
|
||||
fileUrl += "," + savePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
fileUrl += savePath;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fileUrl = string.Empty;
|
||||
}
|
||||
|
||||
return fileUrl;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 附件删除
|
||||
/// <summary>
|
||||
/// 附件删除
|
||||
/// </summary>
|
||||
/// <param name="fileUrl">附件路径</param>
|
||||
/// <param name="hiddenUrl">隐藏列路径</param>
|
||||
/// <returns></returns>
|
||||
public static string DeleteAttachment(string fileUrl, string hiddenUrl)
|
||||
{
|
||||
string hdAttachUrlStr = hiddenUrl;
|
||||
string[] urlArray = hdAttachUrlStr.Split('|');
|
||||
string scanUrl = string.Empty;
|
||||
for (int j = 0; j < urlArray.Length; j++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(urlArray[j]))
|
||||
{
|
||||
if (j == 0)
|
||||
{
|
||||
scanUrl += urlArray[j];
|
||||
}
|
||||
else
|
||||
{
|
||||
scanUrl += "\\" + urlArray[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(fileUrl))
|
||||
{
|
||||
string[] arrStr = fileUrl.Split(new string[] { "," }, System.StringSplitOptions.RemoveEmptyEntries);
|
||||
fileUrl = null;
|
||||
for (int i = 0; i < arrStr.Length; i++)
|
||||
{
|
||||
if (scanUrl != arrStr[i])
|
||||
{
|
||||
if (i != arrStr.Length - 1)
|
||||
{
|
||||
fileUrl += arrStr[i] + ",";
|
||||
}
|
||||
else
|
||||
{
|
||||
fileUrl += arrStr[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fileUrl;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 附件打开公共方法
|
||||
/// <summary>
|
||||
/// 显示附件文件
|
||||
/// </summary>
|
||||
/// <param name="rootValue"></param>
|
||||
public static void ShowAttachmentsFile(string rootValue, string path)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
string[] arrStr = path.Split(new string[] { "," }, System.StringSplitOptions.RemoveEmptyEntries);
|
||||
for (int i = 0; i < arrStr.Length; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(arrStr[i]))
|
||||
{
|
||||
string[] urlArray = arrStr[i].Split('\\');
|
||||
string scanUrl = string.Empty;
|
||||
for (int j = 0; j < urlArray.Length; j++)
|
||||
{
|
||||
scanUrl += urlArray[j] + "|";
|
||||
}
|
||||
string url = rootValue + arrStr[i].Replace('\\', '/');
|
||||
System.Web.HttpContext.Current.Response.Write("<script type='text/javascript' language='javascript'>window.open('" + url + "')</script>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 附件在Image中显示
|
||||
/// <summary>
|
||||
/// 附件在Image中显示
|
||||
/// </summary>
|
||||
/// <param name="rootValue">文件夹路径</param>
|
||||
/// <param name="path">附件路径</param>
|
||||
/// <returns>附件显示HTML</returns>
|
||||
public static string ShowImage(string rootValue, string path)
|
||||
{
|
||||
string htmlStr = string.Empty;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
htmlStr = "<table runat='server' cellpadding='5' cellspacing='5' style=\"width: 100%\">";
|
||||
string[] arrStr = path.Split(new string[] { "," }, System.StringSplitOptions.RemoveEmptyEntries);
|
||||
for (int i = 0; i < arrStr.Length; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(arrStr[i]))
|
||||
{
|
||||
string[] urlArray = arrStr[i].Split('\\');
|
||||
string scanUrl = string.Empty;
|
||||
for (int j = 0; j < urlArray.Length; j++)
|
||||
{
|
||||
scanUrl += urlArray[j] + "|";
|
||||
}
|
||||
|
||||
string url = rootValue + arrStr[i].Replace('\\', '/');
|
||||
string[] subUrl = url.Split('/');
|
||||
string fileName = subUrl[subUrl.Count() - 1];
|
||||
string newFileName = fileName.Substring(fileName.IndexOf("~") + 1);
|
||||
|
||||
htmlStr += "<tr><td style=\"width: 60%\" align=\"left\"><img width='100' height='100' src='" + url + "'></img></td>";
|
||||
}
|
||||
}
|
||||
|
||||
htmlStr += "</table>";
|
||||
}
|
||||
|
||||
return htmlStr;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
using System.IO;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 上传附件相关
|
||||
/// </summary>
|
||||
public class UploadFileService
|
||||
{
|
||||
#region 附件上传
|
||||
/// <summary>
|
||||
/// 附件上传
|
||||
/// </summary>
|
||||
/// <param name="fileUpload">上传控件</param>
|
||||
/// <param name="fileUrl">上传路径</param>
|
||||
/// <param name="constUrl">定义路径</param>
|
||||
/// <returns></returns>
|
||||
public static string UploadAttachment(string rootPath, FineUIPro.FileUpload fileUpload, string fileUrl, string constUrl)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(fileUrl)) ////是否存在附件 存在则删除
|
||||
{
|
||||
string urlFullPath = rootPath + fileUrl;
|
||||
if (File.Exists(urlFullPath))
|
||||
{
|
||||
File.Delete(urlFullPath);
|
||||
}
|
||||
}
|
||||
|
||||
string initFullPath = rootPath + constUrl;
|
||||
if (!Directory.Exists(initFullPath))
|
||||
{
|
||||
Directory.CreateDirectory(initFullPath);
|
||||
}
|
||||
|
||||
string filePath = fileUpload.PostedFile.FileName;
|
||||
string fileName = Funs.GetNewFileName() + "~" + Path.GetFileName(filePath);
|
||||
int count = fileUpload.PostedFile.ContentLength;
|
||||
string savePath = constUrl + fileName;
|
||||
string fullPath = initFullPath + fileName;
|
||||
if (!File.Exists(fullPath))
|
||||
{
|
||||
byte[] buffer = new byte[count];
|
||||
Stream stream = fileUpload.PostedFile.InputStream;
|
||||
|
||||
stream.Read(buffer, 0, count);
|
||||
MemoryStream memoryStream = new MemoryStream(buffer);
|
||||
FileStream fs = new FileStream(fullPath, FileMode.Create, FileAccess.Write);
|
||||
memoryStream.WriteTo(fs);
|
||||
memoryStream.Flush();
|
||||
memoryStream.Close();
|
||||
fs.Flush();
|
||||
fs.Close();
|
||||
memoryStream = null;
|
||||
fs = null;
|
||||
//if (!string.IsNullOrEmpty(fileUrl))
|
||||
//{
|
||||
// fileUrl += "," + savePath;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// fileUrl += savePath;
|
||||
//}
|
||||
fileUrl = savePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
fileUrl = string.Empty;
|
||||
}
|
||||
|
||||
return fileUrl;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 附件资源删除
|
||||
/// <summary>
|
||||
/// 附件资源删除
|
||||
/// </summary>
|
||||
/// <param name="rootPath"></param>
|
||||
/// <param name="fileUrl"></param>
|
||||
public static void DeleteFile(string rootPath, string fileUrl)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(fileUrl))
|
||||
{
|
||||
string[] strs = fileUrl.Trim().Split(',');
|
||||
foreach (var item in strs)
|
||||
{
|
||||
string urlFullPath = rootPath + item;
|
||||
if (File.Exists(urlFullPath))
|
||||
{
|
||||
File.Delete(urlFullPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 上传文件路径
|
||||
/// <summary>
|
||||
/// 版本附件路径
|
||||
/// </summary>
|
||||
public const string SysVersionFilePath = "FileUpload\\SysVersion\\";
|
||||
|
||||
/// <summary>
|
||||
/// 焊工二维码上传路径
|
||||
/// </summary>
|
||||
public const string QRCodeImageFilePath = "FileUpload\\Technical\\Welder\\";
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user