예제 #1
0
        public void PostDataPage(Shareathon item, string pageid)
        {
            FacebookAccount facebookpage    = sharegrprepo.getFbAccount(Guid.Parse(pageid));
            FacebookAccount facebookAccount = sharegrprepo.getFbAccount(item.Facebookaccountid);

            string feeds = FacebookHelper.getFacebookRecentPost(facebookpage.AccessToken, facebookpage.FbUserId);


            string feedId = string.Empty;

            try
            {
                if (!string.IsNullOrEmpty(feeds) && !feeds.Equals("[]"))
                {
                    JObject fbpageNotes = JObject.Parse(feeds);
                    foreach (JObject obj in JArray.Parse(fbpageNotes["data"].ToString()))
                    {
                        try
                        {
                            string feedid = obj["id"].ToString();
                            feedid = feedid.Split('_')[1];
                            FacebookHelper.ShareFeed(facebookAccount.AccessToken, feedid, facebookpage.FbUserId, "", facebookAccount.FbUserId, "", item.Timeintervalminutes);
                        }
                        catch { }
                        Thread.Sleep(1000 * 60 * item.Timeintervalminutes);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
예제 #2
0
        public IHttpActionResult EditShareathon(ShareathonViewModel sharethon)
        {
            Shareathon      eidtShareathon  = sharepo.getShareathon(sharethon.Id);
            FacebookAccount facebookAccount = sharepo.getFbAccount(sharethon.Facebookaccountid);

            eidtShareathon.Facebookaccountid = facebookAccount.Id;
            string id = "";

            for (int i = 0; i < sharethon.FacebookPageId.Length; i++)
            {
                string dataid = sharethon.FacebookPageId[i];
                id = dataid + "," + id;
            }
            eidtShareathon.Facebookpageid      = id.TrimEnd(',');
            eidtShareathon.Timeintervalminutes = sharethon.Timeintervalminutes;

            if (sharepo.updateShareathon(eidtShareathon))
            {
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
예제 #3
0
        public IHttpActionResult AddShareathon(ShareathonViewModel shareathon)
        {
            Shareathon _shreathon = new Shareathon();
            string     id         = "";

            for (int i = 0; i < shareathon.FacebookPageId.Length; i++)
            {
                string dataid = shareathon.FacebookPageId[i];
                id = dataid + "," + id;
            }
            _shreathon.Facebookpageid      = id.TrimEnd(',');
            _shreathon.Facebookaccountid   = shareathon.Facebookaccountid;
            _shreathon.Timeintervalminutes = shareathon.Timeintervalminutes;
            _shreathon.Id     = Guid.NewGuid();
            _shreathon.Userid = shareathon.Userid;
            if (!sharepo.IsShareathonExist(shareathon.Userid, shareathon.Facebookaccountid, _shreathon.Facebookpageid))
            {
                if (sharepo.AddShareathon(_shreathon))
                {
                    return(Ok());
                }
                else
                {
                    return(BadRequest());
                }
            }
            else
            {
                return(BadRequest("Shareathon exist"));
            }
        }
예제 #4
0
        public void PostDataPage(Shareathon item, string pageid)
        {
            Domain.Socioboard.Domain.FacebookAccount facebookpage    = sharepo.getFacebookAccountDetailsByUserProfileId(pageid, item.Userid);
            Domain.Socioboard.Domain.FacebookAccount facebookAccount = sharepo.getFacebookAccountDetailsByUserProfileId(item.Facebookaccountid, item.Userid);

            if (facebookpage != null)
            {
                string feeds = FacebookHelper.getFacebookRecentPost(facebookAccount.AccessToken, facebookpage.FbUserId);



                string feedId = string.Empty;
                try
                {
                    if (!string.IsNullOrEmpty(feeds) && !feeds.Equals("[]"))
                    {
                        JObject fbpageNotes = JObject.Parse(feeds);
                        foreach (JObject obj in JArray.Parse(fbpageNotes["data"].ToString()))
                        {
                            try
                            {
                                string feedid = obj["id"].ToString();
                                feedid = feedid.Split('_')[1];
                                if (sharepo.IsShareathonExistById(item.Id))
                                {
                                    string ret = FacebookHelper.ShareFeed(facebookAccount.AccessToken, feedid, facebookpage.FbUserId, "", facebookAccount.FbUserId, facebookpage.FbUserName);
                                    if (ret == "success")
                                    {
                                        Thread.Sleep(1000 * 60 * item.Timeintervalminutes);
                                    }
                                    else if (ret == "Error validating access token")
                                    {
                                        facebookAccount.IsActive = 2;
                                        facebookrepo.updateFacebookUserStatus(facebookAccount);
                                    }
                                }
                            }
                            catch { }
                        }
                    }
                    else
                    {
                        if (!feeds.Contains("The remote server returned an error: (400) Bad Request."))
                        {
                            facebookpage.IsActive = 2;
                            facebookrepo.updateFacebookUserStatus(facebookpage);
                        }
                        else
                        {
                            facebookpage.IsActive = 2;
                            facebookrepo.updateFacebookUserStatus(facebookAccount);
                            sharepo.UpadteShareathonByFacebookUserId(facebookAccount.FbUserId, facebookAccount.UserId);
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
예제 #5
0
        public bool AddShareathon(Shareathon shareathon)
        {
            bool IsSuccess = false;

            //Creates a database connection and opens up a session
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                //After Session creation, start Transaction.
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    //Proceed action, to Save data.
                    try
                    {
                        session.Save(shareathon);
                        transaction.Commit();
                        IsSuccess = true;
                        return(IsSuccess);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        return(IsSuccess);
                    }
                } //End Transaction
            }     //End Session
        }
예제 #6
0
        public async Task <ActionResult> Edit(string Id)
        {
            User   objuser     = (User)Session["User"];
            string accesstoken = string.Empty;

            if (Session["access_token"] != null)
            {
                accesstoken = Session["access_token"].ToString();
            }
            List <KeyValuePair <string, string> > param = new List <KeyValuePair <string, string> >();
            List <FacebookAccount> lst = new List <FacebookAccount>();

            Shareathon sharethons = null;
            string     nameId     = "";

            Api.FacebookAccount.FacebookAccount ApiobjFacebookAccount = new Api.FacebookAccount.FacebookAccount();
            HttpResponseMessage response = await WebApiReq.GetReq("api/ApiShareathon/GetShareaton?Id=" + Id, "Bearer", accesstoken);

            if (response.IsSuccessStatusCode)
            {
                sharethons = await response.Content.ReadAsAsync <Domain.Socioboard.Domain.Shareathon>();

                nameId = sharethons.Facebookpageid;
                //foreach (var item in nameId)
                //{

                //    List<FacebookAccount> facebookaccount = (List<FacebookAccount>)(new JavaScriptSerializer().Deserialize(ApiobjFacebookAccount.GetFacebookAccountDetailsById(item), typeof(List<FacebookAccount>)));
                //    lst.Add(facebookaccount[0]);
                //}
            }
            List <FacebookAccount> lstFacebookAccount = new List <FacebookAccount>();
            List <FacebookAccount> facebookaccounts   = (List <FacebookAccount>)(new JavaScriptSerializer().Deserialize(ApiobjFacebookAccount.getAllFacebookAccountsOfUser(objuser.Id.ToString()), typeof(List <FacebookAccount>)));
            List <FacebookAccount> lstpage            = facebookaccounts.Where(t => t.Type == "Page").ToList();
            List <FacebookAccount> lstaccount         = facebookaccounts.Where(t => t.Type == "account").ToList();

            ViewBag.UserId     = objuser.Id;
            ViewBag.FbAccounts = lstaccount.Where(t => t.FbUserId != "").ToList();
            foreach (FacebookAccount item in lstpage)
            {
                if (item != null)
                {
                    lstFacebookAccount.Add(item);
                }
            }
            if (lstFacebookAccount.Count > 0)
            {
                ViewBag.FbPages    = lstFacebookAccount;
                Session["FbPages"] = ViewBag.FbPages;
            }
            else
            {
                ViewBag.FbPages = null;
            }
            ViewBag.pageid = nameId;
            return(View(sharethons));
        }
예제 #7
0
        public IHttpActionResult GetShareaton(string Id)
        {
            Guid id = Guid.Empty;

            try
            {
                id = Guid.Parse(Id);
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
            if (id == Guid.Empty)
            {
                return(BadRequest());
            }
            else
            {
                Shareathon sharegrp = sharepo.getShareathon(id);
                return(Ok(sharegrp));
            }
        }