Exemplo n.º 1
0
        private static void runAction(Control owner, JiraNamedEntity action, JiraIssueListModel model,
                                      JiraIssue issue, List <JiraField> fields, StatusLabel status, Action onFinish)
        {
            JiraIssue issueWithTime = SmartJiraServerFacade.Instance.getIssue(issue.Server, issue.Key);

            issueWithTime.SecurityLevel = SmartJiraServerFacade.Instance.getSecurityLevel(issue);
            object           rawIssueObject   = SmartJiraServerFacade.Instance.getRawIssueObject(issue);
            List <JiraField> fieldsWithValues = JiraActionFieldType.fillFieldValues(issue, rawIssueObject, fields);

            // PLVS-133 - this should never happen but does?
            if (model == null)
            {
                owner.Invoke(new MethodInvoker(()
                                               =>
                                               PlvsUtils.showError("Issue List Model was null, please report this as a bug",
                                                                   new Exception("IssueActionRunner.runAction()"))));
                model = JiraIssueListModelImpl.Instance;
            }

            if (fieldsWithValues == null || fieldsWithValues.Count == 0)
            {
                runActionWithoutFields(owner, action, model, issue, status, onFinish);
            }
            else
            {
                owner.Invoke(new MethodInvoker(() =>
                                               new IssueWorkflowAction(issue, action, model, fieldsWithValues, status, onFinish).initAndShowDialog()));
            }
        }
        public JiraTextAreaWithWikiPreview()
        {
            IssueType = -1;
            InitializeComponent();

            throbberPath = PlvsUtils.getThroberPath();
        }
Exemplo n.º 3
0
        public ImageInfo getImage(Server server, string url)
        {
            if (url == null)
            {
                return(new ImageInfo(Resources.nothing, null));
            }
            lock (this) {
                if (cache.ContainsKey(url))
                {
                    return(cache[url]);
                }
                try {
                    HttpWebResponse response       = getResponse(server, url);
                    var             responseStream = response.GetResponseStream();

                    byte[] imgbytes = PlvsUtils.getBytesFromStream(responseStream);

                    Image img = Image.FromStream(new MemoryStream(imgbytes));

                    var fileName = iconCacheDir + "\\" + getFileName(url);
                    using (FileStream f = File.Create(fileName)) {
                        f.Write(imgbytes, 0, imgbytes.Length);
                        f.Close();
                    }
                    ImageInfo imageInfo = new ImageInfo(img, new Uri(fileName));
                    cache[url] = imageInfo;
                    return(imageInfo);
                } catch (Exception e) {
                    Debug.WriteLine("ImageCache.getImage() - exception: " + e.Message);
                    cache[url] = new ImageInfo(Resources.nothing, null);
                    return(new ImageInfo(Resources.nothing, null));
                }
            }
        }
Exemplo n.º 4
0
 private void createIssueWorker(JiraIssue issue, bool keepDialogOpen)
 {
     try {
         string key = SmartJiraServerFacade.Instance.createIssue(server, issue);
         this.safeInvoke(new MethodInvoker(delegate {
             setAllEnabled(true);
             buttonCancel.Enabled = true;
             if (!keepDialogOpen)
             {
                 Close();
             }
             else
             {
                 if (keepDialogOpen)
                 {
                     textSummary.Text     = "";
                     textDescription.Text = "";
                 }
             }
             AtlassianPanel.Instance.Jira.findAndOpenIssue(key, delegate {
                 if (keepDialogOpen)
                 {
                     bringDialogToFront();
                 }
             });
         }));
     } catch (Exception e) {
         this.safeInvoke(new MethodInvoker(delegate {
             PlvsUtils.showError("Unable to create issue", e);
             setAllEnabled(true);
             buttonCancel.Enabled = true;
         }));
     }
 }
