Example #1
0
 public void ReplaceWithNullFuncThrows()
 {
     var seq = new List<object> { new object(), new object() };
     var dummyValue = new object();
     Assert.Throws<ArgumentNullException>(
         () => seq.Replace(
             dummyValue,
             (Func<object, bool>)null).ToList());
 }
Example #2
0
        public void ScrapeFriendsGroup(ref GlobusHttpHelper HttpHelper, List<string> FriendsProfileIDs, string username)
        {
            try
            {
                string MainUrl = string.Empty;

                FriendsProfileIDs = FriendsProfileIDs.Distinct().ToList();

                foreach (var friendID in FriendsProfileIDs)
                {
                    try
                    {
                        MainUrl = "http://www.linkedin.com/profile/view?id=" + friendID;
                        string pageSourceforGroup = HttpHelper.getHtmlfromUrl1(new Uri(MainUrl));

                        if (pageSourceforGroup.Contains("Your address book is currently unavailable. Please check again later"))
                        {
                            Logger("[ " + DateTime.Now + " ] => [ Your address book is currently unavailable. Please check again later ! ]");
                            Logger("[ " + DateTime.Now + " ] => [ Please Wait for sometimes ! ]");
                            System.Threading.Thread.Sleep(1 * 60 * 1000);

                            pageSourceforGroup = HttpHelper.getHtmlfromUrl1(new Uri(MainUrl));
                        }

                        if (pageSourceforGroup.Contains("You and this LinkedIn user don’t know anyone in common") || pageSourceforGroup.Contains("You and this LinkedIn user don&#8217;t know anyone in common"))
                        {
                            Logger("[ " + DateTime.Now + " ] => [ You and this LinkedIn user don’t know anyone in common With Profile URL >>> " + "http://www.linkedin.com/profile/view?id=" + friendID + " ]");
                            continue;
                        }

                        string[] RgxGroupDataforGroup = System.Text.RegularExpressions.Regex.Split(pageSourceforGroup, "link_groupRegistration");
                        string[] RgxGroupDataName = System.Text.RegularExpressions.Regex.Split(pageSourceforGroup, "fmt__profileUserFullName");

                        #region CodeChabgeBysanjeev
                        string MemberName = string.Empty;
                        try
                        {
                            int startIndex = pageSourceforGroup.IndexOf("<span class=\"full-name\">");
                            string start = pageSourceforGroup.Substring(startIndex).Replace("<span class=\"full-name\">", string.Empty);
                            int endIndex = start.IndexOf("</span>");
                            string end = start.Substring(0, endIndex).Replace("</span>", string.Empty);
                            MemberName = end.Trim();

                            //MemberName = pageSourceforGroup.Substring(pageSourceforGroup.IndexOf("<span class=\"full-name\">"), (pageSourceforGroup.IndexOf("</span>", pageSourceforGroup.IndexOf("fmt__profileUserFullName")) - pageSourceforGroup.IndexOf("<span class=\"full-name\">"))).Replace("<span class=\"full-name\">", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace(":", string.Empty).Trim();
                            //MemberName = MemberName.Replace(" ", "-");
                        }
                        catch { }

                        if (RgxGroupDataforGroup.Count() < 2)
                        {
                            try
                            {
                                pageSourceforGroup = HttpHelper.getHtmlfromUrl1(new Uri("http://www.linkedin.com/profile/mappers?x-a=profile_v2_groups%2Cprofile_v2_follow%2Cprofile_v2_connections&x-p=profile_v2_discovery%2Erecords%3A4%2Ctop_card%2EprofileContactsIntegrationStatus%3A0%2Cprofile_v2_comparison_insight%2Edistance%3A1%2Cprofile_v2_right_fixed_discovery%2Eoffset%3A0%2Cprofile_v2_connections%2Edistance%3A1%2Cprofile_v2_right_fixed_discovery%2Erecords%3A4%2Cprofile_v2_network_overview_insight%2Edistance%3A1%2Cprofile_v2_right_top_discovery_teamlinkv2%2Eoffset%3A0%2Cprofile_v2_right_top_discovery_teamlinkv2%2Erecords%3A4%2Cprofile_v2_discovery%2Eoffset%3A0%2Cprofile_v2_summary_upsell%2EsummaryUpsell%3Atrue%2Cprofile_v2_network_overview_insight%2EnumConn%3A1668%2Ctop_card%2Etc%3Atrue&x-oa=bottomAliases&id=" + friendID + "&locale=&snapshotID=&authToken=&authType=name&invAcpt=&notContactable=&primaryAction=&isPublic=false&sfd=true&_=1366115853014"));

                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine("Error >>> " + ex.StackTrace);
                            }
                        }
                        if (pageSourceforGroup.Contains("link_groupRegistration"))
                        {
                            RgxGroupDataforGroup = System.Text.RegularExpressions.Regex.Split(pageSourceforGroup, "link_groupRegistration");
                            RgxGroupDataName = System.Text.RegularExpressions.Regex.Split(pageSourceforGroup, "class=\"full-name\">");

                            foreach (string item in RgxGroupDataforGroup)
                            {
                                string GroupUrl = string.Empty;
                                string GroupNames = string.Empty;
                                string GroupIds = string.Empty;

                                try
                                {
                                    if (!item.Contains("<!DOCTYPE html>") && item.Contains("\"name\":\""))
                                    {
                                        try
                                        {
                                            GroupNames = item.Substring(item.IndexOf("\"name\":\""), (item.IndexOf("\",\"", item.IndexOf("\"name\":\"")) - item.IndexOf("\"name\":\""))).Replace("\"name\":\"", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Trim();

                                        }
                                        catch { }

                                        try
                                        {
                                            //int startindex = item.IndexOf("groups?gid=");
                                            //if (startindex > 0)
                                            //{
                                            //    string start = item.Substring(startindex).Replace("groups?gid=","&");
                                            //    int endindex = start.IndexOf("&");
                                            //    string end = start.Substring(0, endindex);
                                            //    GroupIds = end;

                                            //}
                                            GroupIds = getBetween(item, "groups?gid=", "&");
                                        }
                                        catch { }

                                        if (string.IsNullOrEmpty(GroupIds))
                                        {
                                            try
                                            {
                                                GroupIds = item.Substring(item.IndexOf("groupRegistration?gid="), (item.IndexOf("&", item.IndexOf("groupRegistration?gid=")) - item.IndexOf("groupRegistration?gid="))).Replace("groupRegistration?gid=", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace("&amp", "").Trim();

                                            }
                                            catch { }
                                        }

                                        if (string.IsNullOrEmpty(GroupIds))
                                        {
                                            try
                                            {
                                                //GroupIds = item.Substring(item.IndexOf("groupRegistration?gid="), (item.IndexOf("&", item.IndexOf("groupRegistration?gid=")) - item.IndexOf("groupRegistration?gid="))).Replace("groupRegistration?gid=", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace("&amp", "").Trim();
                                                int startIndex = item.IndexOf("groupRegistration?gid=");
                                                string start = item.Substring(startIndex);
                                                int endIndex = start.IndexOf("&");
                                                string end = start.Substring(0, endIndex).Replace("&", string.Empty);
                                                GroupIds = end.Trim();
                                            }
                                            catch { }
                                        }

                                        GroupUrl = "http://www.linkedin.com/groups?gid=" + GroupIds;

                                        try
                                        {
                                            #region Data Saved In CSV File

                                            if (!string.IsNullOrEmpty(GroupNames))
                                            {
                                                try
                                                {
                                                    string CSVHeader = "GroupUrl" + "," + "GroupName" + "," + "FriendName" + "," + "SearchByID";
                                                    string CSV_Content = GroupUrl.Replace(",", ";") + "," + GroupNames.Replace(",", ";") + "," + MemberName.Replace(",", ";") + "," + username;
                                                    CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_LinkedinFriendsGroupScraper);
                                                    Logger("[ " + DateTime.Now + " ] => [ GroupUrl: " + GroupUrl + " ]");
                                                    Logger("[ " + DateTime.Now + " ] => [ GroupName: " + GroupNames + " ]");
                                                    Logger("[ " + DateTime.Now + " ] => [ FriendName: " + MemberName +" ]");
                                                    Logger("[ " + DateTime.Now + " ] => [ SearchByID: " + username + " ]");
                                                    Logger("[ " + DateTime.Now + " ] => [ Data Saved In CSV File ! ]");

                                                }
                                                catch { }

                                            }
                                            #endregion
                                        }
                                        catch { }
                                    }
                                }
                                catch { }
                            }
                        }
                        else
                        {
                            RgxGroupDataforGroup = System.Text.RegularExpressions.Regex.Split(pageSourceforGroup, "link_media");
                            RgxGroupDataName = System.Text.RegularExpressions.Regex.Split(pageSourceforGroup, "class=\"full-name\">");

                            foreach (string item in RgxGroupDataforGroup)
                            {
                                string GroupUrl = string.Empty;
                                string GroupNames = string.Empty;
                                string GroupIds = string.Empty;

                                try
                                {
                                    if (!item.Contains("<!DOCTYPE html>") && item.Contains("\"name\":\""))
                                    {
                                        try
                                        {
                                            //GroupNames = item.Substring(item.IndexOf("\"name\":\""), (item.IndexOf("\",\"", item.IndexOf("\"name\":\"")) - item.IndexOf("\"name\":\""))).Replace("\"name\":\"", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Trim();
                                            int startindex = item.IndexOf("\"name\"");
                                            string start = item.Substring(startindex).Replace("\"name\"",string.Empty).Replace(":", string.Empty);
                                            int endindex = start.IndexOf(",");
                                            string end = start.Substring(0, endindex).Replace("\"",string.Empty);
                                            GroupNames = end.Trim();
                                        }
                                        catch { }

                                        try
                                        {
                                                int startindex1 = item.IndexOf("\"groupID\"");
                                                string start = item.Substring(startindex1).Replace("\"groupID\"",string.Empty).Replace(":", string.Empty);
                                                int endindex = start.IndexOf(",");
                                                string end = start.Substring(0, endindex);
                                                GroupIds = end.Trim();

                                        }
                                        catch { }

                                        if (string.IsNullOrEmpty(GroupIds))
                                        {
                                            try
                                            {
                                                GroupIds = item.Substring(item.IndexOf("groupRegistration?gid="), (item.IndexOf("&", item.IndexOf("groupRegistration?gid=")) - item.IndexOf("groupRegistration?gid="))).Replace("groupRegistration?gid=", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Replace("&amp", "").Trim();

                                            }
                                            catch { }
                                        }

                                        GroupUrl = "http://www.linkedin.com/groups?gid=" + GroupIds;

                                        try
                                        {
                                            #region Data Saved In CSV File

                                            if (!string.IsNullOrEmpty(GroupNames))
                                            {
                                                try
                                                {
                                                    string CSVHeader = "GroupUrl" + "," + "GroupName" + "," + "FriendName" + "," + "SearchByID";
                                                    string CSV_Content = GroupUrl.Replace(",", ";") + "," + GroupNames.Replace(",", ";") + "," + MemberName.Replace(",", ";") + "," + username;
                                                    CSVUtilities.ExportDataCSVFile(CSVHeader, CSV_Content, Globals.path_LinkedinFriendsGroupScraper);
                                                    Logger("[ " + DateTime.Now + " ] => [ GroupUrl: " + GroupUrl.Replace(",", ";") + " ]");
                                                    Logger("[ " + DateTime.Now + " ] => [ GroupName: " + GroupNames.Replace(",", ";") + " ]");
                                                    Logger("[ " + DateTime.Now + " ] => [ FriendName: " + MemberName.Replace(",", ";") + " ]");
                                                    Logger("[ " + DateTime.Now + " ] => [ SearchByID: " + username + " ]");
                                                    Logger("[ " + DateTime.Now + " ] => [ Data Saved In CSV File ! ]");

                                                }
                                                catch { }

                                            }
                                            #endregion
                                        }
                                        catch { }
                                    }
                                }
                                catch { }
                            }
                        }
                        #endregion
                    }
                    catch { }
                }

            }
            catch (Exception ex)
            {

            }
        }
        public void setTowerChallengeInfo(TowerChallengeInfo tci, GetTowerInfoMessage msg)
        {
            TowerLevel[] tls = msg.getSortedLevels();

            foreach (TowerLevel tl in tls)
            {
                if (this.triallist.ContainsKey(tl.id.ToString()))
                {
                    trialding td = this.triallist[tl.id.ToString()];
                    Console.WriteLine("### found trial " + tl.name + " " + tl.description);
                    string odesc = tl.description.Replace(" ", "");
                    odesc = odesc.Replace("\r\n", "");
                    odesc = odesc.Replace("\n", "");
                    odesc = odesc.Replace("\r", "");

                    string tdesc = td.odescription.Replace(" ","");
                    tdesc = tdesc.Replace("\r\n", "");
                    tdesc = tdesc.Replace("\r", "");
                    tdesc = tdesc.Replace("\n", "");

                    if (odesc != tdesc) //dont check the title!
                    {
                        Console.WriteLine("### dont match because of " + odesc + " " + tdesc);
                    }

                    string oflav = tl.flavour.Replace(" ", "");
                    oflav = oflav.Replace("\r\n", "");
                    oflav = oflav.Replace("\n", "");
                    oflav = oflav.Replace("\r", "");

                    string tflav = td.oflavour.Replace(" ", "");
                    tflav = tflav.Replace("\r\n", "");
                    tflav = tflav.Replace("\r", "");
                    tflav = tflav.Replace("\n", "");

                    if (oflav != tflav) //dont check the title!
                    {
                        Console.WriteLine("### dont match because of " + oflav + " " + tflav);
                    }

                    string oname = tl.name.Replace(" ", "");
                    oname = oname.Replace("\r\n", "");
                    oname = oname.Replace("\n", "");
                    oname = oname.Replace("\r", "");

                    string tname = td.oname.Replace(" ", "");
                    tname = tname.Replace("\r\n", "");
                    tname = tname.Replace("\r", "");
                    tname = tname.Replace("\n", "");

                    if (oname != tname) //dont check the title!
                    {
                        Console.WriteLine("### dont match because of " + oname + " " + tname);
                    }

                    if (odesc == tdesc && oflav == tflav && oname == tname) //dont check the title!
                    {
                        tl.description = td.description;
                        tl.name = td.name;
                        tl.flavour = td.flavour;
                        tl.title = td.title;
                        
                    }
                }
            }
            tci.setLevels(tls);
        }