public IActionResult GetAllLinkedAccountProfiles(long groupId)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
            List <Domain.Socioboard.Models.Groupprofiles>   lstGrpProfiles = Repositories.GroupProfilesRepository.GetAllGroupProfiles(groupId, _redisCache, dbr);
            List <Domain.Socioboard.Models.LinkedInAccount> lstInsAcc      = new List <Domain.Socioboard.Models.LinkedInAccount>();

            foreach (var item in lstGrpProfiles.Where(t => t.profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedIn))
            {
                Domain.Socioboard.Models.LinkedInAccount insAcc = Repositories.LinkedInAccountRepository.getLinkedInAccount(item.profileId, _redisCache, dbr);
                if (insAcc != null)
                {
                    lstInsAcc.Add(insAcc);
                }
            }
            return(Ok(lstInsAcc));
        }
        public IActionResult AddLinkedInAccount(string Code, long groupId, long userId)
        {
            DatabaseRepository dbr         = new DatabaseRepository(_logger, _env);
            string             accesstoken = Helper.LinkedInHelper.GetAccessToken(Code, _appSettings);

            if (!string.IsNullOrEmpty(accesstoken))
            {
                oAuthLinkedIn _oauth = new oAuthLinkedIn();
                _oauth.ConsumerKey    = _appSettings.LinkedinApiKey;
                _oauth.ConsumerSecret = _appSettings.LinkedinSecretKey;
                _oauth.Token          = accesstoken;
                dynamic profile    = Helper.LinkedInHelper.getLinkedInProfile(_oauth);
                string  linkedinId = profile.id.ToString();
                Domain.Socioboard.Models.LinkedInAccount linaccount = Repositories.LinkedInAccountRepository.getLinkedInAccount(linkedinId, _redisCache, dbr);
                if (linaccount != null && linaccount.IsActive == true)
                {
                    if (linaccount.UserId == userId)
                    {
                        return(BadRequest("LinkedIn account already added by you."));
                    }
                    return(BadRequest("LinkedIn account added by other user."));
                }
                else
                {
                    Groups ngrp = dbr.Find <Domain.Socioboard.Models.Groups>(t => t.adminId == userId && t.id == groupId).FirstOrDefault();
                    if (ngrp == null)
                    {
                        return(Ok("Wrong Group Id"));
                    }
                    int i = Repositories.LinkedInAccountRepository.AddLinkedInAccount(_oauth, profile, dbr, userId, groupId, accesstoken, _redisCache, _appSettings, _logger);
                    if (i == 1)
                    {
                        return(Ok("LinkedIn Added Successfully"));
                    }
                    else
                    {
                        return(BadRequest("Error while Adding Account"));
                    }
                }
            }
            else
            {
                return(Ok("Issue In Fetching Access Token"));
            }
        }
        public static string PostLinkedInMessage(string ImageUrl, long userid, string comment, string ProfileId, string imagepath, Helper.Cache _redisCache, Helper.AppSettings _appSettings, Model.DatabaseRepository dbr)
        {
            string json = "";

            Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedInAccount(ProfileId, _redisCache, dbr);
            oAuthLinkedIn _oauth = new oAuthLinkedIn();

            _oauth.ConsumerKey    = _appSettings.LinkedinApiKey;
            _oauth.ConsumerSecret = _appSettings.LinkedinSecretKey;
            _oauth.Token          = _LinkedInAccount.OAuthToken;
            string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json";

            if (string.IsNullOrEmpty(ImageUrl))
            {
                json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment);
            }
            else
            {
                json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, imagepath);
            }

            if (!string.IsNullOrEmpty(json))
            {
                ScheduledMessage scheduledMessage = new ScheduledMessage();
                scheduledMessage.createTime   = DateTime.UtcNow;
                scheduledMessage.picUrl       = ImageUrl;
                scheduledMessage.profileId    = ProfileId;
                scheduledMessage.profileType  = Domain.Socioboard.Enum.SocialProfileType.LinkedIn;
                scheduledMessage.scheduleTime = DateTime.UtcNow;
                scheduledMessage.shareMessage = comment;
                scheduledMessage.userId       = userid;
                scheduledMessage.status       = Domain.Socioboard.Enum.ScheduleStatus.Compleated;
                scheduledMessage.url          = json;
                dbr.Add <ScheduledMessage>(scheduledMessage);

                return("posted");
            }
            else
            {
                json = "Message not posted";
                return(json);
            }
        }
        public static string ComposeLinkedInMessage(string ImageUrl, long userid, string comment, string ProfileId, string imagepath, Domain.Socioboard.Models.LinkedInAccount _objLinkedInAccount, Model.DatabaseRepository dbr, Domain.Socioboard.Models.ScheduledMessage schmessage)
        {
            string json = "";

            Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = _objLinkedInAccount;
            oAuthLinkedIn _oauth = new oAuthLinkedIn();

            //_oauth.ConsumerKey = "81k55eukagnqfa";
            //_oauth.ConsumerSecret = "d9rqHEf7ewdSbsF1";
            _oauth.ConsumerKey    = "754ysxdp72ulk5";
            _oauth.ConsumerSecret = "vbU52SjK7xS6cT8H";
            _oauth.Token          = _LinkedInAccount.OAuthToken;
            string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json";

            if (string.IsNullOrEmpty(ImageUrl))
            {
                json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment);
            }
            else
            {
                json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, imagepath);
            }

            if (!string.IsNullOrEmpty(json))
            {
                apiHitsCount++;
                schmessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated;
                schmessage.url    = json;
                dbr.Add <ScheduledMessage>(schmessage);
                return("posted");
            }
            else
            {
                apiHitsCount = MaxapiHitsCount;
                json         = "Message not posted";
                return(json);
            }
        }
