Ejemplo n.º 1
0
 // This event handler deals with the results of the background operation.
 private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     resultForm.richTextBoxResult.AppendText(StatisticsAndReport.GetReport());
     resultForm.ShowDialog();
     resultForm.richTextBoxResult.Clear();
 }
Ejemplo n.º 2
0
        // This event handler is where the time-consuming work is done.
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            Logger.LogMethod();

            BackgroundWorker            worker = sender as BackgroundWorker;
            Dictionary <string, string> args   = e.Argument as Dictionary <string, string>;

            vkInv.Login    = args["login"];
            vkInv.Password = args["password"];
            string countryId  = args["countryId"];
            string citiesList = args["citiesList"];
            string groupId    = args["groupId"];
            string eventId    = args["eventId"];

            _bwStatus = "Logon";
            worker.ReportProgress(0);
            vkInv.Logon();

            _bwStatus = "Get cities list";
            worker.ReportProgress(0);
            List <string> listCitiesId = VkCityEx.GetListOfCityIdByNames(countryId, citiesList, worker);

            if ((listCitiesId == null) || (listCitiesId.Count == 0))
            {
                throw new ArgumentNullException();
            }

            StatisticsAndReport.CityNames = citiesList;

            _bwStatus = "Get all users in the cities";
            worker.ReportProgress(0);
            List <VkUser> usersInTheCity = new List <VkUser>();

            foreach (string cityId in listCitiesId)
            {
                usersInTheCity.AddRange(vkInv.GetAllUsersInCity(groupId, countryId, cityId, worker));
            }
            if (usersInTheCity.Count == 0)
            {
                throw new ArgumentNullException();
            }
            StatisticsAndReport.UserCountInCity = usersInTheCity.Count;

            _bwStatus = "Get all group member for inventation";
            worker.ReportProgress(0);
            List <VkUser> friends = vkInv.GetFriendsListForInventation(eventId, worker);

            if ((friends == null) || (friends.Count == 0))
            {
                throw new ArgumentNullException();
            }

            usersInTheCity = usersInTheCity.GetHasIdFrom(friends);

            _bwStatus = "Sending invites to users";
            worker.ReportProgress(0);
            vkInv.InviteCycle(eventId, usersInTheCity, worker);
            worker.ReportProgress(100);

            StatisticsAndReport.ParseResultForReport(usersInTheCity);
        }