예제 #1
0
        private void Clubs_Shown(object sender, EventArgs e)
        {
            try
            {
                var cekanje = new Waiting();
                // upali čekanje
                cekanje.Show();
                // prikupi podatke od API
                // endpoint za mečeve
                ClubObjekt klub = api.GetClubObjekt(ClubName);

                Matches mec = api.GetMatches(ClubName);

                cekanje.Close();

                lbl_KlubNazivVrednost.Text = klub.name;
                lbl_NumPlayersValue.Text   = klub.members_count.ToString();

                lbl_FinishedCount.Text = mec.finished.Count.ToString();
                l_InProgress.Text      = mec.in_progress.Count.ToString();
                l_Registration.Text    = mec.registered.Count.ToString();

                FillGridWithData <Finished>(dgvFinished, mec.finished);
                FillGridWithData <InProgress>(dgvInProgress, mec.in_progress);
                FillGridWithData <Registered>(dgv_Registrations, mec.registered);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Desila se greška prilikom prikupljanja podataka o klubu. Provjerite naziv i pokušajte ponovo!" + ex.Message);
                this.Close();
            }
        }
예제 #2
0
        static async Task <Tuple <TResponse, RequestInfo> > DoDelete <TResponse>(
            string relativeUrl,
            object jsonParams,
            OnError errorAction,
            bool showWaiting = true)
        {
            var request = new RequestInfo(relativeUrl)
            {
                ErrorAction = errorAction,
                HttpMethod  = "DELETE",
                JsonData    = jsonParams
            };

            try
            {
                if (showWaiting)
                {
                    await Waiting.Show();
                }

                var result = default(TResponse);
                if (await request.Send())
                {
                    result = await request.ExtractResponse <TResponse>();
                }
                return(Tuple.Create(result, request));
            }
            finally
            {
                if (showWaiting)
                {
                    await Waiting.Hide();
                }
            }
        }
예제 #3
0
        public static void Send(To to, string subject, string body, BaseForm form = null)
        {
            string email       = DB.Execute.GetEmail(Enum.GetName(typeof(To), to).ToLower());
            string username    = DB.Execute.GetEmail("username");
            string password    = DB.Execute.GetEmail("password");
            string displayName = DB.Execute.GetEmail("displayName");
            string host        = DB.Execute.GetEmail("host");
            int    port        = Convert.ToInt32(DB.Execute.GetEmail("port"));
            int    timeout     = 50000;

            Waiting waiting = new Waiting(form);

            waiting.Show();

            SmtpClient client = new SmtpClient {
                Port                  = port,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Host                  = host,
                EnableSsl             = false,
                Credentials           = new NetworkCredential(username, password),
                Timeout               = timeout,
            };
            MailMessage mail = new MailMessage(BaseForm.Student.Email, email)
            {
                Subject    = subject,
                Body       = body,
                IsBodyHtml = false,
            };

            try {
                client.SendCompleted += OnSendCompleted;
                client.SendAsync(mail, waiting);
                //MessageBox.Show(Resources.SentSuccessfully);
                //waiting.Close();
            } catch (Exception x) {
                //waiting.Close();
                MessageBox.Show(Resources.SendingError + "\n" + x.Message);
            }

            //waiting.Dispose();
        }
예제 #4
0
        static async Task <Tuple <TResponse, RequestInfo> > DoPut <TResponse, TEntity, TIdentifier>(
            TEntity entity,
            string relativeUrl,
            string requestData,
            object jsonParams,
            OnError errorAction,
            bool showWaiting) where TEntity : IQueueable <TIdentifier>
        {
            var request = new RequestInfo(relativeUrl)
            {
                ErrorAction = errorAction,
                HttpMethod  = "PUT",
                RequestData = requestData,
                JsonData    = jsonParams
            };

            try
            {
                if (showWaiting)
                {
                    await Waiting.Show();
                }

                var result = default(TResponse);
                if (await request.Send <TEntity, TIdentifier>(entity))
                {
                    result = await request.ExtractResponse <TResponse>();
                }
                return(Tuple.Create(result, request));
            }
            finally
            {
                if (showWaiting)
                {
                    await Waiting.Hide();
                }
            }
        }