Beispiel #5
0
        public static string ComposeLinkedInMessage(string ImageUrl, long userid, string comment, string ProfileId, string imagepath, Domain.Socioboard.Models.LinkedInAccount _objLinkedInAccount, Model.DatabaseRepository dbr, Domain.Socioboard.Models.ScheduledMessage schmessage)
        {
            string json = "";

            Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = _objLinkedInAccount;
            oAuthLinkedIn _oauth = new oAuthLinkedIn();

            _oauth.ConsumerKey    = Helper.AppSettings.LinkedinApiKey;
            _oauth.ConsumerSecret = Helper.AppSettings.LinkedinSecretKey;
            _oauth.Token          = _LinkedInAccount.OAuthToken;
            string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json";

            if (string.IsNullOrEmpty(ImageUrl))
            {
                json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment);
            }
            else
            {
                json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, ImageUrl);
            }

            if (!string.IsNullOrEmpty(json))
            {
                apiHitsCount++;
                schmessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated;
                schmessage.url    = json;
                dbr.Update <ScheduledMessage>(schmessage);
                return("posted");
            }
            else
            {
                apiHitsCount = MaxapiHitsCount;
                json         = "Message not posted";
                return(json);
            }
        }
        public static string PostLinkedInMessage(string ImageUrl, long userid, string comment, string ProfileId, string imagepath, Domain.Socioboard.Enum.MediaType mediaType, string profileName, Helper.Cache _redisCache, Helper.AppSettings _appSettings, Model.DatabaseRepository dbr)
        {
            try
            {
                if (!ImageUrl.Contains("https://") && !ImageUrl.Contains("http://") && !string.IsNullOrEmpty(ImageUrl))
                {
                    var    client   = new ImgurClient("5f1ad42ec5988b7", "f3294c8632ef8de6bfcbc46b37a23d18479159c5");
                    var    endpoint = new ImageEndpoint(client);
                    IImage image;
                    using (var fs = new FileStream(imagepath, FileMode.Open))
                    {
                        image = endpoint.UploadImageStreamAsync(fs).GetAwaiter().GetResult();
                    }

                    var    img  = image.Link;
                    string json = "";
                    Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedInAccount(ProfileId, _redisCache, dbr);
                    oAuthLinkedIn _oauth = new oAuthLinkedIn();
                    _oauth.ConsumerKey    = _appSettings.LinkedinApiKey;
                    _oauth.ConsumerSecret = _appSettings.LinkedinSecretKey;
                    _oauth.Token          = _LinkedInAccount.OAuthToken;
                    string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json";
                    if (string.IsNullOrEmpty(ImageUrl))
                    {
                        json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment);
                    }
                    else
                    {
                        json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, img);
                    }

                    if (!string.IsNullOrEmpty(json))
                    {
                        ScheduledMessage scheduledMessage = new ScheduledMessage();
                        scheduledMessage.createTime        = DateTime.UtcNow;
                        scheduledMessage.picUrl            = _LinkedInAccount.ProfileImageUrl;
                        scheduledMessage.profileId         = ProfileId;
                        scheduledMessage.profileType       = Domain.Socioboard.Enum.SocialProfileType.LinkedIn;
                        scheduledMessage.scheduleTime      = DateTime.UtcNow;
                        scheduledMessage.shareMessage      = comment;
                        scheduledMessage.userId            = userid;
                        scheduledMessage.status            = Domain.Socioboard.Enum.ScheduleStatus.Compleated;
                        scheduledMessage.url               = ImageUrl;
                        scheduledMessage.mediaType         = mediaType;
                        scheduledMessage.socialprofileName = _LinkedInAccount.LinkedinUserName;
                        dbr.Add <ScheduledMessage>(scheduledMessage);

                        return("posted");
                    }
                    else
                    {
                        json = "Message not posted";
                        return(json);
                    }
                }
                else
                {
                    string json = "";
                    Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedInAccount(ProfileId, _redisCache, dbr);
                    oAuthLinkedIn _oauth = new oAuthLinkedIn();
                    _oauth.ConsumerKey    = _appSettings.LinkedinApiKey;
                    _oauth.ConsumerSecret = _appSettings.LinkedinSecretKey;
                    _oauth.Token          = _LinkedInAccount.OAuthToken;
                    string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json";
                    if (string.IsNullOrEmpty(ImageUrl))
                    {
                        json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment);
                    }
                    else
                    {
                        var    client   = new ImgurClient("5f1ad42ec5988b7", "f3294c8632ef8de6bfcbc46b37a23d18479159c5");
                        var    endpoint = new ImageEndpoint(client);
                        IImage image;
                        using (var fs = new FileStream(imagepath, FileMode.Open))
                        {
                            image = endpoint.UploadImageStreamAsync(fs).GetAwaiter().GetResult();
                        }

                        var img = image.Link;
                        json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, img);
                    }

                    if (!string.IsNullOrEmpty(json))
                    {
                        ScheduledMessage scheduledMessage = new ScheduledMessage();
                        scheduledMessage.createTime        = DateTime.UtcNow;
                        scheduledMessage.picUrl            = _LinkedInAccount.ProfileImageUrl;
                        scheduledMessage.profileId         = ProfileId;
                        scheduledMessage.profileType       = Domain.Socioboard.Enum.SocialProfileType.LinkedIn;
                        scheduledMessage.scheduleTime      = DateTime.UtcNow;
                        scheduledMessage.shareMessage      = comment;
                        scheduledMessage.userId            = userid;
                        scheduledMessage.status            = Domain.Socioboard.Enum.ScheduleStatus.Compleated;
                        scheduledMessage.url               = ImageUrl;
                        scheduledMessage.mediaType         = mediaType;
                        scheduledMessage.socialprofileName = _LinkedInAccount.LinkedinUserName;
                        dbr.Add <ScheduledMessage>(scheduledMessage);

                        return("posted");
                    }
                    else
                    {
                        json = "Message not posted";
                        return(json);
                    }
                }
            }


            catch (Exception ex)
            {
                return("Message not posted");
            }
        }
