コード例 #1
0
        private LogItem SuccessEvent(UploadEvent e)
        {
            switch (e.UploadType)
            {
            case UploadEvent.Type.Tournament:
                return(new LogItem(e.Tournament.SanctionNumber + " " + e.Tournament.Name + " lähetetty."));

            case UploadEvent.Type.DeleteTournament:
                return(new LogItem(e.Tournament.SanctionNumber + " " + e.Tournament.Name + " poistettu."));

            case UploadEvent.Type.ResetTournament:
                return(new LogItem(e.Tournament.SanctionNumber + " " + e.Tournament.Name + " resetoitu."));

            case UploadEvent.Type.Teams:
                return(new LogItem(e.Tournament.SanctionNumber + " " + e.Tournament.Name + " tiimit lähetetty."));

            case UploadEvent.Type.Seatings:
                return(new LogItem(e.Tournament.SanctionNumber + " " + e.Tournament.Name + " seatingit lähetetty."));

            case UploadEvent.Type.Pairings:
                return(new LogItem(e.Tournament.SanctionNumber + " " + e.Tournament.Name + " pairingit " + e.Round + " lähetetty."));

            case UploadEvent.Type.Results:
                return(new LogItem(e.Tournament.SanctionNumber + " " + e.Tournament.Name + " tulokset " + e.Round + " lähetetty."));

            case UploadEvent.Type.Pods:
                return(new LogItem(e.Tournament.SanctionNumber + " " + e.Tournament.Name + " podit lähetetty"));

            case UploadEvent.Type.Round:
                return(new LogItem(e.Tournament.SanctionNumber + " " + e.Tournament.Name + " kierros " + e.Round + " poistettu."));

            default:
                return(new LogItem(""));
            }
        }
コード例 #2
0
        public Uploader()
        {
            InitializeComponent();

            pbUpload.MouseEnter += (s, e) =>
            {
                pbUpload.Image = new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "\\img\\file2.png");
                pbBox.Visible  = false;
            };

            pbUpload.MouseLeave += (s, e) =>
            {
                pbUpload.Image = new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "\\img\\file1.png");
                pbBox.Visible  = true;
            };

            pbUpload.Click += (s, e) =>
            {
                using (var fileDialog = new OpenFileDialog())
                {
                    fileDialog.Filter = "*.xlsx|*.XLSX|*.xls|*.XLS";

                    if (fileDialog.ShowDialog() == DialogResult.OK)
                    {
                        FileName       = fileDialog.FileName;
                        lableName.Text = fileDialog.FileName.Split('\\').Last();

                        UploadEvent?.Invoke(this, null);
                    }
                }
            };
        }
コード例 #3
0
        private void OnUpload(UploadEventArgs args)
        {
            UploadEvent handler = MUpload;

            if (handler != null)
            {
                handler(this, args);
            }
        }
コード例 #4
0
ファイル: EventStudy.cs プロジェクト: tomyqg/MyCShapeStudy
        public void OnUpload(object sender, FileUploadedEventArgs e)
        {
            while (e.Process > 0)
            {
                e.Process--;
                UploadEvent?.Invoke(sender, e);

                Thread.Sleep(100);
            }
        }
コード例 #5
0
        private void Tallenna_Click(object sender, RoutedEventArgs e)
        {
            var tournament = (TrackableTournament)TournamentList.SelectedItem;

            if (tournament.Tracking && tournament.Name != tournament.Tournament.Name)
            {
                UploadEvent ev = new UploadEvent(() => _uploader.UploadName(tournament.Tournament.SanctionNumber, tournament.Name),
                                                 tournament.Tournament.WithName(tournament.Name), UploadEvent.Type.Name, 0);
                UploadQueue.Enqueue(ev);
                tournament.Tournament = tournament.Tournament.WithName(tournament.Name);
            }
        }
コード例 #6
0
        private void panel4_MouseClick(object sender, MouseEventArgs e) //Link
        {
            MultipurposePopup LinkPopUp = new MultipurposePopup("Paste the URL here:", "Link:", true);
            string            s         = "";

            if (LinkPopUp.ShowDialog() == DialogResult.OK)
            {
                s = LinkPopUp.MyText;
                UploadEvent?.Invoke(s, s, null, null, "true", "false", null);
            }
            else
            {
                return;
            }
        }