예제 #5
0
        private void btnAnalyzeCode_Click(object sender, EventArgs e)
        {
            try
            {
                String LocalFilePath = txtLocalSourceUrl.Text;
                String GitHubUrl     = txtGitSourceUrl.Text;
                String ProjectName   = txtProjectName.Text;

                if (String.IsNullOrEmpty(LocalFilePath) && String.IsNullOrEmpty(GitHubUrl))
                {
                    MessageBox.Show("Please specify either Local File Path or GIT Url");
                }
                else
                {
                    if (!String.IsNullOrEmpty(ProjectName))
                    {
                        Boolean IsOneTime    = chkOneTimeAnalyse.Checked;
                        Boolean IsTimeToTime = chkTimeToTimeAnalyze.Checked;
                        if (IsOneTime || IsTimeToTime)
                        {
                            if (!String.IsNullOrEmpty(LocalFilePath))
                            {
                                if (Directory.Exists(LocalFilePath) && Directory.EnumerateFiles(LocalFilePath).Count() > 0)
                                {
                                    //setup cqr and cqb and update db

                                    _cloneAnalyzer = new CloneAnalyzer(ProjectName);
                                    var TimeInterval = cmbInterval.SelectedValue;
                                    if (IsOneTime)
                                    {
                                        TimeInterval = "";
                                    }
                                    Waiting waitingForm = new Waiting();
                                    waitingForm.Show();
                                    string analyzeId = "";
                                    var    status    = _cloneAnalyzer.ProcessLocalFilePath(LocalFilePath, ProjectName, GitHubUrl, TimeInterval.ToString(), out analyzeId);
                                    waitingForm.Hide();
                                    waitingForm.Dispose();
                                    if (analyzeId != "")
                                    {
                                        Form3 frmJustResult = new Form3(analyzeId);
                                        frmJustResult.Show();
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Specified directory not exist or empty");
                                }
                            }
                            else if (!String.IsNullOrEmpty(GitHubUrl))
                            {
                                //git hub implementation
                                if (GitHubUrl.Contains(".git"))
                                {
                                    //assume that the master branch always as /archive/master.zip
                                    Waiting waitingForm = new Waiting();
                                    waitingForm.Show();
                                    Application.DoEvents();
                                    var       GitHubUrlforMain = GitHubUrl.Replace(".git", "/archive/master.zip");
                                    string    url    = @GitHubUrlforMain;
                                    WebClient client = new WebClient();
                                    //client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
                                    var           workingDirectory = ConfigurationSettings.AppSettings["DefaultSourceLocation"];
                                    CloneAnalyzer ca        = new CloneAnalyzer("");
                                    string        analyzeId = "";
                                    if (ca.CreateBaseLocationForSource())
                                    {
                                        String uniqueProjectRef = Guid.NewGuid().ToString();
                                        if (!Directory.Exists(workingDirectory + "\\GitSources\\" + uniqueProjectRef))
                                        {
                                            Directory.CreateDirectory(workingDirectory + "\\GitSources\\" + uniqueProjectRef);
                                        }

                                        client.DownloadFile(new Uri(url), @workingDirectory + "\\GitSources\\" + uniqueProjectRef + "\\" + uniqueProjectRef + ".zip");
                                        ZipFile.ExtractToDirectory(@workingDirectory + "\\GitSources\\" + uniqueProjectRef + "\\" + uniqueProjectRef + ".zip", @workingDirectory + "\\GitSources\\" + uniqueProjectRef + "\\");
                                        ca = new CloneAnalyzer("");
                                        var TimeInterval = cmbInterval.SelectedValue;
                                        if (IsOneTime)
                                        {
                                            TimeInterval = "";
                                        }
                                        ca.ProcessLocalFilePath(@workingDirectory + "\\GitSources\\" + uniqueProjectRef, ProjectName, GitHubUrl, TimeInterval.ToString(), out analyzeId);
                                    }
                                    waitingForm.Hide();
                                    waitingForm.Dispose();
                                    if (analyzeId != "")
                                    {
                                        Form3 frmJustResult = new Form3(analyzeId);
                                        frmJustResult.Show();
                                    }
                                    txtGitSourceUrl.Text         = "";
                                    txtLocalSourceUrl.Text       = "";
                                    txtProjectName.Text          = "";
                                    chkOneTimeAnalyse.Checked    = false;
                                    chkTimeToTimeAnalyze.Checked = false;
                                    chkOneTimeAnalyse.Enabled    = false;
                                    chkTimeToTimeAnalyze.Enabled = false;
                                }
                                else
                                {
                                    MessageBox.Show("Seems like provided GIT Url is invalid.");
                                }
                            }
                            else
                            {
                                MessageBox.Show("Please specify either Local File Path or GIT Url");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Please specify a analysis method");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please specify a Project Name");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #6
0
        public void ShowRegistrations()
        {
            p_Register.Visible = true;

            string url = ApiEndPoint + "match/" + (isLive ? "live/" : "") + matchId.ToString();

            var cekanje = new Waiting();

            // upali čekanje
            cekanje.Show();

            //var watch = System.Diagnostics.Stopwatch.StartNew();
            Registrations.Registrations mec = API.GetData.getApiData <Registrations.Registrations>(url);

            #region Labele na formi
            l_MatchID.Text = matchId.ToString();

            l_StartTime.Text  = CommonFunctions.FromUnixTime(mec.StartTime);
            l_BoardCount.Text = mec.Boards.ToString();

            l_Description.Text = mec.Description;

            l_Team1.Text = mec.Teams.Team1.Name;
            l_Team2.Text = mec.Teams.Team2.Name;

            l_Autostart.Text = mec.Settings.Autostart ? "Da" : "Ne";


            if (mec.Settings.TimeControl.Contains("/"))
            {
                l_Tempo.Text = (int.Parse(mec.Settings.TimeControl.Split('/')[1]) / 86400).ToString() + "d";
            }
            else
            {
                l_Tempo.Text = (int.Parse(mec.Settings.TimeControl) / 60).ToString() + "m";
            }

            l_MinGames.Text   = mec.Settings.MinRequiredGames.ToString();
            l_MinPlayers.Text = mec.Settings.MinTeamPlayers.ToString();
            l_Type.Text       = mec.Settings.Rules.ToString() == "chess960" ? "960" : "Standard";

            #endregion

            var igraci2 = from b in mec.Teams.Team2.Players
                          //from c in mec.Teams.Team2.Players
                          orderby b.Rating descending
                          select new Registrations.Player()
            {
                Username       = b.Username,
                Rd             = b.Rd,
                Status         = b.Status,
                TimeoutPercent = b.TimeoutPercent,
                Rating         = b.Rating
            };
            var igraci1 = from b in mec.Teams.Team1.Players
                          //from c in mec.Teams.Team2.Players
                          orderby b.Rating descending
                          select new Registrations.Player()
            {
                Username       = b.Username,
                Rd             = b.Rd,
                Status         = b.Status,
                TimeoutPercent = b.TimeoutPercent,
                Rating         = b.Rating
            };

            var tabele = new List <dynamic>();

            if (igraci1.Count() >= igraci2.Count())
            {
                for (int i = 0; i < igraci1.Count(); i++)
                {
                    if (i >= igraci2.Count())
                    {
                        tabele.Add(new
                        {
                            t1_Username       = igraci1.ElementAt(i).Username,
                            t1_Status         = igraci1.ElementAt(i).Status,
                            t1_TimeoutPercent = igraci1.ElementAt(i).TimeoutPercent,
                            t1_Rd             = igraci1.ElementAt(i).Rd,
                            t1_Rating         = igraci1.ElementAt(i).Rating,



                            t2_Rating         = new long(),
                            t2_Rd             = new double(),
                            t2_TimeoutPercent = new double(),
                            t2_Status         = new Registrations.Status(),
                            t2_Username       = "",
                        });
                    }
                    else
                    {
                        tabele.Add(new
                        {
                            t1_Username       = igraci1.ElementAt(i).Username,
                            t1_Status         = igraci1.ElementAt(i).Status,
                            t1_TimeoutPercent = igraci1.ElementAt(i).TimeoutPercent,
                            t1_Rd             = igraci1.ElementAt(i).Rd,
                            t1_Rating         = igraci1.ElementAt(i).Rating,
                            t2_Rating         = igraci2.ElementAt(i).Rating,
                            t2_Rd             = igraci2.ElementAt(i).Rd,
                            t2_TimeoutPercent = igraci2.ElementAt(i).TimeoutPercent,
                            t2_Status         = igraci2.ElementAt(i).Status,
                            t2_Username       = igraci2.ElementAt(i).Username
                        });
                    }
                }
            }
            else
            {
                for (int i = 0; i < igraci2.Count(); i++)
                {
                    if (i >= igraci1.Count())
                    {
                        tabele.Add(new
                        {
                            t1_Username       = "",
                            t1_Status         = new Registrations.Status(),
                            t1_TimeoutPercent = new double(),
                            t1_Rd             = new double(),
                            t1_Rating         = new long(),


                            t2_Rating         = igraci2.ElementAt(i).Rating,
                            t2_Rd             = igraci2.ElementAt(i).Rd,
                            t2_TimeoutPercent = igraci2.ElementAt(i).TimeoutPercent,
                            t2_Status         = igraci2.ElementAt(i).Status,
                            t2_Username       = igraci2.ElementAt(i).Username
                        });
                    }
                    else
                    {
                        tabele.Add(new
                        {
                            t1_Username       = igraci1.ElementAt(i).Username,
                            t1_Status         = igraci1.ElementAt(i).Status,
                            t1_TimeoutPercent = igraci1.ElementAt(i).TimeoutPercent,
                            t1_Rd             = igraci1.ElementAt(i).Rd,
                            t1_Rating         = igraci1.ElementAt(i).Rating,
                            t2_Rating         = igraci2.ElementAt(i).Rating,
                            t2_Rd             = igraci2.ElementAt(i).Rd,
                            t2_TimeoutPercent = igraci2.ElementAt(i).TimeoutPercent,
                            t2_Status         = igraci2.ElementAt(i).Status,
                            t2_Username       = igraci2.ElementAt(i).Username
                        });
                    }
                }
            }

            var source = new BindingSource();
            source.DataSource = mec;
            dgv_Register.Refresh();
            dgv_Register.DataSource = null;
            dgv_Register.DataSource = tabele;

            dgv_Register.Columns[0].HeaderText = mec.Teams.Team1.Name;
            dgv_Register.Columns[1].HeaderText = "Tip korisnika";
            dgv_Register.Columns[2].HeaderText = "TO %";
            dgv_Register.Columns[3].HeaderText = "RD";
            dgv_Register.Columns[4].HeaderText = "Rejting";
            dgv_Register.Columns[5].HeaderText = "Rejting";
            dgv_Register.Columns[6].HeaderText = "RD";
            dgv_Register.Columns[7].HeaderText = "TO %";
            dgv_Register.Columns[8].HeaderText = "Tip korisnika";
            dgv_Register.Columns[9].HeaderText = mec.Teams.Team2.Name;



            for (int i = 0; i < dgv_Register.ColumnCount; i++)
            {
                dgv_Register.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            }


            cekanje.Close();
        }
예제 #7
0
파일: Form1.cs 프로젝트: AkMedIm/AKMED-ST
        //_______________________________

        /** Coding Login Panel  **/

        //________________________________


        private void Connection_Click(object sender, EventArgs e)
        {
            int        i = 0;
            string     Mode;
            SqlCommand cmd = con.CreateCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select * from registration where login='******' and motdepasse='" + PassBox.Text + "' ";
            cmd.ExecuteNonQuery();
            DataTable      dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(dt);
            i = Convert.ToInt32(dt.Rows.Count.ToString());


            foreach (DataRow dr in dt.Rows)
            {
                Mode                  = dr["UserMode"].ToString();
                UserMod.Text          = Mode.ToString();
                utilisateurname.Text  = dr["nom"].ToString();
                utilisateurfname.Text = dr["prenom"].ToString();
            }



            if (i == 0)
            {
                WrongFill.Visible = true;
                // MessageBox.Show("This username password does not match");
            }


            else if (UserMod.Text == "Admin")
            {
                UsersSecurity.Hide();
                Login.Hide();
                LoginBox.Clear();
                PassBox.Clear();
                WelcomePage.BringToFront();
                Header.Show();
                Waiting.Show();
                WaitingTimer.Start();
                WrongFill.Visible = false;
            }
            else
            {
                // button1.Enabled = false;
                // SupprimerCommande.Enabled = false;
                // commander.Enabled = false;
                dataGridView1.Hide();
                UsersSecurity.Show();
                ajoutstock.Enabled     = false;
                Ajouterbutton.Enabled  = false;
                Annulation.Enabled     = false;
                Moduser.Enabled        = false;
                Suppbutton.Enabled     = false;
                DelDealer.Enabled      = false;
                SaveDealer.Enabled     = false;
                SupprimerUnite.Enabled = false;
                AjouterUnite.Enabled   = false;
                Delbutton.Enabled      = false;
                Modbutton.Enabled      = false;
                AjoutButton.Enabled    = false;
                UserAddPanel.Enabled   = false;
                Fournisseurs.Enabled   = false;
                pictureBox5.Visible    = false;


                Login.Hide();
                LoginBox.Clear();
                PassBox.Clear();
                WelcomePage.BringToFront();
                Header.Show();
                Waiting.Show();
                WaitingTimer.Start();
                WrongFill.Visible = false;
            }
        }