Beispiel #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;
        }
Beispiel #2
0
        public string CreateTransportTask(string sTaskName, TransportReference oReference)
        {
            try
            {
                string sID = ((LoginAccount)Session["loggedInUser"]).AccountID;

                OptimizationTask oOT = new OptimizationTask()
                {
                    TaskID          = GenerateTaskID(),
                    IssuedOn        = DateTime.UtcNow,
                    Name            = sTaskName,
                    TaskStaus       = "available",
                    TaskType        = "transport",
                    IssuedBy        = sID,
                    Logs            = "",
                    Notes           = "",
                    ReferenceValues = oDF.ObjectToXmlString(oReference)
                };
                oDB.OptimizationTasks.Add(oOT);
                oDB.SaveChanges();
                return(oOT.TaskID);
            }
            catch
            {
                return("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");
            }
        }