diff --git a/.vs/Socioboard/v14/.suo b/.vs/Socioboard/v14/.suo index d8076e02c..38fae7b8c 100644 Binary files a/.vs/Socioboard/v14/.suo and b/.vs/Socioboard/v14/.suo differ diff --git a/src/Api.Socioboard/Controllers/FacebookController.cs b/src/Api.Socioboard/Controllers/FacebookController.cs index 889a21911..289916426 100644 --- a/src/Api.Socioboard/Controllers/FacebookController.cs +++ b/src/Api.Socioboard/Controllers/FacebookController.cs @@ -13,6 +13,7 @@ using Socioboard.Facebook.Data; using Microsoft.AspNetCore.Cors; using Domain.Socioboard.Models.Mongo; +using MongoDB.Bson; // For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 @@ -133,7 +134,34 @@ public IActionResult ReconnectFbAccount(string accessToken, long groupId, long u int res = Api.Socioboard.Repositories.FacebookRepository.ReFacebookAccount(profile, FbUser.getFbFriends(accessToken), dbr, userId, ngrp.id, Domain.Socioboard.Enum.FbProfileType.FacebookProfile, accessToken, reconnect, _redisCache, _appSettings, _logger); if (res == 1) { + + MongoRepository repofb = new MongoRepository("FacebookPasswordChangeUserDetail", _appSettings); + try + { + var result = repofb.Find(t => t.profileId == fbacc.FbUserId ); + var task = Task.Run(async () => + { + return await result; + }); + int count = task.Result.Count; + + IList lstFbFeeds = task.Result; + if(count>0) + { + FilterDefinition filter = new BsonDocument("profileId", lstFbFeeds.FirstOrDefault().profileId); + var update = Builders.Update.Set("status", true); + repofb.Update(update, filter); + + } + } + catch (Exception ex) + { + + } + return Ok("Facebook account Reconnect Successfully"); + + } else { diff --git a/src/Api.Socioboard/Controllers/NotificationsController.cs b/src/Api.Socioboard/Controllers/NotificationsController.cs index 462e2501f..b8a5ae0c1 100644 --- a/src/Api.Socioboard/Controllers/NotificationsController.cs +++ b/src/Api.Socioboard/Controllers/NotificationsController.cs @@ -140,6 +140,64 @@ public IActionResult UpdateNotifications(long userId) } - + [HttpGet("ChangePasswordDetail")] + public IActionResult ChangePasswordDetail(long userId) + { + try + { + + MongoRepository mongorepo = new MongoRepository("FacebookPasswordChangeUserDetail", _appSettings); + DatabaseRepository dbr = new DatabaseRepository(_logger, _env); + List datalst = dbr.Find(t => t.UserId == userId).ToList(); + Domain.Socioboard.Models.User userDet = dbr.FindSingle(t => t.Id == userId); + var result = mongorepo.Find(t => t.userId == userId && t.status==false); + var task = Task.Run(async () => + { + return await result; + }); + int count = task.Result.Count; + IList lstfbpasschange = task.Result; + + + if (count>0) + { + return Ok(userDet); + } + else + { + return NotFound(); + } + } + catch (Exception ex) + { + return NotFound(); + } + + + } + + [HttpGet("getfbchangeprofile")] + public IActionResult getfbchangeprofile(long userId) + { + MongoRepository mongorepo = new MongoRepository("FacebookPasswordChangeUserDetail", _appSettings); + DatabaseRepository dbr = new DatabaseRepository(_logger, _env); + List datalst = dbr.Find(t => t.UserId == userId).ToList(); + Domain.Socioboard.Models.User userDet = dbr.FindSingle(t => t.Id == userId); + var result = mongorepo.Find(t => t.userId == userId && t.status==false); + var task = Task.Run(async () => + { + return await result; + }); + int count = task.Result.Count; + IList lstfbpasschange = task.Result; + if (count>0) + { + return Ok(lstfbpasschange.FirstOrDefault().profileId); + } + else + { + return NotFound(); + } + } } } diff --git a/src/Socioboard/wwwroot/contents/socioboard/controllers/facebookfeedscontroller.js b/src/Socioboard/wwwroot/contents/socioboard/controllers/facebookfeedscontroller.js index c8c7fc1b9..d7c3220be 100644 --- a/src/Socioboard/wwwroot/contents/socioboard/controllers/facebookfeedscontroller.js +++ b/src/Socioboard/wwwroot/contents/socioboard/controllers/facebookfeedscontroller.js @@ -217,20 +217,14 @@ SocioboardApp.controller('FacebookFeedsController', function ($rootScope, $scope $scope.reconnect(value.fbProfileType); ac = true; } - }); - if (!ac) { $scope.reconnect(null); } - } - - }, function (reason) { $scope.error = reason.data; }); - }; $scope.confirmation = function () { diff --git a/src/Socioboard/wwwroot/contents/socioboard/controllers/facebookreportcontroller.js b/src/Socioboard/wwwroot/contents/socioboard/controllers/facebookreportcontroller.js index 7e6eed931..185fcd554 100644 --- a/src/Socioboard/wwwroot/contents/socioboard/controllers/facebookreportcontroller.js +++ b/src/Socioboard/wwwroot/contents/socioboard/controllers/facebookreportcontroller.js @@ -1,6 +1,6 @@ 'use strict'; -SocioboardApp.controller('FacebookreportController', function ($rootScope, $scope, $http, $timeout, apiDomain,domain) { +SocioboardApp.controller('FacebookreportController', function ($rootScope, $scope, $http, $timeout, apiDomain) { //alert('helo'); $scope.$on('$viewContentLoaded', function () { $('#Fbfeedsdetails').DataTable({ @@ -71,46 +71,9 @@ SocioboardApp.controller('FacebookreportController', function ($rootScope, $scop } //addaed by me end for total fans - $scope.reconnect = function (xyz) { - $http.get(domain + '/socioboard/recfbcont?id=' + $scope.selectedProfile + '&fbprofileType=' + xyz) - .then(function (response) { - window.location.href = response.data; - - }, function (reason) { - $scope.error = reason.data; - }); - - }; - - $scope.fbprofiles = function () { - - console.log($scope.selectedProfile); - $http.get(apiDomain + '/api/Facebook/GetFacebookProfilesOnlyforReconn?groupId=' + $rootScope.groupId) - .then(function (response) { - console.log(response.data) - if (response.data != null) { - var ac = false; - $scope.profiledet = response.data; - angular.forEach($scope.profiledet, function (value, key) { - if (value.fbUserId == $scope.selectedProfile) { - $scope.reconnect(value.fbProfileType); - ac = true; - } - - }); - - if (!ac) { - $scope.reconnect(null); - } - - } - - - }, function (reason) { - $scope.error = reason.data; - }); + - }; + $scope.getData = function (profileId, days) { diff --git a/src/Socioboard/wwwroot/contents/socioboard/controllers/fbpagedetreportcontroller.js b/src/Socioboard/wwwroot/contents/socioboard/controllers/fbpagedetreportcontroller.js index 1ca6bcf62..dec188214 100644 --- a/src/Socioboard/wwwroot/contents/socioboard/controllers/fbpagedetreportcontroller.js +++ b/src/Socioboard/wwwroot/contents/socioboard/controllers/fbpagedetreportcontroller.js @@ -95,45 +95,45 @@ SocioboardApp.controller('FbpagedetreportController', function ($rootScope, $sco } //for fbpage daily report details-------end - $scope.reconnect = function (xyz) { - $http.get(domain + '/socioboard/recfbcont?id=' + $stateParams.profileId + '&fbprofileType=' + xyz) - .then(function (response) { - window.location.href = response.data; + // $scope.reconnect = function (xyz) { + // $http.get(domain + '/socioboard/recfbcont?id=' + $stateParams.profileId + '&fbprofileType=' + xyz) + // .then(function (response) { + // window.location.href = response.data; - }, function (reason) { - $scope.error = reason.data; - }); + // }, function (reason) { + // $scope.error = reason.data; + // }); - }; + //}; - $scope.fbprofiles = function () { + //$scope.fbprofiles = function () { - $http.get(apiDomain + '/api/Facebook/GetFacebookProfilesOnlyforReconn?groupId=' + $rootScope.groupId) - .then(function (response) { - console.log(response.data) - if (response.data != null) { - var ac = false; - $scope.profiledet = response.data; - angular.forEach($scope.profiledet, function (value, key) { - if (value.fbUserId == $stateParams.profileId) { - $scope.reconnect(value.fbProfileType); - ac = true; - } + // $http.get(apiDomain + '/api/Facebook/GetFacebookProfilesOnlyforReconn?groupId=' + $rootScope.groupId) + // .then(function (response) { + // console.log(response.data) + // if (response.data != null) { + // var ac = false; + // $scope.profiledet = response.data; + // angular.forEach($scope.profiledet, function (value, key) { + // if (value.fbUserId == $stateParams.profileId) { + // $scope.reconnect(value.fbProfileType); + // ac = true; + // } - }); + // }); - if (!ac) { - $scope.reconnect(null); - } + // if (!ac) { + // $scope.reconnect(null); + // } - } + // } - }, function (reason) { - $scope.error = reason.data; - }); + // }, function (reason) { + // $scope.error = reason.data; + // }); - }; + //}; diff --git a/src/Socioboard/wwwroot/contents/socioboard/controllers/notificationallcontroller.js b/src/Socioboard/wwwroot/contents/socioboard/controllers/notificationallcontroller.js index f48d1e29a..55b8d4404 100644 --- a/src/Socioboard/wwwroot/contents/socioboard/controllers/notificationallcontroller.js +++ b/src/Socioboard/wwwroot/contents/socioboard/controllers/notificationallcontroller.js @@ -28,7 +28,7 @@ SocioboardApp.controller('NotificationAllController', function ($rootScope, $sco $scope.changepass = function () { - $http.get(apiDomain + '/api/Notifications/ChangePasswordDetail?userId=' + $rootScope.user.Id ) + $http.get(apiDomain + '/api/Notifications/ChangePasswordDetail?userId=' + $rootScope.user.Id+'&user' ) .then(function (response) { $scope.lstChangePass = response.data; console.log($scope.lstChangePass); @@ -44,6 +44,39 @@ SocioboardApp.controller('NotificationAllController', function ($rootScope, $sco $scope.changepass(); + + $scope.getfbprofileId = function () { + + $http.get(apiDomain + '/api/Notifications/getfbchangeprofile?userId=' + $rootScope.user.Id) + .then(function (response) { + $scope.lstfbprofile = response.data; + // console.log($scope.lstfbprofile); + //var abc = $scope.lstfbprofile; + + //$scope.notifycount = $scope.notifycount + 10; + + }, function (reason) { + $scope.error = reason.data; + }); + // end codes to load recent Feeds + } + $scope.getfbprofileId(); + + $scope.reconnect = function () { + var facebookid = $scope.lstfbprofile; + console.log($scope.lstfbprofile); + // console.log("abcd", $scope.lstfbprofile.userPrimaryEmail); + $http.get(domain + '/socioboard/recfbcont?id=' + facebookid + '&fbprofileType=' + 0) + .then(function (response) { + window.location.href = response.data; + + }, function (reason) { + $scope.error = reason.data; + }); + + }; + + // start codes to load recent Feeds $scope.loadmore = function () { $("#load_more_toggle").addClass("hide"); diff --git a/src/Socioboard/wwwroot/contents/socioboard/views/reports/facebookpagedetreport.html b/src/Socioboard/wwwroot/contents/socioboard/views/reports/facebookpagedetreport.html index a7aff713b..5c94834c4 100644 --- a/src/Socioboard/wwwroot/contents/socioboard/views/reports/facebookpagedetreport.html +++ b/src/Socioboard/wwwroot/contents/socioboard/views/reports/facebookpagedetreport.html @@ -2,11 +2,7 @@

