Beispiel #1
0
        public void GroupRequestSendersForBrowseGroupunique(ref GlobusHttpHelper objGlobusHttpHelper, ref FacebookUser fbUser)
        {
            //chkCountinueProcessGroupCamapinScheduler


            

            GlobusHttpHelper HttpHelper = fbUser.globusHttpHelper;
            string CheckStatus = string.Empty;

            int CountRequest=0;
            try
            {
                string UNqgrpurl = string.Empty;
                List<string> lsturll = new List<string>();
                List<string> lsturllKeyword = new List<string>();
                int intProxyPort = 80;
                Regex IdCheck = new Regex("^[0-9]*$");
                if (!string.IsNullOrEmpty(proxyPort) && IdCheck.IsMatch(proxyPort))
                {
                    intProxyPort = int.Parse(proxyPort);
                }
                string PageSrcHome = objGlobusHttpHelper.getHtmlfromUrl(new Uri(FBGlobals.Instance.fbhomeurl));
                string UserIdGrpMsg = string.Empty;

                UserIdGrpMsg = GlobusHttpHelper.Get_UserID(PageSrcHome);

                #region CodeCommented
                //foreach (var Groupurl in LstGroupUrlsGroupRequestManager)
                //try
                //{
                //    if (LstGroupUrlsGroupRequestManager.Count > 0)
                //    {
                //        foreach (string item in LstGroupUrlsGroupRequestManager)
                //        {
                //            try
                //            {
                //                Queue_Messages.Enqueue(item);
                //            }
                //            catch (Exception ex)
                //            {
                //                GlobusLogHelper.log.Error(ex.StackTrace);
                //            }
                //        }
                //    }
                //}
                //catch (Exception ex)
                //{
                //    GlobusLogHelper.log.Error(ex.StackTrace);
                //} 
                #endregion

                while (Queue_Messages.Count > 0)
                {

                    if (GroupRequestManagerNoOfGroupRequest <= CountRequest)
                    {
                        break;
                    }
                    CountRequest = CountRequest + 1;

                    if (Queue_Messages.Count > 0)
                    {
                        UNqgrpurl = Queue_Messages.Dequeue();
                    }
                    else
                    {
                        return;
                    }

                    try
                    {
                        

                        if (TimeCounter >= CheckGroupRequestManagerNoOfGroupsInBatch)
                        {

                            GlobusLogHelper.log.Debug("Pausing the process for : " + CheckGroupRequestManager_InterbalInMinuts + "  : Minutes");
                            GlobusLogHelper.log.Info("Pausing the process for : " + CheckGroupRequestManager_InterbalInMinuts + "  : Minutes");

                            TimeCounter = 0;

                            Thread.Sleep(1 * 1000 * 60 * CheckGroupRequestManager_InterbalInMinuts);
                            GlobusLogHelper.log.Debug("Process Continue ..");
                            GlobusLogHelper.log.Info("Process Continue ..");
                        }


                        TimeCounter = TimeCounter + 1;

                        string grpurl = UNqgrpurl;
                        string strGroupUrl = grpurl;
                        string __user = "";
                        string fb_dtsg = "";
                        string pgSrc_FanPageSearch = objGlobusHttpHelper.getHtmlfromUrl(new Uri(strGroupUrl));
                        __user = GlobusHttpHelper.GetParamValue(pgSrc_FanPageSearch, "user");
                        if (string.IsNullOrEmpty(__user))
                        {
                            __user = GlobusHttpHelper.ParseJson(pgSrc_FanPageSearch, "user");
                        }
                        fb_dtsg = GlobusHttpHelper.GetParamValue(pgSrc_FanPageSearch, "fb_dtsg");
                        if (string.IsNullOrEmpty(fb_dtsg))
                        {
                            fb_dtsg = GlobusHttpHelper.ParseJson(pgSrc_FanPageSearch, "fb_dtsg");
                        }
                        try
                        {
                            string currentstatus1 = string.Empty;
                            string aaaa = string.Empty;
                            string groupType = string.Empty;
                            string Userstatus = string.Empty;
                            string currentstatus = string.Empty;
                            string stradminlink = string.Empty;
                            string findstatus = string.Empty;
                            string findstatus1 = string.Empty;

                            findstatus = HttpHelper.getHtmlfromUrl(new Uri(grpurl));
                            try
                            {
                                if (grpurl.Contains("http"))
                                {
                                    try
                                    {
                                        string[] grpurlArr = Regex.Split(grpurl, "https://");
                                        string urlforFindingGroupType = grpurlArr[1] + "/members";
                                        string memberurl = urlforFindingGroupType.Replace("//", "/");
                                        memberurl = "https://" + memberurl;
                                        findstatus1 = HttpHelper.getHtmlfromUrl(new Uri(memberurl));
                                    }
                                    catch (Exception ex)
                                    {
                                        GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                                    }
                                }
                                else
                                {
                                    try
                                    {
                                        string urlforFindingGroupType = grpurl + "/members";
                                        string memberurl = urlforFindingGroupType.Replace("//", "/");
                                        memberurl = memberurl.Replace("//", "/");
                                        findstatus1 = HttpHelper.getHtmlfromUrl(new Uri(memberurl));
                                    }
                                    catch (Exception ex)
                                    {
                                        GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                            }
                            try
                            {
                                int Counter = 0;
                                string[] grpurlArr1 = Regex.Split(grpurl, "/");
                                foreach (var grpurlArr_item in grpurlArr1)
                                {
                                    Counter++;
                                }
                                CheckStatus = grpurlArr1[Counter - 1];
                                if (string.IsNullOrEmpty(CheckStatus))
                                {
                                    CheckStatus = grpurlArr1[Counter - 2];
                                }
                            }
                            catch (Exception ex)
                            {
                                GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                            }
                            try
                            {
                                string crtstatus = "";
                                if (findstatus.Contains("clearfix groupsJumpBarTop") && !findstatus.Contains("Join this group to see the discussion") ||findstatus.Contains("_42ft _4jy0 _4jy4 _4jy2 selected _51sy"))
                                {
                                    try
                                    {
                                        List<string> GroupType = objGlobusHttpHelper.GetTextDataByTagAndAttributeName(findstatus, "span", "fsm fcg");
                                        try
                                        {
                                            groupType = GroupType[0];
                                        }
                                        catch (Exception ex)
                                        {
                                           // GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                                        }
                                      

                                        if (grpurl.Contains(FBGlobals.Instance.GroupsGroupCampaignManagerGetFaceBookGroupUrl))                                                      //"https://www.facebook.com/groups/"
                                        {
                                            aaaa = grpurl.Replace(FBGlobals.Instance.GroupsGroupCampaignManagerGetFaceBookGroupUrl, string.Empty).Replace("/", string.Empty);      //"https://www.facebook.com/groups/"
                                        }
                                        else
                                        {
                                            aaaa = grpurl.Replace(FBGlobals.Instance.fbhomeurl, string.Empty).Replace("/", string.Empty);                                            //"https://www.facebook.com/"
                                        }
                                        try
                                        {
                                            stradminlink = findstatus.Substring(findstatus.IndexOf("group_id="), (findstatus.IndexOf("\"", findstatus.IndexOf("group_id=")) - findstatus.IndexOf("group_id="))).Replace("group_id=", string.Empty).Replace("\"", string.Empty).Trim();
                                        }
                                        catch (Exception ex)
                                        {
                                            GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                                        }
                                        aaaa = stradminlink;
                                        // string postdataforjoin = "ref=group_jump_header&group_id=" + aaaa + "&fb_dtsg=" + fb_dtsg + "&__user="******"&phstamp=16581657884875010686";

                                        string postdataforjoin = "ref=group_jump_header&group_id=" + aaaa + "&__user="******"&__a=1&__dyn=7n8apij35CFUSt2u5KIGKaExEW9ACxO4pbGAdGm&__req=9&fb_dtsg=" + fb_dtsg + "&__rev=1055839&ttstamp=265816690497512267";
                                        string localstr = FBGlobals.Instance.GroupsGroupCampaignManagerGetFaceBookGroupUrl;                                                                         // "https://www.facebook.com/groups/"
                                        string Responseofjoin = HttpHelper.postFormData(new Uri(FBGlobals.Instance.GroupGroupRequestManagerAjaxGroupsMembership), postdataforjoin, ref localstr);  //"https://www.facebook.com/ajax/groups/membership/r2j.php?__a=1"

                                        crtstatus = "Request Sent";
                                        if (string.IsNullOrEmpty(Responseofjoin))
                                        {
                                            string reff = FBGlobals.Instance.GroupsGroupCampaignManagerGetFaceBookGroupUrl + aaaa;                                                                     //  "https://www.facebook.com/groups/"
                                            string strResponse = HttpHelper.postFormData(new Uri(FBGlobals.Instance.GroupGroupRequestManagerAjaxGroupsMembership), postdataforjoin, ref reff);    //"https://www.facebook.com/ajax/groups/membership/r2j.php?__a=1"

                                        }
                                        if (Responseofjoin.Contains("[\"goURI(") || Responseofjoin.Contains(aaaa) || Responseofjoin.Contains("redirectPageTo") || Responseofjoin.Contains(CheckStatus))
                                        {

                                            GlobusLogHelper.log.Info("Request Sent to URL :" + grpurl + " with :" + fbUser.username);
                                            GlobusLogHelper.log.Debug("Request Sent to URL :" + grpurl + " with :" + fbUser.username);
                                            //   objclsgrpmngr.UpdateGroupDictionaryData(languageselect, grpurl,Username);      
                                            try
                                            {
                                                string CSVHeader = "FbUser" + "," + "GroupURL";
                                                string CSV_Content = fbUser.username + "," + grpurl;

                                                Globussoft.GlobusFileHelper.ExportDataCSVFile(CSVHeader, CSV_Content, ExportLocationGroupRequest);
                                            }
                                            catch (Exception ex)
                                            {
                                                GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                                    }
                                }

                                if (currentstatus1.Contains("Notifications"))
                                {
                                    try
                                    {
                                        List<string> GroupType = objGlobusHttpHelper.GetTextDataByTagAndAttributeName(findstatus1, "span", "fsm fcg");
                                        groupType = GroupType[0];
                                        crtstatus = "Joined";

                                        // objclsgrpmngr.UpdateGroupDictionaryData(languageselect, grpurl);
                                        //if (!skipalreadySent)
                                        {
                                            GlobusLogHelper.log.Debug("Request Already Accepted On The URL : " + grpurl + " With UserName : "******"Request Already Accepted On The URL : " + grpurl + " With UserName : "******"Error : " + ex.StackTrace);
                                    }

                                }
                                if (currentstatus1.Contains("Cancel Request"))
                                {
                                    try
                                    {
                                        List<string> GroupType = objGlobusHttpHelper.GetTextDataByTagAndAttributeName(findstatus, "span", "fsm fcg");
                                        groupType = GroupType[0];
                                        crtstatus = "Request Already Sent";
                                        // objclsgrpmngr.InsertGroupmanager(Username, grpurl, groupType, crtstatus);
                                        // objclsgrpmngr.UpdateGroupDictionaryData(languageselect, grpurl);
                                        // if (!skipalreadySent)
                                        {
                                            GlobusLogHelper.log.Info("Request Already Sent On The URL : " + grpurl + " With UserName : "******"Request Already Sent On The URL : " + grpurl + " With UserName : "******"FbUser" + "," + "GroupURL";
                                                string CSV_Content = fbUser.username + "," + grpurl;

                                                Globussoft.GlobusFileHelper.ExportDataCSVFile(CSVHeader, CSV_Content, ExportLocationGroupRequest);
                                            }
                                            catch (Exception ex)
                                            {
                                                GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                                    }
                                }
                                if (currentstatus1.Contains("Create Group"))
                                {
                                    GlobusLogHelper.log.Info("Request Already Sent On The URL : " + grpurl + " With UserName : "******"Request Already Sent On The URL : " + grpurl + " With UserName : "******"Error : " + ex.StackTrace);
                            }
                        }
                        catch (Exception ex)
                        {
                            GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                        }
                    }
                    catch (Exception ex)
                    {
                        GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                    }
                    try
                    {
                        int delayInSeconds = Utils.GenerateRandom(minDelayGroupRequestManager * 1000, maxDelayGroupRequestManager * 1000);
                        GlobusLogHelper.log.Info("Delaying for " + delayInSeconds / 1000 + " Seconds With UserName : "******"Delaying for " + delayInSeconds / 1000 + " Seconds With UserName : "******"Error : " + ex.StackTrace);
                    }
                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
            }
        }