コード例 #1
0
        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;
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Request["ID"].IsNull())
            {
                string sTaskID = Request["ID"].Trim();
                oTask = oDB.OptimizationTasks.Where(x => x.TaskID == sTaskID).FirstOrDefault();

                if (oTask != null)
                {
                    oReference = (TransportReference)oDF.XmlStringToObject(oTask.ReferenceValues, oReference);
                    oOutput    = (TransportOutput)oDF.XmlStringToObject(oTask.OutputValues, oOutput);
                    oLogs      = (List <string>)oDF.XmlStringToObject(oTask.Logs, oLogs);
                }
                else
                {
                    Response.Redirect("~/ListTasks.aspx");
                }
            }
            else
            {
                Response.Redirect("~/ListTasks.aspx");
            }
        }