コード例 #1
0
ファイル: CSV.cs プロジェクト: SmartFire/IntelliSync
 public static List<ActionInfo> Read(string path)
 {
     List<ActionInfo> actions = new List<ActionInfo>();
     if (File.Exists(path))
     {
         using (StreamReader sr = new StreamReader(new FileStream(path, FileMode.Open)))
         {
             while (!sr.EndOfStream)
             {
                 string[] line = sr.ReadLine().Split(';');
                 ActionInfo a = new ActionInfo();
                 a.Path = line[0];
                 a.Info = line[2];
                 a.Action = (line[3].Trim() == "") ? E_ACTION.none : (E_ACTION)Enum.Parse(typeof(E_ACTION), line[3]);
                 a.Changedirection = (line[4].Trim() == "BA");
                 actions.Add(a);
             }
             sr.Close();
         }
     }
     return actions;
 }
コード例 #2
0
ファイル: Status.cs プロジェクト: mauguzun/godlove
        public void PinStart()
        {
            Setup();

            AppendTextBox("start ");
            Thread t = new Thread(() =>
            {
                Parallel.ForEach(Accounts, new ParallelOptions()
                {
                    MaxDegreeOfParallelism = 7
                }, (acc) =>
                {
                    DriverInstance drivers = new DriverInstance();
                    this.startedDriver++;
                    try
                    {
                        AppendTextBox(acc.Email + " try login");
                        if (string.IsNullOrEmpty(acc.Proxie))
                        {
                            drivers.InitDriver(show);
                        }
                        else
                        {
                            drivers.InitDriver(show, acc.Proxie.Replace("_", ":"));
                        }

                        Pinterest pin = new Pinterest(drivers.Driver);


                        pin.MakeLogin(acc.Email, acc.Password);
                        pin.UserName = acc.UserName;
                        if (pin.CheckLogin())
                        {
                            pin.SaveCookie(CookieManager.Filename(acc.Email, acc.Proxie.Replace('_', ':')));
                            if (pin.ValidName() == false)
                            {
                                pin.FillName();
                            }
                            GUI.ActionInfo response = new ActionInfo(false, null);
                            while (true)
                            {
                                switch (this.PinAction)
                                {
                                case PinAction.Follow:
                                    limit    = 7;
                                    response = pin.Follow();
                                    break;


                                case PinAction.Repin:

                                    int d = RepinPinList.Count();;
                                    if (RepinPinList.Count() > succeAcction)
                                    {
                                        response = pin.Repin(RepinPinList[succeAcction], firstTime);
                                    }
                                    else
                                    {
                                        this.Close();
                                    }

                                    firstTime = false;

                                    break;

                                //
                                case PinAction.RepinOther:

                                    pin.Driver.Url      = "https://www.pinterest.com/";
                                    var pinsElement     = pin.Driver.FindElementsByCssSelector("[data-force-refresh]");
                                    List <string> hrefs = new List <string>();

                                    foreach (var item in pinsElement)
                                    {
                                        if (!hrefs.Contains(item.GetAttribute("href")))
                                        {
                                            hrefs.Add(item.GetAttribute("href"));
                                        }
                                    }
                                    foreach (var href in hrefs)
                                    {
                                        response = pin.Repin(href, firstTime);
                                        if (response.Done == false)
                                        {
                                            break;
                                        }
                                        else
                                        {
                                            AppendTextBox(href);
                                        }

                                        firstTime = false;
                                    }
                                    break;



                                case PinAction.FollowSelf:
                                    var newbies = AccountManager.Accounts.Where(x => x.Followers == 0);
                                    foreach (var item in newbies)
                                    {
                                        response = pin.Follow(item.UserName);
                                        if (response.Done == false)
                                        {
                                            drivers.SuperQuit();
                                        }
                                        else
                                        {
                                            AlreadyFollowedMyAccount.Add(item.UserName);
                                            File.AppendAllLines(FOLLOWED, AlreadyFollowedMyAccount);
                                        }
                                        AppendTextBox(" followed  " + item.UserName);
                                    }

                                    break;

                                default:
                                    response = pin.MakePost();
                                    break;
                                }
                                if (this.pinAction == PinAction.Follow && response.Done == true)
                                {
                                    int?before          = acc.Follow;
                                    DriverInstance temp = new DriverInstance();
                                    temp.InitDriver(false);
                                    acc = CheckOneAccount(acc, temp);
                                    temp.SuperQuit();

                                    if (before == acc.Follow)
                                    {
                                        AppendTextBox("not work " + this.PinAction + acc.Email);
                                        drivers.SuperQuit();
                                        this.stopedDriver++;
                                        break;
                                    }
                                }
                                else if (this.pinAction == PinAction.Pin && response.Done == true)
                                {
                                    File.AppendAllText(PINNED, response.Info + Environment.NewLine);
                                }

                                if (attemp.Keys.Contains(acc.Email))
                                {
                                    if (attemp[acc.Email] > limit)
                                    {
                                        AppendTextBox(this.PinAction + "= limit =" + acc.Email);
                                        drivers.SuperQuit();
                                    }
                                    attemp[acc.Email]++;
                                }
                                else
                                {
                                    attemp[acc.Email] = 0;
                                }



                                succeAcction++;
                                AppendTextBox(this.PinAction + " - " + response.Done + " - " + response.Info);
                                acc.Status = this.PinAction + DateTime.Now.ToString();

                                //if(response.Done == false)
                                //{
                                //    break;
                                //}
                            }
                        }
                        else
                        {
                            AppendTextBox(pin.Error + ":" + acc.Email);
                            drivers.SuperQuit();
                            this.stopedDriver++;
                        }
                        this.SetInfo();
                    }

                    catch (Exception ex)
                    {
                        DeleteProxie(acc.Proxie);
                        acc.Proxie = null;
                        AppendTextBox("delete proxy " + acc.Proxie.Replace("_", ":"));
                    }
                    finally
                    {
                        drivers.SuperQuit();
                    }
                });
            });

            t.Start();
        }