public StorageRepository(string connectionString, IRepositoryCruid commandFactory) { ConnectionString = connectionString; CommandFactory = commandFactory; CommandFactory.SetRepository(this); Online = new GDriveManager(); }
static void Main(string[] args) { Thread.CurrentThread.CurrentCulture = new CultureInfo("es-ES"); // CHARACTERS List <string> charactersAndUpgradesStrings = new List <string>(); ListFeed list = GDriveManager.GetSpreadsheet(DriveUrl, 1); foreach (ListEntry row in list.Entries) { string name = row.Elements[0].Value; float multiplier = float.Parse(row.Elements[1].Value); int health = int.Parse(row.Elements[2].Value); int klid = int.Parse(row.Elements[3].Value); float klidRegen = float.Parse(row.Elements[4].Value); float speed = float.Parse(row.Elements[5].Value); float whoaPower = float.Parse(row.Elements[6].Value); float mass = float.Parse(row.Elements[7].Value); int spellSlots = int.Parse(row.Elements[8].Value); int price = int.Parse(row.Elements[9].Value); charactersAndUpgradesStrings.Add(String.Format("\n\n//{0}\nWhoaCharacter {0} = new WhoaCharacter({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9});\ncharacters.Add({0});", name, multiplier, health, whoaPower, speed, mass, klid, klidRegen, spellSlots, price)); } ListFeed upgradesList = GDriveManager.GetSpreadsheet(WhoaPlayerProperties.DRIVE_DOCUMENT_URL, 2); foreach (ListEntry row in upgradesList.Entries) { int id = int.Parse(row.Elements[0].Value); if (id == -1) { upgrade.Effects.Add(parseEffect(row)); } else { currentlyUpgradedCharacter = characters[id]; string name = row.Elements[1].Value; int maxLevel = int.Parse(row.Elements[2].Value); int basePrice = int.Parse(row.Elements[3].Value); float priceMultiplier = float.Parse(row.Elements[4].Value); upgrade = new CharacterUpgrade(name, maxLevel, basePrice, priceMultiplier); upgrade.Effects.Add(parseEffect(row)); currentlyUpgradedCharacter.AddUpgrade(upgrade); } } ReplaceAutoGenerated(WhoaScriptsFolderPath + "WHOATESTING.txt", charactersAndUpgradesStrings); // Keep the console window open in debug mode. Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
private void SharePublicKey(string emailToShare) { var publicKeyPath = UserCryptor.GetPublicKeyPath(_authorizationForm._userId); if (!File.Exists(publicKeyPath)) { _authorizationForm._userCryptor.SavePublicKey(); } GDriveManager.ShareFile(publicKeyPath, emailToShare, _authorizationForm._userInfo.Name); }
public CloudModel() { Managers = new List<ICloudManager>(); ICloudManager dm = new GDriveManager(); Managers.Add(dm); foreach (var Manager in Managers) { Manager.Connect(); } }
public CloudModel() { Managers = new List <ICloudManager>(); ICloudManager dm = new GDriveManager(); Managers.Add(dm); foreach (var Manager in Managers) { Manager.Connect(); } }
private void button4_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog(); ofd.InitialDirectory = _directoryPath; ofd.Filter = "All Files(*.*) | *.*"; ofd.FilterIndex = 1; if (ofd.ShowDialog() == DialogResult.OK) { var filenameWithoutPath = Path.GetFileName(ofd.FileName); var file = GDriveManager.UploadFile(ofd.FileName, filenameWithoutPath); } }
private void SynchronizeFolder(string folderPath) { PrepareFolderStructure(folderPath); _directoryPath = folderPath; GDriveManager.LocalFolderPath = _directoryPath; GDriveManager.SyncNewFiles(); GDriveManager.SyncFiles(); GDriveManager.SyncNewUserKeys(); GDriveManager.SyncUserKeys(); GetFiles(); RefreshDirectoryList(); DirectoryWatcherCreate(); }
public void UploadFile(string FilePath, string dirPath) { if (System.IO.File.Exists(FilePath)) { var File = GetFileByPath(dirPath); if (File != null && File.MimeType.Equals("application/vnd.google-apps.folder")) { Google.Apis.Drive.v2.Data.File body = new Google.Apis.Drive.v2.Data.File(); body.Title = System.IO.Path.GetFileName(FilePath); body.Description = "File uploaded by Drive Test"; body.MimeType = GDriveManager.GetMimeType(FilePath); body.Parents = new List <ParentReference>() { new ParentReference() { Id = File.Id } }; byte[] FileBytes = System.IO.File.ReadAllBytes(FilePath); System.IO.MemoryStream stream = new System.IO.MemoryStream(FileBytes); try { FilesResource.InsertMediaUpload request = service.Files.Insert(body, stream, body.MimeType); request.Upload(); Google.Apis.Drive.v2.Data.File res = request.ResponseBody; } catch (Exception e) { throw new Exception("An error occurred: " + e.Message); } } else { throw new Exception("Upload destination not found"); } } else { throw new Exception("File not found"); } }
private void share_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog(); ofd.InitialDirectory = _directoryPath; ofd.Filter = "All Files(*.*) | *.*"; ofd.FilterIndex = 1; if (ofd.ShowDialog() == DialogResult.OK) { var emailToShare = emailInput.Text; if (!IsValidEmail(emailToShare)) { MessageBox.Show("Invalid email address!", "Drive Crypt", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } GDriveManager.ShareFile(ofd.FileName, emailToShare, _authorizationForm._userInfo.Name); var userId = Base64Utils.EncodeBase64(emailToShare); var shareKeyCryptor = new UserCryptor(userId); var keyFilePath = GetUserKeysFolder() + Path.DirectorySeparatorChar + userId + UserCryptor.PUB_KEY_EXTENSION; if (File.Exists(keyFilePath)) { shareKeyCryptor.LoadPublicKey(keyFilePath); } else { MessageBox.Show("The requested user did not share his keys with you yet!", "Drive Crypt", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } var keyFilename = FileCryptor.PrepareKeyForSharing(ofd.FileName, _authorizationForm._userCryptor, shareKeyCryptor); var keyFilenameWithoutPath = Path.GetFileName(keyFilename); GDriveManager.UploadFile(keyFilename, keyFilenameWithoutPath); GDriveManager.ShareFile(keyFilename, emailToShare, _authorizationForm._userInfo.Name); } }
private void shareToolStripMenuItem_Click(object sender, EventArgs e) { if (FolderList.SelectedNode != null) { TreeNode SelectedNode = FolderList.SelectedNode; string FilePath = SelectedNode.Tag.ToString(); var emailToShare = emailInput.Text; if (!IsValidEmail(emailToShare)) { MessageBox.Show("Invalid email address!", "Drive Crypt", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } GDriveManager.ShareFile(FilePath, emailToShare, _authorizationForm._userInfo.Name); var userId = Base64Utils.EncodeBase64(emailToShare); var shareKeyCryptor = new UserCryptor(userId); var keyFilePath = GetUserKeysFolder() + Path.DirectorySeparatorChar + userId + UserCryptor.PUB_KEY_EXTENSION; if (File.Exists(keyFilePath)) { shareKeyCryptor.LoadPublicKey(keyFilePath); } else { MessageBox.Show("The requested user did not share his keys with you yet!", "Drive Crypt", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } var keyFilename = FileCryptor.PrepareKeyForSharing(FilePath, _authorizationForm._userCryptor, shareKeyCryptor); var keyFilenameWithoutPath = Path.GetFileName(keyFilename); GDriveManager.UploadFile(keyFilename, keyFilenameWithoutPath); GDriveManager.ShareFile(keyFilename, emailToShare, _authorizationForm._userInfo.Name); } }