Beispiel #7
0
        public IActionResult AddProfileToGroup(string profileId, long groupId, long userId, Domain.Socioboard.Enum.SocialProfileType profileType)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
            List <Domain.Socioboard.Models.Groupprofiles> lstGroupProfiles = GroupProfilesRepository.getGroupProfiles(groupId, _redisCache, dbr);

            if (lstGroupProfiles.Where(t => t.profileId.Equals(profileId)).Count() > 0)
            {
                return(BadRequest("profile already added"));
            }
            else
            {
                Domain.Socioboard.Models.Groups grp = dbr.Find <Domain.Socioboard.Models.Groups>(t => t.id == groupId).FirstOrDefault();
                if (grp == null)
                {
                    return(BadRequest("Invalid groupId"));
                }
                else
                {
                    Domain.Socioboard.Models.Groupprofiles grpProfile = new Domain.Socioboard.Models.Groupprofiles();
                    if (profileType == Domain.Socioboard.Enum.SocialProfileType.Facebook || profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage || profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookPublicPage)
                    {
                        Domain.Socioboard.Models.Facebookaccounts fbAcc = Repositories.FacebookRepository.getFacebookAccount(profileId, _redisCache, dbr);
                        if (fbAcc == null)
                        {
                            return(BadRequest("Invalid profileId"));
                        }
                        if (fbAcc.UserId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = fbAcc.FbUserName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = "http://graph.facebook.com/" + fbAcc.FbUserId + "/picture?type=small";
                        grpProfile.profileType    = profileType;
                    }
                    else if (profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter)
                    {
                        Domain.Socioboard.Models.TwitterAccount twtAcc = Repositories.TwitterRepository.getTwitterAccount(profileId, _redisCache, dbr);
                        if (twtAcc == null)
                        {
                            return(BadRequest("Invalid profileId"));
                        }
                        if (twtAcc.userId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = twtAcc.twitterScreenName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = twtAcc.profileImageUrl;
                        grpProfile.profileType    = Domain.Socioboard.Enum.SocialProfileType.Twitter;
                    }
                    else if (profileType == Domain.Socioboard.Enum.SocialProfileType.GPlus)
                    {
                        Domain.Socioboard.Models.Googleplusaccounts gplusAccount = Repositories.GplusRepository.getGPlusAccount(profileId, _redisCache, dbr);
                        if (gplusAccount == null)
                        {
                            return(BadRequest("Invalid ProfileId"));
                        }
                        if (gplusAccount.UserId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = gplusAccount.GpUserName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = gplusAccount.GpProfileImage;
                    }
                    else if (profileType == Domain.Socioboard.Enum.SocialProfileType.GoogleAnalytics)
                    {
                        Domain.Socioboard.Models.GoogleAnalyticsAccount gplusAccount = Repositories.GplusRepository.getGAAccount(profileId, _redisCache, dbr);
                        if (gplusAccount == null)
                        {
                            return(BadRequest("Invalid ProfileId"));
                        }
                        if (gplusAccount.UserId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = gplusAccount.GaProfileName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = gplusAccount.ProfilePicUrl;
                    }
                    else if (profileType == Domain.Socioboard.Enum.SocialProfileType.Instagram)
                    {
                        Domain.Socioboard.Models.Instagramaccounts _Instagramaccounts = Repositories.InstagramRepository.getInstagramAccount(profileId, _redisCache, dbr);
                        if (_Instagramaccounts == null)
                        {
                            return(BadRequest("Invalid ProfileId"));
                        }
                        if (_Instagramaccounts.UserId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = _Instagramaccounts.InsUserName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = _Instagramaccounts.ProfileUrl;
                    }
                    else if (profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedIn)
                    {
                        Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedInAccount(profileId, _redisCache, dbr);
                        if (_LinkedInAccount == null)
                        {
                            return(BadRequest("Invalid ProfileId"));
                        }
                        if (_LinkedInAccount.UserId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = _LinkedInAccount.LinkedinUserName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = _LinkedInAccount.ProfileImageUrl;
                    }
                    else if (profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage)
                    {
                        Domain.Socioboard.Models.LinkedinCompanyPage _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(profileId, _redisCache, dbr);
                        if (_LinkedInAccount == null)
                        {
                            return(BadRequest("Invalid ProfileId"));
                        }
                        if (_LinkedInAccount.UserId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = _LinkedInAccount.LinkedinPageName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = _LinkedInAccount.LogoUrl;
                    }
                    else if (profileType == Domain.Socioboard.Enum.SocialProfileType.YouTube)
                    {
                        Domain.Socioboard.Models.YoutubeChannel _YoutubeChannel = Repositories.GplusRepository.getYTChannel(profileId, _redisCache, dbr);
                        if (_YoutubeChannel == null)
                        {
                            return(BadRequest("Invalid ProfileId"));
                        }
                        if (_YoutubeChannel.UserId != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = _YoutubeChannel.YtubeChannelName;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = _YoutubeChannel.ChannelpicUrl;
                    }
                    if (profileType == Domain.Socioboard.Enum.SocialProfileType.Pinterest)
                    {
                        Domain.Socioboard.Models.PinterestAccount pinAcc = dbr.Find <Domain.Socioboard.Models.PinterestAccount>(t => t.username.Equals(profileId)).FirstOrDefault();
                        if (pinAcc == null)
                        {
                            return(BadRequest("Invalid profileId"));
                        }
                        if (pinAcc.userid != userId)
                        {
                            return(BadRequest("profile is added by other user"));
                        }
                        grpProfile.profileName    = pinAcc.firstname + " " + pinAcc.lastname;
                        grpProfile.profileOwnerId = userId;
                        grpProfile.profilePic     = pinAcc.profileimgaeurl;
                        grpProfile.profileType    = profileType;
                    }
                    grpProfile.entryDate   = DateTime.UtcNow;
                    grpProfile.groupId     = grp.id;
                    grpProfile.profileId   = profileId;
                    grpProfile.profileType = profileType;
                    dbr.Add <Domain.Socioboard.Models.Groupprofiles>(grpProfile);
                    //codes to clear cache
                    _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);
                    //end codes to clear cache
                    return(Ok("Added Successfully"));
                }
            }
        }
Beispiel #8
0
        public static List <Domain.Socioboard.Models.profilesdetail> getTop3GroupProfiles(long groupId, Helper.Cache _redisCache, Model.DatabaseRepository dbr)
        {
            //try
            //{
            //    List<Domain.Socioboard.Models.Groupprofiles> inMemGroupProfiles = _redisCache.Get<List<Domain.Socioboard.Models.Groupprofiles>>(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);
            //    if (inMemGroupProfiles != null)
            //    {
            //         return inMemGroupProfiles;
            //    }
            //}
            //catch { }
            //Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail();
            List <Domain.Socioboard.Models.profilesdetail> lstprofiledetail = new List <profilesdetail>();
            List <Domain.Socioboard.Models.Groupprofiles>  groupProfiles    = dbr.FindWithRange <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId, 0, 3).ToList();

            // _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId, groupProfiles);
            //  List<Domain.Socioboard.Models.Groupprofiles> groupProfiless = groupProfiles.Take(3).ToList();
            foreach (Domain.Socioboard.Models.Groupprofiles profile in groupProfiles)
            {
                if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.Facebook)
                {
                    Domain.Socioboard.Models.Facebookaccounts fbAcc = Repositories.FacebookRepository.getFacebookAccount(profile.profileId, _redisCache, dbr);

                    Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail();
                    profiledetails.Fbaccount = fbAcc;
                    lstprofiledetail.Add(profiledetails);
                }
                else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage)
                {
                    Domain.Socioboard.Models.Facebookaccounts fbpageAcc      = Repositories.FacebookRepository.getFacebookAccount(profile.profileId, _redisCache, dbr);
                    Domain.Socioboard.Models.profilesdetail   profiledetails = new profilesdetail();
                    profiledetails.Fbaccount = fbpageAcc;
                    lstprofiledetail.Add(profiledetails);
                }
                else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter)
                {
                    Domain.Socioboard.Models.TwitterAccount twtAcc         = Repositories.TwitterRepository.getTwitterAccount(profile.profileId, _redisCache, dbr);
                    Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail();
                    profiledetails.Twtaccount = twtAcc;
                    lstprofiledetail.Add(profiledetails);
                }
                else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.Instagram)
                {
                    Domain.Socioboard.Models.Instagramaccounts insAcc         = Repositories.InstagramRepository.getInstagramAccount(profile.profileId, _redisCache, dbr);
                    Domain.Socioboard.Models.profilesdetail    profiledetails = new profilesdetail();
                    profiledetails.Instaaccount = insAcc;
                    lstprofiledetail.Add(profiledetails);
                }
                else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.GPlus)
                {
                    Domain.Socioboard.Models.Googleplusaccounts gPlusAcc       = Repositories.GplusRepository.getGPlusAccount(profile.profileId, _redisCache, dbr);
                    Domain.Socioboard.Models.profilesdetail     profiledetails = new profilesdetail();
                    profiledetails.Gplusaccount = gPlusAcc;
                    lstprofiledetail.Add(profiledetails);
                }
                else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedIn)
                {
                    Domain.Socioboard.Models.LinkedInAccount linkdAcc       = Repositories.LinkedInAccountRepository.getLinkedInAccount(profile.profileId, _redisCache, dbr);
                    Domain.Socioboard.Models.profilesdetail  profiledetails = new profilesdetail();
                    profiledetails.LinkdInaccount = linkdAcc;
                    lstprofiledetail.Add(profiledetails);
                }
                else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage)
                {
                    Domain.Socioboard.Models.LinkedinCompanyPage LinkedcompanyAcc = Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(profile.profileId, _redisCache, dbr);
                    Domain.Socioboard.Models.profilesdetail      profiledetails   = new profilesdetail();
                    profiledetails.LinkdINcompanyaccount = LinkedcompanyAcc;
                    lstprofiledetail.Add(profiledetails);
                }
                else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.YouTube)
                {
                    Domain.Socioboard.Models.YoutubeChannel YTChnl         = Repositories.GplusRepository.getYTChannel(profile.profileId, _redisCache, dbr);
                    Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail();
                    profiledetails.Ytubeaccount = YTChnl;
                    lstprofiledetail.Add(profiledetails);
                }
                else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.GoogleAnalytics)
                {
                    Domain.Socioboard.Models.GoogleAnalyticsAccount gAAcc          = Repositories.GplusRepository.getGAAccount(profile.profileId, _redisCache, dbr);
                    Domain.Socioboard.Models.profilesdetail         profiledetails = new profilesdetail();
                    profiledetails.GAaccount = gAAcc;
                    lstprofiledetail.Add(profiledetails);
                }
                else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.Pinterest)
                {
                    Domain.Socioboard.Models.PinterestAccount PinAcc         = Repositories.PinterestRepository.getPinterestAccountDetail(profile.profileId, _redisCache, dbr);
                    Domain.Socioboard.Models.profilesdetail   profiledetails = new profilesdetail();
                    profiledetails.Pintrestaccount = PinAcc;
                    lstprofiledetail.Add(profiledetails);
                }

                //lstprofiledetail.Add(profiledetails);
            }

            return(lstprofiledetail);
        }
