コード例 #1
0
ファイル: Group.cs プロジェクト: BobDankert/ShareFile-NET
        public override void Copy(ODataObject source, JsonSerializer serializer)
        {
            if(source == null || serializer == null) return;
            base.Copy(source, serializer);

            var typedSource = source as Group;
            if(typedSource != null)
            {
                Owner = typedSource.Owner;
                Account = typedSource.Account;
                IsShared = typedSource.IsShared;
                Contacts = typedSource.Contacts;
            }
            else
            {
                JToken token;
                if(source.TryGetProperty("Owner", out token) && token.Type != JTokenType.Null)
                {
                    Owner = (User)serializer.Deserialize(token.CreateReader(), typeof(User));
                }
                if(source.TryGetProperty("Account", out token) && token.Type != JTokenType.Null)
                {
                    Account = (Account)serializer.Deserialize(token.CreateReader(), typeof(Account));
                }
                if(source.TryGetProperty("IsShared", out token) && token.Type != JTokenType.Null)
                {
                    IsShared = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if(source.TryGetProperty("Contacts", out token) && token.Type != JTokenType.Null)
                {
                    Contacts = (IEnumerable<Contact>)serializer.Deserialize(token.CreateReader(), typeof(IEnumerable<Contact>));
                }
            }
        }
コード例 #2
0
        public override void Copy(ODataObject source, JsonSerializer serializer)
        {
            if(source == null || serializer == null) return;
            base.Copy(source, serializer);

            var typedSource = source as ShareAlias;
            if(typedSource != null)
            {
                User = typedSource.User;
                Share = typedSource.Share;
                Email = typedSource.Email;
                Downloads = typedSource.Downloads;
                IsConsumed = typedSource.IsConsumed;
                IsArchived = typedSource.IsArchived;
                IsRead = typedSource.IsRead;
                Uri = typedSource.Uri;
            }
            else
            {
                JToken token;
                if(source.TryGetProperty("User", out token) && token.Type != JTokenType.Null)
                {
                    User = (User)serializer.Deserialize(token.CreateReader(), typeof(User));
                }
                if(source.TryGetProperty("Share", out token) && token.Type != JTokenType.Null)
                {
                    Share = (Share)serializer.Deserialize(token.CreateReader(), typeof(Share));
                }
                if(source.TryGetProperty("Email", out token) && token.Type != JTokenType.Null)
                {
                    Email = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if(source.TryGetProperty("Downloads", out token) && token.Type != JTokenType.Null)
                {
                    Downloads = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?));
                }
                if(source.TryGetProperty("IsConsumed", out token) && token.Type != JTokenType.Null)
                {
                    IsConsumed = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if(source.TryGetProperty("IsArchived", out token) && token.Type != JTokenType.Null)
                {
                    IsArchived = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if(source.TryGetProperty("IsRead", out token) && token.Type != JTokenType.Null)
                {
                    IsRead = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
                if(source.TryGetProperty("Uri", out token) && token.Type != JTokenType.Null)
                {
                    Uri = (Uri)serializer.Deserialize(token.CreateReader(), typeof(Uri));
                }
            }
        }
コード例 #3
0
ファイル: Contact.cs プロジェクト: BobDankert/ShareFile-NET
        public override void Copy(ODataObject source, JsonSerializer serializer)
        {
            if(source == null || serializer == null) return;
            base.Copy(source, serializer);

            var typedSource = source as Contact;
            if(typedSource != null)
            {
                User = typedSource.User;
                FirstName = typedSource.FirstName;
                LastName = typedSource.LastName;
                Company = typedSource.Company;
                EmailMedium = typedSource.EmailMedium;
                EmailShort = typedSource.EmailShort;
                IsConfirmed = typedSource.IsConfirmed;
            }
            else
            {
                JToken token;
                if(source.TryGetProperty("User", out token) && token.Type != JTokenType.Null)
                {
                    User = (User)serializer.Deserialize(token.CreateReader(), typeof(User));
                }
                if(source.TryGetProperty("FirstName", out token) && token.Type != JTokenType.Null)
                {
                    FirstName = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if(source.TryGetProperty("LastName", out token) && token.Type != JTokenType.Null)
                {
                    LastName = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if(source.TryGetProperty("Company", out token) && token.Type != JTokenType.Null)
                {
                    Company = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if(source.TryGetProperty("EmailMedium", out token) && token.Type != JTokenType.Null)
                {
                    EmailMedium = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if(source.TryGetProperty("EmailShort", out token) && token.Type != JTokenType.Null)
                {
                    EmailShort = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if(source.TryGetProperty("IsConfirmed", out token) && token.Type != JTokenType.Null)
                {
                    IsConfirmed = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?));
                }
            }
        }
コード例 #4
0
        public override void Copy(ODataObject source, JsonSerializer serializer)
        {
            if(source == null || serializer == null) return;
            base.Copy(source, serializer);

            var typedSource = source as GenericConfig;
            if(typedSource != null)
            {
                User = typedSource.User;
                ConfigName = typedSource.ConfigName;
                ConfigSize = typedSource.ConfigSize;
                CreationDate = typedSource.CreationDate;
                ModifiedDate = typedSource.ModifiedDate;
                Config = typedSource.Config;
            }
            else
            {
                JToken token;
                if(source.TryGetProperty("User", out token) && token.Type != JTokenType.Null)
                {
                    User = (User)serializer.Deserialize(token.CreateReader(), typeof(User));
                }
                if(source.TryGetProperty("ConfigName", out token) && token.Type != JTokenType.Null)
                {
                    ConfigName = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if(source.TryGetProperty("ConfigSize", out token) && token.Type != JTokenType.Null)
                {
                    ConfigSize = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?));
                }
                if(source.TryGetProperty("CreationDate", out token) && token.Type != JTokenType.Null)
                {
                    CreationDate = (DateTime?)serializer.Deserialize(token.CreateReader(), typeof(DateTime?));
                }
                if(source.TryGetProperty("ModifiedDate", out token) && token.Type != JTokenType.Null)
                {
                    ModifiedDate = (DateTime?)serializer.Deserialize(token.CreateReader(), typeof(DateTime?));
                }
                if(source.TryGetProperty("Config", out token) && token.Type != JTokenType.Null)
                {
                    Config = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
            }
        }
コード例 #5
0
        public override void Copy(ODataObject source, JsonSerializer serializer)
        {
            if(source == null || serializer == null) return;
            base.Copy(source, serializer);

            var typedSource = source as FavoriteFolder;
            if(typedSource != null)
            {
                User = typedSource.User;
                Folder = typedSource.Folder;
                SortOrder = typedSource.SortOrder;
                FolderAlias = typedSource.FolderAlias;
                FolderName = typedSource.FolderName;
                Path = typedSource.Path;
                FileSize = typedSource.FileSize;
                CreationDate = typedSource.CreationDate;
                CreatorFirstName = typedSource.CreatorFirstName;
                CreatorLastName = typedSource.CreatorLastName;
            }
            else
            {
                JToken token;
                if(source.TryGetProperty("User", out token) && token.Type != JTokenType.Null)
                {
                    User = (User)serializer.Deserialize(token.CreateReader(), typeof(User));
                }
                if(source.TryGetProperty("Folder", out token) && token.Type != JTokenType.Null)
                {
                    Folder = (Item)serializer.Deserialize(token.CreateReader(), typeof(Item));
                }
                if(source.TryGetProperty("SortOrder", out token) && token.Type != JTokenType.Null)
                {
                    SortOrder = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?));
                }
                if(source.TryGetProperty("FolderAlias", out token) && token.Type != JTokenType.Null)
                {
                    FolderAlias = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if(source.TryGetProperty("FolderName", out token) && token.Type != JTokenType.Null)
                {
                    FolderName = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if(source.TryGetProperty("Path", out token) && token.Type != JTokenType.Null)
                {
                    Path = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if(source.TryGetProperty("FileSize", out token) && token.Type != JTokenType.Null)
                {
                    FileSize = (long?)serializer.Deserialize(token.CreateReader(), typeof(long?));
                }
                if(source.TryGetProperty("CreationDate", out token) && token.Type != JTokenType.Null)
                {
                    CreationDate = (DateTime?)serializer.Deserialize(token.CreateReader(), typeof(DateTime?));
                }
                if(source.TryGetProperty("CreatorFirstName", out token) && token.Type != JTokenType.Null)
                {
                    CreatorFirstName = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if(source.TryGetProperty("CreatorLastName", out token) && token.Type != JTokenType.Null)
                {
                    CreatorLastName = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
            }
        }
コード例 #6
0
 /// <summary>
 /// Set Roles
 /// </summary>
 /// <example>
 /// {
 /// "Roles" : [ "CanManageUsers", "CanSelectFolderZone" ]
 /// }
 /// </example>
 /// <remarks>
 /// Sets the roles for a user (roles not provided will be disabled.)
 /// The following roles can be set to the user through this call (depending on User type):
 /// CanCreateFolders,
 /// CanSelectFolderZone,
 /// CanUseFileBox,
 /// CanManageUsers,
 /// AdminSharedAddressBook,
 /// CanChangePassword,
 /// CanManageMySettings
 /// </remarks>
 /// <param name="parentUrl"></param>
 /// <param name="user"></param>
 /// <returns>
 /// a modified user record
 /// </returns>
 public IQuery<User> PatchRoles(Uri parentUrl, User user)
 {
     var sfApiQuery = new ShareFile.Api.Client.Requests.Query<User>(Client);
     sfApiQuery.Action("Roles");
     sfApiQuery.Uri(parentUrl);
     sfApiQuery.Body = user;
     sfApiQuery.HttpMethod = "PUT";
     return sfApiQuery;
 }
コード例 #7
0
 /// <summary>
 /// Create Customer
 /// </summary>
 /// <example>
 /// {
 /// "Email":"*****@*****.**",
 /// "FirstName":"Name",
 /// "LastName":"Last Name",
 /// "Company":"Company",
 /// "Password":"******",
 /// "Preferences":
 /// {
 /// "CanResetPassword":true,
 /// "CanViewMySettings":true
 /// },
 /// "DefaultZone":
 /// {
 /// "Id":"zoneid"
 /// }
 /// }
 /// </example>
 /// <remarks>
 /// Creates a new Customer User and associates it to an Account
 /// The following parameters from the input object are used: Email, FirstName, LastName, Company,
 /// DefaultZone, Password, Preferences.CanResetPassword and Preferences.CanViewMySettingsOther parameters are ignored
 /// </remarks>
 /// <param name="user"></param>
 /// <param name="pushCreatorDefaultSettings"></param>
 /// <param name="addshared"></param>
 /// <param name="notify"></param>
 /// <param name="ifNecessary"></param>
 /// <returns>
 /// The new user
 /// </returns>
 public IQuery<User> Create(User user, bool pushCreatorDefaultSettings = false, bool addshared = false, bool notify = false, bool ifNecessary = false)
 {
     var sfApiQuery = new ShareFile.Api.Client.Requests.Query<User>(Client);
     sfApiQuery.From("Users");
     sfApiQuery.QueryString("pushCreatorDefaultSettings", pushCreatorDefaultSettings);
     sfApiQuery.QueryString("addshared", addshared);
     sfApiQuery.QueryString("notify", notify);
     sfApiQuery.QueryString("ifNecessary", ifNecessary);
     sfApiQuery.Body = user;
     sfApiQuery.HttpMethod = "POST";
     return sfApiQuery;
 }
コード例 #8
0
 /// <summary>
 /// Update User
 /// </summary>
 /// <example>
 /// {
 /// "FirstName":"FirstName",
 /// "LastName":"LastName",
 /// "Company":"Company",
 /// "Email":"*****@*****.**",
 /// "Security":
 /// {
 /// "IsDisabled":false
 /// }
 /// "DefaultZone":
 /// {
 /// "Id":"newzoneid"
 /// }
 /// }
 /// </example>
 /// <remarks>
 /// Modifies an existing user object
 /// The following parameters can be modified through this call: FirstName, LastName, Company,
 /// Email, IsDisabled, DefaultZone Id
 /// </remarks>
 /// <param name="url"></param>
 /// <param name="user"></param>
 /// <returns>
 /// a modified user record
 /// </returns>
 public IQuery<User> Update(Uri url, User user)
 {
     var sfApiQuery = new ShareFile.Api.Client.Requests.Query<User>(Client);
     sfApiQuery.Uri(url);
     sfApiQuery.Body = user;
     sfApiQuery.HttpMethod = "PATCH";
     return sfApiQuery;
 }
コード例 #9
0
        public override void Copy(ODataObject source, JsonSerializer serializer)
        {
            if(source == null || serializer == null) return;
            base.Copy(source, serializer);

            var typedSource = source as AsyncOperation;
            if(typedSource != null)
            {
                Operation = typedSource.Operation;
                Account = typedSource.Account;
                AuthorityZone = typedSource.AuthorityZone;
                Source = typedSource.Source;
                User = typedSource.User;
                CreationDate = typedSource.CreationDate;
                State = typedSource.State;
                UpdateDate = typedSource.UpdateDate;
                Target = typedSource.Target;
                BatchID = typedSource.BatchID;
                BatchSourceID = typedSource.BatchSourceID;
                BatchTargetID = typedSource.BatchTargetID;
                BatchProgress = typedSource.BatchProgress;
                BatchState = typedSource.BatchState;
                BatchTotal = typedSource.BatchTotal;
            }
            else
            {
                JToken token;
                if(source.TryGetProperty("Operation", out token) && token.Type != JTokenType.Null)
                {
                    Operation = (SafeEnum<AsyncOperationType>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<AsyncOperationType>));
                }
                if(source.TryGetProperty("Account", out token) && token.Type != JTokenType.Null)
                {
                    Account = (Account)serializer.Deserialize(token.CreateReader(), typeof(Account));
                }
                if(source.TryGetProperty("AuthorityZone", out token) && token.Type != JTokenType.Null)
                {
                    AuthorityZone = (Zone)serializer.Deserialize(token.CreateReader(), typeof(Zone));
                }
                if(source.TryGetProperty("Source", out token) && token.Type != JTokenType.Null)
                {
                    Source = (Item)serializer.Deserialize(token.CreateReader(), typeof(Item));
                }
                if(source.TryGetProperty("User", out token) && token.Type != JTokenType.Null)
                {
                    User = (User)serializer.Deserialize(token.CreateReader(), typeof(User));
                }
                if(source.TryGetProperty("CreationDate", out token) && token.Type != JTokenType.Null)
                {
                    CreationDate = (DateTime?)serializer.Deserialize(token.CreateReader(), typeof(DateTime?));
                }
                if(source.TryGetProperty("State", out token) && token.Type != JTokenType.Null)
                {
                    State = (SafeEnum<AsyncOperationState>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<AsyncOperationState>));
                }
                if(source.TryGetProperty("UpdateDate", out token) && token.Type != JTokenType.Null)
                {
                    UpdateDate = (DateTime?)serializer.Deserialize(token.CreateReader(), typeof(DateTime?));
                }
                if(source.TryGetProperty("Target", out token) && token.Type != JTokenType.Null)
                {
                    Target = (Item)serializer.Deserialize(token.CreateReader(), typeof(Item));
                }
                if(source.TryGetProperty("BatchID", out token) && token.Type != JTokenType.Null)
                {
                    BatchID = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if(source.TryGetProperty("BatchSourceID", out token) && token.Type != JTokenType.Null)
                {
                    BatchSourceID = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if(source.TryGetProperty("BatchTargetID", out token) && token.Type != JTokenType.Null)
                {
                    BatchTargetID = (string)serializer.Deserialize(token.CreateReader(), typeof(string));
                }
                if(source.TryGetProperty("BatchProgress", out token) && token.Type != JTokenType.Null)
                {
                    BatchProgress = (double?)serializer.Deserialize(token.CreateReader(), typeof(double?));
                }
                if(source.TryGetProperty("BatchState", out token) && token.Type != JTokenType.Null)
                {
                    BatchState = (SafeEnum<AsyncOperationState>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<AsyncOperationState>));
                }
                if(source.TryGetProperty("BatchTotal", out token) && token.Type != JTokenType.Null)
                {
                    BatchTotal = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?));
                }
            }
        }