private void SendAll(string message, bool isStartUp = false) { tasks.Clear(); int i = 1; foreach (PersonModel person in Persons) { string m = message; if (isStartUp) { Thread.Sleep(1); Random rand = new Random(unchecked ((int)(DateTime.Now.Ticks))); double r = rand.NextDouble(); if (r > 2) { m = "Привет, $name, скучно на работе сидеть. Давай пообщаемся 😈"; } } Thread.Sleep(12); ChatTask t = new ChatTask(); t.type = Chat.Core.TaskEnum.MESSAGE; t.message = m; t.vkId = person.id; t.timeExpared = te.setTime(10); t.personChatId = "person" + i; t.isStopped = false; t.personName = CurrentUser.Value; if (isStartUp) { PersonChat pc = personWindows[t.personChatId]; pc.startUpFraze = m; } string fullname = person.name; string[] words = fullname.Split(new string[] { " " }, StringSplitOptions.None); string name = words[0]; t.message = t.message.Replace("$name", name); t.message = t.message.Replace("$fullname", fullname); tasks.Add(t); i++; } updateTaskList(); }
private void SendAll(string message) { tasks.Clear(); int i = 1; foreach (PersonModel person in Persons) { Thread.Sleep(12); ChatTask t = new ChatTask(); t.type = Chat.Core.TaskEnum.MESSAGE; t.message = message; t.vkId = person.id; t.timeExpared = te.setTime(10); t.personChatId = "person" + i; t.isStopped = false; t.personName = CurrentUser.Value; tasks.Add(t); i++; } updateTaskList(); }