I'm trying to run some scripts in sequence to create and seed my database. However it seems like the second script never gets run. Furthermore, I think it's running the first script twice.
public DatabaseFixture()
{
var connectionString = "Server=localhost;User Id = sa;Password=yourStrong(!)Password;Initial Catalog = master";
var createSchemaSqlScriptOptions = new SqlScriptOptions { ScriptType = ScriptType.RunAlways, RunGroupOrder = 1 };
var seedDataSqlScriptOptions = new SqlScriptOptions { ScriptType = ScriptType.RunAlways, RunGroupOrder = 2 };
var upgradeEngineBuilder = DeployChanges.To.SqlDatabase(connectionString, null)
.WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly(), script => script.Contains("0001"), createSchemaSqlScriptOptions)
.WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly(), script => script.Contains("0002"), createSchemaSqlScriptOptions)
.LogToConsole();
var upgrader = upgradeEngineBuilder.Build();
var result = upgrader.PerformUpgrade();
}
Also, all my scripts are embedded sources so I don't think it's that.
Hi, your code shows a object createSchemaSqlScriptOptions duplicate in method WithScriptsEmbeddedInAssembly .
Give it a check.
Related
I'm working on integrating Nethereum into my .NET 5 C# API and can do read queries against my chosen blockchain (BSC), but cannot get a SendTransactionAsync or SendRequestAsync to successfully execute. I'm consistently getting the following exception:
Nethereum.JsonRpc.Client.RpcResponseException: 'transaction type not supported: eth_sendRawTransaction'.
Here are code snippets of what I have tried:
// Setup
var account = new Account(privateKey, chainId);
var rpcUrl = "https://data-seed-prebsc-2-s2.binance.org:8545/";
var client = new RpcClient(new Uri(rpcUrl));
var web3 = new Web3(account, client);
var mediaTokenAddress = "0x1E4d1BFDa5d55C2176E9E3e8367BAe720525a8e0";
var mtSvc = new MediaTokenService(web3, mediaTokenAddress);
var mintMsg = new MintNftFunction
{
FromAddress = account.Address,
Recipient = "REDACTED",
MetadataHash = "TestMetaDataHash",
MediaHash = "TestMediaHash",
SeasonId = 1
};
// Attempt #1: Using C# classes generated by the Nethereum CodeGen library
var txReceipt = await mtSvc.MintNftRequestAndWaitForReceiptAsync(mintMsg);
// Attempt #2
var txHandler = web3.Eth.GetContractTransactionHandler<MintNftFunction>();
var signedTx = await txHandler.SignTransactionAsync(mediaTokenAddress, mintMsg);
var txReceipt = await web3.Eth.Transactions.SendTransaction.SendRequestAsync(signedTx);
// Attempt #3
var txInput = mintMsg.CreateTransactionInput(mediaTokenAddress);
var txReceipt = await web3.Eth.TransactionManager.SendTransactionAsync(txInput);
Is there a configuration step I'm missing? Any help is appreciated!
EDIT: I want to call a contract method that will change values within the contract, rather than sending currency. So I need help figuring out how to do that.
For those that come across this issue, I resolved it by setting the following flag on my web3 instance:
web3.TransactionManager.UseLegacyAsDefault = true;
If there is a way to do what I need without setting this flag, please feel free to leave a comment.
Here is an example of how I do this with Nethereum
var web3 = new Nethereum.Web3.Web3("YOUR_NODE_ADDRESS");
var privateKey = "someprivatekey";
var senderAddress = "0x..."; // put actual sender address
var receiveAddress = "0x..."; //put actual receiver address
var txCount = await web3.Eth.Transactions.GetTransactionCount.SendRequestAsync(senderAddress);
double sendAmount = 5.09540000; //this is ETH
var amountInWei = Web3.Convert.ToWei(sendAmount);
//600 GWEI = 0.000000600
//60 GWEI = 0.000000060
var gwei = 147; // this is 0.000000147 ETH. You will want to calculate this based on network fees
var gasPrice = Web3.Convert.ToWei(0.000000001 * gwei);
var gasLimit = Web3.Convert.ToWei(0.000000000000021);
var encoded = Web3.OfflineTransactionSigner.SignTransaction(privateKey, receiveAddress, amountInWei, txCount.Value, gasPrice, gasLimit);
//This is what prompts the transactions
Web3.OfflineTransactionSigner.GetSenderAddress(encoded).Dump();
//TX Returns from this action
var txId = await web3.Eth.Transactions.SendRawTransaction.SendRequestAsync("0x" + encoded);
//Dump out the TX if successful
txId.Dump();
I've used this many times and it has worked for me just fine.
I'm having trouble with my cloud deployment script for AWS, I've been trying to create a rule that triggers my lambda every 15 minutes and invoke it with a json object. If i were to do this from the console i'd do it like this:
After a long time i figured out how to configure this in code:
var functionInput = new { Command = command };
var input = JsonConvert.SerializeObject(functionInput);
var target = new LambdaFunction(lambda, new LambdaFunctionProps
{
Event = RuleTargetInput.FromObject(input)
});
Or like this:
var target = new LambdaFunction(lambda, new LambdaFunctionProps
{
Event = RuleTargetInput.FromText("{\"Command\" = \"" + command + "\"}")
});
But the constant is not correct on aws, i have tried many different ways but it always turns out like this:
This is not correct Json and can't be parsed back to the class, so I want it to turn out like:
{"Command" = "CLEANUP"}
var inputDict = new Dictionary<string, string>();
inputDict.Add("Command", "CleanUp");
myRule.AddTarget(new Amazon.CDK.AWS.Events.Targets.LambdaFunction(myFunction,
new Amazon.CDK.AWS.Events.Targets.LambdaFunctionProps
{
Event = RuleTargetInput.FromObject(inputDict)
}));
I came here looking for the Python equivalent for the same. Figured out finally - Hope someone find this helpful
from aws_cdk import aws_events as events
from aws_cdk import aws_lambda as lambda_
event_input = {"some_key": "some_value"}
some_lambda = lambda_.Function(
# lambda construct
)
some_rule = events.Rule(
# rule construct
)
some_rule.add_target(
targets.LambdaFunction(
some_lambda,
event=events.RuleTargetInput.from_object(event_input)
)
)
I'm able to update test result to testcase in VSTS through program.
Test Case Result Updation
Now, i want to update the result of each test step in test case. Couldn't find any related info. Please help
The simple way is using client API:
Simple sample:
int testpointid = 176;
var u = new Uri("https://[account].visualstudio.com");
VssCredentials c = new VssCredentials(new Microsoft.VisualStudio.Services.Common.VssBasicCredential(string.Empty, "[pat]"));
TfsTeamProjectCollection _tfs = new TfsTeamProjectCollection(u, c);
ITestManagementService test_service = (ITestManagementService)_tfs.GetService(typeof(ITestManagementService));
ITestManagementTeamProject _testproject = test_service.GetTeamProject("scrum2015");
ITestPlan _plan = _testproject.TestPlans.Find(115);
ITestRun testRun = _plan.CreateTestRun(false);
testRun.Title = "apiTest";
ITestPoint point = _plan.FindTestPoint(testpointid);
testRun.AddTestPoint(point, test_service.AuthorizedIdentity);
testRun.Save();
testRun.Refresh();
ITestCaseResultCollection results = testRun.QueryResults();
ITestIterationResult iterationResult;
foreach (ITestCaseResult result in results)
{
iterationResult = result.CreateIteration(1);
foreach (Microsoft.TeamFoundation.TestManagement.Client.ITestStep testStep in result.GetTestCase().Actions)
{
ITestStepResult stepResult = iterationResult.CreateStepResult(testStep.Id);
stepResult.Outcome = Microsoft.TeamFoundation.TestManagement.Client.TestOutcome.Passed; //you can assign different states here
iterationResult.Actions.Add(stepResult);
}
iterationResult.Outcome = Microsoft.TeamFoundation.TestManagement.Client.TestOutcome.Passed;
result.Iterations.Add(iterationResult);
result.Outcome = Microsoft.TeamFoundation.TestManagement.Client.TestOutcome.Passed;
result.State = TestResultState.Completed;
result.Save(true);
}
testRun.State = Microsoft.TeamFoundation.TestManagement.Client.TestRunState.Completed;
results.Save(true);
Regarding REST api, the necessary information is stored in actionResults of iterationDetails (TestCaseResult.IterationDetails), you can try specify IterationDetails to TestCaseResult and update test result.
You can check the details of a test result by using Get a Test Result with DetailInclude (detailsToInclude=Iterations)
I try to create a new EPT (project server 2013) using C# CSOM library.
But It has following error occurred.
"PJClientCallableException: EnterpriseProjectTypeInvalidCreatePDPUid"
Couple of article tell to change the "IsCreate=true". But it does not success for me. Here is the code what I have done.
public void CreateEnterpriseProjectType(Guid eptGuid, string eptName, string eptDescription)
{
ProjectContext pwaContext = new ProjectContext(this.PWA_URL);
EnterpriseProjectTypeCreationInformation eptData = new EnterpriseProjectTypeCreationInformation();
eptData.Id = eptGuid;
eptData.Name = eptName;
eptData.Description = eptDescription;
eptData.IsDefault = false;
eptData.IsManaged = true;
eptData.WorkspaceTemplateName = "PROJECTSITE#0";
eptData.ProjectPlanTemplateId = Guid.Empty;
eptData.WorkflowAssociationId = Guid.Empty;
eptData.Order = 4;
List<ProjectDetailPageCreationInformation> projectDetailPages = new
List<ProjectDetailPageCreationInformation>() {
new ProjectDetailPageCreationInformation() {
Id = pwaContext.ProjectDetailPages[1].Id, IsCreate = true }
};
eptData.ProjectDetailPages = projectDetailPages;
pwaContext.Load(pwaContext.EnterpriseProjectTypes);
pwaContext.ExecuteQuery();
EnterpriseProjectType newEpt = pwaContext.EnterpriseProjectTypes.Add(eptData);
pwaContext.EnterpriseProjectTypes.Update();
pwaContext.ExecuteQuery();
}
Can anyone explain the issue or provide the working code part.
I would like to suggest the following:
Define an enterprise project type:
string basicEpt = "Enterprise Project"; // Basic enterprise project type.
int timeoutSeconds = 10; // The maximum wait time for a queue job, in seconds.
And then, when you create the new project, work like this:
ProjectCreationInformation newProj = new ProjectCreationInformation();
newProj.Id = Guid.NewGuid();
newProj.Name = "Project Name";
newProj.Description = "Test creating a project with CSOM";
newProj.Start = DateTime.Today.Date;
// Setting the EPT GUID is optional. If no EPT is specified, Project Server
// uses the default EPT.
newProj.EnterpriseProjectTypeId = GetEptUid(basicEpt);
PublishedProject newPublishedProj = projContext.Projects.Add(newProj);
QueueJob qJob = projContext.Projects.Update();
// Calling Load and ExecuteQuery for the queue job is optional.
// projContext.Load(qJob);
// projContext.ExecuteQuery();
JobState jobState = projContext.WaitForQueue(qJob, timeoutSeconds);
When the last line of that piece of code ends, the project must be created and published in order to define tasks or whatever.
I don't know what is happening to your code, seems great.
Hope it helps to you,
I created a database with SQLite-net so:
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, "Database.db"), true);
await conn.CreateTableAsync<Musei>();
Musei musPref;
if (muss.NumeroTel != null && muss.Descrizione!=null && muss.indirizzoEmail!= null && muss.Immagine!= null)
{
musPref = new Musei
{
DidascaliaLista=muss.DidascaliaLista,
NomeMuseo = muss.NomeMuseo,
Luogopreciso = muss.Luogopreciso,
Descrizione = muss.Descrizione,
NumeroTel = muss.NumeroTel,
IndirizzoEmail = muss.IndirizzoEmail,
Immagine= muss.Immagine,
};
}
await conn.InsertAsync(musPref);
In another project I need to recover the database created and insert objects inside a ListView, But I do not know how to proceed ..
try
{
StorageFile data = await ApplicationData.Current.LocalFolder.GetFileAsync("Database.db");
}
catch(Exception)
{
}
And now??
I would like to retrieve the database created above and use it, inserting objects "Musei" that are in it and display it in a ListView
If you want to read from the database you created earlier, you can do the following:
// Get a connection to the database that is in the local folder.
var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "Database.db");
var con = new SQLiteAsyncConnection(dbPath, true);
// Get all "Musei" in the database stored in the "Musei" table.
var results = await con.QueryAsync<Musei>("SELECT * FROM Musei");
If you only want the Musei that match a certain field value, for example: you only want to read those in the specific location "Rome", you can do that like this:
var searchLocation = "Rome"; // for example entered by the user in your UI.
// Get only the "Musei" in `searchLocation`.
var results = await con.QueryAsync<Musei>("SELECT * FROM Musei WHERE Luogopreciso ='?'", searchLocation);
An alternative, if you are only querying a single table, is to do it like this, using LINQ:
var query = con.Table<Musei>();
// or, if looking for `searchLocation`:
var query = con.Table<Musei>().Where(m => m.Luogopreciso == "Rome");
you can then get this as a list using:
var result = await query.ToListAsync();
To find out which tables are actually present in your opened database files, you can do this:
var nTables = 0;
System.Diagnostics.Debug.WriteLine("Tables in the database");
foreach (var mapping in con.TableMappings)
{
System.Diagnostics.Debug.WriteLine(mapping.TableName);
nTables++;
}
System.Diagnostics.Debug.WriteLine("{0} tables in total", nTables);
and look at the debug output.