You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
267 lines
9.6 KiB
267 lines
9.6 KiB
4 years ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using System.Data;
|
||
|
using QMFrameWork.Data;
|
||
|
using QMAPP.Entity.Sys;
|
||
|
|
||
|
namespace QMAPP.DAL.Sys
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 模块编号:
|
||
|
/// 作 用:在线帮助持久层
|
||
|
/// 作 者:韩磊
|
||
|
/// 编写日期:2014年12月22日
|
||
|
///</summary>
|
||
|
public class OnlineHelpDAL :BaseDAL
|
||
|
{
|
||
|
#region 获取页面级帮助
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取页面级帮助
|
||
|
/// </summary>
|
||
|
/// <param name="helpInfo">条件</param>
|
||
|
/// <returns>页面级帮助对象</returns>
|
||
|
public OnlineHelp Get(OnlineHelp helpInfo)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
List<OnlineHelp> ret= GetList(helpInfo);
|
||
|
if (ret.Count > 0)
|
||
|
{
|
||
|
helpInfo = ret[0];
|
||
|
}
|
||
|
|
||
|
return helpInfo;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 插入在线帮助信息
|
||
|
|
||
|
/// <summary>
|
||
|
/// 插入在线帮助信息
|
||
|
/// </summary>
|
||
|
/// <param name="helpInfo">在线帮助信息</param>
|
||
|
/// <returns>插入数</returns>
|
||
|
public int Insert(OnlineHelp helpInfo)
|
||
|
{
|
||
|
int count = 0;
|
||
|
|
||
|
try
|
||
|
{
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
//插入基本信息
|
||
|
StringBuilder sql = new StringBuilder();
|
||
|
sql.Append("INSERT INTO T_QM_ONLINEHELP (PID,MENUID,PAGENAME,MODELNAME,COLUMNANME,KIND,HELPCONTENT)");
|
||
|
sql.Append("VALUES (@PID,@MENUID,@PAGENAME,@MODELNAME,@COLUMNANME,@KIND,@HELPCONTENT)");
|
||
|
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
parameters.Add(new DataParameter { ParameterName = "PID", DataType = DbType.String, Value = helpInfo.PID });
|
||
|
parameters.Add(new DataParameter { ParameterName = "MENUID", DataType = DbType.String, Value = helpInfo.MENUID });
|
||
|
parameters.Add(new DataParameter { ParameterName = "PAGENAME", DataType = DbType.String, Value = helpInfo.PAGENAME });
|
||
|
parameters.Add(new DataParameter { ParameterName = "MODELNAME", DataType = DbType.String, Value = helpInfo.MODELNAME });
|
||
|
parameters.Add(new DataParameter { ParameterName = "COLUMNANME", DataType = DbType.String, Value = helpInfo.COLUMNANME });
|
||
|
parameters.Add(new DataParameter { ParameterName = "KIND", DataType = DbType.String, Value = helpInfo.KIND });
|
||
|
//parameters.Add(new DataParameter { ParameterName = "HELPCONTENT", Value = Encoding.Default.GetBytes(helpInfo.HELPCONTENT) });
|
||
|
parameters.Add(new DataParameter { ParameterName = "HELPCONTENT", Value = helpInfo.HELPCONTENT });
|
||
|
|
||
|
count=session.ExecuteSql(sql.ToString(), parameters.ToArray());
|
||
|
|
||
|
}
|
||
|
return count;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 更新在线帮助信息
|
||
|
|
||
|
/// <summary>
|
||
|
/// 更新在线帮助信息
|
||
|
/// </summary>
|
||
|
/// <param name="helpInfo">锁定信息</param>
|
||
|
/// <returns>更新个数</returns>
|
||
|
public int Update(OnlineHelp helpInfo)
|
||
|
{
|
||
|
int count = 0;
|
||
|
|
||
|
try
|
||
|
{
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
//更新基本信息
|
||
|
StringBuilder sql = new StringBuilder();
|
||
|
sql.Append("UPDATE T_QM_ONLINEHELP SET HELPCONTENT=@HELPCONTENT ,MODELNAME=@MODELNAME ,PAGENAME=@PAGENAME WHERE PID=@PID");
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
parameters.Add(new DataParameter { ParameterName = "PID", DataType = DbType.String, Value = helpInfo.PID });
|
||
|
//parameters.Add(new DataParameter { ParameterName = "HELPCONTENT", Value =Encoding.Default.GetBytes(helpInfo.HELPCONTENT) });
|
||
|
parameters.Add(new DataParameter { ParameterName = "HELPCONTENT", Value = helpInfo.HELPCONTENT });
|
||
|
parameters.Add(new DataParameter { ParameterName = "MODELNAME", DataType = DbType.String, Value = helpInfo.MODELNAME });
|
||
|
parameters.Add(new DataParameter { ParameterName = "PAGENAME", DataType = DbType.String, Value = helpInfo.PAGENAME });
|
||
|
count=session.ExecuteSql(sql.ToString(), parameters.ToArray());
|
||
|
}
|
||
|
return count;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 获取字段级帮助集合
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取字段级帮助集合
|
||
|
/// </summary>
|
||
|
/// <param name="condition">条件</param>
|
||
|
/// <param name="page">数据页</param>
|
||
|
/// <returns>数据页</returns>
|
||
|
public List<OnlineHelp> GetList(OnlineHelp condition)
|
||
|
{
|
||
|
string sql = null;
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
List<OnlineHelp> ret = new List<OnlineHelp>();
|
||
|
DataTable dt = new DataTable();
|
||
|
try
|
||
|
{
|
||
|
sql = this.GetQuerySql(condition, ref parameters);
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
dt = session.GetTable(sql, parameters.ToArray());
|
||
|
}
|
||
|
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
foreach (DataRow item in dt.Rows)
|
||
|
{
|
||
|
OnlineHelp helpInfo = new OnlineHelp();
|
||
|
helpInfo.PID = item["PID"].ToString();
|
||
|
helpInfo.KIND = item["KIND"].ToString();
|
||
|
helpInfo.MODELNAME = item["MODELNAME"].ToString();
|
||
|
helpInfo.PAGENAME = item["PAGENAME"].ToString();
|
||
|
helpInfo.COLUMNANME = item["COLUMNANME"].ToString();
|
||
|
|
||
|
if (!(item["HELPCONTENT"] is DBNull))
|
||
|
{
|
||
|
string content = item["HELPCONTENT"].ToString();
|
||
|
helpInfo.HELPCONTENT = content;
|
||
|
}
|
||
|
|
||
|
helpInfo.MENUID = item["MENUID"].ToString();
|
||
|
ret.Add(helpInfo);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return ret;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 获取查询语句
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取查询语句
|
||
|
/// </summary>
|
||
|
/// <param name="user">查询条件</param>
|
||
|
/// <param name="parameters">参数</param>
|
||
|
/// <returns>查询语句</returns>
|
||
|
private string GetQuerySql(OnlineHelp condition, ref List<DataParameter> parameters)
|
||
|
{
|
||
|
StringBuilder sqlBuilder = new StringBuilder();
|
||
|
StringBuilder whereBuilder = new StringBuilder();
|
||
|
try
|
||
|
{
|
||
|
//构成查询语句
|
||
|
sqlBuilder.Append("SELECT PID,MENUID,PAGENAME,MODELNAME,COLUMNANME,KIND,HELPCONTENT ");
|
||
|
sqlBuilder.Append("FROM T_QM_ONLINEHELP ");
|
||
|
|
||
|
// 查询条件
|
||
|
if (string.IsNullOrEmpty(condition.MENUID) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND MENUID = @MENUID");
|
||
|
parameters.Add(new DataParameter { ParameterName = "MENUID", DataType = DbType.String, Value = condition.MENUID });
|
||
|
}
|
||
|
if (string.IsNullOrEmpty(condition.KIND) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND KIND = @KIND");
|
||
|
parameters.Add(new DataParameter { ParameterName = "KIND", DataType = DbType.String, Value = condition.KIND });
|
||
|
}
|
||
|
if (whereBuilder.Length > 0)
|
||
|
{
|
||
|
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
|
||
|
}
|
||
|
return sqlBuilder.ToString();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 更新在线帮助信息
|
||
|
|
||
|
/// <summary>
|
||
|
/// 更新在线帮助信息
|
||
|
/// </summary>
|
||
|
/// <param name="helpInfos">在线帮助信息集合</param>
|
||
|
/// <returns>更新个数</returns>
|
||
|
public int Save(List<OnlineHelp> helpInfos)
|
||
|
{
|
||
|
int count = 0;
|
||
|
|
||
|
try
|
||
|
{
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
session.OpenTs();
|
||
|
|
||
|
foreach (OnlineHelp item in helpInfos)
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(item.PID) == true)
|
||
|
{
|
||
|
item.PID = Guid.NewGuid().ToString();
|
||
|
count=Insert(item);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
count= Update(item);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
session.CommitTs();
|
||
|
}
|
||
|
return count;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|