private void OnReceiveLogMessage(object sender, OnReceivedLogMessageEventArgs e) { logMessage.Add(new LogItem(e.Message)); //coreEngine.SaveLogMessage(e.Message); if (LogListBox.InvokeRequired) { LogListBox.Invoke(new MethodInvoker(delegate() { while (curLogIndex < logMessage.Count) { LogListBox.Items.Add(logMessage[curLogIndex]); //LogListBox.SelectedIndex = LogListBox.Items.Count - 1; curLogIndex++; } //CheckLogLength(); })); } else { while (curLogIndex < logMessage.Count) { LogListBox.Items.Add(logMessage[curLogIndex]); //LogListBox.SelectedIndex = LogListBox.Items.Count - 1; curLogIndex++; } //CheckLogLength(); } }
private void GetTextLog(string text) { if (LogListBox.InvokeRequired) { LogListBox.Invoke(new MethodInvoker(delegate { LogListBox.Items.Add(text); })); } else { LogListBox.Items.Add(text); } SetTextFile(_fileName, text); }
public void Message(string mes) { if (LogListBox.InvokeRequired) { LogListBox.Invoke(new SetMessageDelegate(Message), new object[] { mes }); } else { if (LogListBox.Items.Count > 100) { LogListBox.Items.Clear(); } LogListBox.Items.Add(mes); } }
/// <summary> /// Log /// </summary> /// <param name="mes"></param> private void Message(string mes) { if (LogListBox.InvokeRequired) { LogListBox.Invoke(new UpdateUiDelegate(Message), new object[] { mes }); } else { if (LogListBox.Items.Count > 100) { LogListBox.Items.RemoveAt(0); } LogListBox.Items.Add(mes); LogListBox.SelectedIndex = LogListBox.Items.Count - 1; } }
/// <summary> /// log /// </summary> /// <param name="mes"></param> private void GetMessage(string mes) { if (InvokeRequired) { LogListBox.Invoke(new AsynUpdateUi(GetMessage), new object[] { mes }); } else { if (LogListBox.Items.Count > 100) { LogListBox.Items.Clear(); } LogListBox.Items.Add(mes); LogListBox.SelectedIndex = LogListBox.Items.Count - 1; } }
private void OnReceiveLogWarningMessage(object sender, OnReceivedLogMessageEventArgs e) { logMessage.Add(new LogItem(e.Message, LOG_TYPE.WARNING)); //coreEngine.SaveLogMessage(e.Message); List <LogItem> warningItem = logMessage.FindAll(o => o.logType == LOG_TYPE.WARNING); if (LogListBox.InvokeRequired) { LogListBox.Invoke(new MethodInvoker(delegate() { while (curLogIndex < logMessage.Count) { LogListBox.Items.Add(logMessage[curLogIndex]); curLogIndex++; } })); warningLogListBox.Invoke(new MethodInvoker(delegate() { while (curWarningIndex < warningItem.Count) { warningLogListBox.Items.Add(warningItem[curWarningIndex].logTxt); curWarningIndex++; } })); } else { while (curLogIndex < logMessage.Count) { LogListBox.Items.Add(logMessage[curLogIndex]); curLogIndex++; } while (curWarningIndex < warningItem.Count) { warningLogListBox.Items.Add(warningItem[curWarningIndex].logTxt); curWarningIndex++; } } }
private void OnReceiveLogErrorMessage(object sender, OnReceivedLogMessageEventArgs e) { logMessage.Add(new LogItem(e.Message, LOG_TYPE.ERROR)); //coreEngine.SaveLogMessage(e.Message); List <LogItem> errorItem = logMessage.FindAll(o => o.logType == LOG_TYPE.ERROR); if (LogListBox.InvokeRequired) { LogListBox.Invoke(new MethodInvoker(delegate() { while (curLogIndex < logMessage.Count) { LogListBox.Items.Add(logMessage[curLogIndex]); //LogListBox.SelectedIndex = LogListBox.Items.Count - 1; curLogIndex++; } //CheckLogLength(); })); errorListBox.Invoke(new MethodInvoker(delegate() { while (curErrorIndex < errorItem.Count) { errorListBox.Items.Add(errorItem[curErrorIndex].logTxt); curErrorIndex++; } })); } else { while (curLogIndex < logMessage.Count) { LogListBox.Items.Add(logMessage[curLogIndex]); curLogIndex++; } while (curErrorIndex < errorItem.Count) { errorListBox.Items.Add(errorItem[curErrorIndex].logTxt); curErrorIndex++; } } }
private async void SetLikes(CancellationToken token) { File.Delete(Directory.GetCurrentDirectory() + $"/{_fileName}"); if (LogListBox.InvokeRequired) { LogListBox.Invoke(new MethodInvoker(delegate { LogListBox.Items.Clear(); })); } else { LogListBox.Items.Clear(); } GetTextLog($"Начало"); if (token.IsCancellationRequested) { return; } var resultsList = _usersList.OrderByDescending(u => u.NumberLikes).ToList(); foreach (var instagramUser in resultsList) { if (instagramUser.LikeSet) { GetTextLog($"Пользователю = {instagramUser.UserName} уже был поставлен лайк"); continue; } if (_numberLikesDay >= 200) { GetTextLog("Достигнут лимит лайков на день"); GetTextLog($"Конец"); return; } var userMediaList = await _instagramClient.GetUserMedia(instagramUser.UserName, 1); var instaMediaForInstaUser = userMediaList?.Value; if (instaMediaForInstaUser != null && instaMediaForInstaUser.Any() && instaMediaForInstaUser.Count >= 2) { foreach (var currentMedia in instaMediaForInstaUser.ToList().Take(2)) { var likeMedia = _instagramClient.LikeMedia(currentMedia.InstaIdentifier).Result.Value; if (likeMedia) { GetTextLog($"Запись: https://www.instagram.com/p/{currentMedia.Code} Пользователь = {instagramUser.UserName}"); instagramUser.LikeSet = true; _saveUsersList = false; GetItemListBox(ActiveFollowersUserslistBox, _usersList); Thread.Sleep(_rand.Next(90000, 150000)); } } } else { instagramUser.LikeSet = true; _saveUsersList = false; GetItemListBox(ActiveFollowersUserslistBox, _usersList); GetTextLog($"У пользователя {instagramUser.UserName} нет публикаций"); _numberLikesDay--; } _numberLikesDay++; SetNumberLikesDayLabel(); Thread.Sleep(_rand.Next(5000, 25000)); } GetTextLog($"Конец"); }