예제 #1
0
        private void StartRun(int row)
        {
            //string cookie = "";
            FacebookStatics facebookStatics = new FacebookStatics();

            string[]    arraydataAccount = null;
            YolikerLogs yolikerLogs      = new YolikerLogs()
            {
                dtgrvdata = dtgrvdata,
                row       = row
            };
            Session session = new Session();

            try
            {
START_RUN:
                if (Isstop == true)
                {
                    yolikerLogs.Write("đã dừng chương trình !", YolikerLogs.TypeLog.NORMAL);
                    return;
                }
                string data_ = dtgrvdata.Rows[row].Cells["cldata"].Value.ToString();
                string uid   = GetUID(data_);
                if (!ListFbDie.Contains(uid))
                {
                    if (ListFbLoged.ContainsKey(uid))
                    {
                        facebookStatics.IssCookie    = true;
                        facebookStatics.cookie       = ListFbLoged[uid];
                        facebookStatics.access_token = ListFbTokens[uid];
                    }
                    else
                    {
                        if (typeLogin_ == TypeLogin.COOKIE)
                        {
                            facebookStatics.IssCookie = true;
                            facebookStatics.cookie    = data_;
                        }
                        else
                        {
                            arraydataAccount          = data_.Split('|');
                            facebookStatics.IssCookie = false;
                            facebookStatics.uid       = uid;
                            facebookStatics.pass      = arraydataAccount[1];
                            if (arraydataAccount.Count() >= 3)
                            {
                                facebookStatics.tfa = arraydataAccount[2];
                            }
                        }
                    }
                    if (ListFbTokens.ContainsKey(uid))
                    {
                        //session = new Session();
                        //session.CreateSession();
                        goto strunn;
                    }
                    yolikerLogs.Write("đang login facebook...", YolikerLogs.TypeLog.NORMAL);
                    FacebookLogin login = new FacebookLogin(facebookStatics);
                    FacebookStatics.LoginStatus loginStatus = login.Login();
                    session = login.FacebookSession;
                    if (loginStatus != FacebookStatics.LoginStatus.SUCCESS)
                    {
                        yolikerLogs.Write(ErrorTypeHelper.GetDescriptionFacebookState(loginStatus), YolikerLogs.TypeLog.WARNING);
                        ListFbDie.Add(uid);
                        return;
                    }
                    strunn :;
                    if (!ListFbLoged.ContainsKey(uid))
                    {
                        ListFbLoged.Add(uid, facebookStatics.cookie);
                    }
                    if (!ListFbTokens.ContainsKey(uid))
                    {
                        ListFbTokens.Add(uid, facebookStatics.access_token);
                    }
                    CaptchaStatics.CaptchaService capService = (CaptchaStatics.CaptchaService)Enum.ToObject(typeof(CaptchaStatics.CaptchaService), cbbCapchaType.SelectedIndex);
                    CaptchaStatics captchaStatics            = new CaptchaStatics()
                    {
                        Apikey = txtapikey.Text,
                        Url    = YolikerStatics.LikeCustomUri
                    };
                    YolikerStatics yolikerStatics = new YolikerStatics()
                    {
                        captchaSvName = capService,
                        IdPost        = txtpostid.Text,
                        TypeAction    = GetAction()
                    };
                    Actions actions = new Actions()
                    {
                        statics        = facebookStatics,
                        fbSession      = session,
                        captchaSt      = captchaStatics,
                        yolikerStatics = yolikerStatics,
                        Logs           = yolikerLogs
                    };
                    yolikerLogs.Write("đang login yoliker...", YolikerLogs.TypeLog.NORMAL);
                    YolikerStatics.YolikerState yolikerState = actions.LoginYoliker();
                    if (yolikerState == YolikerStatics.YolikerState.SUCCESS)
                    {
                        yolikerState = actions.StartAction();
                        //session.Dispose();
                        //facebookStatics.dispose();
                        if (yolikerState == YolikerStatics.YolikerState.SUCCESS)
                        {
                            //yolikerLogs.Write("Tăng " + yolikerStatics.TypeAction + " thành công! + " + yolikerStatics.NumLikeDelivered.ToString() + " " + yolikerStatics.TypeAction, YolikerLogs.TypeLog.NORMAL);
                            AppExtension.Writelog("Tăng " + yolikerStatics.TypeAction + " thành công! + " + actions.NumLikeDelivered.ToString() + " " + yolikerStatics.TypeAction, txtlog, row);
                            totalLikeRec_   += actions.NumLikeDelivered;
                            lbtotallike.Text = totalLikeRec_.ToString();
                            if (chkautostop.Checked)
                            {
                                if (totalLikeRec_ >= Convert.ToInt32(numLike.Value))
                                {
                                    AppExtension.Writelog("Thread " + row.ToString() + " đã đủ số like theo yêu cầu !!! " + numLike.Value.ToString() + " LIKE", txtlog, row);
                                    yolikerLogs.Write("đã đủ số like --> tự động dừng tool !", YolikerLogs.TypeLog.NORMAL);
                                    Isstop = true;
                                    AppExtension.isstop = true;
                                    _isrun = false;
                                }
                            }
                            new Thread(() =>
                            {
                                checkapi();
                            }).Start();
                        }
                    }
                    else
                    {
                        yolikerLogs.Write(ErrorTypeHelper.GetDescriptionYolikerState(yolikerState), YolikerLogs.TypeLog.WARNING);
                    }
                    for (int i = 1; i < 16; i++)
                    {
                        if (Isstop == true)
                        {
                            yolikerLogs.Write("đã dừng chương trình !", YolikerLogs.TypeLog.NORMAL);
                            return;
                        }
                        yolikerLogs.Write("đang nghỉ " + i.ToString() + " phút / 16 phút", YolikerLogs.TypeLog.NORMAL);
                        Thread.Sleep(TimeSpan.FromMinutes(1));
                    }
                    goto START_RUN;
                }
                {
                    yolikerLogs.Write("fb này đã die !", YolikerLogs.TypeLog.WARNING);
                    return;
                }
            }
            catch (Exception ex)
            {
                File.AppendAllText("ErrorLog.txt", ex.ToString() + "\r\n");
            }
            finally
            {
                session.Dispose();
                facebookStatics.dispose();
                AppExtension.Writelog("Thread " + row.ToString() + " đã xong !!! ", txtlog, row);
            }
        }
예제 #2
0
 public static string GetDescriptionYolikerState(YolikerStatics.YolikerState yolikerState)
 {
     return(YolikerErrorList[yolikerState]);
 }