Exemplo n.º 5
0
        private void startProjectUpdateThread()
        {
            JiraProject project = (JiraProject)comboProjects.SelectedItem;
            Thread      t       = PlvsUtils.createThread(() => projectUpdateWorker(project));

            t.Start();
        }
        private void executeSearchAndClose()
        {
            string query = textQueryString.Text.Trim();

            if (query.Length == 0)
            {
                return;
            }

            if (JiraIssueUtils.ISSUE_REGEX.IsMatch(query.ToUpper()))
            {
                JiraIssue foundIssue = Model.Issues.FirstOrDefault(issue => issue.Key.Equals(query) && issue.Server.Url.Equals(Server.Url));

                if (foundIssue == null)
                {
                    string key = query.ToUpper();
                    fetchAndOpenIssue(key);
                    return;
                }
                IssueDetailsWindow.Instance.openIssue(foundIssue, AtlassianPanel.Instance.Jira.ActiveIssueManager);
            }
            else
            {
                string url = Server.Url + "/secure/QuickSearch.jspa?searchString=" + HttpUtility.UrlEncode(query);
                PlvsUtils.runBrowser(url);
            }
            Close();
        }
Exemplo n.º 7
0
        private void DropZone_DragDrop(object sender, DragEventArgs e)
        {
            if (!e.Data.GetDataPresent(DataFormats.UnicodeText))
            {
                return;
            }

            string txt = (string)e.Data.GetData(DataFormats.UnicodeText);

            Match m = DROP_REGEX.Match(txt);

            if (m == null)
            {
                return;
            }

            Group @key  = m.Groups[1];
            Group @guid = m.Groups[2];

            if (key == null || guid == null)
            {
                return;
            }

            labelInfo.Text = "Updating issue " + key.Value + "...";

            AllowDrop = false;

            bool add = (e.KeyState & 8) == 8 && (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy;

            Thread t = PlvsUtils.createThread(() => dropActionWorker(key.Value, guid.Value, add));

            t.Start();
        }
        private void runGetTestsThread()
        {
            status.setInfo("Retrieving build test results...");
            Thread t = PlvsUtils.createThread(getTestsRunner);

            t.Start();
        }
        public FieldEditor(string title, JiraIssueListModel model, AbstractJiraServerFacade facade, JiraIssue issue, string fieldId, Point location)
        {
            PlvsLogger.log("FieldEditor - ctor");

            this.model   = model;
            this.facade  = facade;
            this.issue   = issue;
            this.fieldId = fieldId;

            InitializeComponent();

            buttonOk.Enabled     = false;
            buttonCancel.Enabled = false;

            StartPosition = FormStartPosition.Manual;
            Location      = location;

            Text = title;

            field = new JiraField(fieldId, null);

            Thread t = PlvsUtils.createThread(fillFieldWrap);

            t.Start();
        }
        private void buttonOk_Click(object sender, EventArgs e)
        {
            setAllEnabled(false);
            setThrobberVisible(true);

            ICollection <JiraField> updatedFields = mergeFieldsFromEditors();
            Thread t = PlvsUtils.createThread(delegate {
                try {
                    SmartJiraServerFacade.Instance.runIssueActionWithParams(
                        issue, action, updatedFields, textComment.Text.Length > 0 ? textComment.Text : null);
                    var newIssue = SmartJiraServerFacade.Instance.getIssue(issue.Server, issue.Key);
                    UsageCollector.Instance.bumpJiraIssuesOpen();
                    status.setInfo("Action \"" + action.Name + "\" successfully run on issue " + issue.Key);
                    this.safeInvoke(new MethodInvoker(delegate {
                        Close();
                        model.updateIssue(newIssue);
                        if (onFinish != null)
                        {
                            onFinish();
                        }
                    }));
                }
                catch (Exception ex) {
                    this.safeInvoke(new MethodInvoker(() => showErrorAndResumeEditing(ex)));
                }
            });

            t.Start();
        }
        private void initializeFields()
        {
            Thread t = PlvsUtils.createThread(initializeThreadWorker);

            t.Start();
            ShowDialog();
        }
        private void runGetLogThread()
        {
            status.setInfo("Retrieving build logs...");
            Thread t = PlvsUtils.createThread(getLogRunner);

            t.Start();
        }
Exemplo n.º 13
0
        private void getPlansWorker()
        {
            fillServerData();
            try {
                ICollection <BambooPlan> plans = facade.getPlanList(server);
                this.safeInvoke(new MethodInvoker(() => fillPlanList(plans)));
            } catch (Exception e) {
                this.safeInvoke(new MethodInvoker(() => PlvsUtils.showError("Unable to retrieve build plans", e)));
            } finally {
                gettingPlans = false;

                this.safeInvoke(new MethodInvoker(delegate {
//                    buttonCancel.Enabled = true;
                    radioUseFavourites.Enabled  = true;
                    radioSelectManually.Enabled = true;
                    name.Enabled              = true;
                    url.Enabled               = true;
                    user.Enabled              = true;
                    password.Enabled          = true;
                    checkEnabled.Enabled      = true;
                    checkShared.Enabled       = true;
                    checkDontUseProxy.Enabled = true;
                    checkIfValid();
                }));
            }
        }
 private static void findFinished(bool success, string message, Exception e)
 {
     if (!success)
     {
         PlvsUtils.showError(message, e);
     }
 }
 public BambooServerTreeNode(BambooServerModel model, BambooServer server, int imageIdx)
     : base(PlvsUtils.getServerNodeName(model, server), imageIdx)
 {
     this.model  = model;
     this.server = server;
     model.DefaultServerChanged += model_DefaultServerChanged;
 }
Exemplo n.º 16
0
        private void loadPastActiveIssuesDetails()
        {
            LinkedList <ActiveIssue> past = new LinkedList <ActiveIssue>(pastActiveIssues);
            Thread t = PlvsUtils.createThread(() => loadPastActiveIssuesDetailsWorker(generation, past));

            t.Start();
        }
        private void webContent_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        {
            if (e.Url.Equals("about:blank"))
            {
                return;
            }
            e.Cancel = true;
            string url = e.Url.ToString();

            if (url.StartsWith(EXCEPTION_LINK_TAG))
            {
                if (callback != null)
                {
                    callback(url.Substring(EXCEPTION_LINK_TAG.Length));
                }
            }
            else
            {
                try {
                    PlvsUtils.runBrowser(url);
                    // ReSharper disable EmptyGeneralCatchClause
                } catch {
                    // ReSharper restore EmptyGeneralCatchClause
                }
            }
        }
Exemplo n.º 18
0
        private void addComment(JiraIssue issue)
        {
            SmartJiraServerFacade facade = SmartJiraServerFacade.Instance;
            NewIssueComment       dlg    = new NewIssueComment(issue, facade);

            dlg.ShowDialog();
            if (dlg.DialogResult != DialogResult.OK)
            {
                return;
            }

            Thread addCommentThread =
                PlvsUtils.createThread(delegate {
                try {
                    jiraStatus.setInfo("Adding comment to issue...");
                    facade.addComment(issue, dlg.CommentBody);
                    issue = facade.getIssue(issue.Server, issue.Key);
                    jiraStatus.setInfo("Comment added");
                    UsageCollector.Instance.bumpJiraIssuesOpen();
                    container.safeInvoke(new MethodInvoker(() => JiraIssueListModelImpl.Instance.updateIssue(issue)));
                } catch (Exception ex) {
                    jiraStatus.setError("Adding comment failed", ex);
                }
            });

            addCommentThread.Start();
        }
        private void runGetBuildDetailsThread()
        {
            status.setInfo("Retrieving build details...");
            Thread t = PlvsUtils.createThread(getBuildDetailsRunner);

            t.Start();
        }
Exemplo n.º 20
0
        public string getRenderedContent(string issueKey, int issueType, int projectId, string markup)
        {
            var url = new StringBuilder(BaseUrl + "/rest/api/1.0/render");

            if (server.OldSkoolAuth)
            {
                url.Append(appendAuthentication(url.ToString()));
            }

            try {
                var req = (HttpWebRequest)WebRequest.Create(url.ToString());
                req.Proxy = server.NoProxy ? null : GlobalSettings.Proxy;

                req.Credentials      = CredentialUtils.getCredentialsForUserAndPassword(url.ToString(), UserName, Password);
                req.Method           = "POST";
                req.Timeout          = GlobalSettings.NetworkTimeout * 1000;
                req.ReadWriteTimeout = GlobalSettings.NetworkTimeout * 2000;
                req.ContentType      = "application/json";
                req.UserAgent        = Constants.USER_AGENT;

                loadLoginSessionCookies(req);
//                setSessionCookie(req);

                var requestStream = req.GetRequestStream();
                var encoding      = new ASCIIEncoding();

                object json = new {
                    rendererType     = "atlassian-wiki-renderer",
                    unrenderedMarkup = markup,
                    issueKey         = issueKey,
                    issueType        = issueType,
                    projectId        = projectId
                };

                var serialized = JsonConvert.SerializeObject(json);
                var buffer     = encoding.GetBytes(serialized);

                requestStream.Write(buffer, 0, buffer.Length);
                requestStream.Flush();
                requestStream.Close();

                var resp = (HttpWebResponse)req.GetResponse();

                storeLoginSessionCookies(req);

                var stream = resp.GetResponseStream();
                var text   = PlvsUtils.getTextDocument(stream);
                if (stream != null)
                {
                    stream.Close();
                }
                resp.Close();

                return(text);
            } catch (Exception e) {
                Debug.WriteLine(e.Message);
                throw;
            }
        }
        void pollTimerElapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            lastPollTime = null;
            nextPollTime = null;
            Thread t = PlvsUtils.createThread(() => pollRunner(true));

            t.Start();
        }
 private void buttonViewInBrowser_Click(object sender, EventArgs e)
 {
     try {
         PlvsUtils.runBrowser(build.Server.Url + "/browse/" + build.Key);
     } catch (Exception ex) {
         Debug.WriteLine("buttonViewInBrowser_Click - exception: " + ex.Message);
     }
 }
