温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:逐迹内容管理系统AspxNuke v2.0源码
当前文件路径:AspxNuke/Portal/NHibernateDAL/Channel.cs

1using System; 2
using System.Collections.Generic; 3
using NHibernate; 4
5
namespace AspxNuke.Portal.NHibernateDAL 6
{ 7
/// <summary> 8
/// 网站栏目数据层 9
/// </summary> 10
public class Channel : BaseDAL<AspxNuke.Portal.Domain.Channel>, AspxNuke.Portal.IDAL.IChannel 11
{ 12
private ISession session = NHibernateHelper.GetCurrentSession(); 13
14
/// <summary> 15
/// 新增栏目记录 16
/// </summary> 17
/// <param name="currentNode">参考节点</param> 18
/// <param name="currentChannel">参考栏目对象</param> 19
/// <param name="domainChannel">栏目对象</param> 20
public void Insert(int currentNode, AspxNuke.Portal.Domain.Channel currentChannel, AspxNuke.Portal.Domain.Channel domainChannel) 21
{ 22
if (currentChannel == null) 23
{ 24
throw new Exception("参考对像不能为空!"); 25
} 26
27
try 28
{ 29
if (currentChannel.ParentNode == null) 30
{ 31
domainChannel.ParentNode = currentChannel; 32
} 33
else 34
{ 35
switch (currentNode) 36
{ 37
case 0: 38
//目录前 39
domainChannel.ParentNode = currentChannel.ParentNode; 40
domainChannel.OrderBy = currentChannel.OrderBy - 1; 41
break; 42
case 1: 43
//目录后 44
domainChannel.ParentNode = currentChannel.ParentNode; 45
domainChannel.OrderBy = currentChannel.OrderBy + 1; 46
break; 47
case 2: 48
//子目录 49
domainChannel.ParentNode = currentChannel; 50
domainChannel.OrderBy = 0; 51
break; 52
} 53
} 54
55
base.Insert(domainChannel); 56
} 57
catch (Exception ex) 58
{ 59
throw ex; 60
} 61
} 62
/// <summary> 63
/// 更新栏目记录 64
/// </summary> 65
/// <param name="currentNode">参考节点</param> 66
/// <param name="currentChannel">参考栏目对象</param> 67
/// <param name="domainChannel">栏目对象</param> 68
public void Update(int currentNode, AspxNuke.Portal.Domain.Channel currentChannel, AspxNuke.Portal.Domain.Channel domainChannel) 69
{ 70
if (currentChannel == null) 71
{ 72
throw new Exception("参考对像不能为空!"); 73
return; 74
} 75
76
try 77
{ 78
if (currentChannel.ParentNode == null) 79
{ 80
domainChannel.ParentNode = currentChannel; 81
} 82
else 83
{ 84
switch (currentNode) 85
{ 86
case 0: 87
//目录前 88
domainChannel.ParentNode = currentChannel.ParentNode; 89
domainChannel.OrderBy = currentChannel.OrderBy - 1; 90
break; 91
case 1: 92
//目录后 93
domainChannel.ParentNode = currentChannel.ParentNode; 94
domainChannel.OrderBy = currentChannel.OrderBy + 1; 95
break; 96
case 2: 97
//子目录 98
domainChannel.ParentNode = currentChannel; 99
break; 100
} 101
} 102
103
base.Update(domainChannel); 104
} 105
catch (Exception ex) 106
{ 107
throw ex; 108
} 109
} 110
111
/// <summary> 112
/// 删除记录 113
/// </summary> 114
/// <param name="domainChannel">栏目对象</param> 115
new public void Delete(AspxNuke.Portal.Domain.Channel domainChannel) 116
{ 117
if (domainChannel.Childs > 0) 118
{ 119
throw new ArgumentException("删除类别不可以有子类别,请先删除子类别!"); 120
return; 121
} 122
123
ITransaction tx = null; 124
try 125
{ 126
tx = session.BeginTransaction(); 127
session.Delete(domainChannel); 128
129
tx.Commit(); 130
} 131
catch (HibernateException ex) 132
{ 133
if (tx != null) tx.Rollback(); 134
throw ex; 135
} 136
finally 137
{ 138
NHibernateHelper.CloseSession(); 139
} 140
} 141
} 142
} 143
144





}