Hi i have created a an xml test case in bizunit 4.0 called test1.xml
The problem I have is how to run the test. All the examples i find are for bizunit 2.0 and 3.0, but not for 4.0. In the examples i found it says to do this:
BizUnit.BizUnit bizUnit = new BizUnit.BizUnit("testl.xml");
bizUnit.RunTest();
but i get a note saying it is deprecated.
I'm using .net unit tests and calling bizunit from code
Here's an example
// create list of files
TestGeneratedFiles = new System.Collections.Generic.List<String>();
var TestCase = new BizUnit.Xaml.TestCase { Name = "Interface128UnitTestSetup" };
//Create the file validate step
var testStep = new FileReadMultipleStep
{
DirectoryPath = inputPath,
SearchPattern = InputTemplate,
ExpectedNumberOfFiles = 1,
Timeout = 3000,
DeleteFiles = false
};
//Create an XML Validation step
//This will check against the XSD for the document
var validation = new XmlValidationStep();
var schemaSummary = new SchemaDefinition
{
// test deployment copies this file to test directory
XmlSchemaPath = #"Publish_Employee.xsd",
XmlSchemaNameSpace = "http://AMC.Oracle.Employee"
};
validation.XmlSchemas.Add(schemaSummary);
TestCase.ExecutionSteps.Add(testStep);
// run the test case
var bizUnit = new BizUnit.BizUnit(TestCase);
bizUnit.RunTest();
For me this worked (w/o warning):
TestCase tc = TestCase.LoadFromFile("test1.xml");
BizUnit.BizUnit bizUnit = new BizUnit.BizUnit(tc);
bizUnit.RunTest();
Related
I am new in using Npgsql and I tried to make an helper in my asp.net project so that I can call it conveniently in my controllers method.
npgsqlqueryhelper
public DataSet ExecuteQueryWithParams(string commandText, params NpgsqlParameter[] parameters)
{
using (var connection = npgsqlcon.GetnpgsqlConnection())
using (NpgsqlCommand command = new NpgsqlCommand(commandText, connection))
{
DataSet ds = new DataSet();
command.Parameters.AddRange(parameters);
command.CommandTimeout = 5000;
NpgsqlDataAdapter da = new NpgsqlDataAdapter(command);
da.Fill(ds);
connection.Close();
return ds;
}
}
My Controller Method
List<rollingPAR> rollingparlist = new List<rollingPAR>();
npgsqlhelper = new npgsqlQueryHelper();
NpgsqlParameter[] parameterList = {
new NpgsqlParameter("#lid", r.lid),
new NpgsqlParameter("#posting_date", r.date_end)
};
var table = npgsqlhelper.ExecuteQueryWithParams("SELECT ln.get_payment_status()", parameterList).Tables[0];
rollingparlist = table.AsEnumerable().Select(row => new rollingPAR
{
get_payment_status = row.Field<int>("get_payment_status")
}).ToList();
As I tried to run my program, I always encountered an error saying that function ln.get_payment_status() does not exist but when I tried to supply the parameters directly on the query
(e.g var table = npgsqlhelper.ExecuteQueryWithParams("SELECT ln.get_payment_status(1231,'06-18-2019')", parameterList).Tables[0];)
It gives me the data that I need. I don't know what is my mistake and I'm stuck here since yesterday. Can anyone help me with this? TIA
The parameter place holders are not automatically included in the function call. Try adding them:
var table = npgsqlhelper.ExecuteQueryWithParams("SELECT ln.get_payment_status(#lid,#posting_date)", parameterList).Tables[0];
With the help of Sir #JGH, it turns out that my query is missing the parameter placeholders but after I edit it, I encountered an error regarding the datatype between the asp.net datetime and postgresql date so I added this code to remove the error.
parameterList[1].NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Date;
So here is now the new code:
List<rollingPAR> rollingparlist = new List<rollingPAR>();
npgsqlhelper = new npgsqlQueryHelper();
NpgsqlParameter[] parameterList = {
new NpgsqlParameter("#lid", r.lid),
new NpgsqlParameter("#posting_date", r.date_end)
};
parameterList[1].NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Date;
var table = npgsqlhelper.ExecuteQueryWithParams("SELECT ln.get_payment_status(#lid,#posting_date)", parameterList).Tables[0];
rollingparlist = table.AsEnumerable().Select(row => new rollingPAR
{
get_payment_status = row.Field<int?>("get_payment_status")
}).ToList();
Thank you sir #JGH
I'm building a small library that use Application Insights.
Is there a possibility Application Insights working without ApplicationInsights.config file?
I tried remove and add the modules manually at constructor, but it didn't work.
Edited
I did something like that:
dependencies = new DependencyTrackingTelemetryModule();
dependencies.Initialize(configuration);
exceptionTelemetryModule = new UnhandledExceptionTelemetryModule();
exceptionTelemetryModule.Initialize(configuration);
unobservedExceptionTelemetry = new UnobservedExceptionTelemetryModule();
unobservedExceptionTelemetry.Initialize(configuration);
serverTelemetryChannel = new ServerTelemetryChannel();
serverTelemetryChannel.DeveloperMode = true;
serverTelemetryChannel.Initialize(configuration);
azureInstanceMetadataTelemetry = new AzureInstanceMetadataTelemetryModule();
azureInstanceMetadataTelemetry.Initialize(configuration);
var developer = new DeveloperModeWithDebuggerAttachedTelemetryModule();
developer.Initialize(configuration);
configuration.TelemetryInitializers.Add(new OperationCorrelationTelemetryInitializer());
client = new TelemetryClient(configuration);
A minimalistic setup can be done like this.
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DependencyCollector;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel;
..
..
..
private static void setupApplicationInsights()
{
// Setup Channel, Initializers, and Sampling
// Nugets Required: "Microsoft.ApplicationInsights", "Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel"
var channel = new ServerTelemetryChannel();
var config = TelemetryConfiguration.Active;
config.InstrumentationKey = "putikey";
channel.Initialize(config);
TelemetryConfiguration.Active.TelemetryChannel = channel;
//Setup TelemetryInitializers...
config.TelemetryInitializers.Add(new OperationCorrelationTelemetryInitializer());
//Setup Sampling
config.TelemetryProcessorChainBuilder.UseAdaptiveSampling();
// Setup modules...
// Nugets : Microsoft.ApplicationInsights.DependencyCollector
DependencyTrackingTelemetryModule dep = new DependencyTrackingTelemetryModule();
dep.Initialize(config);
}
I need to run workflow XAML, but that workflow keeps references to other XAMLs. When I'm trying to run the workflow by
ActivityXamlServicesSettings settings = new ActivityXamlServicesSettings
{
CompileExpressions = true
};
return ActivityXamlServices.Load(stream, settings);
I get next error from Load method:
CacheMetadata for activity 'MyNamespace.MyMainActivity' threw 'System.Xaml.XamlObjectWriterException: Cannot create unknown type '{clr-namespace:MyNamespace}MyNestedActivity'.
How can I solve it?
I think you have to convert your internal xamls to dll (assembly) file. And load the assembly file while reading/loading the parent xaml.
System.Xaml.XamlXmlReaderSettings xmlsettings = new System.Xaml.XamlXmlReaderSettings();
if(dllFile != null) {
Assembly wfAssembly = Assembly.Load(dllFile);
xmlsettings.LocalAssembly = wfAssembly;
}
System.IO.StringReader stringReader = new System.IO.StringReader(xaml);
XamlXmlReader reader = new XamlXmlReader(stringReader, xmlsettings);
ActivityXamlServicesSettings settings = new ActivityXamlServicesSettings { CompileExpressions = true };
Activity activity = System.Activities.XamlIntegration.ActivityXamlServices.Load(reader, settings);
hope this helps.
I want to get the program names installed from Windows Store(client side). Heres my code. First of all is it possible? Secondly if yes why my code is not working?
StringBuilder stringBuilder = new StringBuilder();
var shell = PowerShell.Create();
// Add the script to the PowerShell object
shell.Commands.AddScript("Import-Module Appx");
shell.Commands.AddScript("Get-AppxPackage ");
Command c = new Command("Out-String");
c.Parameters.Add("width", 150);
shell.Commands.AddCommand(c);
// var results = shell.Invoke();
Collection<PSObject> results = shell.Invoke();
foreach (PSObject obj in results)
{
stringBuilder.AppendLine(obj.ToString());
}
No results returned (Only one and it is empty . )
Well my situation is like this:
I am generating a report as a text file at the server which needs to be printed using DOS mode on a dot matrix printer. I want to avoid Windows printing because it would be too slow. Is there a way in ASP.NET through which I can carry out DOS based printing as it is best suited for Dot matrix printers. I have scoured the net but could not come across any solution or pointers. Does any body have any pointers/solutions which they might have implemented or stumbled across.
This application is a Web based application.
Thanx.
If I understand you right, one option is to execute a batch file that would do the actual printing from ASP.NET. From here: (Obviously, you can omit some of the code writing the output to the page)
// Get the full file path
string strFilePath = “c:\\temp\\test.bat”;
// Create the ProcessInfo object
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("cmd.exe");
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.RedirectStandardInput = true;
psi.RedirectStandardError = true;
psi.WorkingDirectory = “c:\\temp\\“;
// Start the process
System.Diagnostics.Process proc = System.Diagnostics.Process.Start(psi);
// Open the batch file for reading
System.IO.StreamReader strm = System.IO.File.OpenText(strFilePath);
// Attach the output for reading
System.IO.StreamReader sOut = proc.StandardOutput;
// Attach the in for writing
System.IO.StreamWriter sIn = proc.StandardInput;
// Write each line of the batch file to standard input
while(strm.Peek() != -1)
{
sIn.WriteLine(strm.ReadLine());
}
strm.Close();
// Exit CMD.EXE
string stEchoFmt = "# {0} run successfully. Exiting";
sIn.WriteLine(String.Format(stEchoFmt, strFilePath));
sIn.WriteLine("EXIT");
// Close the process
proc.Close();
// Read the sOut to a string.
string results = sOut.ReadToEnd().Trim();
// Close the io Streams;
sIn.Close();
sOut.Close();
// Write out the results.
string fmtStdOut = "<font face=courier size=0>{0}</font>";
this.Response.Write(String.Format(fmtStdOut,results.Replace(System.Environment.NewLine, "<br>")));
The answer from BobbyShaftoe is correct. Here's a pedantic version of it:
public static void CreateProcess(string strFilePath)
{
// Create the ProcessInfo object
var psi = new ProcessStartInfo("cmd.exe")
{
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardInput = true,
RedirectStandardError = true,
WorkingDirectory = "c:\\temp\\"
};
// Start the process
using (var proc = Process.Start(psi))
{
// Attach the in for writing
var sIn = proc.StandardInput;
using (var strm = File.OpenText(strFilePath))
{
// Write each line of the batch file to standard input
while (strm.Peek() != -1)
{
sIn.WriteLine(strm.ReadLine());
}
}
// Exit CMD.EXE
sIn.WriteLine(String.Format("# {0} run successfully. Exiting", strFilePath));
sIn.WriteLine("EXIT");
// Read the sOut to a string.
var results = proc.StandardOutput.ReadToEnd().Trim();
// Write out the results.
string fmtStdOut = "<font face=courier size=0>{0}</font>";
this.Response.Write(String.Format(fmtStdOut,results.Replace(System.Environment.NewLine, "<br>")));
}
}