コード例 #7
0
 /// <summary>
 /// This function reacts to a DragDrop event. It takes the file information from the drag drop event and
 /// launches an UploadEvent for the Controller. It automatically makes Unit, Type, and Comments null.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ResourcePanel_DragDrop(object sender, DragEventArgs e)
 {
     string[] fileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);
     e.Effect = DragDropEffects.Copy;
     if (fileList.Count() > 1)
     {
         throw new Exception("Please drag and drop one file at a time!");
     }
     foreach (string s in fileList)
     {
         byte[] ContentsAsBytes = File.ReadAllBytes(s);
         //Contents.PadRight(Contents.Length + (64 - Contents.Length % 64));
         PadBytes(ContentsAsBytes);
         string Contents = Convert.ToBase64String(ContentsAsBytes); //64 bit encoding works for all file types.
         UploadEvent?.Invoke(Contents, Path.GetFileName(s), null, null, "false", "false", null);
     }
 }
コード例 #8
0
        private void Poista_Click(object sender, RoutedEventArgs e)
        {
            var tournament = (TrackableTournament)TournamentList.SelectedItem;
            var confirm    = MessageBox.Show(
                "Haluatko varmasti poistaa turnauksen " + tournament.Tournament.SanctionNumber + " " + tournament.Name + "?",
                "Oletko varma?",
                MessageBoxButton.YesNo);

            if (confirm == MessageBoxResult.Yes)
            {
                tournament.Tracking           = false;
                tournament.TournamentUploaded = false;
                UploadEvent ev = new UploadEvent(() => _uploader.DeleteTournament(tournament.Tournament.SanctionNumber),
                                                 tournament.Tournament, UploadEvent.Type.DeleteTournament, 0);
                UploadQueue.Enqueue(ev);
            }
        }
コード例 #9
0
        /// <summary>
        /// %BG - 0
        /// %DB - 1
        /// %DP - 2
        /// %_G - 3
        /// %LB - 4
        /// %LP - 5
        /// %_O - 6
        /// %_P - 7
        /// %_R - 8
        /// %_Y - 9
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddClassClick(object sender, EventArgs e)
        {
            MultipurposePopup ClassNamePopUp = new MultipurposePopup("Choose a class name.", "Class:", true);
            var Result = ClassNamePopUp.ShowDialog();

            if (Result == DialogResult.OK)
            {
                string Extension = GetNextColor();
                CurrentClass = ClassNamePopUp.MyText + Extension;
                //DeleteSempahore.Release();
                ResourcePanel.BackgroundImage = System.Drawing.Image.FromFile(GetBackImage(CurrentClass));
                ClassClick?.Invoke(CurrentClass);
                CurrentClassLabel.Text = CurrentClass.Substring(0, CurrentClass.Length - 3);
                AllClasses.Add(CurrentClass);
                ClassesMediator.Controls.Clear();
                UpdateClasses(AllClasses);
                Thread.Sleep(500); //Give ClassClick time to finish.
                UploadEvent?.Invoke("_Placeholder to keep new class on server", "_Class_Foot_In_Door", null, null, "true", "false", null);
            }
        }
コード例 #10
0
        private void panel3_MouseClick(object sender, MouseEventArgs e) //File
        {
            OpenFileDialog Chooser = new OpenFileDialog();

            Chooser.InitialDirectory = "c:\\";
            string s = "";

            if (Chooser.ShowDialog() == DialogResult.OK)
            {
                s = Chooser.FileName;
                byte[] ContentsAsBytes = File.ReadAllBytes(s);
                //Contents.PadRight(Contents.Length + (64 - Contents.Length % 64));
                PadBytes(ContentsAsBytes);
                string Contents = Convert.ToBase64String(ContentsAsBytes); //64 bit encoding works for all file types.
                UploadEvent?.Invoke(Contents, Path.GetFileName(s), null, null, "false", "false", null);
            }
            else
            {
                return;
            }
        }
コード例 #11
0
 protected virtual void OnUploadEvent(EventArgs e) => UploadEvent?.Invoke(this, e);
