D:\work\Talent\TalentSolution\bbsSolution\Components\Posts.cs 行: 338
SqlDataProvider 行: 4414
数据还原时使用的用户编号为原数据库的编号,所以需要暂时修改anf插入用户的sp,将编号改为固定,完成后再改回来
删除了ix_forumgroup约束
删除了约束 forumuser_profile
修改forums_User_CreateUpdateDelete,放弃对用户名和email的要求
版本号的问题
倒数据的时候要先修改postdate为原始数据,完成后再改回来@PostDate datetime = null,
用户注册日期也要添加,在sp添加新的参数datecreate
........总体的修改过程:
1.从服务器端复制一个论坛程序到相应的位置
2.在本地对一个新的论坛程序进行改造
3.从本地上传覆盖掉服务器端相应位置论坛的需要自定义的部分
4.将服务器端的原数据库备份
5.将备份下载,在本地还原
6.使用最新数据的原论坛数据库将数据导入到新论坛的数据库
7.备份本地的新论坛的数据库
8.将备份上传到服务器端,将需要使用的新论坛数据库还原
........论坛程序的更换
0.连接字符串的修改
1.数据的导入
2.注册用户时主站和论坛的联系
3.主站首页论坛最新帖子显示的修改
.........注册用户时主站和论坛的联系
1.在新论坛数据库添加forums_User_InsertForMain和forums_User_RemoveforMain
2.修改注册用户时使用的方法,先添加用户到论坛,然后添加用户到主站
3.主站添加用户时,用户编号为使用论坛添加用户后产生的自动编号。因此需要修改主站数据库,将用户表的编号的标识属性去掉。然后将添加用户的sp的编号的output去掉。
4.测试。
..........主站首页论坛最新帖子显示的修改
1.修改提供最新帖子的那个方法。
...........要注意的问题
1.各个dll的替换。
建立新的anf数据库,删除两个约束
到服务器端备份目标数据库,下载到本地
将新备份还原旧的bbs数据库
使用写好的程序将旧bbs的数据导入到新的anf数据库
修改定制新的anf的web项目。
注意倒数据时数据库和正常运行的数据库不一样
1using System;
2using System.Data;
3using AspNetForums;
4using AspNetForums.Controls;
5using AspNetForums.Components;
6using AspNetForums.Enumerations;
7
8namespace AspNetForums
9{
10 /**//// <summary>
11 /// ForumConver 的摘要说明。
12 /// </summary>
13 public class ForumConver
14 {
15 public ForumConver()
16 {
17 //
18 // TODO: 在此处添加构造函数逻辑
19 //
20 }
21
22 static int topicSize=500;
23 static int artSize=500;
24 static int userSize=1000;
25
26 CreateForum#region CreateForum
27
28 public static void CreateForum()
29 {
30 //添加组
31
32 Stella2.Model.Districts dists=Stella2.Business.Cached.GetDists();
33
34 foreach(Stella2.Model.District dist in dists.getDistricts())
35 {
36 //原始的组编号
37 int oriDistID=dist.Id;
38 //新的组编号
39 int newDistID=addForumGroup(dist.Name);
40 //添加板块
41 Stella2.Model.Themes themes=Stella2.Business.Cached.GetThemes(oriDistID);
42 foreach(Stella2.Model.Theme theme in themes.getThemes())
43 {
44 //原始的板块编号
45 int oriThemeID=theme.Id;
46 //新的板块编号
47 int newThemeID =addForum(theme,newDistID);
48
49 //添加帖子
50 Stella2.Model.Topics topics= (new Stella2.CheagleDAL.Theme()).GetTopics(oriThemeID,topicSize,1);
51 foreach(Stella2.Model.Topic topic in topics.getTopics())
52 {
53 //原始的主题编号
54 int oriTopicID=topic.Id;
55 Stella2.Model.Art[] arts=(new Stella2.CheagleDAL.Topic()).GetArts(oriTopicID,artSize,1).getArts();
56 //长度
57 int len=arts.Length;
58 //.先添加楼主帖
59 //新的主题的楼主帖的帖子编号
60
61 int newTopicArtID=0;
62 bool goon=true;
63 try
64 {
65 newTopicArtID=addThread(arts[0],newThemeID);
66 }
67 catch
68 {
69 goon=false;
70 }
71
72 if(goon)
73 {
74 //..再添加回帖
75 for(int i=1;i<len;i++)
76 {
77 addPost(arts[i],newTopicArtID);
78 }
79 }
80
81 }
82 }
83
84 }
85 }
86 #endregion
87
88 addForumGroup#region addForumGroup
89 static int addForumGroup(string name)
90 {
91 ForumGroup group = new ForumGroup(name);
92
93 //新的组编号
94 return ForumGroups.AddForumGroup(group);
95 }
96 #endregion
97
98 addForum#region addForum
99 static int addForum(Stella2.Model.Theme theme,int newDistID)
100 {
101 Forum forum = new Forum();
102 forum.ForumGroupID = newDistID;
103 forum.Name = theme.Name;
104 forum.ForumType = AspNetForums.Enumerations.ForumType.Normal;
105 forum.IsActive = true;
106 int themeid=Forums.AddForum(forum);
107 //权限
108 addPermissions(themeid);
109 return themeid;
110 }
111 #endregion
112
113 addThread#region addThread
114 static int addThread(Stella2.Model.Art topArt,int newThemeID)
115 {
116 Thread postToAdd = new Thread();
117
118 postToAdd.Username = topArt.UserAdded.Name;
119
120 postToAdd.Subject = topArt.Title;
121 postToAdd.IsLocked = false;
122 postToAdd.IsGlobal = false;
123
124 postToAdd.DisableBBCode = false;
125 postToAdd.DisableEmoticon = false;
126
127 postToAdd.IsTracked = false;
128
129 postToAdd.EmoticonID=0;
130
131 postToAdd.PostType = PostType.HTML;
132 postToAdd.Body =topArt.Body;
133
134 postToAdd.PostDate=topArt.DateAdded;
135
136 postToAdd.IsSticky = false;
137
138 //使用新的板块编号
139 postToAdd.ForumID=newThemeID;
140
141 User user=new User();
142
143 //添加该帖子的用户
144 user.UserID=topArt.UserAdded.UserId;
145 user.Nickname=topArt.UserAdded.Name;
146
147 return Posts.AddPost(postToAdd,user).PostID;
148
149 }
150 #endregion
151
152 addPost#region addPost
153 static void addPost(Stella2.Model.Art commonArt,int newTopicArtID)
154 {
155 Thread postToAdd = new Thread();
156
157 postToAdd.Username = commonArt.UserAdded.Name;
158
159 postToAdd.Subject = commonArt.Title;
160 postToAdd.IsLocked =false;
161 postToAdd.IsGlobal = false;
162
163 postToAdd.DisableBBCode = false;
164 postToAdd.DisableEmoticon =false;
165
166 postToAdd.IsTracked = false;
167
168 postToAdd.EmoticonID=0;
169
170 postToAdd.PostType = PostType.HTML;
171 postToAdd.Body =commonArt.Body;
172
173 postToAdd.PostDate=commonArt.DateAdded;
174
175 postToAdd.IsSticky = false;
176
177 //此处不是threadid,而是要回复的帖子的postid:新的主题的楼主帖的帖子编号
178 postToAdd.ParentID=newTopicArtID;
179
180 postToAdd.ForumID=0;
181
182 User user=new User();
183
184 //添加该帖子的用户
185 user.UserID=commonArt.UserAdded.UserId;
186 user.Nickname=commonArt.UserAdded.Name;
187
188
189 try
190 {
191 Posts.AddPost(postToAdd, user);
192 }
193 catch
194 {}
195 }
196 #endregion
197
198 addPermissions#region addPermissions
199 static void addPermissions(int newThemeID)
200 {
201
202
203 // Add the Everyone forum permission
204 //
205 ForumPermissions.AddForumPermission( newThemeID, 0 );
206 // 增加论坛默认角色 by venjiang 2004/12/23
207 ForumPermissions.AddForumPermission( newThemeID, 7 ); // 全局注册用户
208 ForumPermissions.AddForumPermission( newThemeID, 8 ); // 站点注册用户
209
210 // Get the forum permission just added
211 // 默认游客访问权限
212 ForumPermission permission = ForumPermissions.GetForumPermission(newThemeID, 0);
213
214
215
216 // 修订游客默认权限 by venjiang 2004/12/23
217 permission.View = AccessControlEntry.Allow;
218 permission.Read = AccessControlEntry.Allow;
219 permission.Post = AccessControlEntry.Deny;
220 permission.Reply = AccessControlEntry.Deny;
221 permission.Edit = AccessControlEntry.Deny;
222 permission.Delete = AccessControlEntry.Deny;
223 permission.Sticky = AccessControlEntry.Deny;
224 permission.Announce = AccessControlEntry.Deny;
225 permission.CreatePoll = AccessControlEntry.Deny;
226 permission.Vote = AccessControlEntry.Deny;
227 permission.Moderate = AccessControlEntry.Deny;
228 permission.Attachment = AccessControlEntry.Deny;
229
230 ForumPermissions.UpdateForumPermission( permission );
231
232 // 修订默认用户权限设置 by venjiang 2004/12/23
233 // 更新站点注册用户默认权限
234 permission = ForumPermissions.GetForumPermission(newThemeID, 7);
235 permission.View = AccessControlEntry.Allow;
236 permission.Read = AccessControlEntry.Allow;
237 permission.Post = AccessControlEntry.Allow;
238 permission.Reply = AccessControlEntry.Allow;
239 permission.Edit = AccessControlEntry.Allow;
240 permission.Delete = AccessControlEntry.Allow;
241 permission.Sticky = AccessControlEntry.Deny;
242 permission.Announce = AccessControlEntry.Deny;
243 permission.CreatePoll = AccessControlEntry.Deny;
244 permission.Vote = AccessControlEntry.Allow;
245 permission.Moderate = AccessControlEntry.Deny;
246 permission.Attachment = AccessControlEntry.Deny;
247
248 ForumPermissions.UpdateForumPermission( permission );
249
250 // 更新全局注册用户默认权限
251 permission = ForumPermissions.GetForumPermission(newThemeID, 8);
252 permission.View = AccessControlEntry.Allow;
253 permission.Read = AccessControlEntry.Allow;
254 permission.Post = AccessControlEntry.Allow;
255 permission.Reply = AccessControlEntry.Allow;
256 permission.Edit = AccessControlEntry.Allow;
257 permission.Delete = AccessControlEntry.Allow;
258 permission.Sticky = AccessControlEntry.Deny;
259 permission.Announce = AccessControlEntry.Deny;
260 permission.CreatePoll = AccessControlEntry.Deny;
261 permission.Vote = AccessControlEntry.Allow;
262 permission.Moderate = AccessControlEntry.Deny;
263 permission.Attachment = AccessControlEntry.Deny;
264
265 ForumPermissions.UpdateForumPermission( permission );
266 }
267
268 #endregion
269
270 CreateUser#region CreateUser
271 public static void CreateUser()
272 {
273 int count=0;
274 DataTable dt=Talent.Facade.User.UserBaseTopN(ChinaTalent.UserShowType.General,ChinaTalent.UserType.User);
275 foreach(DataRow dr in dt.Rows)
276 {
277 User user = new User();
278 user.Username =(string) dr["Username"];
279 user.Nickname = (string)dr["Username"];
280 user.Email = (string)dr["Email"];
281 user.IPCreated = Globals.IPAddress;
282 user.DateCreated=(DateTime)dr["CreateDate"];
283 user.Password = (string)dr["UserPwd"];
284 user.AccountStatus = UserAccountStatus.Approved;
285 user.IsAnonymous = false;
286 //先修改存储过程,强制插入用户编号。完成后再修改回
287 user.UserID=(int)dr["UserID"];
288 Users.Create(user, true);
289 }
290 }
291 #endregion
292
293 }
294}
295
1ALTER proc forums_User_RemoveforMain
2@UserID int
3as
4BEGIN
5 -- 删除用户
6 BEGIN TRAN
7
8 UPDATE forums_Posts set UserID = 0 where UserID = @UserID
9
10 if( @@ERROR != 0 )
11 begin
12 rollback tran
13 select -1
14 end
15
16 delete forums_UserProfile where UserID = @UserID
17
18 if( @@ERROR != 0 )
19 begin
20 rollback tran
21 select -1
22 end
23
24 delete forums_Users where UserID = @UserID
25
26 if( @@ERROR != 0 )
27 begin
28 rollback tran
29 select -1
30 end
31 else
32 begin
33 commit tran
34 select 1
35 end
36
37END
1ALTER procedure forums_User_InsertForMain
2(
3 @UserID int out,
4 @UserName nvarchar (64) ,
5 @Password nvarchar (64),
6 @Email nvarchar (128)
7
8)
9AS
10
11SET NOCOUNT ON
12
13-- 创建新用户
14
15BEGIN
16
17 -- 检查用户名是否存在
18 IF EXISTS(SELECT UserName FROM forums_Users (nolock) WHERE UserName = @UserName )
19 select 2
20 ELSE
21 -- 进一步检查Email地址是否存在
22 IF EXISTS(SELECT Email FROM forums_Users (nolock) WHERE Email = @Email )
23 select 3
24 ELSE
25 BEGIN
26 -- 进一步检查昵称是否存在
27 IF EXISTS(SELECT NickName FROM forums_Users (nolock) WHERE NickName = @UserName AND IsAnonymous = 0)
28 SELECT 6
29 ELSE
30 BEGIN
31 -- 追加新用户
32 INSERT INTO forums_Users
33 ( UserName,
34 NickName,
35 Email,
36 Password
37 )
38 VALUES
39 ( @UserName,
40 @UserName,
41 @Email,
42 @Password
43 )
44
45 IF( @@ERROR != 0 )
46 select -1
47
48 -- 获取创建新用户的ID
49 SET @UserID = @@IDENTITY
50 -- 追加用户配置信息
51 INSERT INTO forums_UserProfile
52 (
53 [UserID] ,
54 [timezone]
55
56 )
57 VALUES
58 ( @UserID,
59 0
60 )
61
62 IF( @@ERROR != 0 )
63 select -1
64 --增加默认用户角色
65 exec forums_Roles_AddUser @UserID, 7
66 exec forums_Roles_AddUser @UserID, 8
67
68 select 1 -- 返回成功代码
69 END
70 END
71 -- 即出存储过程
72 RETURN
73END