示例#1
0
        private void buttonCreateECHNotices_Click(object sender, EventArgs e)
        {
            if (checkBoxTestOnly.Checked)
            {
                // Moses Newman 11/9/2014 if test mode add test email address(s) to Email table.
                IACDataSetTableAdapters.EmailTableAdapter EmailTableAdapter = new IACDataSetTableAdapters.EmailTableAdapter();
                EmailTableAdapter.UpdateTestEmail(textBoxTestEmail.Text.TrimStart().TrimEnd());
                EmailTableAdapter.Dispose();
                EmailTableAdapter = null;
            }
            ldDueDate       = (DateTime)nullableDateTimePicker1.Value;
            lbSMS           = false;
            lsMergeFileName = (String)listBoxMergeFileName.Items[listBoxMergeFileName.SelectedIndex];
            if (comboBoxDayDue.Text.TrimEnd() == "")
            {
                lnDayDue = 0;
            }
            else
            {
                lnDayDue = Convert.ToInt32(comboBoxDayDue.Text);
            }
            MDIIAC2013 MDImain = (MDIIAC2013)MdiParent;

            lfrm   = new QueryProgress();
            worker = new BackgroundWorker();
            worker.WorkerReportsProgress = true;
            worker.DoWork             += new DoWorkEventHandler(worker_DoMailMerge);
            worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
            worker.ProgressChanged    += new ProgressChangedEventHandler(worker_ProgressChanged);
            worker.RunWorkerAsync();
            lfrm.Text             = "EFT Email Notices";
            lfrm.lblProgress.Text = "Creating EFT Email Notices";
            lfrm.ShowDialog();
            Clipboard.Clear();
        }
示例#2
0
        private void button2_Click(object sender, EventArgs e)
        {
            lnDayDue  = Convert.ToInt32(comboBoxDayDue.Text);
            ldDueDate = (DateTime)nullableDateTimePicker1.Value;
            lbSMS     = true;
            if (comboBoxDayDue.Text.TrimEnd() == "")
            {
                lnDayDue = 0;
            }
            else
            {
                lnDayDue = Convert.ToInt32(comboBoxDayDue.Text);
            }
            MDIIAC2013 MDImain = (MDIIAC2013)MdiParent;

            lfrm   = new QueryProgress();
            worker = new BackgroundWorker();
            worker.WorkerReportsProgress = true;
            worker.DoWork             += new DoWorkEventHandler(worker_DoMailMerge);
            worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
            worker.ProgressChanged    += new ProgressChangedEventHandler(worker_ProgressChanged);
            worker.RunWorkerAsync();
            lfrm.Text             = "EFT SMS Notices";
            lfrm.lblProgress.Text = "Creating SMS Notices";
            lfrm.ShowDialog();
        }
        } // read only var.

        public ServerQueryHandler(
            List <Server> servers,
            QueryProgress progressCallback,
            Action finishCallback)
        {
            serversToQuery    = servers;
            _finishCallback   = finishCallback;
            _progressCallback = progressCallback;

            _thread = new Thread(new ThreadStart(Run));
            _thread.IsBackground = true; // don't let this thread stop the app closing!
            _thread.Start();
        }
示例#4
0
        private Track QueryProgressToTrack(QueryProgress prog)
        {
            var track = new Track
            {
                TrackName          = prog.Song.Title,
                AlbumName          = prog.Song.Album,
                ArtistName         = prog.Song.Artist,
                Duration           = prog.Progress.TotalTime,
                WhenStartedPlaying = DateTime.Now.Subtract(prog.Progress.ElapsedTime),
            };

            return(track);
        }
示例#5
0
        private void buttonPost_Click(object sender, EventArgs e)
        {
            MDIIAC2013 MDImain = (MDIIAC2013)MdiParent;

            lfrm   = new QueryProgress();
            worker = new BackgroundWorker();
            worker.WorkerReportsProgress = true;
            worker.DoWork             += new DoWorkEventHandler(worker_PostAddOns);
            worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
            worker.ProgressChanged    += new ProgressChangedEventHandler(worker_ProgressChanged);
            worker.RunWorkerAsync();
            lfrm.Text             = "Open Dealer AddOn Posting";
            lfrm.lblProgress.Text = "Posting Open Dealer AddOns";
            lfrm.ShowDialog();
        }
