how to pass arguments in EMR job to use in bootstrap script - c#

I have a bootstrap script which runs with my EMR job.
I need to pass a parameter to this script so I can configure a path for different environments
The following line in my script needs to use it
path=OVA/{EnvironmentName}/Scripts/UniqueUsers
I am using C# to invoke a streaming EMR job. how do I pass this argument while I create the job?
HadoopJarStepConfig config = new StreamingStep()
.WithInputs(input)
.WithOutput(output)
.WithMapper(configMapperLocation)
.WithReducer(configReducerLocation)
.ToHadoopJarStepConfig();
string configName = string.Format("Unique_Users_config_{0}", outputFolder);
StepConfig uniqueUsersDaily = new StepConfig()
.WithName(configName)
.WithActionOnFailure("TERMINATE_JOB_FLOW")
.WithHadoopJarStep(config);
ScriptBootstrapActionConfig bootstrapActionScript = new ScriptBootstrapActionConfig()
.WithPath(configBootStrapScriptLocation);
BootstrapActionConfig bootstrapAction = new BootstrapActionConfig()
.WithName("CustomAction")
.WithScriptBootstrapAction(bootstrapActionScript);
string jobName = string.Format("Unique_User_DailyJob_{0}", outputFolder);
RunJobFlowRequest jobRequest = new RunJobFlowRequest()
.WithName(jobName)
.WithBootstrapActions(bootstrapAction)
.WithSteps(uniqueUsersDaily)
.WithLogUri(configHadoopLogLocation)
.WithInstances(new JobFlowInstancesConfig()
.WithHadoopVersion(configHadoopVersion)
.WithInstanceCount(2)
.WithKeepJobFlowAliveWhenNoSteps(false)
.WithMasterInstanceType(configMasterInstanceType)
.WithSlaveInstanceType(configSlaveInstanceType));

You can use withArgs() of ScriptBootstrapActionConfig, in Java you can do as follows, I am sure there is a similar method for C#:
ScriptBootstrapActionConfig bootstrapActionScript = new ScriptBootstrapActionConfig()
.WithPath(configBootStrapScriptLocation)
.WithArgs(List<String> args);

Related

Check if Unity Build Successfully or Not (UNITY C#)

Here's my script for building Programmatically
BuildPlayerOptions szBuildResult = new BuildPlayerOptions();
szBuildResult.scenes = scenes;
szBuildResult.locationPathName = m_szapkFileName;
szBuildResult.target = BuildTarget.StandaloneWindows;
szBuildResult.options = BuildOptions.None;
BuildPipeline.BuildPlayer(szBuildResult);
Now I tried to do something like this
string result = BuildPipeline.BuildPlayer(szBuildResult);
But it's returning me an error saying
Cannot convert type UnityEditor.Build.Reporting.BuildReport to string
How can i check if the build is successful or not?
I'm using Unity 2018.2
BuildPipeline.BuildPlayer will reutrn BuildReport object. so use BuildReport instead of string
BuildReport result = BuildPipeline.BuildPlayer(szBuildResult);

Disabling DHTMLX event_bar_date on ASP.net cs file

I am using DHTMLX nuget package and I'm trying to disable or hide the value on event_bar_date through my aspx.cs
sched.Templates.event_header = #"<span class='event_date'
{start_date:date(%g:%s %A)}</span><br></div>";
sched.Templates.event_bar_header = ???????
I found something like this but this but using JS file which Im not familiar with, I want it to be directly on my cs file
scheduler.templates.event_bar_date = function(start,end,ev){
return "• <b class ='disp_none'>"+scheduler.templates.event_date(start)+"</b> ";
};
You can do the same config in c#:
var scheduler = new DHXScheduler();
...
scheduler.Templates.event_bar_date = "• ";
http://scheduler-net.com/docs/options-and-templates.html#using_javascript_configuration_with_the_scheduler
You can wrap JS configuration into some function and tell DHXScheduler to call it to initialization on the client side, e.g.
JS:
window.app = {
configure: function () {
scheduler.attachEvent("onSchedulerReady", function () {
scheduler.templates.event_bar_date = function (start, end, ev) {
return "• ";
};
});
}
};
C#
var scheduler = new DHXScheduler();
scheduler.BeforeInit.Add("app.configure();");
Here is a complete demo, you might need to update nuget package of DHTMLX Scheduler in order to run it
https://s3.amazonaws.com/uploads.hipchat.com/15721/63476/GFsBPty6TaIz13o/schedulernetmonthdatetemplate.zip
Server-side configuration ( scheduler.Templates.event_bar_date = "• "; ) should also work, however seems like this particular template gets rewrited during initialization, that is a reason why i've put it definition into onSchedulerReady handler
http://docs.dhtmlx.com/scheduler/api__scheduler_onschedulerready_event.html

how to pass an interface to a method which accepts ITestCase type interface in C#?

I have a TestSuite (TFS object) object which calls an add method .This add method accepts ITestCase as an argument .This ITestCase interface has different methods and properties described at below link:
http://msdn.microsoft.com/en-us/library/dd984690
Now i want to pass ITestCase object which implements some of those methods mentioned at above link.
var ts = testPlan.TestSuites[i];
var testCase = ts.TestCases.Add(<ITestCase testcase>);
Assuming that you actually want to create a real test case, as opposed to a mock in a unit test (or similar), then this blog post has a code sample which creates one: http://www.ewaldhofman.nl/post/2009/12/11/TFS-SDK-2010-e28093-Part-5-e28093-Create-a-new-Test-Case-work-item.aspx.
Here's some hacked-together code that creates a new test case, based on the blog entry above, and then adds it to an existing test suite (called "ExampleSuite2", located in a test plan called "TfsVersioning Test Plan"):
var tfsUri = new Uri("http://localhost:8080/tfs/");
var tfsConfigServer = new TfsConfigurationServer(tfsUri, new UICredentialsProvider());
tfsConfigServer.EnsureAuthenticated();
var projCollectionNode = tfsConfigServer.CatalogNode.QueryChildren(new[] {CatalogResourceTypes.ProjectCollection}, false, CatalogQueryOptions.None).FirstOrDefault();
var collectionId = new Guid(projCollectionNode.Resource.Properties["InstanceId"]);
var projCollection = tfsConfigServer.GetTeamProjectCollection(collectionId);
ITestManagementService tms = projCollection.GetService<ITestManagementService>();
var project = tms.GetTeamProject("TfsVersioning");
var testCase = project.TestCases.Create();
testCase.Title = "Browse my blog";
var navigateToSiteStep = testCase.CreateTestStep();
navigateToSiteStep.Title = "Navigate to \"http://www.ewaldhofman.nl\"";
testCase.Actions.Add(navigateToSiteStep);
var clickOnFirstPostStep = testCase.CreateTestStep();
clickOnFirstPostStep.Title = "Click on the first post in the summary";
clickOnFirstPostStep.ExpectedResult = "The details of the post are visible";
testCase.Actions.Add(clickOnFirstPostStep);
testCase.Save();
//Add test case to an existing test suite
var plans = project.TestPlans.Query("SELECT * FROM TestPlan where PlanName = 'TfsVersioning Test Plan'");
var plan = plans.First();
var firstMatchingSuite = project.TestSuites.Query("SELECT * FROM TestSuite where Title = 'ExampleSuite2'").First();
((IStaticTestSuite)firstMatchingSuite).Entries.Add(testCase);
plan.Save();
After running this code the new test case appeared in MTM, associated with the target test suite.

Schedule SSIS Package using C#

What I want to do, is to schedule a SSIS package, using C#. the missing part is, how to tell the agent that this schedulare is for the SSIS package "X", Here is my code :
Server srv = new Server();
//Define an Operator object variable by supplying the Agent (parent JobServer object) and the name in the constructor.
Operator op = new Operator(srv.JobServer, "AC_Operator") { NetSendAddress = "Network1_PC" };
//Create the operator on the instance of SQL Server Agent.
op.Create();
//Define a Job object variable by supplying the Agent and the name arguments in the constructor and setting properties.
Job jb = new Job(srv.JobServer, "AC_Job");
//Specify which operator to inform and the completion action.
jb.OperatorToNetSend = "AC_Operator";
jb.NetSendLevel = CompletionAction.Always;
//Create the job on the instance of SQL Server Agent.
jb.Create();
//Define a JobStep object variable by supplying the parent job and name arguments in the constructor.
JobStep jbstp = new JobStep(jb, "AC_Job_Step");
jbstp.OnSuccessAction = StepCompletionAction.QuitWithSuccess;
jbstp.OnFailAction = StepCompletionAction.QuitWithFailure;
//Create the job step on the instance of SQL Agent.
jbstp.Create();
//Define a JobSchedule object variable by supplying the parent job and name arguments in the constructor.
JobSchedule jbsch = new JobSchedule(jb, "AC_Job_Schedule");
//Set properties to define the schedule frequency, and duration.
jbsch.FrequencyTypes = FrequencyTypes.Daily;
jbsch.FrequencySubDayTypes = FrequencySubDayTypes.Minute;
jbsch.FrequencySubDayInterval = 30;
TimeSpan ts1 = new TimeSpan(9, 0, 0);
jbsch.ActiveStartTimeOfDay = ts1;
TimeSpan ts2 = new TimeSpan(17, 0, 0);
jbsch.ActiveEndTimeOfDay = ts2;
jbsch.FrequencyInterval = 1;
DateTime d = new DateTime(2003, 1, 1);
jbsch.ActiveStartDate = d;
//Create the job schedule on the instance of SQL Agent.
jbsch.Create();
Thanks for your time.
What you are needing to do is set the jobstep's SubSystem and then build your Command. In comparing the .NET generated code to a SQL Agent created job, the only difference I noticed was the assignment of the DatabaseName property so I set that as well.
You'll also undoubtedly want to look at dtexec to figure out how to configure and invoke your package or you can cheat like I do and use dtexecui or the Agent to build out the SET and other commands and then paste those in as the source command.
//Define a JobStep object variable by supplying the parent job and name arguments in the constructor.
JobStep jbstp = new JobStep(jb, "AC_Job_Step");
jbstp.OnSuccessAction = StepCompletionAction.QuitWithSuccess;
jbstp.OnFailAction = StepCompletionAction.QuitWithFailure;
string command = string.Empty;
command = #"/FILE ""C:\sandbox\SSISHackAndSlash2008\SSISHackAndSlash2008\EzAPI_Recipe01.dtsx"" /CHECKPOINTING OFF /REPORTING E";
jbstp.SubSystem = AgentSubSystem.Ssis;
jbstp.DatabaseName = "master";
jbstp.Command = command;
//Create the job step on the instance of SQL Agent.
jbstp.Create();

Passing MsBuild Command Line Arguments with BuildEngine

I have the following code to build a project from another C# app:
var buildEngine = new Engine();
buildEngine.RegisterLogger(new ConsoleLogger());
var success = buildEngine.BuildProjectFile(pathToCsProjFile);
if(!success)
{
Log.LogIt("On Noes! We Broke!");
}
else
{
Log.LogIt("It Worked!!!!!!");
}
Currently it builds the default configuration (Debug) but I want it to build the release version. If I were invoking MsBuild from the command line I would do something like:
C:\Windows\WinFX\v3.5>msbuild.exe *.proj /ToolsVersion:3.5 /p:Configuration=Release
How do I pass that configuration switch to the build engine?
You'll want to set the property, something like this should do the trick:
var pathToCsProjFile = "";
var buildEngine = new Engine();
var project = new Project(buildEngine);
project.Load(pathToCsProjFile);
project.SetProperty("Configuration", "Release");
var success = project.Build();
Use one of the other overloaded implementations of BuildProjectFile. I believe this one. Create a BuildPropertyGroup and add the properties you want. In this case 'Configuration' = 'Release'

Categories

Resources