public void ApplyPendingScripts(SqlConnection connection, IMigratorConfiguration configuration, IEnumerable <PendingItem> scripts) { foreach (var updateScript in scripts) { ClasspathScripts.Add(updateScript); AppliedItem appliedScript = new AppliedItem { Type = updateScript.Type, Executed = DateTime.Now, Name = updateScript.Name, Version = updateScript.Version, Checksum = updateScript.Checksum }; if (updateScript.Type == ItemType.Repeatable) { AppliedItem oldItem = DbItems.FirstOrDefault(s => Equals(updateScript.Version, s.Version)); if (oldItem != null) { DbItems.Remove(oldItem); } } DbItems.Add(appliedScript); AppliedItems.Add(appliedScript); Log.InfoFormat("Running script {0} with version {1}", updateScript.Name, updateScript.Version); } }
public void Update(AppliedItem update) { _wrappedData = update; OnPropertyChanged(nameof(ItemId)); OnPropertyChanged(nameof(ItemType)); OnPropertyChanged(nameof(AppliedMs)); OnPropertyChanged(nameof(ExpireMs)); OnPropertyChanged(nameof(MaxSeconds)); OnPropertyChanged(nameof(RemainingMs)); OnPropertyChanged(nameof(RemainingSeconds)); OnPropertyChanged(nameof(RemainingTime)); }
public AppliedItem GetAppliedScript(SqlConnection connection, SqlTransaction tx, IMigratorConfiguration configuration, PendingItem script) { AppliedItem result = null; using (var command = new SqlCommand(string.Format(SelectSingleFromSchemaVersionSql, configuration.SchemaVersionTable), connection, tx)) { command.CommandTimeout = configuration.CommandTimeout; command.Parameters.Add(new SqlParameter("Version", script.Version)); using (var reader = command.ExecuteReader()) { while (reader.Read()) { result = BuildAppliedScript(reader); } } } return(result); }
private void AskAndUseLuckyEgg(ItemDataWrapper item) { if (!GameClient.IsXpBoostActive) { var dialog = new PoGoMessageDialog("", string.Format(Resources.CodeResources.GetString("ItemUseQuestionText"), Resources.Items.GetString(item.ItemId.ToString()))); dialog.AcceptText = Resources.CodeResources.GetString("YesText"); dialog.CancelText = Resources.CodeResources.GetString("CancelText"); dialog.CoverBackground = true; dialog.AnimationType = PoGoMessageDialogAnimation.Bottom; dialog.AcceptInvoked += async(sender, e) => { // Send use request var res = await GameClient.UseXpBoost(item.ItemId); switch (res.Result) { case UseItemXpBoostResponse.Types.Result.Success: AppliedItem appliedItem = res.AppliedItems.Item.FirstOrDefault <AppliedItem>(); GameClient.AppliedItems.Add(new AppliedItemWrapper(appliedItem)); ReturnToGameScreen.Execute(); break; case UseItemXpBoostResponse.Types.Result.ErrorXpBoostAlreadyActive: ReturnToGameScreen.Execute(); break; case UseItemXpBoostResponse.Types.Result.ErrorInvalidItemType: case UseItemXpBoostResponse.Types.Result.ErrorLocationUnset: case UseItemXpBoostResponse.Types.Result.ErrorNoItemsRemaining: case UseItemXpBoostResponse.Types.Result.Unset: break; default: throw new ArgumentOutOfRangeException(); } }; dialog.Show(); } }
private void RunScript(SqlConnection connection, SqlTransaction tx, IMigratorConfiguration configuration, PendingItem script) { Log.DebugFormat(script.Type == ItemType.Versioned ? "Applying script {0}" : "Reapplying script {0}", script.Name); AppliedItem appliedScript = GetAppliedScript(connection, tx, configuration, script); if (appliedScript != null && appliedScript.Type == ItemType.Versioned) { Log.Debug("Script already applied, skipping."); return; } foreach (var scriptItem in new ScriptSplitter(script.Content.ToString())) { try { using (var command = new SqlCommand(scriptItem, connection, tx)) { command.CommandTimeout = configuration.CommandTimeout; command.ExecuteNonQuery(); } } catch (SqlException) { Log.Error("Error while running script:\n" + scriptItem); throw; } } if (appliedScript == null) { InsertIntoSchemaVersion(connection, tx, configuration, script); } else { UpdateSchemaVersion(connection, tx, configuration, script); } }
public AppliedItemWrapper(AppliedItem appliedItem) { _wrappedData = appliedItem; }