Ejemplo n.º 1
0
 public static List<Sprint> getSprints()
 {
     if (sprints == null)
     {
         sprints = new List<Sprint>();
         try
         {
             XmlReader reader = XmlReader.Create("Data/sprints.xml");
             reader.Read(); //read xml declaration
             reader.Read(); //read whitespace
             reader.Read();
             if (reader.NodeType != XmlNodeType.Element || reader.Name != "sprints")
             {
                 throw new XmlException("the first element should be sprints");
             }
             while (reader.Read())
             {
                 if (reader.NodeType == XmlNodeType.Element && reader.Name == "sprint")
                 {
                     Sprint s = new Sprint();
                     Debug.WriteLine("Reading a sprint");
                     string nextElement = "Undefined";
                     while (!(reader.NodeType == XmlNodeType.EndElement && reader.Name == "sprint") && reader.Read())
                     {
                         if (reader.NodeType == XmlNodeType.Element)
                         {
                             nextElement = reader.Name;
                         }
                         else if (reader.NodeType == XmlNodeType.EndElement)
                         {
                             nextElement = "Undefined";
                         }
                         else if (reader.NodeType == XmlNodeType.Text)
                         {
                             switch (nextElement)
                             {
                                 case "created-at":
                                     s.createdAt = DateTime.Parse(reader.Value);
                                     break;
                                 case "end-at":
                                     s.endAt = DateTime.Parse(reader.Value);
                                     break;
                                 case "id":
                                     s.id = int.Parse(reader.Value);
                                     break;
                                 case "name":
                                     s.name = reader.Value;
                                     break;
                                 case "project-id":
                                     s.projectId = int.Parse(reader.Value);
                                     break;
                                 case "start-at":
                                     s.startAt = DateTime.Parse(reader.Value);
                                     break;
                                 case "step":
                                     s.step = int.Parse(reader.Value);
                                     break;
                                 case "updated-at":
                                     s.updatedAt = DateTime.Parse(reader.Value);
                                     break;
                                 case "velocity":
                                     s.velocity = int.Parse(reader.Value);
                                     break;
                                 case "theorical-velocity":
                                     s.theoricalVelocity = int.Parse(reader.Value);
                                     break;
                             }
                         }
                     }//end while
                     sprints.Add(s);
                 }
             }
         }
         catch (XmlException Ex)
         {
             Debug.WriteLine("Erreur: " + Ex.Message);
         }
     }
     return sprints;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Create and add a sprint and its user stories
 /// </summary>
 public void LoadSprint(Sprint sp)
 {
     if (!Sprints.ContainsKey(sp.id))
     {
         this.IsDataLoaded = false;
         ObservableCollection<ItemViewModel> newCollection = new ObservableCollection<ItemViewModel>();
         foreach (Story st in DataProvider.getStories())
         {
             if (st.sprintId == sp.id)
             {
                 newCollection.Add(new ItemViewModel() { LineOne = st.name, LineTwo = st.status, LineThree = st.createdAt.ToShortDateString(), Id = st.id.ToString() });
             }
         }
         Sprints.Add(sp.id, newCollection);
         this.IsDataLoaded = true;
     }
 }