public static List <InteractFacebookView> GetInteracts() { List <InteractFacebookView> interacts = new List <InteractFacebookView>(); InteractFacebookView interact1 = new InteractFacebookView() { ShopId = 3333, Status = ProcessStatusConstant.WAITING, Action = ActionConstant.ADDFRIEND, Detail = GetCustomers(), Schedule = DateTime.Now.Date, TimeDelay = 3000, }; InteractFacebookView interact2 = new InteractFacebookView() { ShopId = 3333, Status = ProcessStatusConstant.WAITING, Action = ActionConstant.SENDMESSAGE, Content = "Hello", Image = @"C:\Users\Nitrogen\Pictures\Screenshots\Screenshot (1).png", Detail = GetCustomers(), Schedule = DateTime.Now.Date, TimeDelay = 3000 }; InteractFacebookView interact3 = new InteractFacebookView() { ShopId = 3333, Status = ProcessStatusConstant.WAITING, Action = ActionConstant.COMMENT, Content = "Hello", Image = @"C:\Users\Nitrogen\Pictures\Screenshots\Screenshot (1).png", Detail = GetCustomers(), Schedule = DateTime.Now.Date, TimeDelay = 3000, CountPost = 2, Type = TypeConstant.PROFILE }; InteractFacebookView interact4 = new InteractFacebookView() { ShopId = 3333, Status = ProcessStatusConstant.WAITING, Action = ActionConstant.COMMENT, Content = "Hello", Image = @"C:\Users\Nitrogen\Pictures\Screenshots\Screenshot (1).png", Detail = GetPages(), Schedule = DateTime.Now.Date, TimeDelay = 3000, CountPost = 2, Type = TypeConstant.PROFILE }; interacts.Add(interact1); interacts.Add(interact2); //interacts.Add(interact3); interacts.Add(interact4); return(interacts); }
public Task SendMessages(InteractFacebookView interact, string username) { return(Task.Run(() => { if (interact == null || interact.Action != ActionConstant.SENDMESSAGE || interact.Status == ProcessStatusConstant.FINISH || interact.Status == ProcessStatusConstant.STOP || interact.Schedule.Date != DateTime.Now.Date) { return; } interact.Status = ProcessStatusConstant.PROCESSING; string userProfilePath = $@"{UrlConstant.ProfileChromePath}\{username}"; ChromeSelenium chrome = new ChromeSelenium(userProfilePath, VarConstant.IsShowBrowser); bool isFinish = true; foreach (var cus in interact.Detail) { if (cus.Status == (int)ActionConstant.Status.Waiting || cus.Status == (int)ActionConstant.Status.Fail) { cus.Status = chrome.SendMessageFb(cus.Uid, interact.Content, interact.Image); } if (cus.Status == (int)ActionConstant.Status.Fail) { isFinish = false; } Thread.Sleep(interact.TimeDelay); } if (isFinish) { interact.Status = ProcessStatusConstant.FINISH; } chrome.Quit(); })); }