Run() public method

public Run ( ) : bool
return bool
Beispiel #1
0
        protected void OnAdd(object sender, EventArgs e)
        {
            NewSiteDialog dlg = new NewSiteDialog();

            try {
                if (dlg.Run())
                {
                    string url = dlg.Url;
                    if (!url.StartsWith("http://") && !url.StartsWith("https://") && !url.StartsWith("file://"))
                    {
                        url = "http://" + url;
                    }

                    try {
                        new Uri(url);
                    } catch {
                        Services.ShowError(null, "Invalid url: " + url, null, true);
                    }

                    if (!service.Repositories.ContainsRepository(url))
                    {
                        IProgressStatus m  = new ConsoleProgressStatus(false);
                        AddinRepository rr = service.Repositories.RegisterRepository(m, url);
                        if (rr == null)
                        {
                            Services.ShowError(null, "The repository could not be registered", null, true);
                            return;
                        }
                        treeStore.AppendValues(rr.Url, rr.Title);
                    }
                }
            } finally {
                dlg.Destroy();
            }
        }
		protected void OnAdd (object sender, EventArgs e)
		{
			NewSiteDialog dlg = new NewSiteDialog ();
			try {
				if (dlg.Run ()) {
					string url = dlg.Url;
					if (!url.StartsWith ("http://") && !url.StartsWith ("https://") && !url.StartsWith ("file://")) {
						url = "http://" + url;
					}
					
					try {
						new Uri (url);
					} catch {
						Services.ShowError (null, "Invalid url: " + url, null, true);
					}
					
					if (!service.Repositories.ContainsRepository (url)) {
						IProgressStatus m = new ConsoleProgressStatus (false);
						AddinRepository rr = service.Repositories.RegisterRepository (m, url);
						if (rr == null) {
							Services.ShowError (null, "The repository could not be registered", null, true);
							return;
						}
						treeStore.AppendValues (rr.Url, rr.Title);
					}
				}
			} finally {
				dlg.Destroy ();
			}
		}
		protected void OnAdd (object sender, EventArgs e)
		{
			NewSiteDialog dlg = new NewSiteDialog (this);
			try {
				if (dlg.Run ()) {
					string url = dlg.Url;
					if (!url.StartsWith ("http://") && !url.StartsWith ("https://") && !url.StartsWith ("file://")) {
						url = "http://" + url;
					}
					
					try {
						new Uri (url);
					} catch {
						Services.ShowError (null, "Invalid url: " + url, null, true);
					}
					
					if (!service.Repositories.ContainsRepository (url)) {
						ProgressDialog pdlg = new ProgressDialog (this);
						pdlg.Show ();
						pdlg.SetMessage (AddinManager.CurrentLocalizer.GetString ("Registering repository"));
						
						bool done = false;
						AddinRepository rr = null;
						Exception error = null;
						
						ThreadPool.QueueUserWorkItem (delegate {
							try {
								rr = service.Repositories.RegisterRepository (pdlg, url, true);
							} catch (System.Exception ex) {
								error = ex;
							} finally {
								done = true;
							}
						});
						
						while (!done) {
							if (Gtk.Application.EventsPending ())
								Gtk.Application.RunIteration ();
							else
								Thread.Sleep (100);
						}

						pdlg.Destroy ();
						
						if (pdlg.HadError) {
							if (rr != null)
								service.Repositories.RemoveRepository (rr.Url);
							return;
						}
						
						if (error != null) {
							Services.ShowError (error, "The repository could not be registered", null, true);
							return;
						}
						
						AppendRepository (rr);
					}
				}
			} finally {
				dlg.Destroy ();
			}
		}
Beispiel #4
0
        protected void OnAdd(object sender, EventArgs e)
        {
            NewSiteDialog dlg = new NewSiteDialog(this);

            try {
                if (dlg.Run())
                {
                    string url = dlg.Url;
                    if (!url.StartsWith("http://") && !url.StartsWith("https://") && !url.StartsWith("file://"))
                    {
                        url = "http://" + url;
                    }

                    try {
                        new Uri(url);
                    } catch {
                        Services.ShowError(null, "Invalid url: " + url, null, true);
                    }

                    if (!service.Repositories.ContainsRepository(url))
                    {
                        ProgressDialog pdlg = new ProgressDialog(this);
                        pdlg.Show();
                        pdlg.SetMessage(AddinManager.CurrentLocalizer.GetString("Registering repository"));

                        bool            done  = false;
                        AddinRepository rr    = null;
                        Exception       error = null;

                        ThreadPool.QueueUserWorkItem(delegate {
                            try {
                                rr = service.Repositories.RegisterRepository(pdlg, url, true);
                            } catch (System.Exception ex) {
                                error = ex;
                            } finally {
                                done = true;
                            }
                        });

                        while (!done)
                        {
                            if (Gtk.Application.EventsPending())
                            {
                                Gtk.Application.RunIteration();
                            }
                            else
                            {
                                Thread.Sleep(100);
                            }
                        }

                        pdlg.Destroy();

                        if (pdlg.HadError)
                        {
                            if (rr != null)
                            {
                                service.Repositories.RemoveRepository(rr.Url);
                            }
                            return;
                        }

                        if (error != null)
                        {
                            Services.ShowError(error, "The repository could not be registered", null, true);
                            return;
                        }

                        AppendRepository(rr);
                    }
                }
            } finally {
                dlg.Destroy();
            }
        }