/// <summary>Get secure user command.</summary> public static CloudMessage NewMessage(CloudAction action, string localRsaPublicKey = null, string remoteRsaPublicKey = null, string username = null, string password = null) { var cmd = new CloudMessage(action); if (!string.IsNullOrEmpty(localRsaPublicKey)) { // Include local RSA public key which will be used by remote side to encrypt reply data. cmd.Values.Add(CloudKey.RsaPublicKey, localRsaPublicKey); } if (!string.IsNullOrEmpty(remoteRsaPublicKey)) { // Use cloud RSA key to generate random AES-256 password inside. cmd.Values.AddRandomPassword(remoteRsaPublicKey); } if (!string.IsNullOrEmpty(username)) { // Add encrypted username. cmd.Values.Add(CloudKey.Username, username, true); } if (!string.IsNullOrEmpty(password)) { // Add encrypted password. cmd.Values.Add(CloudKey.Password, password, true); } return(cmd); }
public void Add(Game[] games, CloudAction action) { for (int i = 0; i < games.Length; i++) { Add(games[i], action); } }
public void Add <T>(CloudAction action, T[] items, Guid[] checksums = null) { var o = SettingsManager.Options; var allow = o.InternetAutoSave; if (!allow) { return; } var message = new CloudMessage(action); // Try to assign list. message.Checksums = checksums; message.UserGames = items as UserGame[]; message.UserSettings = items as UserSetting[]; message.UserDevices = items as UserDevice[]; message.UserComputers = items as UserComputer[]; message.UserInstances = items as UserInstance[]; message.MailMessages = items as MailMessageSerializable[]; var item = new CloudItem() { Date = DateTime.Now, Message = message, State = CloudState.None, }; TasksTimer.DoActionNow(item); }
bool GamesAction <T>(CloudAction action) { var ws = new WebServiceClient(); ws.Url = MainForm.Current.OptionsPanel.InternetDatabaseUrlComboBox.Text; var items = data .Where(x => x.Action == action) .Select(x => x.Item) .OfType <T>() .ToList(); var success = true; // If there is data to submit. if (items.Count > 0) { string result = null; if (typeof(T) == typeof(Game)) { result = ws.SetGames(action, items.Cast <Game>().ToList()); } success = string.IsNullOrEmpty(result); if (!success) { MainForm.Current.SetHeaderBody(MessageBoxIcon.Error, result); } } ws.Dispose(); return(success); }
private void OpenCloud(CloudAction cloudAction) { UpdateCloudStatus(CloudStatus.CloudUpdating); _cloudAction = cloudAction; var savedGameClient = PlayGamesPlatform.Instance.SavedGame; savedGameClient.OpenWithAutomaticConflictResolution(DataFileName, DataSource.ReadCacheOrNetwork, ConflictResolutionStrategy.UseMostRecentlySaved, CloudWasOpenedCallback); }
public void Add(Game game, CloudAction action) { var item = new CloudItem { Action = action, Date = DateTime.Now, Item = game, State = CloudState.None, }; data.Add(item); }
/// <summary> /// Submit changed data to the cloud. /// </summary> Exception Execute <T>(CloudAction action) { var ws = new WebServiceClient(); ws.Url = SettingsManager.Options.InternetDatabaseUrl; CloudMessage result = null; try { var citems = data.Where(x => x.Action == action); var items = citems.Select(x => x.Item).OfType <T>().ToList(); if (items.Count > 0) { // Add security. var o = SettingsManager.Options; var command = CloudHelper.NewMessage(action, o.UserRsaPublicKey, o.CloudRsaPublicKey, o.Username, o.Password); command.Values.Add(CloudKey.HashedDiskId, o.HashedDiskId, true); //// Add secure credentials. //var rsa = new JocysCom.ClassLibrary.Security.Encryption("Cloud"); //if (string.IsNullOrEmpty(rsa.RsaPublicKeyValue)) //{ // var username = rsa.RsaEncrypt("username"); // var password = rsa.RsaEncrypt("password"); // ws.SetCredentials(username, password); //} // Add changes. if (typeof(T) == typeof(UserGame)) { command.UserGames = items as List <UserGame>; } else if (typeof(T) == typeof(UserDevice)) { command.UserControllers = items as List <UserDevice>; } result = ws.Execute(command); if (result.ErrorCode > 0) { queueTimer.ChangeSleepInterval(5 * 60 * 1000); return(new Exception(result.ErrorMessage)); } foreach (var item in citems) { data.Remove(item); } } } catch (Exception ex) { // Sleep for 5 minutes; queueTimer.ChangeSleepInterval(5 * 60 * 1000); return(ex); } return(null); }
private async ValueTask DeprovisionAsync( string projectName, CloudAction cloudAction) { List <string> environments = RetrieveEnvironments(cloudAction); foreach (string environmentName in environments) { await this.cloudManagementService.DeprovisionResouceGroupAsync( projectName, environmentName); } }
/// <summary> /// Submit changed data to the cloud. /// </summary> Exception Execute <T>(CloudAction action) { var ws = new WebServiceClient(); ws.Url = SettingsManager.Options.InternetDatabaseUrl; CloudResults result = null; try { var citems = data.Where(x => x.Action == action); var items = citems.Select(x => x.Item).OfType <T>().ToList(); if (items.Count > 0) { var command = new CloudCommand(); command.Action = action; if (typeof(T) == typeof(UserGame)) { command.UserGames = items as List <UserGame>; } else if (typeof(T) == typeof(UserController)) { command.UserControllers = items as List <UserController>; } // Add secure credentials. var rsa = new JocysCom.ClassLibrary.Security.Encryption("Cloud"); if (string.IsNullOrEmpty(rsa.RsaPublicKeyValue)) { var username = rsa.RsaEncrypt("username"); var password = rsa.RsaEncrypt("password"); ws.SetCredentials(username, password); } result = ws.Execute(command); if (result.ErrorCode > 0) { queueTimer.SleepTimer.Interval = 5 * 60 * 1000; return(new Exception(result.ErrorMessage)); } foreach (var item in citems) { data.Remove(item); } } } catch (Exception ex) { // Sleep for 5 minutes; queueTimer.SleepTimer.Interval = 5 * 60 * 1000; return(ex); } return(null); }
public void Add <T>(CloudAction action, params T[] items) { for (int i = 0; i < items.Length; i++) { var item = new CloudItem { Action = action, Date = DateTime.Now, Item = items[i], State = CloudState.None, }; data.Add(item); } }
void _Add(CloudAction action, object items, Guid[] checksums) { var message = new CloudMessage(action); // Try to assign list. message.Checksums = checksums; message.UserGames = items as UserGame[]; message.UserDevices = items as UserDevice[]; var item = new CloudItem() { Date = DateTime.Now, Message = message, State = CloudState.None, }; queueTimer.DoActionNow(item); }
/// <summary> /// Submit changed data to the cloud. /// </summary> void Execute <T>(CloudAction action) { MainForm.Current.LoadingCircle = true; var ws = new WebServiceClient(); ws.Url = MainForm.Current.OptionsPanel.InternetDatabaseUrlComboBox.Text; CloudResults result = null; try { var items = data.Where(x => x.Action == action).Select(x => x.Item).OfType <T>().ToList(); if (items.Count > 0) { var command = new CloudCommand(); command.Action = action; if (typeof(T) == typeof(Game)) { command.Games = items as List <Game>; } else if (typeof(T) == typeof(UserController)) { command.UserControllers = items as List <UserController>; } // Add secure credentials. var rsa = new JocysCom.ClassLibrary.Security.Encryption("Cloud"); if (string.IsNullOrEmpty(rsa.RsaPublicKeyValue)) { var username = rsa.RsaEncrypt("username"); var password = rsa.RsaEncrypt("password"); ws.SetCredentials(username, password); } result = ws.Execute(command); MainForm.Current.SetHeaderBody(result.ErrorCode == 0 ? MessageBoxIcon.Information : MessageBoxIcon.Error, result.ErrorMessage); } } catch (Exception ex) { var error = ex.Message; if (ex.InnerException != null) { error += "\r\n" + ex.InnerException.Message; } MainForm.Current.SetHeaderBody(MessageBoxIcon.Error, error); } }
private async ValueTask ProvisionAsync( string projectName, CloudAction cloudAction) { List <string> environments = RetrieveEnvironments(cloudAction); foreach (string environmentName in environments) { IResourceGroup resourceGroup = await this.cloudManagementService .ProvisionResourceGroupAsync( projectName, environmentName); IAppServicePlan appServicePlan = await this.cloudManagementService .ProvisionPlanAsync( projectName, environmentName, resourceGroup); ISqlServer sqlServer = await this.cloudManagementService .ProvisionSqlServerAsync( projectName, environmentName, resourceGroup); SqlDatabase sqlDatabase = await this.cloudManagementService .ProvisionSqlDatabaseAsync( projectName, environmentName, sqlServer); IWebApp webApp = await this.cloudManagementService .ProvisionWebAppAsync( projectName, environmentName, sqlDatabase.ConnectionString, resourceGroup, appServicePlan); } }
public void Add <T>(CloudAction action, T[] items, bool split = false, Guid[] checksums = null) { BeginInvoke((MethodInvoker) delegate() { var allow = MainForm.Current.OptionsPanel.InternetAutoSaveCheckBox.Checked; if (!allow) { return; } if (split) { for (int i = 0; i < items.Length; i++) { _Add(action, new T[] { items[i] }, checksums); } } else { _Add(action, items, checksums); } }); }
public void Add <T>(CloudAction action, T[] items = null) { BeginInvoke((MethodInvoker) delegate() { var allow = MainForm.Current.OptionsPanel.InternetAutoSaveCheckBox.Checked; if (!allow) { return; } for (int i = 0; i < items.Length; i++) { var item = new CloudItem() { Action = action, Date = DateTime.Now, Item = items[i], State = CloudState.None, }; data.Add(item); } }); }
public void Add <T>(CloudAction action, T[] items, bool split = false, Guid[] checksums = null) { ControlsHelper.BeginInvoke(() => { var o = SettingsManager.Options; var allow = o.InternetAutoSave; if (!allow) { return; } if (split) { for (int i = 0; i < items.Length; i++) { _Add(action, new T[] { items[i] }, checksums); } } else { _Add(action, items, checksums); } }); }
public string SetGames(CloudAction action, List <Game> games) { return((action == CloudAction.Delete) ? Delete(games) : Upsert(games)); }
public void Run(CloudAction workflow) { this.Run(workflow.Body); }
public void SetGamesAsync(CloudAction action, List <Game> games, object userState = null) { InvokeAsync("SetGames", SetGamesCompleted, userState, new object[] { action, games }); }
public string SetGames(CloudAction action, List <Game> games) { object[] results = Invoke("SetGames", new object[] { action, games }); return((string)results[0]); }
public string SetGames(CloudAction action, List<Game> games) { object[] results = Invoke("SetGames", new object[] { action, games }); return (string)results[0]; }
private static List <string> RetrieveEnvironments(CloudAction cloudAction) => cloudAction?.Environments ?? new List <string>();
public string SetGames(CloudAction action, List<Game> games) { if (action == CloudAction.Delete) { var db = new x360ceModelContainer(); var deleted = 0; for (int i = 0; i < games.Count; i++) { var game = games[i]; var diskDriveId = game.DiskDriveId; var fileName = game.FileName; var currentGame = db.Games.FirstOrDefault(x => x.DiskDriveId == diskDriveId && x.FileName == fileName); if (currentGame == null) continue; db.Games.DeleteObject(currentGame); deleted++; } db.SaveChanges(); db.Dispose(); db = null; return string.Format("{0} game(s) deleted.", deleted); } else { var db = new x360ceModelContainer(); var created = 0; var updated = 0; for (int i = 0; i < games.Count; i++) { var game = games[i]; var diskDriveId = game.DiskDriveId; var fileName = game.FileName; var item = db.Games.FirstOrDefault(x => x.DiskDriveId == diskDriveId && x.FileName == fileName); if (item == null) { created++; item = new Game(); item.GameId = Guid.NewGuid(); db.Games.AddObject(item); item.DateCreated = DateTime.Now; } else { updated++; item.DateUpdated = DateTime.Now; } item.Comment = game.Comment; item.CompanyName = game.CompanyName; item.DInputFile = game.DInputFile; item.DInputMask = game.DInputMask; item.FakePID = game.FakePID; item.FakeVID = game.FakeVID; item.FileName = game.FileName; item.FileProductName = game.FileProductName; item.FileVersion = game.FileVersion; item.FullPath = game.FullPath; item.HookMask = game.HookMask; item.IsEnabled = game.IsEnabled; item.Timeout = game.Timeout; item.Weight = 1; item.XInputMask = game.XInputMask; } db.SaveChanges(); db.Dispose(); db = null; return string.Format("{0} game(s) created, {1} game(s) updated.", created, updated); } }
public void SetGamesAsync(CloudAction action, List<Game> games, object userState = null) { InvokeAsync("SetGames", SetGamesCompleted, userState, new object[] { action, games }); }
public string SetGames(CloudAction action, List <Game> games) { if (action == CloudAction.Delete) { var db = new x360ceModelContainer(); var deleted = 0; for (int i = 0; i < games.Count; i++) { var game = games[i]; var diskDriveId = game.DiskDriveId; var fileName = game.FileName; var currentGame = db.Games.FirstOrDefault(x => x.DiskDriveId == diskDriveId && x.FileName == fileName); if (currentGame == null) { continue; } db.Games.DeleteObject(currentGame); deleted++; } db.SaveChanges(); db.Dispose(); db = null; return(string.Format("{0} game(s) deleted.", deleted)); } else { var db = new x360ceModelContainer(); var created = 0; var updated = 0; for (int i = 0; i < games.Count; i++) { var game = games[i]; var diskDriveId = game.DiskDriveId; var fileName = game.FileName; var item = db.Games.FirstOrDefault(x => x.DiskDriveId == diskDriveId && x.FileName == fileName); if (item == null) { created++; item = new Game(); item.GameId = Guid.NewGuid(); db.Games.AddObject(item); item.DateCreated = DateTime.Now; } else { updated++; item.DateUpdated = DateTime.Now; } item.Comment = game.Comment; item.CompanyName = game.CompanyName; item.DInputFile = game.DInputFile; item.DInputMask = game.DInputMask; item.FakePID = game.FakePID; item.FakeVID = game.FakeVID; item.FileName = game.FileName; item.FileProductName = game.FileProductName; item.FileVersion = game.FileVersion; item.FullPath = game.FullPath; item.HookMask = game.HookMask; item.IsEnabled = game.IsEnabled; item.Timeout = game.Timeout; item.Weight = 1; item.XInputMask = game.XInputMask; } db.SaveChanges(); db.Dispose(); db = null; return(string.Format("{0} game(s) created, {1} game(s) updated.", created, updated)); } }
public CloudMessage(CloudAction action) { Action = action; Values = new KeyValueList(); }