コード例 #12
0
        public void CheckTournaments()
        {
            AddNewAndActiveTournaments();
            foreach (TrackableTournament t in Tournaments.Where(t => t.Tracking))
            {
                Tournament oldTournament = t.Tournament;
                Tournament newTournament = _reader.getTournament(t.Tournament.TournamentId).WithName(t.Name);
                t.Tournament = newTournament;
                Boolean uploadAll = false;
                if (!t.TournamentUploaded)
                {
                    UploadEvent e = new UploadEvent(() => _uploader.UploadTournament(t), newTournament, UploadEvent.Type.Tournament, 0);
                    UploadQueue.Enqueue(e);
                    t.TournamentUploaded = true;
                    uploadAll            = true;
                }
                if (!oldTournament.Equals(newTournament) || uploadAll)
                {
                    if (!oldTournament.Teams.SequenceEqual(newTournament.Teams) || !newTournament.Teams.IsEmpty && uploadAll)
                    {
                        UploadEvent e = new UploadEvent(() => _uploader.UploadTeams(newTournament.SanctionNumber, newTournament.Teams),
                                                        newTournament, UploadEvent.Type.Teams, 0);
                        UploadQueue.Enqueue(e);
                        uploadAll = true;
                    }
                    if (!oldTournament.Seatings.SequenceEqual(newTournament.Seatings) || !newTournament.Seatings.IsEmpty && uploadAll)
                    {
                        UploadEvent e = new UploadEvent(() => _uploader.UploadSeatings(newTournament.SanctionNumber, newTournament.Seatings),
                                                        newTournament, UploadEvent.Type.Seatings, 0);
                        UploadQueue.Enqueue(e);
                    }
                    if (!oldTournament.Rounds.SequenceEqual(newTournament.Rounds) || !newTournament.Rounds.IsEmpty && uploadAll)
                    {
                        foreach (var round in oldTournament.Rounds.ZipAll(newTournament.Rounds, (r1, r2) => new { OldRound = r1, NewRound = r2 }))
                        {
                            if (round.NewRound == null)
                            {
                                UploadEvent e = new UploadEvent(() => _uploader.DeleteRound(newTournament.SanctionNumber, round.OldRound.Number),
                                                                newTournament, UploadEvent.Type.Round, round.OldRound.Number);
                                UploadQueue.Enqueue(e);
                            }
                            else
                            {
                                if (round.OldRound == null || round.NewRound == null || !round.OldRound.Pairings.SequenceEqual(round.NewRound.Pairings, new Pairing.PairingEqualityComparer()) || round.NewRound != null && uploadAll)
                                {
                                    UploadEvent e = new UploadEvent(() => _uploader.UploadPairings(newTournament.SanctionNumber, round.NewRound.Number, round.NewRound.Playoff, round.NewRound.Pairings),
                                                                    newTournament, UploadEvent.Type.Pairings, round.NewRound.Number);
                                    UploadQueue.Enqueue(e);
                                    uploadAll = true;
                                }
                                if (round.OldRound == null || !round.OldRound.Pairings.Select(p => p.Result).SequenceEqual(round.NewRound.Pairings.Select(p => p.Result)) || round.NewRound != null && uploadAll)
                                {
                                    UploadEvent e = new UploadEvent(() => _uploader.UploadResults(newTournament.SanctionNumber, round.NewRound.Number, round.NewRound.Pairings),
                                                                    newTournament, UploadEvent.Type.Results, round.NewRound.Number);
                                    UploadQueue.Enqueue(e);
                                    uploadAll = true;
                                }
                            }
                        }
                    }
                    if (!oldTournament.Pods.SequenceEqual(newTournament.Pods) || !newTournament.Pods.IsEmpty && uploadAll)
                    {
                        UploadEvent e = new UploadEvent(() => _uploader.UploadPods(newTournament.SanctionNumber, newTournament.Pods),
                                                        newTournament, UploadEvent.Type.Pods, 0);
                        UploadQueue.Enqueue(e);
                    }
                }
            }

            Thread.Sleep(5000);
            new CheckTournamentsDelegate(CheckTournaments).BeginInvoke(null, null);
        }