forked from socioboard/socioboard-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Publishing.aspx.cs
502 lines (418 loc) · 23 KB
/
Publishing.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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SocioBoard.Domain;
using SocioBoard.Model;
using GlobusGooglePlusLib.Authentication;
using GlobusInstagramLib.Authentication;
using GlobusLinkedinLib.Authentication;
using GlobusTwitterLib.Authentication;
using System.Configuration;
using System.Collections;
using log4net;
using SocioBoard.Helper;
namespace SocioBoard
{
public partial class Publishing : System.Web.UI.Page
{
ILog logger = LogManager.GetLogger(typeof(Publishing));
string Datetime = string.Empty;
UserRepository objUserRepository = new UserRepository();
protected void Page_Load(object sender, EventArgs e)
{
TeamRepository objTeamRepository = new TeamRepository();
GroupRepository objGroupRepository = new GroupRepository();
//SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"];
// Session["groupcheck"]
User user = (User)Session["LoggedUser"];
try
{
#region for You can use only 30 days as Unpaid User
//SocioBoard.Domain.User user = (User)Session["LoggedUser"];
if (user.PaymentStatus.ToLower() == "unpaid")
{
if (!SBUtils.IsUserWorkingDaysValid(user.ExpiryDate))
{
// ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('You can use only 30 days as Unpaid User !');", true);
Session["GreaterThan30Days"] = "GreaterThan30Days";
Response.Redirect("/Settings/Billing.aspx");
}
}
#endregion
}
catch (Exception ex)
{
Console.WriteLine("Error : " + ex.StackTrace);
}
if (user != null)
{
if (user.ActivationStatus == "0" || user.ActivationStatus == null)
{
actdiv.InnerHtml = "<marquee behavior=\"scroll\" direction=\"left\"><span >Your account is not yet activated.Check your E-mail to activate your account.</span><a id=\"resendmail\" uid=\"" + user.Id + "\" href=\"#\">Resend Mail</a></marquee>";
if (Request.QueryString["stat"] == "activate")
{
if (Request.QueryString["id"] != null)
{
//objUserActivation = objUserActivationRepository.GetUserActivationStatusbyid(Request.QueryString["id"].ToString());
if (user.Id.ToString() == Request.QueryString["id"].ToString())
{
user.Id = user.Id; //Guid.Parse(Request.QueryString["id"]);
//objUserActivation.UserId = Guid.Parse(Request.QueryString["id"]);// objUserActivation.UserId;
user.ActivationStatus = "1";
//UserActivationRepository.Update(objUserActivation);
int res = objUserRepository.UpdateActivationStatusByUserId(user);
actdiv.Attributes.CssStyle.Add("display", "none");
Console.WriteLine("before");
#region to check/update user Reference Relation
IsUserReferenceActivated(Request.QueryString["id"].ToString());
Console.WriteLine("after");
#endregion
}
else
{
Session["ActivationError"] = "Wrong Activation Link please contact Admin!";
//ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Wrong Activation Link please contact Admin!');", true);
//Response.Redirect("ActivationLink.aspx");
}
}
else
{
Session["ActivationError"] = "Wrong Activation Link please contact Admin!";
//ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Wrong Activation Link please contact Admin!');", true);
//Response.Redirect("ActivationLink.aspx");
}
}
else
{
// Response.Redirect("ActivationLink.aspx");
}
}
//if (Session["groupcheck"] == null)
//{
// Session["groupcheck"] = groupsselection.SelectedValue;
//}
//else
//{
// groupsselection.SelectedValue = Session["groupcheck"].ToString();
//}
if (user.ActivationStatus == "1")
{
actdiv.Attributes.CssStyle.Add("display", "none");
}
}
if (!IsPostBack)
{
if (user == null)
Response.Redirect("/Default.aspx");
else
{
try
{
ArrayList totalAccuount = objTeamRepository.getAllAccountUser(user.EmailId,user.Id);
if (totalAccuount.Count != 0)
{
try
{
foreach (Guid item in totalAccuount)
{
Guid GroupIde = (Guid)item;
List<Groups> GetData = objGroupRepository.getAllGroupsDetail(GroupIde);
if (GetData.Count != 0)
{
foreach (var items in GetData)
{
try
{
groupsselection.Items.Add(new ListItem((string)items.GroupName, items.Id.ToString()));
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
logger.Error("Error : " + ex.Message);
logger.Error("Error : " + ex.StackTrace);
}
}
}
if (Session["groupcheck"] == null)
{
Session["groupcheck"] = groupsselection.SelectedValue;
}
else
{
groupsselection.SelectedValue = Session["groupcheck"].ToString();
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
logger.Error("Error : " + ex.Message);
logger.Error("Error : " + ex.StackTrace);
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
logger.Error("Error : " + ex.Message);
logger.Error("Error : " + ex.StackTrace);
}
NewMethod(user);
}
}
}
private void NewMethod(User user)
{
SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"];
TeamRepository objTeamRepository = new TeamRepository();
GroupRepository objGroupRepository = new GroupRepository();
RssFeedsRepository rssFeedsRepo = new RssFeedsRepository();
List<RssFeeds> lstrssfeeds = rssFeedsRepo.getAllActiveRssFeeds(user.Id);
TwitterAccountRepository twtAccountRepo = new TwitterAccountRepository();
ArrayList arrTwtAcc = twtAccountRepo.getAllTwitterAccountsOfUser(user.Id);
//===================================================================================================================================
//====================================================================================================================================
if (lstrssfeeds != null)
{
if (lstrssfeeds.Count != 0)
{
//int rssCount = 0;
string rssData = string.Empty;
rssData += "<h2 class=\"league section-ttl rss_header\">Active RSS Feeds</h2>";
foreach (RssFeeds item in lstrssfeeds)
{
TwitterAccount twtAccount = twtAccountRepo.getUserInformation(item.ProfileScreenName, user.Id);
string picurl = string.Empty;
if (string.IsNullOrEmpty(twtAccount.ProfileUrl))
{
picurl = "../Contents/img/blank_img.png";
}
else
{
picurl = twtAccount.ProfileUrl;
}
rssData += " <section id=\"" + item.Id + "\" class=\"publishing\">" +
"<section class=\"twothird\">" +
"<article class=\"quarter\">" +
"<div href=\"#\" class=\"avatar_link view_profile\" title=\"\">" +
"<img title=\"" + item.ProfileScreenName + "\" src=\"" + picurl + "\" data-src=\"\" class=\"avatar sm\">" +
"<article class=\"rss_ava_icon\"><span title=\"Twitter\" class=\"icon twitter_16\"></span></article>" +
"</div>" +
"</article>" +
"<article class=\"threefourth\">" +
"<ul>" +
"<li>" + item.FeedUrl + "</li>" +
"<li>Prefix: </li>" +
"<li class=\"freq\" title=\"New items from this feed will be posted at most once every hour\">Max Frequency: " + item.Duration + "</li>" +
"</ul>" +
"</article>" +
"</section>" +
"<section class=\"third\">" +
"<ul class=\"rss_action_buttons\">" +
"<li onclick=\"pauseFunction('" + item.Id + "');\" class=\"\"><a id=\"pause_" + item.Id + "\" href=\"#\" title=\"Pause\" class=\"small_pause icon pause\"></a></li>" +
"<li onclick=\"deleteRssFunction('" + item.Id + "');\" class=\"show-on-hover\"><a id=\"delete_" + item.Id + "\" href=\"#\" title=\"Delete\" class=\"small_remove icon delete\"></a></li>" +
"</ul>" +
"</section>" +
"</section>";
}
rss.InnerHtml = rssData;
rss.Style.Add("display", "block");
rdata.Style.Add("display", "none");
}
}
try
{
if (Session["IncomingTasks"] != null)
{
//incom_tasks.InnerHtml = Convert.ToString((int)Session["IncomingTasks"]);
//incomTasks.InnerHtml = Convert.ToString((int)Session["IncomingTasks"]);
}
else
{
TaskRepository taskRepo = new TaskRepository();
ArrayList alst = taskRepo.getAllIncompleteTasksOfUser(user.Id,team.GroupId);
Session["IncomingTasks"] = alst.Count;
}
}
catch (Exception es)
{
logger.Error(es.StackTrace);
Console.WriteLine(es.StackTrace);
}
if (Session["CountMessages"] != null)
{
//incom_messages.InnerHtml = Convert.ToString((int)Session["CountMessages"]);
//incomMessages.InnerHtml = Convert.ToString((int)Session["CountMessages"]);
}
else
{
//incom_messages.InnerHtml = "0";
//incomMessages.InnerHtml = "0";
}
//usernm.InnerHtml = "Hello, <a href=\"../Settings/PersonalSettings.aspx\"> " + user.UserName + "</a>";
usernm.InnerHtml = "Hello, " + user.UserName + "";
//usernm.InnerHtml = "Hello, <a href=\"../Settings/PersonalSettings.aspx\"> " + user.UserName + "</a>";
usernm.InnerHtml = "Hello, " + user.UserName + "";
//usernm.InnerHtml = "Hello, <a href=\"../Settings/PersonalSettings.aspx\"> " + user.UserName + "</a>";
if (!string.IsNullOrEmpty(user.ProfileUrl))
{
//userimg.InnerHtml = "<a href=\"../Settings/PersonalSettings.aspx\"><img id=\"loggeduserimg\" src=\"" + user.ProfileUrl + "\" alt=\"" + user.UserName + "\"/></a>";
userimg.InnerHtml = "<img id=\"loggeduserimg\" src=\"" + user.ProfileUrl + "\" alt=\"" + user.UserName + "\"/>";
if (user.TimeZone != null)
{
Datetime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToLongDateString() + " " + TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToShortTimeString() + " (" + user.TimeZone + ")";
//userinf.InnerHtml = Datetime;
}
if (user.TimeZone == null)
{
Datetime = DateTime.Now.ToString();
//userinf.InnerHtml = Datetime;
}
}
else
{
//userimg.InnerHtml = "<a href=\"../Settings/PersonalSettings.aspx\"><img id=\"loggeduserimg\" src=\"../Contents/img/blank_img.png\" alt=\"" + user.UserName + "\"/></a>";
userimg.InnerHtml = "<img id=\"loggeduserimg\" src=\"../Contents/img/blank_img.png\" alt=\"" + user.UserName + "\"/>";
if (user.TimeZone != null)
{
Datetime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToLongDateString() + " " + TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, user.TimeZone).ToShortTimeString() + " (" + user.TimeZone + ")";
//userinf.InnerHtml = Datetime;
}
if (user.TimeZone == null)
{
Datetime = DateTime.Now.ToString();
//userinf.InnerHtml = Datetime;
}
}
try
{
GroupRepository grouprepo = new GroupRepository();
List<Groups> lstgroups = grouprepo.getAllGroups(user.Id);
string totgroups = string.Empty;
if (lstgroups.Count != 0)
{
foreach (Groups item in lstgroups)
{
totgroups += "<li><a href=\"../Settings/InviteMember.aspx?q=" + item.Id + "\" id=\"group_" + item.Id + "\"><img src=\"../Contents/img/groups_.png\" alt=\"\" style=\" margin-right:5px;\"/>" + item.GroupName + "</a></li>";
}
inviteRedirect.InnerHtml = totgroups;
}
}
catch (Exception ex)
{
logger.Error(ex.StackTrace);
Console.WriteLine(ex.StackTrace);
}
}
public void AuthenticateFacebook(object sender, EventArgs e)
{
string fb = "http://www.facebook.com/dialog/oauth/?scope=publish_stream,read_stream,read_insights,manage_pages,user_checkins,user_photos,read_mailbox,manage_notifications,read_page_mailboxes,email,user_videos,offline_access&client_id=" + ConfigurationManager.AppSettings["ClientId"] + "&redirect_uri=" + ConfigurationManager.AppSettings["RedirectUrl"] + "&response_type=code";
// fb_cont.HRef = fb_account.HRef;
Response.Redirect(fb);
}
public void AuthenticateTwitter(object sender, EventArgs e)
{
oAuthTwitter OAuth = new oAuthTwitter();
if (Request["oauth_token"] == null)
{
OAuth.AccessToken = string.Empty;
OAuth.AccessTokenSecret = string.Empty;
OAuth.CallBackUrl = ConfigurationManager.AppSettings["callbackurl"].ToString();
Response.Redirect(OAuth.AuthorizationLinkGet());
}
}
public void AuthenticateLinkedin(object sender, EventArgs e)
{
oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();
string authLink = Linkedin_oauth.AuthorizationLinkGet();
Session["reuqestToken"] = Linkedin_oauth.Token;
Session["reuqestTokenSecret"] = Linkedin_oauth.TokenSecret;
Response.Redirect(authLink);
}
public void AuthenticateInstagram(object sender, EventArgs e)
{
GlobusInstagramLib.Authentication.ConfigurationIns config = new GlobusInstagramLib.Authentication.ConfigurationIns("https://instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"].ToString(), ConfigurationManager.AppSettings["InstagramClientSec"].ToString(), ConfigurationManager.AppSettings["InstagramCallBackURL"].ToString(), "https://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
oAuthInstagram _api = oAuthInstagram.GetInstance(config);
Response.Redirect(_api.AuthGetUrl("likes+comments+basic+relationships"));
}
public void AuthenticateGooglePlus(object sender, EventArgs e)
{
oAuthToken objToken = new oAuthToken();
Response.Redirect(objToken.GetAutherizationLink("https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/plus.me+https://www.googleapis.com/auth/plus.login"));
}
public void fbPage_connect(object sender, EventArgs e)
{
try
{
Session["fbSocial"] = "p";
string fbpageconnectClick = "http://www.facebook.com/dialog/oauth/?scope=publish_stream,read_stream,read_insights,manage_pages,user_checkins,user_photos,read_mailbox,manage_notifications,read_page_mailboxes,email,user_videos,offline_access&client_id=" + ConfigurationManager.AppSettings["ClientId"] + "&redirect_uri=" + ConfigurationManager.AppSettings["RedirectUrl"] + "&response_type=code";
Response.Redirect(fbpageconnectClick);
}
catch (Exception Err)
{
logger.Error(Err.StackTrace);
Response.Write(Err.Message.ToString());
}
}
public bool IsUserReferenceActivated(string RefereeId)
{
//testing
Console.WriteLine("Inside " + RefereeId);
bool ret = false;
try
{
User objUser = new User();
Package objPackage = new Package();
UserPackageRelation objUserPackageRelation = new UserPackageRelation();
UserRepository objUserRepository = new UserRepository();
UserPackageRelationRepository objUserPackageRelationRepository = new UserPackageRelationRepository();
UserRefRelation objUserRefRelation = new UserRefRelation();
UserRefRelationRepository objUserRefRelationRepository = new UserRefRelationRepository();
PackageRepository objPackageRepository = new PackageRepository();
objUserRefRelation.ReferenceUserId = (Guid.Parse(RefereeId));
//testing
List<UserRefRelation> check = objUserRefRelationRepository.GetUserRefRelationInfo();
//testing
List<UserRefRelation> lstUserRefRelation = objUserRefRelationRepository.GetUserRefRelationInfoByRefreeId(objUserRefRelation);
if (lstUserRefRelation.Count > 0)
{
if (lstUserRefRelation[0].Status == "0")
{
objUserRefRelation = lstUserRefRelation[0];
objUserRefRelation.Status = "1";
objUser = objUserRepository.getUsersById(lstUserRefRelation[0].ReferenceUserId);
objUser.ExpiryDate = objUser.ExpiryDate.AddDays(30);
objUser.AccountType = "Premium";
objPackage = objPackageRepository.getPackageDetails("Premium");
objUserPackageRelation.Id = Guid.NewGuid();
objUserPackageRelation.UserId = objUser.Id;
objUserPackageRelation.PackageId = objPackage.Id;
objUserPackageRelation.ModifiedDate = DateTime.Now;
objUserPackageRelation.PackageStatus = true;
objUserPackageRelationRepository.AddUserPackageRelation(objUserPackageRelation);
int objUserRepositoryresponse = objUserRepository.UpdateUserExpiryDateById(objUser);
int objUserRefRelationRepositoryresponse = objUserRefRelationRepository.UpdateStatusById(objUserRefRelation);
}
}
}
catch (Exception ex)
{
logger.Error(ex.Message);
}
return ret;
}
protected void groupsselection_SelectedIndexChanged(object sender, EventArgs e)
{
SocioBoard.Domain.User user = (User)Session["LoggedUser"];
string GroupNames = string.Empty;
TeamRepository objTeamRepository = new TeamRepository();
Team lstDetails = objTeamRepository.getAllGroupsDetails(user.EmailId.ToString(), Guid.Parse(groupsselection.SelectedValue),user.Id);
Session["GroupName"] = lstDetails;
Session["groupcheck"] = groupsselection.SelectedValue;
NewMethod(user);
}
}
}