void Current_LogEvent(object sender, EventArgs e) { if (sender != null) { LogData.Add(sender.ToString()); } }
private void MergeLogActions(IEnumerable <LogAction> logActions) { foreach (var logAction in logActions) { LogData.Add(logAction); } listViewLog.ItemsSource = LogData; }
void Application_logMessageReceived(string condition, string stackTrace, LogType type) { string logLine = System.String.Format("[{0}]:{1}", type.ToString(), condition); logLine += "\n"; LogData.Add(logLine); if (LogData.Count > 10) { LogData.RemoveAt(0); } LogDataDital = ""; foreach (var item in LogData) { LogDataDital += item; } }
private void _endTask() { if (!duringTask) { return; } duringTask = false; _log.Add(taskCounter, taskStartTime, (DateTime.Now - taskStartTime)); displayMessage.add("Task ended...", Color.yellow, displayEndTaskMessageTime); _canLogTunas = false; _logTunas.flush(); INFORM_BONSAI.start = 0; }
void ILogger.Log <TState>( LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter) { var format = formatter(state, exception)?.Trim(); lock (_sync) // Guard against tests with explicit concurrency { if (format != null) { if (_cancellationTokenSource != null) { _cancellationTokenSource.Cancel(); _cancellationTokenSource = null; } var commandLogData = state as DbCommandLogData; if (commandLogData != null) { var parameters = ""; if (commandLogData.Parameters.Any()) { parameters = string.Join( _newLine, commandLogData.Parameters .Select(p => $"{p.Name}: {p.FormatParameter(quoteValues: false)}")) + _newLine + _newLine; } SqlStatements.Add(parameters + commandLogData.CommandText); LogData.Add(commandLogData); } else { LogBuilder.AppendLine(format); } TestOutputHelper?.WriteLine(format + Environment.NewLine); } } }
public static void BeginFrame(double frameTime) { if (frameTime <= CurrentFrameTime) { Clear(); } int oneHourDurationIdx = 0; foreach (FrameData frame in LogData) { if (frame.StartTime < frameTime - 3600) { ++oneHourDurationIdx; } else { break; } } if (oneHourDurationIdx > 0) { LogData.RemoveRange(0, oneHourDurationIdx); } D3DDevice.Device.ImmediateContext.Begin(_queryOcclusion); D3DDevice.Device.ImmediateContext.Begin(_queryPipelineStats); D3DDevice.Device.ImmediateContext.Begin(_queryTimeStampDisjoint); D3DDevice.Device.ImmediateContext.End(_queryTimeStampFrameBegin); CurrentFrameTime = frameTime; long memoryUsed = _currentProc.PrivateMemorySize64; var frameData = new FrameData() { StartTime = CurrentFrameTime, TimeBlocks = new List <DataEntry>(), PrivateMemory = (double)memoryUsed }; LogData.Add(frameData); IsWithinFrame = true; }
private void InsertRecord() { using (new WaitCursor()) { Log clsLog = new Log(); if (VerifyData() == true) { SetData(clsLog); Boolean bSucess = new Boolean(); bSucess = LogData.Add(clsLog); if (bSucess == true) { GoBack_To_Grid(); } else { MessageBox.Show("Insert failed.", "Error"); } } } }
private void UpdateLog() { // clear the previous visual data LogData.Clear(); // get the selectedTab int selectedTabIndex = LogTabControl.SelectedIndex; // if the selected tab is undefined, just return if (selectedTabIndex == -1) { return; } LogData.Add(GameState.GetLogEntry(0)); // add "Game Started." // for each index of the log, except for the first, see if we want to display it for (int i = 1; i < GameState.GetLogSize(); ++i) { // get the string we are considering -> s string s = GameState.GetLogEntry(i); // if "Me" is selected, check if the entry pertains to user, continue if doesn't if (selectedTabIndex == 1) { if (!s.Contains("You") && !s.Contains("Me")) { continue; } } // if a non-user player tab is selected else if (selectedTabIndex > 1) { // check if the entry contains their name, continue if doesn't if (!s.Contains(PlayersData[selectedTabIndex - 1])) { continue; } } // now check filters // if user only wants to see significant entries, and entry contains "significant", continue if (Filter1ToggleButton.IsChecked.Equals(true) && s.Contains("significant")) { continue; } // if user only wants to see entries pertaining to cards shown and entry does not contain // "showed", continue if (Filter2ToggleButton.IsChecked.Equals(true) && Filter3ToggleButton.IsChecked.Equals(false) && !s.Contains("showed")) { continue; } else if (Filter2ToggleButton.IsChecked.Equals(false) && Filter3ToggleButton.IsChecked.Equals(true) && !s.Contains("suggested")) { continue; } else if (Filter2ToggleButton.IsChecked.Equals(true) && Filter3ToggleButton.IsChecked.Equals(true) && (!s.Contains("suggested")) && (!s.Contains("showed"))) { continue; } // add the string since at this point we have done all our checking LogData.Add(s); } // scroll to the last entry for convenience LogListView.ScrollIntoView(LogListView.Items.GetItemAt(LogListView.Items.Count - 1)); }
public void Save() { List <JHSemesterScoreRecord> addSemsScore = new List <JHSemesterScoreRecord>(); List <JHSemesterScoreRecord> updateSemsScore = new List <JHSemesterScoreRecord>(); SubjectScoreLogFormater subjLogFormater = new SubjectScoreLogFormater(); DomainScoreLogFormater domainLogFormater = new DomainScoreLogFormater(); foreach (StudentScore student in Students) { #region 決定要新增還是更新。 JHSemesterScoreRecord JHScore = GetJHSemesterScore(student.Id, student.SemestersScore[SemesterData.Empty]); SCSemsScore SCScore = student.SemestersScore[SemesterData.Empty]; if (string.IsNullOrEmpty(JHScore.ID)) { addSemsScore.Add(JHScore); } else { updateSemsScore.Add(JHScore); } #endregion #region 產生科目資料。 JHScore.Subjects.Clear(); foreach (string strSubject in SCScore.Subject) { SemesterSubjectScore objSCSubject = SCScore.Subject[strSubject]; SubjectScore objJHSubject = GetJHSubjectScore(strSubject, objSCSubject); LogData subjLog = new LogData(strSubject); subjLog.Formater = subjLogFormater; decimal?score = objSCSubject.Value.HasValue ? (decimal?)(double)objSCSubject.Value : null; //記錄 Log subjLog.Add(new LogData("成績", objJHSubject.Score + "", score.ToString())); subjLog.Add(new LogData("權重", objJHSubject.Credit + "", objSCSubject.Weight + "")); subjLog.Add(new LogData("節數", objJHSubject.Period + "", objSCSubject.Period + "")); if (Program.Mode == ModuleMode.KaoHsiung) { subjLog.Add(new LogData("努力程度", objJHSubject.Effort + "", objSCSubject.Effort + "")); } subjLog.Add(new LogData("文字評量", objJHSubject.Text + "", objSCSubject.Text)); subjLog.Add(new LogData("領域", objJHSubject.Domain + "", objSCSubject.Domain)); SCScore.Subject.Log.Add(subjLog); objJHSubject.Score = score; objJHSubject.Credit = objSCSubject.Weight; objJHSubject.Period = objSCSubject.Period; objJHSubject.Effort = objSCSubject.Effort; objJHSubject.Text = objSCSubject.Text; objJHSubject.Domain = objSCSubject.Domain; JHScore.Subjects.Add(strSubject, objJHSubject); } //排序科目名稱。 Dictionary <string, SubjectScore> orderSubject = new Dictionary <string, SubjectScore>(JHScore.Subjects); JHScore.Subjects.Clear(); foreach (string subjName in Util.SortSubjectDomain(orderSubject.Keys)) { JHScore.Subjects.Add(subjName, orderSubject[subjName]); } #endregion #region 產生領域資料。 JHScore.Domains.Clear(); foreach (string strDomain in SCScore.Domain) { //彈性課程不記錄領域領域。 if (Util.IsVariableDomain(strDomain)) { continue; } SemesterDomainScore objSCDomain = SCScore.Domain[strDomain]; DomainScore objJHDomain = GetJHDomainScore(strDomain, objSCDomain); LogData domainLog = new LogData(strDomain); domainLog.Formater = subjLogFormater; decimal?score = objSCDomain.Value.HasValue ? (decimal?)(double)objSCDomain.Value : null; //記錄 Log domainLog.Add(new LogData("成績", objJHDomain.Score + "", score + "")); domainLog.Add(new LogData("權重", objJHDomain.Credit + "", objSCDomain.Weight + "")); domainLog.Add(new LogData("節數", objJHDomain.Period + "", objSCDomain.Period + "")); if (Program.Mode == ModuleMode.KaoHsiung) { domainLog.Add(new LogData("努力程度", objJHDomain.Effort + "", objSCDomain.Effort + "")); } domainLog.Add(new LogData("文字評量", objJHDomain.Text + "", objSCDomain.Text)); SCScore.Domain.Log.Add(domainLog); objJHDomain.Score = score; objJHDomain.Credit = objSCDomain.Weight; objJHDomain.Period = objSCDomain.Period; objJHDomain.Effort = objSCDomain.Effort; objJHDomain.Text = objSCDomain.Text; JHScore.Domains.Add(strDomain, objJHDomain); } //記錄 Log SCScore.LearningLog.Formater = domainLogFormater; SCScore.LearningLog.OriginValue = JHScore.CourseLearnScore + ""; SCScore.LearningLog.NewValue = SCScore.LearnDomainScore + ""; SCScore.CourseLog.Formater = domainLogFormater; SCScore.CourseLog.OriginValue = JHScore.CourseLearnScore + ""; SCScore.CourseLog.NewValue = SCScore.CourseLearnScore + ""; JHScore.LearnDomainScore = SCScore.LearnDomainScore; JHScore.CourseLearnScore = SCScore.CourseLearnScore; //排序領域名稱。 Dictionary <string, DomainScore> orderDomain = new Dictionary <string, DomainScore>(JHScore.Domains); JHScore.Domains.Clear(); foreach (string domainName in Util.SortSubjectDomain(orderDomain.Keys)) { JHScore.Domains.Add(domainName, orderDomain[domainName]); } #endregion } #region 新增科目成績 FunctionSpliter <JHSemesterScoreRecord, JHSemesterScoreRecord> addSpliter = new FunctionSpliter <JHSemesterScoreRecord, JHSemesterScoreRecord>(500, 5); addSpliter.Function = delegate(List <JHSemesterScoreRecord> part) { // 加入檢查當科目與領域成績筆數0不新增 List <JHSemesterScoreRecord> insertPart = new List <JHSemesterScoreRecord> (); foreach (JHSemesterScoreRecord rec in part) { // 沒有任何領域或科目成績 if (rec.Domains.Count == 0 && rec.Subjects.Count == 0) { continue; } insertPart.Add(rec); } if (insertPart.Count > 0) { JHSemesterScore.Insert(insertPart); } return(new List <JHSemesterScoreRecord>()); }; addSpliter.ProgressChange = delegate(int progress) { Reporter.Feedback("新增科目成績...", Util.CalculatePercentage(addSemsScore.Count, progress)); }; addSpliter.Execute(addSemsScore); #endregion #region 更新科目成績 FunctionSpliter <JHSemesterScoreRecord, JHSemesterScoreRecord> updateSpliter = new FunctionSpliter <JHSemesterScoreRecord, JHSemesterScoreRecord>(500, 5); updateSpliter.Function = delegate(List <JHSemesterScoreRecord> part) { JHSemesterScore.Update(part); return(new List <JHSemesterScoreRecord>()); }; updateSpliter.ProgressChange = delegate(int progress) { Reporter.Feedback("更新科目成績...", Util.CalculatePercentage(updateSemsScore.Count, progress)); }; updateSpliter.Execute(updateSemsScore); #endregion }
private async void TailFileAsync() { //https://www.codeproject.com/Articles/7568/Tail-NET using (StreamReader reader = new StreamReader(new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) { string line = string.Empty; #if STANDALONE while ((line = reader.ReadLine()) != null) { await Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { LogData.Add(new LogEntry() { Entry = line }); })); } NotifyPropertyChanged("LogData"); NotifyPropertyChanged("LogViewSource"); #else // read the existing file content ThreadHelper.JoinableTaskFactory.Run(async delegate { while ((line = await reader.ReadLineAsync()) != null) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); // Switch to main thread LogData.Add(new LogEntry() { Entry = line }); //NotifyPropertyChanged("LogData"); } NotifyPropertyChanged("LogData"); }); #endif long EOFPosition = reader.BaseStream.Length; // tail the file while (Running) { Thread.Sleep(FILE_READ_DELAY); if (reader.BaseStream.Length == EOFPosition) { continue; } reader.BaseStream.Seek(EOFPosition, SeekOrigin.Begin); #if STANDALONE while ((line = reader.ReadLine()) != null) { await Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { LogData.Add(new LogEntry() { Entry = line }); })); } NotifyPropertyChanged("LogViewSource"); #else while ((line = reader.ReadLine()) != null) { //Console.WriteLine(line); ThreadHelper.JoinableTaskFactory.Run(async delegate { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); // Switch to main thread LogData.Add(new LogEntry() { Entry = line }); //NotifyPropertyChanged("LogData"); }); } #endif EOFPosition = reader.BaseStream.Position; } } }
/// <summary> /// 組み込み関数を実行する。 /// </summary> /// <param name="name">名前</param> /// <param name="args">引数</param> /// <param name="at">int型@作用素</param> /// <param name="ats">string型@作用素</param> /// <returns></returns> public override Value Invoke(string name, Value[] args, int at, string ats) { if (args.Length == 0) { switch (name) { case "CodeList": var codeList = new Value[BrandList.List.Count]; for (var i = 0; i < codeList.Length; i++) { codeList[i] = new Value(BrandList.List[i]); } return(new Value(codeList)); default: return(base.Invoke(name, args, at, ats)); } } var brand = Brand; if (ats != null) { if (!GlobalEnv.BrandData.Contains(ats)) { throw new RuntimeException("missing brand code " + ats, null); } brand = GlobalEnv.BrandData[ats]; } string msg; if (args.Length == 1) { var prefix = ""; switch (name) { case "Print": break; case "PrintLog": prefix = string.Format( "{0} {1} {2} ", brand.Code, brand.Name, Prices[Index + at].Date.ToString("yy/MM/dd")); break; default: return(base.Invoke(name, args, at, ats)); } if (args[0] == null) { msg = "null"; } else if (args[0].ValueType == Value.Type.Array) { throw new RuntimeException("wrong type argument for " + name + "(1)", null); } else { msg = args[0].InnerValue.ToString(); } AppendText(prefix + msg + "\r\n"); return(null); } if (args.Length != 2) { return(base.Invoke(name, args, at, ats)); } var log = new Log { Date = Prices[Index + at].Date, Code = brand.Code, Price = (int)args[0].InnerValue, Quantity = (int)args[1].InnerValue }; msg = string.Format("{0} {1} {2} {3}円 {4}株 ", brand.Code, brand.Name, log.Date.ToString("yy/MM/dd"), log.Price, log.Quantity); switch (name) { case "Buy": log.Order = Order.Buy; LogData.Add(log); // if (!LogData.Add(log)) // throw new RuntimeException("同日の売買があります。", null); msg += "買\r\n"; break; case "Sell": log.Order = Order.Sell; LogData.Add(log); // if (!LogData.Add(log)) // throw new RuntimeException("同日の売買があります。", null); msg += "売\r\n"; break; default: return(base.Invoke(name, args, at, ats)); } AppendText(msg); return(null); }