public static void CancelJobs(IdaJob owner) { var n = 0; foreach (var job in JobList.Where(job => (job.MyIdaJob == owner))) { if (job.TheStatus == SingleRunJob.Status.Waiting) { n++; } job.TheStatus = SingleRunJob.Status.Cancelled; } AddJobs(owner.GetNextJobs(n)); //for (var i = 0; i < JobList.Count; i++) //{ // JobList[i].TheStatus = JobList[i].MyIdaJob == owner // ? SingleRunJob.Status.Cancelled // : JobList[i].TheStatus; //} }
public void SetIdaTableEntry(IdaJob idajob) { if (IdaTable.InvokeRequired == false) { var rowList = IdaTable.Rows.Cast <DataGridViewRow>().Where( ro => ((string)ro.Cells["Model"].Value == idajob.Model) && ((string)ro.Cells["Record"].Value == idajob.Record) && ((string)ro.Cells["Folder"].Value == idajob.ModelFolder) ).ToList(); DataGridViewRow row; if (rowList.Count > 0) { row = rowList[0]; } else { row = new DataGridViewRow(); row.Cells["Model"].Value = idajob.Model; row.Cells["Record"].Value = idajob.Record; row.Cells["Folder"].Value = idajob.ModelFolder; IdaGraphDic[idajob] = idajob.Graph; } row.Cells["Status"].Value = idajob.Status.ToString(); row.Cells["RunningJobs"].Value = idajob.Status.NRunningJobs; row.Cells["CompletedJobs"].Value = idajob.Status.NCompleteJobs; } else { var dlgt = new SetIdaTableEntryDelegate(SetIdaTableEntry); try { Invoke(dlgt, idajob); } catch { Thread.Sleep(1000); Invoke(dlgt, idajob); } } }
public static bool SetResultString(string result, out SingleRunJob job, out IdaPoint pnt) { // model record im edp endTime dvrgFlg job = null; pnt = null; var resList = result.Split(' ').ToList(); if (resList.Count < 2) { return(false); } var model = resList[0]; var rec = resList[1]; var im = Convert.ToDouble(resList[2]); job = JobPool.GetJob(model, rec, im); if (job.TheStatus != SingleRunJob.Status.Cancelled) { job.TheStatus = SingleRunJob.Status.Recieved; } else { job.TheStatus = SingleRunJob.Status.CancelRecieved; } pnt = new IdaPoint { Im = Convert.ToDouble(resList[2]), Edp = Convert.ToDouble(resList[3]), AnalysisEndTime = Convert.ToDouble(resList[4]), DivergFlag = Convert.ToInt16(resList[5]) != 0 }; IdaJob toDelete = null; var jobList = IdaJobPool.Where(idajob => idajob.Model == model && idajob.Record == rec).ToArray(); if (!jobList.Any()) { throw new Exception("IDAJob not found"); } var idaJob = jobList.ElementAt(0); bool cancel; bool deleteMe; idaJob.SetResult(job, pnt, out cancel, out deleteMe); if (cancel) { JobPool.CancelJobs(idaJob); } if (deleteMe) { toDelete = idaJob; Logger.LogIdaFinished(idaJob); } if (toDelete != null) { IdaJobPool.Remove(toDelete); if (LoadedJobsPool.Count == 0) { return(IdaJobPool.Count == 0); } IdaJobPool.Add(LoadedJobsPool[0]); LoadedJobsPool.RemoveAt(0); } return(IdaJobPool.Count == 0); }
public static void LogIdaFinished(IdaJob idaJob) { //Log("IDA (model= {idaJob.Model}, record= {idaJob.Record}) Finished"); }