Exemplo n.º 1
0
        public static async Task <PersonTask> Create(string num, string strJson, Log log)
        {
            try
            {
                PersonTask ptask = new PersonTask();
                ptask.Number  = num;
                ptask.log     = log;
                ptask.Scripts = new List <Script>();
                JObject        json        = JObject.Parse(strJson);
                IList <JToken> jsonScripts = json["arr"].Children().ToList();
                foreach (var jsonScript in jsonScripts)
                {
                    Script script = await Script.Create(num, jsonScript, log);

                    ptask.Scripts.Add(script);
                }
                log.ScriptsCount = jsonScripts.Count();
                return(ptask);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
                return(null);
            }
        }
Exemplo n.º 2
0
        public static async Task <Spammer> LoadFromFile(string filename, string numsfilename, Log log)
        {
            try
            {
                string[]          numbers = System.IO.File.ReadAllLines(numsfilename);
                string            str     = System.IO.File.ReadAllText(filename);
                List <PersonTask> ptasks  = new List <PersonTask>();
                for (int i = 0; i < numbers.Count(); i++)
                {
                    log.Wrt("Creating task for " + numbers[i]);
                    PersonTask ptask = await PersonTask.Create(numbers[i], str, log);

                    ptasks.Add(ptask);
                }
                return(new Spammer()
                {
                    pertasks = ptasks, log = log
                });
            }catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Spammer LoadFromFile 0 error" + ex.Message);
                return(null);
            }
        }