示例#6
0
        public void ProgressUpdateReciever(QueryProgress progress)
        {
            if (!IsEnabled || !_scrobbler.BaseScrobbler.HasSession)
            {
                return;
            }

            try
            {
                if (progress.Progress.Percent < PercentNowPlaying && !_doneNowPlaying)
                {
                    _doneScrobble = false;
                    Log.O("LastFM, Now Playing: {0} - {1}", progress.Song.Artist, progress.Song.Title);
                    _currentSong = progress.Song;
                    _scrobbler.NowPlaying(QueryProgressToTrack(progress));
                    _doneNowPlaying = true;
                }

                //A track should only be scrobbled when the following conditions have been met:
                //The track must be longer than 30 seconds.
                //And the track has been played for at least half its duration,
                //or for 4 minutes (whichever occurs earlier).
                //See http://www.last.fm/api/scrobbling
                //This is enforced by LPFM so might as well enforce it here to avoid issues
                if (progress.Progress.TotalTime.TotalSeconds >= MinTrackLength &&
                    (progress.Progress.ElapsedTime.TotalSeconds >= SecondsBeforeScrobble || progress.Progress.Percent > PercentBeforeScrobble) &&
                    !_doneScrobble)
                {
                    _doneNowPlaying = false;
                    Log.O("LastFM, Scrobbling: {0} - {1}", progress.Song.Artist, progress.Song.Title);
                    _scrobbler.Scrobble(QueryProgressToTrack(progress));
                    _doneScrobble = true;
                }

                if (_scrobbler.QueuedCount > 0)
                {
                    ProcessScrobbles();
                }
            }
            catch (Exception ex)
            {
                Log.O("Last.FM Error!: " + ex.ToString());
            }
        }
示例#7
0
 public void ProgressUpdateReciever(QueryProgress progress)
 {
 }
        } // read only var.

        public ServerQueryHandler(
            List<Server> servers,
            QueryProgress progressCallback,
            Action finishCallback)
        {
            serversToQuery = servers;
            _finishCallback = finishCallback;
            _progressCallback = progressCallback;

            _thread = new Thread(new ThreadStart(Run));
            _thread.IsBackground = true; // don't let this thread stop the app closing!
            _thread.Start();
        }
示例#9
0
        /// <summary>
        /// Builds a WebRequest object and queries the server for a response.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <param name="progressChanged">A progress changed event handler receiving
        /// upload progress information.</param>
        /// <param name="fields">The POST fields to upload along with the request.</param>
        /// <returns>An XmlReader containing the response.</returns>
        private XmlDocument QueryServer(string action, QueryProgress progressChanged = null,
                                        params PostDataField[] fields)
        {
            PostDataBuilder builder = new PostDataBuilder();

            builder.AddPart(new PostDataField("action", action));
            builder.AddParts(fields);

            WebRequest reportRequest = HttpWebRequest.Create(BlackBoxServer);

            reportRequest.ContentType = builder.ContentType;
            reportRequest.Method      = "POST";
            reportRequest.Timeout     = int.MaxValue;
            using (Stream formStream = builder.Stream)
            {
                reportRequest.ContentLength = formStream.Length;
                using (Stream requestStream = reportRequest.GetRequestStream())
                {
                    int    lastRead = 0;
                    byte[] buffer   = new byte[32768];
                    while ((lastRead = formStream.Read(buffer, 0, buffer.Length)) != 0)
                    {
                        requestStream.Write(buffer, 0, lastRead);
                        if (progressChanged != null)
                        {
                            progressChanged(formStream.Position, formStream.Length);
                        }
                    }
                }
            }

            try
            {
                HttpWebResponse response = reportRequest.GetResponse() as HttpWebResponse;
                using (Stream responseStream = response.GetResponseStream())
                {
                    XmlReader   reader = XmlReader.Create(responseStream);
                    XmlDocument result = new XmlDocument();
                    result.Load(reader);
                    return(result);
                }
            }
            catch (XmlException)
            {
                return(null);
            }
            catch (WebException e)
            {
                if (e.Response == null)
                {
                    throw;
                }

                using (Stream responseStream = e.Response.GetResponseStream())
                {
                    try
                    {
                        XmlReader reader = XmlReader.Create(responseStream);
                        reader.ReadToFollowing("error");
                        throw new InvalidDataException(string.Format(CultureInfo.CurrentCulture,
                                                                     "The server encountered a problem while processing the request: {0}",
                                                                     reader.ReadString()));
                    }
                    catch (XmlException)
                    {
                    }
                }

                throw new InvalidDataException(((HttpWebResponse)e.Response).StatusDescription);
            }
        }