public void Print(Timeline timeline) { var timeLineHeader = _timeLineHeaderSupplier(); timeline.Index = timeLineHeader.LastIndex; TimelineDto timelineDto = this._mapper.Map <Timeline, TimelineDto>(timeline); Console.WriteLine(timelineDto.Time + ":" + timelineDto.Message); if (timeLineHeader.UserName == "") { timeLineHeader.UserName = "******"; } if (timeLineHeader.Status == TIMELINE_STATUS.FIRST) { var file = File.Create(timeLineHeader.TargetYaml); using (StreamWriter timelineWriter = new StreamWriter(file)) { timelineWriter.WriteLine("timelines:"); timelineWriter.WriteLine(" - timelines1:" + timelineDto.Time); timelineWriter.WriteLine(" {0}:{1}", timeLineHeader.UserName, timelineDto.Message); timelineWriter.Dispose(); } } else { using (StreamWriter timelineWriter2 = new StreamWriter(File.Open(timeLineHeader.TargetYaml, FileMode.Append))) { timelineWriter2.WriteLine(" - timelines{0}:{1}", ++(timeLineHeader.LastIndex), timelineDto.Time); timelineWriter2.WriteLine(" {0}:{1}", timeLineHeader.UserName, timelineDto.Message); timelineWriter2.Dispose(); } } }
public void Print(Timeline timeline) { TimelineDto timelineDto = this._mapper.Map <Timeline, TimelineDto>(timeline); Console.WriteLine(timelineDto.Time + ":" + timelineDto.Message); }