Beispiel #9
0
        public static List <Domain.Socioboard.Models.profilesdetail> SearchProfileType(long groupId, string Profiletype, Helper.Cache _redisCache, Model.DatabaseRepository dbr)
        {
            try
            {
                List <Domain.Socioboard.Models.Groupprofiles> inMemGroupProfiles = _redisCache.Get <List <Domain.Socioboard.Models.Groupprofiles> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);
                if (inMemGroupProfiles != null)
                {
                    // return inMemGroupProfiles;
                }
            }
            catch { }
            List <Domain.Socioboard.Models.profilesdetail> lstprofiledetail = new List <profilesdetail>();
            {
                if (Profiletype == "Facebook")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> FbProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.Facebook).ToList();
                    foreach (Domain.Socioboard.Models.Groupprofiles profil in FbProfiles)
                    {
                        Domain.Socioboard.Models.Facebookaccounts fbAcc          = Repositories.FacebookRepository.getFacebookAccount(profil.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail   profiledetails = new profilesdetail();
                        profiledetails.Fbaccount = fbAcc;
                        lstprofiledetail.Add(profiledetails);
                    }
                }
                else if (Profiletype == "FacebookPage")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> Fbpage = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage).ToList();
                    foreach (Domain.Socioboard.Models.Groupprofiles page in Fbpage)
                    {
                        Domain.Socioboard.Models.Facebookaccounts fbpageAcc      = Repositories.FacebookRepository.getFacebookAccount(page.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail   profiledetails = new profilesdetail();
                        profiledetails.Fbaccount = fbpageAcc;
                        lstprofiledetail.Add(profiledetails);
                    }
                }
                else if (Profiletype == "twitter")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> TwitterProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter).ToList();
                    foreach (Domain.Socioboard.Models.Groupprofiles Twitter in TwitterProfiles)
                    {
                        Domain.Socioboard.Models.TwitterAccount twtAcc         = Repositories.TwitterRepository.getTwitterAccount(Twitter.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail();
                        profiledetails.Twtaccount = twtAcc;
                        lstprofiledetail.Add(profiledetails);
                    }
                }
                else if (Profiletype == "instagram")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> InstagramProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.Instagram).ToList();
                    foreach (Domain.Socioboard.Models.Groupprofiles Instagram in InstagramProfiles)
                    {
                        Domain.Socioboard.Models.Instagramaccounts insAcc         = Repositories.InstagramRepository.getInstagramAccount(Instagram.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail    profiledetails = new profilesdetail();
                        profiledetails.Instaaccount = insAcc;
                        lstprofiledetail.Add(profiledetails);
                    }
                }
                else if (Profiletype == "googlepluse")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> GPlusProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.GPlus).ToList();
                    foreach (Domain.Socioboard.Models.Groupprofiles GPlus in GPlusProfiles)
                    {
                        Domain.Socioboard.Models.Googleplusaccounts gPlusAcc       = Repositories.GplusRepository.getGPlusAccount(GPlus.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail     profiledetails = new profilesdetail();
                        profiledetails.Gplusaccount = gPlusAcc;
                        lstprofiledetail.Add(profiledetails);
                    }
                }
                else if (Profiletype == "linkedin")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> LinkedInProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedIn).ToList();
                    foreach (Domain.Socioboard.Models.Groupprofiles LinkedIn in LinkedInProfiles)
                    {
                        Domain.Socioboard.Models.LinkedInAccount linkdAcc       = Repositories.LinkedInAccountRepository.getLinkedInAccount(LinkedIn.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail  profiledetails = new profilesdetail();
                        profiledetails.LinkdInaccount = linkdAcc;
                        lstprofiledetail.Add(profiledetails);
                    }
                }
                else if (Profiletype == "linkedincompanypage")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> LinkedInComapanyPageProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage).ToList();

                    foreach (Domain.Socioboard.Models.Groupprofiles LinkedInComapanyPage in LinkedInComapanyPageProfiles)
                    {
                        Domain.Socioboard.Models.LinkedinCompanyPage LinkedcompanyAcc = Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(LinkedInComapanyPage.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail      profiledetails   = new profilesdetail();
                        profiledetails.LinkdINcompanyaccount = LinkedcompanyAcc;
                        lstprofiledetail.Add(profiledetails);
                    }
                }
                else if (Profiletype == "Youtube")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> YouTubeProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.YouTube).ToList();
                    foreach (Domain.Socioboard.Models.Groupprofiles YouTube in YouTubeProfiles)
                    {
                        Domain.Socioboard.Models.YoutubeChannel YTChnl         = Repositories.GplusRepository.getYTChannel(YouTube.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail();
                        profiledetails.Ytubeaccount = YTChnl;
                        lstprofiledetail.Add(profiledetails);
                    }
                }
                else if (Profiletype == "GAnalytics")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> GoogleAnalyticsProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.GoogleAnalytics).ToList();

                    foreach (Domain.Socioboard.Models.Groupprofiles GoogleAnalytics in GoogleAnalyticsProfiles)
                    {
                        Domain.Socioboard.Models.GoogleAnalyticsAccount gAAcc          = Repositories.GplusRepository.getGAAccount(GoogleAnalytics.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail         profiledetails = new profilesdetail();
                        profiledetails.GAaccount = gAAcc;
                        lstprofiledetail.Add(profiledetails);
                    }
                }
                else if (Profiletype == "Pinterest")
                {
                    List <Domain.Socioboard.Models.Groupprofiles> PinterestProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.Pinterest).ToList();
                    foreach (Domain.Socioboard.Models.Groupprofiles Pinterest in PinterestProfiles)
                    {
                        Domain.Socioboard.Models.PinterestAccount PinAcc         = Repositories.PinterestRepository.getPinterestAccountDetail(Pinterest.profileId, _redisCache, dbr);
                        Domain.Socioboard.Models.profilesdetail   profiledetails = new profilesdetail();
                        profiledetails.Pintrestaccount = PinAcc;
                        lstprofiledetail.Add(profiledetails);
                    }
                }

                return(lstprofiledetail);
            }
        }
