コード例 #1
0
ファイル: Program.cs プロジェクト: SebastianNiebl/Timesheet
        public void Save(Piece[] pieces, Ticket[] tickets, Session session)
        {
            SessionContent content  = new SessionContent(tickets, pieces);
            string         jcontent = JsonConvert.SerializeObject(content, Formatting.Indented);

            File.WriteAllText(string.Format(".\\saves\\{0}.json", session.Name), jcontent);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: SebastianNiebl/Timesheet
        public ApplicationLayer Load(Session session)
        {
            string           jcontent = File.ReadAllText(string.Format(".\\saves\\{0}.json", session.Name));
            SessionContent   content  = JsonConvert.DeserializeObject <SessionContent>(jcontent);
            ApplicationLayer app      = new ApplicationLayer(content.tickets, content.pieces);

            Ticket[] closed = app.FilterTicketsBy((t) => t.Closed);
            if (closed != null)
            {
                foreach (Ticket ticket in closed)
                {
                    ticket.CalculateDuration(); //recalculate Durations
                }
            }
            return(app);
        }