Beispiel #1
0
        private void worker_ready(object sender, RunWorkerCompletedEventArgs e)
        {
            if (progress.Value == progress.Maximum)
            {
                progress.Invoke(new MethodInvoker(reset_process));
                Dictionary<int, string> sd_index_url = new Dictionary<int, string>();
                Dictionary<int, string> sd_index_name = new Dictionary<int, string>();
                Dictionary<int, bool> sd_index_male = new Dictionary<int, bool>();
                List<int> l_indexes = new List<int>();

                foreach (people p in storage.warehouse)
                {
                    if (p.name != null)
                    {
                        sd_index_url.Add(p.index, p.url);
                        sd_index_name.Add(p.index, p.name);
                        sd_index_male.Add(p.index, p.male);
                        l_indexes.Add(p.index);
                    }
                }
                progress_max = l_indexes.Count;
                progress.Invoke(new MethodInvoker(set_progress_max));
                l_indexes.Sort();
                int[] indexes = l_indexes.ToArray();
                int index;
                List<people> tmp = new List<people>();
                for (int k = 0; k < progress_max; k++)
                {
                    progress.BeginInvoke(new MethodInvoker(increase_progress));
                    index = indexes[k];
                    people tmp_people = new people();
                    tmp_people.index = k + 1;
                    sd_index_male.TryGetValue(index, out tmp_people.male);
                    sd_index_name.TryGetValue(index, out tmp_people.name);
                    sd_index_url.TryGetValue(index, out tmp_people.url);
                    tmp.Add(tmp_people);
                }
                string head1 = "<html> <head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />  <title>Your Friends</title>";
                string head2 = "</head>\n";
                string body1 = "<body><table border = \"1\"";
                body1 += @"<tr><td><h2>Number of Friends</h2></td> <td><h2>Picture</h2></td> <td><h2>Name</h2></td> </tr>";
                progress_max = progress_max + tmp.Count;
                progress.Invoke(new MethodInvoker(set_progress_max));
                string items = "";
                string id;
                foreach (people s in tmp)
                {
                    if (s.male)
                        id = "m";
                    else
                        id = "f";
                    items += Environment.NewLine + "<tr class=\""+id+"\">";
                    items += "<td> " + s.index + " </td>\t";
                    items += "<td><a href=\"https://graph.facebook.com/" + s.url + "/picture?type=large\"title=\"" + s.name + "\" class=\"preview\"><img src=\"https://graph.facebook.com/" + s.url + "/picture\" alt=\"" + s.name + "'s profile picture\"/></a></td>";
                    items += "\t\t<td><a id=\"" + id + "\" href=https://www.facebook.com/" + s.url + ">" + s.name + "</a></td>";
                    progress.BeginInvoke(new MethodInvoker(increase_progress));
                }
                string body2 = "</tr> </table>";
                body2 += copyright();
                body2 += "</body></html>";
                string path = System.IO.Path.GetTempPath() + "\\file.html";
                System.IO.File.WriteAllText(path, head1 + Environment.NewLine + js() + Environment.NewLine + css() + Environment.NewLine + head2 + Environment.NewLine + body1 + Environment.NewLine + items + Environment.NewLine + body2);
                Process.Start(path);
            }
        }
Beispiel #2
0
 private void getfbpage(string url, out people person)
 {
     person = new people();
     try
     {
         WebClient web = new WebClient();
         person.url = url;
         url = "https://graph.facebook.com/" + url;
         string httpfile = web.DownloadString(url);
         int i_name = httpfile.IndexOf("name") + 7;
         string s_name = httpfile.Remove(0, i_name);
         i_name = s_name.IndexOf(",") - 1;
         person.name = s_name.Remove(i_name);
         person.name = person.name.Replace("\\u00fc", "&uuml;"); //ü
         person.name = person.name.Replace("\\u00f6", "&ouml;"); // ö
         person.name = person.name.Replace("\\u00e4", "&auml;"); // ä
         person.name = person.name.Replace("\\u00f6", "&Üuml;"); // Ü
         person.name = person.name.Replace("\u00d6", "&Ouml;"); // Ö
         person.name = person.name.Replace("\\u00c4", "&Auml;"); // Ä
         person.name = person.name.Replace("\\u00df", "&szlig;"); // ß
         int g_index = httpfile.IndexOf("gender") + 5;
         httpfile = httpfile.Remove(0, g_index);
         httpfile = httpfile.Remove(10);
         if (!httpfile.Contains("f"))
             person.male = true;
         else
             person.male = false;
     }
     catch (Exception)
     { }
 }