Beispiel #10
0
 public static void PostLinkedInMessage(Domain.Socioboard.Models.ScheduledMessage schmessage, Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount)
 {
     try
     {
         DatabaseRepository dbr = new DatabaseRepository();
         if (_LinkedInAccount != null && _LinkedInAccount.IsActive)
         {
             string linkedindata = ComposeLinkedInMessage(schmessage.url, schmessage.userId, schmessage.shareMessage, _LinkedInAccount.LinkedinUserId, schmessage.picUrl, _LinkedInAccount, dbr, schmessage);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
     }
 }
Beispiel #11
0
        public static string ComposeLinkedInMessage(string ImageUrl, long userid, string comment, string ProfileId, string imagepath, Domain.Socioboard.Models.LinkedInAccount _objLinkedInAccount, Model.DatabaseRepository dbr, Domain.Socioboard.Models.ScheduledMessage schmessage, Domain.Socioboard.Models.User _user)
        {
            string json = "";
            var    img  = "";

            Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = _objLinkedInAccount;
            oAuthLinkedIn _oauth = new oAuthLinkedIn();

            _oauth.ConsumerKey    = AppSettings.LinkedinApiKey;
            _oauth.ConsumerSecret = AppSettings.LinkedinSecretKey;
            _oauth.Token          = _LinkedInAccount.OAuthToken;
            string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json";

            if (string.IsNullOrEmpty(ImageUrl))
            {
                json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment);
            }
            else
            {
                var    client   = new ImgurClient(AppSettings.imgurclietId, AppSettings.imgurclietSecret);
                var    endpoint = new ImageEndpoint(client);
                IImage image;
                using (var fs = new FileStream(imagepath, FileMode.Open))
                {
                    image = endpoint.UploadImageStreamAsync(fs).GetAwaiter().GetResult();
                }

                var imgs = image.Link;
                json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, imgs);
            }

            if (!string.IsNullOrEmpty(json))
            {
                apiHitsCount++;
                schmessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated;
                schmessage.url    = json;
                dbr.Update <ScheduledMessage>(schmessage);
                Domain.Socioboard.Models.Notifications notify = new Notifications();
                Notifications lstnotifications = dbr.Single <Notifications>(t => t.MsgId == schmessage.id);
                if (lstnotifications == null)
                {
                    notify.MsgId            = schmessage.id;
                    notify.MsgStatus        = "Scheduled";
                    notify.notificationtime = schmessage.localscheduletime;
                    notify.NotificationType = "Schedule Successfully";
                    notify.ReadOrUnread     = "Unread";
                    notify.UserId           = userid;
                    dbr.Add <Notifications>(notify);
                    if (_user.scheduleSuccessUpdates)
                    {
                        string sucResponse = SendMailbySendGrid(AppSettings.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, true, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    }
                    return("posted");
                }
                else
                {
                    if (_user.scheduleSuccessUpdates)
                    {
                        string sucResponse = SendMailbySendGrid(AppSettings.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, true, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    }
                    return("posted");
                }
            }
            else
            {
                apiHitsCount = MaxapiHitsCount;
                json         = "Message not posted";
                Domain.Socioboard.Models.Notifications notify = new Notifications();
                Notifications lstnotifications = dbr.Single <Notifications>(t => t.MsgId == schmessage.id);
                if (lstnotifications == null)
                {
                    notify.MsgId            = schmessage.id;
                    notify.MsgStatus        = "Failed";
                    notify.notificationtime = schmessage.localscheduletime;
                    notify.NotificationType = "Schedule Failed";
                    notify.ReadOrUnread     = "Unread";
                    notify.UserId           = userid;
                    dbr.Add <Notifications>(notify);
                    if (_user.scheduleFailureUpdates)
                    {
                        string falResponse = SendMailbySendGrid(AppSettings.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, false, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    }
                    return(json);
                }
                else
                {
                    if (_user.scheduleFailureUpdates)
                    {
                        string falResponse = SendMailbySendGrid(AppSettings.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, false, AppSettings.sendGridUserName, AppSettings.sendGridPassword);
                    }
                    return(json);
                }
            }
        }
        public static void PostLinkedInMessage(Domain.Socioboard.Models.ScheduledMessage schmessage, Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount)
        {
            try
            {
                DatabaseRepository dbr = new DatabaseRepository();

                if (_LinkedInAccount.SchedulerUpdate.AddHours(1) <= DateTime.UtcNow)
                {
                    if (_LinkedInAccount != null)
                    {
                        if (_LinkedInAccount.IsActive)
                        {
                            if (apiHitsCount < MaxapiHitsCount)
                            {
                                if (schmessage.scheduleTime <= DateTime.UtcNow)
                                {
                                    string linkedindata = ComposeLinkedInMessage(schmessage.url, schmessage.userId, schmessage.shareMessage, _LinkedInAccount.LinkedinUserId, schmessage.picUrl, _LinkedInAccount, dbr, schmessage);
                                    if (!string.IsNullOrEmpty(linkedindata))
                                    {
                                        apiHitsCount++;
                                    }
                                }
                            }
                            else
                            {
                                apiHitsCount = 0;
                            }
                        }
                        else
                        {
                            apiHitsCount = 0;
                        }
                    }
                }
                else
                {
                    apiHitsCount = 0;
                }
            }
            catch (Exception ex)
            {
                apiHitsCount = MaxapiHitsCount;
            }
        }
Beispiel #13
0
        public async Task <ActionResult> ScheduleMessage(string message, string profileId, long userId, string imagePath, string link, string scheduledatetime, IFormFile files)
        {
            var    filename    = "";
            string postmessage = "";
            var    uploads     = _appEnv.WebRootPath + "\\wwwwroot\\upload\\" + profileId;

            if (files != null)
            {
                if (files.Length > 0)
                {
                    var fileName = Microsoft.Net.Http.Headers.ContentDispositionHeaderValue.Parse(files.ContentDisposition).FileName.Trim('"');
                    // await file.s(Path.Combine(uploads, fileName));
                    filename = Microsoft.Net.Http.Headers.ContentDispositionHeaderValue
                               .Parse(files.ContentDisposition)
                               .FileName
                               .Trim('"');
                    //apiimgPath = _appSettings.ApiDomain + "/api/Media/get?id=" + $@"{Domain.Socioboard.Helpers.SBHelper.RandomString(10) + '.' + fileName.Split('.')[1]}";
                    var tempName = Domain.Socioboard.Helpers.SBHelper.RandomString(10) + '.' + fileName.Split('.')[1];
                    filename = _appEnv.WebRootPath + "\\upload" + $@"\{tempName}";

                    uploads = _appSettings.ApiDomain + "/api/Media/get?id=" + $@"{tempName}";

                    // size += file.Length;
                    using (FileStream fs = System.IO.File.Create(filename))
                    {
                        files.CopyTo(fs);
                        fs.Flush();
                    }
                    filename = uploads;
                }
            }
            else if (!string.IsNullOrEmpty(imagePath))
            {
                filename = imagePath;
            }


            string[] updatedmessgae = Regex.Split(message, "<br>");
            foreach (var item in updatedmessgae)
            {
                if (!string.IsNullOrEmpty(item))
                {
                    if (item.Contains("https://") || item.Contains("http://"))
                    {
                        link = item;
                    }
                    if (item.Contains("hhh") || item.Contains("nnn"))
                    {
                        if (item.Contains("hhh"))
                        {
                            postmessage = postmessage + "\n\r" + item.Replace("hhh", "#");
                        }
                    }
                    else
                    {
                        postmessage = postmessage + "\n\r" + item;
                    }
                }
            }
            message = postmessage;

            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);

            string[] lstProfileIds = null;
            if (profileId != null)
            {
                lstProfileIds = profileId.Split(',');
                profileId     = lstProfileIds[0];
            }
            else
            {
                return(Ok("profileId required"));
            }

            string retunMsg = string.Empty;

            foreach (var item in lstProfileIds)
            {
                if (item.StartsWith("fb"))
                {
                    try
                    {
                        string prId = item.Substring(3, item.Length - 3);
                        Domain.Socioboard.Models.Facebookaccounts objFacebookaccounts = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(prId, _redisCache, dbr);
                        Helper.ScheduleMessageHelper.ScheduleMessage(prId, objFacebookaccounts.FbUserName, message, Domain.Socioboard.Enum.SocialProfileType.Facebook, userId, filename, "https://graph.facebook.com/" + prId + "/picture?type=small", scheduledatetime, _appSettings, _redisCache, dbr, _logger);
                    }
                    catch (System.Exception ex)
                    {
                        _logger.LogError(ex.StackTrace);
                        //return Ok("Issue With Facebook schedulers");
                    }
                }
                if (item.StartsWith("page"))
                {
                    try
                    {
                        string prId = item.Substring(5, item.Length - 5);
                        Domain.Socioboard.Models.Facebookaccounts objFacebookaccounts = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(prId, _redisCache, dbr);
                        Helper.ScheduleMessageHelper.ScheduleMessage(prId, objFacebookaccounts.FbUserName, message, Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage, userId, filename, "https://graph.facebook.com/" + prId + "/picture?type=small", scheduledatetime, _appSettings, _redisCache, dbr, _logger);
                    }
                    catch (System.Exception ex)
                    {
                        _logger.LogError(ex.StackTrace);
                        // return Ok("Issue With Facebook Page schedulers");
                    }
                }
                if (item.StartsWith("tw"))
                {
                    try
                    {
                        string prId = item.Substring(3, item.Length - 3);
                        Domain.Socioboard.Models.TwitterAccount objTwitterAccount = Api.Socioboard.Repositories.TwitterRepository.getTwitterAccount(prId, _redisCache, dbr);
                        Helper.ScheduleMessageHelper.ScheduleMessage(prId, objTwitterAccount.twitterScreenName, message, Domain.Socioboard.Enum.SocialProfileType.Twitter, userId, filename, objTwitterAccount.profileImageUrl, scheduledatetime, _appSettings, _redisCache, dbr, _logger);
                    }
                    catch (System.Exception ex)
                    {
                        _logger.LogError(ex.StackTrace);

                        // return Ok("Issue With Twitter schedulers");
                    }
                }
                if (item.StartsWith("lin"))
                {
                    try
                    {
                        string prId = item.Substring(4, item.Length - 4);
                        Domain.Socioboard.Models.LinkedInAccount objLinkedInAccount = Api.Socioboard.Repositories.LinkedInAccountRepository.getLinkedInAccount(prId, _redisCache, dbr);
                        Helper.ScheduleMessageHelper.ScheduleMessage(prId, objLinkedInAccount.LinkedinUserName, message, Domain.Socioboard.Enum.SocialProfileType.LinkedIn, userId, filename, objLinkedInAccount.ProfileImageUrl, scheduledatetime, _appSettings, _redisCache, dbr, _logger);
                    }
                    catch (System.Exception ex)
                    {
                        _logger.LogError(ex.StackTrace);

                        // return Ok("Issue With Linkedin schedulers");
                    }
                }
                if (item.StartsWith("Cmpylinpage"))
                {
                    try
                    {
                        string prId = item.Substring(12, item.Length - 12);
                        Domain.Socioboard.Models.LinkedinCompanyPage objLinkedinCompanyPage = Api.Socioboard.Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(prId, _redisCache, dbr);
                        Helper.ScheduleMessageHelper.ScheduleMessage(prId, objLinkedinCompanyPage.LinkedinPageName, message, Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage, userId, filename, objLinkedinCompanyPage.LogoUrl, scheduledatetime, _appSettings, _redisCache, dbr, _logger);
                    }
                    catch (System.Exception ex)
                    {
                        _logger.LogError(ex.StackTrace);

                        // return Ok("Issue With Linkedin Page schedulers");
                    }
                }
            }
            return(Ok("scheduled"));
        }
Beispiel #14
0
        public IActionResult AddRssUrl(long userId, long groupId, string rssUrl, string profileId)
        {
            try
            {
                XmlDocument xmlDoc = new XmlDocument(); // Create an XML document object
                xmlDoc.Load(rssUrl);
                var abc = xmlDoc.DocumentElement.GetElementsByTagName("item");
                if (abc.Count == 0)
                {
                    return(Ok("This Url Does't  Conatin Rss Feed"));
                }
            }
            catch (Exception ex)
            {
                return(Ok("This Url Does't  Conatin Rss Feed"));
            }

            try
            {
                var dbr         = new DatabaseRepository(_logger, _env);
                var _RssFeedUrl = Repositories.RssFeedRepository.AddRssUrl(profileId, rssUrl, dbr);

                if (_RssFeedUrl != "null")
                {
                    string[] lstProfileIds;
                    if (profileId != null)
                    {
                        lstProfileIds = profileId.Split(',');
                        profileId     = lstProfileIds[0];
                    }
                    else
                    {
                        return(Ok("profileId required"));
                    }

                    foreach (var item in lstProfileIds)
                    {
                        if (item.StartsWith("fb"))
                        {
                            string prId = item.Substring(3, item.Length - 3);
                            Domain.Socioboard.Models.Facebookaccounts objFacebookAccount = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(prId, _redisCache, dbr);
                            string ret = Repositories.RssFeedRepository.AddRssFeed(rssUrl, userId, prId, Domain.Socioboard.Enum.SocialProfileType.Facebook, "http://graph.facebook.com/" + objFacebookAccount.FbUserId + "/picture?type=small", objFacebookAccount.FbUserName, null, dbr, _appSettings);
                        }
                        else if (item.StartsWith("page"))
                        {
                            string prId = item.Substring(5, item.Length - 5);
                            Domain.Socioboard.Models.Facebookaccounts objFacebookAccount = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(prId, _redisCache, dbr);
                            string ret = Repositories.RssFeedRepository.AddRssFeed(rssUrl, userId, prId, Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage, "http://graph.facebook.com/" + objFacebookAccount.FbUserId + "/picture?type=small", objFacebookAccount.FbUserName, null, dbr, _appSettings);
                        }
                        else if (item.StartsWith("tw"))
                        {
                            string prId = item.Substring(3, item.Length - 3);
                            Domain.Socioboard.Models.TwitterAccount objTwitterAccount = Api.Socioboard.Repositories.TwitterRepository.getTwitterAccount(prId, _redisCache, dbr);
                            string ret = Repositories.RssFeedRepository.AddRssFeed(rssUrl, userId, prId, Domain.Socioboard.Enum.SocialProfileType.Twitter, objTwitterAccount.profileImageUrl, objTwitterAccount.twitterName, null, dbr, _appSettings);
                        }
                        else if (item.StartsWith("lin"))
                        {
                            string prId = item.Substring(4);
                            Domain.Socioboard.Models.LinkedInAccount objLinkedInAccount = Api.Socioboard.Repositories.LinkedInAccountRepository.getLinkedInAccount(prId, _redisCache, dbr);
                            string ret = Repositories.RssFeedRepository.AddRssFeed(rssUrl, userId, prId, Domain.Socioboard.Enum.SocialProfileType.LinkedIn, objLinkedInAccount.ProfileImageUrl, objLinkedInAccount.LinkedinUserName, null, dbr, _appSettings);
                        }
                        else if (item.StartsWith("Cmpylinpage"))
                        {
                            string prId = item.Substring(12);
                            Domain.Socioboard.Models.LinkedinCompanyPage objLinkedinCompanyPage = Api.Socioboard.Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(prId, _redisCache, dbr);
                            string ret = Repositories.RssFeedRepository.AddRssFeed(rssUrl, userId, prId, Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage, objLinkedinCompanyPage.LogoUrl, objLinkedinCompanyPage.LinkedinPageName, null, dbr, _appSettings);
                        }
                    }
                    return(Ok("Added Successfully"));
                }
            }
            catch (Exception)
            {
                return(Ok("Can't Add Rss Url"));
            }
            return(Ok("Can't Add Rss Url"));
        }