公司级平台-IProgram-IBaseProgram
1、IBase
/// <summary> /// 功能:基本业务逻辑操作接口类 /// 作者:谭斌 /// 时间:2014-12-12 /// </summary> /// <typeparam name="T"></typeparam> public interface IBase<T> { #region 属性 //IHashObject PageParams { get; } #endregion #region //新增(新增前操作:取得新增前的数据) IHashObject AddRecord(T entity, IHashObject objParmas); //修改编辑前操作 IHashObject EditRecord(T entity, IHashObject objParmas); //保存 /// <summary> /// 保存按钮操作 /// </summary> /// <param name="entity">数据模型</param> /// <param name="sType">保存类型</param> /// <returns></returns> IHashObject SaveRecord(T entity, SaveType sType); //删除 /// <summary> /// 删除按钮数据操作 /// </summary> /// <param name="entity"></param> /// <returns></returns> IHashObject DeleteRecord(T entity, IHashObject objParmas); IHashObject GetRecord(IHashObject RowData); #endregion }
2、IService
/// <summary> /// 基本信息操作接口 /// 增删改查 导出 导入 打印 /// </summary> /// <typeparam name="T"></typeparam> public interface IBaseService<T> : IBase<T>, IExecl<T>, IPrint, IRepository<T> { #region 属性 /// <summary> /// 表名 /// </summary> string TableName { get; } /// <summary> /// 表别名 /// </summary> string TableNameSpel { get; } #endregion }
3、Service
/// <summary> /// 基本信息实体接口 /// BaseService继承 /// </summary> public interface IBaseEntity : IBaseService<IHashObject> { /// <summary> /// 数据操作实体 /// </summary> IBaseData iBase { get; set; } /// <summary> /// 数据列表实体 /// </summary> IListData iRepos { get; set; } }
4、DataStruct
public class DataStruct { public static IList<MsSqlColumnInfo> GetPropertyInfoArray(Type type) { System.Reflection.PropertyInfo[] props = null; IList<MsSqlColumnInfo> list = new List<MsSqlColumnInfo>(); try { //Type type = typeof(IProgram.Model.Models.AreaModel); object obj = Activator.CreateInstance(type); props = type.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); } catch (Exception ex) { return list; } foreach (var property in props) { if (!property.IsDefined(typeof(IProgram.Model.ColumnAttribute), false)) continue; var attributes = property.GetCustomAttributes(typeof(IProgram.Model.ColumnAttribute), false); foreach (var attribute in attributes) { if (attribute.GetType() != typeof(IProgram.Model.ColumnAttribute)) continue; IProgram.Model.ColumnAttribute col = attribute as IProgram.Model.ColumnAttribute; MsSqlColumnInfo ms = new MsSqlColumnInfo(); //ms.Name = (int)attribute.GetType().GetProperty("ColumnName").GetValue(attribute); ms.Caption = col.Caption; ms.Name = col.ColumnName; ms.DataType = System.Enum.GetName(typeof(IProgram.Model.SqlDataType), col.DataType); ms.IsKey = col.IsKey; ms.IsAutoIncrement = col.IsAuto; ms.IsNullAble = col.IsNullAble; ms.Default = col.Default; ms.ValidationRepeat = col.ValidationRepeat; list.Add(ms); } } return list; } }