Exemplo n.º 1
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();
                }
            }
        }
Exemplo n.º 2
0
 private void WaitingTimer_Tick(object sender, EventArgs e)
 {
     compteur++;
     if (compteur >= 5)
     {
         WaitingTimer.Stop();
         Waiting.Hide();
         timer1.Start();
     }
 }
Exemplo n.º 3
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();
                }
            }
        }
Exemplo n.º 4
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);
            }
        }