Exemplo n.º 23
0
 private void linkErrorDetails_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (exception == null)
     {
         return;
     }
     PlvsUtils.showError("Failed to connect to server \"" + server.Name + "\"", exception);
 }
            private static Image getImagePath(System.Drawing.Image img)
            {
                Image image = new Image {
                    Source = PlvsUtils.bitmapSourceFromPngImage(img), Width = 16, Height = 16
                };

                return(image);
            }
Exemplo n.º 25
0
 static void applicationThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     if (PlvsUtils.isConnectorException(e.Exception))
     {
         UnhandledExceptionDialog dlg = new UnhandledExceptionDialog(e.Exception);
         dlg.ShowDialog();
     }
 }
 private static void viewUrlInTheBrowser(string url)
 {
     try {
         PlvsUtils.runBrowser(url);
     } catch (Exception ex) {
         Debug.WriteLine("viewUrlInTheBrowser - exception: " + ex.Message);
     }
 }
 private void buttonHelp_Click(object sender, EventArgs e)
 {
     try {
         PlvsUtils.runBrowser("http://confluence.atlassian.com/display/IDEPLUGIN/Using+Bamboo+in+the+Visual+Studio+Connector");
     } catch (Exception ex) {
         Debug.WriteLine("TabBamboo.buttonHelp_Click() - exception: " + ex.Message);
     }
 }
 private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!tabControl.SelectedTab.Equals(tabLog))
     {
         return;
     }
     webLog.DocumentText = PlvsUtils.getThrobberHtml(PlvsUtils.getThroberPath(), "Fetching build log...");
 }
Exemplo n.º 29
0
        public ExceptionViewer(string message, Exception exception)
        {
            InitializeComponent();

            StartPosition = FormStartPosition.CenterParent;

            textException.Text = PlvsUtils.getFullExceptionTextDetails(message, exception);
        }
Exemplo n.º 30
0
        private void buttonReportBug_Click(object sender, EventArgs e)
        {
            try {
                PlvsUtils.runBrowser("https://ecosystem.atlassian.net/secure/CreateIssueDetails!init.jspa?pid=13773&issuetype=1");
// ReSharper disable EmptyGeneralCatchClause
            } catch (Exception) {
// ReSharper restore EmptyGeneralCatchClause
            }
        }