Example #1
0
		public async Task<bool> EditPostAsync(string postid, string title, string description, IList<string> categories, bool publish)
		{
			XmlRPC.Array array = new XmlRPC.Array((categories == null) ? 0 : categories.Count);
			if (categories != null)
			{
				List<string> list = categories.Distinct<string>().ToList<string>();
				list.Sort();
				List<Value> ss = new List<Value>();
				(
					from c in list
					select new StringValue(c)).ToList<StringValue>().ForEach(delegate(StringValue i)
				{
					ss.Add(i);
				});
				array.AddRange(ss);
			}
			Service service = new Service(this.BlogConnectionInfo.MetaWeblogURL);
			Struct @struct = new Struct();
			@struct["title"] = new StringValue(title);
			@struct["description"] = new StringValue(description);
			@struct["categories"] = array;
			MethodCall methodCall = new MethodCall("metaWeblog.editPost");
			methodCall.Parameters.Add(postid);
			methodCall.Parameters.Add(this.BlogConnectionInfo.Username);
			methodCall.Parameters.Add(this.BlogConnectionInfo.Password);
			methodCall.Parameters.Add(@struct);
			methodCall.Parameters.Add(publish);
			service.Cookies = this.BlogConnectionInfo.Cookies;
			MethodResponse methodResponse = await service.ExecuteAsync(methodCall);
			Value value = methodResponse.Parameters[0];
			BooleanValue booleanValue = (BooleanValue)value;
			return booleanValue.Boolean;
		}
Example #2
0
		public async Task<string> NewPostAsync(string title, string description, IList<string> categories, bool publish, DateTime? date_created)
		{
			XmlRPC.Array array;
			if (categories == null)
			{
				array = new XmlRPC.Array(0);
			}
			else
			{
				array = new XmlRPC.Array(categories.Count);
				List<Value> ss = new List<Value>();
				(
					from c in categories
					select new StringValue(c)).ToList<StringValue>().ForEach(delegate(StringValue i)
				{
					ss.Add(i);
				});
				array.AddRange(ss);
			}
			Service service = new Service(this.BlogConnectionInfo.MetaWeblogURL);
			Struct @struct = new Struct();
			@struct["title"] = new StringValue(title);
			@struct["description"] = new StringValue(description);
			@struct["categories"] = array;
			if (date_created.HasValue)
			{
				@struct["dateCreated"] = new DateTimeValue(date_created.Value);
				@struct["date_created_gmt"] = new DateTimeValue(date_created.Value.ToUniversalTime());
			}
			MethodCall methodCall = new MethodCall("metaWeblog.newPost");
			methodCall.Parameters.Add(this.BlogConnectionInfo.BlogID);
			methodCall.Parameters.Add(this.BlogConnectionInfo.Username);
			methodCall.Parameters.Add(this.BlogConnectionInfo.Password);
			methodCall.Parameters.Add(@struct);
			methodCall.Parameters.Add(publish);
			service.Cookies = this.BlogConnectionInfo.Cookies;
			MethodResponse methodResponse = await service.ExecuteAsync(methodCall);
			Value value = methodResponse.Parameters[0];
			return ((StringValue)value).String;
		}