public void ProcessTask(TaskManager.TaskDetails oTask, out List <string> lsLogs, out string sOutput, out string sStatus) { // cast input values TransportReference oReference = new TransportReference(); oReference = (TransportReference)oDF.XmlStringToObject(oTask.ReferenceValues, oReference); TransportOutput oOutput = new TransportOutput(); // call processing algorithm GAMSWorkspace ws = new GAMSWorkspace(); // fill GAMSDatabase by reading from Access GAMSDatabase db = ReadFromDatabase(ws, oReference.Identifier); // run job using (GAMSOptions opt = ws.AddOptions()) { GAMSJob t9 = ws.AddJobFromString(GetModelText()); opt.Defines.Add("gdxincname", db.Name); opt.AllModelTypes = "xpress"; t9.Run(opt, db); foreach (GAMSVariableRecord rec in t9.OutDB.GetVariable("z")) { oOutput.TransportCost = rec.Level; } // write results into Access file WriteToDatabase(ws, t9.OutDB, oReference.Identifier); } // submit results sOutput = oDF.ObjectToXmlString(oOutput); sStatus = "completed"; lsLogs = lsLog; }
private void WorkerDoWork(object sender, DoWorkEventArgs e) { TaskManager.TaskDetails oTask = (TaskManager.TaskDetails)e.Argument; lsLog.Clear(); try { string sOutput = "", sStatus = ""; OptimizationAlgorithm oProcess = new OptimizationAlgorithm(); oProcess.ProcessTask(oTask, out lsLog, out sOutput, out sStatus); string sLogs = oDF.ObjectToXmlString(lsLog); oTM.SubmitResult(oTask.TaskID, sOutput, sLogs, sStatus); } catch (Exception ex) { lsLog.Add("Exception:" + ex.Message); string sLogs = oDF.ObjectToXmlString(lsLog); oTM.SubmitResult(oTask.TaskID, null, sLogs, "failed"); } }
private void TimerTick(object sender, EventArgs e) { if (IsTaskServerActive()) { // check for available tasks TaskManager.TaskDetails oTask = oTM.GetTask("TransportBot01", "transport"); if (oTask != null) { // if a task is available take it AddLogItem("Task Received : " + oTask.Name + ". Probing Stopped."); oTimer.Stop(); oWorker.RunWorkerAsync(oTask); } else { AddLogItem("No Tasks Available. Probing will continue."); } } else { AddLogItem("Task Server InAccessible. Probing will continue."); } }