public static Dictionary <string, object> GetJobDict(int id, bool verbose) { var dict = new Dictionary <string, Object>(); using (TurbineModelContainer container = new TurbineModelContainer()) { Turbine.Data.Job entity = container.Jobs.Single(s => s.Id == id); dict = GetJobRepresentation(entity, verbose); } return(dict); }
public void TestExcelSpreadsheet1() { var app = ApplicationProducerContract.Get("Excel"); Assert.IsNotNull(app); ISimulationProducerContract simulation_contract = AspenSimulationContract.Create("test", "Excel"); Assert.IsNotNull(simulation_contract); byte[] data; using (var fstream = File.Open(@"exceltest.xlsm", FileMode.Open)) { using (var ms = new MemoryStream()) { fstream.CopyTo(ms); data = ms.ToArray(); } } Assert.IsTrue(data.Length > 0); System.Threading.Thread.Sleep(10); simulation_contract.UpdateInput("spreadsheet", data, "plain/text"); data = null; using (var fstream = File.Open("exceltest-sinter.json", FileMode.Open)) { using (var ms = new MemoryStream()) { fstream.CopyTo(ms); data = ms.ToArray(); } } Assert.IsTrue(data.Length > 0); System.Threading.Thread.Sleep(10); simulation_contract.UpdateInput("configuration", data, "plain/text"); System.Threading.Thread.Sleep(10); var guid = Guid.NewGuid(); var job_producer_contract = simulation_contract.NewJob(guid, false, false); job_producer_contract.Process.Input = new Dictionary <string, Object>() { }; job_producer_contract.Submit(); System.Threading.Thread.Sleep(10); IConsumerRegistrationContract contract = Turbine.Consumer.AppUtility.GetConsumerRegistrationContract(); Assert.IsNull(contract.Queue); contract.Register(); Turbine.Consumer.Contract.SinterConsumer consumer = new Turbine.Consumer.Excel.ExcelSinterConsumer(); //Utility.CheckBaseDirectory(); consumer.Run(); int jobID = job_producer_contract.Id; Debug.WriteLine("Job GUID" + guid.ToString(), GetType().Name); Dictionary <string, Object> json = null; using (Turbine.Data.TurbineModelContainer container = new Turbine.Data.TurbineModelContainer()) { Turbine.Data.Job entity = container.Jobs.Single(s => s.Id == job_producer_contract.Id); json = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, Object> >(entity.Process.Output); } string output = Newtonsoft.Json.JsonConvert.SerializeObject(json); Debug.WriteLine("OUTPUT: " + output, GetType().Name); }