- Showing last 90 days report ({{fromDate | date}} - {{toDate | date}}) - - Reconnect    - - + Showing last 90 days report ({{fromDate | date}} - {{toDate | date}})

diff --git a/src/Socioboard/wwwroot/contents/socioboard/views/reports/facebookpagereport.html b/src/Socioboard/wwwroot/contents/socioboard/views/reports/facebookpagereport.html index 79f870e3e..518eede12 100644 --- a/src/Socioboard/wwwroot/contents/socioboard/views/reports/facebookpagereport.html +++ b/src/Socioboard/wwwroot/contents/socioboard/views/reports/facebookpagereport.html @@ -16,9 +16,7 @@
15 30 60 - 90 - Reconnect - + 90
diff --git a/src/Socioboard/wwwroot/contents/socioboard/views/reports/facebookreport.html b/src/Socioboard/wwwroot/contents/socioboard/views/reports/facebookreport.html index acabde37a..734999d74 100644 --- a/src/Socioboard/wwwroot/contents/socioboard/views/reports/facebookreport.html +++ b/src/Socioboard/wwwroot/contents/socioboard/views/reports/facebookreport.html @@ -16,16 +16,12 @@
15 30 60 - 90 - - Reconnect    - + 90
-
diff --git a/src/Socioboard/wwwroot/contents/socioboard/views/settings/notification_all.html b/src/Socioboard/wwwroot/contents/socioboard/views/settings/notification_all.html index 10f020b26..f3e823b81 100644 --- a/src/Socioboard/wwwroot/contents/socioboard/views/settings/notification_all.html +++ b/src/Socioboard/wwwroot/contents/socioboard/views/settings/notification_all.html @@ -23,17 +23,19 @@
Your notifications
    -
  • +
  • -
    - - For {{lstChangePass.userPrimaryEmail}} account password has change , please reconnect your account !! -
    -
  • {{notify.socialprofileName}} diff --git a/src/SocioboardDataServices/Reports/FacebookReports/FacebookPageReports.cs b/src/SocioboardDataServices/Reports/FacebookReports/FacebookPageReports.cs index df09d19a5..adbc0c5bc 100644 --- a/src/SocioboardDataServices/Reports/FacebookReports/FacebookPageReports.cs +++ b/src/SocioboardDataServices/Reports/FacebookReports/FacebookPageReports.cs @@ -22,37 +22,42 @@ public static void CreateFacebookPageReport() { try { + int c = 0; DatabaseRepository dbr = new DatabaseRepository(); List lstFbAcc = dbr.Find(t => t.IsAccessTokenActive && t.IsActive && t.FbProfileType == Domain.Socioboard.Enum.FbProfileType.FacebookPage).ToList(); - + //lstFbAcc = lstFbAcc.Where(t => t.FbUserId.Contains("790900144392091")).ToList(); foreach (var item in lstFbAcc) { - if (item.lastpagereportgenerated.AddHours(24) <= DateTime.UtcNow) - { - CreateReports(item.FbUserId, item.AccessToken, item.Is90DayDataUpdated); + //if (item.lastpagereportgenerated.AddHours(24) <= DateTime.UtcNow) + //{ + CreateReports(item.FbUserId, item.AccessToken, item.Is90DayDataUpdated,item.UserId); item.Is90DayDataUpdated = true; item.lastpagereportgenerated = DateTime.UtcNow; dbr.Update(item); cache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterMessageReportsByProfileId + item.FbUserId); - } + Console.WriteLine(c++); + Console.WriteLine("updated "+item.FbUserId); + + // } } Thread.Sleep(60000); } catch (Exception ex) { Console.WriteLine("issue in web api calling" + ex.StackTrace); - Thread.Sleep(600000); + Thread.Sleep(60000); } } } - public static void CreateReports(string ProfileId, string AccessToken, bool is90daysupdated) + public static void CreateReports(string ProfileId, string AccessToken, bool is90daysupdated,long userId) { int day = 1; if (!is90daysupdated) { day = 90; } + double since = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow.AddDays(-day)); double until = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow); JObject pageobj = new JObject(); @@ -80,6 +85,12 @@ public static void CreateReports(string ProfileId, string AccessToken, bool is90 JObject jofacebooksharing_typeUrlobj = new JObject(); JObject jofacebookagegenderUrlobj = new JObject(); + MongoRepository mongorepofb = new MongoRepository("FacebookPasswordChangeUserDetail"); + + string errormsg = null; + string ispasschange = null; + string msg = null; + #region likes try @@ -96,10 +107,14 @@ public static void CreateReports(string ProfileId, string AccessToken, bool is90 { string facebooknewfanUrl = "https://graph.facebook.com/v2.7/" + ProfileId + "/insights/page_fan_adds?pretty=0&since=" + since.ToString() + "&suppress_http_code=1&until=" + until.ToString() + "&access_token=" + AccessToken; string outputface = getFacebookResponse(facebooknewfanUrl); + ispasschange = outputface; likesobj = JArray.Parse(JArray.Parse(JObject.Parse(outputface)["data"].ToString())[0]["values"].ToString()); } catch (Exception ex) { + errormsg = ispasschange; + msg = getBetween(errormsg, "e\":\"", ":"); + } #endregion #region unlikes @@ -107,10 +122,12 @@ public static void CreateReports(string ProfileId, string AccessToken, bool is90 { string facebookunlikjeUrl = "https://graph.facebook.com/v2.7/" + ProfileId + "/insights/page_fan_removes?pretty=0&since=" + since.ToString() + "&suppress_http_code=1&until=" + until.ToString() + "&access_token=" + AccessToken; string outputfaceunlike = getFacebookResponse(facebookunlikjeUrl); + ispasschange = outputfaceunlike; unlikesobj = JArray.Parse(JArray.Parse(JObject.Parse(outputfaceunlike)["data"].ToString())[0]["values"].ToString()); } catch (Exception ex) { + errormsg = ispasschange; } #endregion #region impression @@ -226,6 +243,52 @@ public static void CreateReports(string ProfileId, string AccessToken, bool is90 { } + try + { + if (msg == "Error validating access token") + { + + DatabaseRepository dbr = new DatabaseRepository(); + Domain.Socioboard.Models.Facebookaccounts lstFbAcc = dbr.Single(t => t.FbUserId == ProfileId); + Domain.Socioboard.Models.User lstUser = dbr.Single(t => t.Id == lstFbAcc.UserId); + Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail fbdetailpass = new Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail(); + fbdetailpass.Id = ObjectId.GenerateNewId(); + fbdetailpass.strId = ObjectId.GenerateNewId().ToString(); + fbdetailpass.userId = userId; + fbdetailpass.profileId = ProfileId; + fbdetailpass.message = msg; + fbdetailpass.userPrimaryEmail = lstUser.EmailId; + fbdetailpass.dateValue = DateTime.Today.ToString(); + fbdetailpass.status = false; + + try + { + MongoRepository mongorepo = new MongoRepository("FacebookPasswordChangeUserDetail"); + var ret = mongorepo.Find(t => t.profileId == fbdetailpass.profileId); + var task = Task.Run(async () => + { + return await ret; + }); + if (task.Result != null) + { + if (task.Result.Count() < 1) + { + mongorepo.Add(fbdetailpass); + } + } + } + catch (Exception ex) + { + } + + } + } + catch (Exception ex) + { + + } + + #endregion foreach (JObject obj in likesobj) { @@ -827,7 +890,7 @@ public static void CreateReports(string ProfileId, string AccessToken, bool is90 try { MongoRepository mongorepo = new MongoRepository("FacaebookPageDailyReports"); - var ret = mongorepo.Find(t => t.date == facebookReportViewModal.date); + var ret = mongorepo.Find(t => t.date == facebookReportViewModal.date && t.pageId == facebookReportViewModal.pageId); var task = Task.Run(async () => { return await ret; @@ -850,6 +913,22 @@ public static void CreateReports(string ProfileId, string AccessToken, bool is90 } + + public static string getBetween(string strSource, string strStart, string strEnd) + { + int Start, End; + if (strSource.Contains(strStart) && strSource.Contains(strEnd)) + { + Start = strSource.IndexOf(strStart, 0) + strStart.Length; + End = strSource.IndexOf(strEnd, Start); + return strSource.Substring(Start, End - Start); + } + else + { + return ""; + } + } + public static string getFacebookResponse(string Url) { var facebooklistpagerequest = (HttpWebRequest)WebRequest.Create(Url);