|
@@ -2,8 +2,10 @@
|
|
using Google.Apis.Drive.v3;
|
|
using Google.Apis.Drive.v3;
|
|
using Google.Apis.Services;
|
|
using Google.Apis.Services;
|
|
using Google.Apis.Util.Store;
|
|
using Google.Apis.Util.Store;
|
|
|
|
+using PDF_Office.Model.CloudDrive;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
|
+using System.Collections.ObjectModel;
|
|
using System.IO;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text;
|
|
@@ -15,12 +17,12 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
|
|
//多用户UX交互
|
|
//多用户UX交互
|
|
public class GoogleDriveManager
|
|
public class GoogleDriveManager
|
|
{
|
|
{
|
|
-
|
|
|
|
//已登录的所有用户
|
|
//已登录的所有用户
|
|
- public List<GoogleDriveUserItem> GoogleDriveUsers = new List<GoogleDriveUserItem>();
|
|
|
|
-
|
|
|
|
|
|
+ // public ObservableCollection<CloudFileUser> GoogleDriveUsers = new ObservableCollection<CloudFileUser>();
|
|
|
|
|
|
- public GoogleDriveManager()
|
|
|
|
|
|
+ private static GoogleDriveManager instance;
|
|
|
|
+ public static GoogleDriveManager GoogleDrive => instance ?? (instance = new GoogleDriveManager());
|
|
|
|
+ private GoogleDriveManager()
|
|
{
|
|
{
|
|
GoogleDriveStatic.GetFilesPathTemp();
|
|
GoogleDriveStatic.GetFilesPathTemp();
|
|
GoogleDriveStatic.GetCredentialsPath();
|
|
GoogleDriveStatic.GetCredentialsPath();
|
|
@@ -34,7 +36,7 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
|
|
public async Task<bool> GetHistoryUsers()
|
|
public async Task<bool> GetHistoryUsers()
|
|
{
|
|
{
|
|
var tuples = await GoogleDriveStatic.GetHistoryService();
|
|
var tuples = await GoogleDriveStatic.GetHistoryService();
|
|
- GoogleDriveUsers.Clear();
|
|
|
|
|
|
+ CloudFilesContentViewModel.CloudFileUserLists.Clear();
|
|
foreach (var tuple in tuples)
|
|
foreach (var tuple in tuples)
|
|
{
|
|
{
|
|
|
|
|
|
@@ -44,7 +46,7 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (GoogleDriveUsers.Count > 0)
|
|
|
|
|
|
+ if (CloudFilesContentViewModel.CloudFileUserLists.Count > 0)
|
|
{
|
|
{
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -53,28 +55,59 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
|
|
|
|
|
|
public async void AddGoogleDriveUser(Tuple<DriveService, UserCredential> tuple)
|
|
public async void AddGoogleDriveUser(Tuple<DriveService, UserCredential> tuple)
|
|
{
|
|
{
|
|
- GoogleDriveUserItem userItem = new GoogleDriveUserItem();
|
|
|
|
|
|
+ CloudFileUser cloudFileUser = new CloudFileUser();
|
|
|
|
+ GoogleDriveUserItem userItem = new GoogleDriveUserItem();
|
|
userItem.Service = tuple.Item1;
|
|
userItem.Service = tuple.Item1;
|
|
userItem.CurrentCredential = tuple.Item2;
|
|
userItem.CurrentCredential = tuple.Item2;
|
|
- userItem.User.UserAccount = await userItem.GetUserAcountAsync();
|
|
|
|
- GoogleDriveUsers.Add(userItem);
|
|
|
|
|
|
+ cloudFileUser.driveItem = userItem;
|
|
|
|
+
|
|
|
|
+ User user = new User();
|
|
|
|
+ user.UserAccount = await userItem.GetUserAcountAsync();
|
|
|
|
+ user.cloudType = CloudType.GoogleDrive;
|
|
|
|
+ cloudFileUser.user = user;
|
|
|
|
+
|
|
|
|
+ CloudFilesContentViewModel.CloudFileUserLists.Add(cloudFileUser);
|
|
}
|
|
}
|
|
|
|
|
|
- public async Task<bool> LoginUderCount()
|
|
|
|
|
|
+ public async Task<bool> LoginUserCount()
|
|
{
|
|
{
|
|
- var tuple = await GoogleDriveStatic.GetServiceAsync();
|
|
|
|
-
|
|
|
|
|
|
+ var tuple = await GoogleDriveStatic.GetServiceAsync();
|
|
|
|
+ bool result = false;
|
|
if (tuple != null)
|
|
if (tuple != null)
|
|
{
|
|
{
|
|
|
|
+ result = true;
|
|
|
|
+
|
|
|
|
+ // Task.Run(async () =>
|
|
|
|
+ // {
|
|
|
|
+
|
|
|
|
+ await GetUserInfo(tuple);
|
|
|
|
+ // });
|
|
|
|
|
|
- GoogleDriveUserItem userItem = new GoogleDriveUserItem();
|
|
|
|
- userItem.Service = tuple.Item1;
|
|
|
|
- userItem.CurrentCredential = tuple.Item2;
|
|
|
|
- userItem.User.UserAccount = await userItem.GetUserAcountAsync();
|
|
|
|
- GoogleDriveUsers.Add(userItem);
|
|
|
|
- return true;
|
|
|
|
}
|
|
}
|
|
- return false;
|
|
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public async Task<bool> GetUserInfo(Tuple<DriveService, UserCredential> tuple)
|
|
|
|
+ {
|
|
|
|
+ CloudFileUser cloudFileUser = new CloudFileUser();
|
|
|
|
+ GoogleDriveUserItem userItem = new GoogleDriveUserItem();
|
|
|
|
+ userItem.Service = tuple.Item1;
|
|
|
|
+ userItem.CurrentCredential = tuple.Item2;
|
|
|
|
+ cloudFileUser.driveItem = userItem;
|
|
|
|
+
|
|
|
|
+ User user = new User();
|
|
|
|
+ user.UserAccount = await userItem.GetUserAcountAsync();
|
|
|
|
+ user.cloudType = CloudType.GoogleDrive;
|
|
|
|
+ cloudFileUser.user = user;
|
|
|
|
+
|
|
|
|
+ CloudFilesContentViewModel.CloudFileUserLists.Add(cloudFileUser);
|
|
|
|
+ //GoogleDriveUserItem userItem = new GoogleDriveUserItem();
|
|
|
|
+ //userItem.Service = tuple.Item1;
|
|
|
|
+ //userItem.CurrentCredential = tuple.Item2;
|
|
|
|
+ //userItem.User.UserAccount = await userItem.GetUserAcountAsync();
|
|
|
|
+ //CloudFilesContentViewModel.CloudFileUserLists.Add(userItem);
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
public async Task<bool> RemoveUser(GoogleDriveUserItem userIttem)
|
|
public async Task<bool> RemoveUser(GoogleDriveUserItem userIttem)
|