mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 05:53:27 -07:00
Code quality changes [skip ci]
This commit is contained in:
parent
61cfe004c5
commit
798ca503a5
108 changed files with 1981 additions and 2258 deletions
|
@ -26,22 +26,18 @@ using GreenshotConfluencePlugin;
|
|||
using GreenshotConfluencePlugin.confluence;
|
||||
using GreenshotPlugin.Core;
|
||||
|
||||
/// <summary>
|
||||
/// For details see the Confluence API site
|
||||
/// See: http://confluence.atlassian.com/display/CONFDEV/Remote+API+Specification
|
||||
/// </summary>
|
||||
namespace Confluence {
|
||||
#region transport classes
|
||||
public class Page {
|
||||
public Page(RemotePage page) {
|
||||
id = page.id;
|
||||
Id = page.id;
|
||||
Title = page.title;
|
||||
SpaceKey = page.space;
|
||||
Url = page.url;
|
||||
Content = page.content;
|
||||
}
|
||||
public Page(RemoteSearchResult searchResult, string space) {
|
||||
id = searchResult.id;
|
||||
Id = searchResult.id;
|
||||
Title = searchResult.title;
|
||||
SpaceKey = space;
|
||||
Url = searchResult.url;
|
||||
|
@ -49,12 +45,12 @@ namespace Confluence {
|
|||
}
|
||||
|
||||
public Page(RemotePageSummary pageSummary) {
|
||||
id = pageSummary.id;
|
||||
Id = pageSummary.id;
|
||||
Title = pageSummary.title;
|
||||
SpaceKey = pageSummary.space;
|
||||
Url =pageSummary.url;
|
||||
}
|
||||
public long id {
|
||||
public long Id {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
@ -91,46 +87,52 @@ namespace Confluence {
|
|||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// For details see the Confluence API site
|
||||
/// See: http://confluence.atlassian.com/display/CONFDEV/Remote+API+Specification
|
||||
/// </summary>
|
||||
public class ConfluenceConnector : IDisposable {
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceConnector));
|
||||
private const string AUTH_FAILED_EXCEPTION_NAME = "com.atlassian.confluence.rpc.AuthenticationFailedException";
|
||||
private const string V2_FAILED = "AXIS";
|
||||
private static readonly ConfluenceConfiguration config = IniConfig.GetIniSection<ConfluenceConfiguration>();
|
||||
private string credentials = null;
|
||||
private DateTime loggedInTime = DateTime.Now;
|
||||
private bool loggedIn = false;
|
||||
private ConfluenceSoapServiceService confluence;
|
||||
private readonly int timeout;
|
||||
private string url;
|
||||
private readonly Cache<string, RemotePage> pageCache = new Cache<string, RemotePage>(60 * config.Timeout);
|
||||
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(ConfluenceConnector));
|
||||
private const string AuthFailedExceptionName = "com.atlassian.confluence.rpc.AuthenticationFailedException";
|
||||
private const string V2Failed = "AXIS";
|
||||
private static readonly ConfluenceConfiguration Config = IniConfig.GetIniSection<ConfluenceConfiguration>();
|
||||
private string _credentials;
|
||||
private DateTime _loggedInTime = DateTime.Now;
|
||||
private bool _loggedIn;
|
||||
private ConfluenceSoapServiceService _confluence;
|
||||
private readonly int _timeout;
|
||||
private string _url;
|
||||
private readonly Cache<string, RemotePage> _pageCache = new Cache<string, RemotePage>(60 * Config.Timeout);
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
if (confluence != null) {
|
||||
logout();
|
||||
protected void Dispose(bool disposing) {
|
||||
if (_confluence != null) {
|
||||
Logout();
|
||||
}
|
||||
if (disposing) {
|
||||
if (confluence != null) {
|
||||
confluence.Dispose();
|
||||
confluence = null;
|
||||
if (_confluence != null) {
|
||||
_confluence.Dispose();
|
||||
_confluence = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ConfluenceConnector(string url, int timeout) {
|
||||
this.timeout = timeout;
|
||||
init(url);
|
||||
_timeout = timeout;
|
||||
Init(url);
|
||||
}
|
||||
|
||||
private void init(string url) {
|
||||
this.url = url;
|
||||
confluence = new ConfluenceSoapServiceService();
|
||||
confluence.Url = url;
|
||||
confluence.Proxy = NetworkHelper.CreateProxy(new Uri(url));
|
||||
private void Init(string url) {
|
||||
_url = url;
|
||||
_confluence = new ConfluenceSoapServiceService
|
||||
{
|
||||
Url = url,
|
||||
Proxy = NetworkHelper.CreateProxy(new Uri(url))
|
||||
};
|
||||
}
|
||||
|
||||
~ConfluenceConnector() {
|
||||
|
@ -141,41 +143,43 @@ namespace Confluence {
|
|||
/// Internal login which catches the exceptions
|
||||
/// </summary>
|
||||
/// <returns>true if login was done sucessfully</returns>
|
||||
private bool doLogin(string user, string password) {
|
||||
private bool DoLogin(string user, string password) {
|
||||
try {
|
||||
credentials = confluence.login(user, password);
|
||||
loggedInTime = DateTime.Now;
|
||||
loggedIn = true;
|
||||
_credentials = _confluence.login(user, password);
|
||||
_loggedInTime = DateTime.Now;
|
||||
_loggedIn = true;
|
||||
} catch (Exception e) {
|
||||
// Check if confluence-v2 caused an error, use v1 instead
|
||||
if (e.Message.Contains(V2_FAILED) && url.Contains("v2")) {
|
||||
init(url.Replace("v2", "v1"));
|
||||
return doLogin(user, password);
|
||||
if (e.Message.Contains(V2Failed) && _url.Contains("v2")) {
|
||||
Init(_url.Replace("v2", "v1"));
|
||||
return DoLogin(user, password);
|
||||
}
|
||||
// check if auth failed
|
||||
if (e.Message.Contains(AUTH_FAILED_EXCEPTION_NAME)) {
|
||||
if (e.Message.Contains(AuthFailedExceptionName)) {
|
||||
return false;
|
||||
}
|
||||
// Not an authentication issue
|
||||
loggedIn = false;
|
||||
credentials = null;
|
||||
_loggedIn = false;
|
||||
_credentials = null;
|
||||
e.Data.Add("user", user);
|
||||
e.Data.Add("url", url);
|
||||
e.Data.Add("url", _url);
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void login() {
|
||||
logout();
|
||||
public void Login() {
|
||||
Logout();
|
||||
try {
|
||||
// Get the system name, so the user knows where to login to
|
||||
string systemName = url.Replace(ConfluenceConfiguration.DEFAULT_POSTFIX1,"");
|
||||
systemName = url.Replace(ConfluenceConfiguration.DEFAULT_POSTFIX2, "");
|
||||
CredentialsDialog dialog = new CredentialsDialog(systemName);
|
||||
dialog.Name = null;
|
||||
string systemName = _url.Replace(ConfluenceConfiguration.DEFAULT_POSTFIX1,"");
|
||||
systemName = systemName.Replace(ConfluenceConfiguration.DEFAULT_POSTFIX2, "");
|
||||
CredentialsDialog dialog = new CredentialsDialog(systemName)
|
||||
{
|
||||
Name = null
|
||||
};
|
||||
while (dialog.Show(dialog.Name) == DialogResult.OK) {
|
||||
if (doLogin(dialog.Name, dialog.Password)) {
|
||||
if (DoLogin(dialog.Name, dialog.Password)) {
|
||||
if (dialog.SaveChecked) {
|
||||
dialog.Confirm(true);
|
||||
}
|
||||
|
@ -185,7 +189,7 @@ namespace Confluence {
|
|||
dialog.Confirm(false);
|
||||
} catch (ApplicationException e) {
|
||||
// exception handling ...
|
||||
LOG.Error("Problem using the credentials dialog", e);
|
||||
Log.Error("Problem using the credentials dialog", e);
|
||||
}
|
||||
// For every windows version after XP show an incorrect password baloon
|
||||
dialog.IncorrectPassword = true;
|
||||
|
@ -195,119 +199,119 @@ namespace Confluence {
|
|||
}
|
||||
} catch (ApplicationException e) {
|
||||
// exception handling ...
|
||||
LOG.Error("Problem using the credentials dialog", e);
|
||||
Log.Error("Problem using the credentials dialog", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void logout() {
|
||||
if (credentials != null) {
|
||||
confluence.logout(credentials);
|
||||
credentials = null;
|
||||
loggedIn = false;
|
||||
public void Logout() {
|
||||
if (_credentials != null) {
|
||||
_confluence.logout(_credentials);
|
||||
_credentials = null;
|
||||
_loggedIn = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkCredentials() {
|
||||
if (loggedIn) {
|
||||
if (loggedInTime.AddMinutes(timeout-1).CompareTo(DateTime.Now) < 0) {
|
||||
logout();
|
||||
login();
|
||||
private void CheckCredentials() {
|
||||
if (_loggedIn) {
|
||||
if (_loggedInTime.AddMinutes(_timeout-1).CompareTo(DateTime.Now) < 0) {
|
||||
Logout();
|
||||
Login();
|
||||
}
|
||||
} else {
|
||||
login();
|
||||
Login();
|
||||
}
|
||||
}
|
||||
|
||||
public bool isLoggedIn {
|
||||
public bool IsLoggedIn {
|
||||
get {
|
||||
return loggedIn;
|
||||
return _loggedIn;
|
||||
}
|
||||
}
|
||||
|
||||
public void addAttachment(long pageId, string mime, string comment, string filename, IBinaryContainer image) {
|
||||
checkCredentials();
|
||||
public void AddAttachment(long pageId, string mime, string comment, string filename, IBinaryContainer image) {
|
||||
CheckCredentials();
|
||||
RemoteAttachment attachment = new RemoteAttachment();
|
||||
// Comment is ignored, see: http://jira.atlassian.com/browse/CONF-9395
|
||||
attachment.comment = comment;
|
||||
attachment.fileName = filename;
|
||||
attachment.contentType = mime;
|
||||
confluence.addAttachment(credentials, pageId, attachment, image.ToByteArray());
|
||||
_confluence.addAttachment(_credentials, pageId, attachment, image.ToByteArray());
|
||||
}
|
||||
|
||||
public Page getPage(string spaceKey, string pageTitle) {
|
||||
public Page GetPage(string spaceKey, string pageTitle) {
|
||||
RemotePage page = null;
|
||||
string cacheKey = spaceKey + pageTitle;
|
||||
if (pageCache.Contains(cacheKey)) {
|
||||
page = pageCache[cacheKey];
|
||||
if (_pageCache.Contains(cacheKey)) {
|
||||
page = _pageCache[cacheKey];
|
||||
}
|
||||
if (page == null) {
|
||||
checkCredentials();
|
||||
page = confluence.getPage(credentials, spaceKey, pageTitle);
|
||||
pageCache.Add(cacheKey, page);
|
||||
CheckCredentials();
|
||||
page = _confluence.getPage(_credentials, spaceKey, pageTitle);
|
||||
_pageCache.Add(cacheKey, page);
|
||||
}
|
||||
return new Page(page);
|
||||
}
|
||||
|
||||
public Page getPage(long pageId) {
|
||||
public Page GetPage(long pageId) {
|
||||
RemotePage page = null;
|
||||
string cacheKey = "" + pageId;
|
||||
|
||||
if (pageCache.Contains(cacheKey)) {
|
||||
page = pageCache[cacheKey];
|
||||
if (_pageCache.Contains(cacheKey)) {
|
||||
page = _pageCache[cacheKey];
|
||||
}
|
||||
if (page == null) {
|
||||
checkCredentials();
|
||||
page = confluence.getPage(credentials, pageId);
|
||||
pageCache.Add(cacheKey, page);
|
||||
CheckCredentials();
|
||||
page = _confluence.getPage(_credentials, pageId);
|
||||
_pageCache.Add(cacheKey, page);
|
||||
}
|
||||
return new Page(page);
|
||||
}
|
||||
|
||||
public Page getSpaceHomepage(Space spaceSummary) {
|
||||
checkCredentials();
|
||||
RemoteSpace spaceDetail = confluence.getSpace(credentials, spaceSummary.Key);
|
||||
RemotePage page = confluence.getPage(credentials, spaceDetail.homePage);
|
||||
public Page GetSpaceHomepage(Space spaceSummary) {
|
||||
CheckCredentials();
|
||||
RemoteSpace spaceDetail = _confluence.getSpace(_credentials, spaceSummary.Key);
|
||||
RemotePage page = _confluence.getPage(_credentials, spaceDetail.homePage);
|
||||
return new Page(page);
|
||||
}
|
||||
|
||||
public List<Space> getSpaceSummaries() {
|
||||
checkCredentials();
|
||||
RemoteSpaceSummary [] spaces = confluence.getSpaces(credentials);
|
||||
public List<Space> GetSpaceSummaries() {
|
||||
CheckCredentials();
|
||||
RemoteSpaceSummary [] spaces = _confluence.getSpaces(_credentials);
|
||||
List<Space> returnSpaces = new List<Space>();
|
||||
foreach(RemoteSpaceSummary space in spaces) {
|
||||
returnSpaces.Add(new Space(space));
|
||||
}
|
||||
returnSpaces.Sort((x, y) => string.Compare(x.Name, y.Name));
|
||||
returnSpaces.Sort((x, y) => string.CompareOrdinal(x.Name, y.Name));
|
||||
return returnSpaces;
|
||||
}
|
||||
|
||||
public List<Page> getPageChildren(Page parentPage) {
|
||||
checkCredentials();
|
||||
public List<Page> GetPageChildren(Page parentPage) {
|
||||
CheckCredentials();
|
||||
List<Page> returnPages = new List<Page>();
|
||||
RemotePageSummary[] pages = confluence.getChildren(credentials, parentPage.id);
|
||||
RemotePageSummary[] pages = _confluence.getChildren(_credentials, parentPage.Id);
|
||||
foreach(RemotePageSummary page in pages) {
|
||||
returnPages.Add(new Page(page));
|
||||
}
|
||||
returnPages.Sort((x, y) => string.Compare(x.Title, y.Title));
|
||||
returnPages.Sort((x, y) => string.CompareOrdinal(x.Title, y.Title));
|
||||
return returnPages;
|
||||
}
|
||||
|
||||
public List<Page> getPageSummaries(Space space) {
|
||||
checkCredentials();
|
||||
public List<Page> GetPageSummaries(Space space) {
|
||||
CheckCredentials();
|
||||
List<Page> returnPages = new List<Page>();
|
||||
RemotePageSummary[] pages = confluence.getPages(credentials, space.Key);
|
||||
RemotePageSummary[] pages = _confluence.getPages(_credentials, space.Key);
|
||||
foreach(RemotePageSummary page in pages) {
|
||||
returnPages.Add(new Page(page));
|
||||
}
|
||||
returnPages.Sort((x, y) => string.Compare(x.Title, y.Title));
|
||||
returnPages.Sort((x, y) => string.CompareOrdinal(x.Title, y.Title));
|
||||
return returnPages;
|
||||
}
|
||||
|
||||
public List<Page> searchPages(string query, string space) {
|
||||
checkCredentials();
|
||||
public List<Page> SearchPages(string query, string space) {
|
||||
CheckCredentials();
|
||||
List<Page> results = new List<Page>();
|
||||
foreach(RemoteSearchResult searchResult in confluence.search(credentials, query, 20)) {
|
||||
LOG.DebugFormat("Got result of type {0}", searchResult.type);
|
||||
foreach(RemoteSearchResult searchResult in _confluence.search(_credentials, query, 20)) {
|
||||
Log.DebugFormat("Got result of type {0}", searchResult.type);
|
||||
if ("page".Equals(searchResult.type)) {
|
||||
results.Add(new Page(searchResult, space));
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace GreenshotConfluencePlugin {
|
|||
}
|
||||
|
||||
public override IEnumerable<IDestination> DynamicDestinations() {
|
||||
if (ConfluencePlugin.ConfluenceConnectorNoLogin == null || !ConfluencePlugin.ConfluenceConnectorNoLogin.isLoggedIn) {
|
||||
if (ConfluencePlugin.ConfluenceConnectorNoLogin == null || !ConfluencePlugin.ConfluenceConnectorNoLogin.IsLoggedIn) {
|
||||
yield break;
|
||||
}
|
||||
List<Page> currentPages = ConfluenceUtils.GetCurrentPages();
|
||||
|
@ -117,7 +117,7 @@ namespace GreenshotConfluencePlugin {
|
|||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
||||
ExportInformation exportInformation = new ExportInformation(Designation, Description);
|
||||
// force password check to take place before the pages load
|
||||
if (!ConfluencePlugin.ConfluenceConnector.isLoggedIn) {
|
||||
if (!ConfluencePlugin.ConfluenceConnector.IsLoggedIn) {
|
||||
return exportInformation;
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ namespace GreenshotConfluencePlugin {
|
|||
Nullable<bool> dialogResult = confluenceUpload.ShowDialog();
|
||||
if (dialogResult.HasValue && dialogResult.Value) {
|
||||
selectedPage = confluenceUpload.SelectedPage;
|
||||
if (confluenceUpload.isOpenPageSelected) {
|
||||
if (confluenceUpload.IsOpenPageSelected) {
|
||||
openPage = false;
|
||||
}
|
||||
filename = confluenceUpload.Filename;
|
||||
|
@ -164,7 +164,7 @@ namespace GreenshotConfluencePlugin {
|
|||
try {
|
||||
new PleaseWaitForm().ShowAndWait(Description, Language.GetString("confluence", LangKey.communication_wait),
|
||||
delegate() {
|
||||
ConfluencePlugin.ConfluenceConnector.addAttachment(page.id, "image/" + config.UploadFormat.ToString().ToLower(), null, filename, new SurfaceContainer(surfaceToUpload, outputSettings, filename));
|
||||
ConfluencePlugin.ConfluenceConnector.AddAttachment(page.Id, "image/" + config.UploadFormat.ToString().ToLower(), null, filename, new SurfaceContainer(surfaceToUpload, outputSettings, filename));
|
||||
}
|
||||
);
|
||||
LOG.Debug("Uploaded to Confluence.");
|
||||
|
|
|
@ -68,8 +68,8 @@ namespace GreenshotConfluencePlugin {
|
|||
CreateConfluenceConntector();
|
||||
}
|
||||
try {
|
||||
if (_confluenceConnector != null && !_confluenceConnector.isLoggedIn) {
|
||||
_confluenceConnector.login();
|
||||
if (_confluenceConnector != null && !_confluenceConnector.IsLoggedIn) {
|
||||
_confluenceConnector.Login();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MessageBox.Show(Language.GetFormattedString("confluence", LangKey.login_error, e.Message));
|
||||
|
@ -112,7 +112,7 @@ namespace GreenshotConfluencePlugin {
|
|||
public virtual void Shutdown() {
|
||||
LOG.Debug("Confluence Plugin shutdown.");
|
||||
if (_confluenceConnector != null) {
|
||||
_confluenceConnector.logout();
|
||||
_confluenceConnector.Logout();
|
||||
_confluenceConnector = null;
|
||||
}
|
||||
}
|
||||
|
@ -131,8 +131,8 @@ namespace GreenshotConfluencePlugin {
|
|||
IniConfig.Save();
|
||||
if (_confluenceConnector != null) {
|
||||
if (!url.Equals(_config.Url)) {
|
||||
if (_confluenceConnector.isLoggedIn) {
|
||||
_confluenceConnector.logout();
|
||||
if (_confluenceConnector.IsLoggedIn) {
|
||||
_confluenceConnector.Logout();
|
||||
}
|
||||
_confluenceConnector = null;
|
||||
}
|
||||
|
|
|
@ -50,14 +50,14 @@ namespace GreenshotConfluencePlugin {
|
|||
try {
|
||||
bool pageDouble = false;
|
||||
foreach(Confluence.Page page in pages) {
|
||||
if (page.id == pageId) {
|
||||
if (page.Id == pageId) {
|
||||
pageDouble = true;
|
||||
LOG.DebugFormat("Skipping double page with ID {0}", pageId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!pageDouble) {
|
||||
Confluence.Page page = ConfluencePlugin.ConfluenceConnector.getPage(pageId);
|
||||
Confluence.Page page = ConfluencePlugin.ConfluenceConnector.GetPage(pageId);
|
||||
LOG.DebugFormat("Adding page {0}", page.Title);
|
||||
pages.Add(page);
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ namespace GreenshotConfluencePlugin {
|
|||
}
|
||||
}
|
||||
if (!pageDouble) {
|
||||
Confluence.Page page = ConfluencePlugin.ConfluenceConnector.getPage(space, title);
|
||||
Confluence.Page page = ConfluencePlugin.ConfluenceConnector.GetPage(space, title);
|
||||
LOG.DebugFormat("Adding page {0}", page.Title);
|
||||
pages.Add(page);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Page x:Class="GreenshotConfluencePlugin.ConfluencePagePicker"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:l="clr-namespace:TranslationByMarkupExtension" Loaded="Page_Loaded">
|
||||
Loaded="Page_Loaded">
|
||||
<ListView Name="PageListView" SelectionMode="Single" ItemsSource="{Binding}" SelectionChanged="PageListView_SelectionChanged" Width="480" Height="500">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace GreenshotConfluencePlugin {
|
|||
if (PageListView.HasItems && PageListView.SelectedItems.Count > 0) {
|
||||
confluenceUpload.SelectedPage = (Page)PageListView.SelectedItem;
|
||||
// Make sure the uploader knows we selected an already opened page
|
||||
confluenceUpload.isOpenPageSelected = true;
|
||||
confluenceUpload.IsOpenPageSelected = true;
|
||||
} else {
|
||||
confluenceUpload.SelectedPage = null;
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace GreenshotConfluencePlugin {
|
|||
void doSearch() {
|
||||
string spaceKey = (string)SpaceComboBox.SelectedValue;
|
||||
config.SearchSpaceKey = spaceKey;
|
||||
List<Confluence.Page> searchResult = ConfluencePlugin.ConfluenceConnector.searchPages(searchText.Text, spaceKey);
|
||||
List<Confluence.Page> searchResult = ConfluencePlugin.ConfluenceConnector.SearchPages(searchText.Text, spaceKey);
|
||||
pages.Clear();
|
||||
foreach(Confluence.Page page in searchResult) {
|
||||
pages.Add(page);
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace GreenshotConfluencePlugin {
|
|||
LOG.Debug("Loading pages for page: " + page.Title);
|
||||
(new Thread(() => {
|
||||
Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)(() => {ShowBusy.Visibility = Visibility.Visible;}));
|
||||
List<Confluence.Page> pages = confluenceConnector.getPageChildren(page);
|
||||
List<Confluence.Page> pages = confluenceConnector.GetPageChildren(page);
|
||||
Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)(() => {
|
||||
foreach(Confluence.Page childPage in pages) {
|
||||
LOG.Debug("Adding page: " + childPage.Title);
|
||||
|
@ -105,7 +105,7 @@ namespace GreenshotConfluencePlugin {
|
|||
|
||||
// Get homepage
|
||||
try {
|
||||
Confluence.Page page = confluenceConnector.getSpaceHomepage(space);
|
||||
Confluence.Page page = confluenceConnector.GetSpaceHomepage(space);
|
||||
TreeViewItem pageTreeViewItem = new TreeViewItem();
|
||||
pageTreeViewItem.Header = page.Title;
|
||||
pageTreeViewItem.Tag = page;
|
||||
|
|
|
@ -29,56 +29,56 @@ namespace GreenshotConfluencePlugin {
|
|||
/// Interaction logic for ConfluenceUpload.xaml
|
||||
/// </summary>
|
||||
public partial class ConfluenceUpload : Window {
|
||||
private Page pickerPage = null;
|
||||
private Page _pickerPage;
|
||||
public Page PickerPage {
|
||||
get {
|
||||
if (pickerPage == null) {
|
||||
if (_pickerPage == null) {
|
||||
List<Confluence.Page> pages = ConfluenceUtils.GetCurrentPages();
|
||||
if (pages != null && pages.Count > 0) {
|
||||
pickerPage = new ConfluencePagePicker(this, pages);
|
||||
_pickerPage = new ConfluencePagePicker(this, pages);
|
||||
}
|
||||
}
|
||||
return pickerPage;
|
||||
return _pickerPage;
|
||||
}
|
||||
}
|
||||
|
||||
private Page searchPage = null;
|
||||
private Page _searchPage;
|
||||
public Page SearchPage {
|
||||
get {
|
||||
if (searchPage == null) {
|
||||
searchPage = new ConfluenceSearch(this);
|
||||
if (_searchPage == null) {
|
||||
_searchPage = new ConfluenceSearch(this);
|
||||
}
|
||||
return searchPage;
|
||||
return _searchPage;
|
||||
}
|
||||
}
|
||||
|
||||
private Page browsePage = null;
|
||||
private Page _browsePage;
|
||||
public Page BrowsePage {
|
||||
get {
|
||||
if (browsePage == null) {
|
||||
browsePage = new ConfluenceTreePicker(this);
|
||||
if (_browsePage == null) {
|
||||
_browsePage = new ConfluenceTreePicker(this);
|
||||
}
|
||||
return browsePage;
|
||||
return _browsePage;
|
||||
}
|
||||
}
|
||||
|
||||
private Confluence.Page selectedPage = null;
|
||||
private Confluence.Page _selectedPage;
|
||||
public Confluence.Page SelectedPage {
|
||||
get {
|
||||
return selectedPage;
|
||||
return _selectedPage;
|
||||
}
|
||||
set {
|
||||
selectedPage = value;
|
||||
if (selectedPage != null) {
|
||||
_selectedPage = value;
|
||||
if (_selectedPage != null) {
|
||||
Upload.IsEnabled = true;
|
||||
} else {
|
||||
Upload.IsEnabled = false;
|
||||
}
|
||||
isOpenPageSelected = false;
|
||||
IsOpenPageSelected = false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool isOpenPageSelected {
|
||||
public bool IsOpenPageSelected {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
@ -87,39 +87,39 @@ namespace GreenshotConfluencePlugin {
|
|||
set;
|
||||
}
|
||||
|
||||
private static DateTime lastLoad = DateTime.Now;
|
||||
private static List<Confluence.Space> spaces;
|
||||
private static DateTime _lastLoad = DateTime.Now;
|
||||
private static List<Confluence.Space> _spaces;
|
||||
public List<Confluence.Space> Spaces {
|
||||
get {
|
||||
updateSpaces();
|
||||
while (spaces == null) {
|
||||
UpdateSpaces();
|
||||
while (_spaces == null) {
|
||||
Thread.Sleep(300);
|
||||
}
|
||||
return spaces;
|
||||
return _spaces;
|
||||
}
|
||||
}
|
||||
|
||||
public ConfluenceUpload(string filename) {
|
||||
Filename = filename;
|
||||
InitializeComponent();
|
||||
this.DataContext = this;
|
||||
updateSpaces();
|
||||
DataContext = this;
|
||||
UpdateSpaces();
|
||||
if (PickerPage == null) {
|
||||
PickerTab.Visibility = Visibility.Collapsed;
|
||||
SearchTab.IsSelected = true;
|
||||
}
|
||||
}
|
||||
|
||||
void updateSpaces() {
|
||||
if (spaces != null && DateTime.Now.AddMinutes(-60).CompareTo(lastLoad) > 0) {
|
||||
void UpdateSpaces() {
|
||||
if (_spaces != null && DateTime.Now.AddMinutes(-60).CompareTo(_lastLoad) > 0) {
|
||||
// Reset
|
||||
spaces = null;
|
||||
_spaces = null;
|
||||
}
|
||||
// Check if load is needed
|
||||
if (spaces == null) {
|
||||
if (_spaces == null) {
|
||||
(new Thread(() => {
|
||||
spaces = ConfluencePlugin.ConfluenceConnector.getSpaceSummaries();
|
||||
lastLoad = DateTime.Now;
|
||||
_spaces = ConfluencePlugin.ConfluenceConnector.GetSpaceSummaries();
|
||||
_lastLoad = DateTime.Now;
|
||||
}) { Name = "Loading spaces for confluence"}).Start();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,5 @@
|
|||
/// <param name="key">The key.</param>
|
||||
/// <returns></returns>
|
||||
object Translate(string key);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the available languages.
|
||||
/// </summary>
|
||||
/// <value>The available languages.</value>
|
||||
//IEnumerable<CultureInfo> Languages { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,20 +34,5 @@ namespace TranslationByMarkupExtension {
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ITranslationProvider Members
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="ITranslationProvider.AvailableLanguages" />
|
||||
/// </summary>
|
||||
/*public IEnumerable<CultureInfo> Languages {
|
||||
get {
|
||||
foreach (LanguageFile supportedLanguage in Language.SupportedLanguages) {
|
||||
yield return new CultureInfo(supportedLanguage.Ietf);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue