static List <OutputObject> ExtractValuesObject(string jsonStr) { try { List <OutputObject> listOutput = new List <OutputObject>(); var objects = JObject.Parse(JObject.Parse(jsonStr)["Results"].ToString()); foreach (var output in objects) { OutputObject tmpOutput = new OutputObject(); tmpOutput.Name = output.Key; JArray outputArray = JArray.Parse(output.Value["value"]["Values"][0].ToString()); foreach (var outputValue in outputArray) { tmpOutput.Values.Add(outputValue.ToString()); } listOutput.Add(tmpOutput); } return(listOutput); } catch (Exception) { return(null); } }
public OutputObject DateOfBirthValidation(string input) { var output = new OutputObject(); if (!DateTime.TryParse(input, out var datetime)) { output.ErrorMessage = "Failed parsing to format dd-mm-yyyy!"; return(output); } output.Value = datetime; return(output); }
public OutputObject PersonalIdValidation(string input) { var output = new OutputObject(); if (!ulong.TryParse(input, out var personalId)) { output.ErrorMessage = "Number is invalid!"; return(output); } output.Value = personalId; return(output); }
public OutputObject BloodTypeValidation(string input, List <BloodType> bloodTypes) { var output = new OutputObject(); if (!int.TryParse(input, out var value) || value < 0 || value > bloodTypes.Count - 1) { output.ErrorMessage = "Invalid index inserted."; return(output); } output.Value = new BloodInfo { BloodType = bloodTypes.ElementAt(value - 1) }; return(output); }
protected void btnSubmit_Click(object sender, EventArgs e) { try { //Dictionary<string, string> featureList = getColumnsAndValues(); //if (featureList == null || featureList.Count == 0) return; // Blob contain input file. Get from Input Information string Account_Name = txtAccountName_blob.Text; string Account_Key = txtAccountKey_blob.Text; string container = txtContainer_blob.Text; string inputBlobName = txtBlobName.Text; // Blob store output. Get from Azure Blob information OutputObject output = new OutputObject { AccountName = txtAccountName.Text, AccountKey = txtAccountKey.Text, Container = txtContainer.Text, isAddTime = false, NodeOutputName = new Dictionary <string, string>() }; foreach (var batchOutput in paramObj.listBatchOutputs) { output.NodeOutputName.Add(batchOutput.Name, string.IsNullOrEmpty(batchOutput.Alias) ? batchOutput.Name : batchOutput.Alias); } string filePath = _fileUpload.FileName; if (!input_radio_File.Checked) { filePath = null; } InvokeBatchExecutionService(Account_Name, Account_Key, container, inputBlobName, filePath, output).Wait(); } catch (Exception ex) { //txtresultModal.Text = ex.Message; //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "failModal", "$('#failModal').modal();", true); ShowError(ex.Message); } }
public override Task WriteAsync(OutputFormatterWriteContext context) { object data; if (context.Object is IEnumerable <object> list) { data = list.Select(o => new OutputObject(o) { Links = _linkService.GetLinks(o) }); } else { data = new OutputObject(context.Object) { Links = _linkService.GetLinks(context.Object) } }; return(base.WriteAsync(new OutputFormatterWriteContext(context.HttpContext, context.WriterFactory, typeof(OutputObject), data))); } }
private void button5_Click(object sender, EventArgs e) { string InputXlPath = textBox1.Text; string OutputXlPath = textBox2.Text; bool RunAllTestCases = false; if (RunAllCases.Checked) { RunAllTestCases = true; } if (InputXlPath == "") { MessageBox.Show("Please provide Input Excel Path"); return; } else if (File.Exists(InputXlPath) == false) { MessageBox.Show("Can not find Input Excel. Please enter a valid Input Excel Path"); return; } if (OutputXlPath == "") { MessageBox.Show("Please provide Output Excel Path"); return; } else if (Directory.Exists(OutputXlPath) == false) { MessageBox.Show("Can not find Output Excel folder. Please enter a valid Output Excel folder"); return; } OutputObject outputObject = new OutputObject(); if (textBox3.Text == "") { MessageBox.Show("Please provide Output SQL Server Name"); return; } outputObject.OutPutServerName = textBox3.Text; if (textBox4.Text == "") { MessageBox.Show("Please provide Output SQL Login"); return; } outputObject.OutPutUserName = textBox4.Text; if (textBox5.Text == "") { MessageBox.Show("Please provide Output SQL Password"); return; } outputObject.OutPutPass = textBox5.Text; if (textBox6.Text == "") { MessageBox.Show("Please provide Output Database"); return; } outputObject.OutPutDataBase = textBox6.Text; SqlConnection conn = new SqlConnection(); try { conn.ConnectionString = "Server=" + outputObject.OutPutServerName + ";Database=" + outputObject.OutPutDataBase + ";User Id=" + outputObject.OutPutUserName + ";Password="******"Invalid Output SQL Connection. Please check your SQL info. \n Error :" + E.Message); return; } finally { conn.Close(); } automation = new RMS.NGFMAutomation.LoopEvents.NGFMAutomation(InputXlPath, OutputXlPath, outputObject); try { automation.Run(RunAllTestCases); } catch (InvalidDataException invalidE) { MessageBox.Show(invalidE.Message); return; } MessageBox.Show("Automation Run Completed! Please check Output Excel and SQL Database for results."); Application.Exit(); }
async Task InvokeBatchExecutionService(string accountNameInput, string accountKeyInput, string containerInput, string inputBlobName, string inputFileName, OutputObject outputObj) { // Upload file to Blob if pathFile given if (isHasInput && input_radio_File.Checked) { accountNameInput = outputObj.AccountName; if (string.IsNullOrEmpty(accountNameInput)) { //Console.WriteLine("Upload Error"); ShowError("Please enter Account Name"); return; } accountKeyInput = outputObj.AccountKey; if (string.IsNullOrEmpty(accountKeyInput)) { //Console.WriteLine("Upload Error"); ShowError("Please enter Account Key"); return; } containerInput = outputObj.Container; if (string.IsNullOrEmpty(containerInput)) { //Console.WriteLine("Upload Error"); ShowError("Please enter Container Name"); return; } if (string.IsNullOrEmpty(_fileUpload.FileName)) { //Console.WriteLine("Upload Error"); ShowError("Please choose input file"); return; } inputBlobName = inputFileName; //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "disable", "$(\"#btnclear\").prop(\"disabled\",true);", true); bool uploadresult = await uploadBigFile(accountNameInput, accountKeyInput, containerInput, inputFileName); //$("#btnclear").prop("disabled",true) if (!uploadresult) { //Console.WriteLine("Upload Error"); ShowError("Upload Error"); return; } } // First collect and fill in the URI and access key for your web service endpoint. // These are available on your service's API help page. var endpointUri = paramObj.Url; string accessKey = Crypto.DecryptStringAES(paramObj.APIKey); // Create an Azure Machine Learning runtime client for this endpoint var runtimeClient = new RuntimeClient(endpointUri, accessKey); // Define the request information for your batch job. This information can contain: // -- A reference to the AzureBlob containing the input for your job run // -- A set of values for global parameters defined as part of your experiment and service // -- A set of output blob locations that allow you to redirect the job's results // NOTE: This sample is applicable, as is, for a service with explicit input port and // potential global parameters. Also, we choose to also demo how you could override the // location of one of the output blobs that could be generated by your service. You might // need to tweak these features to adjust the sample to your service. // // All of these properties of a BatchJobRequest shown below can be optional, depending on // your service, so it is not required to specify all with any request. If you do not want to // use any of the parameters, a null value should be passed in its place. // Define the reference to the blob containing your input data. You can refer to this blob by its // connection string / container / blob name values; alternatively, we also support references // based on a blob SAS URI string ext = ".csv";//inputBlobName.Substring(inputBlobName.LastIndexOf(".")); BlobReference inputBlob; if (isHasInput) { inputBlob = BlobReference.CreateFromConnectionStringData( connectionString: string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", accountNameInput, accountKeyInput), containerName: containerInput, blobName: inputBlobName); ext = inputBlobName.Substring(inputBlobName.LastIndexOf(".")); } else { inputBlob = null; } // If desired, one can override the location where the job outputs are to be stored, by passing in // the storage account details and name of the blob where we want the output to be redirected to. var outputLocations = new Dictionary <string, BlobReference>(); foreach (var keyvalue in outputObj.NodeOutputName) { outputLocations.Add( keyvalue.Key, BlobReference.CreateFromConnectionStringData( connectionString: string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", outputObj.AccountName, outputObj.AccountKey), containerName: outputObj.Container, blobName: !outputObj.isAddTime ? keyvalue.Value + "_" + DateTime.Now.ToString("MMddyy_hhmmss") + ext : keyvalue.Value + ext )); } ; // If applicable, you can also set the global parameters for your service var globalParameters = new Dictionary <string, string>(); foreach (var global in paramObj.listGlobalParameter) { string columnValue = ""; var control = FindControl(global.Name); if (control is TextBox) { TextBox txt = control as TextBox; if (txt.Text != "") { columnValue = txt.Text; } } else if (control is DropDownList) { DropDownList lb = control as DropDownList; if (lb.SelectedIndex != -1) { columnValue = lb.SelectedValue; } } if (control is RadioButtonList) { RadioButtonList ct = control as RadioButtonList; if (ct.SelectedIndex != -1) { columnValue = ct.SelectedValue; } } globalParameters.Add(global.Name, columnValue); } var jobRequest = new BatchJobRequest { Input = inputBlob, GlobalParameters = globalParameters, Outputs = outputLocations }; try { // Register the batch job with the system, which will grant you access to a job object BatchJob job = await runtimeClient.RegisterBatchJobAsync(jobRequest); AddJobIdCookie(job.Id, job.CreatedAt.ToLocalTime().ToString()); // Start the job to allow it to be scheduled in the running queue await job.StartAsync(); //ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "window.open('Status.aspx?jobid=" + job.Id + "');", true); Response.Redirect("Status.aspx?jobid=" + job.Id); // Wait for the job's completion and handle the output //BatchJobStatus jobStatus = await job.WaitForCompletionAsync(); //while (job.CheckStatus().JobState != JobState.Finished && job.CheckStatus().JobState != JobState.Failed) //{ // Console.WriteLine(job.Id + ":" + job.CreatedAt.ToLocalTime() + job.CheckStatus().JobState); //} //BatchJobStatus jobStatus = job.CheckStatus(); ////job.CreatedAt //if (jobStatus.JobState == JobState.Finished) //{ // // Process job outputs // //Console.WriteLine(@"Job {0} has completed successfully and returned {1} outputs", job.Id, jobStatus.Results.Count); // lblJobIdSuccess.Text = job.Id; // ScriptManager.RegisterStartupScript(Page, Page.GetType(), "CompleteSuccess", "$('#CompleteSuccess').modal();", true); // foreach (var output in jobStatus.Results) // { // //Console.WriteLine(@"\t{0}: {1}", output.Key, output.Value.AbsoluteUri); // Response.Redirect(output.Value.AbsoluteUri); // } //} //else if (jobStatus.JobState == JobState.Failed) //{ // // Handle job failure // //Console.WriteLine(@"Job {0} has failed with this error: {1}", job.Id, jobStatus.Details); // txtresultModal.Text = jobStatus.Details; // ScriptManager.RegisterStartupScript(Page, Page.GetType(), "failModal", "$('#failModal').modal();", true); //} } catch (ArgumentException ex) { //Console.WriteLine("Argument {0} is invalid: {1}", aex.ParamName, aex.Message); //txtresultModal.Text = ex.Message; //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "failModal", "$('#failModal').modal();", true); ShowError(ex.Message); } catch (RuntimeException runtimeError) { //Console.WriteLine("Runtime error occurred: {0} - {1}", runtimeError.ErrorCode, runtimeError.Message); //Console.WriteLine("Error details:"); string error = ""; foreach (var errorDetails in runtimeError.Details) { error += string.Format("\t{0} - {1}", errorDetails.Code, errorDetails.Message); } //txtresultModal.Text = error; //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "failModal", "$('#failModal').modal();", true); ShowError(error); } catch (Exception ex) { //Console.WriteLine("Unexpected error occurred: {0} - {1}", ex.GetType().Name, ex.Message); //txtresultModal.Text = ex.Message; //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "failModal", "$('#failModal').modal();", true); ShowError(ex.Message); } }