예제 #1
0
		/// <summary>
		/// Puts / saves the modified wiki page at the remote wiki server.
		/// </summary>
		/// <param name="pageName">Name of the page.</param>
		/// <param name="rawWikiText">The raw wiki text.</param>
		/// <param name="putParameters">The put parameters.</param>
		/// <returns>True if all went good. False otherwise.</returns>
		/// <exception cref="CommunicationException">Is thrown when the Xml-Rpc mechanism had errors.</exception>
		/// <exception cref="WebException">Is thrown when the HTTP connection had errors.</exception>
		public bool PutPage(string pageName, string rawWikiText, PutParameters[] putParameters)
		{
			try
			{
				return this.clientProxy.PutPage(pageName, rawWikiText, putParameters);
			}
			catch (WebException we)
			{
				logger.Warn(we);
				throw;
			}
			catch (XmlRpcException xrpce)
			{
				logger.Warn(xrpce);
				throw new CommunicationException(xrpce.Message);
			}
		}
		private void saveWikipage_Click(object sender, RoutedEventArgs e)
		{
			this.statusLabel.Content = "Saving wikipage.";

			try
			{
				string rawWikipage = String.Empty;
				FlowDocument document = this.outputBox.Document;
				TextRange wholeDocument = new TextRange(document.ContentStart, document.ContentEnd);
				rawWikipage = wholeDocument.Text;
				if (!String.IsNullOrEmpty(rawWikipage))
				{
					List<PutParameters> putParametersList = new List<PutParameters>();
					PutParameters putParameters = new PutParameters();
					putParameters.ChangeSummary = "Generated summary";
					putParameters.IsMinor = true;
					putParametersList.Add(putParameters);

					this.clientProxy.PutPage(this.getWikipageText.Text, rawWikipage, putParametersList.ToArray());
				}
				else
				{
					this.statusLabel.Content = "Nothing to save.";
				}
			}
			catch (CommunicationException ce)
			{
				this.statusLabel.Content = "Couldn't save wiki page. Cause: " + ce.Message;
			}

			this.statusLabel.Content = "Wikipage saved!";
		}