-
Notifications
You must be signed in to change notification settings - Fork 20
/
Program.cs
62 lines (58 loc) · 2.4 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.IO;
using owncloudsharp;
using owncloudsharp.Types;
namespace ocsharpdemo
{
class MainClass
{
public static void Main (string[] args)
{
var c = new Client ("https://octest.myvpx.de/owncloud10", "demo", "demo");
/*Console.Write ("Testing DAV:List ... ");
var list = c.List ("/");
Console.WriteLine ("Received " + list.Count + " item(s)");
foreach (var item in list) {
if (!item.ContentType.Equals ("dav/directory")) {
Console.Write ("Testing DAV:Downloading: " + item.Path + "/" + item.Name + " ... ");
var data = c.Download (item.Path + "/" + item.Name);
Console.WriteLine (data.Length + " Bytes received");
BinaryReader reader = new BinaryReader (data);
data.Position = 0;
byte[] rdata = reader.ReadBytes ((int)data.Length);
File.WriteAllBytes (item.Name, rdata);
if (!c.Exists ("/demo"))
c.CreateDirectory ("/demo");
Console.Write ("Testing DAV:Uploading " + item.Name + " to /demo/ ... ");
var status = c.Upload ("/demo/" + item.Name, new MemoryStream (rdata), item.ContentType);
if (status)
Console.WriteLine ("DONE");
else
Console.WriteLine ("FAILED");
Console.Write ("Testing DAV:Deleting " + item.Name + " from /demo/ ... ");
status = c.Delete ("/demo/" + item.Name);
if (status)
Console.WriteLine ("DONE");
else
Console.WriteLine ("FAILED");
} else
continue;
}*/
Console.Write ("Testing OCS:ListOpenRemoteShare ... ");
if (!c.Exists("/demo"))
c.CreateDirectory("/demo");
var a = c.CreateUser("test", "D8!di7As1");
a = c.CreateUser("demo001", "D8!di7As0");
a = c.CreateGroup("Test123");
a = c.AddUserToGroup("test", "Test123");
var ps = c.ShareWithLink("/demo", Convert.ToInt32(OcsPermission.All), "demo", OcsBoolParam.True);
var us = c.ShareWithUser("/demo", "test", Convert.ToInt32(OcsPermission.All), OcsBoolParam.False);
var gs = c.ShareWithGroup("/demo", "Test123", Convert.ToInt32(OcsPermission.All));
var result = c.IsShared("/demo") ? "is shared" : "is not shared";
Console.WriteLine ("/demo " + result + ".");
var r1 = c.SetUserAttribute("demo001", OCSUserAttributeKey.Password , "D8!di7Ab9"); // "D8!di7As1"
Console.WriteLine(r1);
Console.ReadLine();
}
}
}