Ejemplo n.º 1
0
        private void UploadRepoMenuItemHandler(object sender, EventArgs e)
        {
            var repo    = (GinRepositoryData)((MenuItem)sender).Parent.Tag;
            var fstatus = JsonConvert.DeserializeObject <
                Dictionary <string, GinRepository.FileStatus> >(ServiceClient.GetRepositoryFileInfo(repo.Name));

            var alteredFiles = from kvp in fstatus
                               where kvp.Value == GinRepository.FileStatus.OnDiskModified ||
                               kvp.Value == GinRepository.FileStatus.Unknown
                               select kvp;

            var files = alteredFiles as KeyValuePair <string, GinRepository.FileStatus>[] ?? alteredFiles.ToArray();

            if (!files.Any())
            {
                return; //Nothing to upload here
            }
            var uploadfiledlg = new MetroUploadFilesDlg(files);
            var res           = uploadfiledlg.ShowDialog();

            if (res == DialogResult.Cancel)
            {
                return;
            }

            foreach (var file in files)
            {
                ServiceClient.UploadFile(repo.Name, file.Key);
            }
        }
Ejemplo n.º 2
0
        private void UploadRepoMenuItemHandler(object sender, EventArgs e)
        {
            var repo    = (GinRepositoryData)((MenuItem)sender).Parent.Tag;
            var fstatus = JsonConvert.DeserializeObject <
                Dictionary <string, GinRepository.FileStatus> >(ServiceClient.GetRepositoryFileInfo(repo.Name));

            var alteredFiles = from kvp in fstatus
                               where kvp.Value == GinRepository.FileStatus.OnDiskModified ||
                               kvp.Value == GinRepository.FileStatus.Unknown || kvp.Value == GinRepository.FileStatus.Removed
                               select kvp;

            var files = alteredFiles as KeyValuePair <string, GinRepository.FileStatus>[] ?? alteredFiles.ToArray();

            if (!files.Any())
            {
                ///No new or changed files. Show notification.
                try
                {
                    _trayIcon.ShowBalloonTip(500, "WinGIN", "Nothing to do.", ToolTipIcon.Info);
                }
                catch
                {
                }
                return; //Nothing to upload here
            }

            var    uploadfiledlg = new MetroUploadFilesDlg(files);
            var    res           = uploadfiledlg.ShowDialog();
            string commitMessage = uploadfiledlg.CommitTextBox.Text;

            if (res == DialogResult.Cancel)
            {
                return;
            }
            if (String.IsNullOrEmpty(commitMessage))
            {
                //WCF requires that non-optional arguments be non-empty, so we provide a placeholder value
                ServiceClient.UploadFile(repo.Name, "%EMPTYSTRING%");
            }
            else
            {
                ServiceClient.UploadFileWithMessage(repo.Name, "%EMPTYSTRING%", commitMessage);
            }
        }