-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmyaccount.aspx.cs
417 lines (357 loc) · 20.3 KB
/
myaccount.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
#region XD World Recipe V 2.8
// FileName: myaccount.cs
// Author: Dexter Zafra
// Date Created: 5/29/2008
// Website: www.ex-designz.net
#endregion
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
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 XDRecipe.UI;
using XDRecipe.BL;
using XDRecipe.Common;
using XDRecipe.Security;
using XDRecipe.Common.Utilities;
using XDRecipe.BL.Providers.CookBooks;
using XDRecipe.BL.Providers.FriendList;
using XDRecipe.BL.Providers.User;
public partial class myaccount : BasePage
{
private Utility Util
{
get { return new Utility(); }
}
protected void Page_Load(object sender, EventArgs e)
{
if (Authentication.IsUserAuthenticated)
{
HideContentIfNotLogin.Visible = true;
int UserID = UserIdentity.UserID;
string Username = UserIdentity.UserName;
Blogic.UpdateUserLastLogin(UserID);
lblusernameheader.Text = Username + "'s My Account";
ProviderUserDetails user = new ProviderUserDetails();
user.FillUp(UserID);
lbllastactivitymsg.Text = " Your last activity was on: (<span style='color: #800000'>" + string.Format("{0:g}", user.LastLogin) + "</span>)";
lblmyprofilelink.Text = "<img src='images/user1_icon.gif'> <a href=userprofile.aspx?uid=" + UserID + ">My Profile</a>";
lbleditmyprofile.Text = "<img src='images/editsmall.gif'> <a href='editprofile.aspx'>Edit My Profile</a>";
lblmycookbooklink.Text = "<img src='images/cookbookicon_smll.gif'> <a href='mycookbook.aspx'>My Cook Book</a>";
lblmyfriendslistlink.Text = "<img src='images/friendlisticon_smll.gif'> <a href='myfriendslist.aspx'>My Friends List</a>";
lblmypminbox.Text = "<img src='images/newmsg_icon_smll2.gif'> <a href='pmview.aspx'>My PM Inbox</a>";
lblmyprofilelink.Attributes.Add("onmouseover", "Tip('View my profile page.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
lblmyprofilelink.Attributes.Add("onmouseout", "UnTip()");
lbleditmyprofile.Attributes.Add("onmouseover", "Tip('Update information, change password, email and photo.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
lbleditmyprofile.Attributes.Add("onmouseout", "UnTip()");
lblmycookbooklink.Attributes.Add("onmouseover", "Tip('Vew My Cook Book page.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
lblmycookbooklink.Attributes.Add("onmouseout", "UnTip()");
lblmyfriendslistlink.Attributes.Add("onmouseover", "Tip('Vew My Friends List page.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
lblmyfriendslistlink.Attributes.Add("onmouseout", "UnTip()");
lblmypminbox.Attributes.Add("onmouseover", "Tip('View my Inbox.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
lblmypminbox.Attributes.Add("onmouseout", "UnTip()");
GetMetaTitleTagKeywords(Username);
GetMyStatisticsCounter(user);
GetCounters(user);
GetUserWhoAddMeInFriendsList(UserID);
GetLast5UsersWhoSavedMyRecipeInCookBook(UserID);
GetDDLSelectedValue();
GetStatisticsCounters();
GetReturnFromUpdateMsg();
user = null;
}
else
{
GetMetaTitleTagKeywords("Denied View");
HideContentIfNotLogin.Visible = false;
lblyouarenotlogin.Visible = true;
lblusernameheader.Text = "Denied My Account View";
lblyouarenotlogin.Text = "<div style='margin-top: 12px; margin-bottom: 7px;'><img src='images/lock.gif' align='absmiddle'> You are not authorize to My Account page. Please login to view your Account Page.</div>";
}
}
private void GetStatisticsCounters()
{
ProviderSiteStatistics Statistics = new ProviderSiteStatistics();
Statistics.fillup();
lbltotalrecipe.Text = "Recipes: " + string.Format("{0:#,###}", Statistics.TotalRecipe);
lbltotalarticle.Text = "Articles: " + Statistics.TotalArticle;
lbltotalrecipecomments.Text = "Recipe Comments: " + Statistics.TotalRecipeComments;
lbltotalarticlecomments.Text = "Article Comments: " + Statistics.TotalArticleComments;
lbltotalsavedrecipeincookbook.Text = "Recipes in CookBook: " + Statistics.TotalSavedRecipesInCookBook;
lbltotaluserswhousecookbook.Text = "Users in CookBook: " + Statistics.TotalUsersWhoUseCookBook;
lbltotaluserswhousefriendslist.Text = "Users in FriendsList: " + Statistics.TotalUsersWhoUseFriendsList;
lbltotalprivatemessage.Text = "Private Messages: " + Statistics.TotalPrivateMessage;
lbltotalRegisteredUsers.Text = "Total Members: <a href='members.aspx'>" + Statistics.TotalMembers + "</a>";
lbltotalRegisteredUsers.Attributes.Add("onmouseover", "Tip('Browse members page.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
lbltotalRegisteredUsers.Attributes.Add("onmouseout", "UnTip()");
lbltotaluserjoinedtoday.Text = "Joined Today: " + Statistics.TotalUsersJoinedToday;
lbltotaluserjoininaweek.Text = "Joined Last 7 Days: " + Statistics.TotalUsersJoinedInAWeek;
lbltotaluserjoinedinamonth.Text = "Joined Last 31 Days: " + Statistics.TotalUsersJoinedInAMonth;
Statistics = null;
}
private void GetMyStatisticsCounter(ProviderUserDetails user)
{
lblcountmysavedrecipe.Text = "Saved Recipe: " + user.SavedrecipeCount.ToString();
lblcountmyfriends.Text = "Saved Friends: " + user.FriendsCount.ToString();
lblcommentedrecipe.Text = "Comments Recipe: " + user.CommentRecipeCount.ToString();
lblpostedrecipecount.Text = "Published Recipe: " + user.PostedRecipeCount.ToString();
lblpostedarticlecount.Text = "Published Article: " + user.PostedArticleCount.ToString();
lblcommentarticle.Text = "Comments Article: " + user.CommentArticleCount.ToString();
if (user.SavedrecipeCount != 0)
{
lblcountmysavedrecipe.Text = "Saved Recipe: <a href='mycookbook.aspx'>" + user.SavedrecipeCount + "</a>";
lblcountmysavedrecipe.Attributes.Add("onmouseover", "Tip('Browse My Cook Book.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
lblcountmysavedrecipe.Attributes.Add("onmouseout", "UnTip()");
}
if (user.FriendsCount != 0)
{
lblcountmyfriends.Text = "Saved Recipe: <a href='myfriendslist.aspx'>" + user.FriendsCount + "</a>";
lblcountmyfriends.Attributes.Add("onmouseover", "Tip('Browse My Friends List.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
lblcountmyfriends.Attributes.Add("onmouseout", "UnTip()");
}
if (user.PostedRecipeCount != 0)
{
lblpostedrecipecount.Text = "Published Recipe: <a href=" + "findallrecipebyauthor.aspx?author=" + user.Username + ">" + user.PostedRecipeCount + "</a>";
lblpostedrecipecount.Attributes.Add("onmouseover", "Tip('Browse all my published recipe.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
lblpostedrecipecount.Attributes.Add("onmouseout", "UnTip()");
}
if (user.PostedArticleCount != 0)
{
lblpostedarticlecount.Text = "Published Article: <a href=" + "findallarticlebyauthor.aspx?author=" + user.Username + ">" + user.PostedArticleCount + "</a>";
lblpostedarticlecount.Attributes.Add("onmouseover", "Tip('Browse all my published article.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
lblpostedarticlecount.Attributes.Add("onmouseout", "UnTip()");
}
if (user.CommentRecipeCount != 0)
{
lblcommentedrecipe.Text = "Comments Recipe: <a href=" + "findallrecipecommentedbyuser.aspx?commentauthor=" + user.Username + ">" + user.CommentRecipeCount + "</a>";
lblcommentedrecipe.Attributes.Add("onmouseover", "Tip('Browse all commented recipe.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
lblcommentedrecipe.Attributes.Add("onmouseout", "UnTip()");
}
if (user.CommentArticleCount != 0)
{
lblcommentarticle.Text = "Comments Article: <a href=" + "findallarticlecommentbyuser.aspx?author=" + user.Username + ">" + user.CommentArticleCount + "</a>";
lblcommentarticle.Attributes.Add("onmouseover", "Tip('Browse all my commented article.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
lblcommentarticle.Attributes.Add("onmouseout", "UnTip()");
}
}
private void GetUserWhoAddMeInFriendsList(int UserID)
{
//Get all users who add me in their Friends List.
//This gives user some info who are the user added him/her in Friends list.
ProvidersListOfUserWhoAddedMe Who = new ProvidersListOfUserWhoAddedMe(UserID);
WhoAddsMe.DataSource = Who.GetUsers();
WhoAddsMe.DataBind();
int CountUsers = Blogic.GetCountUserWhoAddMeInFriendsList(UserID);
if (CountUsers != 0)
{
lblcountwhoaddmeinfriendslist.Text = "There are (" + CountUsers + ") users.";
}
else
{
lblcountwhoaddmeinfriendslist.Text = "No users have added you in the Friends List.";
}
Who = null;
}
private void GetLast5UsersWhoSavedMyRecipeInCookBook(int UserID)
{
ProviderLast5UsersWhoSavedMyRecipe WhoSavedMyRecipe = new ProviderLast5UsersWhoSavedMyRecipe(UserID);
Last5UsersWhoSavedMyRecipe.DataSource = WhoSavedMyRecipe.GetUsers();
Last5UsersWhoSavedMyRecipe.DataBind();
int CountUsers = Blogic.GetCountUsersWhoSavedMyRecipeInCookBook(UserID);
if (CountUsers != 0)
{
lblcountuserswhosavedmyrecipe.Text = "There are (" + CountUsers + ") users.";
}
else
{
lblcountuserswhosavedmyrecipe.Text = "No users have saved your recipe in Cook Book.";
}
WhoSavedMyRecipe = null;
}
private void GetDDLSelectedValue()
{
UserFeaturesConfiguration.Fetch(UserIdentity.UserID);
int layout = UserFeaturesConfiguration.GetUserPreferredLayout;
int pagesize = UserFeaturesConfiguration.GetUserPreferredPageSize;
if ((UserFeaturesConfiguration.IsUserChoosePreferredLayoutPageSize))
{
uconfigturnonofflayoutpagesize.Items.Insert(0, new ListItem("Turn On", "1"));
}
else
{
uconfigturnonofflayoutpagesize.Items.Insert(0, new ListItem("Turn Off", "0"));
}
switch (layout)
{
case 1:
uconfigpreflayout.Items.Insert(0, new ListItem("Rows", layout.ToString()));
break;
case 2:
uconfigpreflayout.Items.Insert(0, new ListItem("Grid - 2 Columns", layout.ToString()));
break;
case 3:
uconfigpreflayout.Items.Insert(0, new ListItem("Grid - 3 Columns", layout.ToString()));
break;
}
if (UserFeaturesConfiguration.IsUserChooseToReceivePM)
{
uconfigreceivepm.Items.Insert(0, new ListItem("Receive PM - Yes", "1"));
}
else
{
uconfigreceivepm.Items.Insert(0, new ListItem("Receive PM - No", "0"));
}
if (UserFeaturesConfiguration.IsUserChooseToReceiveEmailAlertReceivePM)
{
uconfigreceivepmemailalert.Items.Insert(0, new ListItem("Receive PM Email - Yes", "1"));
}
else
{
uconfigreceivepmemailalert.Items.Insert(0, new ListItem("Receive PM Email - No", "0"));
}
uconfigprefpagesize.Items.Insert(0, new ListItem(pagesize + " Records Per Page", pagesize.ToString()));
}
private void GetCounters(ProviderUserDetails user)
{
if (user.PostedRecipeCount != 0)
{
lblviewallmysubmittedrecipe.Text = "<img src='images/editsmall.gif'> <a href=" + "findallrecipebyauthor.aspx?author=" + user.Username + ">Edit My Published Recipe</a>";
lblviewallmysubmittedrecipe.Attributes.Add("onmouseover", "Tip('You have published (" + user.PostedRecipeCount + ") recipes.<br>Click to view or edit all of your published recipe.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
lblviewallmysubmittedrecipe.Attributes.Add("onmouseout", "UnTip()");
}
else
{
lblviewallmysubmittedrecipe.Text = "<img src='images/editsmall.gif'> <a href='javascript:void(0)'>Edit My Published Recipe</a>";
lblviewallmysubmittedrecipe.Attributes.Add("onmouseover", "Tip('You have not published any recipe.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
lblviewallmysubmittedrecipe.Attributes.Add("onmouseout", "UnTip()");
}
if (user.PostedArticleCount != 0)
{
lblviewallmypublishedarticle.Text = "<img src='images/editsmall.gif'> <a href=" + "findallarticlebyauthor.aspx?author=" + user.Username + ">Edit My Published Article</a>";
lblviewallmypublishedarticle.Attributes.Add("onmouseover", "Tip('You have published (" + user.PostedArticleCount + ") article.<br>Click to view or edit all of your published article.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
lblviewallmypublishedarticle.Attributes.Add("onmouseout", "UnTip()");
}
else
{
lblviewallmypublishedarticle.Text = "<img src='images/editsmall.gif'> <a href='javascript:void(0)'>Edit My Published Article</a>";
lblviewallmypublishedarticle.Attributes.Add("onmouseover", "Tip('You have not published any article.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
lblviewallmypublishedarticle.Attributes.Add("onmouseout", "UnTip()");
}
}
private void GetReturnFromUpdateMsg()
{
string item = "";
int status = 0;
//After updating settings in Myaccount.aspx
//Make sure parameter is not empty. The passed in parameter mode is "Success"
if (!string.IsNullOrEmpty(Request.QueryString["item"]) && !string.IsNullOrEmpty(Request.QueryString["status"]))
{
item = Request.QueryString["item"];
status = (int)Util.Val(Request.QueryString["status"]);
lblupdatesettingsmsg.Visible = true;
//Public/Private redirection return message
if (item == "fl")
{
switch (status)
{
case 0:
lblupdatesettingsmsg.Text = "<div style='width: 450px; margin-left: 20px; margin-top: 15px; color: #800000;'><img src='images/availuname.gif'> Update Success - Your Friends List is now Private.</div>";
break;
case 1:
lblupdatesettingsmsg.Text = "<div style='width: 450px; margin-left: 20px; margin-top: 15px; color: #800000;'><img src='images/availuname.gif'> Update Success - Your Friends List is now Public.</div>";
break;
}
}
else if (item == "cb")
{
switch (status)
{
case 0:
lblupdatesettingsmsg.Text = "<div style='width: 450px; margin-left: 20px; margin-top: 15px; color: #800000;'><img src='images/availuname.gif'> Update Success - Your Cook Book is now Private.</div>";
break;
case 1:
lblupdatesettingsmsg.Text = "<div style='width: 450px; margin-left: 20px; margin-top: 15px; color: #800000;'><img src='images/availuname.gif'> Update Success - Your Cook Book is now Public.</div>";
break;
}
}
}
if (!string.IsNullOrEmpty(Request.QueryString["item"]) && !string.IsNullOrEmpty(Request.QueryString["numrecord"]))
{
item = Request.QueryString["item"];
int numrecord = (int)Util.Val(Request.QueryString["numrecord"]);
lblupdatesettingsmsg.Visible = true;
if (item == "fln")
{
lblupdatesettingsmsg.Text = "<div style='width: 450px; margin-left: 20px; margin-top: 15px; color: #800000;'><img src='images/availuname.gif'> Update Success - Friends List in your profile page will now show " + numrecord + " friends.</div>";
}
else if (item == "cbn")
{
lblupdatesettingsmsg.Text = "<div style='width: 450px; margin-left: 20px; margin-top: 15px; color: #800000;'><img src='images/availuname.gif'> Update Success - Cook Book in your profile page will now show " + numrecord + " recipes.</div>";
}
}
if (!string.IsNullOrEmpty(Request.QueryString["save"]))
{
lblupdatesettingsmsg.Visible = true;
lblupdatesettingsmsg.Text = "<div style='width: 450px; margin-left: 20px; margin-top: 15px; color: #800000;'><img src='images/availuname.gif'> Update Success - Preferred layout and pagesize has been updated.</div>";
}
if (!string.IsNullOrEmpty(Request.QueryString["method"]) && !string.IsNullOrEmpty(Request.QueryString["setting"]))
{
string method = Request.QueryString["method"];
int settingval = (int)Util.Val(Request.QueryString["setting"]);
lblupdatesettingsmsg.Visible = true;
switch (method)
{
case "receivepm":
if (settingval == 1)
lblupdatesettingsmsg.Text = "<div style='width: 450px; margin-left: 20px; margin-top: 15px; color: #800000;'><img src='images/availuname.gif'> Update Success - Your opted to receive a Private Message from other members.</div>";
else
lblupdatesettingsmsg.Text = "<div style='width: 450px; margin-left: 20px; margin-top: 15px; color: #800000;'><img src='images/availuname.gif'> Update Success - You opted not to receive any Private Message fropm other members.</div>";
break;
case "pmemailalert":
if (settingval == 1)
lblupdatesettingsmsg.Text = "<div style='width: 450px; margin-left: 20px; margin-top: 15px; color: #800000;'><img src='images/availuname.gif'> Update Success - You opted to receive an email alert when someone send you a PM.</div>";
else
lblupdatesettingsmsg.Text = "<div style='width: 450px; margin-left: 20px; margin-top: 15px; color: #800000;'><img src='images/availuname.gif'> Update Success - You opted not to receive an email alert when someone send you a PM.</div>";
break;
}
}
}
public void UpdatePreferredLayoutPageSize_Click(object sender, EventArgs e)
{
if (Authentication.IsUserAuthenticated)
{
Blogic.ConfigurePreferredLayoutPagesize(UserIdentity.UserID, Int32.Parse(Request.Form[uconfigturnonofflayoutpagesize.UniqueID]),
Int32.Parse(Request.Form[uconfigpreflayout.UniqueID]), Int32.Parse(Request.Form[uconfigprefpagesize.UniqueID]));
Response.Redirect("confirmlayoutchange.aspx?ReturnURL=" + this.Request.Url.PathAndQuery + "&flag=1");
}
}
public void UpdateReceivePM_Click(object sender, EventArgs e)
{
if (Authentication.IsUserAuthenticated)
{
Blogic.UpdateReceivePM(UserIdentity.UserID, Int32.Parse(Request.Form[uconfigreceivepm.UniqueID]));
Response.Redirect("confirmupdatepmconfig.aspx?mode=receivepm&val=" + Int32.Parse(Request.Form[uconfigreceivepm.UniqueID]));
}
}
public void UpdateReceivePMEmailAlert_Click(object sender, EventArgs e)
{
if (Authentication.IsUserAuthenticated)
{
Blogic.UpdateReceivePMEmailAlert(UserIdentity.UserID, Int32.Parse(Request.Form[uconfigreceivepmemailalert.UniqueID]));
Response.Redirect("confirmupdatepmconfig.aspx?mode=pmemailalert&val=" + Int32.Parse(Request.Form[uconfigreceivepmemailalert.UniqueID]));
}
}
private void GetMetaTitleTagKeywords(string UserName)
{
Page.Header.Title = UserName + " Account Seetings Page";
HtmlMeta metaTag = new HtmlMeta();
metaTag.Name = "Keywords";
metaTag.Content = UserName + " Account Seetings Page.";
this.Header.Controls.Add(metaTag);
}
}