///<summary>Gets the note for the given provider, if one exists. Otherwise, gets the proccode.defaultnote. ///Currently procStatus only supports TP or C statuses.</summary> public static string GetNote(long provNum, long codeNum, ProcStat procStatus, bool isGroupNote = false) { //No need to check RemotingRole; no call to db. List <ProcCodeNote> listProcCodeNotes = GetDeepCopy(); for (int i = 0; i < listProcCodeNotes.Count; i++) { if (listProcCodeNotes[i].ProvNum != provNum) { continue; } if (listProcCodeNotes[i].CodeNum != codeNum) { continue; } //Skip provider specific notes if this is a group note and the procedure is not complete // OR if this is NOT a group note and the procedure does not have the desired status. if ((isGroupNote && listProcCodeNotes[i].ProcStatus != ProcStat.C) || (!isGroupNote && listProcCodeNotes[i].ProcStatus != procStatus)) { continue; } return(listProcCodeNotes[i].Note); } //A provider specific procedure code note could not be found, use the default for the procedure code. if (procStatus == ProcStat.TP) { return(ProcedureCodes.GetProcCode(codeNum).DefaultTPNote); } return(ProcedureCodes.GetProcCode(codeNum).DefaultNote); }
public EraTestProcCodeData(string procCode, ProcStat procStatus, double procFee, DateTime procDateTime) { ProcCode = procCode; ProcStatus = procStatus; ProcFee = procFee; ProcDateTime = procDateTime; }
///<summary>Returns the proc</summary> ///<param name="procDate">If not included, will be set to DateTime.Now.</param> public static Procedure CreateProcedure(Patient pat, string procCodeStr, ProcStat procStatus, string toothNum, double procFee, DateTime procDate = default(DateTime), int priority = 0, long plannedAptNum = 0, long provNum = 0) { Procedure proc = new Procedure(); proc.CodeNum = ProcedureCodes.GetCodeNum(procCodeStr); proc.PatNum = pat.PatNum; if (procDate == default(DateTime)) { proc.ProcDate = DateTime.Today; } else { proc.ProcDate = procDate; } proc.ProcStatus = procStatus; proc.ProvNum = provNum; if (provNum == 0) { proc.ProvNum = pat.PriProv; } proc.ProcFee = procFee; proc.ToothNum = toothNum; proc.Prosthesis = "I"; proc.Priority = Defs.GetDefsForCategory(DefCat.TxPriorities, true)[priority].DefNum; proc.PlannedAptNum = plannedAptNum; proc.ClinicNum = pat.ClinicNum; Procedures.Insert(proc); return(proc); }
public void SInTests_SInEnum() { ProcStat procStatus = ProcStat.EC; int procStatusInt = (int)procStatus; Assert.AreEqual(procStatus, SIn.Enum <ProcStat>(procStatusInt)); }
public void ManPageExampleParsing() { string sample = "cpu 10132153 290696 3084719 46828483 16683 0 25195 0 175628 0"; var stat = ProcStat.FromLine(sample); Assert.Equal(10132153, stat.User); Assert.Equal(25195, stat.Softirq); }
public void ThrowOnInvalidData() { Assert.Throws <ArgumentNullException>(() => { ProcStat.FromLine(null); }); Assert.Throws <ArgumentException>(() => { ProcStat.FromLine(string.Empty); }); Assert.Throws <ArgumentException>(() => { ProcStat.FromLine(" "); }); Assert.Throws <ArgumentException>(() => { ProcStat.FromLine("cpu "); }); Assert.Throws <FormatException>(() => { ProcStat.FromLine("cpu invalid data"); }); }
public bool UpdateStatus(Process[] proc, int calcID, int time = 0) { ProcStat LastStatus = Status; IsPathExist = CheckPath(); if (!IsPathExist) { Status = ProcStat.NotExist; } else { Status = ProcStat.Rest; foreach (Process p in proc) { try { string path = Convert.ToString(p.MainModule.FileName); string pid = Convert.ToString(p.Id); if (String.Equals(path, ProcPath, StringComparison.OrdinalIgnoreCase)) { if (FirstPlayTime.Ticks == 0) { FirstPlayTime = DateTime.Now; } if (pid == calcID.ToString()) { Status = ProcStat.Focused; if (time != 0) { addTime(time); } return(true); } else { Status = ProcStat.Unfocused; } } } catch { } } } if (LastStatus == ProcStat.Focused || LastStatus == ProcStat.Unfocused) { if (Status == ProcStat.Rest || Status == ProcStat.NotExist) { LastPlayTime = DateTime.Now; return(true); } } return(false); }
public void ProcStatParsing() { string sample = "cpu 23294 0 8415 11690959 1078 0 923 0 0 0"; var stat = ProcStat.FromLine(sample); Assert.Equal(23294, stat.User); Assert.Equal(0, stat.Nice); Assert.Equal(8415, stat.System); Assert.Equal(11690959, stat.Idle); Assert.Equal(1078, stat.Iowait); Assert.Equal(0, stat.Irq); Assert.Equal(923, stat.Softirq); }
/// <summary>Returns the proc</summary> public static Procedure CreateProcedure(Patient pat,string procCodeStr,ProcStat procStatus,string toothNum,double procFee){ Procedure proc=new Procedure(); proc.CodeNum=ProcedureCodes.GetCodeNum(procCodeStr); proc.PatNum=pat.PatNum; proc.ProcDate=DateTime.Today; proc.ProcStatus=procStatus; proc.ProvNum=pat.PriProv; proc.ProcFee=procFee; proc.ToothNum=toothNum; proc.Prosthesis="I"; Procedures.Insert(proc); return proc; }
public void Average() { // real data extracted to validate the method // get data : head -n 1 /proc/stat // cpu stress on my 16 cores : stress -c 4 // compared with htop string first = "cpu 41389 68 12438 19810438 1167 0 1230 0 0 0"; string second = "cpu 44991 68 12448 19821179 1168 0 1276 0 0 0"; var cpuUsage = ProcStat.FromLine(first).AverageCpuWith(ProcStat.FromLine(second)); Assert.Equal(26, cpuUsage); }
/// <summary> /// Update Status, FirstPlayTime, LastPlayTime, totalPlayTime /// </summary> /// <param name="dic">dictionary of processes</param> /// <param name="running">always false</param> /// <param name="time">interval, usually 0 (at initialization) or 5</param> /// <returns></returns> public bool UpdateStatus2(Dictionary <String, bool> dic, ref bool running, int time = 0) { ProcStat LastStatus = Status; IsPathExist = CheckPath(); if (!IsPathExist) { // Condition: uninstalled Status = ProcStat.NotExist; } else { Status = ProcStat.Rest; if (dic.ContainsKey(ProcPath.ToLower())) { running = true; if (FirstPlayTime.Ticks == 0) { FirstPlayTime = DateTime.Now; } if (dic[ProcPath.ToLower()]) { // Condition: focused, then return Status = ProcStat.Focused; if (time != 0) { addTime(time); } return(true); } else { // Condition: unfocused Status = ProcStat.Unfocused; } } } if (LastStatus == ProcStat.Focused || LastStatus == ProcStat.Unfocused) { // Condition: last status is running, current status is not focused if (Status == ProcStat.Rest || Status == ProcStat.NotExist) { // Condition: current status is resting, then update LastPlayTime LastPlayTime = DateTime.Now; DisplaySettings.RestoreDisplay(this); return(true); } } return(false); }
/// <summary>Returns the proc</summary> public static Procedure CreateProcedure(Patient pat, string procCodeStr, ProcStat procStatus, string toothNum, double procFee) { Procedure proc = new Procedure(); proc.CodeNum = ProcedureCodes.GetCodeNum(procCodeStr); proc.PatNum = pat.PatNum; proc.ProcDate = DateTime.Today; proc.ProcStatus = procStatus; proc.ProvNum = pat.PriProv; proc.ProcFee = procFee; proc.ToothNum = toothNum; proc.Prosthesis = "I"; Procedures.Insert(proc); return(proc); }
// Process DataTable of records for batch / run and allocate ranges of records // for each process private void MTCalcRecsToProcess(DataTable dt) { // Calc number of processes needed for all records rowCount = dt.Rows.Count; procCount = rowCount / MTMaxRecsPerProc; procCount += (rowCount % MTMaxRecsPerProc == 0) ? 0 : 1; // Create array of process status classes processStatus = new ProcStat[procCount]; // For each process status in the array fill in values and presortid ranges for (int i = 0; i < processStatus.Length; i++) { // Create and Number the process processStatus[i] = new ProcStat(); processStatus[i].ProcNum = i; // Get presortIDs for start and end of ranges int ndx = MTMaxRecsPerProc * i; processStatus[i].RecStart = dt.Rows[ndx]["MPresortID"].ToString(); ndx += MTMaxRecsPerProc - 1; if (ndx > rowCount - 1) { ndx = rowCount - 1; } processStatus[i].RecEnd = dt.Rows[ndx]["MPresortID"].ToString(); // Initialize the rest of the process status processStatus[i].Started = false; processStatus[i].Ended = false; processStatus[i].Error = false; processStatus[i].ReturnCode = 0; processStatus[i].Batch = Batch; processStatus[i].Run = Run; processStatus[i].LetterType = Lettertype; processStatus[i].RunTime = string.Empty; } var tasks = (MTMaxParallelProcs > processStatus.Length) ? processStatus.Length : MTMaxParallelProcs; Log.Info(string.Format("MT Individual PDFs: {0} Worker runs, {1} in parallel", procCount, tasks)); if (WT != null) { WT.ReportProgress(-2, string.Format("MT Individual PDFs: {0} Worker runs, {1} in parallel", procCount, tasks)); } }
///<summary>Responsible for updating procedures in the group to "In Process" or "Not In Process", depending on the stat passed in. ///Also sends signal to cause cache refresh. Refreshes local cache for clients directly connected.</summary> public static void UpdateGroupForProc(long procNum, ProcStat stat) { //No need to check RemotingRole; no call to db. List <ProcMultiVisit> listPmvs = GetGroupsForProcsFromDb(procNum); ProcMultiVisit pmv = listPmvs.FirstOrDefault(x => x.ProcNum == procNum); if (pmv == null) { return; //Rare edge case. Might happen is someone deletes the procedure at the same time another person is updating it. } bool isGroupInProcessOld = IsGroupInProcess(listPmvs); if (stat == ProcStat.D) { //If the procedure is deleted, also delete the procvisitmulti to reduce clutter. listPmvs.Remove(pmv); //Remove pmv from listpmvs. if (pmv.ProcMultiVisitNum == pmv.GroupProcMultiVisitNum && !listPmvs.IsNullOrEmpty()) //If the group points to the pmv to be removed and the group still exists. { long replacementGPMVNum = listPmvs.First().ProcMultiVisitNum; UpdateGroupProcMultiVisitNumForGroup(pmv.ProcMultiVisitNum, replacementGPMVNum); foreach (ProcMultiVisit procMulti in listPmvs) //Replace all group numbers. { procMulti.GroupProcMultiVisitNum = replacementGPMVNum; } } Delete(pmv.ProcMultiVisitNum); } else { ProcMultiVisit oldPmv = pmv.Copy(); pmv.ProcStatus = stat; Update(pmv, oldPmv); } bool isGroupInProcess = IsGroupInProcess(listPmvs); if (isGroupInProcess != isGroupInProcessOld) { UpdateInProcessForGroup(pmv.GroupProcMultiVisitNum, isGroupInProcess); } //Always send a signal and refresh the cache in case someone else is going to edit the group soon. Signalods.SetInvalid(InvalidType.ProcMultiVisits); if (RemotingClient.RemotingRole == RemotingRole.ClientDirect) { RefreshCache(); } }
static Stat() { for (uint i = 0; i < procs.Length; i++) { procs[i] = new ProcStat(); } for (uint i = 0; i < mctrls.Length; i++) { mctrls[i] = new MemCtrlStat(i); } for (uint i = 0; i < busses.Length; i++) { busses[i] = new BusStat(i); } for (uint c = 0; c < Config.mem.chan_max; c++) { for (uint r = 0; r < Config.mem.rank_max; r++) { for (uint b = 0; b < Config.mem.bank_max; b++) { banks[c, r, b] = new BankStat(c, r, b); } } } // Shared cache if (Config.proc.shared_l2) { caches = new CacheStat[1]; } else { caches = new CacheStat[Config.N]; } for (int i = 0; i < caches.Length; i++) { caches[i] = new CacheStat(); } }
public static ProcStat ProcStatusParse(string procStat) { ProcStat retval = ProcStat.TP; //default to TP status switch (procStat.ToLower()) { case "c": case "complete": retval = ProcStat.C; break; case "ec": case "existing current provider": retval = ProcStat.EC; break; case "eo": case "existing other provider": retval = ProcStat.EO; break; case "r": case "referred out": retval = ProcStat.R; break; case "cn": case "condition": retval = ProcStat.Cn; break; //case "tp"://not necessary, just default to TP if either of these values or if unsupported value //case "treatment planned": default: retval = ProcStat.TP; break; } return(retval); }
internal void reset() { proc = ProcStat.INIT; pow = PowerStat.UNKNOWN; ver = 0xff; }
private void radioEntryCn_CheckedChanged(object sender,EventArgs e) { newStatus=ProcStat.Cn; }
private void radioEntryR_CheckedChanged(object sender,System.EventArgs e) { newStatus=ProcStat.R; }
/// <summary> Checks ProcStat passed to see if one of the check boxes on the form contains a check for the ps passed. For example if ps is TP and the checkShowTP.Checked is true it will return true.</summary> private bool ProcStatDesired(ProcStat ps,bool isLocked) { switch(ps) { case ProcStat.TP: if(checkShowTP.Checked) { return true; } break; case ProcStat.C: if(checkShowC.Checked) { return true; } break; case ProcStat.EC: if(checkShowE.Checked) { return true; } break; case ProcStat.EO: if(checkShowE.Checked) { return true; } break; case ProcStat.R: if(checkShowR.Checked) { return true; } break; case ProcStat.D: if(checkAudit.Checked || (checkShowC.Checked && isLocked)) { return true; } break; case ProcStat.Cn: if(checkShowCn.Checked) { return true; } break; } //TODO: if proc Date is within show date range; return true; return false; }
// Start the MultiThreaded Processes private void StartMTProcs() { // First Queue all the Process Status objects for multithread processing for (int i = 0; i < processStatus.Length; i++) { processWorkQueue.Enqueue(processStatus[i]); } // Create the Task Array based on the max number of parallel processes config parm // but no more than total processes needed. var tasks = (MTMaxParallelProcs > processStatus.Length) ? processStatus.Length : MTMaxParallelProcs; processTasks = new Task[tasks]; // Create the Process array like the task array and init //taskProcess = new Process[MTMaxParallelProcs]; //for (int i = 0; i < taskProcess.Length; i++) taskProcess[i] = null; if (WT != null) { string text = string.Format("{0} Workers Done of {1}", interlockedWorkerDone, procCount); WT.ReportProgress(-1, text); } // For each of the max parallel processes, start a Task(thread) to process the queue for (int i = 0; i < processTasks.Length; i++) { // for each Task start the thread as a lambda processTasks[i] = Task.Factory.StartNew(() => { // while there are items in the queue process them while (processWorkQueue.Count > 0) { // Get next item from queue ProcStat procStatusItem; bool success = processWorkQueue.TryDequeue(out procStatusItem); // If got item from queue process it on our task number if (success) { // If cancel pending don't start another process if ((WT != null) && (WT.CancellationPending)) { continue; } Interlocked.Increment(ref interlockedWorkerStarted); RunProcess(procStatusItem); Interlocked.Increment(ref interlockedWorkerDone); if (WT != null) { string text = string.Format("Workers Done {0} of {1}", interlockedWorkerDone, procCount); int pcrecsdone = (interlockedWorkerDone * 100) / (procCount); LockedWT(pcrecsdone, text); } } } // No more items in queue, just end the Task }, TaskCreationOptions.LongRunning); } // Worker Thread, Wait for all Tasks to finish, catch any exceptions try { while (!Task.WaitAll(processTasks, 1000)) { Application.DoEvents(); } } catch (Exception ex) { Log.Error(string.Format("RunProcess: Error: {0}", ex.Message)); Log.Error(string.Format("RunProcess: Error: {0}", ex.StackTrace)); if (ex.InnerException != null) { Log.Error(string.Format("RunProcess: Inner Error: {0}", ex.InnerException.Message)); Log.Error(string.Format("RunProcess: Inner Error: {0}", ex.InnerException.StackTrace)); } } finally { // For each process status in the array Log status for (int i = 0; i < processStatus.Length; i++) { ProcStat ps = processStatus[i]; string s = string.Format("Worker: {0}, RC: {1}, Time: {2}", ps.ProcNum, ps.ReturnCode, ps.RunTime); Log.Info(s); } } }
///<summary>Returns index for sorting based on this order: Cn,TP,R,EO,EC,C,D</summary> private int GetProcStatusIdx(ProcStat procStat) { switch(procStat) { case ProcStat.Cn: return 0; case ProcStat.TP: return 1; case ProcStat.R: return 2; case ProcStat.EO: return 3; case ProcStat.EC: return 4; case ProcStat.C: return 5; case ProcStat.D: return 6; } return 0; }
public bool UpdateStatus(Process[] proc,int calcID,int time=0) { ProcStat LastStatus = Status; IsPathExist=CheckPath(); if (!IsPathExist) { Status = ProcStat.NotExist; } else { Status = ProcStat.Rest; foreach (Process p in proc) { try { string path = Convert.ToString(p.MainModule.FileName); string pid = Convert.ToString(p.Id); if (String.Equals(path,ProcPath,StringComparison.OrdinalIgnoreCase)) { if (FirstPlayTime.Ticks == 0) { FirstPlayTime = DateTime.Now; } if (pid == calcID.ToString()) { Status = ProcStat.Focused; if (time != 0) { addTime(time); } return true; } else { Status = ProcStat.Unfocused; } } } catch { } } } if (LastStatus == ProcStat.Focused || LastStatus == ProcStat.Unfocused) { if (Status == ProcStat.Rest || Status == ProcStat.NotExist) { LastPlayTime = DateTime.Now; return true; } } return false; }
public void Set(GameExecutionInfo t) { Title = t.Title; Brand = t.Brand; SaleDay = t.SaleDay; ErogameScapeID = t.ErogameScapeID; TotalPlayTime = t.TotalPlayTime; FirstPlayTime = t.FirstPlayTime; LastPlayTime = t.LastPlayTime; IsProcNEqExec = t.IsProcNEqExec; IsPathExist = t.IsPathExist; ExecPath = t.ExecPath; ProcPath = t.ProcPath; Status = t.Status; uid = t.uid; }
private void DrawProcsOfStatus(ProcStat procStat) { //this requires: ProcStatus, ADACode, ToothNum, Surf, and ToothRange. All need to be raw database values. string[] teeth; Color cLight = Color.White; Color cDark = Color.White; for (int i = 0; i < ProcList.Count; i++) { if (PIn.PInt(ProcList[i]["ProcStatus"].ToString()) != (int)procStat) { continue; } if (ProcedureCodes.GetProcCode(ProcList[i]["ADACode"].ToString()).PaintType == ToothPaintingType.Extraction && ( PIn.PInt(ProcList[i]["ProcStatus"].ToString()) == (int)ProcStat.C || PIn.PInt(ProcList[i]["ProcStatus"].ToString()) == (int)ProcStat.EC || PIn.PInt(ProcList[i]["ProcStatus"].ToString()) == (int)ProcStat.EO )) { continue; //prevents the red X. Missing teeth already handled. } if (ProcedureCodes.GetProcCode(ProcList[i]["ADACode"].ToString()).GraphicColor == Color.FromArgb(0)) { switch ((ProcStat)PIn.PInt(ProcList[i]["ProcStatus"].ToString())) { case ProcStat.C: cDark = DefB.Short[(int)DefCat.ChartGraphicColors][1].ItemColor; cLight = DefB.Short[(int)DefCat.ChartGraphicColors][6].ItemColor; break; case ProcStat.TP: cDark = DefB.Short[(int)DefCat.ChartGraphicColors][0].ItemColor; cLight = DefB.Short[(int)DefCat.ChartGraphicColors][5].ItemColor; break; case ProcStat.EC: cDark = DefB.Short[(int)DefCat.ChartGraphicColors][2].ItemColor; cLight = DefB.Short[(int)DefCat.ChartGraphicColors][7].ItemColor; break; case ProcStat.EO: cDark = DefB.Short[(int)DefCat.ChartGraphicColors][3].ItemColor; cLight = DefB.Short[(int)DefCat.ChartGraphicColors][8].ItemColor; break; case ProcStat.R: cDark = DefB.Short[(int)DefCat.ChartGraphicColors][4].ItemColor; cLight = DefB.Short[(int)DefCat.ChartGraphicColors][9].ItemColor; break; } } else { cDark = ProcedureCodes.GetProcCode(ProcList[i]["ADACode"].ToString()).GraphicColor; cLight = ProcedureCodes.GetProcCode(ProcList[i]["ADACode"].ToString()).GraphicColor; } switch (ProcedureCodes.GetProcCode(ProcList[i]["ADACode"].ToString()).PaintType) { case ToothPaintingType.BridgeDark: if (ToothInitials.ToothIsMissingOrHidden(ToothInitialList, ProcList[i]["ToothNum"].ToString())) { toothChart.SetPontic(ProcList[i]["ToothNum"].ToString(), cDark); } else { toothChart.SetCrown(ProcList[i]["ToothNum"].ToString(), cDark); } break; case ToothPaintingType.BridgeLight: if (ToothInitials.ToothIsMissingOrHidden(ToothInitialList, ProcList[i]["ToothNum"].ToString())) { toothChart.SetPontic(ProcList[i]["ToothNum"].ToString(), cLight); } else { toothChart.SetCrown(ProcList[i]["ToothNum"].ToString(), cLight); } break; case ToothPaintingType.CrownDark: toothChart.SetCrown(ProcList[i]["ToothNum"].ToString(), cDark); break; case ToothPaintingType.CrownLight: toothChart.SetCrown(ProcList[i]["ToothNum"].ToString(), cLight); break; case ToothPaintingType.DentureDark: if (ProcList[i]["Surf"].ToString() == "U") { teeth = new string[14]; for (int t = 0; t < 14; t++) { teeth[t] = (t + 2).ToString(); } } else if (ProcList[i]["Surf"].ToString() == "L") { teeth = new string[14]; for (int t = 0; t < 14; t++) { teeth[t] = (t + 18).ToString(); } } else { teeth = ProcList[i]["ToothRange"].ToString().Split(new char[] { ',' }); } for (int t = 0; t < teeth.Length; t++) { if (ToothInitials.ToothIsMissingOrHidden(ToothInitialList, teeth[t])) { toothChart.SetPontic(teeth[t], cDark); } else { toothChart.SetCrown(teeth[t], cDark); } } break; case ToothPaintingType.DentureLight: if (ProcList[i]["Surf"].ToString() == "U") { teeth = new string[14]; for (int t = 0; t < 14; t++) { teeth[t] = (t + 2).ToString(); } } else if (ProcList[i]["Surf"].ToString() == "L") { teeth = new string[14]; for (int t = 0; t < 14; t++) { teeth[t] = (t + 18).ToString(); } } else { teeth = ProcList[i]["ToothRange"].ToString().Split(new char[] { ',' }); } for (int t = 0; t < teeth.Length; t++) { if (ToothInitials.ToothIsMissingOrHidden(ToothInitialList, teeth[t])) { toothChart.SetPontic(teeth[t], cLight); } else { toothChart.SetCrown(teeth[t], cLight); } } break; case ToothPaintingType.Extraction: toothChart.SetBigX(ProcList[i]["ToothNum"].ToString(), cDark); break; case ToothPaintingType.FillingDark: toothChart.SetSurfaceColors(ProcList[i]["ToothNum"].ToString(), ProcList[i]["Surf"].ToString(), cDark); break; case ToothPaintingType.FillingLight: toothChart.SetSurfaceColors(ProcList[i]["ToothNum"].ToString(), ProcList[i]["Surf"].ToString(), cLight); break; case ToothPaintingType.Implant: toothChart.SetImplant(ProcList[i]["ToothNum"].ToString(), cDark); break; case ToothPaintingType.PostBU: toothChart.SetBU(ProcList[i]["ToothNum"].ToString(), cDark); break; case ToothPaintingType.RCT: toothChart.SetRCT(ProcList[i]["ToothNum"].ToString(), cDark); break; case ToothPaintingType.Sealant: toothChart.SetSealant(ProcList[i]["ToothNum"].ToString(), cDark); break; } } }
public bool UpdateStatus2(Dictionary<String, bool> dic,ref bool running,int time=0) { ProcStat LastStatus = Status; IsPathExist=CheckPath(); if (!IsPathExist) { Status = ProcStat.NotExist; } else { Status = ProcStat.Rest; if (dic.ContainsKey(ProcPath.ToLower())) { running = true; if (FirstPlayTime.Ticks == 0) { FirstPlayTime = DateTime.Now; } if (dic[ProcPath.ToLower()]) { Status = ProcStat.Focused; if (time != 0) { addTime(time); } return true; } else { Status = ProcStat.Unfocused; } } } if (LastStatus == ProcStat.Focused || LastStatus == ProcStat.Unfocused) { if (Status == ProcStat.Rest || Status == ProcStat.NotExist) { LastPlayTime = DateTime.Now; DisplaySettings.RestoreDisplay(this); return true; } } return false; }
// Start and wait for completion of an external process on a Task thread private int RunProcess(ProcStat ps) { int code = 0; Stopwatch sw = new Stopwatch(); sw.Start(); Process proc = new Process(); // Build command line arguments string parm = string.Format("Close=Auto Num={0} Start={1} End={2} Batch={3} Run={4} TestProd={5} RefID={6}", ps.ProcNum.ToString().Trim(), ps.RecStart.Trim(), ps.RecEnd.Trim(), ps.Batch.Trim(), ps.Run.Trim(), (UseTestDB) ? "TEST" : "PROD", refID.Trim()); if (!string.IsNullOrEmpty(ps.LetterType)) { parm = parm + string.Format(", Letter={0}", ps.LetterType.Trim()); } LockedLog("I", string.Format("RunProcess {0}: Starting: {1}", ps.ProcNum, parm)); // Start and wait for completion of External process try { ps.Started = true; // Configure the process using the StartInfo properties. proc.StartInfo.FileName = Path.Combine(Environment.CurrentDirectory, "ProcessWorker.exe"); proc.StartInfo.Arguments = parm; proc.StartInfo.WorkingDirectory = Environment.CurrentDirectory; //process.StartInfo.UseShellExecute = false; // Start the external process lock (LockProcessStart) { proc.Start(); Thread.Sleep(3000); } // Wait here for the process to exit. proc.WaitForExit(); // Retrieve the exit code code = proc.ExitCode; LockedLog("I", string.Format("ProcessWorker: {0}, Exit Code {1}", ps.ProcNum.ToString().Trim(), code)); ps.ReturnCode = code; ps.Ended = true; } catch (Exception ex) { LockedLog("E", string.Format("RunProcess {0}: Error: {1}", ps.ProcNum, ex.Message)); LockedLog("E", string.Format("RunProcess {0}: Error: {1}", ps.ProcNum, ex.StackTrace)); if (ex.InnerException != null) { LockedLog("E", string.Format("RunProcess {0}: Inner Error: {1}", ps.ProcNum, ex.InnerException.Message)); LockedLog("E", string.Format("RunProcess {0}: Inner Error: {1}", ps.ProcNum, ex.InnerException.StackTrace)); } } finally { proc.Close(); sw.Stop(); ps.RunTime = sw.Elapsed.ToString(@"hh\:mm\:ss\.f"); string text = string.Format("RunProcess {0}: Ending: Time: {1}", ps.ProcNum, sw.Elapsed.ToString(@"hh\:mm\:ss\.f")); LockedLog("I", text); } return(code); }
///<summary></summary> public void InitializeOnStartup(){ if(InitializedOnStartup) { return; } InitializedOnStartup=true; newStatus=ProcStat.TP; ChartLayoutHelper.InitializeOnStartup(this,tabProc,gridProg,panelEcw,tabControlImages,ClientSize,gridPtInfo,toothChart,textTreatmentNotes,butECWup,butECWdown,tabPatInfo); //can't use Lan.F Lan.C(this,new Control[]{ checkDone, butNew, butClear, checkShowTP, checkShowC, checkShowE, checkShowR, checkRx, checkNotes, labelDx, butM, butOI, butD, butL, butBF, butV, groupBox2, radioEntryTP, radioEntryC, radioEntryEC, radioEntryEO, radioEntryR, checkToday, labelDx, label6, butAddProc, label14, //textProcCode is handled in ClearButtons() butOK, label13, tabEnterTx, tabMissing, tabMovements, tabPrimary, tabPlanned, tabShow, tabDraw}, true); LayoutToolBar(); //ComputerPref localComputerPrefs=ComputerPrefs.GetForLocalComputer(); this.toothChart.DeviceFormat=new ToothChartDirectX.DirectXDeviceFormat(ComputerPrefs.LocalComputer.DirectXFormat); this.toothChart.DrawMode=ComputerPrefs.LocalComputer.GraphicsSimple;//triggers ResetControls. Plugins.HookAddCode(this,"ContrChart.InitializeOnStartup_end",PatCur); }